@runfusion/fusion 0.17.0 → 0.17.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +1729 -789
- package/dist/client/assets/{AgentDetailView-DGqT1oDt.js → AgentDetailView-17J-F0Rl.js} +3 -3
- package/dist/client/assets/{AgentsView-BmemrfrO.js → AgentsView-sbBkb7Wd.js} +45 -45
- package/dist/client/assets/ChatView-BR5cvK_B.js +1 -0
- package/dist/client/assets/{DevServerView-C3Q0XqDA.js → DevServerView-GFFVXHVP.js} +1 -1
- package/dist/client/assets/{DirectoryPicker-BZWVA9ND.js → DirectoryPicker-WPDSBdT6.js} +1 -1
- package/dist/client/assets/{DocumentsView-DO48ivSq.js → DocumentsView-BHpDsIIt.js} +1 -1
- package/dist/client/assets/{InsightsView-CAngTfMf.js → InsightsView-Bxu0TJkt.js} +1 -1
- package/dist/client/assets/{MemoryView-B3rNcAOW.js → MemoryView-CmnzZorw.js} +2 -2
- package/dist/client/assets/{NodesView-BnV1LWa8.js → NodesView-CO9_4hCr.js} +4 -4
- package/dist/client/assets/{PiExtensionsManager-C3_Lw4sa.js → PiExtensionsManager-4e3MlD62.js} +3 -3
- package/dist/client/assets/{PluginManager-Vv3nzrJ1.js → PluginManager-DGN2rvOY.js} +1 -1
- package/dist/client/assets/ResearchView-Dsa6Gykl.js +1 -0
- package/dist/client/assets/{RoadmapsView-BiIpE-b8.js → RoadmapsView-jHTOK0RQ.js} +2 -2
- package/dist/client/assets/{SettingsModal-CK4w8Ztb.js → SettingsModal-4Z8ZJMzD.js} +1 -1
- package/dist/client/assets/SettingsModal-D0kuJpBA.js +31 -0
- package/dist/client/assets/{SetupWizardModal-Dw6N4UvY.js → SetupWizardModal-Bhumd4Rf.js} +1 -1
- package/dist/client/assets/{SkillsView-C1196wgA.js → SkillsView-MHweJTz4.js} +1 -1
- package/dist/client/assets/{folder-open-WVtgE4k3.js → folder-open-BNQW9dE9.js} +1 -1
- package/dist/client/assets/{index-BIJgrHEn.css → index-DEVBHvyW.css} +1 -1
- package/dist/client/assets/index-k_85J1DS.js +682 -0
- package/dist/client/assets/{star-MSImEC8V.js → star-7L86NZrT.js} +1 -1
- package/dist/client/assets/{upload-Dmvy3xXd.js → upload-DsAS6tno.js} +1 -1
- package/dist/client/assets/{users-CncYvHNf.js → users-D3u6f2Rz.js} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/client/version.json +1 -1
- package/dist/extension.js +1239 -527
- package/dist/pi-claude-cli/package.json +1 -1
- package/dist/plugins/fusion-plugin-dependency-graph/package.json +1 -1
- package/package.json +1 -1
- package/dist/client/assets/ChatView-CZQUBFlV.js +0 -1
- package/dist/client/assets/ResearchView-Dfdsuc21.js +0 -1
- package/dist/client/assets/SettingsModal-BN00HYJ2.js +0 -31
- package/dist/client/assets/index-Bv0TGzDH.js +0 -682
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/AgentDetailView-
|
|
2
|
-
import{c as Nt,A as Re,C as Ke,Z as
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/AgentDetailView-17J-F0Rl.js","assets/vendor-react-K0fH_qHe.js","assets/index-k_85J1DS.js","assets/vendor-xterm-DzcZoU0P.js","assets/vendor-xterm-LZoznX6r.css","assets/index-DEVBHvyW.css","assets/star-7L86NZrT.js","assets/AgentDetailView-yu8Xltqk.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{c as Nt,A as Re,C as Ke,Z as Rt,s as Pt,r as Ge,F as ct,f as _t,a as $t,b as It,B as dt,u as Ct,d as et,e as Ft,g as Lt,h as zt,i as Dt,j as ht,P as Ot,k as Ht,l as qt,m as Vt,n as Wt,o as Bt,p as Ut,q as Kt,t as Gt,v as pt,G as Qt,S as Jt,L as tt,T as nt,R as Qe,X as bt,w as Zt,x as Xt,y as vt,z as Yt,D as en,E as tn,H as nn,I as xe,J as at,K as an,M as sn,N as rn,O as ln,Q as on,U as cn,V as dn,W as Ne,Y as We,_ as ft,$ as st,a0 as un,a1 as mn,a2 as Be,a3 as gn,a4 as hn,a5 as pn,a6 as bn,a7 as vn}from"./index-k_85J1DS.js";import{r as n,j as e,a as fn}from"./vendor-react-K0fH_qHe.js";import{S as xn,r as yn}from"./AgentDetailView-17J-F0Rl.js";import{U as St}from"./upload-DsAS6tno.js";import{F as wn}from"./folder-open-BNQW9dE9.js";import"./vendor-xterm-DzcZoU0P.js";import"./star-7L86NZrT.js";/**
|
|
3
3
|
* @license lucide-react v1.7.0 - ISC
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the ISC license.
|
|
6
6
|
* See the LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/const
|
|
7
|
+
*/const jn=[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["rect",{x:"3",y:"4",width:"6",height:"6",rx:"1",key:"cif1o7"}]],kn=Nt("list-todo",jn);/**
|
|
8
8
|
* @license lucide-react v1.7.0 - ISC
|
|
9
9
|
*
|
|
10
10
|
* This source code is licensed under the ISC license.
|
|
11
11
|
* See the LICENSE file in the root directory of this source tree.
|
|
12
|
-
*/const kn=[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]],Nn=Nt("sliders-horizontal",kn);function xt(i){return typeof i=="number"&&Number.isFinite(i)?i:0}function Fe(i){return i.toLocaleString()}function In({agents:i}){const{rows:o,totalInputTokens:k,totalOutputTokens:u,totalTokens:c}=n.useMemo(()=>{const r=i.map(d=>{const p=xt(d.totalInputTokens),b=xt(d.totalOutputTokens);return{id:d.id,name:d.name,inputTokens:p,outputTokens:b,totalTokens:p+b}}).sort((d,p)=>p.totalTokens-d.totalTokens||d.name.localeCompare(p.name)||d.id.localeCompare(p.id));return{rows:r,totalInputTokens:r.reduce((d,p)=>d+p.inputTokens,0),totalOutputTokens:r.reduce((d,p)=>d+p.outputTokens,0),totalTokens:r.reduce((d,p)=>d+p.totalTokens,0)}},[i]),g=c>0;return e.jsxs("section",{className:"agent-token-stats-panel","aria-label":"Agent token usage statistics",children:[e.jsx("header",{className:"agent-token-stats-panel__header",children:e.jsx("h3",{className:"agent-token-stats-panel__title",children:"Token Usage by Agent"})}),e.jsxs("div",{className:"agent-token-stats-panel__totals",role:"list","aria-label":"Token usage totals",children:[e.jsxs("div",{className:"agent-token-stats-panel__total-card",role:"listitem",children:[e.jsx("span",{className:"agent-token-stats-panel__total-label",children:"Input Tokens"}),e.jsx("span",{className:"agent-token-stats-panel__total-value",children:Fe(k)})]}),e.jsxs("div",{className:"agent-token-stats-panel__total-card",role:"listitem",children:[e.jsx("span",{className:"agent-token-stats-panel__total-label",children:"Output Tokens"}),e.jsx("span",{className:"agent-token-stats-panel__total-value",children:Fe(u)})]}),e.jsxs("div",{className:"agent-token-stats-panel__total-card",role:"listitem",children:[e.jsx("span",{className:"agent-token-stats-panel__total-label",children:"Combined Tokens"}),e.jsx("span",{className:"agent-token-stats-panel__total-value",children:Fe(c)})]})]}),g?e.jsx("div",{className:"agent-token-stats-panel__table-wrapper",children:e.jsxs("table",{className:"agent-token-stats-panel__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:"Agent"}),e.jsx("th",{scope:"col",children:"Input"}),e.jsx("th",{scope:"col",children:"Output"}),e.jsx("th",{scope:"col",children:"Total"})]})}),e.jsx("tbody",{children:o.map(r=>e.jsxs("tr",{children:[e.jsxs("th",{scope:"row",className:"agent-token-stats-panel__agent-cell",children:[e.jsx("span",{className:"agent-token-stats-panel__agent-name",children:r.name}),e.jsx("span",{className:"agent-token-stats-panel__agent-id",children:r.id})]}),e.jsx("td",{children:Fe(r.inputTokens)}),e.jsx("td",{children:Fe(r.outputTokens)}),e.jsx("td",{className:"agent-token-stats-panel__total-cell",children:Fe(r.totalTokens)})]},r.id))})]})}):e.jsx("div",{className:"agent-token-stats-panel__empty",role:"status",children:"No token usage recorded yet. Token totals appear here once agents run."})]})}const Cn=[{icon:Re,label:"Active Agents",valueKey:"activeCount",className:"agent-metric-card--active"},{icon:jn,label:"Assigned Tasks",valueKey:"assignedTaskCount",className:"agent-metric-card--tasks"},{icon:Ke,label:"Success Rate",valueKey:"successRate",className:"agent-metric-card--success"},{icon:Mt,label:"Total Runs",valueKey:"completedRuns",className:"agent-metric-card--runs"}];function Sn({stats:i,className:o=""}){return i?e.jsx("div",{className:`agent-metrics-bar ${o}`.trim(),children:Cn.map(k=>{const u=k.valueKey==="successRate"?`${Math.round(i.successRate*100)}%`:i[k.valueKey];return e.jsxs("div",{className:`agent-metric-card ${k.className}`,children:[e.jsx(k.icon,{size:18}),e.jsxs("div",{className:"agent-metric-info",children:[e.jsx("span",{className:"agent-metric-value",children:u}),e.jsx("span",{className:"agent-metric-label",children:k.label})]})]},k.label)})}):null}const yt=200;function An(i,o){const[k,u]=n.useState([]),[c,g]=n.useState(!1),r=n.useRef(null),d=n.useRef(0),p=n.useRef(i),b=n.useRef(o);return(p.current!==i||b.current!==o)&&(p.current=i,b.current=o,d.current++,r.current&&(r.current(),r.current=null),u([]),g(!1)),n.useEffect(()=>{if(!i){u([]),g(!1);return}const y=d.current;let I=`/api/tasks/${encodeURIComponent(i)}/logs/stream`;o&&(I+=`?projectId=${encodeURIComponent(o)}`);const f=Rt(I,{events:{"agent:log":E=>{if(d.current===y)try{const R=JSON.parse(E.data),$={type:R.type??"text",text:R.text??R.content??"",timestamp:R.timestamp,content:R.content};u(j=>{const T=[$,...j];return T.length>yt?T.slice(0,yt):T})}catch{}}},onOpen:()=>{d.current===y&&g(!0)},onError:()=>{d.current===y&&g(!1)}});return r.current=f,()=>{f(),r.current=null,d.current===y&&g(!1)}},[i,o]),{entries:k,isConnected:c}}const En=5e3;function Tn({agent:i,projectId:o,onSelect:k,onOpenTaskLogs:u}){const{entries:c,isConnected:g}=An(i.taskId,o),[r,d]=n.useState(null);n.useEffect(()=>{if(!i.taskId){d(null);return}let j=!1,T;const h=async()=>{try{const M=await Pt(i.taskId,o);j||d(M)}catch{}finally{j||(T=setTimeout(h,En))}};return h(),()=>{j=!0,T&&clearTimeout(T)}},[i.taskId,o]);const p=i.lastHeartbeatAt?Math.floor((Date.now()-new Date(i.lastHeartbeatAt).getTime())/1e3):0,b=(()=>{if(!i.lastHeartbeatAt)return null;const j=Ge(i.runtimeConfig?.heartbeatIntervalMs),T=new Date(i.lastHeartbeatAt).getTime()+j,h=Math.round((T-Date.now())/1e3);return Number.isFinite(h)?h<=0?`Heartbeat overdue ${it(-h)}`:`Next heartbeat in ${it(h)}`:null})(),N=r?.steps?.[r.currentStep??0],y=r?.steps?.length??0,I=(r?.currentStep??0)+1,f=r?.modelId,E=()=>{k&&k(i.id)},R=j=>{j.stopPropagation(),i.taskId&&u&&u(i.taskId)},$=j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),E())};return e.jsxs("div",{className:"live-agent-card",onClick:E,onKeyDown:$,role:"button",tabIndex:0,"aria-label":`Select agent ${i.name}`,children:[e.jsxs("div",{className:"live-agent-card-header",children:[e.jsxs("div",{className:"live-agent-card-name",children:[e.jsx("span",{className:`status-dot ${i.state==="running"?"status-dot--pending":"status-dot--online"}`,"aria-hidden":"true"}),e.jsx("span",{children:i.name})]}),i.taskId&&e.jsx("span",{className:"live-agent-task badge",children:i.taskId})]}),e.jsx("div",{className:"live-agent-card-transcript",children:c.length===0?e.jsx("div",{className:"live-agent-card-empty",children:i.taskId?N?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"live-agent-card-status",children:["Step ",I,y?`/${y}`:"",": ",N.name]}),f&&e.jsx("div",{className:"live-agent-card-status-sub",children:f}),e.jsx("div",{className:"live-agent-card-status-sub",children:g?"Waiting for output...":"Connecting to log stream..."})]}):e.jsx("span",{children:g?"Waiting for output...":"Connecting..."}):e.jsx("span",{children:i.state==="running"?"Starting...":"Idle — no task assigned"})}):c.slice(0,20).map((j,T)=>e.jsx("div",{className:"live-agent-card-line",children:j.text},T))}),e.jsxs("div",{className:"live-agent-card-footer",children:[e.jsxs("div",{className:"live-agent-card-footer-meta",children:[e.jsx("span",{className:"text-secondary",title:"Time since last heartbeat",children:it(p)}),b&&e.jsx("span",{className:"live-agent-card-next-heartbeat",title:b,children:b})]}),e.jsxs("div",{className:"live-agent-card-footer-actions",children:[i.taskId&&u&&e.jsxs("button",{type:"button",className:"live-agent-card-logs-btn",onClick:R,title:"View live run logs","aria-label":`View live logs for ${i.taskId}`,children:[e.jsx(ct,{size:12}),e.jsx("span",{children:"Live logs"})]}),g&&e.jsx(Re,{size:12,className:"live-agent-streaming-dot"})]})]})]})}function it(i){return i<60?`${i}s`:i<3600?`${Math.floor(i/60)}m ${i%60}s`:`${Math.floor(i/3600)}h ${Math.floor(i%3600/60)}m`}function Mn({agents:i,projectId:o,onAgentSelect:k,onOpenTaskLogs:u,className:c=""}){const g=Array.from(new Map(i.map(r=>[r.id,r])).values());return g.length===0?null:e.jsxs("div",{className:`active-agents-panel ${c}`.trim(),children:[e.jsxs("div",{className:"active-agents-panel-header",children:[e.jsx(Re,{size:16}),e.jsxs("span",{children:["Active Agents (",g.length,")"]})]}),e.jsx("div",{className:"active-agents-grid",children:g.map(r=>e.jsx(Tn,{agent:r,projectId:o,onSelect:k,onOpenTaskLogs:u},r.id))})]})}function Rn({stats:i,activeAgents:o,projectId:k,isOpen:u,onToggle:c,onSelectAgent:g,onOpenTaskLogs:r}){return e.jsxs("section",{className:"agents-overview-bar","aria-label":"Agents overview",children:[e.jsxs("button",{type:"button",className:"agents-overview-bar__toggle","aria-expanded":u,onClick:c,children:[e.jsxs("span",{className:"agents-overview-bar__title-wrap",children:[u?e.jsx(_t,{size:16,"aria-hidden":"true"}):e.jsx(It,{size:16,"aria-hidden":"true"}),e.jsx("span",{className:"agents-overview-bar__title",children:"Overview"})]}),e.jsxs("span",{className:"agents-overview-bar__meta text-secondary",children:[i?.activeCount??0," active · ",o.length," running"]})]}),u?e.jsxs("div",{className:"agents-overview-bar__content",children:[e.jsx(Sn,{stats:i,className:"agents-overview-bar__metrics"}),e.jsx(Mn,{agents:o,projectId:k,onAgentSelect:g,onOpenTaskLogs:r,className:"agents-overview-bar__active-panel"})]}):null]})}function rt({title:i="No agents found",description:o="Create an agent to get started",ctaLabel:k="Create Agent",onCtaClick:u}){return e.jsxs("div",{className:"agent-empty",children:[e.jsx(dt,{size:48,opacity:.3,className:"agent-empty-state__icon"}),e.jsx("p",{className:"agent-empty-state__title",children:i}),e.jsx("p",{className:"agent-empty-state__description text-secondary",children:o}),u?e.jsx("button",{type:"button",className:"btn btn-task-create btn-sm",onClick:u,children:k}):null]})}const wt=3,lt=1e3;function Pn({isOpen:i,onClose:o,onGenerated:k,projectId:u}){const[c,g]=n.useState(""),[r,d]=n.useState({type:"input"}),[p,b]=n.useState(null),[N,y]=n.useState(!1),I=n.useRef(null),f=n.useRef(null);n.useEffect(()=>{i&&r.type==="input"&&f.current?.focus()},[i,r.type]),n.useEffect(()=>{if(!i&&I.current){const h=I.current;I.current=null,et(h,u).catch(()=>{})}},[i,u]),n.useEffect(()=>{if(!i)return;const h=M=>{M.key==="Escape"&&E()};return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[i]);const E=n.useCallback(()=>{if(I.current){const h=I.current;I.current=null,et(h,u).catch(()=>{})}g(""),d({type:"input"}),b(null),y(!1),o()},[o,u]),R=n.useCallback(async()=>{if(!(!c.trim()||c.trim().length<wt)){b(null),d({type:"loading"});try{const{sessionId:h}=await $t(c.trim(),u);I.current=h;const{spec:M}=await Ft(h,u);d({type:"preview",spec:M,sessionId:h})}catch(h){const M=h instanceof Error?h.message:"Failed to generate agent specification";M.includes("429")||M.toLowerCase().includes("rate limit")?b("Too many requests. Please wait a moment and try again."):b(M),d({type:"input"}),I.current=null}}},[c,u]),$=n.useCallback(async()=>{if(I.current){const h=I.current;I.current=null;try{await et(h,u)}catch{}}await R()},[R,u]),j=n.useCallback(()=>{r.type==="preview"&&(I.current=null,k(r.spec),g(""),d({type:"input"}),b(null),y(!1),o())},[r,k,o]);if(!i)return null;const T=c.trim().length>=wt&&c.trim().length<=lt;return e.jsx("div",{className:"agent-dialog-overlay",onClick:h=>{h.target===h.currentTarget&&E()},children:e.jsxs("div",{className:"agent-dialog",role:"dialog","aria-modal":"true","aria-label":"Generate agent with AI",children:[e.jsxs("div",{className:"agent-dialog-header",children:[e.jsxs("span",{className:"agent-dialog-header-title",children:[e.jsx("span",{className:"agent-dialog-header-sparkle",children:"✨"}),"Generate Agent"]}),e.jsx("button",{className:"modal-close",onClick:E,"aria-label":"Close",children:"×"})]}),e.jsxs("div",{className:"agent-dialog-body",children:[p&&e.jsx("div",{className:"agent-dialog-error-banner",children:p}),r.type==="input"&&e.jsxs("div",{children:[e.jsx("p",{className:"agent-dialog-info",children:"Describe your agent's role and the AI will generate a complete specification including system prompt, suggested configuration, and more."}),e.jsxs("div",{className:"agent-dialog-field",children:[e.jsx("label",{htmlFor:"agent-role-description",children:"Role Description"}),e.jsx("textarea",{ref:f,id:"agent-role-description",className:"input agent-dialog-textarea",rows:4,placeholder:'e.g. "Senior frontend code reviewer who specializes in React accessibility"',value:c,onChange:h=>g(h.target.value),onKeyDown:h=>{h.key==="Enter"&&!h.shiftKey&&T&&(h.preventDefault(),R())},maxLength:lt,"aria-describedby":"role-description-hint"}),e.jsxs("div",{id:"role-description-hint",className:"agent-dialog-hint",children:[e.jsx("span",{children:"Describe what your agent should do"}),e.jsxs("span",{children:[c.length,"/",lt]})]})]})]}),r.type==="loading"&&e.jsxs("div",{className:"agent-dialog-loading-center",children:[e.jsx("div",{className:"agent-dialog-spinner spin"}),e.jsx("p",{className:"agent-dialog-loading-text",children:"Generating agent specification..."})]}),r.type==="preview"&&e.jsxs("div",{children:[e.jsxs("div",{className:"agent-dialog-summary agent-dialog-summary--spaced",children:[e.jsxs("div",{className:"agent-dialog-summary-row",children:[e.jsx("span",{className:"agent-dialog-summary-row-label agent-dialog-summary-row-label--fixed",children:"Title"}),e.jsxs("span",{className:"agent-dialog-summary-row-value",children:[r.spec.icon," ",r.spec.title]})]}),e.jsxs("div",{className:"agent-dialog-summary-row",children:[e.jsx("span",{className:"agent-dialog-summary-row-label agent-dialog-summary-row-label--fixed",children:"Role"}),e.jsx("span",{children:r.spec.role})]}),e.jsxs("div",{className:"agent-dialog-summary-row",children:[e.jsx("span",{className:"agent-dialog-summary-row-label agent-dialog-summary-row-label--fixed",children:"Description"}),e.jsx("span",{className:"agent-dialog-summary-row-value agent-dialog-summary-row-value--body",children:r.spec.description})]}),e.jsxs("div",{className:"agent-dialog-summary-row",children:[e.jsx("span",{className:"agent-dialog-summary-row-label agent-dialog-summary-row-label--fixed",children:"Thinking"}),e.jsx("span",{className:"agent-dialog-summary-row-value agent-dialog-summary-row-value--capitalize",children:r.spec.thinkingLevel})]}),e.jsxs("div",{className:"agent-dialog-summary-row",children:[e.jsx("span",{className:"agent-dialog-summary-row-label agent-dialog-summary-row-label--fixed",children:"Max Turns"}),e.jsx("span",{children:r.spec.maxTurns})]})]}),e.jsxs("div",{className:"agent-dialog-field",children:[e.jsxs("label",{children:["System Prompt",e.jsx("button",{type:"button",className:"agent-dialog-expand-btn",onClick:()=>y(!N),children:N?"Collapse":"Expand"})]}),e.jsxs("div",{className:`agent-generation-prompt-box${N?"":" agent-generation-prompt-box--collapsed"}`,children:[r.spec.systemPrompt,!N&&r.spec.systemPrompt.length>500&&e.jsx("div",{className:"agent-generation-prompt-fade"})]})]})]})]}),e.jsxs("div",{className:"agent-dialog-footer",children:[e.jsx("button",{className:"btn",onClick:E,children:"Cancel"}),r.type==="input"&&e.jsx("button",{className:"btn btn-task-create",onClick:()=>void R(),disabled:!T,children:"Generate"}),r.type==="preview"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:()=>void $(),children:"Regenerate"}),e.jsx("button",{className:"btn btn-task-create",onClick:j,children:"Use This"})]})]})]})})}const _n=`# Soul: Chief Executive Officer
|
|
12
|
+
*/const Nn=[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]],In=Nt("sliders-horizontal",Nn);function xt(s){return typeof s=="number"&&Number.isFinite(s)?s:0}function Fe(s){return s.toLocaleString()}function Cn({agents:s}){const{rows:o,totalInputTokens:k,totalOutputTokens:u,totalTokens:c}=n.useMemo(()=>{const r=s.map(d=>{const p=xt(d.totalInputTokens),v=xt(d.totalOutputTokens);return{id:d.id,name:d.name,inputTokens:p,outputTokens:v,totalTokens:p+v}}).sort((d,p)=>p.totalTokens-d.totalTokens||d.name.localeCompare(p.name)||d.id.localeCompare(p.id));return{rows:r,totalInputTokens:r.reduce((d,p)=>d+p.inputTokens,0),totalOutputTokens:r.reduce((d,p)=>d+p.outputTokens,0),totalTokens:r.reduce((d,p)=>d+p.totalTokens,0)}},[s]),g=c>0;return e.jsxs("section",{className:"agent-token-stats-panel","aria-label":"Agent token usage statistics",children:[e.jsx("header",{className:"agent-token-stats-panel__header",children:e.jsx("h3",{className:"agent-token-stats-panel__title",children:"Token Usage by Agent"})}),e.jsxs("div",{className:"agent-token-stats-panel__totals",role:"list","aria-label":"Token usage totals",children:[e.jsxs("div",{className:"agent-token-stats-panel__total-card",role:"listitem",children:[e.jsx("span",{className:"agent-token-stats-panel__total-label",children:"Input Tokens"}),e.jsx("span",{className:"agent-token-stats-panel__total-value",children:Fe(k)})]}),e.jsxs("div",{className:"agent-token-stats-panel__total-card",role:"listitem",children:[e.jsx("span",{className:"agent-token-stats-panel__total-label",children:"Output Tokens"}),e.jsx("span",{className:"agent-token-stats-panel__total-value",children:Fe(u)})]}),e.jsxs("div",{className:"agent-token-stats-panel__total-card",role:"listitem",children:[e.jsx("span",{className:"agent-token-stats-panel__total-label",children:"Combined Tokens"}),e.jsx("span",{className:"agent-token-stats-panel__total-value",children:Fe(c)})]})]}),g?e.jsx("div",{className:"agent-token-stats-panel__table-wrapper",children:e.jsxs("table",{className:"agent-token-stats-panel__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:"Agent"}),e.jsx("th",{scope:"col",children:"Input"}),e.jsx("th",{scope:"col",children:"Output"}),e.jsx("th",{scope:"col",children:"Total"})]})}),e.jsx("tbody",{children:o.map(r=>e.jsxs("tr",{children:[e.jsxs("th",{scope:"row",className:"agent-token-stats-panel__agent-cell",children:[e.jsx("span",{className:"agent-token-stats-panel__agent-name",children:r.name}),e.jsx("span",{className:"agent-token-stats-panel__agent-id",children:r.id})]}),e.jsx("td",{children:Fe(r.inputTokens)}),e.jsx("td",{children:Fe(r.outputTokens)}),e.jsx("td",{className:"agent-token-stats-panel__total-cell",children:Fe(r.totalTokens)})]},r.id))})]})}):e.jsx("div",{className:"agent-token-stats-panel__empty",role:"status",children:"No token usage recorded yet. Token totals appear here once agents run."})]})}const Sn=[{icon:Re,label:"Active Agents",valueKey:"activeCount",className:"agent-metric-card--active"},{icon:kn,label:"Assigned Tasks",valueKey:"assignedTaskCount",className:"agent-metric-card--tasks"},{icon:Ke,label:"Success Rate",valueKey:"successRate",className:"agent-metric-card--success"},{icon:Rt,label:"Total Runs",valueKey:"completedRuns",className:"agent-metric-card--runs"}];function An({stats:s,className:o=""}){return s?e.jsx("div",{className:`agent-metrics-bar ${o}`.trim(),children:Sn.map(k=>{const u=k.valueKey==="successRate"?`${Math.round(s.successRate*100)}%`:s[k.valueKey];return e.jsxs("div",{className:`agent-metric-card ${k.className}`,children:[e.jsx(k.icon,{size:18}),e.jsxs("div",{className:"agent-metric-info",children:[e.jsx("span",{className:"agent-metric-value",children:u}),e.jsx("span",{className:"agent-metric-label",children:k.label})]})]},k.label)})}):null}const yt=200;function En(s,o){const[k,u]=n.useState([]),[c,g]=n.useState(!1),r=n.useRef(null),d=n.useRef(0),p=n.useRef(s),v=n.useRef(o);return(p.current!==s||v.current!==o)&&(p.current=s,v.current=o,d.current++,r.current&&(r.current(),r.current=null),u([]),g(!1)),n.useEffect(()=>{if(!s){u([]),g(!1);return}const y=d.current;let I=`/api/tasks/${encodeURIComponent(s)}/logs/stream`;o&&(I+=`?projectId=${encodeURIComponent(o)}`);const f=Pt(I,{events:{"agent:log":E=>{if(d.current===y)try{const R=JSON.parse(E.data),$={type:R.type??"text",text:R.text??R.content??"",timestamp:R.timestamp,content:R.content};u(j=>{const T=[$,...j];return T.length>yt?T.slice(0,yt):T})}catch{}}},onOpen:()=>{d.current===y&&g(!0)},onError:()=>{d.current===y&&g(!1)}});return r.current=f,()=>{f(),r.current=null,d.current===y&&g(!1)}},[s,o]),{entries:k,isConnected:c}}const Tn=5e3;function Mn({agent:s,projectId:o,onSelect:k,onOpenTaskLogs:u}){const{entries:c,isConnected:g}=En(s.taskId,o),[r,d]=n.useState(null);n.useEffect(()=>{if(!s.taskId){d(null);return}let j=!1,T;const h=async()=>{try{const M=await _t(s.taskId,o);j||d(M)}catch{}finally{j||(T=setTimeout(h,Tn))}};return h(),()=>{j=!0,T&&clearTimeout(T)}},[s.taskId,o]);const p=s.lastHeartbeatAt?Math.floor((Date.now()-new Date(s.lastHeartbeatAt).getTime())/1e3):0,v=(()=>{if(!s.lastHeartbeatAt)return null;const j=Ge(s.runtimeConfig?.heartbeatIntervalMs),T=new Date(s.lastHeartbeatAt).getTime()+j,h=Math.round((T-Date.now())/1e3);return Number.isFinite(h)?h<=0?`Heartbeat overdue ${it(-h)}`:`Next heartbeat in ${it(h)}`:null})(),N=r?.steps?.[r.currentStep??0],y=r?.steps?.length??0,I=(r?.currentStep??0)+1,f=r?.modelId,E=()=>{k&&k(s.id)},R=j=>{j.stopPropagation(),s.taskId&&u&&u(s.taskId)},$=j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),E())};return e.jsxs("div",{className:"live-agent-card",onClick:E,onKeyDown:$,role:"button",tabIndex:0,"aria-label":`Select agent ${s.name}`,children:[e.jsxs("div",{className:"live-agent-card-header",children:[e.jsxs("div",{className:"live-agent-card-name",children:[e.jsx("span",{className:`status-dot ${s.state==="running"?"status-dot--pending":"status-dot--online"}`,"aria-hidden":"true"}),e.jsx("span",{children:s.name})]}),s.taskId&&e.jsx("span",{className:"live-agent-task badge",children:s.taskId})]}),e.jsx("div",{className:"live-agent-card-transcript",children:c.length===0?e.jsx("div",{className:"live-agent-card-empty",children:s.taskId?N?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"live-agent-card-status",children:["Step ",I,y?`/${y}`:"",": ",N.name]}),f&&e.jsx("div",{className:"live-agent-card-status-sub",children:f}),e.jsx("div",{className:"live-agent-card-status-sub",children:g?"Waiting for output...":"Connecting to log stream..."})]}):e.jsx("span",{children:g?"Waiting for output...":"Connecting..."}):e.jsx("span",{children:s.state==="running"?"Starting...":"Idle — no task assigned"})}):c.slice(0,20).map((j,T)=>e.jsx("div",{className:"live-agent-card-line",children:j.text},T))}),e.jsxs("div",{className:"live-agent-card-footer",children:[e.jsxs("div",{className:"live-agent-card-footer-meta",children:[e.jsx("span",{className:"text-secondary",title:"Time since last heartbeat",children:it(p)}),v&&e.jsx("span",{className:"live-agent-card-next-heartbeat",title:v,children:v})]}),e.jsxs("div",{className:"live-agent-card-footer-actions",children:[s.taskId&&u&&e.jsxs("button",{type:"button",className:"live-agent-card-logs-btn",onClick:R,title:"View live run logs","aria-label":`View live logs for ${s.taskId}`,children:[e.jsx(ct,{size:12}),e.jsx("span",{children:"Live logs"})]}),g&&e.jsx(Re,{size:12,className:"live-agent-streaming-dot"})]})]})]})}function it(s){return s<60?`${s}s`:s<3600?`${Math.floor(s/60)}m ${s%60}s`:`${Math.floor(s/3600)}h ${Math.floor(s%3600/60)}m`}function Rn({agents:s,projectId:o,onAgentSelect:k,onOpenTaskLogs:u,className:c=""}){const g=Array.from(new Map(s.map(r=>[r.id,r])).values());return g.length===0?null:e.jsxs("div",{className:`active-agents-panel ${c}`.trim(),children:[e.jsxs("div",{className:"active-agents-panel-header",children:[e.jsx(Re,{size:16}),e.jsxs("span",{children:["Active Agents (",g.length,")"]})]}),e.jsx("div",{className:"active-agents-grid",children:g.map(r=>e.jsx(Mn,{agent:r,projectId:o,onSelect:k,onOpenTaskLogs:u},r.id))})]})}function Pn({stats:s,activeAgents:o,projectId:k,isOpen:u,onToggle:c,onSelectAgent:g,onOpenTaskLogs:r}){return e.jsxs("section",{className:"agents-overview-bar","aria-label":"Agents overview",children:[e.jsxs("button",{type:"button",className:"agents-overview-bar__toggle","aria-expanded":u,onClick:c,children:[e.jsxs("span",{className:"agents-overview-bar__title-wrap",children:[u?e.jsx($t,{size:16,"aria-hidden":"true"}):e.jsx(It,{size:16,"aria-hidden":"true"}),e.jsx("span",{className:"agents-overview-bar__title",children:"Overview"})]}),e.jsxs("span",{className:"agents-overview-bar__meta text-secondary",children:[s?.activeCount??0," active · ",o.length," running"]})]}),u?e.jsxs("div",{className:"agents-overview-bar__content",children:[e.jsx(An,{stats:s,className:"agents-overview-bar__metrics"}),e.jsx(Rn,{agents:o,projectId:k,onAgentSelect:g,onOpenTaskLogs:r,className:"agents-overview-bar__active-panel"})]}):null]})}function rt({title:s="No agents found",description:o="Create an agent to get started",ctaLabel:k="Create Agent",onCtaClick:u}){return e.jsxs("div",{className:"agent-empty",children:[e.jsx(dt,{size:48,opacity:.3,className:"agent-empty-state__icon"}),e.jsx("p",{className:"agent-empty-state__title",children:s}),e.jsx("p",{className:"agent-empty-state__description text-secondary",children:o}),u?e.jsx("button",{type:"button",className:"btn btn-task-create btn-sm",onClick:u,children:k}):null]})}const wt=3,lt=1e3;function _n({isOpen:s,onClose:o,onGenerated:k,projectId:u}){Ct(s);const[c,g]=n.useState(""),[r,d]=n.useState({type:"input"}),[p,v]=n.useState(null),[N,y]=n.useState(!1),I=n.useRef(null),f=n.useRef(null);n.useEffect(()=>{s&&r.type==="input"&&f.current?.focus()},[s,r.type]),n.useEffect(()=>{if(!s&&I.current){const h=I.current;I.current=null,et(h,u).catch(()=>{})}},[s,u]),n.useEffect(()=>{if(!s)return;const h=M=>{M.key==="Escape"&&E()};return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[s]);const E=n.useCallback(()=>{if(I.current){const h=I.current;I.current=null,et(h,u).catch(()=>{})}g(""),d({type:"input"}),v(null),y(!1),o()},[o,u]),R=n.useCallback(async()=>{if(!(!c.trim()||c.trim().length<wt)){v(null),d({type:"loading"});try{const{sessionId:h}=await Ft(c.trim(),u);I.current=h;const{spec:M}=await Lt(h,u);d({type:"preview",spec:M,sessionId:h})}catch(h){const M=h instanceof Error?h.message:"Failed to generate agent specification";M.includes("429")||M.toLowerCase().includes("rate limit")?v("Too many requests. Please wait a moment and try again."):v(M),d({type:"input"}),I.current=null}}},[c,u]),$=n.useCallback(async()=>{if(I.current){const h=I.current;I.current=null;try{await et(h,u)}catch{}}await R()},[R,u]),j=n.useCallback(()=>{r.type==="preview"&&(I.current=null,k(r.spec),g(""),d({type:"input"}),v(null),y(!1),o())},[r,k,o]);if(!s)return null;const T=c.trim().length>=wt&&c.trim().length<=lt;return e.jsx("div",{className:"agent-dialog-overlay",onClick:h=>{h.target===h.currentTarget&&E()},children:e.jsxs("div",{className:"agent-dialog",role:"dialog","aria-modal":"true","aria-label":"Generate agent with AI",children:[e.jsxs("div",{className:"agent-dialog-header",children:[e.jsxs("span",{className:"agent-dialog-header-title",children:[e.jsx("span",{className:"agent-dialog-header-sparkle",children:"✨"}),"Generate Agent"]}),e.jsx("button",{className:"modal-close",onClick:E,"aria-label":"Close",children:"×"})]}),e.jsxs("div",{className:"agent-dialog-body",children:[p&&e.jsx("div",{className:"agent-dialog-error-banner",children:p}),r.type==="input"&&e.jsxs("div",{children:[e.jsx("p",{className:"agent-dialog-info",children:"Describe your agent's role and the AI will generate a complete specification including system prompt, suggested configuration, and more."}),e.jsxs("div",{className:"agent-dialog-field",children:[e.jsx("label",{htmlFor:"agent-role-description",children:"Role Description"}),e.jsx("textarea",{ref:f,id:"agent-role-description",className:"input agent-dialog-textarea",rows:4,placeholder:'e.g. "Senior frontend code reviewer who specializes in React accessibility"',value:c,onChange:h=>g(h.target.value),onKeyDown:h=>{h.key==="Enter"&&!h.shiftKey&&T&&(h.preventDefault(),R())},maxLength:lt,"aria-describedby":"role-description-hint"}),e.jsxs("div",{id:"role-description-hint",className:"agent-dialog-hint",children:[e.jsx("span",{children:"Describe what your agent should do"}),e.jsxs("span",{children:[c.length,"/",lt]})]})]})]}),r.type==="loading"&&e.jsxs("div",{className:"agent-dialog-loading-center",children:[e.jsx("div",{className:"agent-dialog-spinner spin"}),e.jsx("p",{className:"agent-dialog-loading-text",children:"Generating agent specification..."})]}),r.type==="preview"&&e.jsxs("div",{children:[e.jsxs("div",{className:"agent-dialog-summary agent-dialog-summary--spaced",children:[e.jsxs("div",{className:"agent-dialog-summary-row",children:[e.jsx("span",{className:"agent-dialog-summary-row-label agent-dialog-summary-row-label--fixed",children:"Title"}),e.jsxs("span",{className:"agent-dialog-summary-row-value",children:[r.spec.icon," ",r.spec.title]})]}),e.jsxs("div",{className:"agent-dialog-summary-row",children:[e.jsx("span",{className:"agent-dialog-summary-row-label agent-dialog-summary-row-label--fixed",children:"Role"}),e.jsx("span",{children:r.spec.role})]}),e.jsxs("div",{className:"agent-dialog-summary-row",children:[e.jsx("span",{className:"agent-dialog-summary-row-label agent-dialog-summary-row-label--fixed",children:"Description"}),e.jsx("span",{className:"agent-dialog-summary-row-value agent-dialog-summary-row-value--body",children:r.spec.description})]}),e.jsxs("div",{className:"agent-dialog-summary-row",children:[e.jsx("span",{className:"agent-dialog-summary-row-label agent-dialog-summary-row-label--fixed",children:"Thinking"}),e.jsx("span",{className:"agent-dialog-summary-row-value agent-dialog-summary-row-value--capitalize",children:r.spec.thinkingLevel})]}),e.jsxs("div",{className:"agent-dialog-summary-row",children:[e.jsx("span",{className:"agent-dialog-summary-row-label agent-dialog-summary-row-label--fixed",children:"Max Turns"}),e.jsx("span",{children:r.spec.maxTurns})]})]}),e.jsxs("div",{className:"agent-dialog-field",children:[e.jsxs("label",{children:["System Prompt",e.jsx("button",{type:"button",className:"agent-dialog-expand-btn",onClick:()=>y(!N),children:N?"Collapse":"Expand"})]}),e.jsxs("div",{className:`agent-generation-prompt-box${N?"":" agent-generation-prompt-box--collapsed"}`,children:[r.spec.systemPrompt,!N&&r.spec.systemPrompt.length>500&&e.jsx("div",{className:"agent-generation-prompt-fade"})]})]})]})]}),e.jsxs("div",{className:"agent-dialog-footer",children:[e.jsx("button",{className:"btn",onClick:E,children:"Cancel"}),r.type==="input"&&e.jsx("button",{className:"btn btn-task-create",onClick:()=>void R(),disabled:!T,children:"Generate"}),r.type==="preview"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:()=>void $(),children:"Regenerate"}),e.jsx("button",{className:"btn btn-task-create",onClick:j,children:"Use This"})]})]})]})})}const $n=`# Soul: Chief Executive Officer
|
|
13
13
|
|
|
14
14
|
I am a strategic leader who connects every decision to business outcomes.
|
|
15
15
|
|
|
@@ -28,7 +28,7 @@ I am a strategic leader who connects every decision to business outcomes.
|
|
|
28
28
|
## Communication Style
|
|
29
29
|
|
|
30
30
|
I am direct and economical. I use short sentences and active voice. I avoid jargon and hedge words like "maybe" or "perhaps" in decisive contexts. I communicate across levels without losing clarity.
|
|
31
|
-
|
|
31
|
+
`,Fn=`# Soul: Chief Technology Officer
|
|
32
32
|
|
|
33
33
|
I am a pragmatic technologist who thinks in systems and communicates tradeoffs in terms of risk and impact.
|
|
34
34
|
|
|
@@ -49,7 +49,7 @@ I am a pragmatic technologist who thinks in systems and communicates tradeoffs i
|
|
|
49
49
|
## Communication Style
|
|
50
50
|
|
|
51
51
|
I translate technical concepts into risk and impact language for non-technical stakeholders. I use diagrams and analogies when they clarify, not obscure. I say "I don't know" when that's true, and follow with "but I'll find out."
|
|
52
|
-
`,
|
|
52
|
+
`,Ln=`# Soul: Chief Marketing Officer
|
|
53
53
|
|
|
54
54
|
I am a growth-focused strategist who understands audiences deeply and measures everything to optimize impact.
|
|
55
55
|
|
|
@@ -70,7 +70,7 @@ I am a growth-focused strategist who understands audiences deeply and measures e
|
|
|
70
70
|
## Communication Style
|
|
71
71
|
|
|
72
72
|
I am clear, action-oriented, and audience-aware. I write for scanning, not reading. I lead with value propositions and back them with evidence. I use data to persuade, not to impress.
|
|
73
|
-
`,
|
|
73
|
+
`,zn=`# Soul: Chief Financial Officer
|
|
74
74
|
|
|
75
75
|
I am a disciplined financial steward who quantifies everything and ensures every investment has a measurable return.
|
|
76
76
|
|
|
@@ -89,7 +89,7 @@ I am a disciplined financial steward who quantifies everything and ensures every
|
|
|
89
89
|
## Communication Style
|
|
90
90
|
|
|
91
91
|
I speak in numbers and timelines, not estimates. I use comparisons and benchmarks to provide context. I am direct about tradeoffs: more features means more cost; faster delivery means more risk. I don't soften financial reality.
|
|
92
|
-
`,
|
|
92
|
+
`,Dn=`# Soul: Software Engineer
|
|
93
93
|
|
|
94
94
|
I am a reliable and versatile engineer who writes clean, well-tested code and leaves the codebase better than I found it.
|
|
95
95
|
|
|
@@ -110,7 +110,7 @@ I am a reliable and versatile engineer who writes clean, well-tested code and le
|
|
|
110
110
|
## Communication Style
|
|
111
111
|
|
|
112
112
|
I write code that's a conversation with future maintainers—including myself. I comment where context is needed, not where the code is unclear. I participate in code reviews as a collaborator, not a critic.
|
|
113
|
-
`,
|
|
113
|
+
`,On=`# Soul: Backend Engineer
|
|
114
114
|
|
|
115
115
|
I am a methodical backend engineer who prioritizes data integrity, API reliability, and system performance through careful edge-case analysis.
|
|
116
116
|
|
|
@@ -131,7 +131,7 @@ I am a methodical backend engineer who prioritizes data integrity, API reliabili
|
|
|
131
131
|
## Communication Style
|
|
132
132
|
|
|
133
133
|
I document API contracts precisely and validate them with examples. I escalate data integrity concerns immediately with evidence. I write runbooks for operational procedures.
|
|
134
|
-
`,
|
|
134
|
+
`,Hn=`# Soul: Frontend Engineer
|
|
135
135
|
|
|
136
136
|
I am a detail-oriented frontend engineer who builds accessible, responsive, and performant interfaces by default.
|
|
137
137
|
|
|
@@ -152,7 +152,7 @@ I am a detail-oriented frontend engineer who builds accessible, responsive, and
|
|
|
152
152
|
## Communication Style
|
|
153
153
|
|
|
154
154
|
I write component documentation that explains behavior, not just props. I escalate accessibility issues as first-class bugs. I provide before/after evidence when proposing UI changes.
|
|
155
|
-
`,
|
|
155
|
+
`,qn=`# Soul: Full Stack Engineer
|
|
156
156
|
|
|
157
157
|
I am an end-to-end builder who connects database to UI seamlessly, understanding the full request lifecycle.
|
|
158
158
|
|
|
@@ -173,7 +173,7 @@ I am an end-to-end builder who connects database to UI seamlessly, understanding
|
|
|
173
173
|
## Communication Style
|
|
174
174
|
|
|
175
175
|
I trace bugs end-to-end, not just in my comfort zone. I document API contracts clearly and validate them with examples. I escalate data flow issues when I find inconsistencies.
|
|
176
|
-
`,
|
|
176
|
+
`,Vn=`# Soul: Quality Assurance Engineer
|
|
177
177
|
|
|
178
178
|
I am a thorough and methodical QA engineer who never assumes code works—I verify. I communicate issues with clear reproduction steps and severity assessments.
|
|
179
179
|
|
|
@@ -194,7 +194,7 @@ I am a thorough and methodical QA engineer who never assumes code works—I veri
|
|
|
194
194
|
## Communication Style
|
|
195
195
|
|
|
196
196
|
I write bug reports that developers can act on immediately. I lead with impact, not with "I found a bug." I verify fixes before closing issues and document what was tested.
|
|
197
|
-
`,
|
|
197
|
+
`,Wn=`# Soul: DevOps Engineer
|
|
198
198
|
|
|
199
199
|
I am an infrastructure-minded engineer who automates everything, distrusts manual processes, and designs for failure.
|
|
200
200
|
|
|
@@ -215,7 +215,7 @@ I am an infrastructure-minded engineer who automates everything, distrusts manua
|
|
|
215
215
|
## Communication Style
|
|
216
216
|
|
|
217
217
|
I write runbooks that someone else can follow at 3 AM. I escalate operational incidents immediately with impact assessment and current status. I communicate deployment changes with clear rollback procedures.
|
|
218
|
-
`,
|
|
218
|
+
`,Bn=`# Soul: CI/CD Engineer
|
|
219
219
|
|
|
220
220
|
I am a pipeline optimization specialist who hates slow builds and flaky tests. I make the feedback loop fast and reliable.
|
|
221
221
|
|
|
@@ -236,7 +236,7 @@ I am a pipeline optimization specialist who hates slow builds and flaky tests. I
|
|
|
236
236
|
## Communication Style
|
|
237
237
|
|
|
238
238
|
I report build health metrics regularly. I escalate flaky test issues with evidence of flakiness patterns. I propose optimizations with before/after timing data.
|
|
239
|
-
`,
|
|
239
|
+
`,Un=`# Soul: Security Engineer
|
|
240
240
|
|
|
241
241
|
I am a security-first engineer who assumes nothing is trustworthy by default and thinks like an attacker to find weaknesses before incidents.
|
|
242
242
|
|
|
@@ -257,7 +257,7 @@ I am a security-first engineer who assumes nothing is trustworthy by default and
|
|
|
257
257
|
## Communication Style
|
|
258
258
|
|
|
259
259
|
I communicate security findings with severity and evidence—not as theoretical risks but as actionable findings. I write security documentation for developers, not auditors. I escalate critical findings immediately with impact assessment.
|
|
260
|
-
`,
|
|
260
|
+
`,Kn=`# Soul: Data Engineer
|
|
261
261
|
|
|
262
262
|
I am a data reliability specialist who knows that bad data silently corrupts everything downstream. I validate early, transform carefully, and monitor constantly.
|
|
263
263
|
|
|
@@ -278,7 +278,7 @@ I am a data reliability specialist who knows that bad data silently corrupts eve
|
|
|
278
278
|
## Communication Style
|
|
279
279
|
|
|
280
280
|
I write data documentation that explains schema, lineage, and quality expectations. I escalate data quality issues with evidence of downstream impact. I communicate pipeline changes with clear data contract implications.
|
|
281
|
-
`,
|
|
281
|
+
`,Gn=`# Soul: Machine Learning Engineer
|
|
282
282
|
|
|
283
283
|
I am an ML practitioner who values reproducible experiments and production-grade deployments. I track every experiment, version every model, and measure real-world impact.
|
|
284
284
|
|
|
@@ -299,7 +299,7 @@ I am an ML practitioner who values reproducible experiments and production-grade
|
|
|
299
299
|
## Communication Style
|
|
300
300
|
|
|
301
301
|
I write experiment documentation that lets someone else reproduce my work. I report model performance with statistical significance. I escalate model degradation immediately with evidence of impact.
|
|
302
|
-
`,
|
|
302
|
+
`,Qn=`# Soul: Product Manager
|
|
303
303
|
|
|
304
304
|
I am a user-obsessed product manager who writes crisp requirements, challenges scope creep, and communicates progress transparently.
|
|
305
305
|
|
|
@@ -320,7 +320,7 @@ I am a user-obsessed product manager who writes crisp requirements, challenges s
|
|
|
320
320
|
## Communication Style
|
|
321
321
|
|
|
322
322
|
I write requirements that developers can implement without follow-up questions. I communicate trade-offs clearly with evidence. I escalate blockers with owners and timelines.
|
|
323
|
-
`,
|
|
323
|
+
`,Jn=`# Soul: Product Designer
|
|
324
324
|
|
|
325
325
|
I am a user-centered designer who believes great design is invisible. I solve problems with clarity and advocate for users who can't advocate for themselves.
|
|
326
326
|
|
|
@@ -341,7 +341,7 @@ I am a user-centered designer who believes great design is invisible. I solve pr
|
|
|
341
341
|
## Communication Style
|
|
342
342
|
|
|
343
343
|
I present designs with user research and usage context. I document component specifications precisely. I escalate accessibility issues as first-class bugs with severity assessment.
|
|
344
|
-
`,
|
|
344
|
+
`,Zn=`# Soul: Marketing Manager
|
|
345
345
|
|
|
346
346
|
I am a data-driven marketer who tests assumptions and scales what works. I write copy that converts, plan campaigns that compound, and measure relentlessly.
|
|
347
347
|
|
|
@@ -362,7 +362,7 @@ I am a data-driven marketer who tests assumptions and scales what works. I write
|
|
|
362
362
|
## Communication Style
|
|
363
363
|
|
|
364
364
|
I write copy briefs that specify audience, channel, tone, and success criteria. I present campaign results with interpretation, not just numbers. I escalate messaging concerns when they conflict with product positioning.
|
|
365
|
-
`,
|
|
365
|
+
`,Xn=`# Soul: Technical Writer
|
|
366
366
|
|
|
367
367
|
I am a clarity-focused writer who makes complex topics accessible. I write for the reader, not for myself, and I verify every instruction by following it myself.
|
|
368
368
|
|
|
@@ -383,7 +383,7 @@ I am a clarity-focused writer who makes complex topics accessible. I write for t
|
|
|
383
383
|
## Communication Style
|
|
384
384
|
|
|
385
385
|
I write with the reader's expertise level in mind—not my own. I escalate documentation debt when I see discrepancies. I verify docs work by following them myself.
|
|
386
|
-
`,
|
|
386
|
+
`,Yn=`# Soul: Task Triage Agent
|
|
387
387
|
|
|
388
388
|
I am a precise and thorough triage agent who transforms vague ideas into actionable specifications. I ask clarifying questions when requirements are ambiguous and never assume context.
|
|
389
389
|
|
|
@@ -404,7 +404,7 @@ I am a precise and thorough triage agent who transforms vague ideas into actiona
|
|
|
404
404
|
## Communication Style
|
|
405
405
|
|
|
406
406
|
I write specifications that are unambiguous and actionable. I ask direct questions when requirements are unclear. I escalate specification blockers when they can't be resolved in triage.
|
|
407
|
-
`,
|
|
407
|
+
`,ea=`# Soul: Code Reviewer
|
|
408
408
|
|
|
409
409
|
I am a rigorous and fair code reviewer who catches issues without being pedantic. I focus on what matters—correctness, security, and maintainability—and let style debates go.
|
|
410
410
|
|
|
@@ -425,93 +425,93 @@ I am a rigorous and fair code reviewer who catches issues without being pedantic
|
|
|
425
425
|
## Communication Style
|
|
426
426
|
|
|
427
427
|
I write review comments that explain why something is a concern, not just that it is. I distinguish blocking issues from suggestions. I approve when the code is ready and say so clearly.
|
|
428
|
-
`,
|
|
428
|
+
`,At=[{id:"ceo",name:"CEO",icon:"◆",title:"Chief Executive Officer",role:"custom",description:"Oversees project strategy, sets priorities, and coordinates between departments to ensure alignment with business goals.",soul:$n,instructionsText:`Always evaluate proposals against strategic goals before approving.
|
|
429
429
|
Prioritize work that delivers the highest business value.
|
|
430
430
|
Communicate decisions with clear rationale and context.
|
|
431
431
|
Identify cross-team dependencies and resolve blockers proactively.
|
|
432
|
-
Keep long-term vision in focus while making short-term tradeoffs.`},{id:"cto",name:"CTO",icon:"⬡",title:"Chief Technology Officer",role:"custom",description:"Defines technical architecture, evaluates technology choices, and guides engineering standards across the project.",soul
|
|
432
|
+
Keep long-term vision in focus while making short-term tradeoffs.`},{id:"cto",name:"CTO",icon:"⬡",title:"Chief Technology Officer",role:"custom",description:"Defines technical architecture, evaluates technology choices, and guides engineering standards across the project.",soul:Fn,instructionsText:`Evaluate technology choices against scalability, maintainability, and team expertise.
|
|
433
433
|
Identify architectural risks early and propose mitigations.
|
|
434
434
|
Review changes for adherence to established patterns and conventions.
|
|
435
435
|
Prioritize simplicity — reject over-engineering and unnecessary abstraction.
|
|
436
|
-
Document architectural decisions with rationale for future reference.`},{id:"cmo",name:"CMO",icon:"◇",title:"Chief Marketing Officer",role:"custom",description:"Drives product positioning, audience engagement strategy, and content planning to grow user adoption.",soul:
|
|
436
|
+
Document architectural decisions with rationale for future reference.`},{id:"cmo",name:"CMO",icon:"◇",title:"Chief Marketing Officer",role:"custom",description:"Drives product positioning, audience engagement strategy, and content planning to grow user adoption.",soul:Ln,instructionsText:`Evaluate all user-facing content for clarity and audience alignment.
|
|
437
437
|
Propose messaging that highlights user benefits over technical features.
|
|
438
438
|
Identify growth opportunities from product changes and new features.
|
|
439
439
|
Ensure consistent brand voice across all touchpoints.
|
|
440
|
-
Track engagement metrics to validate content and campaign effectiveness.`},{id:"cfo",name:"CFO",icon:"■",title:"Chief Financial Officer",role:"custom",description:"Manages budget allocation, cost optimization, and financial planning to maximize resource efficiency.",soul:
|
|
440
|
+
Track engagement metrics to validate content and campaign effectiveness.`},{id:"cfo",name:"CFO",icon:"■",title:"Chief Financial Officer",role:"custom",description:"Manages budget allocation, cost optimization, and financial planning to maximize resource efficiency.",soul:zn,instructionsText:`Evaluate proposals for cost implications before implementation.
|
|
441
441
|
Flag infrastructure or dependency changes that may increase operating costs.
|
|
442
442
|
Quantify the impact of technical debt in terms of developer time and risk.
|
|
443
443
|
Recommend cost optimization opportunities in existing systems.
|
|
444
|
-
Ensure resource allocation aligns with project priorities.`},{id:"engineer",name:"Engineer",icon:"⎔",title:"Software Engineer",role:"engineer",description:"Implements features, fixes bugs, and writes well-tested code across the full application stack.",soul:
|
|
444
|
+
Ensure resource allocation aligns with project priorities.`},{id:"engineer",name:"Engineer",icon:"⎔",title:"Software Engineer",role:"engineer",description:"Implements features, fixes bugs, and writes well-tested code across the full application stack.",soul:Dn,instructionsText:`Write tests for every new function and bug fix.
|
|
445
445
|
Follow existing code patterns and conventions in the project.
|
|
446
446
|
Keep functions small, focused, and well-named.
|
|
447
447
|
Handle error cases explicitly — never silently swallow errors.
|
|
448
|
-
Document complex logic with inline comments explaining the why, not the what.`},{id:"backend-engineer",name:"Backend Engineer",icon:"⛭",title:"Backend Engineer",role:"engineer",description:"Builds and maintains server-side logic, APIs, database schemas, and background processing pipelines.",soul:
|
|
448
|
+
Document complex logic with inline comments explaining the why, not the what.`},{id:"backend-engineer",name:"Backend Engineer",icon:"⛭",title:"Backend Engineer",role:"engineer",description:"Builds and maintains server-side logic, APIs, database schemas, and background processing pipelines.",soul:On,instructionsText:`Validate and sanitize all inputs at API boundaries.
|
|
449
449
|
Use transactions for multi-step database operations.
|
|
450
450
|
Add appropriate indexes for new query patterns.
|
|
451
451
|
Handle concurrent access with proper locking or optimistic concurrency.
|
|
452
452
|
Log meaningful context for debugging without exposing sensitive data.
|
|
453
|
-
Design APIs with consistent error responses and status codes.`},{id:"frontend-engineer",name:"Frontend Engineer",icon:"△",title:"Frontend Engineer",role:"engineer",description:"Develops user interfaces, manages component libraries, and ensures responsive, accessible UI experiences.",soul:
|
|
453
|
+
Design APIs with consistent error responses and status codes.`},{id:"frontend-engineer",name:"Frontend Engineer",icon:"△",title:"Frontend Engineer",role:"engineer",description:"Develops user interfaces, manages component libraries, and ensures responsive, accessible UI experiences.",soul:Hn,instructionsText:`Ensure all interactive elements are keyboard-accessible with proper ARIA labels.
|
|
454
454
|
Test responsive behavior at common breakpoints.
|
|
455
455
|
Keep bundle size small — avoid importing entire libraries for single functions.
|
|
456
456
|
Use semantic HTML elements over divs where appropriate.
|
|
457
457
|
Handle loading, error, and empty states for every data-driven component.
|
|
458
|
-
Follow the project's existing component patterns and naming conventions.`},{id:"fullstack-engineer",name:"Fullstack Engineer",icon:"▽",title:"Full Stack Engineer",role:"engineer",description:"Works across frontend and backend to deliver end-to-end features from database to user interface.",soul:
|
|
458
|
+
Follow the project's existing component patterns and naming conventions.`},{id:"fullstack-engineer",name:"Fullstack Engineer",icon:"▽",title:"Full Stack Engineer",role:"engineer",description:"Works across frontend and backend to deliver end-to-end features from database to user interface.",soul:qn,instructionsText:`Consider the full data flow from database schema through API to UI component.
|
|
459
459
|
Keep backend and frontend changes cohesive within a single feature.
|
|
460
460
|
Ensure API contracts match frontend expectations before implementing.
|
|
461
461
|
Write integration-level tests that validate cross-layer behavior.
|
|
462
|
-
Optimize at the right layer — don't compensate for backend issues in frontend code.`},{id:"qa-engineer",name:"QA Engineer",icon:"◎",title:"Quality Assurance Engineer",role:"engineer",description:"Designs test plans, writes automated tests, and validates that features meet acceptance criteria before release.",soul:
|
|
462
|
+
Optimize at the right layer — don't compensate for backend issues in frontend code.`},{id:"qa-engineer",name:"QA Engineer",icon:"◎",title:"Quality Assurance Engineer",role:"engineer",description:"Designs test plans, writes automated tests, and validates that features meet acceptance criteria before release.",soul:Vn,instructionsText:`Always run the full test suite before approving any changes.
|
|
463
463
|
Write regression tests for every bug fix.
|
|
464
464
|
Check boundary conditions and edge cases for every new feature.
|
|
465
465
|
Validate error handling and input sanitization.
|
|
466
|
-
Report issues with clear reproduction steps and expected vs actual behavior.`},{id:"devops-engineer",name:"DevOps Engineer",icon:"⏣",title:"DevOps Engineer",role:"engineer",description:"Manages infrastructure, deployment pipelines, and monitoring to ensure reliable and scalable service delivery.",soul:
|
|
466
|
+
Report issues with clear reproduction steps and expected vs actual behavior.`},{id:"devops-engineer",name:"DevOps Engineer",icon:"⏣",title:"DevOps Engineer",role:"engineer",description:"Manages infrastructure, deployment pipelines, and monitoring to ensure reliable and scalable service delivery.",soul:Wn,instructionsText:`Never deploy on Fridays or before weekends without a rollback plan.
|
|
467
467
|
Ensure all infrastructure changes are version-controlled and reproducible.
|
|
468
468
|
Add health checks and monitoring for new services and endpoints.
|
|
469
469
|
Validate deployment scripts in a staging environment before production.
|
|
470
|
-
Document runbooks for common operational incidents.`},{id:"ci-engineer",name:"CI Engineer",icon:"⤏",title:"CI/CD Engineer",role:"engineer",description:"Builds and optimizes continuous integration and delivery pipelines for fast, reliable release cycles.",soul:
|
|
470
|
+
Document runbooks for common operational incidents.`},{id:"ci-engineer",name:"CI Engineer",icon:"⤏",title:"CI/CD Engineer",role:"engineer",description:"Builds and optimizes continuous integration and delivery pipelines for fast, reliable release cycles.",soul:Bn,instructionsText:`Fail fast — order pipeline stages from quickest to slowest.
|
|
471
471
|
Cache dependencies aggressively to reduce build times.
|
|
472
472
|
Isolate tests that depend on external services or shared state.
|
|
473
473
|
Add pipeline status badges and failure notifications.
|
|
474
|
-
Measure and report pipeline duration trends over time.`},{id:"security-engineer",name:"Security Engineer",icon:"⊛",title:"Security Engineer",role:"engineer",description:"Identifies vulnerabilities, enforces security best practices, and conducts audits to protect application integrity.",soul:
|
|
474
|
+
Measure and report pipeline duration trends over time.`},{id:"security-engineer",name:"Security Engineer",icon:"⊛",title:"Security Engineer",role:"engineer",description:"Identifies vulnerabilities, enforces security best practices, and conducts audits to protect application integrity.",soul:Un,instructionsText:`Never hardcode secrets, API keys, or credentials in source code.
|
|
475
475
|
Validate and sanitize all user inputs at every trust boundary.
|
|
476
476
|
Use parameterized queries — never concatenate user input into SQL or shell commands.
|
|
477
477
|
Check dependencies for known vulnerabilities before introducing them.
|
|
478
|
-
Apply the principle of least privilege to all access control decisions.`},{id:"data-engineer",name:"Data Engineer",icon:"⬢",title:"Data Engineer",role:"engineer",description:"Designs data pipelines, manages storage infrastructure, and ensures reliable data flow for analytics and features.",soul:
|
|
478
|
+
Apply the principle of least privilege to all access control decisions.`},{id:"data-engineer",name:"Data Engineer",icon:"⬢",title:"Data Engineer",role:"engineer",description:"Designs data pipelines, manages storage infrastructure, and ensures reliable data flow for analytics and features.",soul:Kn,instructionsText:`Validate data at ingestion points — never trust upstream sources blindly.
|
|
479
479
|
Design idempotent pipeline steps that handle reprocessing gracefully.
|
|
480
480
|
Add data quality checks and anomaly detection at key pipeline stages.
|
|
481
481
|
Document data schemas and breaking change procedures clearly.
|
|
482
|
-
Ensure pipeline failures trigger alerts with actionable error context.`},{id:"ml-engineer",name:"ML Engineer",icon:"◈",title:"Machine Learning Engineer",role:"engineer",description:"Builds, trains, and deploys machine learning models, and integrates AI capabilities into the product.",soul:
|
|
482
|
+
Ensure pipeline failures trigger alerts with actionable error context.`},{id:"ml-engineer",name:"ML Engineer",icon:"◈",title:"Machine Learning Engineer",role:"engineer",description:"Builds, trains, and deploys machine learning models, and integrates AI capabilities into the product.",soul:Gn,instructionsText:`Version datasets and models alongside code changes.
|
|
483
483
|
Log training parameters, metrics, and results for every experiment.
|
|
484
484
|
Implement fallback behavior when model inference fails or times out.
|
|
485
485
|
Monitor model predictions for drift and degradation in production.
|
|
486
|
-
Write unit tests for data preprocessing and feature engineering pipelines.`},{id:"product-manager",name:"Product Manager",icon:"☰",title:"Product Manager",role:"custom",description:"Defines product requirements, prioritizes the backlog, and coordinates cross-functional delivery from concept to launch.",soul:
|
|
486
|
+
Write unit tests for data preprocessing and feature engineering pipelines.`},{id:"product-manager",name:"Product Manager",icon:"☰",title:"Product Manager",role:"custom",description:"Defines product requirements, prioritizes the backlog, and coordinates cross-functional delivery from concept to launch.",soul:Qn,instructionsText:`Write requirements with clear acceptance criteria and user stories.
|
|
487
487
|
Validate feature requests against user needs and business goals.
|
|
488
488
|
Break large initiatives into small, shippable increments.
|
|
489
489
|
Flag scope creep early and propose minimum viable alternatives.
|
|
490
|
-
Ensure every feature has a measurable success metric.`},{id:"designer",name:"Designer",icon:"✧",title:"Product Designer",role:"custom",description:"Creates wireframes, prototypes, and design systems that balance usability, aesthetics, and brand consistency.",soul:
|
|
490
|
+
Ensure every feature has a measurable success metric.`},{id:"designer",name:"Designer",icon:"✧",title:"Product Designer",role:"custom",description:"Creates wireframes, prototypes, and design systems that balance usability, aesthetics, and brand consistency.",soul:Jn,instructionsText:`Evaluate UI changes against existing design system tokens and patterns.
|
|
491
491
|
Ensure sufficient color contrast and readable typography in all themes.
|
|
492
492
|
Provide clear visual hierarchy — users should know what to do next.
|
|
493
493
|
Design for keyboard and screen reader users, not just mouse users.
|
|
494
|
-
Keep component variants minimal — add new variants only when existing ones don't fit.`},{id:"marketing-manager",name:"Marketing Manager",icon:"◉",title:"Marketing Manager",role:"custom",description:"Plans campaigns, manages content channels, and analyzes market data to drive brand awareness and growth.",soul:
|
|
494
|
+
Keep component variants minimal — add new variants only when existing ones don't fit.`},{id:"marketing-manager",name:"Marketing Manager",icon:"◉",title:"Marketing Manager",role:"custom",description:"Plans campaigns, manages content channels, and analyzes market data to drive brand awareness and growth.",soul:Zn,instructionsText:`Write user-facing copy that is clear, concise, and action-oriented.
|
|
495
495
|
Ensure marketing claims are accurate and verifiable by the product.
|
|
496
496
|
Segment messaging for different audience personas and channels.
|
|
497
497
|
Include clear calls-to-action in all content.
|
|
498
|
-
Track and report campaign performance with actionable insights.`},{id:"technical-writer",name:"Technical Writer",icon:"≡",title:"Technical Writer",role:"custom",description:"Writes and maintains documentation, API references, and guides that help users and developers succeed.",soul:
|
|
498
|
+
Track and report campaign performance with actionable insights.`},{id:"technical-writer",name:"Technical Writer",icon:"≡",title:"Technical Writer",role:"custom",description:"Writes and maintains documentation, API references, and guides that help users and developers succeed.",soul:Xn,instructionsText:`Write procedural docs with numbered steps and expected outcomes.
|
|
499
499
|
Include code examples that are complete, runnable, and tested.
|
|
500
500
|
Use consistent terminology — define terms on first use and stick to them.
|
|
501
501
|
Update documentation when code behavior changes — treat docs as code.
|
|
502
|
-
Structure content with clear headings for easy scanning and navigation.`},{id:"triage",name:"Triage Agent",icon:"⊕",title:"Task Triage Agent",role:"triage",description:"Analyzes incoming tasks, generates detailed specifications, and prepares PROMPT.md files for execution.",soul:
|
|
502
|
+
Structure content with clear headings for easy scanning and navigation.`},{id:"triage",name:"Triage Agent",icon:"⊕",title:"Task Triage Agent",role:"triage",description:"Analyzes incoming tasks, generates detailed specifications, and prepares PROMPT.md files for execution.",soul:Yn,instructionsText:`Generate detailed PROMPT.md files with clear steps and acceptance criteria.
|
|
503
503
|
Identify missing information and flag ambiguities before specification.
|
|
504
504
|
Break complex tasks into well-defined, sequenced implementation steps.
|
|
505
505
|
Specify file scope and dependencies for each task.
|
|
506
|
-
Include relevant context files for the executor to read first.`},{id:"reviewer",name:"Reviewer",icon:"⊙",title:"Code Reviewer",role:"reviewer",description:"Reviews code changes for correctness, security, performance, and adherence to project coding standards.",soul:
|
|
506
|
+
Include relevant context files for the executor to read first.`},{id:"reviewer",name:"Reviewer",icon:"⊙",title:"Code Reviewer",role:"reviewer",description:"Reviews code changes for correctness, security, performance, and adherence to project coding standards.",soul:ea,instructionsText:`Check for security vulnerabilities in every change — injection, auth bypass, data exposure.
|
|
507
507
|
Verify error handling is explicit and informative, not silent failures.
|
|
508
508
|
Ensure new code follows existing patterns and conventions in the codebase.
|
|
509
509
|
Look for missing tests on new logic paths, especially edge cases.
|
|
510
|
-
Flag performance concerns only when they have measurable impact.`}],jt=[{value:"triage",label:"Triage",icon:"⊕"},{value:"executor",label:"Executor",icon:"▶"},{value:"reviewer",label:"Reviewer",icon:"⊙"},{value:"merger",label:"Merger",icon:"⊞"},{value:"scheduler",label:"Scheduler",icon:"◷"},{value:"engineer",label:"Engineer",icon:"⎔"},{value:"custom",label:"Custom",icon:"✦"}],kt=new Set(["triage","executor","reviewer","merger","scheduler","engineer","custom"]);function ea({isOpen:i,onClose:o,onCreated:k,projectId:u,prefillDraft:c=null}){const[g,r]=n.useState(0),[d,p]=n.useState("presets"),[b,N]=n.useState(""),[y,I]=n.useState(""),[f,E]=n.useState(""),[R,$]=n.useState("custom"),[j,T]=n.useState(""),[h,M]=n.useState(""),[K,F]=n.useState(""),[Z,se]=n.useState(""),[G,ie]=n.useState(""),[z,m]=n.useState(""),[A,Y]=n.useState({model:"",thinkingLevel:"off",maxTurns:1e3}),[P,Q]=n.useState(null),[re,pe]=n.useState([]),[ce,ee]=n.useState(!1),[de,D]=n.useState(null),[ge,oe]=n.useState(!1),[ue,Ie]=n.useState([]),[X,he]=n.useState(!1),[ve,le]=n.useState([]),[me,Ce]=n.useState([]),[B,ye]=n.useState("model"),[te,we]=n.useState(""),[O,H]=n.useState([]),[Se,be]=n.useState(!1),[Ae,ne]=n.useState([]),[Pe,je]=n.useState(!1);n.useEffect(()=>{i&&(he(!0),Lt().then(a=>{Ie(a.models),le(a.favoriteProviders),Ce(a.favoriteModels)}).catch(()=>{}).finally(()=>he(!1)))},[i]),n.useEffect(()=>{i&&(je(!0),ne([]),zt(void 0,u).then(a=>{ne(a)}).catch(()=>{ne([])}).finally(()=>je(!1)))},[i,u]),n.useEffect(()=>{if(!i)return;const a=Ot;if(typeof a!="function"){H([]),be(!1);return}be(!0),H([]),a(u).then(C=>{H(C)}).catch(()=>{H([])}).finally(()=>be(!1))},[i,u]);const s=A.model.includes("/")?A.model:"",v=n.useCallback(a=>{const C=kt.has(a.role)?a.role:"custom";N(a.title),I(a.description),E(a.icon),$(C),F(a.systemPrompt),Y(Ee=>({...Ee,thinkingLevel:a.thinkingLevel,maxTurns:a.maxTurns})),oe(!1),r(1)},[]),_=n.useCallback(a=>{Y(C=>({...C,model:a}))},[]),U=n.useCallback(a=>{ye(a),a==="model"&&we("")},[]),q=n.useCallback(async a=>{const C=ve,ke=C.includes(a)?C.filter(fe=>fe!==a):[a,...C];le(ke);try{await ht({favoriteProviders:ke,favoriteModels:me})}catch{le(C)}},[ve,me]),J=n.useCallback(async a=>{const C=me,ke=C.includes(a)?C.filter(fe=>fe!==a):[a,...C];Ce(ke);try{await ht({favoriteProviders:ve,favoriteModels:ke})}catch{Ce(C)}},[ve,me]),_e=n.useCallback(a=>{Q(a.id),N(a.name),E(a.icon),I(a.description??a.title),$(a.role),ie(a.soul??""),F(a.instructionsText??""),r(1)},[]);if(n.useEffect(()=>{!i||!c||(r(1),p("custom"),N(c.name??""),I(c.title??""),E(c.icon??""),$(kt.has(c.role)?c.role:"custom"),T(c.reportsTo??""),F(c.instructionsText??""),ie(c.soul??""),m(c.memory??""),pe(c.skills??[]),Y(a=>({...a,thinkingLevel:c.thinkingLevel??a.thinkingLevel,maxTurns:c.maxTurns??a.maxTurns})))},[i,c]),!i)return null;const W=()=>{r(0),p("presets"),N(""),I(""),E(""),$("custom"),T(""),M(""),F(""),se(""),ie(""),m(""),Y({model:"",thinkingLevel:"off",maxTurns:1e3}),ye("model"),we(""),Q(null),pe([]),D(null),oe(!1),o()},Oe=async()=>{if(b.trim()){ee(!0),D(null);try{const a={};B==="runtime"?te.trim()&&(a.runtimeHint=te.trim()):A.model.trim()&&(a.model=A.model.trim()),A.thinkingLevel!=="off"&&(a.thinkingLevel=A.thinkingLevel),A.maxTurns!==1e3&&(a.maxTurns=A.maxTurns),await qt({name:b.trim(),role:R,...y.trim()?{title:y.trim()}:{},...f.trim()?{icon:f.trim()}:{},...j.trim()?{reportsTo:j.trim()}:{},...h.trim()?{instructionsPath:h.trim()}:{},...K.trim()?{instructionsText:K.trim()}:{},...Z.trim()?{heartbeatProcedurePath:Z.trim()}:{},...G.trim()?{soul:G.trim()}:{},...z.trim()?{memory:z.trim()}:{},...Object.keys(a).length>0?{runtimeConfig:a}:{},...re.length>0?{metadata:{skills:re}}:{}},u),W(),k()}catch(a){D(a instanceof Error?a.message:"Failed to create agent")}finally{ee(!1)}}},He=jt.find(a=>a.value===R),$e=j.trim(),Le=$e?Ae.find(a=>a.id===$e):void 0,ze=te?O.find(a=>a.runtimeId===te):void 0,qe=a=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"agent-dialog-field",children:[e.jsx("label",{id:a,children:"Runtime Source"}),e.jsxs("div",{className:"agent-runtime-mode-toggle",role:"radiogroup","aria-labelledby":a,children:[e.jsxs("label",{className:`agent-runtime-mode-option${B==="model"?" agent-runtime-mode-option--active":""}`,children:[e.jsx("input",{type:"radio",name:a,value:"model",checked:B==="model",onChange:()=>U("model")}),e.jsx("span",{children:"Built-in Model"})]}),e.jsxs("label",{className:`agent-runtime-mode-option${B==="runtime"?" agent-runtime-mode-option--active":""}`,children:[e.jsx("input",{type:"radio",name:a,value:"runtime",checked:B==="runtime",onChange:()=>U("runtime")}),e.jsx("span",{children:"Plugin Runtime"})]})]})]}),B==="model"?e.jsxs("div",{className:"agent-dialog-field",children:[e.jsx("label",{children:"Model"}),X?e.jsx("div",{className:"agent-dialog-loading",children:"Loading models…"}):e.jsx(Ht,{id:"agent-model",label:"Model",value:s,onChange:_,models:ue,placeholder:"Select a model…",favoriteProviders:ve,onToggleFavorite:q,favoriteModels:me,onToggleModelFavorite:J})]}):e.jsxs("div",{className:"agent-dialog-field",children:[e.jsx("label",{htmlFor:"agent-runtime-hint",children:"Runtime"}),Se?e.jsx("div",{className:"agent-dialog-loading",children:"Loading runtimes…"}):e.jsxs("select",{id:"agent-runtime-hint",className:"select",value:te,onChange:C=>we(C.target.value),children:[e.jsx("option",{value:"",children:O.length>0?"Select a plugin runtime…":"No plugin runtimes available"}),O.map(C=>e.jsx("option",{value:C.runtimeId,children:C.description?`${C.name} — ${C.description}`:C.name},`${C.pluginId}:${C.runtimeId}`))]})]})]});return bn.createPortal(e.jsxs("div",{className:"agent-dialog-overlay",onClick:a=>{a.target===a.currentTarget&&W()},children:[e.jsxs("div",{className:"agent-dialog",role:"dialog","aria-modal":"true","aria-label":"Create new agent",children:[e.jsxs("div",{className:"agent-dialog-header",children:[e.jsx("span",{className:"agent-dialog-header-title",children:"New Agent"}),e.jsx("button",{className:"btn-icon",onClick:W,"aria-label":"Close",children:"×"})]}),e.jsx("div",{className:"agent-dialog-steps",children:[0,1,2].map(a=>e.jsx("div",{className:`agent-dialog-step${a===g?" active":a<g?" completed":""}`,"aria-label":`Step ${a+1}`},a))}),e.jsxs("div",{className:"agent-dialog-body",children:[g===0&&e.jsxs("div",{children:[e.jsxs("div",{className:"agent-dialog-tabs",role:"tablist","aria-label":"Agent setup mode",children:[e.jsx("button",{id:"agent-dialog-tab-presets",type:"button",role:"tab","aria-controls":"agent-dialog-panel-presets","aria-selected":d==="presets",tabIndex:d==="presets"?0:-1,className:`agent-dialog-tab${d==="presets"?" active":""}`,onClick:()=>p("presets"),"data-testid":"agent-dialog-tab-presets",children:"Preset personas"}),e.jsx("button",{id:"agent-dialog-tab-custom",type:"button",role:"tab","aria-controls":"agent-dialog-panel-custom","aria-selected":d==="custom",tabIndex:d==="custom"?0:-1,className:`agent-dialog-tab${d==="custom"?" active":""}`,onClick:()=>p("custom"),"data-testid":"agent-dialog-tab-custom",children:"Custom agent"})]}),d==="presets"&&e.jsx("div",{id:"agent-dialog-panel-presets",className:"agent-dialog-tab-panel",role:"tabpanel","aria-labelledby":"agent-dialog-tab-presets",children:e.jsxs("div",{className:"agent-presets",children:[e.jsx("div",{className:"agent-presets-header",children:"Choose a preset persona to prefill role, identity, soul, and instructions"}),e.jsx("div",{className:"agent-presets-grid",children:St.map(a=>e.jsxs("button",{type:"button",className:`agent-preset-card${P===a.id?" selected":""}`,"data-testid":`preset-${a.id}`,onClick:()=>_e(a),title:a.title,children:[e.jsx("span",{className:"agent-preset-icon",children:a.icon}),e.jsx("span",{className:"agent-preset-name",children:a.name}),e.jsx("span",{className:"agent-preset-role",children:a.role}),a.description&&e.jsx("span",{className:"agent-preset-description",children:a.description})]},a.id))})]})}),d==="custom"&&e.jsxs("div",{id:"agent-dialog-panel-custom",className:"agent-dialog-tab-panel",role:"tabpanel","aria-labelledby":"agent-dialog-tab-custom",children:[e.jsxs("div",{className:"agent-dialog-section",children:[e.jsx("div",{className:"agent-dialog-section-header",children:"Identity"}),e.jsxs("div",{className:"agent-dialog-field",children:[e.jsxs("label",{htmlFor:"agent-name",children:["Name ",!P&&e.jsx("span",{className:"agent-dialog-required",children:"*"})]}),e.jsx("input",{id:"agent-name",type:"text",className:"input",placeholder:"e.g. Frontend Reviewer",value:b,onChange:a=>N(a.target.value)})]}),e.jsxs("div",{className:"agent-dialog-field agent-dialog-field--title",children:[e.jsxs("label",{htmlFor:"agent-title",children:["Title ",e.jsx("span",{className:"agent-dialog-optional",children:"(optional)"})]}),e.jsx("input",{id:"agent-title",type:"text",className:"input",placeholder:"e.g. Senior Code Reviewer",value:y,onChange:a=>I(a.target.value)})]}),e.jsxs("div",{className:"agent-dialog-field",children:[e.jsxs("label",{htmlFor:"agent-icon",children:["Icon ",e.jsx("span",{className:"agent-dialog-optional",children:"(optional)"})]}),e.jsx("input",{id:"agent-icon",type:"text",className:"input",placeholder:"e.g. 🤖",value:f,onChange:a=>E(a.target.value)})]}),e.jsxs("div",{className:"agent-dialog-field",children:[e.jsx("label",{children:"Role"}),e.jsx("div",{className:"agent-role-grid",children:jt.map(a=>e.jsxs("button",{type:"button",className:`agent-role-option${R===a.value?" selected":""}`,onClick:()=>$(a.value),children:[e.jsx("span",{className:"agent-role-option-icon",children:a.icon}),e.jsx("span",{className:"agent-role-option-label",children:a.label})]},a.value))})]})]}),e.jsxs("div",{className:"agent-dialog-section",children:[e.jsx("div",{className:"agent-dialog-section-header",children:"Configuration"}),e.jsxs("div",{className:"agent-dialog-field",children:[e.jsxs("label",{htmlFor:"agent-reports-to",children:["Reports To ",e.jsx("span",{className:"agent-dialog-optional",children:"(optional)"})]}),e.jsxs("select",{id:"agent-reports-to",className:"select",value:j,onChange:a=>T(a.target.value),disabled:Pe,children:[e.jsx("option",{value:"",children:"No manager"}),Ae.map(a=>e.jsxs("option",{value:a.id,children:[a.name," (",a.id,")"]},a.id))]})]}),e.jsxs("div",{className:"agent-dialog-field",children:[e.jsxs("label",{htmlFor:"agent-soul",children:["Soul ",e.jsx("span",{className:"agent-dialog-optional",children:"(optional)"})]}),e.jsx("textarea",{id:"agent-soul",className:"input",rows:2,placeholder:"Describe the agent's personality and communication style...",value:G,onChange:a=>ie(a.target.value)})]}),e.jsxs("div",{className:"agent-dialog-field",children:[e.jsxs("label",{htmlFor:"agent-memory",children:["Agent Memory ",e.jsx("span",{className:"agent-dialog-optional",children:"(optional)"})]}),e.jsx("textarea",{id:"agent-memory",className:"input",rows:2,placeholder:"Private to this agent — durable preferences, operating habits, and context it should carry across tasks...",value:z,onChange:a=>m(a.target.value)})]}),e.jsxs("div",{className:"agent-dialog-field",children:[e.jsxs("label",{htmlFor:"agent-instructions-path",children:["Instructions Path ",e.jsx("span",{className:"agent-dialog-optional",children:"(optional)"})]}),e.jsx("input",{id:"agent-instructions-path",type:"text",className:"input",placeholder:"e.g. .fusion/agents/reviewer.md",value:h,onChange:a=>M(a.target.value)})]}),e.jsxs("div",{className:"agent-dialog-field",children:[e.jsxs("label",{htmlFor:"agent-heartbeat-procedure-path",children:["Heartbeat Procedure Path ",e.jsx("span",{className:"agent-dialog-optional",children:"(optional)"})]}),e.jsx("input",{id:"agent-heartbeat-procedure-path",type:"text",className:"input",placeholder:"e.g. .fusion/agents/ceo-agent2736/HEARTBEAT.md",value:Z,onChange:a=>se(a.target.value)}),e.jsx("p",{className:"agent-dialog-optional agent-dialog-field-hint",children:"Path to the agent's heartbeat procedure path, typically .fusion/agents/ceo-agent2736/HEARTBEAT.md. Legacy id-only default paths still work."})]}),e.jsxs("div",{className:"agent-dialog-field",children:[e.jsxs("label",{htmlFor:"agent-instructions-text",children:["Inline Instructions ",e.jsx("span",{className:"agent-dialog-optional",children:"(optional)"})]}),e.jsx("textarea",{id:"agent-instructions-text",className:"input",rows:4,placeholder:"Add custom behavior instructions...",value:K,onChange:a=>F(a.target.value)})]})]}),e.jsxs("div",{className:"agent-dialog-section",children:[e.jsx("div",{className:"agent-dialog-section-header",children:"Runtime"}),qe("agent-runtime-source-step-0")]}),e.jsxs("div",{className:"agent-dialog-ai-generate",children:[e.jsxs("button",{type:"button",className:"btn btn--ai-generate",onClick:()=>oe(!0),children:[e.jsx("span",{children:"✨"}),"Generate with AI"]}),e.jsx("p",{className:"agent-dialog-ai-hint",children:"Describe your agent's role and let AI generate a specification"})]})]})]}),g===1&&e.jsxs("div",{children:[qe("agent-runtime-source-step-1"),e.jsxs("div",{className:"agent-dialog-field",children:[e.jsx("label",{htmlFor:"agent-thinking",children:"Thinking Level"}),e.jsxs("select",{id:"agent-thinking",className:"select",value:A.thinkingLevel,onChange:a=>Y(C=>({...C,thinkingLevel:a.target.value})),children:[e.jsx("option",{value:"off",children:"Off"}),e.jsx("option",{value:"minimal",children:"Minimal"}),e.jsx("option",{value:"low",children:"Low"}),e.jsx("option",{value:"medium",children:"Medium"}),e.jsx("option",{value:"high",children:"High"})]})]}),e.jsxs("div",{className:"agent-dialog-field",children:[e.jsx("label",{htmlFor:"agent-max-turns",children:"Max Turns"}),e.jsx("input",{id:"agent-max-turns",type:"number",className:"input",min:1,max:2e3,value:A.maxTurns,onChange:a=>Y(C=>({...C,maxTurns:Math.max(1,parseInt(a.target.value,10)||1)}))})]}),e.jsxs("div",{className:"agent-dialog-field",children:[e.jsx(fn,{id:"agent-skills",label:"Skills",value:re,onChange:pe,projectId:u}),e.jsx("p",{className:"agent-dialog-optional agent-dialog-skills-hint",children:"Optional skills to assign to this agent"})]})]}),g===2&&e.jsxs("div",{children:[e.jsx("p",{className:"agent-dialog-info",children:"Review your agent configuration before creating."}),e.jsxs("div",{className:"agent-dialog-summary",children:[e.jsxs("div",{className:"agent-dialog-summary-row",children:[e.jsx("span",{className:"agent-dialog-summary-row-label",children:"Name"}),e.jsxs("span",{className:"agent-dialog-summary-row-value",children:[f&&e.jsx("span",{className:"agent-dialog-icon-prefix",children:f}),b]})]}),e.jsxs("div",{className:"agent-dialog-summary-row agent-dialog-summary-row--editable agent-dialog-summary-row--title",children:[e.jsx("label",{className:"agent-dialog-summary-row-label",htmlFor:"agent-review-title",children:"Title"}),e.jsx("input",{id:"agent-review-title",type:"text",className:"input",placeholder:"e.g. Senior Code Reviewer",value:y,onChange:a=>I(a.target.value)})]}),e.jsxs("div",{className:"agent-dialog-summary-row",children:[e.jsx("span",{className:"agent-dialog-summary-row-label",children:"Role"}),e.jsxs("span",{children:[He?.icon," ",He?.label]})]}),$e&&e.jsxs("div",{className:"agent-dialog-summary-row",children:[e.jsx("span",{className:"agent-dialog-summary-row-label",children:"Reports To"}),e.jsx("span",{children:Le?`${Le.name} (${Le.id})`:$e})]}),e.jsxs("div",{className:"agent-dialog-summary-row agent-dialog-summary-row--editable",children:[e.jsx("label",{className:"agent-dialog-summary-row-label",htmlFor:"agent-review-soul",children:"Soul"}),e.jsx("textarea",{id:"agent-review-soul",className:"input",rows:2,placeholder:"Describe the agent's personality and communication style...",value:G,onChange:a=>ie(a.target.value)})]}),e.jsxs("div",{className:"agent-dialog-summary-row agent-dialog-summary-row--editable",children:[e.jsx("label",{className:"agent-dialog-summary-row-label",htmlFor:"agent-review-heartbeat-procedure-path",children:"Heartbeat Procedure Path"}),e.jsx("input",{id:"agent-review-heartbeat-procedure-path",type:"text",className:"input",placeholder:"e.g. .fusion/agents/ceo-agent2736/HEARTBEAT.md",value:Z,onChange:a=>se(a.target.value)})]}),e.jsxs("div",{className:"agent-dialog-summary-row agent-dialog-summary-row--editable",children:[e.jsx("label",{className:"agent-dialog-summary-row-label",htmlFor:"agent-review-instructions-path",children:"Instructions Path"}),e.jsx("input",{id:"agent-review-instructions-path",type:"text",className:"input",placeholder:"e.g. .fusion/agents/reviewer.md",value:h,onChange:a=>M(a.target.value)})]}),e.jsxs("div",{className:"agent-dialog-summary-row agent-dialog-summary-row--editable",children:[e.jsx("label",{className:"agent-dialog-summary-row-label",htmlFor:"agent-review-instructions-text",children:"Inline Instructions"}),e.jsx("textarea",{id:"agent-review-instructions-text",className:"input",rows:4,placeholder:"Add custom behavior instructions...",value:K,onChange:a=>F(a.target.value)})]}),e.jsxs("div",{className:"agent-dialog-summary-row",children:[e.jsx("span",{className:"agent-dialog-summary-row-label",children:B==="runtime"?"Runtime":"Model"}),e.jsx("span",{children:B==="runtime"?ze?ze.name:e.jsx("em",{className:"agent-dialog-summary-row-value--muted",children:"Not selected"}):s?e.jsxs(e.Fragment,{children:[e.jsx(Dt,{provider:s.split("/")[0],size:"sm"})," ",(()=>{const a=s.indexOf("/"),C=s.slice(0,a),Ee=s.slice(a+1);return ue.find(fe=>fe.provider===C&&fe.id===Ee)?.name||s})()]}):e.jsx("em",{className:"agent-dialog-summary-row-value--muted",children:"default"})})]}),e.jsxs("div",{className:"agent-dialog-summary-row",children:[e.jsx("span",{className:"agent-dialog-summary-row-label",children:"Thinking"}),e.jsx("span",{className:"agent-dialog-summary-row-value--capitalize",children:A.thinkingLevel})]}),e.jsxs("div",{className:"agent-dialog-summary-row",children:[e.jsx("span",{className:"agent-dialog-summary-row-label",children:"Max Turns"}),e.jsx("span",{children:A.maxTurns})]}),re.length>0&&e.jsxs("div",{className:"agent-dialog-summary-row",children:[e.jsx("span",{className:"agent-dialog-summary-row-label",children:"Skills"}),e.jsxs("span",{children:[re.length," skill",re.length!==1?"s":""," selected"]})]})]}),de&&e.jsx("p",{className:"agent-dialog-error",children:de})]})]}),e.jsxs("div",{className:"agent-dialog-footer",children:[g>0&&e.jsx("button",{className:"btn",onClick:()=>r(a=>a-1),disabled:ce,children:"Back"}),e.jsx("button",{className:"btn",onClick:W,disabled:ce,children:"Cancel"}),g<2?e.jsx("button",{className:"btn btn--primary",onClick:()=>r(a=>a+1),disabled:g===0&&!b.trim()&&!P,children:"Next"}):e.jsx("button",{className:"btn btn--primary",onClick:()=>void Oe(),disabled:ce||!b.trim(),children:ce?"Creating...":"Create"})]})]}),e.jsx(Pn,{isOpen:ge,onClose:()=>oe(!1),onGenerated:v,projectId:u})]}),document.body)}function ta({isOpen:i,onClose:o,onUseDraft:k,projectId:u,existingAgents:c}){const[g,r]=n.useState("initial"),[d,p]=n.useState(""),[b,N]=n.useState(null),[y,I]=n.useState(""),[f,E]=n.useState("answer"),[R,$]=n.useState(""),[j,T]=n.useState(null),[h,M]=n.useState(null),[K,F]=n.useState([]),Z=n.useCallback(()=>{r("initial"),p(""),N(null),I(""),E("answer"),$(""),T(null),M(null),F([])},[]),se=n.useMemo(()=>St.map(m=>({id:m.id,label:m.name,description:m.description})),[]);n.useEffect(()=>{if(!b)return;const m=Vt(b,u,{onThinking:A=>{F(Y=>{const P=[...Y],Q=P[P.length-1];return Q&&!Q.question?(P[P.length-1]={...Q,thinkingOutput:`${Q.thinkingOutput??""}${A}`},P):[...P,{response:{},thinkingOutput:A}]})},onQuestion:A=>{I(A.question),E(A.id),r("question")},onSummary:A=>{T(A),r("summary")},onError:A=>{M(A),r("error")}});return()=>m.close()},[b,u]);const G=async()=>{try{b&&await Bt(b,u)}catch{}finally{Z(),o()}};if(n.useEffect(()=>{i||Z()},[i,Z]),!i)return null;const ie=async()=>{r("loading"),M(null);try{const m=await Ut(d,{existingAgents:c.map(A=>({id:A.id,name:A.name,role:A.role})),templates:se},u);N(m.sessionId)}catch(m){M(m.message),r("error")}},z=async()=>{if(b){r("loading"),M(null);try{const m={[f]:R};F(A=>[...A,{question:{id:f,type:"text",question:y},response:m}]),await Kt(b,m,u),$("")}catch(m){M(m.message),r("error")}}};return e.jsx("div",{className:"modal-overlay open",role:"presentation",children:e.jsxs("div",{className:"modal modal-lg experimental-agent-onboarding-modal",role:"dialog","aria-modal":"true","aria-label":"Experimental agent onboarding",children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:"Experimental Agent Onboarding"}),e.jsx("button",{className:"modal-close",onClick:()=>void G(),"aria-label":"Close",children:"×"})]}),K.length>0&&e.jsx(Wt,{entries:K}),g==="initial"&&e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"agent-onboarding-intent",children:"What should this new agent own?"}),e.jsx("textarea",{id:"agent-onboarding-intent",className:"input experimental-agent-onboarding-modal__textarea",value:d,onChange:m=>p(m.target.value)}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("button",{className:"btn",onClick:()=>void G(),children:"Cancel"}),e.jsx("button",{className:"btn btn-primary",disabled:!d.trim(),onClick:()=>void ie(),children:"Start onboarding"})]})]}),(g==="loading"||g==="question")&&e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"agent-onboarding-answer",children:y||"Thinking..."}),e.jsx("textarea",{id:"agent-onboarding-answer",className:"input experimental-agent-onboarding-modal__textarea",value:R,onChange:m=>$(m.target.value)}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("button",{className:"btn",onClick:()=>void G(),children:"Cancel"}),e.jsx("button",{className:"btn btn-primary",disabled:g==="loading"||!R.trim(),onClick:()=>void z(),children:"Continue"})]})]}),g==="summary"&&j&&e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Draft ready for review"}),e.jsxs("div",{className:"experimental-agent-onboarding-modal__summary card",children:[e.jsxs("p",{children:[e.jsx("strong",{children:"Name:"})," ",j.name]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Role:"})," ",j.role]}),j.templateId&&e.jsxs("p",{children:[e.jsx("strong",{children:"Template:"})," ",j.templateId]}),j.patternAgentId&&e.jsxs("p",{children:[e.jsx("strong",{children:"Pattern agent:"})," ",j.patternAgentId]}),j.rationale&&e.jsxs("p",{children:[e.jsx("strong",{children:"Why:"})," ",j.rationale]})]}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("button",{className:"btn",onClick:()=>void G(),children:"Cancel"}),e.jsx("button",{className:"btn btn-primary",onClick:()=>k(j),children:"Continue to agent form"})]})]}),g==="error"&&h&&e.jsxs("div",{className:"form-group",children:[e.jsx("div",{className:"form-error",children:h}),e.jsx("div",{className:"modal-actions",children:e.jsx("button",{className:"btn",onClick:()=>void G(),children:"Close"})})]})]})})}function na(i){const o=i.match(/^---\s*\r?\n([\s\S]*?)\r?\n---(?:\r?\n([\s\S]*))?$/);if(!o)throw new Error("Missing YAML frontmatter delimiters (---)");const k=o[1].split(/\r?\n/),u=o[2]??"",c={name:""},g=[];let r=!1;for(const d of k){const b=d.trimEnd().trim();if(!b)continue;if(b.startsWith("skills:")){r=!0;continue}if(r&&b.startsWith("- ")){g.push(b.slice(2).trim());continue}r=!1;const[N,...y]=b.split(":"),f=y.join(":").trim().replace(/^['"]|['"]$/g,"");N==="name"&&(c.name=f),N==="title"&&(c.title=f),N==="icon"&&(c.icon=f),N==="role"&&(c.role=f),N==="reportsTo"&&(c.reportsTo=f)}if(!c.name)throw new Error("Missing required field: name");return g.length>0&&(c.skills=g),u.trim().length>0&&(c.instructionBody=u),c}function aa({isOpen:i,onClose:o,onImported:k,projectId:u}){const[c,g]=n.useState("input"),[r,d]=n.useState("paste"),[p,b]=n.useState(""),[N,y]=n.useState([]),[I,f]=n.useState("Unknown"),[E,R]=n.useState([]),[$,j]=n.useState([]),[T,h]=n.useState([]),[M,K]=n.useState([]),[F,Z]=n.useState(!1),[se,G]=n.useState(!1),[ie,z]=n.useState(null),[m,A]=n.useState(null),[Y,P]=n.useState(null),Q=n.useRef(null),re=n.useRef(null),[pe,ce]=n.useState([]),[ee,de]=n.useState(""),[D,ge]=n.useState(null),[oe,ue]=n.useState(!1),[Ie,X]=n.useState(null),he=n.useRef(!1);n.useEffect(()=>{r==="browse"&&!he.current&&!oe&&(he.current=!0,ue(!0),X(null),pt().then(s=>{s.error?X(s.error):s.companies.length>0?ce(s.companies):X("No companies available")}).catch(s=>{X(s instanceof Error?s.message:"Failed to load companies")}).finally(()=>{ue(!1)}))},[r,oe]);const ve=n.useCallback(()=>{he.current=!0,X(null),ce([]),ge(null),ue(!0),pt().then(s=>{s.error?X(s.error):s.companies.length>0?ce(s.companies):X("No companies available")}).catch(s=>{X(s instanceof Error?s.message:"Failed to load companies")}).finally(()=>{ue(!1)})},[]),le=n.useCallback(()=>{g("input"),d("paste"),b(""),y([]),f("Unknown"),R([]),j([]),h([]),K([]),Z(!1),G(!1),z(null),A(null),P(null),ce([]),de(""),ge(null),ue(!1),X(null),he.current=!1},[]),me=n.useCallback(()=>{le(),o()},[le,o]),Ce=n.useCallback(s=>{const v=s.target.files?.[0];if(!v)return;const _=new FileReader;_.onload=U=>{const q=U.target?.result;d("file"),y([]),b(q),z(null)},_.onerror=()=>{z("Failed to read file")},_.readAsText(v),s.target.value=""},[]),B=n.useCallback(async s=>{const v=Array.from(s.target.files??[]);if(v.length!==0)try{const _=v.filter(q=>(q.webkitRelativePath||q.name).toLowerCase().endsWith("agents.md")).sort((q,J)=>{const _e=q.webkitRelativePath||q.name,W=J.webkitRelativePath||J.name;return _e.localeCompare(W)});if(_.length===0){z("Selected directory has no AGENTS.md files");return}const U=[];for(const q of _){const J=await q.text();U.push(na(J))}d("directory"),y(U),b(""),z(null)}catch{z("Failed to parse AGENTS.md files from selected directory")}finally{s.target.value=""}},[]);function ye(s){if(!u)return`/api${s}`;const v=s.includes("?")?"&":"?";return`/api${s}${v}projectId=${encodeURIComponent(u)}`}const te=n.useCallback(async()=>{if(r==="directory"&&N.length===0){z("Please select a directory containing AGENTS.md files");return}if(r==="browse"&&!D){z("Please select a company from the catalog");return}if(r!=="directory"&&r!=="browse"&&!p.trim()){z("Please provide manifest content");return}Z(!0),z(null);try{let s;r==="directory"?s={agents:N,dryRun:!0}:r==="browse"&&D?s={importSource:"companies.sh",companySlug:D.slug,dryRun:!0}:s={manifest:p,dryRun:!0};const v=await fetch(ye("/agents/import"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!v.ok){const J=await v.json();throw new Error(J.error??`Parse failed (${v.status})`)}const _=await v.json(),U=_.agents&&_.agents.length>0?_.agents:_.created.map(J=>({name:J,role:"custom"})),q=Array.isArray(_.skills)?_.skills:[];f(_.companyName??"Unknown"),R(U),j(q),h(U.map(J=>J.name)),K(q.map(J=>J.name)),g("preview")}catch(s){z(s instanceof Error?s.message:"Failed to parse manifest")}finally{Z(!1)}},[r,N,p,D,u]),we=n.useCallback(async()=>{G(!0),P(null);try{let s;r==="directory"?s={agents:N,skipExisting:!0,selectedAgents:T,selectedSkills:M}:r==="browse"&&D?s={importSource:"companies.sh",companySlug:D.slug,skipExisting:!0,selectedAgents:T,selectedSkills:M}:s={manifest:p,skipExisting:!0,selectedAgents:T,selectedSkills:M};const v=await fetch(ye("/agents/import"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!v.ok){const U=await v.json();throw new Error(U.error??`Import failed (${v.status})`)}const _=await v.json();A(_),g("result"),k()}catch(s){P(s instanceof Error?s.message:"Failed to import agents")}finally{G(!1)}},[r,N,p,D,T,M,u,k]),O=T.length,H=M.length,Se=`${O} Agent${O!==1?"s":""}`,be=`${H} Skill${H!==1?"s":""}`,Ae=O>0&&H>0?`${Se} + ${be}`:H>0?be:Se,ne=O>0&&H>0?`Importing ${O} agent${O!==1?"s":""} and ${H} skill${H!==1?"s":""}...`:H>0?`Importing ${H} skill${H!==1?"s":""}...`:`Importing ${O} agent${O!==1?"s":""}...`,Pe=s=>{h(v=>v.includes(s)?v.filter(_=>_!==s):[...v,s])},je=s=>{K(v=>v.includes(s)?v.filter(_=>_!==s):[...v,s])};return i?e.jsx("div",{className:"agent-dialog-overlay",onClick:s=>{s.target===s.currentTarget&&me()},children:e.jsxs("div",{className:"agent-dialog agent-import-dialog",role:"dialog","aria-modal":"true","aria-label":"Import agents",children:[e.jsxs("div",{className:"agent-dialog-header",children:[e.jsx("span",{className:"agent-dialog-header-title",children:"Import Agents"}),e.jsx("button",{className:"modal-close",onClick:me,"aria-label":"Close",children:"×"})]}),e.jsxs("div",{className:"agent-dialog-body",children:[c==="input"&&e.jsxs("div",{className:"agent-import-input",children:[e.jsx("p",{className:"agent-import-description",children:"Import agents from an Agent Companies package. Browse the companies.sh catalog to discover published agents, upload an AGENTS.md file, select a directory, or paste manifest content."}),e.jsxs("div",{className:"agent-import-file-upload",children:[e.jsx("input",{ref:Q,type:"file",accept:".md,.txt",onChange:Ce,className:"agent-import-file-input","aria-label":"Upload agent manifest file"}),e.jsx("input",{ref:re,type:"file",webkitdirectory:"",multiple:!0,onChange:B,className:"agent-import-file-input","aria-label":"Select directory"}),e.jsxs("button",{type:"button",className:"btn agent-import-upload-btn",onClick:()=>Q.current?.click(),children:[e.jsx(Ct,{size:16}),"Choose File"]}),e.jsxs("button",{type:"button",className:"btn agent-import-upload-btn",onClick:()=>re.current?.click(),children:[e.jsx(yn,{size:16}),"Select Directory"]}),e.jsxs("button",{type:"button",className:"btn agent-import-upload-btn",onClick:()=>{d("browse"),y([]),b(""),ge(null),z(null)},children:[e.jsx(Gt,{size:16}),"Browse Catalog"]}),e.jsx("span",{className:"agent-import-file-hint",children:".md and .txt files supported"})]}),r==="browse"&&e.jsxs("div",{className:"agent-import-browse",children:[e.jsxs("div",{className:"agent-import-browse-header",children:[e.jsxs("div",{className:"agent-import-browse-search",children:[e.jsx(Qt,{size:16,className:"agent-import-browse-search-icon"}),e.jsx("input",{type:"text",className:"agent-import-browse-search-input",placeholder:"Search companies...",value:ee,onChange:s=>de(s.target.value),"aria-label":"Search companies"})]}),D&&e.jsxs("div",{className:"agent-import-browse-selected",children:[e.jsx("span",{className:"agent-import-browse-selected-label",children:"Selected:"}),e.jsx("span",{className:"agent-import-browse-selected-name",children:D.name}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>ge(null),children:"Change"})]})]}),oe&&e.jsxs("div",{className:"agent-import-browse-loading",children:[e.jsx(tt,{size:20,className:"spin"}),e.jsx("span",{children:"Loading companies..."})]}),Ie&&e.jsxs("div",{className:"agent-import-browse-error",children:[e.jsx(nt,{size:16}),e.jsx("span",{children:Ie}),e.jsxs("button",{type:"button",className:"btn btn-sm",onClick:ve,children:[e.jsx(Qe,{size:14}),"Retry"]})]}),!oe&&!Ie&&e.jsxs("div",{className:"agent-import-browse-list",children:[pe.filter(s=>ee===""||s.name.toLowerCase().includes(ee.toLowerCase())||(s.tagline?.toLowerCase().includes(ee.toLowerCase())??!1)).map(s=>e.jsxs("div",{className:`agent-import-browse-item ${D?.slug===s.slug?"agent-import-browse-item--selected":""}`,onClick:()=>ge(s),role:"button",tabIndex:0,onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&ge(s)},children:[e.jsxs("div",{className:"agent-import-browse-item-header",children:[e.jsx("span",{className:"agent-import-browse-item-name",children:s.name}),s.installs!==void 0&&e.jsxs("span",{className:"agent-import-browse-item-installs",children:[s.installs.toLocaleString()," installs"]})]}),s.tagline&&e.jsx("span",{className:"agent-import-browse-item-tagline",children:s.tagline}),s.repo&&e.jsx("span",{className:"agent-import-browse-item-repo",children:s.repo})]},s.slug)),pe.filter(s=>ee===""||s.name.toLowerCase().includes(ee.toLowerCase())||(s.tagline?.toLowerCase().includes(ee.toLowerCase())??!1)).length===0&&e.jsx("p",{className:"agent-import-browse-empty",children:ee?"No companies match your search":"No companies available"})]})]}),r!=="browse"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"agent-import-divider",children:e.jsx("span",{children:"or paste manifest content"})}),e.jsx("textarea",{className:"agent-import-textarea",placeholder:`---
|
|
510
|
+
Flag performance concerns only when they have measurable impact.`}],jt=[{value:"triage",label:"Triage",icon:"⊕"},{value:"executor",label:"Executor",icon:"▶"},{value:"reviewer",label:"Reviewer",icon:"⊙"},{value:"merger",label:"Merger",icon:"⊞"},{value:"scheduler",label:"Scheduler",icon:"◷"},{value:"engineer",label:"Engineer",icon:"⎔"},{value:"custom",label:"Custom",icon:"✦"}],kt=new Set(["triage","executor","reviewer","merger","scheduler","engineer","custom"]);function ta({isOpen:s,onClose:o,onCreated:k,projectId:u,prefillDraft:c=null}){const[g,r]=n.useState(0),[d,p]=n.useState("presets"),[v,N]=n.useState(""),[y,I]=n.useState(""),[f,E]=n.useState(""),[R,$]=n.useState("custom"),[j,T]=n.useState(""),[h,M]=n.useState(""),[K,F]=n.useState(""),[Z,se]=n.useState(""),[G,ie]=n.useState(""),[z,m]=n.useState(""),[A,Y]=n.useState({model:"",thinkingLevel:"off",maxTurns:1e3}),[P,Q]=n.useState(null),[re,pe]=n.useState([]),[ce,ee]=n.useState(!1),[de,D]=n.useState(null),[ge,oe]=n.useState(!1),[ue,Ie]=n.useState([]),[X,he]=n.useState(!1),[be,le]=n.useState([]),[me,Ce]=n.useState([]),[B,ye]=n.useState("model"),[te,we]=n.useState(""),[O,H]=n.useState([]),[Se,ve]=n.useState(!1),[Ae,ne]=n.useState([]),[Pe,je]=n.useState(!1);n.useEffect(()=>{s&&(he(!0),zt().then(a=>{Ie(a.models),le(a.favoriteProviders),Ce(a.favoriteModels)}).catch(()=>{}).finally(()=>he(!1)))},[s]),n.useEffect(()=>{s&&(je(!0),ne([]),Dt(void 0,u).then(a=>{ne(a)}).catch(()=>{ne([])}).finally(()=>je(!1)))},[s,u]),n.useEffect(()=>{if(!s)return;const a=Ht;if(typeof a!="function"){H([]),ve(!1);return}ve(!0),H([]),a(u).then(C=>{H(C)}).catch(()=>{H([])}).finally(()=>ve(!1))},[s,u]);const i=A.model.includes("/")?A.model:"",b=n.useCallback(a=>{const C=kt.has(a.role)?a.role:"custom";N(a.title),I(a.description),E(a.icon),$(C),F(a.systemPrompt),Y(Ee=>({...Ee,thinkingLevel:a.thinkingLevel,maxTurns:a.maxTurns})),oe(!1),r(1)},[]),_=n.useCallback(a=>{Y(C=>({...C,model:a}))},[]),U=n.useCallback(a=>{ye(a),a==="model"&&we("")},[]),q=n.useCallback(async a=>{const C=be,ke=C.includes(a)?C.filter(fe=>fe!==a):[a,...C];le(ke);try{await ht({favoriteProviders:ke,favoriteModels:me})}catch{le(C)}},[be,me]),J=n.useCallback(async a=>{const C=me,ke=C.includes(a)?C.filter(fe=>fe!==a):[a,...C];Ce(ke);try{await ht({favoriteProviders:be,favoriteModels:ke})}catch{Ce(C)}},[be,me]),_e=n.useCallback(a=>{Q(a.id),N(a.name),E(a.icon),I(a.description??a.title),$(a.role),ie(a.soul??""),F(a.instructionsText??""),r(1)},[]);if(n.useEffect(()=>{!s||!c||(r(1),p("custom"),N(c.name??""),I(c.title??""),E(c.icon??""),$(kt.has(c.role)?c.role:"custom"),T(c.reportsTo??""),F(c.instructionsText??""),ie(c.soul??""),m(c.memory??""),pe(c.skills??[]),Y(a=>({...a,thinkingLevel:c.thinkingLevel??a.thinkingLevel,maxTurns:c.maxTurns??a.maxTurns})))},[s,c]),!s)return null;const W=()=>{r(0),p("presets"),N(""),I(""),E(""),$("custom"),T(""),M(""),F(""),se(""),ie(""),m(""),Y({model:"",thinkingLevel:"off",maxTurns:1e3}),ye("model"),we(""),Q(null),pe([]),D(null),oe(!1),o()},Oe=async()=>{if(v.trim()){ee(!0),D(null);try{const a={};B==="runtime"?te.trim()&&(a.runtimeHint=te.trim()):A.model.trim()&&(a.model=A.model.trim()),A.thinkingLevel!=="off"&&(a.thinkingLevel=A.thinkingLevel),A.maxTurns!==1e3&&(a.maxTurns=A.maxTurns),await Vt({name:v.trim(),role:R,...y.trim()?{title:y.trim()}:{},...f.trim()?{icon:f.trim()}:{},...j.trim()?{reportsTo:j.trim()}:{},...h.trim()?{instructionsPath:h.trim()}:{},...K.trim()?{instructionsText:K.trim()}:{},...Z.trim()?{heartbeatProcedurePath:Z.trim()}:{},...G.trim()?{soul:G.trim()}:{},...z.trim()?{memory:z.trim()}:{},...Object.keys(a).length>0?{runtimeConfig:a}:{},...re.length>0?{metadata:{skills:re}}:{}},u),W(),k()}catch(a){D(a instanceof Error?a.message:"Failed to create agent")}finally{ee(!1)}}},He=jt.find(a=>a.value===R),$e=j.trim(),Le=$e?Ae.find(a=>a.id===$e):void 0,ze=te?O.find(a=>a.runtimeId===te):void 0,qe=a=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"agent-dialog-field",children:[e.jsx("label",{id:a,children:"Runtime Source"}),e.jsxs("div",{className:"agent-runtime-mode-toggle",role:"radiogroup","aria-labelledby":a,children:[e.jsxs("label",{className:`agent-runtime-mode-option${B==="model"?" agent-runtime-mode-option--active":""}`,children:[e.jsx("input",{type:"radio",name:a,value:"model",checked:B==="model",onChange:()=>U("model")}),e.jsx("span",{children:"Built-in Model"})]}),e.jsxs("label",{className:`agent-runtime-mode-option${B==="runtime"?" agent-runtime-mode-option--active":""}`,children:[e.jsx("input",{type:"radio",name:a,value:"runtime",checked:B==="runtime",onChange:()=>U("runtime")}),e.jsx("span",{children:"Plugin Runtime"})]})]})]}),B==="model"?e.jsxs("div",{className:"agent-dialog-field",children:[e.jsx("label",{children:"Model"}),X?e.jsx("div",{className:"agent-dialog-loading",children:"Loading models…"}):e.jsx(qt,{id:"agent-model",label:"Model",value:i,onChange:_,models:ue,placeholder:"Select a model…",favoriteProviders:be,onToggleFavorite:q,favoriteModels:me,onToggleModelFavorite:J})]}):e.jsxs("div",{className:"agent-dialog-field",children:[e.jsx("label",{htmlFor:"agent-runtime-hint",children:"Runtime"}),Se?e.jsx("div",{className:"agent-dialog-loading",children:"Loading runtimes…"}):e.jsxs("select",{id:"agent-runtime-hint",className:"select",value:te,onChange:C=>we(C.target.value),children:[e.jsx("option",{value:"",children:O.length>0?"Select a plugin runtime…":"No plugin runtimes available"}),O.map(C=>e.jsx("option",{value:C.runtimeId,children:C.description?`${C.name} — ${C.description}`:C.name},`${C.pluginId}:${C.runtimeId}`))]})]})]});return fn.createPortal(e.jsxs("div",{className:"agent-dialog-overlay",onClick:a=>{a.target===a.currentTarget&&W()},children:[e.jsxs("div",{className:"agent-dialog",role:"dialog","aria-modal":"true","aria-label":"Create new agent",children:[e.jsxs("div",{className:"agent-dialog-header",children:[e.jsx("span",{className:"agent-dialog-header-title",children:"New Agent"}),e.jsx("button",{className:"btn-icon",onClick:W,"aria-label":"Close",children:"×"})]}),e.jsx("div",{className:"agent-dialog-steps",children:[0,1,2].map(a=>e.jsx("div",{className:`agent-dialog-step${a===g?" active":a<g?" completed":""}`,"aria-label":`Step ${a+1}`},a))}),e.jsxs("div",{className:"agent-dialog-body",children:[g===0&&e.jsxs("div",{children:[e.jsxs("div",{className:"agent-dialog-tabs",role:"tablist","aria-label":"Agent setup mode",children:[e.jsx("button",{id:"agent-dialog-tab-presets",type:"button",role:"tab","aria-controls":"agent-dialog-panel-presets","aria-selected":d==="presets",tabIndex:d==="presets"?0:-1,className:`agent-dialog-tab${d==="presets"?" active":""}`,onClick:()=>p("presets"),"data-testid":"agent-dialog-tab-presets",children:"Preset personas"}),e.jsx("button",{id:"agent-dialog-tab-custom",type:"button",role:"tab","aria-controls":"agent-dialog-panel-custom","aria-selected":d==="custom",tabIndex:d==="custom"?0:-1,className:`agent-dialog-tab${d==="custom"?" active":""}`,onClick:()=>p("custom"),"data-testid":"agent-dialog-tab-custom",children:"Custom agent"})]}),d==="presets"&&e.jsx("div",{id:"agent-dialog-panel-presets",className:"agent-dialog-tab-panel",role:"tabpanel","aria-labelledby":"agent-dialog-tab-presets",children:e.jsxs("div",{className:"agent-presets",children:[e.jsx("div",{className:"agent-presets-header",children:"Choose a preset persona to prefill role, identity, soul, and instructions"}),e.jsx("div",{className:"agent-presets-grid",children:At.map(a=>e.jsxs("button",{type:"button",className:`agent-preset-card${P===a.id?" selected":""}`,"data-testid":`preset-${a.id}`,onClick:()=>_e(a),title:a.title,children:[e.jsx("span",{className:"agent-preset-icon",children:a.icon}),e.jsx("span",{className:"agent-preset-name",children:a.name}),e.jsx("span",{className:"agent-preset-role",children:a.role}),a.description&&e.jsx("span",{className:"agent-preset-description",children:a.description})]},a.id))})]})}),d==="custom"&&e.jsxs("div",{id:"agent-dialog-panel-custom",className:"agent-dialog-tab-panel",role:"tabpanel","aria-labelledby":"agent-dialog-tab-custom",children:[e.jsxs("div",{className:"agent-dialog-section",children:[e.jsx("div",{className:"agent-dialog-section-header",children:"Identity"}),e.jsxs("div",{className:"agent-dialog-field",children:[e.jsxs("label",{htmlFor:"agent-name",children:["Name ",!P&&e.jsx("span",{className:"agent-dialog-required",children:"*"})]}),e.jsx("input",{id:"agent-name",type:"text",className:"input",placeholder:"e.g. Frontend Reviewer",value:v,onChange:a=>N(a.target.value)})]}),e.jsxs("div",{className:"agent-dialog-field agent-dialog-field--title",children:[e.jsxs("label",{htmlFor:"agent-title",children:["Title ",e.jsx("span",{className:"agent-dialog-optional",children:"(optional)"})]}),e.jsx("input",{id:"agent-title",type:"text",className:"input",placeholder:"e.g. Senior Code Reviewer",value:y,onChange:a=>I(a.target.value)})]}),e.jsxs("div",{className:"agent-dialog-field",children:[e.jsxs("label",{htmlFor:"agent-icon",children:["Icon ",e.jsx("span",{className:"agent-dialog-optional",children:"(optional)"})]}),e.jsx("input",{id:"agent-icon",type:"text",className:"input",placeholder:"e.g. 🤖",value:f,onChange:a=>E(a.target.value)})]}),e.jsxs("div",{className:"agent-dialog-field",children:[e.jsx("label",{children:"Role"}),e.jsx("div",{className:"agent-role-grid",children:jt.map(a=>e.jsxs("button",{type:"button",className:`agent-role-option${R===a.value?" selected":""}`,onClick:()=>$(a.value),children:[e.jsx("span",{className:"agent-role-option-icon",children:a.icon}),e.jsx("span",{className:"agent-role-option-label",children:a.label})]},a.value))})]})]}),e.jsxs("div",{className:"agent-dialog-section",children:[e.jsx("div",{className:"agent-dialog-section-header",children:"Configuration"}),e.jsxs("div",{className:"agent-dialog-field",children:[e.jsxs("label",{htmlFor:"agent-reports-to",children:["Reports To ",e.jsx("span",{className:"agent-dialog-optional",children:"(optional)"})]}),e.jsxs("select",{id:"agent-reports-to",className:"select",value:j,onChange:a=>T(a.target.value),disabled:Pe,children:[e.jsx("option",{value:"",children:"No manager"}),Ae.map(a=>e.jsxs("option",{value:a.id,children:[a.name," (",a.id,")"]},a.id))]})]}),e.jsxs("div",{className:"agent-dialog-field",children:[e.jsxs("label",{htmlFor:"agent-soul",children:["Soul ",e.jsx("span",{className:"agent-dialog-optional",children:"(optional)"})]}),e.jsx("textarea",{id:"agent-soul",className:"input",rows:2,placeholder:"Describe the agent's personality and communication style...",value:G,onChange:a=>ie(a.target.value)})]}),e.jsxs("div",{className:"agent-dialog-field",children:[e.jsxs("label",{htmlFor:"agent-memory",children:["Agent Memory ",e.jsx("span",{className:"agent-dialog-optional",children:"(optional)"})]}),e.jsx("textarea",{id:"agent-memory",className:"input",rows:2,placeholder:"Private to this agent — durable preferences, operating habits, and context it should carry across tasks...",value:z,onChange:a=>m(a.target.value)})]}),e.jsxs("div",{className:"agent-dialog-field",children:[e.jsxs("label",{htmlFor:"agent-instructions-path",children:["Instructions Path ",e.jsx("span",{className:"agent-dialog-optional",children:"(optional)"})]}),e.jsx("input",{id:"agent-instructions-path",type:"text",className:"input",placeholder:"e.g. .fusion/agents/reviewer.md",value:h,onChange:a=>M(a.target.value)})]}),e.jsxs("div",{className:"agent-dialog-field",children:[e.jsxs("label",{htmlFor:"agent-heartbeat-procedure-path",children:["Heartbeat Procedure Path ",e.jsx("span",{className:"agent-dialog-optional",children:"(optional)"})]}),e.jsx("input",{id:"agent-heartbeat-procedure-path",type:"text",className:"input",placeholder:"e.g. .fusion/agents/ceo-agent2736/HEARTBEAT.md",value:Z,onChange:a=>se(a.target.value)}),e.jsx("p",{className:"agent-dialog-optional agent-dialog-field-hint",children:"Path to the agent's heartbeat procedure path, typically .fusion/agents/ceo-agent2736/HEARTBEAT.md. Legacy id-only default paths still work."})]}),e.jsxs("div",{className:"agent-dialog-field",children:[e.jsxs("label",{htmlFor:"agent-instructions-text",children:["Inline Instructions ",e.jsx("span",{className:"agent-dialog-optional",children:"(optional)"})]}),e.jsx("textarea",{id:"agent-instructions-text",className:"input",rows:4,placeholder:"Add custom behavior instructions...",value:K,onChange:a=>F(a.target.value)})]})]}),e.jsxs("div",{className:"agent-dialog-section",children:[e.jsx("div",{className:"agent-dialog-section-header",children:"Runtime"}),qe("agent-runtime-source-step-0")]}),e.jsxs("div",{className:"agent-dialog-ai-generate",children:[e.jsxs("button",{type:"button",className:"btn btn--ai-generate",onClick:()=>oe(!0),children:[e.jsx("span",{children:"✨"}),"Generate with AI"]}),e.jsx("p",{className:"agent-dialog-ai-hint",children:"Describe your agent's role and let AI generate a specification"})]})]})]}),g===1&&e.jsxs("div",{children:[qe("agent-runtime-source-step-1"),e.jsxs("div",{className:"agent-dialog-field",children:[e.jsx("label",{htmlFor:"agent-thinking",children:"Thinking Level"}),e.jsxs("select",{id:"agent-thinking",className:"select",value:A.thinkingLevel,onChange:a=>Y(C=>({...C,thinkingLevel:a.target.value})),children:[e.jsx("option",{value:"off",children:"Off"}),e.jsx("option",{value:"minimal",children:"Minimal"}),e.jsx("option",{value:"low",children:"Low"}),e.jsx("option",{value:"medium",children:"Medium"}),e.jsx("option",{value:"high",children:"High"})]})]}),e.jsxs("div",{className:"agent-dialog-field",children:[e.jsx("label",{htmlFor:"agent-max-turns",children:"Max Turns"}),e.jsx("input",{id:"agent-max-turns",type:"number",className:"input",min:1,max:2e3,value:A.maxTurns,onChange:a=>Y(C=>({...C,maxTurns:Math.max(1,parseInt(a.target.value,10)||1)}))})]}),e.jsxs("div",{className:"agent-dialog-field",children:[e.jsx(xn,{id:"agent-skills",label:"Skills",value:re,onChange:pe,projectId:u}),e.jsx("p",{className:"agent-dialog-optional agent-dialog-skills-hint",children:"Optional skills to assign to this agent"})]})]}),g===2&&e.jsxs("div",{children:[e.jsx("p",{className:"agent-dialog-info",children:"Review your agent configuration before creating."}),e.jsxs("div",{className:"agent-dialog-summary",children:[e.jsxs("div",{className:"agent-dialog-summary-row",children:[e.jsx("span",{className:"agent-dialog-summary-row-label",children:"Name"}),e.jsxs("span",{className:"agent-dialog-summary-row-value",children:[f&&e.jsx("span",{className:"agent-dialog-icon-prefix",children:f}),v]})]}),e.jsxs("div",{className:"agent-dialog-summary-row agent-dialog-summary-row--editable agent-dialog-summary-row--title",children:[e.jsx("label",{className:"agent-dialog-summary-row-label",htmlFor:"agent-review-title",children:"Title"}),e.jsx("input",{id:"agent-review-title",type:"text",className:"input",placeholder:"e.g. Senior Code Reviewer",value:y,onChange:a=>I(a.target.value)})]}),e.jsxs("div",{className:"agent-dialog-summary-row",children:[e.jsx("span",{className:"agent-dialog-summary-row-label",children:"Role"}),e.jsxs("span",{children:[He?.icon," ",He?.label]})]}),$e&&e.jsxs("div",{className:"agent-dialog-summary-row",children:[e.jsx("span",{className:"agent-dialog-summary-row-label",children:"Reports To"}),e.jsx("span",{children:Le?`${Le.name} (${Le.id})`:$e})]}),e.jsxs("div",{className:"agent-dialog-summary-row agent-dialog-summary-row--editable",children:[e.jsx("label",{className:"agent-dialog-summary-row-label",htmlFor:"agent-review-soul",children:"Soul"}),e.jsx("textarea",{id:"agent-review-soul",className:"input",rows:2,placeholder:"Describe the agent's personality and communication style...",value:G,onChange:a=>ie(a.target.value)})]}),e.jsxs("div",{className:"agent-dialog-summary-row agent-dialog-summary-row--editable",children:[e.jsx("label",{className:"agent-dialog-summary-row-label",htmlFor:"agent-review-heartbeat-procedure-path",children:"Heartbeat Procedure Path"}),e.jsx("input",{id:"agent-review-heartbeat-procedure-path",type:"text",className:"input",placeholder:"e.g. .fusion/agents/ceo-agent2736/HEARTBEAT.md",value:Z,onChange:a=>se(a.target.value)})]}),e.jsxs("div",{className:"agent-dialog-summary-row agent-dialog-summary-row--editable",children:[e.jsx("label",{className:"agent-dialog-summary-row-label",htmlFor:"agent-review-instructions-path",children:"Instructions Path"}),e.jsx("input",{id:"agent-review-instructions-path",type:"text",className:"input",placeholder:"e.g. .fusion/agents/reviewer.md",value:h,onChange:a=>M(a.target.value)})]}),e.jsxs("div",{className:"agent-dialog-summary-row agent-dialog-summary-row--editable",children:[e.jsx("label",{className:"agent-dialog-summary-row-label",htmlFor:"agent-review-instructions-text",children:"Inline Instructions"}),e.jsx("textarea",{id:"agent-review-instructions-text",className:"input",rows:4,placeholder:"Add custom behavior instructions...",value:K,onChange:a=>F(a.target.value)})]}),e.jsxs("div",{className:"agent-dialog-summary-row",children:[e.jsx("span",{className:"agent-dialog-summary-row-label",children:B==="runtime"?"Runtime":"Model"}),e.jsx("span",{children:B==="runtime"?ze?ze.name:e.jsx("em",{className:"agent-dialog-summary-row-value--muted",children:"Not selected"}):i?e.jsxs(e.Fragment,{children:[e.jsx(Ot,{provider:i.split("/")[0],size:"sm"})," ",(()=>{const a=i.indexOf("/"),C=i.slice(0,a),Ee=i.slice(a+1);return ue.find(fe=>fe.provider===C&&fe.id===Ee)?.name||i})()]}):e.jsx("em",{className:"agent-dialog-summary-row-value--muted",children:"default"})})]}),e.jsxs("div",{className:"agent-dialog-summary-row",children:[e.jsx("span",{className:"agent-dialog-summary-row-label",children:"Thinking"}),e.jsx("span",{className:"agent-dialog-summary-row-value--capitalize",children:A.thinkingLevel})]}),e.jsxs("div",{className:"agent-dialog-summary-row",children:[e.jsx("span",{className:"agent-dialog-summary-row-label",children:"Max Turns"}),e.jsx("span",{children:A.maxTurns})]}),re.length>0&&e.jsxs("div",{className:"agent-dialog-summary-row",children:[e.jsx("span",{className:"agent-dialog-summary-row-label",children:"Skills"}),e.jsxs("span",{children:[re.length," skill",re.length!==1?"s":""," selected"]})]})]}),de&&e.jsx("p",{className:"agent-dialog-error",children:de})]})]}),e.jsxs("div",{className:"agent-dialog-footer",children:[g>0&&e.jsx("button",{className:"btn",onClick:()=>r(a=>a-1),disabled:ce,children:"Back"}),e.jsx("button",{className:"btn",onClick:W,disabled:ce,children:"Cancel"}),g<2?e.jsx("button",{className:"btn btn--primary",onClick:()=>r(a=>a+1),disabled:g===0&&!v.trim()&&!P,children:"Next"}):e.jsx("button",{className:"btn btn--primary",onClick:()=>void Oe(),disabled:ce||!v.trim(),children:ce?"Creating...":"Create"})]})]}),e.jsx(_n,{isOpen:ge,onClose:()=>oe(!1),onGenerated:b,projectId:u})]}),document.body)}function na({isOpen:s,onClose:o,onUseDraft:k,projectId:u,existingAgents:c}){const[g,r]=n.useState("initial"),[d,p]=n.useState(""),[v,N]=n.useState(null),[y,I]=n.useState(""),[f,E]=n.useState("answer"),[R,$]=n.useState(""),[j,T]=n.useState(null),[h,M]=n.useState(null),[K,F]=n.useState([]),Z=n.useCallback(()=>{r("initial"),p(""),N(null),I(""),E("answer"),$(""),T(null),M(null),F([])},[]),se=n.useMemo(()=>At.map(m=>({id:m.id,label:m.name,description:m.description})),[]);n.useEffect(()=>{if(!v)return;const m=Wt(v,u,{onThinking:A=>{F(Y=>{const P=[...Y],Q=P[P.length-1];return Q&&!Q.question?(P[P.length-1]={...Q,thinkingOutput:`${Q.thinkingOutput??""}${A}`},P):[...P,{response:{},thinkingOutput:A}]})},onQuestion:A=>{I(A.question),E(A.id),r("question")},onSummary:A=>{T(A),r("summary")},onError:A=>{M(A),r("error")}});return()=>m.close()},[v,u]);const G=async()=>{try{v&&await Ut(v,u)}catch{}finally{Z(),o()}};if(n.useEffect(()=>{s||Z()},[s,Z]),!s)return null;const ie=async()=>{r("loading"),M(null);try{const m=await Kt(d,{existingAgents:c.map(A=>({id:A.id,name:A.name,role:A.role})),templates:se},u);N(m.sessionId)}catch(m){M(m.message),r("error")}},z=async()=>{if(v){r("loading"),M(null);try{const m={[f]:R};F(A=>[...A,{question:{id:f,type:"text",question:y},response:m}]),await Gt(v,m,u),$("")}catch(m){M(m.message),r("error")}}};return e.jsx("div",{className:"modal-overlay open",role:"presentation",children:e.jsxs("div",{className:"modal modal-lg experimental-agent-onboarding-modal",role:"dialog","aria-modal":"true","aria-label":"Experimental agent onboarding",children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:"Experimental Agent Onboarding"}),e.jsx("button",{className:"modal-close",onClick:()=>void G(),"aria-label":"Close",children:"×"})]}),K.length>0&&e.jsx(Bt,{entries:K}),g==="initial"&&e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"agent-onboarding-intent",children:"What should this new agent own?"}),e.jsx("textarea",{id:"agent-onboarding-intent",className:"input experimental-agent-onboarding-modal__textarea",value:d,onChange:m=>p(m.target.value)}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("button",{className:"btn",onClick:()=>void G(),children:"Cancel"}),e.jsx("button",{className:"btn btn-primary",disabled:!d.trim(),onClick:()=>void ie(),children:"Start onboarding"})]})]}),(g==="loading"||g==="question")&&e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"agent-onboarding-answer",children:y||"Thinking..."}),e.jsx("textarea",{id:"agent-onboarding-answer",className:"input experimental-agent-onboarding-modal__textarea",value:R,onChange:m=>$(m.target.value)}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("button",{className:"btn",onClick:()=>void G(),children:"Cancel"}),e.jsx("button",{className:"btn btn-primary",disabled:g==="loading"||!R.trim(),onClick:()=>void z(),children:"Continue"})]})]}),g==="summary"&&j&&e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Draft ready for review"}),e.jsxs("div",{className:"experimental-agent-onboarding-modal__summary card",children:[e.jsxs("p",{children:[e.jsx("strong",{children:"Name:"})," ",j.name]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Role:"})," ",j.role]}),j.templateId&&e.jsxs("p",{children:[e.jsx("strong",{children:"Template:"})," ",j.templateId]}),j.patternAgentId&&e.jsxs("p",{children:[e.jsx("strong",{children:"Pattern agent:"})," ",j.patternAgentId]}),j.rationale&&e.jsxs("p",{children:[e.jsx("strong",{children:"Why:"})," ",j.rationale]})]}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("button",{className:"btn",onClick:()=>void G(),children:"Cancel"}),e.jsx("button",{className:"btn btn-primary",onClick:()=>k(j),children:"Continue to agent form"})]})]}),g==="error"&&h&&e.jsxs("div",{className:"form-group",children:[e.jsx("div",{className:"form-error",children:h}),e.jsx("div",{className:"modal-actions",children:e.jsx("button",{className:"btn",onClick:()=>void G(),children:"Close"})})]})]})})}function aa(s){const o=s.match(/^---\s*\r?\n([\s\S]*?)\r?\n---(?:\r?\n([\s\S]*))?$/);if(!o)throw new Error("Missing YAML frontmatter delimiters (---)");const k=o[1].split(/\r?\n/),u=o[2]??"",c={name:""},g=[];let r=!1;for(const d of k){const v=d.trimEnd().trim();if(!v)continue;if(v.startsWith("skills:")){r=!0;continue}if(r&&v.startsWith("- ")){g.push(v.slice(2).trim());continue}r=!1;const[N,...y]=v.split(":"),f=y.join(":").trim().replace(/^['"]|['"]$/g,"");N==="name"&&(c.name=f),N==="title"&&(c.title=f),N==="icon"&&(c.icon=f),N==="role"&&(c.role=f),N==="reportsTo"&&(c.reportsTo=f)}if(!c.name)throw new Error("Missing required field: name");return g.length>0&&(c.skills=g),u.trim().length>0&&(c.instructionBody=u),c}function sa({isOpen:s,onClose:o,onImported:k,projectId:u}){Ct(s);const[c,g]=n.useState("input"),[r,d]=n.useState("paste"),[p,v]=n.useState(""),[N,y]=n.useState([]),[I,f]=n.useState("Unknown"),[E,R]=n.useState([]),[$,j]=n.useState([]),[T,h]=n.useState([]),[M,K]=n.useState([]),[F,Z]=n.useState(!1),[se,G]=n.useState(!1),[ie,z]=n.useState(null),[m,A]=n.useState(null),[Y,P]=n.useState(null),Q=n.useRef(null),re=n.useRef(null),[pe,ce]=n.useState([]),[ee,de]=n.useState(""),[D,ge]=n.useState(null),[oe,ue]=n.useState(!1),[Ie,X]=n.useState(null),he=n.useRef(!1);n.useEffect(()=>{r==="browse"&&!he.current&&!oe&&(he.current=!0,ue(!0),X(null),pt().then(i=>{i.error?X(i.error):i.companies.length>0?ce(i.companies):X("No companies available")}).catch(i=>{X(i instanceof Error?i.message:"Failed to load companies")}).finally(()=>{ue(!1)}))},[r,oe]);const be=n.useCallback(()=>{he.current=!0,X(null),ce([]),ge(null),ue(!0),pt().then(i=>{i.error?X(i.error):i.companies.length>0?ce(i.companies):X("No companies available")}).catch(i=>{X(i instanceof Error?i.message:"Failed to load companies")}).finally(()=>{ue(!1)})},[]),le=n.useCallback(()=>{g("input"),d("paste"),v(""),y([]),f("Unknown"),R([]),j([]),h([]),K([]),Z(!1),G(!1),z(null),A(null),P(null),ce([]),de(""),ge(null),ue(!1),X(null),he.current=!1},[]),me=n.useCallback(()=>{le(),o()},[le,o]),Ce=n.useCallback(i=>{const b=i.target.files?.[0];if(!b)return;const _=new FileReader;_.onload=U=>{const q=U.target?.result;d("file"),y([]),v(q),z(null)},_.onerror=()=>{z("Failed to read file")},_.readAsText(b),i.target.value=""},[]),B=n.useCallback(async i=>{const b=Array.from(i.target.files??[]);if(b.length!==0)try{const _=b.filter(q=>(q.webkitRelativePath||q.name).toLowerCase().endsWith("agents.md")).sort((q,J)=>{const _e=q.webkitRelativePath||q.name,W=J.webkitRelativePath||J.name;return _e.localeCompare(W)});if(_.length===0){z("Selected directory has no AGENTS.md files");return}const U=[];for(const q of _){const J=await q.text();U.push(aa(J))}d("directory"),y(U),v(""),z(null)}catch{z("Failed to parse AGENTS.md files from selected directory")}finally{i.target.value=""}},[]);function ye(i){if(!u)return`/api${i}`;const b=i.includes("?")?"&":"?";return`/api${i}${b}projectId=${encodeURIComponent(u)}`}const te=n.useCallback(async()=>{if(r==="directory"&&N.length===0){z("Please select a directory containing AGENTS.md files");return}if(r==="browse"&&!D){z("Please select a company from the catalog");return}if(r!=="directory"&&r!=="browse"&&!p.trim()){z("Please provide manifest content");return}Z(!0),z(null);try{let i;r==="directory"?i={agents:N,dryRun:!0}:r==="browse"&&D?i={importSource:"companies.sh",companySlug:D.slug,dryRun:!0}:i={manifest:p,dryRun:!0};const b=await fetch(ye("/agents/import"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!b.ok){const J=await b.json();throw new Error(J.error??`Parse failed (${b.status})`)}const _=await b.json(),U=_.agents&&_.agents.length>0?_.agents:_.created.map(J=>({name:J,role:"custom"})),q=Array.isArray(_.skills)?_.skills:[];f(_.companyName??"Unknown"),R(U),j(q),h(U.map(J=>J.name)),K(q.map(J=>J.name)),g("preview")}catch(i){z(i instanceof Error?i.message:"Failed to parse manifest")}finally{Z(!1)}},[r,N,p,D,u]),we=n.useCallback(async()=>{G(!0),P(null);try{let i;r==="directory"?i={agents:N,skipExisting:!0,selectedAgents:T,selectedSkills:M}:r==="browse"&&D?i={importSource:"companies.sh",companySlug:D.slug,skipExisting:!0,selectedAgents:T,selectedSkills:M}:i={manifest:p,skipExisting:!0,selectedAgents:T,selectedSkills:M};const b=await fetch(ye("/agents/import"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!b.ok){const U=await b.json();throw new Error(U.error??`Import failed (${b.status})`)}const _=await b.json();A(_),g("result"),k()}catch(i){P(i instanceof Error?i.message:"Failed to import agents")}finally{G(!1)}},[r,N,p,D,T,M,u,k]),O=T.length,H=M.length,Se=`${O} Agent${O!==1?"s":""}`,ve=`${H} Skill${H!==1?"s":""}`,Ae=O>0&&H>0?`${Se} + ${ve}`:H>0?ve:Se,ne=O>0&&H>0?`Importing ${O} agent${O!==1?"s":""} and ${H} skill${H!==1?"s":""}...`:H>0?`Importing ${H} skill${H!==1?"s":""}...`:`Importing ${O} agent${O!==1?"s":""}...`,Pe=i=>{h(b=>b.includes(i)?b.filter(_=>_!==i):[...b,i])},je=i=>{K(b=>b.includes(i)?b.filter(_=>_!==i):[...b,i])};return s?e.jsx("div",{className:"agent-dialog-overlay",onClick:i=>{i.target===i.currentTarget&&me()},children:e.jsxs("div",{className:"agent-dialog agent-import-dialog",role:"dialog","aria-modal":"true","aria-label":"Import agents",children:[e.jsxs("div",{className:"agent-dialog-header",children:[e.jsx("span",{className:"agent-dialog-header-title",children:"Import Agents"}),e.jsx("button",{className:"modal-close",onClick:me,"aria-label":"Close",children:"×"})]}),e.jsxs("div",{className:"agent-dialog-body",children:[c==="input"&&e.jsxs("div",{className:"agent-import-input",children:[e.jsx("p",{className:"agent-import-description",children:"Import agents from an Agent Companies package. Browse the companies.sh catalog to discover published agents, upload an AGENTS.md file, select a directory, or paste manifest content."}),e.jsxs("div",{className:"agent-import-file-upload",children:[e.jsx("input",{ref:Q,type:"file",accept:".md,.txt",onChange:Ce,className:"agent-import-file-input","aria-label":"Upload agent manifest file"}),e.jsx("input",{ref:re,type:"file",webkitdirectory:"",multiple:!0,onChange:B,className:"agent-import-file-input","aria-label":"Select directory"}),e.jsxs("button",{type:"button",className:"btn agent-import-upload-btn",onClick:()=>Q.current?.click(),children:[e.jsx(St,{size:16}),"Choose File"]}),e.jsxs("button",{type:"button",className:"btn agent-import-upload-btn",onClick:()=>re.current?.click(),children:[e.jsx(wn,{size:16}),"Select Directory"]}),e.jsxs("button",{type:"button",className:"btn agent-import-upload-btn",onClick:()=>{d("browse"),y([]),v(""),ge(null),z(null)},children:[e.jsx(Qt,{size:16}),"Browse Catalog"]}),e.jsx("span",{className:"agent-import-file-hint",children:".md and .txt files supported"})]}),r==="browse"&&e.jsxs("div",{className:"agent-import-browse",children:[e.jsxs("div",{className:"agent-import-browse-header",children:[e.jsxs("div",{className:"agent-import-browse-search",children:[e.jsx(Jt,{size:16,className:"agent-import-browse-search-icon"}),e.jsx("input",{type:"text",className:"agent-import-browse-search-input",placeholder:"Search companies...",value:ee,onChange:i=>de(i.target.value),"aria-label":"Search companies"})]}),D&&e.jsxs("div",{className:"agent-import-browse-selected",children:[e.jsx("span",{className:"agent-import-browse-selected-label",children:"Selected:"}),e.jsx("span",{className:"agent-import-browse-selected-name",children:D.name}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>ge(null),children:"Change"})]})]}),oe&&e.jsxs("div",{className:"agent-import-browse-loading",children:[e.jsx(tt,{size:20,className:"spin"}),e.jsx("span",{children:"Loading companies..."})]}),Ie&&e.jsxs("div",{className:"agent-import-browse-error",children:[e.jsx(nt,{size:16}),e.jsx("span",{children:Ie}),e.jsxs("button",{type:"button",className:"btn btn-sm",onClick:be,children:[e.jsx(Qe,{size:14}),"Retry"]})]}),!oe&&!Ie&&e.jsxs("div",{className:"agent-import-browse-list",children:[pe.filter(i=>ee===""||i.name.toLowerCase().includes(ee.toLowerCase())||(i.tagline?.toLowerCase().includes(ee.toLowerCase())??!1)).map(i=>e.jsxs("div",{className:`agent-import-browse-item ${D?.slug===i.slug?"agent-import-browse-item--selected":""}`,onClick:()=>ge(i),role:"button",tabIndex:0,onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&ge(i)},children:[e.jsxs("div",{className:"agent-import-browse-item-header",children:[e.jsx("span",{className:"agent-import-browse-item-name",children:i.name}),i.installs!==void 0&&e.jsxs("span",{className:"agent-import-browse-item-installs",children:[i.installs.toLocaleString()," installs"]})]}),i.tagline&&e.jsx("span",{className:"agent-import-browse-item-tagline",children:i.tagline}),i.repo&&e.jsx("span",{className:"agent-import-browse-item-repo",children:i.repo})]},i.slug)),pe.filter(i=>ee===""||i.name.toLowerCase().includes(ee.toLowerCase())||(i.tagline?.toLowerCase().includes(ee.toLowerCase())??!1)).length===0&&e.jsx("p",{className:"agent-import-browse-empty",children:ee?"No companies match your search":"No companies available"})]})]}),r!=="browse"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"agent-import-divider",children:e.jsx("span",{children:"or paste manifest content"})}),e.jsx("textarea",{className:"agent-import-textarea",placeholder:`---
|
|
511
511
|
name: CEO
|
|
512
512
|
title: Chief Executive Officer
|
|
513
513
|
reportsTo: null
|
|
514
514
|
skills:
|
|
515
515
|
- review
|
|
516
516
|
---
|
|
517
|
-
Agent instructions go here...`,value:p,onChange:s=>{d("paste"),y([]),b(s.target.value),z(null)},rows:8,"aria-label":"Manifest content"})]}),e.jsxs("p",{className:"agent-import-file-hint",children:["Current input: ",r]}),ie&&e.jsxs("p",{className:"agent-dialog-error",children:[e.jsx(nt,{size:14}),ie]})]}),c==="preview"&&e.jsxs("div",{className:"agent-import-preview",children:[e.jsxs("div",{className:"agent-import-company",children:[e.jsx("span",{className:"agent-import-company-label",children:"Company"}),e.jsx("span",{className:"agent-import-company-name",children:I})]}),e.jsxs("div",{className:"agent-import-count",children:[e.jsx(ct,{size:14}),e.jsxs("span",{children:[E.length," agent",E.length!==1?"s":""," found"]})]}),E.length>0&&e.jsxs("div",{className:"agent-import-selection-controls",children:[e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>h(E.map(s=>s.name)),children:"Select all agents"}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>h([]),children:"Clear agents"})]}),E.length>0?e.jsx("div",{className:"agent-import-agent-list",children:E.map((s,v)=>e.jsxs("div",{className:"agent-import-agent-item",children:[e.jsx("label",{className:"checkbox-label",children:e.jsx("input",{type:"checkbox","aria-label":`Select agent ${s.name}`,checked:T.includes(s.name),onChange:()=>Pe(s.name)})}),e.jsx("span",{className:"agent-import-agent-icon",children:s.icon||"🤖"}),e.jsxs("div",{className:"agent-import-agent-details",children:[e.jsx("span",{className:"agent-import-agent-name",children:s.name}),e.jsxs("span",{className:"agent-import-agent-meta",children:[s.title&&e.jsxs("span",{className:"agent-import-agent-title",children:[s.title," · "]}),e.jsx("span",{className:"agent-import-agent-role",children:s.role}),s.reportsTo&&e.jsxs("span",{className:"agent-import-agent-reports",children:[" · reports to ",s.reportsTo]}),s.skills&&s.skills.length>0&&e.jsxs("span",{className:"agent-import-agent-model",children:[" · skills: ",s.skills.join(", ")]})]}),s.instructionsText&&e.jsxs("span",{className:"agent-import-agent-instructions",children:[s.instructionsText.slice(0,100),s.instructionsText.length>100?"...":""]})]})]},v))}):e.jsx("p",{className:"agent-import-empty",children:"No agents found in the manifest."}),$.length>0&&e.jsxs("div",{className:"agent-import-skills-section",children:[e.jsxs("div",{className:"agent-import-count",children:[e.jsx(ct,{size:14}),e.jsxs("span",{children:[$.length," skill",$.length!==1?"s":""," found"]})]}),e.jsxs("div",{className:"agent-import-selection-controls",children:[e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>K($.map(s=>s.name)),children:"Select all skills"}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>K([]),children:"Clear skills"})]}),e.jsx("div",{className:"agent-import-skill-list",children:$.map((s,v)=>e.jsxs("div",{className:"agent-import-skill-item",children:[e.jsx("label",{className:"checkbox-label",children:e.jsx("input",{type:"checkbox","aria-label":`Select skill ${s.name}`,checked:M.includes(s.name),onChange:()=>je(s.name)})}),e.jsx("span",{className:"agent-import-skill-icon",children:"⚡"}),e.jsxs("div",{className:"agent-import-skill-details",children:[e.jsx("span",{className:"agent-import-skill-name",children:s.name}),s.description&&e.jsx("span",{className:"agent-import-skill-description",children:s.description})]})]},`${s.name}-${v}`))})]}),Y&&e.jsxs("p",{className:"agent-dialog-error",children:[e.jsx(nt,{size:14}),Y]})]}),c==="result"&&m&&e.jsxs("div",{className:"agent-import-result",children:[e.jsx("div",{className:"agent-import-result-icon",children:e.jsx(Ke,{size:32})}),e.jsx("h3",{className:"agent-import-result-title",children:"Import Complete"}),e.jsxs("p",{className:"agent-import-result-company",children:["From ",e.jsx("strong",{children:m.companyName??"Unknown"})]}),e.jsxs("div",{className:"agent-import-result-stats",children:[m.created.length>0&&e.jsx("div",{className:"agent-import-result-stat agent-import-result-stat--success",children:e.jsxs("span",{children:[m.created.length," created"]})}),m.skipped.length>0&&e.jsx("div",{className:"agent-import-result-stat agent-import-result-stat--skipped",children:e.jsxs("span",{children:[m.skipped.length," skipped (already exist)"]})}),m.errors.length>0&&e.jsx("div",{className:"agent-import-result-stat agent-import-result-stat--error",children:e.jsxs("span",{children:[m.errors.length," error",m.errors.length!==1?"s":""]})})]}),m.created.length>0&&e.jsx("div",{className:"agent-import-result-agents",children:m.created.map((s,v)=>e.jsxs("div",{className:"agent-import-result-agent",children:[e.jsx(Ke,{size:12}),e.jsx("span",{children:s.name})]},v))}),m.errors.length>0&&e.jsx("div",{className:"agent-import-result-errors",children:m.errors.map((s,v)=>e.jsxs("div",{className:"agent-import-result-error",children:[e.jsx(vt,{size:12}),e.jsxs("span",{children:[s.name,": ",s.error]})]},v))}),m.skills&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"agent-import-result-divider"}),e.jsx("h4",{className:"agent-import-result-section-title",children:"Skills"}),e.jsxs("div",{className:"agent-import-result-stats",children:[m.skills.imported.length>0&&e.jsx("div",{className:"agent-import-result-stat agent-import-result-stat--success",children:e.jsxs("span",{children:[m.skills.imported.length," skill",m.skills.imported.length!==1?"s":""," imported"]})}),m.skills.skipped.length>0&&e.jsx("div",{className:"agent-import-result-stat agent-import-result-stat--skipped",children:e.jsxs("span",{children:[m.skills.skipped.length," skill",m.skills.skipped.length!==1?"s":""," skipped (already exist)"]})}),m.skills.errors.length>0&&e.jsx("div",{className:"agent-import-result-stat agent-import-result-stat--error",children:e.jsxs("span",{children:[m.skills.errors.length," skill",m.skills.errors.length!==1?"s":""," error",m.skills.errors.length!==1?"s":""]})}),m.skills.imported.length===0&&m.skills.skipped.length===0&&m.skills.errors.length===0&&e.jsx("div",{className:"agent-import-result-stat agent-import-result-stat--skipped",children:e.jsx("span",{children:"No skills in package"})})]}),m.skills.imported.length>0&&e.jsx("div",{className:"agent-import-result-agents",children:m.skills.imported.map((s,v)=>e.jsxs("div",{className:"agent-import-result-agent",children:[e.jsx(Ke,{size:12}),e.jsx("span",{children:s.name})]},v))}),m.skills.errors.length>0&&e.jsx("div",{className:"agent-import-result-errors",children:m.skills.errors.map((s,v)=>e.jsxs("div",{className:"agent-import-result-error",children:[e.jsx(vt,{size:12}),e.jsxs("span",{children:[s.name,": ",s.error]})]},v))})]})]})]}),e.jsxs("div",{className:"agent-dialog-footer",children:[c==="preview"&&e.jsx("button",{className:"btn",onClick:()=>g("input"),disabled:se,children:"Back"}),e.jsx("button",{className:"btn",onClick:me,disabled:se,children:c==="result"?"Close":"Cancel"}),c==="input"&&e.jsx("button",{className:"btn btn-task-create",onClick:()=>void te(),disabled:F||(r==="directory"?N.length===0:r==="browse"?!D:!p.trim()),children:F?e.jsxs(e.Fragment,{children:[e.jsx(tt,{size:14,className:"spin"}),"Parsing..."]}):"Preview"}),c==="preview"&&e.jsx("button",{className:"btn btn-task-create",onClick:()=>void we(),disabled:se||O===0&&H===0,children:se?e.jsxs(e.Fragment,{children:[e.jsx(tt,{size:14,className:"spin"}),ne]}):`Import ${Ae}`})]})]})}):null}const sa=n.lazy(()=>vn(()=>import("./AgentDetailView-DGqT1oDt.js").then(i=>i.A),__vite__mapDeps([0,1,2,3,4,5,6,7])).then(i=>({default:i.AgentDetailView}))),Ue=[{value:"triage",label:"Triage",icon:"⊕"},{value:"executor",label:"Executor",icon:"▶"},{value:"reviewer",label:"Reviewer",icon:"⊙"},{value:"merger",label:"Merger",icon:"⊞"},{value:"scheduler",label:"Scheduler",icon:"◷"},{value:"engineer",label:"Engineer",icon:"⎔"},{value:"custom",label:"Custom",icon:"✦"}],ot=[.1,.25,.5,1,2,3,5,10],ia=/(?:^|\/)skills\/([^/]+)\/SKILL\.md$/i;function At(i){const o=i.trim();if(!o)return i;const k=o.match(ia);return k?.[1]?k[1]:o}function Je(i){switch(i){case"running":return"agent-badge--running";case"active":return"agent-badge--active";case"paused":return"agent-badge--paused";case"error":return"agent-badge--error";case"terminated":return"agent-badge--terminated";case"idle":default:return"agent-badge--idle"}}function ut(i,o){switch(o){case"running":return`${i}--running`;case"active":return`${i}--active`;case"paused":return`${i}--paused`;case"error":return`${i}--error`;case"terminated":return`${i}--terminated`;case"idle":default:return`${i}--idle`}}function Et({node:i,onSelect:o,getHealthStatus:k,getRoleIcon:u,getSkillBadges:c,selectedAgentId:g}){const{agent:r,children:d}=i,p=k(r),b=Je(r.state),N=ut("org-chart-node-card",r.state);return e.jsxs("div",{className:`org-chart-node${d.length>0?" org-chart-node--has-children":""}`,children:[e.jsxs("div",{className:`${N}${g===r.id?" agent-card--selected":""}`,onClick:()=>o(r.id),role:"button",tabIndex:0,onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.key===" "&&y.preventDefault(),o(r.id))},children:[e.jsxs("div",{className:"org-chart-node__header",children:[e.jsx("span",{className:"org-chart-node__icon",children:u(r.role)}),e.jsx("span",{className:"org-chart-node__name",children:r.name})]}),e.jsxs("div",{className:"org-chart-node__meta",children:[e.jsx("span",{className:`org-chart-node__badge ${b}`,children:r.state}),e.jsxs("span",{className:"org-chart-node__health",style:{color:p.color},title:p.reason??p.label,children:[p.icon,!p.stateDerived&&e.jsx("span",{className:"text-secondary",children:p.label})]}),(()=>{const y=c(r);if(y.length===0)return null;const I=y.slice(0,2),f=y.length-2;return e.jsxs(e.Fragment,{children:[I.map(E=>e.jsx("span",{className:"org-chart-node__skill",children:At(E)},E)),f>0&&e.jsxs("span",{className:"org-chart-node__skill",children:["+",f]})]})})()]})]}),d.length>0&&e.jsx("div",{className:"org-chart-children",role:"group","aria-label":`${r.name} employees`,children:d.map(y=>e.jsx(Et,{node:y,onSelect:o,getHealthStatus:k,getRoleIcon:u,getSkillBadges:c,selectedAgentId:g},y.agent.id))})]})}function ga({addToast:i,projectId:o,onOpenTaskLogs:k,agentOnboardingEnabled:u=!1}){const[c,g]=n.useState(!1),d=Jt()==="mobile",[p,b]=n.useState("all"),{agents:N,stats:y,isLoading:I,loadAgents:f}=Zt(o,{filterState:p,showSystemAgents:c}),[E,R]=n.useState(!1),[$,j]=n.useState(!1),[T,h]=n.useState(null),[M,K]=n.useState(!1),[F,Z]=n.useState(null),se=d&&!!F,[G,ie]=n.useState("dashboard"),[z,m]=n.useState(null),[A,Y]=n.useState(!1),[P,Q]=n.useState(()=>{if(typeof window>"u")return"list";const t=bt("fn-agent-view",o);return t==="list"||t==="board"||t==="org"?t:"list"}),[re,pe]=n.useState([]),[ce,ee]=n.useState(!1),[de,D]=n.useState(!1),[ge,oe]=n.useState(!1),ue=n.useRef(null),{confirm:Ie}=Xt(),X=n.useRef(null),he=n.useId();n.useEffect(()=>{const t=bt("fn-agent-view",o);if(t==="list"||t==="board"||t==="org"){Q(t);return}Q("list")},[o]),n.useEffect(()=>{Yt("fn-agent-view",P,o)},[P,o]);const[ve,le]=n.useState(null),me=n.useRef(null),[Ce,B]=n.useState(null),[ye,te]=n.useState(null),[we,O]=n.useState({}),[H,Se]=n.useState(1),[be,Ae]=n.useState(!1),[ne,Pe]=n.useState(new Set),[je,s]=n.useState(new Map),v=n.useRef(!0);n.useEffect(()=>(v.current=!0,()=>{v.current=!1}),[]),n.useEffect(()=>{en(o).then(t=>{v.current&&Se(t.heartbeatMultiplier??1)}).catch(()=>{})},[o]);const _=n.useCallback(async t=>{const l=Number.isFinite(t)&&t>0?t:1;Se(l),Ae(!0);try{await tn({heartbeatMultiplier:l},o),i(`Heartbeat speed set to ×${l.toFixed(1)}`,"success")}catch(w){i(`Failed to save heartbeat multiplier: ${xe(w)}`,"error")}finally{v.current&&Ae(!1)}},[o,i]),U=n.useMemo(()=>je.size===0?N:N.map(t=>{const l=je.get(t.id);return l?{...t,state:l}:t}),[N,je]),q=n.useMemo(()=>U.filter(t=>c||!at(t)),[U,c]),J=n.useMemo(()=>U.filter(t=>t.state!=="active"&&t.state!=="running"?!1:c||!at(t)),[U,c]),_e=n.useMemo(()=>{if(c)return re;const t=l=>at(l.agent)?null:{...l,children:l.children.map(t).filter(w=>w!==null)};return re.map(t).filter(l=>l!==null)},[re,c]);n.useEffect(()=>{if(P!=="org")return;let t=!1;return ee(!0),nn(o,{includeEphemeral:c}).then(l=>{t||pe(l)}).catch(l=>{t||(i(`Failed to load org chart: ${xe(l)}`,"error"),pe([]))}).finally(()=>{t||ee(!1)}),()=>{t=!0}},[P,o,c,i]),n.useEffect(()=>{const t=setInterval(()=>{f()},3e4);return()=>{clearInterval(t)}},[f]),n.useEffect(()=>{if(!de)return;const t=w=>{const S=w.target;S&&(ue.current?.contains(S)||X.current?.contains(S)||D(!1))},l=w=>{w.key==="Escape"&&(D(!1),X.current?.focus())};return document.addEventListener("mousedown",t),document.addEventListener("touchstart",t),document.addEventListener("keydown",l),()=>{document.removeEventListener("mousedown",t),document.removeEventListener("touchstart",t),document.removeEventListener("keydown",l)}},[de]);const W=async(t,l)=>{if(!ne.has(t)){Pe(w=>new Set(w).add(t)),s(w=>{const S=new Map(w);return S.set(t,l),S});try{await gn(t,l,o),i(`Agent state updated to ${l}`,"success"),await f(),s(w=>{const S=new Map(w);return S.delete(t),S})}catch(w){s(S=>{const V=new Map(S);return V.delete(t),V}),i(`Failed to update state: ${xe(w)}`,"error")}finally{Pe(w=>{const S=new Set(w);return S.delete(t),S})}}},Oe=async(t,l)=>{if(await Ie({title:"Delete Agent",message:`Delete agent "${l}"? This cannot be undone.`,danger:!0}))try{await pn(t,o),i(`Agent "${l}" deleted`,"success"),f()}catch(S){i(`Failed to delete agent: ${xe(S)}`,"error")}},He=async(t,l)=>{const w=N.find(S=>S.id===t);if(w){if(w.role===l){le(null);return}try{await Be(t,{role:l},o),i(`Agent role updated to ${Ue.find(S=>S.value===l)?.label??l}`,"success"),le(null),f()}catch(S){i(`Failed to update role: ${xe(S)}`,"error")}}},$e=(t,l)=>{t.key==="Escape"&&le(null)},Le=async(t,l)=>{ye===t.id&&(te(null),O(w=>{const S={...w};return delete S[t.id],S})),B(t.id);try{await Be(t.id,{runtimeConfig:{...t.runtimeConfig??{},heartbeatIntervalMs:l}},o),i(`Heartbeat interval updated to ${st(l)} for ${t.name}`,"success"),f()}catch(w){i(`Failed to update heartbeat interval: ${xe(w)}`,"error")}finally{B(null)}},ze=async t=>{const l=we[t.id]??"";if(l.trim()===""){i("Please enter a heartbeat interval in minutes","error");return}const w=Number(l);if(isNaN(w)){i("Heartbeat interval must be a valid number","error");return}if(w<=0){i("Heartbeat interval must be greater than 0","error");return}if(w>=1&&w<5){B(t.id);try{await Be(t.id,{runtimeConfig:{...t.runtimeConfig??{},heartbeatIntervalMs:mn}},o),i(`Heartbeat interval set to 5 minutes (minimum). ${w} minute${w!==1?"s":""} was below the 5-minute minimum.`,"success"),te(null),O(V=>{const Te={...V};return delete Te[t.id],Te}),f()}catch(V){i(`Failed to update heartbeat interval: ${xe(V)}`,"error")}finally{B(null)}return}const S=Math.round(w*6e4);B(t.id);try{await Be(t.id,{runtimeConfig:{...t.runtimeConfig??{},heartbeatIntervalMs:S}},o),i(`Heartbeat interval updated to ${st(S)} for ${t.name}`,"success"),te(null),O(V=>{const Te={...V};return delete Te[t.id],Te}),f()}catch(V){i(`Failed to update heartbeat interval: ${xe(V)}`,"error")}finally{B(null)}},qe=t=>{const l=Ge(t.runtimeConfig?.heartbeatIntervalMs),w=Math.round(l/6e4);te(t.id),O(S=>({...S,[t.id]:String(w)}))},a=n.useCallback((t,l)=>{Z(t),ie(l?.initialTab??"dashboard"),m(l?.initialRunId??null),Y(l?.preferActiveRun??!1)},[]),C=n.useCallback(()=>{Z(null),ie("dashboard"),m(null),Y(!1)},[]),Ee=n.useCallback(t=>{a(t)},[a]),ke=n.useCallback(t=>{a(t),d&&oe(!1)},[d,a]),fe=async(t,l)=>{try{await hn(t,o,{source:"on_demand",triggerDetail:"Triggered from dashboard"}),i(`Heartbeat run started for ${l}`,"success"),f()}catch(w){i(`Failed to start heartbeat run: ${xe(w)}`,"error")}},mt=t=>Ue.find(l=>l.value===t)?.label??t,Ze=t=>Ue.find(l=>l.value===t)?.icon??"◆",L=F?q.find(t=>t.id===F)??null:null,gt=t=>Array.isArray(t.metadata?.skills)?t.metadata.skills:[],Xe=t=>un(t),Tt=I&&N.length===0,Ve=n.useCallback(()=>{if(u){j(!0);return}R(!0)},[u]);return e.jsxs("div",{className:"agents-view",children:[e.jsxs("div",{className:"agents-view-header",children:[e.jsxs("div",{className:"agents-view-title",children:[e.jsx(dt,{size:24}),e.jsx("h2",{children:"Agents"})]}),e.jsxs("div",{className:"agents-view-controls",children:[e.jsxs("div",{className:"view-toggle",children:[e.jsx("button",{className:`view-toggle-btn${P==="list"?" active":""}`,onClick:()=>Q("list"),title:"List view","aria-label":"List view","aria-pressed":P==="list",children:e.jsx(an,{size:16})}),e.jsx("button",{className:`view-toggle-btn${P==="board"?" active":""}`,onClick:()=>Q("board"),title:"Board view","aria-label":"Board view","aria-pressed":P==="board",children:e.jsx(Re,{size:16})}),e.jsx("button",{className:`view-toggle-btn${P==="org"?" active":""}`,onClick:()=>Q("org"),title:"Org Chart view","aria-label":"Org Chart view","aria-pressed":P==="org",children:e.jsx(sn,{size:16})})]}),e.jsxs("div",{className:"agents-view-primary-actions",children:[e.jsx("button",{ref:X,className:`btn-icon agent-controls-trigger${de?" agent-controls-trigger--active":""}`,onClick:()=>D(t=>!t),title:"Controls","aria-label":"Controls","aria-haspopup":"dialog","aria-expanded":de,"aria-controls":he,children:e.jsx(Nn,{size:16})}),e.jsx("button",{className:"btn-icon",onClick:()=>void f(),title:"Refresh","aria-label":"Refresh",children:e.jsx(Qe,{size:16,className:I?"spin":void 0})}),e.jsxs("button",{className:"btn btn-task-create btn-sm",onClick:()=>{Ve(),D(!1)},children:[e.jsx(rn,{size:16}),"New Agent"]})]})]})]}),de&&e.jsxs("div",{ref:ue,id:he,className:"agent-controls-panel agent-controls-panel--scrollable",role:"dialog","aria-label":"Agent controls","aria-modal":"false",children:[e.jsxs("div",{className:"agent-controls",children:[e.jsxs("div",{className:"agent-controls-filters",children:[e.jsxs("div",{className:"agent-state-filter",children:[e.jsx(ln,{size:14}),e.jsxs("select",{className:"agent-state-filter-select",value:p,onChange:t=>b(t.target.value),"aria-label":"Filter agents by state",children:[e.jsx("option",{value:"all",children:"All States"}),e.jsx("option",{value:"idle",children:"Idle"}),e.jsx("option",{value:"active",children:"Active"}),e.jsx("option",{value:"running",children:"Running"}),e.jsx("option",{value:"paused",children:"Paused"}),e.jsx("option",{value:"error",children:"Error"}),e.jsx("option",{value:"terminated",children:"Terminated"})]})]}),e.jsxs("label",{className:"checkbox-label agent-system-filter",children:[e.jsx("input",{type:"checkbox",checked:c,onChange:t=>g(t.target.checked),"aria-label":"Show system agents"}),"Show system agents"]})]}),e.jsx("div",{className:"agent-controls-actions",children:e.jsxs("button",{className:"btn",onClick:()=>{K(!0),D(!1)},children:[e.jsx(Ct,{size:16}),"Import"]})})]}),e.jsx("div",{className:"agent-global-controls",children:e.jsxs("div",{className:"heartbeat-multiplier-group",children:[e.jsxs("div",{className:"heartbeat-multiplier-controls",children:[e.jsx("label",{htmlFor:"globalHeartbeatMultiplier",className:"heartbeat-multiplier-label",children:"Heartbeat Speed"}),e.jsx("input",{id:"globalHeartbeatMultiplier",className:"heartbeat-multiplier-slider touch-target",type:"range",min:.1,max:10,step:.1,value:H,onChange:t=>{const l=Number(t.target.value);_(Number.isFinite(l)&&l>0?l:1)},disabled:be}),e.jsxs("span",{className:"heartbeat-multiplier-value",children:["×",H.toFixed(1)]}),e.jsx("select",{className:"heartbeat-multiplier-preset",value:String(ot.reduce((t,l)=>Math.abs(l-H)<Math.abs(t-H)?l:t,ot[0])),onChange:t=>{const l=Number(t.target.value);_(Number.isFinite(l)&&l>0?l:1)},disabled:be,"aria-label":"Heartbeat speed preset",children:ot.map(t=>e.jsxs("option",{value:String(t),children:["×",t]},t))})]}),e.jsx("small",{className:"text-secondary",children:"Scales all agent heartbeat intervals. ×0.5 = twice as fast, ×2.0 = twice as slow. Default: ×1.0"})]})}),e.jsx(In,{agents:q})]}),e.jsx(Rn,{stats:y,activeAgents:J,projectId:o,isOpen:ge,onToggle:()=>oe(t=>!t),onSelectAgent:ke,onOpenTaskLogs:k}),e.jsxs("div",{className:"agents-split-layout",children:[e.jsxs("div",{className:`agents-split-sidebar${se?" agents-split-sidebar--hidden-mobile":""}`,children:[e.jsxs("div",{className:"agents-view-content",children:[e.jsx(ea,{isOpen:E,onClose:()=>{R(!1),h(null)},onCreated:()=>{R(!1),h(null),f()},projectId:o,prefillDraft:T}),e.jsx(ta,{isOpen:$,onClose:()=>j(!1),onUseDraft:t=>{h(t),j(!1),R(!0)},projectId:o,existingAgents:N}),e.jsx(aa,{isOpen:M,onClose:()=>K(!1),onImported:()=>void f(),projectId:o}),Tt?e.jsxs("div",{className:"agents-view-loading",role:"status","aria-live":"polite",children:[e.jsx(Qe,{size:18,className:"spin"}),e.jsx("span",{children:"Loading agents..."})]}):P==="org"?e.jsx("div",{className:"agent-org-chart","data-testid":"agent-org-chart",children:ce?e.jsxs("div",{className:"agent-org-chart__loading",role:"status","aria-live":"polite",children:[e.jsx(Qe,{size:18,className:"spin"}),e.jsx("span",{children:"Loading org chart..."})]}):_e.length===0?e.jsx(rt,{onCtaClick:Ve}):_e.map(t=>e.jsx(Et,{node:t,onSelect:a,getHealthStatus:Xe,getRoleIcon:Ze,getSkillBadges:gt,selectedAgentId:F},t.agent.id))}):P==="board"?e.jsx("div",{className:"agent-board",children:q.length===0?e.jsx(rt,{onCtaClick:Ve}):q.map(t=>{const l=Xe(t),w=Je(t.state),S=ut("agent-board-card",t.state);return e.jsx("div",{className:`agent-board-card ${S}${F===t.id?" agent-card--selected":""}`,children:e.jsxs("div",{className:"agent-board-clickable",onClick:()=>a(t.id),role:"button",tabIndex:0,onKeyDown:V=>{(V.key==="Enter"||V.key===" ")&&(V.key===" "&&V.preventDefault(),a(t.id))},children:[e.jsxs("div",{className:"agent-board-header",children:[e.jsx("span",{className:"agent-board-icon",children:Ze(t.role)}),e.jsx("span",{className:"agent-board-badge badge text-secondary",children:mt(t.role)}),e.jsx("span",{className:`agent-board-badge badge ${w}`,children:t.state})]}),e.jsx("div",{className:"agent-board-name",children:t.name}),e.jsx("div",{className:"agent-board-id",children:t.id}),e.jsxs("div",{className:"agent-board-health",style:{color:l.color},title:l.reason??l.label,children:[l.icon,!l.stateDerived&&` ${l.label}`]})]})},t.id)})}):e.jsx("div",{className:"agent-list",children:q.length===0?e.jsx(rt,{onCtaClick:Ve}):q.map(t=>{const l=Xe(t),w=Je(t.state),S=ut("agent-card",t.state),V=Ge(t.runtimeConfig?.heartbeatIntervalMs),Te=on(V),De=Ce===t.id;return e.jsxs("div",{className:`agent-card ${S}${F===t.id?" agent-card--selected":""}`,children:[e.jsxs("div",{className:"agent-card-header",children:[e.jsxs("div",{className:"agent-info agent-info--clickable",onClick:()=>a(t.id),role:"button",tabIndex:0,onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.key===" "&&x.preventDefault(),a(t.id))},children:[ve===t.id?e.jsx("select",{ref:me,className:"select agent-role-select",value:t.role,onChange:x=>void He(t.id,x.target.value),onKeyDown:x=>$e(x,t.id),onBlur:()=>le(null),autoFocus:!0,children:Ue.map(x=>e.jsxs("option",{value:x.value,children:[x.icon," ",x.label]},x.value))}):e.jsx("span",{className:"agent-icon agent-icon--clickable",onClick:x=>{x.stopPropagation(),le(t.id)},title:"Click to change role",role:"button",tabIndex:0,onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.stopPropagation(),le(t.id))},children:Ze(t.role)}),e.jsxs("div",{className:"agent-meta",children:[e.jsx("span",{className:"agent-name",children:t.name}),e.jsx("span",{className:"agent-id text-secondary",children:t.id})]}),e.jsx(It,{size:20,className:"agent-card-chevron"})]}),e.jsxs("div",{className:"agent-badges",children:[e.jsx("span",{className:`badge ${w}`,children:t.state}),e.jsxs("span",{className:"badge",style:{color:l.color},title:l.reason??l.label,children:[l.icon,!l.stateDerived&&` ${l.label}`]}),e.jsx("span",{className:"badge text-secondary",children:mt(t.role)}),(()=>{const x=gt(t);if(x.length===0)return null;const ae=x.slice(0,2),Me=x.length-2;return e.jsxs(e.Fragment,{children:[ae.map(Ye=>e.jsx("span",{className:"badge badge-skill",title:Ye,children:At(Ye)},Ye)),Me>0&&e.jsxs("span",{className:"badge badge-skill",children:["+",Me]})]})})()]})]}),e.jsxs("div",{className:"agent-card-body",children:[t.taskId&&e.jsxs("div",{className:"agent-task",children:[e.jsx("span",{className:"text-secondary",children:"Working on:"}),e.jsx("span",{className:"badge",children:t.taskId})]}),e.jsxs("div",{className:"agent-heartbeat-control",children:[e.jsx("span",{className:"text-secondary",children:"Heartbeat:"}),ye===t.id?e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",inputMode:"numeric",pattern:"[0-9]*",className:"input agent-heartbeat-custom-input",value:we[t.id]??"",onChange:x=>O(ae=>({...ae,[t.id]:x.target.value})),onKeyDown:x=>{x.key==="Enter"?ze(t):x.key==="Escape"&&(te(null),O(ae=>{const Me={...ae};return delete Me[t.id],Me}))},disabled:De,"aria-label":`Custom heartbeat interval in minutes for ${t.name}`}),e.jsx("span",{className:"text-secondary",children:"min"}),e.jsx("button",{className:"btn btn--sm",onClick:()=>void ze(t),disabled:De,title:"Save custom interval",children:"Save"}),e.jsx("button",{className:"btn btn--sm",onClick:()=>{te(null),O(x=>{const ae={...x};return delete ae[t.id],ae})},disabled:De,title:"Cancel custom interval",children:"Cancel"})]}):e.jsx(e.Fragment,{children:e.jsxs("select",{className:"select agent-heartbeat-select",value:V,onChange:x=>{const ae=x.target.value;ae==="__custom__"?qe(t):Le(t,Number(ae))},disabled:De,"aria-label":`Set heartbeat interval for ${t.name}`,children:[Te.map(x=>e.jsx("option",{value:x.value,children:x.label},x.value)),cn.some(x=>x.value===V)&&e.jsx("option",{value:"__custom__",children:"Custom..."})]})}),De&&e.jsx("span",{className:"agent-heartbeat-saving text-secondary",children:"Saving…"}),t.lastHeartbeatAt&&(()=>{const x=new Date(t.lastHeartbeatAt),ae=new Date(x.getTime()+V),Me=t.state==="active"||t.state==="running";return e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"agent-heartbeat-last text-secondary",title:x.toLocaleString(),children:["Last: ",x.toLocaleTimeString()]}),Me&&e.jsxs("span",{className:"agent-heartbeat-next text-secondary",title:ae.toLocaleString(),children:["Next: ",ae.toLocaleTimeString()]})]})})()]})]}),e.jsxs("div",{className:"agent-card-actions",children:[t.state==="idle"&&e.jsxs("button",{className:"btn btn--sm",onClick:()=>void W(t.id,"active"),disabled:ne.has(t.id),title:"Activate",children:[e.jsx(Ne,{size:14})," Start"]}),t.state==="active"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"btn btn--sm",onClick:()=>void fe(t.id,t.name),disabled:ne.has(t.id),title:"Run Now","aria-label":`Run now for ${t.name}`,children:[e.jsx(Re,{size:14})," Run Now"]}),e.jsxs("button",{className:"btn btn--sm",onClick:()=>void W(t.id,"paused"),disabled:ne.has(t.id),title:"Pause",children:[e.jsx(We,{size:14})," Pause"]})]}),t.state==="paused"&&e.jsxs("button",{className:"btn btn--sm",onClick:()=>void W(t.id,"active"),disabled:ne.has(t.id),title:"Resume",children:[e.jsx(Ne,{size:14})," Resume"]}),t.state==="running"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"btn btn--sm",onClick:()=>a(t.id,{initialTab:"runs",initialRunId:null,preferActiveRun:!0}),title:"View live run details","aria-label":`View live run details for ${t.name}`,children:[e.jsx(Re,{size:14})," Running"]}),e.jsxs("button",{className:"btn btn--sm",onClick:()=>void W(t.id,"paused"),disabled:ne.has(t.id),title:"Pause",children:[e.jsx(We,{size:14})," Pause"]})]}),t.state==="error"&&e.jsxs("button",{className:"btn btn--sm",onClick:()=>void W(t.id,"active"),disabled:ne.has(t.id),title:"Retry",children:[e.jsx(Ne,{size:14})," Retry"]}),t.state==="terminated"&&e.jsxs("button",{className:"btn btn--sm",onClick:()=>void W(t.id,"active"),disabled:ne.has(t.id),title:"Start",children:[e.jsx(Ne,{size:14})," Start"]}),e.jsx("button",{className:"btn btn--sm agent-card-details-btn",onClick:()=>a(t.id),title:`View details for ${t.name}`,"aria-label":`View details for ${t.name}`,children:"View Details"}),e.jsxs("button",{className:"btn btn--sm btn--danger",onClick:()=>void Oe(t.id,t.name),title:"Delete",children:[e.jsx(ft,{size:14})," Delete"]})]})]},t.id)})})]}),!d&&L&&e.jsxs("div",{className:"agents-sidebar-quick-controls",children:[e.jsxs("div",{className:"agents-sidebar-quick-controls__header",children:[e.jsx("strong",{children:L.name}),e.jsx("span",{className:`badge ${Je(L.state)}`,children:L.state})]}),e.jsxs("div",{className:"agents-sidebar-quick-controls__meta",children:[e.jsx("span",{children:st(Ge(L.runtimeConfig?.heartbeatIntervalMs))}),L.lastHeartbeatAt&&e.jsxs("span",{children:["Last ",xn(L.lastHeartbeatAt)]})]}),e.jsxs("div",{className:"agents-sidebar-quick-controls__actions",children:[L.state==="idle"&&e.jsxs("button",{className:"btn btn-sm",onClick:()=>void W(L.id,"active"),children:[e.jsx(Ne,{size:14})," Start"]}),L.state==="active"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"btn btn-sm",onClick:()=>void fe(L.id,L.name),children:[e.jsx(Re,{size:14})," Run Now"]}),e.jsxs("button",{className:"btn btn-sm",onClick:()=>void W(L.id,"paused"),children:[e.jsx(We,{size:14})," Pause"]})]}),L.state==="running"&&e.jsxs("button",{className:"btn btn-sm",onClick:()=>void W(L.id,"paused"),children:[e.jsx(We,{size:14})," Pause"]}),L.state==="paused"&&e.jsxs("button",{className:"btn btn-sm",onClick:()=>void W(L.id,"active"),children:[e.jsx(Ne,{size:14})," Resume"]}),L.state==="error"&&e.jsxs("button",{className:"btn btn-sm",onClick:()=>void W(L.id,"active"),children:[e.jsx(Ne,{size:14})," Retry"]}),L.state==="terminated"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"btn btn-sm",onClick:()=>void W(L.id,"active"),children:[e.jsx(Ne,{size:14})," Start"]}),e.jsxs("button",{className:"btn btn-danger btn-sm",onClick:()=>void Oe(L.id,L.name),children:[e.jsx(ft,{size:14})," Delete"]})]})]})]})]}),e.jsxs("div",{className:`agents-split-detail${d&&!F?" agents-split-detail--hidden-mobile":""}`,children:[se&&e.jsx("div",{className:"agents-mobile-back-row",children:e.jsxs("button",{className:"btn agents-mobile-back-btn",onClick:C,children:[e.jsx(dn,{size:16}),"Agents"]})}),F?e.jsx(n.Suspense,{fallback:null,children:e.jsx(sa,{inline:!0,agentId:F,projectId:o,onClose:C,addToast:i,onChildClick:Ee,initialTab:G,initialRunId:z,preferActiveRun:A})}):e.jsxs("div",{className:"agents-detail-empty-state",children:[e.jsx(dt,{size:48}),e.jsx("h3",{children:"Select an agent"}),e.jsx("p",{children:"Choose an agent from the sidebar to view details"})]})]})]})]})}export{ga as AgentsView,At as formatAgentSkillBadgeLabel};
|
|
517
|
+
Agent instructions go here...`,value:p,onChange:i=>{d("paste"),y([]),v(i.target.value),z(null)},rows:8,"aria-label":"Manifest content"})]}),e.jsxs("p",{className:"agent-import-file-hint",children:["Current input: ",r]}),ie&&e.jsxs("p",{className:"agent-dialog-error",children:[e.jsx(nt,{size:14}),ie]})]}),c==="preview"&&e.jsxs("div",{className:"agent-import-preview",children:[e.jsxs("div",{className:"agent-import-company",children:[e.jsx("span",{className:"agent-import-company-label",children:"Company"}),e.jsx("span",{className:"agent-import-company-name",children:I})]}),e.jsxs("div",{className:"agent-import-count",children:[e.jsx(ct,{size:14}),e.jsxs("span",{children:[E.length," agent",E.length!==1?"s":""," found"]})]}),E.length>0&&e.jsxs("div",{className:"agent-import-selection-controls",children:[e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>h(E.map(i=>i.name)),children:"Select all agents"}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>h([]),children:"Clear agents"})]}),E.length>0?e.jsx("div",{className:"agent-import-agent-list",children:E.map((i,b)=>e.jsxs("div",{className:"agent-import-agent-item",children:[e.jsx("label",{className:"checkbox-label",children:e.jsx("input",{type:"checkbox","aria-label":`Select agent ${i.name}`,checked:T.includes(i.name),onChange:()=>Pe(i.name)})}),e.jsx("span",{className:"agent-import-agent-icon",children:i.icon||"🤖"}),e.jsxs("div",{className:"agent-import-agent-details",children:[e.jsx("span",{className:"agent-import-agent-name",children:i.name}),e.jsxs("span",{className:"agent-import-agent-meta",children:[i.title&&e.jsxs("span",{className:"agent-import-agent-title",children:[i.title," · "]}),e.jsx("span",{className:"agent-import-agent-role",children:i.role}),i.reportsTo&&e.jsxs("span",{className:"agent-import-agent-reports",children:[" · reports to ",i.reportsTo]}),i.skills&&i.skills.length>0&&e.jsxs("span",{className:"agent-import-agent-model",children:[" · skills: ",i.skills.join(", ")]})]}),i.instructionsText&&e.jsxs("span",{className:"agent-import-agent-instructions",children:[i.instructionsText.slice(0,100),i.instructionsText.length>100?"...":""]})]})]},b))}):e.jsx("p",{className:"agent-import-empty",children:"No agents found in the manifest."}),$.length>0&&e.jsxs("div",{className:"agent-import-skills-section",children:[e.jsxs("div",{className:"agent-import-count",children:[e.jsx(ct,{size:14}),e.jsxs("span",{children:[$.length," skill",$.length!==1?"s":""," found"]})]}),e.jsxs("div",{className:"agent-import-selection-controls",children:[e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>K($.map(i=>i.name)),children:"Select all skills"}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>K([]),children:"Clear skills"})]}),e.jsx("div",{className:"agent-import-skill-list",children:$.map((i,b)=>e.jsxs("div",{className:"agent-import-skill-item",children:[e.jsx("label",{className:"checkbox-label",children:e.jsx("input",{type:"checkbox","aria-label":`Select skill ${i.name}`,checked:M.includes(i.name),onChange:()=>je(i.name)})}),e.jsx("span",{className:"agent-import-skill-icon",children:"⚡"}),e.jsxs("div",{className:"agent-import-skill-details",children:[e.jsx("span",{className:"agent-import-skill-name",children:i.name}),i.description&&e.jsx("span",{className:"agent-import-skill-description",children:i.description})]})]},`${i.name}-${b}`))})]}),Y&&e.jsxs("p",{className:"agent-dialog-error",children:[e.jsx(nt,{size:14}),Y]})]}),c==="result"&&m&&e.jsxs("div",{className:"agent-import-result",children:[e.jsx("div",{className:"agent-import-result-icon",children:e.jsx(Ke,{size:32})}),e.jsx("h3",{className:"agent-import-result-title",children:"Import Complete"}),e.jsxs("p",{className:"agent-import-result-company",children:["From ",e.jsx("strong",{children:m.companyName??"Unknown"})]}),e.jsxs("div",{className:"agent-import-result-stats",children:[m.created.length>0&&e.jsx("div",{className:"agent-import-result-stat agent-import-result-stat--success",children:e.jsxs("span",{children:[m.created.length," created"]})}),m.skipped.length>0&&e.jsx("div",{className:"agent-import-result-stat agent-import-result-stat--skipped",children:e.jsxs("span",{children:[m.skipped.length," skipped (already exist)"]})}),m.errors.length>0&&e.jsx("div",{className:"agent-import-result-stat agent-import-result-stat--error",children:e.jsxs("span",{children:[m.errors.length," error",m.errors.length!==1?"s":""]})})]}),m.created.length>0&&e.jsx("div",{className:"agent-import-result-agents",children:m.created.map((i,b)=>e.jsxs("div",{className:"agent-import-result-agent",children:[e.jsx(Ke,{size:12}),e.jsx("span",{children:i.name})]},b))}),m.errors.length>0&&e.jsx("div",{className:"agent-import-result-errors",children:m.errors.map((i,b)=>e.jsxs("div",{className:"agent-import-result-error",children:[e.jsx(bt,{size:12}),e.jsxs("span",{children:[i.name,": ",i.error]})]},b))}),m.skills&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"agent-import-result-divider"}),e.jsx("h4",{className:"agent-import-result-section-title",children:"Skills"}),e.jsxs("div",{className:"agent-import-result-stats",children:[m.skills.imported.length>0&&e.jsx("div",{className:"agent-import-result-stat agent-import-result-stat--success",children:e.jsxs("span",{children:[m.skills.imported.length," skill",m.skills.imported.length!==1?"s":""," imported"]})}),m.skills.skipped.length>0&&e.jsx("div",{className:"agent-import-result-stat agent-import-result-stat--skipped",children:e.jsxs("span",{children:[m.skills.skipped.length," skill",m.skills.skipped.length!==1?"s":""," skipped (already exist)"]})}),m.skills.errors.length>0&&e.jsx("div",{className:"agent-import-result-stat agent-import-result-stat--error",children:e.jsxs("span",{children:[m.skills.errors.length," skill",m.skills.errors.length!==1?"s":""," error",m.skills.errors.length!==1?"s":""]})}),m.skills.imported.length===0&&m.skills.skipped.length===0&&m.skills.errors.length===0&&e.jsx("div",{className:"agent-import-result-stat agent-import-result-stat--skipped",children:e.jsx("span",{children:"No skills in package"})})]}),m.skills.imported.length>0&&e.jsx("div",{className:"agent-import-result-agents",children:m.skills.imported.map((i,b)=>e.jsxs("div",{className:"agent-import-result-agent",children:[e.jsx(Ke,{size:12}),e.jsx("span",{children:i.name})]},b))}),m.skills.errors.length>0&&e.jsx("div",{className:"agent-import-result-errors",children:m.skills.errors.map((i,b)=>e.jsxs("div",{className:"agent-import-result-error",children:[e.jsx(bt,{size:12}),e.jsxs("span",{children:[i.name,": ",i.error]})]},b))})]})]})]}),e.jsxs("div",{className:"agent-dialog-footer",children:[c==="preview"&&e.jsx("button",{className:"btn",onClick:()=>g("input"),disabled:se,children:"Back"}),e.jsx("button",{className:"btn",onClick:me,disabled:se,children:c==="result"?"Close":"Cancel"}),c==="input"&&e.jsx("button",{className:"btn btn-task-create",onClick:()=>void te(),disabled:F||(r==="directory"?N.length===0:r==="browse"?!D:!p.trim()),children:F?e.jsxs(e.Fragment,{children:[e.jsx(tt,{size:14,className:"spin"}),"Parsing..."]}):"Preview"}),c==="preview"&&e.jsx("button",{className:"btn btn-task-create",onClick:()=>void we(),disabled:se||O===0&&H===0,children:se?e.jsxs(e.Fragment,{children:[e.jsx(tt,{size:14,className:"spin"}),ne]}):`Import ${Ae}`})]})]})}):null}const ia=n.lazy(()=>vn(()=>import("./AgentDetailView-17J-F0Rl.js").then(s=>s.A),__vite__mapDeps([0,1,2,3,4,5,6,7])).then(s=>({default:s.AgentDetailView}))),Ue=[{value:"triage",label:"Triage",icon:"⊕"},{value:"executor",label:"Executor",icon:"▶"},{value:"reviewer",label:"Reviewer",icon:"⊙"},{value:"merger",label:"Merger",icon:"⊞"},{value:"scheduler",label:"Scheduler",icon:"◷"},{value:"engineer",label:"Engineer",icon:"⎔"},{value:"custom",label:"Custom",icon:"✦"}],ot=[.1,.25,.5,1,2,3,5,10],ra=/(?:^|\/)skills\/([^/]+)\/SKILL\.md$/i;function Et(s){const o=s.trim();if(!o)return s;const k=o.match(ra);return k?.[1]?k[1]:o}function Je(s){switch(s){case"running":return"agent-badge--running";case"active":return"agent-badge--active";case"paused":return"agent-badge--paused";case"error":return"agent-badge--error";case"terminated":return"agent-badge--terminated";case"idle":default:return"agent-badge--idle"}}function ut(s,o){switch(o){case"running":return`${s}--running`;case"active":return`${s}--active`;case"paused":return`${s}--paused`;case"error":return`${s}--error`;case"terminated":return`${s}--terminated`;case"idle":default:return`${s}--idle`}}function Tt({node:s,onSelect:o,getHealthStatus:k,getRoleIcon:u,getSkillBadges:c,selectedAgentId:g}){const{agent:r,children:d}=s,p=k(r),v=Je(r.state),N=ut("org-chart-node-card",r.state);return e.jsxs("div",{className:`org-chart-node${d.length>0?" org-chart-node--has-children":""}`,children:[e.jsxs("div",{className:`${N}${g===r.id?" agent-card--selected":""}`,onClick:()=>o(r.id),role:"button",tabIndex:0,onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.key===" "&&y.preventDefault(),o(r.id))},children:[e.jsxs("div",{className:"org-chart-node__header",children:[e.jsx("span",{className:"org-chart-node__icon",children:u(r.role)}),e.jsx("span",{className:"org-chart-node__name",children:r.name})]}),e.jsxs("div",{className:"org-chart-node__meta",children:[e.jsx("span",{className:`org-chart-node__badge ${v}`,children:r.state}),e.jsxs("span",{className:"org-chart-node__health",style:{color:p.color},title:p.reason??p.label,children:[p.icon,!p.stateDerived&&e.jsx("span",{className:"text-secondary",children:p.label})]}),(()=>{const y=c(r);if(y.length===0)return null;const I=y.slice(0,2),f=y.length-2;return e.jsxs(e.Fragment,{children:[I.map(E=>e.jsx("span",{className:"org-chart-node__skill",children:Et(E)},E)),f>0&&e.jsxs("span",{className:"org-chart-node__skill",children:["+",f]})]})})()]})]}),d.length>0&&e.jsx("div",{className:"org-chart-children",role:"group","aria-label":`${r.name} employees`,children:d.map(y=>e.jsx(Tt,{node:y,onSelect:o,getHealthStatus:k,getRoleIcon:u,getSkillBadges:c,selectedAgentId:g},y.agent.id))})]})}function ha({addToast:s,projectId:o,onOpenTaskLogs:k,agentOnboardingEnabled:u=!1}){const[c,g]=n.useState(!1),d=Zt()==="mobile",[p,v]=n.useState("all"),{agents:N,stats:y,isLoading:I,loadAgents:f}=Xt(o,{filterState:p,showSystemAgents:c}),[E,R]=n.useState(!1),[$,j]=n.useState(!1),[T,h]=n.useState(null),[M,K]=n.useState(!1),[F,Z]=n.useState(null),se=d&&!!F,[G,ie]=n.useState("dashboard"),[z,m]=n.useState(null),[A,Y]=n.useState(!1),[P,Q]=n.useState(()=>{if(typeof window>"u")return"list";const t=vt("fn-agent-view",o);return t==="list"||t==="board"||t==="org"?t:"list"}),[re,pe]=n.useState([]),[ce,ee]=n.useState(!1),[de,D]=n.useState(!1),[ge,oe]=n.useState(!1),ue=n.useRef(null),{confirm:Ie}=Yt(),X=n.useRef(null),he=n.useId();n.useEffect(()=>{const t=vt("fn-agent-view",o);if(t==="list"||t==="board"||t==="org"){Q(t);return}Q("list")},[o]),n.useEffect(()=>{en("fn-agent-view",P,o)},[P,o]);const[be,le]=n.useState(null),me=n.useRef(null),[Ce,B]=n.useState(null),[ye,te]=n.useState(null),[we,O]=n.useState({}),[H,Se]=n.useState(1),[ve,Ae]=n.useState(!1),[ne,Pe]=n.useState(new Set),[je,i]=n.useState(new Map),b=n.useRef(!0);n.useEffect(()=>(b.current=!0,()=>{b.current=!1}),[]),n.useEffect(()=>{tn(o).then(t=>{b.current&&Se(t.heartbeatMultiplier??1)}).catch(()=>{})},[o]);const _=n.useCallback(async t=>{const l=Number.isFinite(t)&&t>0?t:1;Se(l),Ae(!0);try{await nn({heartbeatMultiplier:l},o),s(`Heartbeat speed set to ×${l.toFixed(1)}`,"success")}catch(w){s(`Failed to save heartbeat multiplier: ${xe(w)}`,"error")}finally{b.current&&Ae(!1)}},[o,s]),U=n.useMemo(()=>je.size===0?N:N.map(t=>{const l=je.get(t.id);return l?{...t,state:l}:t}),[N,je]),q=n.useMemo(()=>U.filter(t=>c||!at(t)),[U,c]),J=n.useMemo(()=>U.filter(t=>t.state!=="active"&&t.state!=="running"?!1:c||!at(t)),[U,c]),_e=n.useMemo(()=>{if(c)return re;const t=l=>at(l.agent)?null:{...l,children:l.children.map(t).filter(w=>w!==null)};return re.map(t).filter(l=>l!==null)},[re,c]);n.useEffect(()=>{if(P!=="org")return;let t=!1;return ee(!0),an(o,{includeEphemeral:c}).then(l=>{t||pe(l)}).catch(l=>{t||(s(`Failed to load org chart: ${xe(l)}`,"error"),pe([]))}).finally(()=>{t||ee(!1)}),()=>{t=!0}},[P,o,c,s]),n.useEffect(()=>{const t=setInterval(()=>{f()},3e4);return()=>{clearInterval(t)}},[f]),n.useEffect(()=>{if(!de)return;const t=w=>{const S=w.target;S&&(ue.current?.contains(S)||X.current?.contains(S)||D(!1))},l=w=>{w.key==="Escape"&&(D(!1),X.current?.focus())};return document.addEventListener("mousedown",t),document.addEventListener("touchstart",t),document.addEventListener("keydown",l),()=>{document.removeEventListener("mousedown",t),document.removeEventListener("touchstart",t),document.removeEventListener("keydown",l)}},[de]);const W=async(t,l)=>{if(!ne.has(t)){Pe(w=>new Set(w).add(t)),i(w=>{const S=new Map(w);return S.set(t,l),S});try{await hn(t,l,o),s(`Agent state updated to ${l}`,"success"),await f(),i(w=>{const S=new Map(w);return S.delete(t),S})}catch(w){i(S=>{const V=new Map(S);return V.delete(t),V}),s(`Failed to update state: ${xe(w)}`,"error")}finally{Pe(w=>{const S=new Set(w);return S.delete(t),S})}}},Oe=async(t,l)=>{if(await Ie({title:"Delete Agent",message:`Delete agent "${l}"? This cannot be undone.`,danger:!0}))try{await bn(t,o),s(`Agent "${l}" deleted`,"success"),f()}catch(S){s(`Failed to delete agent: ${xe(S)}`,"error")}},He=async(t,l)=>{const w=N.find(S=>S.id===t);if(w){if(w.role===l){le(null);return}try{await Be(t,{role:l},o),s(`Agent role updated to ${Ue.find(S=>S.value===l)?.label??l}`,"success"),le(null),f()}catch(S){s(`Failed to update role: ${xe(S)}`,"error")}}},$e=(t,l)=>{t.key==="Escape"&&le(null)},Le=async(t,l)=>{ye===t.id&&(te(null),O(w=>{const S={...w};return delete S[t.id],S})),B(t.id);try{await Be(t.id,{runtimeConfig:{...t.runtimeConfig??{},heartbeatIntervalMs:l}},o),s(`Heartbeat interval updated to ${st(l)} for ${t.name}`,"success"),f()}catch(w){s(`Failed to update heartbeat interval: ${xe(w)}`,"error")}finally{B(null)}},ze=async t=>{const l=we[t.id]??"";if(l.trim()===""){s("Please enter a heartbeat interval in minutes","error");return}const w=Number(l);if(isNaN(w)){s("Heartbeat interval must be a valid number","error");return}if(w<=0){s("Heartbeat interval must be greater than 0","error");return}if(w>=1&&w<5){B(t.id);try{await Be(t.id,{runtimeConfig:{...t.runtimeConfig??{},heartbeatIntervalMs:gn}},o),s(`Heartbeat interval set to 5 minutes (minimum). ${w} minute${w!==1?"s":""} was below the 5-minute minimum.`,"success"),te(null),O(V=>{const Te={...V};return delete Te[t.id],Te}),f()}catch(V){s(`Failed to update heartbeat interval: ${xe(V)}`,"error")}finally{B(null)}return}const S=Math.round(w*6e4);B(t.id);try{await Be(t.id,{runtimeConfig:{...t.runtimeConfig??{},heartbeatIntervalMs:S}},o),s(`Heartbeat interval updated to ${st(S)} for ${t.name}`,"success"),te(null),O(V=>{const Te={...V};return delete Te[t.id],Te}),f()}catch(V){s(`Failed to update heartbeat interval: ${xe(V)}`,"error")}finally{B(null)}},qe=t=>{const l=Ge(t.runtimeConfig?.heartbeatIntervalMs),w=Math.round(l/6e4);te(t.id),O(S=>({...S,[t.id]:String(w)}))},a=n.useCallback((t,l)=>{Z(t),ie(l?.initialTab??"dashboard"),m(l?.initialRunId??null),Y(l?.preferActiveRun??!1)},[]),C=n.useCallback(()=>{Z(null),ie("dashboard"),m(null),Y(!1)},[]),Ee=n.useCallback(t=>{a(t)},[a]),ke=n.useCallback(t=>{a(t),d&&oe(!1)},[d,a]),fe=async(t,l)=>{try{await pn(t,o,{source:"on_demand",triggerDetail:"Triggered from dashboard"}),s(`Heartbeat run started for ${l}`,"success"),f()}catch(w){s(`Failed to start heartbeat run: ${xe(w)}`,"error")}},mt=t=>Ue.find(l=>l.value===t)?.label??t,Ze=t=>Ue.find(l=>l.value===t)?.icon??"◆",L=F?q.find(t=>t.id===F)??null:null,gt=t=>Array.isArray(t.metadata?.skills)?t.metadata.skills:[],Xe=t=>mn(t),Mt=I&&N.length===0,Ve=n.useCallback(()=>{if(u){j(!0);return}R(!0)},[u]);return e.jsxs("div",{className:"agents-view",children:[e.jsxs("div",{className:"agents-view-header",children:[e.jsxs("div",{className:"agents-view-title",children:[e.jsx(dt,{size:24}),e.jsx("h2",{children:"Agents"})]}),e.jsxs("div",{className:"agents-view-controls",children:[e.jsxs("div",{className:"view-toggle",children:[e.jsx("button",{className:`view-toggle-btn${P==="list"?" active":""}`,onClick:()=>Q("list"),title:"List view","aria-label":"List view","aria-pressed":P==="list",children:e.jsx(sn,{size:16})}),e.jsx("button",{className:`view-toggle-btn${P==="board"?" active":""}`,onClick:()=>Q("board"),title:"Board view","aria-label":"Board view","aria-pressed":P==="board",children:e.jsx(Re,{size:16})}),e.jsx("button",{className:`view-toggle-btn${P==="org"?" active":""}`,onClick:()=>Q("org"),title:"Org Chart view","aria-label":"Org Chart view","aria-pressed":P==="org",children:e.jsx(rn,{size:16})})]}),e.jsxs("div",{className:"agents-view-primary-actions",children:[e.jsx("button",{ref:X,className:`btn-icon agent-controls-trigger${de?" agent-controls-trigger--active":""}`,onClick:()=>D(t=>!t),title:"Controls","aria-label":"Controls","aria-haspopup":"dialog","aria-expanded":de,"aria-controls":he,children:e.jsx(In,{size:16})}),e.jsx("button",{className:"btn-icon",onClick:()=>void f(),title:"Refresh","aria-label":"Refresh",children:e.jsx(Qe,{size:16,className:I?"spin":void 0})}),e.jsxs("button",{className:"btn btn-task-create btn-sm",onClick:()=>{Ve(),D(!1)},children:[e.jsx(ln,{size:16}),"New Agent"]})]})]})]}),de&&e.jsxs("div",{ref:ue,id:he,className:"agent-controls-panel agent-controls-panel--scrollable",role:"dialog","aria-label":"Agent controls","aria-modal":"false",children:[e.jsxs("div",{className:"agent-controls",children:[e.jsxs("div",{className:"agent-controls-filters",children:[e.jsxs("div",{className:"agent-state-filter",children:[e.jsx(on,{size:14}),e.jsxs("select",{className:"agent-state-filter-select",value:p,onChange:t=>v(t.target.value),"aria-label":"Filter agents by state",children:[e.jsx("option",{value:"all",children:"All States"}),e.jsx("option",{value:"idle",children:"Idle"}),e.jsx("option",{value:"active",children:"Active"}),e.jsx("option",{value:"running",children:"Running"}),e.jsx("option",{value:"paused",children:"Paused"}),e.jsx("option",{value:"error",children:"Error"}),e.jsx("option",{value:"terminated",children:"Terminated"})]})]}),e.jsxs("label",{className:"checkbox-label agent-system-filter",children:[e.jsx("input",{type:"checkbox",checked:c,onChange:t=>g(t.target.checked),"aria-label":"Show system agents"}),"Show system agents"]})]}),e.jsx("div",{className:"agent-controls-actions",children:e.jsxs("button",{className:"btn",onClick:()=>{K(!0),D(!1)},children:[e.jsx(St,{size:16}),"Import"]})})]}),e.jsx("div",{className:"agent-global-controls",children:e.jsxs("div",{className:"heartbeat-multiplier-group",children:[e.jsxs("div",{className:"heartbeat-multiplier-controls",children:[e.jsx("label",{htmlFor:"globalHeartbeatMultiplier",className:"heartbeat-multiplier-label",children:"Heartbeat Speed"}),e.jsx("input",{id:"globalHeartbeatMultiplier",className:"heartbeat-multiplier-slider touch-target",type:"range",min:.1,max:10,step:.1,value:H,onChange:t=>{const l=Number(t.target.value);_(Number.isFinite(l)&&l>0?l:1)},disabled:ve}),e.jsxs("span",{className:"heartbeat-multiplier-value",children:["×",H.toFixed(1)]}),e.jsx("select",{className:"heartbeat-multiplier-preset",value:String(ot.reduce((t,l)=>Math.abs(l-H)<Math.abs(t-H)?l:t,ot[0])),onChange:t=>{const l=Number(t.target.value);_(Number.isFinite(l)&&l>0?l:1)},disabled:ve,"aria-label":"Heartbeat speed preset",children:ot.map(t=>e.jsxs("option",{value:String(t),children:["×",t]},t))})]}),e.jsx("small",{className:"text-secondary",children:"Scales all agent heartbeat intervals. ×0.5 = twice as fast, ×2.0 = twice as slow. Default: ×1.0"})]})}),e.jsx(Cn,{agents:q})]}),e.jsx(Pn,{stats:y,activeAgents:J,projectId:o,isOpen:ge,onToggle:()=>oe(t=>!t),onSelectAgent:ke,onOpenTaskLogs:k}),e.jsxs("div",{className:"agents-split-layout",children:[e.jsxs("div",{className:`agents-split-sidebar${se?" agents-split-sidebar--hidden-mobile":""}`,children:[e.jsxs("div",{className:"agents-view-content",children:[e.jsx(ta,{isOpen:E,onClose:()=>{R(!1),h(null)},onCreated:()=>{R(!1),h(null),f()},projectId:o,prefillDraft:T}),e.jsx(na,{isOpen:$,onClose:()=>j(!1),onUseDraft:t=>{h(t),j(!1),R(!0)},projectId:o,existingAgents:N}),e.jsx(sa,{isOpen:M,onClose:()=>K(!1),onImported:()=>void f(),projectId:o}),Mt?e.jsxs("div",{className:"agents-view-loading",role:"status","aria-live":"polite",children:[e.jsx(Qe,{size:18,className:"spin"}),e.jsx("span",{children:"Loading agents..."})]}):P==="org"?e.jsx("div",{className:"agent-org-chart","data-testid":"agent-org-chart",children:ce?e.jsxs("div",{className:"agent-org-chart__loading",role:"status","aria-live":"polite",children:[e.jsx(Qe,{size:18,className:"spin"}),e.jsx("span",{children:"Loading org chart..."})]}):_e.length===0?e.jsx(rt,{onCtaClick:Ve}):_e.map(t=>e.jsx(Tt,{node:t,onSelect:a,getHealthStatus:Xe,getRoleIcon:Ze,getSkillBadges:gt,selectedAgentId:F},t.agent.id))}):P==="board"?e.jsx("div",{className:"agent-board",children:q.length===0?e.jsx(rt,{onCtaClick:Ve}):q.map(t=>{const l=Xe(t),w=Je(t.state),S=ut("agent-board-card",t.state);return e.jsx("div",{className:`agent-board-card ${S}${F===t.id?" agent-card--selected":""}`,children:e.jsxs("div",{className:"agent-board-clickable",onClick:()=>a(t.id),role:"button",tabIndex:0,onKeyDown:V=>{(V.key==="Enter"||V.key===" ")&&(V.key===" "&&V.preventDefault(),a(t.id))},children:[e.jsxs("div",{className:"agent-board-header",children:[e.jsx("span",{className:"agent-board-icon",children:Ze(t.role)}),e.jsx("span",{className:"agent-board-badge badge text-secondary",children:mt(t.role)}),e.jsx("span",{className:`agent-board-badge badge ${w}`,children:t.state})]}),e.jsx("div",{className:"agent-board-name",children:t.name}),e.jsx("div",{className:"agent-board-id",children:t.id}),e.jsxs("div",{className:"agent-board-health",style:{color:l.color},title:l.reason??l.label,children:[l.icon,!l.stateDerived&&` ${l.label}`]})]})},t.id)})}):e.jsx("div",{className:"agent-list",children:q.length===0?e.jsx(rt,{onCtaClick:Ve}):q.map(t=>{const l=Xe(t),w=Je(t.state),S=ut("agent-card",t.state),V=Ge(t.runtimeConfig?.heartbeatIntervalMs),Te=cn(V),De=Ce===t.id;return e.jsxs("div",{className:`agent-card ${S}${F===t.id?" agent-card--selected":""}`,children:[e.jsxs("div",{className:"agent-card-header",children:[e.jsxs("div",{className:"agent-info agent-info--clickable",onClick:()=>a(t.id),role:"button",tabIndex:0,onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.key===" "&&x.preventDefault(),a(t.id))},children:[be===t.id?e.jsx("select",{ref:me,className:"select agent-role-select",value:t.role,onChange:x=>void He(t.id,x.target.value),onKeyDown:x=>$e(x,t.id),onBlur:()=>le(null),autoFocus:!0,children:Ue.map(x=>e.jsxs("option",{value:x.value,children:[x.icon," ",x.label]},x.value))}):e.jsx("span",{className:"agent-icon agent-icon--clickable",onClick:x=>{x.stopPropagation(),le(t.id)},title:"Click to change role",role:"button",tabIndex:0,onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.stopPropagation(),le(t.id))},children:Ze(t.role)}),e.jsxs("div",{className:"agent-meta",children:[e.jsx("span",{className:"agent-name",children:t.name}),e.jsx("span",{className:"agent-id text-secondary",children:t.id})]}),e.jsx(It,{size:20,className:"agent-card-chevron"})]}),e.jsxs("div",{className:"agent-badges",children:[e.jsx("span",{className:`badge ${w}`,children:t.state}),e.jsxs("span",{className:"badge",style:{color:l.color},title:l.reason??l.label,children:[l.icon,!l.stateDerived&&` ${l.label}`]}),e.jsx("span",{className:"badge text-secondary",children:mt(t.role)}),(()=>{const x=gt(t);if(x.length===0)return null;const ae=x.slice(0,2),Me=x.length-2;return e.jsxs(e.Fragment,{children:[ae.map(Ye=>e.jsx("span",{className:"badge badge-skill",title:Ye,children:Et(Ye)},Ye)),Me>0&&e.jsxs("span",{className:"badge badge-skill",children:["+",Me]})]})})()]})]}),e.jsxs("div",{className:"agent-card-body",children:[t.taskId&&e.jsxs("div",{className:"agent-task",children:[e.jsx("span",{className:"text-secondary",children:"Working on:"}),e.jsx("span",{className:"badge",children:t.taskId})]}),e.jsxs("div",{className:"agent-heartbeat-control",children:[e.jsx("span",{className:"text-secondary",children:"Heartbeat:"}),ye===t.id?e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",inputMode:"numeric",pattern:"[0-9]*",className:"input agent-heartbeat-custom-input",value:we[t.id]??"",onChange:x=>O(ae=>({...ae,[t.id]:x.target.value})),onKeyDown:x=>{x.key==="Enter"?ze(t):x.key==="Escape"&&(te(null),O(ae=>{const Me={...ae};return delete Me[t.id],Me}))},disabled:De,"aria-label":`Custom heartbeat interval in minutes for ${t.name}`}),e.jsx("span",{className:"text-secondary",children:"min"}),e.jsx("button",{className:"btn btn--sm",onClick:()=>void ze(t),disabled:De,title:"Save custom interval",children:"Save"}),e.jsx("button",{className:"btn btn--sm",onClick:()=>{te(null),O(x=>{const ae={...x};return delete ae[t.id],ae})},disabled:De,title:"Cancel custom interval",children:"Cancel"})]}):e.jsx(e.Fragment,{children:e.jsxs("select",{className:"select agent-heartbeat-select",value:V,onChange:x=>{const ae=x.target.value;ae==="__custom__"?qe(t):Le(t,Number(ae))},disabled:De,"aria-label":`Set heartbeat interval for ${t.name}`,children:[Te.map(x=>e.jsx("option",{value:x.value,children:x.label},x.value)),dn.some(x=>x.value===V)&&e.jsx("option",{value:"__custom__",children:"Custom..."})]})}),De&&e.jsx("span",{className:"agent-heartbeat-saving text-secondary",children:"Saving…"}),t.lastHeartbeatAt&&(()=>{const x=new Date(t.lastHeartbeatAt),ae=new Date(x.getTime()+V),Me=t.state==="active"||t.state==="running";return e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"agent-heartbeat-last text-secondary",title:x.toLocaleString(),children:["Last: ",x.toLocaleTimeString()]}),Me&&e.jsxs("span",{className:"agent-heartbeat-next text-secondary",title:ae.toLocaleString(),children:["Next: ",ae.toLocaleTimeString()]})]})})()]})]}),e.jsxs("div",{className:"agent-card-actions",children:[t.state==="idle"&&e.jsxs("button",{className:"btn btn--sm",onClick:()=>void W(t.id,"active"),disabled:ne.has(t.id),title:"Activate",children:[e.jsx(Ne,{size:14})," Start"]}),t.state==="active"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"btn btn--sm",onClick:()=>void fe(t.id,t.name),disabled:ne.has(t.id),title:"Run Now","aria-label":`Run now for ${t.name}`,children:[e.jsx(Re,{size:14})," Run Now"]}),e.jsxs("button",{className:"btn btn--sm",onClick:()=>void W(t.id,"paused"),disabled:ne.has(t.id),title:"Pause",children:[e.jsx(We,{size:14})," Pause"]})]}),t.state==="paused"&&e.jsxs("button",{className:"btn btn--sm",onClick:()=>void W(t.id,"active"),disabled:ne.has(t.id),title:"Resume",children:[e.jsx(Ne,{size:14})," Resume"]}),t.state==="running"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"btn btn--sm",onClick:()=>a(t.id,{initialTab:"runs",initialRunId:null,preferActiveRun:!0}),title:"View live run details","aria-label":`View live run details for ${t.name}`,children:[e.jsx(Re,{size:14})," Running"]}),e.jsxs("button",{className:"btn btn--sm",onClick:()=>void W(t.id,"paused"),disabled:ne.has(t.id),title:"Pause",children:[e.jsx(We,{size:14})," Pause"]})]}),t.state==="error"&&e.jsxs("button",{className:"btn btn--sm",onClick:()=>void W(t.id,"active"),disabled:ne.has(t.id),title:"Retry",children:[e.jsx(Ne,{size:14})," Retry"]}),t.state==="terminated"&&e.jsxs("button",{className:"btn btn--sm",onClick:()=>void W(t.id,"active"),disabled:ne.has(t.id),title:"Start",children:[e.jsx(Ne,{size:14})," Start"]}),e.jsx("button",{className:"btn btn--sm agent-card-details-btn",onClick:()=>a(t.id),title:`View details for ${t.name}`,"aria-label":`View details for ${t.name}`,children:"View Details"}),e.jsxs("button",{className:"btn btn--sm btn--danger",onClick:()=>void Oe(t.id,t.name),title:"Delete",children:[e.jsx(ft,{size:14})," Delete"]})]})]},t.id)})})]}),!d&&L&&e.jsxs("div",{className:"agents-sidebar-quick-controls",children:[e.jsxs("div",{className:"agents-sidebar-quick-controls__header",children:[e.jsx("strong",{children:L.name}),e.jsx("span",{className:`badge ${Je(L.state)}`,children:L.state})]}),e.jsxs("div",{className:"agents-sidebar-quick-controls__meta",children:[e.jsx("span",{children:st(Ge(L.runtimeConfig?.heartbeatIntervalMs))}),L.lastHeartbeatAt&&e.jsxs("span",{children:["Last ",yn(L.lastHeartbeatAt)]})]}),e.jsxs("div",{className:"agents-sidebar-quick-controls__actions",children:[L.state==="idle"&&e.jsxs("button",{className:"btn btn-sm",onClick:()=>void W(L.id,"active"),children:[e.jsx(Ne,{size:14})," Start"]}),L.state==="active"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"btn btn-sm",onClick:()=>void fe(L.id,L.name),children:[e.jsx(Re,{size:14})," Run Now"]}),e.jsxs("button",{className:"btn btn-sm",onClick:()=>void W(L.id,"paused"),children:[e.jsx(We,{size:14})," Pause"]})]}),L.state==="running"&&e.jsxs("button",{className:"btn btn-sm",onClick:()=>void W(L.id,"paused"),children:[e.jsx(We,{size:14})," Pause"]}),L.state==="paused"&&e.jsxs("button",{className:"btn btn-sm",onClick:()=>void W(L.id,"active"),children:[e.jsx(Ne,{size:14})," Resume"]}),L.state==="error"&&e.jsxs("button",{className:"btn btn-sm",onClick:()=>void W(L.id,"active"),children:[e.jsx(Ne,{size:14})," Retry"]}),L.state==="terminated"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"btn btn-sm",onClick:()=>void W(L.id,"active"),children:[e.jsx(Ne,{size:14})," Start"]}),e.jsxs("button",{className:"btn btn-danger btn-sm",onClick:()=>void Oe(L.id,L.name),children:[e.jsx(ft,{size:14})," Delete"]})]})]})]})]}),e.jsxs("div",{className:`agents-split-detail${d&&!F?" agents-split-detail--hidden-mobile":""}`,children:[se&&e.jsx("div",{className:"agents-mobile-back-row",children:e.jsxs("button",{className:"btn agents-mobile-back-btn",onClick:C,children:[e.jsx(un,{size:16}),"Agents"]})}),F?e.jsx(n.Suspense,{fallback:null,children:e.jsx(ia,{inline:!0,agentId:F,projectId:o,onClose:C,addToast:s,onChildClick:Ee,initialTab:G,initialRunId:z,preferActiveRun:A})}):e.jsxs("div",{className:"agents-detail-empty-state",children:[e.jsx(dt,{size:48}),e.jsx("h3",{children:"Select an agent"}),e.jsx("p",{children:"Choose an agent from the sidebar to view details"})]})]})]})]})}export{ha as AgentsView,Et as formatAgentSkillBadgeLabel};
|