@runfusion/fusion 0.20.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/bin.js +2021 -996
  2. package/dist/client/assets/AgentDetailView-BKKpbp1S.js +18 -0
  3. package/dist/client/assets/AgentDetailView-CeO_1MK7.css +1 -0
  4. package/dist/client/assets/AgentsView-BRXFmrcJ.js +527 -0
  5. package/dist/client/assets/AgentsView-Bs03ptrd.css +1 -0
  6. package/dist/client/assets/ChatView-D7L2e_qu.js +1 -0
  7. package/dist/client/assets/DevServerView-l8RCyL2k.js +1 -0
  8. package/dist/client/assets/DirectoryPicker-CS1dwqcC.js +1 -0
  9. package/dist/client/assets/DocumentsView-DmthQWDZ.js +1 -0
  10. package/dist/client/assets/{InsightsView-Cqim12az.js → InsightsView-DvXpMKmH.js} +2 -2
  11. package/dist/client/assets/{MemoryView-CakLoJtY.js → MemoryView-CPwlKnUI.js} +2 -2
  12. package/dist/client/assets/{NodesView-BxGm3poT.js → NodesView-BLlfUfsy.js} +3 -3
  13. package/dist/client/assets/{PiExtensionsManager-lJbmskyZ.js → PiExtensionsManager-j8rPXqmB.js} +2 -2
  14. package/dist/client/assets/PluginManager-pW6RMz5z.js +1 -0
  15. package/dist/client/assets/ResearchView-D9DNJYDq.js +1 -0
  16. package/dist/client/assets/{RoadmapsView-CeKks_OI.js → RoadmapsView-Djc_X35v.js} +2 -2
  17. package/dist/client/assets/SettingsModal-WGCF_pk8.js +31 -0
  18. package/dist/client/assets/{SettingsModal-YdeVPhRJ.js → SettingsModal-fxvTFLtR.js} +1 -1
  19. package/dist/client/assets/SetupWizardModal-tG_MF_nA.js +1 -0
  20. package/dist/client/assets/SkillsView-Ddf0YL8z.js +1 -0
  21. package/dist/client/assets/agentSkills-DDHJnrkn.css +1 -0
  22. package/dist/client/assets/agentSkills-EwIwBlG8.js +1 -0
  23. package/dist/client/assets/folder-open-BiJpmnaT.js +6 -0
  24. package/dist/client/assets/index-D6ebxTPF.css +1 -0
  25. package/dist/client/assets/index-DYDLmOcK.js +694 -0
  26. package/dist/client/assets/{star-DxVRh9VT.js → star-BwRZmiuZ.js} +2 -2
  27. package/dist/client/assets/upload-D4NwZhPp.js +6 -0
  28. package/dist/client/assets/{users-3SD3oNMQ.js → users-DNISDtI1.js} +2 -2
  29. package/dist/client/index.html +2 -2
  30. package/dist/client/version.json +1 -1
  31. package/dist/droid-cli/package.json +1 -1
  32. package/dist/extension.js +1172 -401
  33. package/dist/pi-claude-cli/package.json +1 -1
  34. package/dist/plugins/fusion-plugin-dependency-graph/package.json +1 -1
  35. package/dist/plugins/fusion-plugin-hermes-runtime/bundled.js +480 -0
  36. package/dist/plugins/fusion-plugin-hermes-runtime/manifest.json +14 -0
  37. package/dist/plugins/fusion-plugin-hermes-runtime/package.json +11 -0
  38. package/dist/plugins/fusion-plugin-openclaw-runtime/bundled.js +369 -0
  39. package/dist/plugins/fusion-plugin-openclaw-runtime/manifest.json +14 -0
  40. package/dist/plugins/fusion-plugin-openclaw-runtime/package.json +11 -0
  41. package/dist/plugins/fusion-plugin-paperclip-runtime/bundled.js +966 -0
  42. package/dist/plugins/fusion-plugin-paperclip-runtime/manifest.json +15 -0
  43. package/dist/plugins/fusion-plugin-paperclip-runtime/package.json +11 -0
  44. package/package.json +3 -1
  45. package/skill/fusion/references/engine-tools.md +1 -1
  46. package/dist/client/assets/AgentDetailView-C6BG7O7i.js +0 -18
  47. package/dist/client/assets/AgentDetailView-CUtWvXBn.css +0 -1
  48. package/dist/client/assets/ChatView-DeXUYwSY.js +0 -1
  49. package/dist/client/assets/DevServerView-Dariyxt_.js +0 -1
  50. package/dist/client/assets/DirectoryPicker-SchiK-Aq.js +0 -1
  51. package/dist/client/assets/DocumentsView-C6v-tBhG.js +0 -1
  52. package/dist/client/assets/PluginManager-BZjNNf9m.js +0 -1
  53. package/dist/client/assets/ResearchView-Bzsr9V0y.js +0 -1
  54. package/dist/client/assets/SettingsModal-D-9CLguN.js +0 -31
  55. package/dist/client/assets/SetupWizardModal-DAC04LlA.js +0 -1
  56. package/dist/client/assets/SkillsView-CClC_5RN.js +0 -1
  57. package/dist/client/assets/index-CrHLf3pB.js +0 -1222
  58. package/dist/client/assets/index-Df1bHDY4.css +0 -1
@@ -0,0 +1,18 @@
1
+ import{r as t,j as e}from"./vendor-react-K0fH_qHe.js";import{c as us,dt as mt,du as ht,dv as ft,dw as gt,L as I,R as ms,at as Fs,Z as xt,au as as,a1 as We,a as Bs,b as Os,dx as bt,dy as vt,dz as pt,D as _s,cD as jt,dA as Nt,J as Y,dB as yt,dC as Is,dD as Vs,s as Ve,bd as St,k as Us,$ as ns,a0 as As,aR as $e,X as Js,F as De,A as Ue,dE as Ws,dF as Gs,dG as kt,cx as Ct,aQ as Rt,bE as wt,av as qs,B as Ys,a3 as Mt,a7 as Ft,a9 as At,dH as os,l as Ks,dI as Et,bH as Tt,r as Pt,as as $t,a6 as Zs,dJ as Dt,C as ne,dK as Qs,dL as Lt,dM as zt,dN as Ht,dO as qe,ae as Ye,ag as Ke,ah as Ze,ac as Xs,dP as Bt,dQ as Ot,i as _t,h as It,j as Es,a4 as Vt,dR as Ut,dS as Jt,m as Wt,dT as ds,a8 as Gt,dU as qt,Y as Yt,dV as Kt,dW as Zt,dX as et,dY as Qt,dZ as Xt,d_ as ea,d$ as sa}from"./index-DYDLmOcK.js";import{S as st}from"./star-BwRZmiuZ.js";import{f as is,S as ta}from"./agentSkills-EwIwBlG8.js";import"./vendor-xterm-DzcZoU0P.js";/**
2
+ * @license lucide-react v1.7.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const aa=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]],Je=us("chart-column",aa);/**
7
+ * @license lucide-react v1.7.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const na=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M17 12h-2l-2 5-2-10-2 5H7",key:"15hlnc"}]],ia=us("square-activity",na);/**
12
+ * @license lucide-react v1.7.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const ra=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],la=us("trending-down",ra);function Ts(s){return s<1e3?`${s}ms`:s<6e4?`${(s/1e3).toFixed(1)}s`:s<36e5?`${Math.floor(s/6e4)}m`:`${(s/36e5).toFixed(1)}h`}function ca(s){return`${Math.round(s*100)}%`}function Ps(s){const n=Date.now(),i=new Date(s).getTime(),c=n-i;if(c<0){const m=Math.abs(c);return m<6e4?"in a moment":m<36e5?`in ${Math.floor(m/6e4)}m`:m<864e5?`in ${Math.floor(m/36e5)}h`:`in ${Math.floor(m/864e5)}d`}return c<6e4?"just now":c<36e5?`${Math.floor(c/6e4)}m ago`:c<864e5?`${Math.floor(c/36e5)}h ago`:`${Math.floor(c/864e5)}d ago`}function oa(s){switch(s){case"periodic":return"Periodic";case"post-task":return"Post-Task";case"manual":return"Manual";case"user-requested":return"User Requested";default:return s}}function Te(s){return s instanceof Error&&s.message?s.message:String(s)}function da(s){switch(s){case"improving":return"↑ Improving";case"declining":return"↓ Declining";case"stable":return"→ Stable";default:return"Insufficient data"}}function ua(s){switch(s){case"improving":return"trend-improving";case"declining":return"trend-declining";case"stable":return"trend-stable";default:return"trend-insufficient"}}function $s(s,n=5){return e.jsx("span",{className:"rating-stars",children:Array.from({length:n},(i,c)=>e.jsx(st,{size:14,className:c<s?"star-filled":"star-empty",fill:c<s?"currentColor":"none"},c))})}function ma({agentId:s,projectId:n,addToast:i}){const[c,m]=t.useState([]),[x,w]=t.useState(null),[f,S]=t.useState(null),[E,C]=t.useState([]),[o,p]=t.useState(!0),[D,z]=t.useState(!0),[M,H]=t.useState(!1),[J,g]=t.useState(!1),[V,Q]=t.useState(null),[j,A]=t.useState(0),[v,T]=t.useState(""),[F,K]=t.useState(""),B=t.useCallback(async()=>{try{const[l,r]=await Promise.all([mt(s,20,n),ht(s,void 0,n)]);m(l),w(r)}catch(l){i(`Failed to load reflections: ${Te(l)}`,"error")}finally{p(!1)}},[s,n,i]),W=t.useCallback(async()=>{try{const[l,r]=await Promise.all([ft(s,n),gt(s,{limit:50},n)]);S(l),C(r)}catch(l){i(`Failed to load ratings: ${Te(l)}`,"error")}finally{z(!1)}},[s,n,i]);t.useEffect(()=>{B(),W()},[B,W]);const G=async()=>{H(!0);try{if(!await bt(s,n)){i("Not enough history to generate a reflection yet","error");return}i("Reflection generated successfully","success"),p(!0),await B()}catch(l){const r=Te(l),b=r.toLowerCase();b.includes("agent not found")||b.includes("not found")?i("This agent is no longer available. It may have been deleted.","error"):b.includes("insufficient history")?i("Not enough history to generate a reflection yet","error"):i(`Failed to generate reflection: ${r}`,"error")}finally{H(!1)}},k=async l=>{if(l.preventDefault(),j!==0){g(!0);try{await vt(s,{score:j,category:v||void 0,comment:F||void 0,raterType:"user"},n),A(0),T(""),K(""),i("Rating added","success"),await W()}catch(r){i(`Failed to add rating: ${Te(r)}`,"error")}finally{g(!1)}}},$=async l=>{try{await pt(s,l,n),i("Rating deleted","success"),await W()}catch(r){i(`Failed to delete rating: ${Te(r)}`,"error")}},d=l=>{Q(r=>r===l?null:l)};if(o&&D)return e.jsx("div",{className:"reflections-tab",children:e.jsxs("div",{className:"reflections-loading-indicator",children:[e.jsx(I,{size:16,className:"animate-spin"}),e.jsx("span",{className:"text-muted",children:"Loading evaluation..."})]})});const h=x&&x.totalTasksCompleted===0&&x.totalTasksFailed===0&&x.recentReflectionCount===0;return e.jsxs("div",{className:"reflections-tab",children:[e.jsxs("div",{className:"reflections-header",children:[e.jsxs("h3",{children:[e.jsx(Je,{size:16}),"Performance, Reflections & Ratings"]}),e.jsx("button",{className:"btn btn-secondary",onClick:G,disabled:M,title:"Generate a manual reflection",children:M?e.jsxs(e.Fragment,{children:[e.jsx(I,{size:14,className:"animate-spin"}),"Reflecting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ms,{size:14}),"Reflect Now"]})})]}),x&&!h&&e.jsxs("div",{className:"reflections-stats-grid",children:[e.jsxs("div",{className:"reflections-stat-card",children:[e.jsxs("div",{className:"stat-value",children:[e.jsx(Fs,{size:16,style:{color:"var(--color-success)"}}),x.totalTasksCompleted]}),e.jsx("div",{className:"stat-label",children:"Tasks Completed"})]}),e.jsxs("div",{className:"reflections-stat-card",children:[e.jsxs("div",{className:"stat-value",children:[e.jsx(la,{size:16,style:{color:"var(--color-error)"}}),x.totalTasksFailed]}),e.jsx("div",{className:"stat-label",children:"Tasks Failed"})]}),e.jsxs("div",{className:"reflections-stat-card",children:[e.jsxs("div",{className:"stat-value",children:[e.jsx(xt,{size:16,style:{color:"var(--in-progress)"}}),Ts(x.avgDurationMs)]}),e.jsx("div",{className:"stat-label",children:"Avg Duration"})]}),e.jsxs("div",{className:"reflections-stat-card",children:[e.jsxs("div",{className:"stat-value",children:[e.jsx(Je,{size:16,style:{color:x.successRate>=.8?"var(--color-success)":x.successRate>=.5?"var(--color-warning)":"var(--color-error)"}}),ca(x.successRate)]}),e.jsx("div",{className:"stat-label",children:"Success Rate"})]}),e.jsxs("div",{className:"reflections-stat-card",children:[e.jsxs("div",{className:"stat-value",children:[e.jsx(as,{size:16,style:{color:"var(--color-info)"}}),x.recentReflectionCount]}),e.jsx("div",{className:"stat-label",children:"Reflections"})]})]}),h&&e.jsxs("div",{className:"reflections-no-data",children:[e.jsx(Je,{size:24,opacity:.3}),e.jsx("p",{children:"No performance data yet"})]}),e.jsxs("div",{className:"reflections-ratings-section",children:[e.jsx("h4",{children:"User Ratings"}),D?e.jsxs("div",{className:"reflections-loading-indicator",children:[e.jsx(I,{size:16,className:"animate-spin"}),e.jsx("span",{className:"text-muted",children:"Loading ratings..."})]}):e.jsxs(e.Fragment,{children:[f&&e.jsxs("div",{className:"rating-summary-card",children:[e.jsxs("div",{className:"rating-score-display",children:[e.jsx("span",{className:"rating-average",children:f.averageScore.toFixed(1)}),$s(Math.round(f.averageScore))]}),e.jsxs("div",{className:"rating-stats",children:[e.jsxs("span",{className:"rating-count",children:[f.totalRatings," ratings"]}),e.jsx("span",{className:`rating-trend-badge ${ua(f.trend)}`,children:da(f.trend)})]})]}),f&&Object.keys(f.categoryAverages).length>0&&e.jsxs("div",{className:"category-breakdown",children:[e.jsx("h4",{children:"Category Averages"}),Object.entries(f.categoryAverages).map(([l,r])=>e.jsxs("div",{className:"category-item",children:[e.jsx("span",{className:"category-name",children:l}),e.jsx("span",{className:"category-score",children:r.toFixed(1)})]},l))]}),e.jsxs("form",{className:"add-rating-form",onSubmit:k,children:[e.jsx("h4",{children:"Add Rating"}),e.jsx("div",{className:"star-selector",children:[1,2,3,4,5].map(l=>e.jsx("button",{type:"button",className:"star-btn touch-target",onClick:()=>A(l),title:`${l} star${l>1?"s":""}`,children:e.jsx(st,{size:24,fill:l<=j?"currentColor":"none",className:l<=j?"star-filled":"star-empty"})},l))}),e.jsxs("select",{value:v,onChange:l=>T(l.target.value),className:"select add-rating-category-select",children:[e.jsx("option",{value:"",children:"Select category..."}),e.jsx("option",{value:"quality",children:"Quality"}),e.jsx("option",{value:"speed",children:"Speed"}),e.jsx("option",{value:"communication",children:"Communication"}),e.jsx("option",{value:"reliability",children:"Reliability"}),e.jsx("option",{value:"other",children:"Other"})]}),e.jsx("textarea",{value:F,onChange:l=>K(l.target.value),placeholder:"Optional comment...",className:"input add-rating-comment-input",rows:3}),e.jsx("button",{type:"submit",className:"btn btn-task-create",disabled:j===0||J,children:J?"Submitting...":"Submit Rating"})]}),e.jsxs("div",{className:"rating-history",children:[e.jsx("h4",{children:"Rating History"}),E.length===0?e.jsx("p",{className:"no-ratings",children:"No ratings yet"}):E.map(l=>e.jsxs("div",{className:"rating-history-item",children:[e.jsxs("div",{className:"rating-item-header",children:[$s(l.score),l.category&&e.jsx("span",{className:"rating-category-badge",children:l.category}),e.jsx("span",{className:"rating-time",children:Ps(l.createdAt)}),e.jsx("button",{type:"button",className:"rating-delete-btn touch-target",onClick:()=>void $(l.id),title:"Delete rating",children:e.jsx(We,{size:14})})]}),l.comment&&e.jsx("p",{className:"rating-comment",children:l.comment})]},l.id))]})]})]}),e.jsxs("div",{className:"reflections-list",children:[e.jsx("h4",{children:"Reflection History"}),o?e.jsxs("div",{className:"reflections-loading-indicator",children:[e.jsx(I,{size:16,className:"animate-spin"}),e.jsx("span",{className:"text-muted",children:"Loading reflections..."})]}):c.length===0?e.jsxs("div",{className:"reflection-empty",children:[e.jsx(as,{size:32,opacity:.3}),e.jsx("p",{children:"No reflections yet"}),e.jsx("p",{className:"text-secondary",children:"Trigger a reflection to get started"})]}):e.jsx("div",{className:"reflection-cards",children:c.map(l=>{const r=V===l.id;return e.jsxs("div",{className:`reflection-card ${r?"reflection-card--expanded":""}`,onClick:()=>d(l.id),role:"button",tabIndex:0,onKeyDown:b=>b.key==="Enter"&&d(l.id),children:[e.jsxs("div",{className:"reflection-card-header",children:[e.jsx("span",{className:`reflection-trigger-badge reflection-trigger-${l.trigger}`,children:oa(l.trigger)}),e.jsx("span",{className:"reflection-timestamp",children:Ps(l.timestamp)}),e.jsx("span",{className:"reflection-chevron",children:r?e.jsx(Bs,{size:16}):e.jsx(Os,{size:16})})]}),e.jsx("div",{className:"reflection-summary",children:l.summary}),r&&e.jsxs("div",{className:"reflection-details",children:[l.insights.length>0&&e.jsxs("div",{className:"reflection-insights",children:[e.jsxs("h5",{children:[e.jsx(as,{size:14})," Insights"]}),e.jsx("ul",{children:l.insights.map((b,L)=>e.jsx("li",{children:b},L))})]}),l.suggestedImprovements.length>0&&e.jsxs("div",{className:"reflection-suggestions",children:[e.jsxs("h5",{children:[e.jsx(Fs,{size:14})," Suggested Improvements"]}),e.jsx("ul",{children:l.suggestedImprovements.map((b,L)=>e.jsx("li",{children:b},L))})]}),l.metrics&&e.jsxs("div",{className:"reflection-metrics",children:[e.jsx("h5",{children:"Metrics"}),e.jsxs("div",{className:"metrics-grid",children:[l.metrics.tasksCompleted!==void 0&&e.jsxs("div",{className:"metric",children:[e.jsx("span",{className:"metric-label",children:"Tasks:"}),e.jsx("span",{className:"metric-value",children:l.metrics.tasksCompleted})]}),l.metrics.tasksFailed!==void 0&&e.jsxs("div",{className:"metric",children:[e.jsx("span",{className:"metric-label",children:"Failed:"}),e.jsx("span",{className:"metric-value",children:l.metrics.tasksFailed})]}),l.metrics.avgDurationMs!==void 0&&e.jsxs("div",{className:"metric",children:[e.jsx("span",{className:"metric-label",children:"Avg Duration:"}),e.jsx("span",{className:"metric-value",children:Ts(l.metrics.avgDurationMs)})]}),l.metrics.errorCount!==void 0&&e.jsxs("div",{className:"metric",children:[e.jsx("span",{className:"metric-label",children:"Errors:"}),e.jsx("span",{className:"metric-value",children:l.metrics.errorCount})]})]})]})]})]},l.id)})})]})]})}function te(...s){return s.filter(Boolean).join(" ")}function Me(s){const n=Date.now(),i=new Date(s).getTime(),c=n-i;if(c<0){const m=Math.abs(c);return m<6e4?"in a moment":m<36e5?`in ${Math.floor(m/6e4)}m`:m<864e5?`in ${Math.floor(m/36e5)}h`:`in ${Math.floor(m/864e5)}d`}return c<6e4?"just now":c<36e5?`${Math.floor(c/6e4)}m ago`:c<864e5?`${Math.floor(c/36e5)}h ago`:`${Math.floor(c/864e5)}d ago`}const ha=[{id:"dashboard",label:"Dashboard",icon:ia},{id:"logs",label:"Logs",icon:De},{id:"runs",label:"Runs",icon:Ue},{id:"tasks",label:"Tasks",icon:Ws},{id:"employees",label:"Employees",icon:Gs},{id:"soul",label:"Soul",icon:kt},{id:"instructions",label:"Instructions",icon:Ct},{id:"memory",label:"Agent Memory",icon:De},{id:"reflections",label:"Evaluation",icon:Je},{id:"config",label:"Settings",icon:Rt}],hs={idle:{bg:"var(--state-idle-bg)",text:"var(--state-idle-text)",border:"var(--state-idle-border)"},active:{bg:"var(--state-active-bg)",text:"var(--state-active-text)",border:"var(--state-active-border)"},running:{bg:"var(--state-active-bg)",text:"var(--state-active-text)",border:"var(--state-active-border)"},paused:{bg:"var(--state-paused-bg)",text:"var(--state-paused-text)",border:"var(--state-paused-border)"},error:{bg:"var(--state-error-bg)",text:"var(--state-error-text)",border:"var(--state-error-border)"}},Ge={completed:{icon:ne,color:"var(--color-success)"},failed:{icon:Dt,color:"var(--color-error)"},active:{icon:I,color:"var(--in-progress)"},terminated:{icon:$e,color:"var(--text-muted)"}},Ds={"long-term":"Long-term",daily:"Daily",dreams:"Dreams"},fa={"long-term":"Curated durable decisions, conventions, constraints, and pitfalls for this specific agent.",daily:"Raw daily observations and open loops recorded by this agent.",dreams:"Synthesized patterns and emerging themes distilled from this agent's daily memory."},ga=Zs(ds),xa=700;function ba(s,n){return s.some(i=>i.path===n)?n:s.find(i=>i.layer==="long-term")?.path??s[0]?.path??""}function za({agentId:s,projectId:n,onClose:i,addToast:c,onChildClick:m,inline:x=!1,showInlineBackButton:w=!1,initialTab:f,initialRunId:S,preferActiveRun:E=!1,onMutationSuccess:C}){const[o,p]=t.useState(null),{confirm:D}=_s(),[z,M]=t.useState([]),[H,J]=t.useState(!0),[g,V]=t.useState(f??"dashboard"),[Q,j]=t.useState(!1),[A,v]=t.useState(!1),[T,F]=t.useState(null),K=t.useRef(null),B=t.useRef(!1);jt(K,!x,"fusion:agent-detail-modal-size");const W=t.useRef(i),G=t.useRef(c),k=t.useRef(null),$=t.useRef(!1),d=t.useRef(null),h=t.useRef(0),l=t.useRef(s),r=t.useRef(n);W.current=i,G.current=c,k.current=o;const b=t.useCallback(async()=>{k.current===null&&J(!0);try{const X=await Nt(s,n);p(X)}catch(X){G.current(`Failed to load agent: ${Y(X)}`,"error"),W.current()}finally{J(!1)}},[s,n]),L=t.useCallback(async()=>{const y=h.current,X=s,ee=n,Z=()=>h.current!==y||s!==X||n!==ee;try{if(o?.taskId){F(null),d.current=null;const Re=await yt(o.taskId,ee,{limit:100});if(Z())return;M(Re.entries);return}const oe=await Is(X,1,ee);if(Z())return;const ie=oe[0]??null;if(F(ie),!ie){d.current=null,M([]);return}if(d.current===ie.id)return;const pe=await Vs(X,ie.id,ee);if(Z())return;M(pe),d.current=ie.id}catch(oe){if(Z())return;console.error("Failed to load agent logs:",oe)}},[o?.taskId,s,n]),he=t.useCallback(y=>{$.current=y},[]),ce=t.useCallback(async(y=!1)=>{await C?.({agentId:s,deleted:y})},[s,C]),ue=t.useCallback(async()=>{await b(),await ce(!1)},[b,ce]);t.useEffect(()=>{b()},[b]),t.useEffect(()=>{const y=setInterval(()=>{b()},3e4);return()=>{clearInterval(y)}},[b]),t.useEffect(()=>{o&&g==="logs"&&L()},[o,g,L]),t.useEffect(()=>{g!=="logs"&&(d.current=null)},[g]),t.useEffect(()=>{if(g!=="logs"||o?.taskId||!T||T.status!=="active")return;const y=h.current,X=s,ee=T.id,Z=n?`?projectId=${encodeURIComponent(n)}`:"",oe=Ve(`/api/agents/${encodeURIComponent(X)}/runs/${encodeURIComponent(ee)}/logs/stream${Z}`,{events:{"agent:log":ie=>{if(h.current===y)try{const pe=JSON.parse(ie.data);M(Re=>[...Re,pe])}catch{}}},onOpen:()=>{h.current===y&&j(!0)},onError:()=>{h.current===y&&j(!1)}});return()=>{oe(),h.current===y&&j(!1)}},[g,o?.taskId,s,n,T]),t.useEffect(()=>{(l.current!==s||r.current!==n)&&(l.current=s,r.current=n,h.current++,M([]),j(!1),F(null),d.current=null,$.current=!1)},[s,n]),t.useEffect(()=>{const y=n?`?projectId=${encodeURIComponent(n)}`:"",X=h.current;return Ve(`/api/events${y}`,{events:{"agent:updated":ee=>{if(h.current===X)try{const Z=JSON.parse(ee.data);if(!Z||typeof Z!="object"||Z.id!==s||$.current)return;b()}catch{}}}})},[s,n,b]),t.useEffect(()=>{if(g!=="logs"||!o?.taskId){j(!1);return}const y=h.current,X=o.taskId,ee=n?`?projectId=${encodeURIComponent(n)}`:"",Z=Ve(`/api/tasks/${encodeURIComponent(X)}/logs/stream${ee}`,{events:{"agent:log":oe=>{if(h.current===y)try{const ie=JSON.parse(oe.data);M(pe=>[...pe,ie])}catch{}}},onOpen:()=>{h.current===y&&j(!0)},onError:()=>{h.current===y&&j(!1)}});return()=>{Z(),h.current===y&&j(!1)}},[o?.taskId,g,n]);const N=async y=>{if(A||!k.current)return;const X=k.current.state;if(X!==y){v(!0),p(ee=>ee&&{...ee,state:y});try{await Ft(s,y,n),c(`Agent state updated to ${y}`,"success"),await ue()}catch(ee){p(Z=>Z&&{...Z,state:X}),c(`Failed to update state: ${Y(ee)}`,"error")}finally{v(!1)}}},U=async()=>{if(!(!o||!await D({title:"Delete Agent",message:`Delete agent "${o.name}"? This cannot be undone.`,danger:!0})))try{await At(s,n),c(`Agent "${o.name}" deleted`,"success"),await ce(!0),i()}catch(X){c(`Failed to delete agent: ${Y(X)}`,"error")}},me=()=>o?Mt(o):{label:"Unknown",icon:e.jsx(Ys,{size:14}),color:"var(--text-muted)",stateDerived:!1},Le=()=>{o&&(navigator.clipboard.writeText(o.id),c("Agent ID copied to clipboard","success"))};if(H)return x?e.jsx("div",{className:"agent-detail-inline-loading",role:"region","aria-label":"Agent detail loading",children:e.jsxs("div",{className:"agent-detail-loading",children:[e.jsx(I,{className:"animate-spin",size:24}),e.jsx("span",{children:"Loading agent..."})]})}):e.jsx("div",{className:"agent-detail-overlay",onMouseDown:y=>{y.target===y.currentTarget&&(B.current=!0)},onMouseUp:y=>{B.current&&y.target===y.currentTarget&&i(),B.current=!1},role:"dialog","aria-modal":"true",children:e.jsx("div",{className:"agent-detail-modal",ref:K,children:e.jsxs("div",{className:"agent-detail-loading",children:[e.jsx(I,{className:"animate-spin",size:24}),e.jsx("span",{children:"Loading agent..."})]})})});if(!o)return null;const be=hs[o.state],ve=me(),Qe=x?"agent-detail-inline":"agent-detail-modal";return e.jsx("div",{className:x?"agent-detail-inline-shell":"agent-detail-overlay",onClick:y=>!x&&y.target===y.currentTarget&&i(),role:x?"region":"dialog","aria-label":x?"Agent detail":void 0,"aria-modal":x?void 0:"true",children:e.jsxs("div",{className:Qe,ref:K,children:[e.jsxs("div",{className:"agent-detail-header",children:[e.jsxs("div",{className:"agent-detail-identity",children:[x&&w?e.jsxs("button",{type:"button",className:"btn agent-detail-inline-back",onClick:i,"aria-label":"Back to agents",children:[e.jsx(St,{size:16}),"Agents"]}):null,e.jsx("div",{className:"agent-detail-icon",children:e.jsx(Us,{agent:o,size:36})}),e.jsxs("div",{className:"agent-detail-info",children:[e.jsx("h2",{children:o.name}),e.jsxs("div",{className:"agent-detail-badges",children:[e.jsx("span",{className:"badge",style:{background:be.bg,color:be.text,border:`1px solid ${be.border}`},children:o.state}),e.jsxs("span",{className:"badge",style:{color:ve.color},title:ve.reason??ve.label,children:[ve.icon,!ve.stateDerived&&ve.label]})]})]})]}),e.jsxs("div",{className:"agent-detail-header-actions",children:[e.jsxs("div",{className:"agent-detail-controls",children:[o.state==="idle"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"btn btn-task-create btn--compact",onClick:()=>void N("active"),disabled:A,children:[e.jsx(ns,{size:14}),"Start"]}),e.jsxs("button",{className:"btn btn--danger btn--compact",onClick:U,children:[e.jsx(We,{size:14}),"Delete"]})]}),o.state==="active"&&e.jsxs("button",{className:"btn btn--compact agent-detail-mobile-icon-control",onClick:()=>void N("paused"),disabled:A,"aria-label":"Pause",children:[e.jsx(As,{size:14}),e.jsx("span",{className:"agent-detail-control-label",children:"Pause"})]}),o.state==="paused"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"btn btn-task-create btn--compact agent-detail-mobile-icon-control",onClick:()=>void N("active"),disabled:A,"aria-label":"Resume",children:[e.jsx(ns,{size:14}),e.jsx("span",{className:"agent-detail-control-label",children:"Resume"})]}),e.jsxs("button",{className:"btn btn--danger btn--compact",onClick:U,children:[e.jsx(We,{size:14}),"Delete"]})]}),o.state==="running"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"btn btn--compact agent-detail-mobile-icon-control",onClick:()=>void N("paused"),disabled:A,"aria-label":"Pause",children:[e.jsx(As,{size:14}),e.jsx("span",{className:"agent-detail-control-label",children:"Pause"})]}),e.jsxs("button",{className:"btn btn--danger btn--compact",onClick:()=>void N("paused"),disabled:A,children:[e.jsx($e,{size:14}),"Stop"]})]}),o.state==="error"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"btn btn-task-create btn--compact",onClick:()=>void N("active"),disabled:A,children:[e.jsx(ns,{size:14}),"Retry"]}),e.jsxs("button",{className:"btn btn--danger btn--compact",onClick:()=>void N("paused"),disabled:A,children:[e.jsx($e,{size:14}),"Stop"]})]})]}),e.jsxs("div",{className:"agent-detail-utility-actions",children:[e.jsx("button",{className:"btn-icon",onClick:()=>void b(),title:"Refresh","aria-label":"Refresh",children:e.jsx(ms,{size:16})}),!x&&e.jsx("button",{className:"btn-icon",onClick:i,"aria-label":"Close",title:"Close",children:e.jsx(Js,{size:20})})]})]})]}),e.jsx("div",{className:"agent-detail-tabs",children:ha.map(y=>e.jsxs("button",{className:te("agent-detail-tab",g===y.id&&"active"),onClick:()=>V(y.id),children:[e.jsx(y.icon,{size:16}),y.label]},y.id))}),e.jsxs("div",{className:"agent-detail-content",children:[g==="dashboard"&&e.jsx(va,{agent:o,health:ve,onChildClick:m,projectId:n}),g==="logs"&&e.jsx(pa,{logs:z,isStreaming:Q,hasTask:!!o.taskId||z.length>0||T!==null,fallbackLabel:!o.taskId&&T?`Latest run · ${T.id.slice(0,8)}`:null}),g==="runs"&&e.jsx(ja,{addToast:c,agentId:o.id,projectId:n,agentState:o.state,agentName:o.name,initialRunId:S,preferActiveRun:E}),g==="tasks"&&e.jsx(ka,{agentId:o.id,projectId:n,addToast:c}),g==="employees"&&e.jsx(Ea,{agentId:o.id,projectId:n,onChildClick:m}),g==="soul"&&e.jsx(Ra,{agent:o,projectId:n,addToast:c,onSaved:ue}),g==="instructions"&&e.jsx(Ma,{agent:o,projectId:n,addToast:c,onSaved:ue}),g==="memory"&&e.jsx(wa,{agent:o,projectId:n,addToast:c,onSaved:ue}),g==="reflections"&&e.jsx(ma,{agentId:o.id,projectId:n,addToast:c}),g==="config"&&e.jsx(Aa,{agent:o,projectId:n,addToast:c,onSaved:ue,onHasChangesChange:he,onDelete:U},o.id)]}),!x&&e.jsxs("div",{className:"agent-detail-footer",children:[e.jsx("button",{className:"btn-icon",onClick:Le,title:"Copy Agent ID",children:e.jsx(wt,{})}),e.jsx("span",{className:"agent-detail-id",onClick:Le,children:o.id}),o.taskId&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"divider",children:"|"}),e.jsx("span",{className:"text-muted",children:"Working on:"}),e.jsxs("a",{href:`/tasks/${o.taskId}`,className:"link",children:[o.taskId,e.jsx(qs,{size:12})]})]})]})]})})}function va({agent:s,health:n,onChildClick:i,projectId:c}){const m=hs[s.state],[x,w]=t.useState([]),[f,S]=t.useState(!0),[E,C]=t.useState(null),[o,p]=t.useState([]),[D,z]=t.useState(null),[M,H]=t.useState(null),[J,g]=t.useState(!1),[V,Q]=t.useState(null),j=typeof s.runtimeConfig?.runtimeHint=="string"?s.runtimeConfig.runtimeHint:"",A=(()=>{const d=s.runtimeConfig??{};if(j){const h=o.find(l=>l.runtimeId===j);return h?h.name:j}if(d.modelProvider&&d.modelId)return`${d.modelProvider}/${d.modelId}`;if(typeof d.model=="string"&&d.model.includes("/")){const h=d.model.indexOf("/");return d.model.slice(h+1)}return null})();t.useEffect(()=>{os(s.id,c).then(C).catch(()=>C(null))},[s.id,c]),t.useEffect(()=>{Ks(c).then(p).catch(()=>p([]))},[c]),t.useEffect(()=>{let d=!1;return S(!0),Et(s.id,c).then(h=>{if(d)return;const l=h.length>0&&h[0]?.id===s.id?[...h].reverse():h;w(l)}).catch(()=>{d||w([])}).finally(()=>{d||S(!1)}),()=>{d=!0}},[s.id,c]);const v=t.useMemo(()=>{const d=s.completedRuns||[],h=new Date;h.setHours(0,0,0,0);const l=d.filter(b=>new Date(b.startedAt)>=h),r=d.filter(b=>b.status==="completed");return{totalRuns:d.length,todayRuns:l.length,successfulRuns:r.length,successRate:d.length>0?Math.round(r.length/d.length*100):0}},[s]),T=(s.completedRuns||[]).slice(0,5),F=Array.isArray(s.metadata?.skills)?s.metadata.skills:[],K=D?is(D):null,B=t.useCallback(async d=>{g(!0),Q(null),H(null);try{const h=await Tt(d,c);H(h)}catch(h){Q(Y(h))}finally{g(!1)}},[c]),W=t.useCallback(d=>{if(D===d){z(null),H(null),Q(null),g(!1);return}z(d),B(d)},[B,D]),G=s.state==="active"||s.state==="running",k=Pt(s.runtimeConfig?.heartbeatIntervalMs),$=G&&s.lastHeartbeatAt?new Date(new Date(s.lastHeartbeatAt).getTime()+k).toISOString():null;return e.jsxs("div",{className:"dashboard-tab dashboard-summary-layout",children:[E?.isOverBudget&&e.jsxs("div",{className:"budget-warning-banner",role:"alert",children:[e.jsx("span",{children:"⚠️"}),e.jsxs("span",{children:[e.jsx("strong",{children:"Budget Exhausted:"})," This agent has exceeded its token budget and may operate with limited functionality."]})]}),e.jsxs("section",{className:"dashboard-summary-card dashboard-summary-hero",children:[e.jsxs("div",{className:"dashboard-summary-hero__heading",children:[e.jsx(Ys,{}),e.jsx("h3",{children:"Overview"}),e.jsx("strong",{children:s.name}),e.jsx("span",{className:"inline-badge",style:{background:m.bg,color:m.text},children:s.state})]}),e.jsxs("div",{className:"dashboard-summary-hero__meta",children:[e.jsxs("span",{className:"dashboard-summary-hero__health",title:n.reason??n.label,children:[n.icon," ",n.label]}),e.jsxs("span",{children:["Role: ",s.role]}),e.jsxs("span",{children:[e.jsx("span",{className:"dashboard-summary-label",children:j?"Runtime":"Model"}),e.jsxs("span",{children:[" ",A??"Auto"]})]}),F.length>0?e.jsxs("span",{className:"dashboard-summary-skills",children:[e.jsx("span",{className:"dashboard-summary-label",children:"Skills"}),e.jsx("span",{className:"dashboard-summary-skill-badges",role:"list","aria-label":"Assigned skills",children:F.map(d=>{const h=D===d;return e.jsx("button",{type:"button",className:te("badge","badge-skill","dashboard-summary-skill-badge","dashboard-summary-skill-badge-btn",h&&"dashboard-summary-skill-badge--selected"),title:d,onClick:()=>W(d),"aria-expanded":h,"aria-label":`View details for ${is(d)}`,children:is(d)},d)})})]}):e.jsx("span",{children:"Skills: —"})]}),D?e.jsxs("div",{className:"dashboard-summary-skill-detail","data-testid":"agent-skill-detail",children:[e.jsxs("div",{className:"dashboard-summary-skill-detail-header",children:[e.jsx("span",{className:"dashboard-summary-skill-detail-title",children:K}),e.jsxs("button",{type:"button",className:"btn btn-sm",onClick:()=>W(D),children:[e.jsx(Js,{size:14}),"Close"]})]}),J?e.jsxs("div",{className:"dashboard-summary-skill-detail-loading",role:"status","aria-live":"polite",children:[e.jsx(I,{size:14,className:"animate-spin"}),"Loading skill content..."]}):V?e.jsxs("div",{className:"dashboard-summary-skill-detail-error",role:"alert",children:[e.jsx($t,{size:14}),e.jsx("span",{children:V}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>void B(D),children:"Retry"})]}):M?e.jsx("pre",{className:"dashboard-summary-skill-detail-content",children:M.skillMd||"(No SKILL.md found)"}):e.jsx("div",{className:"dashboard-summary-skill-detail-empty",children:"No skill content available"})]}):null]}),e.jsxs("section",{className:"dashboard-summary-card",children:[e.jsx("h3",{children:"Heartbeat & Health"}),e.jsxs("div",{className:"dashboard-summary-grid",children:[e.jsxs("div",{children:[e.jsx("p",{className:"dashboard-summary-label",children:"Last heartbeat"}),e.jsx("p",{children:s.lastHeartbeatAt?Me(s.lastHeartbeatAt):"Never"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"dashboard-summary-label",children:"Next expected"}),e.jsx("p",{children:$?Me($):"Not scheduled"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"dashboard-summary-label",children:"Interval"}),e.jsx("p",{children:Zs(k)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"dashboard-summary-label",children:"Status"}),e.jsxs("p",{className:"dashboard-summary-health-row",children:[e.jsx("span",{className:te("status-dot",s.state==="running"&&"status-dot--running")}),n.label,n.reason&&e.jsxs("span",{className:"text-secondary dashboard-summary-health-reason",title:n.reason,children:["(",n.reason,")"]})]})]})]})]}),e.jsxs("section",{className:"dashboard-summary-card",children:[e.jsx("h3",{children:"Current Work"}),s.taskId?e.jsxs("div",{className:"current-task",children:[e.jsx("a",{href:`/tasks/${s.taskId}`,className:"task-badge",children:s.taskId}),e.jsxs("a",{href:`/tasks/${s.taskId}`,className:"btn btn-sm",children:["View Task ",e.jsx(qs,{size:14})]})]}):e.jsx("p",{className:"text-muted",children:"No active assignment"})]}),e.jsxs("section",{className:"dashboard-summary-card",children:[e.jsx("h3",{children:"Recent Runs"}),e.jsxs("p",{className:"dashboard-summary-label",children:[v.successfulRuns,"/",v.totalRuns," successful (",v.successRate,"%)"]}),T.length===0?e.jsx("p",{className:"text-muted",children:"No runs yet"}):e.jsx("div",{className:"runs-list",children:T.map(d=>{const h=Ge[d.status]||Ge.terminated,l=h.icon;return e.jsxs("div",{className:"run-item",children:[e.jsx(l,{size:14,style:{color:h.color}}),e.jsx("span",{children:Me(d.startedAt)}),e.jsxs("span",{className:"text-muted",children:[Math.max(0,Math.round((new Date(d.endedAt||d.startedAt).getTime()-new Date(d.startedAt).getTime())/1e3)),"s"]})]},d.id)})})]}),e.jsxs("section",{className:"dashboard-summary-card",children:[e.jsx("h3",{children:"Throughput"}),e.jsxs("div",{className:"stats-grid",children:[e.jsxs("div",{className:"stat-card",children:[e.jsx("div",{className:"stat-value",children:v.totalRuns}),e.jsx("div",{className:"stat-label",children:"Total Runs"})]}),e.jsxs("div",{className:"stat-card",children:[e.jsx("div",{className:"stat-value",children:v.todayRuns}),e.jsx("div",{className:"stat-label",children:"Runs Today"})]}),e.jsxs("div",{className:"stat-card",children:[e.jsxs("div",{className:"stat-value",children:[v.successRate,"%"]}),e.jsx("div",{className:"stat-label",children:"Success Rate"})]})]})]}),e.jsxs("section",{className:"dashboard-summary-card",children:[e.jsx("h3",{children:"Chain of Command"}),f?e.jsxs("div",{className:"chain-of-command-loading",role:"status","aria-live":"polite",children:[e.jsx(I,{size:14,className:"animate-spin"}),e.jsx("span",{children:"Loading reporting chain..."})]}):x.length<=1?e.jsx("p",{className:"text-muted",children:"No reporting chain"}):e.jsx("div",{className:"chain-of-command-path","aria-label":"Chain of command",children:x.map((d,h)=>{const l=h===x.length-1,r=!l;return e.jsxs("div",{className:"chain-of-command-item",children:[e.jsx("button",{type:"button",className:`chain-of-command-node${l?" chain-of-command-node--current":""}`,onClick:()=>r&&i?.(d.id),disabled:!r||!i,title:l?"Current agent":`View ${d.name}`,children:d.name}),!l&&e.jsx("span",{className:"chain-of-command-separator","aria-hidden":"true",children:"→"})]},d.id)})})]})]})}function pa({logs:s,isStreaming:n,hasTask:i,fallbackLabel:c}){return i?e.jsxs("div",{className:"logs-tab",children:[e.jsxs("div",{className:"logs-header",children:[e.jsxs("span",{className:"logs-count",children:[s.length," entries"]}),c&&e.jsx("span",{className:"text-muted logs-fallback-label",children:c}),n&&e.jsxs("span",{className:"streaming-indicator",children:[e.jsx("span",{className:"streaming-dot"}),"Live"]})]}),s.length===0?e.jsxs("div",{className:"logs-empty",children:[e.jsx(De,{size:48,opacity:.3}),e.jsx("p",{children:"No log entries yet"}),e.jsx("p",{className:"text-muted",children:n?"Waiting for activity...":"Logs will appear here when the agent is active"})]}):e.jsx(Qs,{entries:s,loading:!1})]}):e.jsx("div",{className:"logs-tab",children:e.jsxs("div",{className:"logs-empty",children:[e.jsx(De,{size:48,opacity:.3}),e.jsx("p",{children:"No activity yet"}),e.jsx("p",{className:"text-muted",children:"Agent logs will appear here from the current task or most recent run"})]})})}function ja({addToast:s,agentId:n,projectId:i,agentState:c,agentName:m,initialRunId:x,preferActiveRun:w}){const[f,S]=t.useState([]),{confirm:E}=_s(),[C,o]=t.useState(!0),[p,D]=t.useState(null),[z,M]=t.useState([]),[H,J]=t.useState(!1),[g,V]=t.useState(null),[Q,j]=t.useState(!1),A=t.useRef(!1),v=t.useCallback(async()=>{try{const r=await Is(n,50,i);S(r)}catch(r){s(`Failed to load runs: ${Y(r)}`,"error")}finally{o(!1)}},[n,i,s]);t.useEffect(()=>{v()},[v]);const T=f.some(r=>r.status==="active"),F=p?f.find(r=>r.id===p)?.status:void 0;t.useEffect(()=>{if(!T)return;const r=setInterval(()=>{v()},5e3);return()=>clearInterval(r)},[T,v]),t.useEffect(()=>{if(!p||F!=="active")return;const r=i?`?projectId=${encodeURIComponent(i)}`:"";return Ve(`/api/agents/${encodeURIComponent(n)}/runs/${encodeURIComponent(p)}/logs/stream${r}`,{events:{"agent:log":b=>{try{const L=JSON.parse(b.data);M(he=>[...he,L])}catch{}}}})},[p,F,n,i]);const K=t.useCallback(async r=>{if(p===r){D(null),M([]),V(null);return}D(r),J(!0),j(!0),M([]),V(null);try{const[b,L]=await Promise.all([Vs(n,r,i),Lt(n,r,i)]);M(b),V(L)}catch(b){s(`Failed to load run details: ${Y(b)}`,"error"),M([]),V(null)}finally{J(!1),j(!1)}},[p,n,i,s]);t.useEffect(()=>{A.current=!1},[n,x,w]),t.useEffect(()=>{if(f.length===0||C||A.current)return;const r=x?f.find(b=>b.id===x):w?f.find(b=>b.status==="active"):null;A.current=!0,r&&K(r.id)},[x,w,f,C,K]);const B=async()=>{try{await Gt(n,i,{source:"on_demand",triggerDetail:"Triggered from dashboard"}),s(`Heartbeat run started for ${m??n}`,"success"),o(!0),v()}catch(r){s(`Failed to start heartbeat run: ${Y(r)}`,"error")}},W=async()=>{if(await E({title:"Stop Active Run",message:"Stop the active run? The agent's work will be interrupted.",danger:!0}))try{await qt(n,i),s("Run stopped","success"),o(!0),v()}catch(b){s(`Failed to stop run: ${Y(b)}`,"error")}},G=c==="active"||c==="idle";if(C&&f.length===0)return e.jsx("div",{className:"runs-tab",children:e.jsxs("div",{className:"runs-loading-row",children:[e.jsx(I,{size:16,className:"animate-spin"}),e.jsx("span",{className:"text-muted",children:"Loading runs..."})]})});if(f.length===0)return e.jsxs("div",{className:"runs-tab",children:[G&&e.jsx("div",{className:"runs-toolbar",children:e.jsxs("button",{className:"btn btn--sm btn-task-create",onClick:()=>void B(),"aria-label":`Run now for ${m??n}`,children:[e.jsx(Ue,{size:14})," Run Now"]})}),e.jsxs("div",{className:"runs-empty",children:[e.jsx(Ue,{size:48,opacity:.3}),e.jsx("p",{children:"No runs yet"}),e.jsx("p",{className:"text-muted",children:"Heartbeat runs will appear here"})]})]});const k=[...f].sort((r,b)=>new Date(b.startedAt).getTime()-new Date(r.startedAt).getTime()),$=k.filter(r=>r.status==="active"),d=k.filter(r=>r.status!=="active"),h=r=>r?e.jsxs("div",{className:"run-usage",children:[e.jsxs("span",{children:["Input: ",r.inputTokens.toLocaleString()]}),e.jsxs("span",{children:["Output: ",r.outputTokens.toLocaleString()]}),r.cachedTokens>0&&e.jsxs("span",{children:["Cached: ",r.cachedTokens.toLocaleString()]})]}):null,l=(r,b,L)=>{const he=Ge[r.status]||Ge.completed,ce=he.icon,ue=r.endedAt?Na(new Date(r.startedAt),new Date(r.endedAt)):"In progress",N=p===r.id;return e.jsxs("div",{children:[e.jsxs("div",{className:te("run-card",L&&"run-card--active",N&&"run-card--selected","run-card--clickable"),onClick:()=>void K(r.id),role:"button",tabIndex:0,"aria-expanded":N,"aria-label":`${L?"Active":""} run ${r.id.slice(0,8)}, ${r.status}`,onKeyDown:U=>{(U.key==="Enter"||U.key===" ")&&(U.preventDefault(),K(r.id))},children:[e.jsxs("div",{className:"run-header",children:[e.jsxs("div",{className:"run-header-group",children:[N?e.jsx(Bs,{size:14}):e.jsx(Os,{size:14}),L?e.jsxs("span",{className:"run-live-indicator",children:[e.jsx("span",{className:"live-dot"}),"Live Run"]}):e.jsxs("span",{className:"run-id",children:["#",b+1," ",r.id.slice(0,8)]})]}),e.jsxs("div",{className:"run-header-group",children:[r.invocationSource&&e.jsx("span",{className:"badge run-badge--compact",children:r.invocationSource}),L&&e.jsxs("button",{className:"btn btn--sm btn--danger",onClick:U=>{U.preventDefault(),U.stopPropagation(),W()},"aria-label":"Stop active run",children:[e.jsx($e,{size:12})," Stop"]}),e.jsxs("span",{className:te("run-status",r.status),children:[e.jsx(ce,{size:14,style:{color:he.color}}),r.status]}),r.heartbeatProcedureSource==="custom"&&e.jsx("span",{className:"badge run-badge--compact",children:"Heartbeat: custom"})]})]}),e.jsxs("div",{className:"run-details",children:[e.jsxs("span",{children:["Started ",Me(r.startedAt)]}),e.jsx("span",{children:"•"}),e.jsx("span",{children:ue}),r.triggerDetail&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsx("span",{className:"text-muted",children:r.triggerDetail})]})]})]}),N&&e.jsxs("div",{className:"run-logs-container",children:[Q?e.jsxs("div",{className:"run-details-loading-state",children:[e.jsx(I,{size:14,className:"animate-spin"}),e.jsx("span",{className:"text-muted",children:"Loading details..."})]}):g&&e.jsxs("div",{className:"run-output-sections",children:[e.jsx("div",{className:"run-output-section",children:e.jsxs("details",{children:[e.jsx("summary",{className:"run-output-label run-output-summary",children:"System Prompt"}),g.systemPrompt?e.jsx("pre",{className:"run-output-panel",children:g.systemPrompt}):e.jsx("div",{className:"text-muted run-output-empty",children:"System prompt not captured for this run"})]})}),e.jsx("div",{className:"run-output-section",children:e.jsxs("details",{children:[e.jsx("summary",{className:"run-output-label run-output-summary",children:"Execution Prompt"}),g.executionPrompt?e.jsx("pre",{className:"run-output-panel",children:g.executionPrompt}):e.jsx("div",{className:"text-muted run-output-empty",children:"Execution prompt not captured for this run"})]})}),g.usageJson&&e.jsxs("div",{className:"run-output-section",children:[e.jsx("div",{className:"run-output-label",children:"Token Usage"}),h(g.usageJson)]}),g.stdoutExcerpt&&e.jsxs("div",{className:"run-output-section",children:[e.jsx("div",{className:"run-output-label",children:"Output"}),e.jsx("pre",{className:"run-output-panel",children:g.stdoutExcerpt.length>2e3?`${g.stdoutExcerpt.slice(0,2e3)}
17
+
18
+ ... (truncated, ${g.stdoutExcerpt.length} chars total)`:g.stdoutExcerpt})]}),g.stderrExcerpt&&e.jsxs("div",{className:"run-output-section",children:[e.jsx("div",{className:"run-output-label run-output-label--error",children:"Errors"}),e.jsx(Yt,{errorText:g.stderrExcerpt,summaryPrefix:"Run error",issueContext:{surface:"AgentDetailView runs",agentId:n,agentName:m,agentState:c,runId:g.id,taskId:void 0,timestamp:g.startedAt}})]}),g.resultJson&&e.jsxs("div",{className:"run-output-section",children:[e.jsx("div",{className:"run-output-label",children:"Result"}),e.jsx("pre",{className:"run-output-panel",children:JSON.stringify(g.resultJson,null,2)})]}),g.contextSnapshot&&Object.keys(g.contextSnapshot).length>0&&e.jsxs("div",{className:"run-output-section",children:[e.jsx("div",{className:"run-output-label",children:"Context"}),e.jsx("div",{className:"run-context-grid",children:Object.entries(g.contextSnapshot).map(([U,me])=>e.jsxs("span",{className:"run-context-item",children:[e.jsxs("span",{className:"text-muted",children:[U,":"]})," ",e.jsx("span",{children:String(me)})]},U))})]}),!g.stdoutExcerpt&&!g.stderrExcerpt&&!g.resultJson&&e.jsx("div",{className:"text-muted run-output-empty",children:"No output captured"})]}),e.jsxs("div",{className:"run-agent-logs-section",children:[e.jsx("div",{className:"run-output-label",children:"Agent Logs"}),H?e.jsxs("div",{className:"run-details-loading-state",children:[e.jsx(I,{size:14,className:"animate-spin"}),e.jsx("span",{className:"text-muted",children:"Loading logs..."})]}):z.length===0?e.jsx("div",{className:"text-muted run-output-empty",children:"No logs available for this run"}):e.jsx(Qs,{entries:z,loading:!1})]})]})]},r.id)};return e.jsxs("div",{className:"runs-tab",children:[G&&e.jsxs("div",{className:"runs-toolbar runs-toolbar--between",children:[e.jsxs("span",{className:"runs-toolbar-meta",children:[f.length," run",f.length!==1?"s":"",T&&e.jsxs("span",{className:"run-live-indicator run-live-indicator--with-margin",children:[e.jsx("span",{className:"live-dot"}),"Live"]})]}),e.jsxs("div",{className:"run-header-group",children:[T&&e.jsxs("button",{className:"btn btn--sm btn--danger",onClick:()=>void W(),"aria-label":`Stop active run for ${m??n}`,children:[e.jsx($e,{size:14})," Stop Run"]}),e.jsxs("button",{className:"btn btn--sm btn-task-create",onClick:()=>void B(),"aria-label":`Run now for ${m??n}`,children:[e.jsx(Ue,{size:14})," Run Now"]})]})]}),$.map((r,b)=>l(r,b,!0)),d.map((r,b)=>l(r,$.length+b,!1))]})}function Na(s,n){const i=Math.floor((n.getTime()-s.getTime())/1e3);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`}const ya={triage:"Triage",todo:"Todo","in-progress":"In Progress","in-review":"In Review",done:"Done",archived:"Archived"};function Sa(s){const n=s.title?.trim()||s.description?.trim()||s.id;return n.length>80?`${n.slice(0,77)}...`:n}function ka({agentId:s,projectId:n,addToast:i}){const[c,m]=t.useState([]),[x,w]=t.useState(!0);return t.useEffect(()=>{let f=!1;return w(!0),zt(s,n).then(S=>{f||m(S)}).catch(S=>{f||(m([]),i(`Failed to load assigned tasks: ${Y(S)}`,"error"))}).finally(()=>{f||w(!1)}),()=>{f=!0}},[s,n,i]),x?e.jsxs("div",{className:"agent-tasks-empty",children:[e.jsx(I,{size:16,className:"animate-spin"}),e.jsx("p",{children:"Loading assigned tasks..."})]}):c.length===0?e.jsxs("div",{className:"agent-tasks-empty",children:[e.jsx(Ws,{size:18}),e.jsx("p",{children:"No tasks assigned to this agent"})]}):e.jsx("div",{className:"agent-tasks-list",children:c.map(f=>e.jsxs("a",{className:"agent-task-item",href:`/tasks/${f.id}`,children:[e.jsxs("div",{className:"agent-task-row",children:[e.jsx("span",{className:"agent-task-id",children:f.id}),e.jsx("span",{className:`agent-task-column column-${f.column}`,children:ya[f.column]})]}),e.jsx("div",{className:"agent-task-title",title:f.title||f.description||f.id,children:Sa(f)}),e.jsxs("div",{className:"agent-task-status",children:[f.status??"idle"," · Updated ",Me(f.updatedAt)]})]},f.id))})}const Pe=[{key:"maxRetries",label:"Max Retries",type:"number",placeholder:"3",hint:"Maximum number of automatic retries on task failure (0–10, default 3)",min:0,max:10},{key:"timeoutMs",label:"Task Timeout (ms)",type:"number",placeholder:"600000",hint:"Maximum time in ms before a task is considered timed out (minimum 60000ms, default 600000ms)",min:6e4,max:864e5},{key:"logLevel",label:"Log Level",type:"select",hint:"Verbosity of agent log output",options:[{value:"debug",label:"Debug"},{value:"info",label:"Info"},{value:"warn",label:"Warning"},{value:"error",label:"Error"}]}];function Ca(s){const n={};for(const i of Pe){const c=s[i.key]?.trim();if(c){if(i.type==="number"){const m=Number(c);if(Number.isNaN(m)||!Number.isFinite(m)){n[i.key]=`"${i.label}" must be a valid number`;continue}i.min!==void 0&&m<i.min&&(n[i.key]=`"${i.label}" must be at least ${i.min.toLocaleString()}`),i.max!==void 0&&m>i.max&&(n[i.key]=`"${i.label}" must be at most ${i.max.toLocaleString()}`)}if(i.type==="select"){const m=i.options?.map(x=>x.value)??[];m.length>0&&!m.includes(c)&&(n[i.key]=`"${i.label}" must be one of: ${m.join(", ")}`)}}}return n}function Ra({agent:s,projectId:n,addToast:i,onSaved:c}){const[m,x]=t.useState(s.soul??""),[w,f]=t.useState(!1),[S,E]=t.useState(!1),[C,o]=t.useState(!1),p=t.useRef(null);t.useEffect(()=>{x(s.soul??""),E(!1),o(!1)},[s.id,s.soul]),t.useEffect(()=>()=>{p.current&&clearTimeout(p.current)},[]);const D=m!==(s.soul??""),z=async()=>{if(m.length>1e4){i("Soul must be at most 10,000 characters","error");return}f(!0);try{await Kt(s.id,m,n),i("Soul saved","success"),E(!0),p.current&&clearTimeout(p.current),p.current=setTimeout(()=>E(!1),3e3),await c()}catch(M){i(`Failed to save soul: ${Y(M)}`,"error")}finally{f(!1)}};return e.jsx("div",{className:"config-tab",children:e.jsxs("div",{className:"config-section",children:[e.jsx("h3",{children:"Soul"}),e.jsx("p",{className:"config-description",children:"Define this agent's personality and identity."}),e.jsx("div",{className:"config-fields",children:e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"agent-soul",children:"Agent Soul"}),e.jsx("div",{className:"agent-content-toolbar",children:e.jsxs("div",{className:"agent-content-mode-toggle",children:[e.jsxs("button",{className:`btn btn-sm ${C?"":"btn-primary"}`,onClick:()=>o(!1),disabled:!C,"aria-label":"Edit mode",children:[e.jsx(qe,{size:14}),"Edit"]}),e.jsxs("button",{className:`btn btn-sm ${C?"btn-primary":""}`,onClick:()=>o(!0),disabled:C,"aria-label":"Preview mode",children:[e.jsx(Ye,{size:14}),"Preview"]})]})}),C?m.trim()?e.jsx("div",{className:"agent-content-preview markdown-body",children:e.jsx(Ke,{remarkPlugins:[Ze],children:m})}):e.jsx("div",{className:"agent-content-preview agent-content-placeholder",children:"No soul defined yet. Switch to Edit mode to define the agent's personality."}):e.jsx("textarea",{id:"agent-soul",className:"input config-textarea-mono",rows:12,placeholder:"Describe this agent's personality, tone, and behavioral traits...",value:m,onChange:M=>{x(M.target.value),E(!1)}}),!C&&e.jsx("span",{className:"config-hint",children:"Defines the agent's character and identity. Max 10,000 characters."})]})}),!C&&e.jsxs("div",{className:"config-actions",children:[e.jsx("button",{className:"btn btn-task-create",disabled:!D||w,onClick:()=>void z(),children:w?e.jsxs(e.Fragment,{children:[e.jsx(I,{size:16,className:"animate-spin"}),"Saving…"]}):e.jsxs(e.Fragment,{children:[e.jsx(ne,{size:16}),"Save Soul"]})}),!D&&S&&e.jsxs("span",{className:"config-saved-indicator",children:[e.jsx(ne,{size:14}),"Soul saved"]})]})]})})}function wa({agent:s,projectId:n,addToast:i,onSaved:c}){const[m,x]=t.useState(s.memory??""),[w,f]=t.useState(!1),[S,E]=t.useState(!1),[C,o]=t.useState(!1),[p,D]=t.useState([]),[z,M]=t.useState(!1),[H,J]=t.useState(""),[g,V]=t.useState(""),[Q,j]=t.useState(!1),[A,v]=t.useState(!1),[T,F]=t.useState(!1),[K,B]=t.useState(!1),[W,G]=t.useState(""),k=t.useRef(null),$=t.useRef(null),d=s.state==="running",h=m!==(s.memory??""),l=t.useMemo(()=>p.find(N=>N.path===H),[p,H]),r=l?fa[l.layer]:"Select a memory file to view or edit.",b=t.useCallback(async N=>{v(!0);try{const U=await Bt(s.id,N,n);J(U.path),V(U.content),j(!1),B(!1)}catch(U){i(`Failed to load agent memory file: ${Y(U)}`,"error")}finally{v(!1)}},[s.id,n,i]),L=t.useCallback(async(N="")=>{M(!0);try{const{files:U}=await Ot(s.id,n);if(D(U),U.length===0){J(""),V(""),j(!1);return}const me=ba(U,N);await b(me)}catch(U){i(`Failed to load memory files: ${Y(U)}`,"error"),D([]),J(""),V(""),j(!1)}finally{M(!1)}},[s.id,n,i,b]);t.useEffect(()=>{x(s.memory??""),E(!1),o(!1),G(""),B(!1),L()},[s.id,s.memory,L]),t.useEffect(()=>()=>{k.current&&clearTimeout(k.current),$.current&&clearTimeout($.current)},[]);const he=async()=>{if(m.length>5e4){i("Memory must be at most 50,000 characters","error");return}f(!0);try{await Qt(s.id,m,n),i("Memory saved","success"),E(!0),k.current&&clearTimeout(k.current),k.current=setTimeout(()=>E(!1),3e3),await c()}catch(N){i(`Failed to save memory: ${Y(N)}`,"error")}finally{f(!1)}},ce=async N=>{if(!(!N||N===H)){if(Q){G("Save the current file before switching to another file.");return}G(""),await b(N)}},ue=async()=>{if(H){F(!0);try{await Xt(s.id,H,g,n),j(!1),B(!0),$.current&&clearTimeout($.current),$.current=setTimeout(()=>B(!1),3e3),G(""),await L(H),i("Agent memory file saved","success"),await c()}catch(N){i(`Failed to save agent memory file: ${Y(N)}`,"error")}finally{F(!1)}}};return e.jsx("div",{className:"config-tab",children:e.jsxs("div",{className:"config-section",children:[e.jsx("h3",{children:"Agent Memory"}),e.jsx("p",{className:"config-description",children:"Store context that belongs to this agent only. Workspace memory, daily notes, dreams, and qmd search live in project settings under Project Memory."}),d&&e.jsx("p",{className:"config-hint config-hint--block-spacing",children:"Read-only while this agent is running."}),e.jsxs("div",{className:"config-fields",children:[e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"agent-memory",children:"Inline Memory"}),e.jsx("span",{className:"config-hint config-hint--block",children:"Short-form memory stored directly on the agent record and injected into prompts."}),e.jsx("div",{className:"agent-content-toolbar",children:e.jsxs("div",{className:"agent-content-mode-toggle",children:[!d&&e.jsxs("button",{className:`btn btn-sm ${C?"":"btn-primary"}`,onClick:()=>o(!1),disabled:!C,"aria-label":"Edit mode",children:[e.jsx(qe,{size:14}),"Edit"]}),e.jsxs("button",{className:`btn btn-sm ${C?"btn-primary":""}`,onClick:()=>o(!0),disabled:C,"aria-label":"Preview mode",children:[e.jsx(Ye,{size:14}),"Preview"]})]})}),C?m.trim()?e.jsx("div",{className:"agent-content-preview markdown-body",children:e.jsx(Ke,{remarkPlugins:[Ze],children:m})}):e.jsx("div",{className:"agent-content-preview agent-content-placeholder",children:"No agent memory defined yet. Switch to Edit mode to add memory content."}):e.jsx("textarea",{id:"agent-memory","aria-label":"Agent Memory",className:"input config-textarea-mono",rows:10,placeholder:"Durable preferences, operating habits, and context this agent should carry across tasks...",value:m,readOnly:d,onChange:N=>{x(N.target.value),E(!1)}}),!C&&e.jsx("span",{className:"config-hint",children:"This is the inline memory field on the agent JSON record. Max 50,000 characters."})]}),e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"agent-memory-file-select",children:"Memory Files"}),e.jsxs("span",{className:"config-hint config-hint--block",children:["Full OpenClaw memory files at ",e.jsxs("code",{children:["agent/",s.name||s.id,"/memory/"]})," (MEMORY.md, DREAMS.md, and daily notes)."]}),e.jsx("select",{id:"agent-memory-file-select",className:"select",value:H,disabled:z||A||T||p.length===0,onChange:N=>{ce(N.target.value)},children:p.length===0?e.jsx("option",{value:"",children:"No memory files found"}):p.map(N=>e.jsxs("option",{value:N.path,children:[Ds[N.layer]," • ",N.label]},N.path))}),z&&e.jsxs("span",{className:"config-hint config-hint--inline-loader",children:[e.jsx(I,{size:14,className:"animate-spin"}),"Loading memory files…"]}),l&&e.jsxs("div",{className:"config-hint config-hint--top-spacing",children:[e.jsx("strong",{children:Ds[l.layer]})," · ",r,e.jsx("br",{}),l.size.toLocaleString()," bytes · Updated ",Me(l.updatedAt)]}),e.jsx("textarea",{className:"input config-textarea-mono config-textarea-top-spacing",rows:14,placeholder:"Select a memory file to view and edit its content...",value:g,readOnly:d||!H||A,onChange:N=>{V(N.target.value),j(!0),B(!1),G("")}}),A&&e.jsxs("span",{className:"config-hint config-hint--inline-loader",children:[e.jsx(I,{size:14,className:"animate-spin"}),"Loading file content…"]}),W&&e.jsx("span",{className:"config-hint config-hint--top-spacing config-hint--block",children:W})]})]}),e.jsxs("div",{className:"config-actions",children:[!C&&e.jsx("button",{className:"btn btn-task-create",disabled:!h||w||d,onClick:()=>void he(),children:w?e.jsxs(e.Fragment,{children:[e.jsx(I,{size:16,className:"animate-spin"}),"Saving…"]}):e.jsxs(e.Fragment,{children:[e.jsx(ne,{size:16}),"Save Memory"]})}),e.jsx("button",{className:"btn",disabled:!Q||T||!H||d,onClick:()=>void ue(),children:T?e.jsxs(e.Fragment,{children:[e.jsx(I,{size:16,className:"animate-spin"}),"Saving file…"]}):e.jsxs(e.Fragment,{children:[e.jsx(ne,{size:16}),"Save Memory File"]})}),!h&&S&&e.jsxs("span",{className:"config-saved-indicator",children:[e.jsx(ne,{size:14}),"Memory saved"]}),!Q&&K&&e.jsxs("span",{className:"config-saved-indicator",children:[e.jsx(ne,{size:14}),"Memory file saved"]})]})]})})}function Ma({agent:s,projectId:n,addToast:i,onSaved:c}){const[m,x]=t.useState(s.instructionsText??""),[w,f]=t.useState(s.instructionsPath??""),[S,E]=t.useState(!1),[C,o]=t.useState(""),[p,D]=t.useState(!1),[z,M]=t.useState(!1),[H,J]=t.useState(!1),[g,V]=t.useState(!1),[Q,j]=t.useState(!1),[A,v]=t.useState(!1),T=t.useRef(null),F=t.useRef(null);t.useEffect(()=>{const k=w.trim();if(!k){o(""),M(!1);return}D(!0),Xs("project",k).then($=>{o($.content),M(!1)}).catch($=>{const d=Y($);d.includes("ENOENT")||d.includes("Not found")||d.includes("not found")?(o(""),M(!1)):(i(`Failed to load instructions file: ${d}`,"error"),o(""))}).finally(()=>{D(!1)})},[w,i]),t.useEffect(()=>{x(s.instructionsText??""),f(s.instructionsPath??""),j(!1),v(!1),E(!1)},[s.id,s.instructionsText,s.instructionsPath]),t.useEffect(()=>()=>{T.current&&clearTimeout(T.current),F.current&&clearTimeout(F.current)},[]);const K=(()=>{const k=m??"",$=s.instructionsText??"",d=w?.trim()??"",h=s.instructionsPath?.trim()??"";return k!==$||d!==h})(),B=async()=>{J(!0);try{await Zt(s.id,{instructionsText:m||void 0,instructionsPath:w.trim()||void 0},n),i("Instructions saved","success"),j(!0),T.current&&clearTimeout(T.current),T.current=setTimeout(()=>j(!1),3e3),await c()}catch(k){i(`Failed to save instructions: ${Y(k)}`,"error")}finally{J(!1)}},W=async()=>{const k=w.trim();if(!k){i("No instructions file path set","error");return}V(!0);try{await et("project",k,C),i("Instructions file saved","success"),M(!1),v(!0),F.current&&clearTimeout(F.current),F.current=setTimeout(()=>v(!1),3e3),await c()}catch($){i(`Failed to save instructions file: ${Y($)}`,"error")}finally{V(!1)}},G=!!w.trim();return e.jsxs("div",{className:"config-tab",children:[e.jsxs("div",{className:"config-section",children:[e.jsx("h3",{children:"Custom Instructions"}),e.jsx("p",{className:"config-description",children:"Append custom instructions to this agent's system prompt at execution time. Use this to customize behavior, coding style, or project conventions without modifying built-in prompts."}),e.jsxs("div",{className:"config-fields",children:[e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"instructions-text",children:"Inline Instructions"}),e.jsx("div",{className:"agent-content-toolbar",children:e.jsxs("div",{className:"agent-content-mode-toggle",children:[e.jsxs("button",{className:`btn btn-sm ${S?"":"btn-primary"}`,onClick:()=>E(!1),disabled:!S,"aria-label":"Edit mode","data-testid":"instructions-edit-toggle",children:[e.jsx(qe,{size:14}),"Edit"]}),e.jsxs("button",{className:`btn btn-sm ${S?"btn-primary":""}`,onClick:()=>E(!0),disabled:S,"aria-label":"Preview mode","data-testid":"instructions-preview-toggle",children:[e.jsx(Ye,{size:14}),"Preview"]})]})}),S?m.trim()?e.jsx("div",{className:"agent-content-preview markdown-body",children:e.jsx(Ke,{remarkPlugins:[Ze],children:m})}):e.jsx("div",{className:"agent-content-preview agent-content-placeholder",children:"No inline instructions defined yet. Switch to Edit mode to add instructions."}):e.jsx("textarea",{id:"instructions-text",className:"input",rows:10,placeholder:"Enter custom instructions to append to this agent's system prompt...",value:m,onChange:k=>{x(k.target.value),j(!1)}}),!S&&e.jsx("span",{className:"config-hint",children:"Markdown formatting supported. Max 50,000 characters."})]}),e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"instructions-path",children:"Instructions File Path"}),e.jsx("input",{id:"instructions-path",type:"text",className:"input",placeholder:"e.g., .fusion/agents/my-agent-instructions.md",value:w,onChange:k=>{f(k.target.value),j(!1)}}),e.jsx("span",{className:"config-hint",children:"Path to a .md file (relative to project root). Contents are read and appended at execution time."})]})]}),!S&&e.jsxs("div",{className:"config-actions",children:[e.jsx("button",{className:"btn btn-task-create",disabled:!K||H,onClick:()=>void B(),children:H?e.jsxs(e.Fragment,{children:[e.jsx(I,{size:16,className:"animate-spin"}),"Saving…"]}):e.jsxs(e.Fragment,{children:[e.jsx(ne,{size:16}),"Save Instructions"]})}),!K&&Q&&e.jsxs("span",{className:"config-saved-indicator",children:[e.jsx(ne,{size:14}),"Instructions saved"]})]})]}),G&&e.jsxs("div",{className:"config-section",children:[e.jsx("h3",{children:"Instructions File Editor"}),e.jsx("p",{className:"config-description",children:"Edit the instructions file directly. Changes are saved separately from the path configuration."}),e.jsx("div",{className:"config-fields",children:e.jsxs("div",{className:"config-field",children:[e.jsxs("div",{className:"config-inline-header",children:[e.jsx("label",{htmlFor:"instructions-file-content",children:"File Content"}),p&&e.jsxs("span",{className:"config-hint config-hint--inline-tight",children:[e.jsx(I,{size:12,className:"animate-spin"}),"Loading..."]}),z&&!p&&e.jsx("span",{className:"config-hint config-hint--warning",children:"Unsaved changes"})]}),e.jsx("textarea",{id:"instructions-file-content",className:"input config-textarea-mono",rows:20,placeholder:"File content will appear here when loaded...",value:C,readOnly:p,onChange:k=>{o(k.target.value),M(!0),v(!1)}}),e.jsx("span",{className:"config-hint",children:"Edit the markdown file content directly. Save separately using the button below."})]})}),e.jsxs("div",{className:"config-actions",children:[e.jsx("button",{className:"btn btn-task-create",disabled:!z||g,onClick:()=>void W(),children:g?e.jsxs(e.Fragment,{children:[e.jsx(I,{size:16,className:"animate-spin"}),"Saving…"]}):e.jsxs(e.Fragment,{children:[e.jsx(ne,{size:16}),"Save File"]})}),!z&&A&&e.jsxs("span",{className:"config-saved-indicator",children:[e.jsx(ne,{size:14}),"File saved"]})]})]})]})}function Ls(s){const n=s??{},i={};return n.heartbeatIntervalMs!==void 0&&n.heartbeatIntervalMs!==null&&(i.heartbeatIntervalMs=String(Number(n.heartbeatIntervalMs)/1e3)),n.heartbeatTimeoutMs!==void 0&&n.heartbeatTimeoutMs!==null&&(i.heartbeatTimeoutMs=String(Number(n.heartbeatTimeoutMs)/1e3)),n.maxConcurrentRuns!==void 0&&n.maxConcurrentRuns!==null&&(i.maxConcurrentRuns=String(n.maxConcurrentRuns)),(n.messageResponseMode==="immediate"||n.messageResponseMode==="on-heartbeat")&&(i.messageResponseMode=n.messageResponseMode),i}function rs(s){return s?.enabled!==!1}function ls(s){return s?.autoClaimRelevantTasks!==!1}function cs(s){return s?.runMissedHeartbeatOnStartup===!0}function zs(s){return s?.allowParallelExecution!==!1}function Hs(s){const n=(s??{}).budgetConfig,i={};return n&&(n.tokenBudget!==void 0&&n.tokenBudget!==null&&(i.tokenBudget=String(n.tokenBudget)),n.usageThreshold!==void 0&&n.usageThreshold!==null&&(i.usageThreshold=String(Number(n.usageThreshold)*100)),n.budgetPeriod!==void 0&&n.budgetPeriod!==null&&(i.budgetPeriod=String(n.budgetPeriod)),n.resetDay!==void 0&&n.resetDay!==null&&(i.resetDay=String(n.resetDay))),i}function Fa({agent:s,projectId:n,addToast:i,onSaved:c}){const[m,x]=t.useState(!1),[w,f]=t.useState(!1),[S,E]=t.useState(!1),[C,o]=t.useState(!1),[p,D]=t.useState(!1),[z,M]=t.useState(""),[H,J]=t.useState(!1),[g,V]=t.useState(null),[Q,j]=t.useState(!1),A=t.useRef(null),v=s.heartbeatProcedurePath?.trim(),T=`.fusion/agents/${s.name.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||s.id.toLowerCase().replace(/[^a-z0-9]+/g,"-")||"agent"}-${s.id.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"agent"}/HEARTBEAT.md`,F=`.fusion/agents/${s.id}/HEARTBEAT.md`,K=s.id.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"agent",B=!!(v&&(v===T||v===F||new RegExp(`^\\.fusion/agents/[^/]+-${K}/HEARTBEAT\\.md$`).test(v))),W=!!v,G=t.useCallback(async h=>{E(!0),V(null);try{const l=await Xs("project",h,n);M(l.content),J(!1)}catch(l){const r=Y(l);V(r),i(`Failed to load heartbeat procedure file: ${r}`,"error")}finally{E(!1)}},[i,n]);t.useEffect(()=>{f(!1),D(!1),M(""),J(!1),V(null),E(!1),o(!1),j(!1)},[s.id,v]),t.useEffect(()=>()=>{A.current&&clearTimeout(A.current)},[]);const k=async()=>{v&&(f(!0),await G(v))},$=async()=>{if(v){o(!0);try{await et("project",v,z,n),J(!1),j(!0),i("Heartbeat procedure file saved","success"),A.current&&clearTimeout(A.current),A.current=setTimeout(()=>j(!1),3e3),await c()}catch(h){i(`Failed to save heartbeat procedure file: ${Y(h)}`,"error")}finally{o(!1)}}},d=async()=>{x(!0);try{const h=await sa(s.id,n);i(h.procedureFileSeeded?`Heartbeat procedure file ready at ${h.heartbeatProcedurePath}`:`Heartbeat procedure path set to ${h.heartbeatProcedurePath}`,"success"),await c()}catch(h){i(`Failed to upgrade heartbeat procedure: ${Y(h)}`,"error")}finally{x(!1)}};return e.jsxs("div",{className:"config-section",children:[e.jsx("h3",{children:"Heartbeat Procedure"}),e.jsxs("p",{className:"config-description",children:["The per-tick procedure this agent runs every wake. Defaults to a per-agent markdown file (for example ",e.jsx("code",{children:".fusion/agents/ceo-agent2736/HEARTBEAT.md"}),") that you can edit. Legacy id-only default paths remain valid. Resets on every tick — no need to restart the agent after editing."]}),e.jsxs("div",{className:"config-fields",children:[e.jsxs("div",{className:"config-field",children:[e.jsxs("span",{className:"config-hint",children:["Current path: ",e.jsx("code",{children:v||"(none — using built-in default)"})]}),W&&e.jsx("div",{className:"heartbeat-procedure-actions",children:e.jsx("button",{className:"btn btn-sm",onClick:()=>void k(),disabled:S,children:S?e.jsxs(e.Fragment,{children:[e.jsx(I,{size:16,className:"animate-spin"}),"Loading file…"]}):e.jsxs(e.Fragment,{children:[e.jsx(De,{size:16}),"View Heartbeat Markdown"]})})})]}),e.jsxs("div",{className:"config-field",children:[e.jsx("button",{className:"btn",disabled:m||B,onClick:()=>void d(),"aria-label":"Upgrade agent to default heartbeat procedure file",children:m?e.jsxs(e.Fragment,{children:[e.jsx(I,{size:16,className:"animate-spin"}),"Upgrading…"]}):B?e.jsxs(e.Fragment,{children:[e.jsx(ne,{size:16}),"Already on default"]}):"Upgrade to Default Heartbeat Procedure"}),e.jsxs("span",{className:"config-hint",children:["Sets ",e.jsx("code",{children:"heartbeatProcedurePath"})," to"," ",e.jsx("code",{children:T})," ","and seeds the file from the built-in template if it doesn't exist. Each agent gets its own per-agent file, so edits stay scoped to this agent. Operator edits to the file are preserved."]})]})]}),w&&W&&v&&e.jsxs("div",{className:"config-fields heartbeat-procedure-viewer",children:[e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"heartbeat-procedure-file-content",children:"Heartbeat Procedure File"}),e.jsxs("div",{className:"agent-content-toolbar",children:[e.jsxs("div",{className:"agent-content-mode-toggle",children:[e.jsxs("button",{className:`btn btn-sm ${p?"":"btn-primary"}`,onClick:()=>D(!1),disabled:!p,"aria-label":"Heartbeat file edit mode",children:[e.jsx(qe,{size:14}),"Edit"]}),e.jsxs("button",{className:`btn btn-sm ${p?"btn-primary":""}`,onClick:()=>D(!0),disabled:p,"aria-label":"Heartbeat file preview mode",children:[e.jsx(Ye,{size:14}),"Preview"]})]}),S&&e.jsxs("span",{className:"config-hint heartbeat-procedure-status",children:[e.jsx(I,{size:12,className:"animate-spin"}),"Loading..."]}),H&&!S&&e.jsx("span",{className:"config-hint heartbeat-procedure-status heartbeat-procedure-status--warning",children:"Unsaved changes"})]}),p?z.trim()?e.jsx("div",{className:"agent-content-preview markdown-body",children:e.jsx(Ke,{remarkPlugins:[Ze],children:z})}):e.jsx("div",{className:"agent-content-preview agent-content-placeholder",children:"No heartbeat procedure markdown content yet."}):e.jsx("textarea",{id:"heartbeat-procedure-file-content",className:"input",rows:16,value:z,readOnly:S,placeholder:"Heartbeat procedure markdown file content will appear here...",onChange:h=>{M(h.target.value),J(!0),j(!1)}}),g&&e.jsxs("span",{className:"config-error",children:["Failed to load file: ",g]}),e.jsxs("span",{className:"config-hint",children:["This editor writes directly to ",e.jsx("code",{children:v}),"."]})]}),!p&&e.jsxs("div",{className:"config-actions",children:[e.jsx("button",{className:"btn btn-task-create",disabled:!H||C||S,onClick:()=>void $(),children:C?e.jsxs(e.Fragment,{children:[e.jsx(I,{size:16,className:"animate-spin"}),"Saving…"]}):e.jsxs(e.Fragment,{children:[e.jsx(ne,{size:16}),"Save Heartbeat File"]})}),!H&&Q&&e.jsxs("span",{className:"config-saved-indicator",children:[e.jsx(ne,{size:14}),"File saved"]})]})]})]})}function Aa({agent:s,projectId:n,addToast:i,onSaved:c,onHasChangesChange:m,onDelete:x}){const[w,f]=t.useState(s.name),[S,E]=t.useState(s.role),[C,o]=t.useState(s.title??""),[p,D]=t.useState(s.icon??""),[z,M]=t.useState(s.reportsTo??""),[H,J]=t.useState([]),[g,V]=t.useState(!1),[Q,j]=t.useState(!1),A=t.useRef(null),[v,T]=t.useState(()=>{const a={};for(const u of Pe){const R=s.metadata[u.key];R!=null&&(a[u.key]=String(R))}return a}),[F,K]=t.useState(()=>Ls(s.runtimeConfig)),[B,W]=t.useState(()=>rs(s.runtimeConfig)),[G,k]=t.useState(()=>ls(s.runtimeConfig)),[$,d]=t.useState(()=>cs(s.runtimeConfig)),[h,l]=t.useState(()=>zs(s.runtimeConfig)),[r,b]=t.useState(()=>Hs(s.runtimeConfig)),[L,he]=t.useState(s.bundleConfig?.mode??""),[ce,ue]=t.useState(s.bundleConfig?.entryFile??"AGENTS.md"),[N,U]=t.useState(s.bundleConfig?.externalPath??""),[me,Le]=t.useState(s.bundleConfig?.files??[]),[be,ve]=t.useState(Array.isArray(s.metadata?.skills)?s.metadata.skills:[]),[Qe,y]=t.useState([]),[X,ee]=t.useState(!1),[Z,oe]=t.useState([]),[ie,pe]=t.useState([]),[Re,fs]=t.useState([]),[tt,gs]=t.useState(!1),ze=(()=>{const a=s.runtimeConfig??{};return a.modelProvider&&a.modelId?`${a.modelProvider}/${a.modelId}`:typeof a.model=="string"&&a.model.includes("/")?a.model:""})(),ke=typeof s.runtimeConfig?.runtimeHint=="string"?s.runtimeConfig.runtimeHint:"",[fe,Xe]=t.useState(ke?"runtime":"model"),[je,xs]=t.useState(ze),[Fe,es]=t.useState(ke),He=z.trim(),bs=t.useMemo(()=>H.filter(a=>a.id!==s.id),[H,s.id]),at=!!He&&!bs.some(a=>a.id===He);t.useEffect(()=>{let a=!1;return V(!0),_t(void 0,n).then(u=>{a||J(u)}).catch(()=>{a||J([])}).finally(()=>{a||V(!1)}),()=>{a=!0}},[n]),t.useEffect(()=>{ee(!0),It().then(a=>{y(a.models),oe(a.favoriteProviders),pe(a.favoriteModels)}).catch(()=>{}).finally(()=>ee(!1))},[]);const nt=t.useCallback(async a=>{const u=Z,_=u.includes(a)?u.filter(ae=>ae!==a):[a,...u];oe(_);try{await Es({favoriteProviders:_,favoriteModels:ie})}catch{oe(u)}},[Z,ie]),it=t.useCallback(async a=>{const u=ie,_=u.includes(a)?u.filter(ae=>ae!==a):[a,...u];pe(_);try{await Es({favoriteProviders:Z,favoriteModels:_})}catch{pe(u)}},[Z,ie]);t.useEffect(()=>{gs(!0),Ks(n).then(fs).catch(()=>fs([])).finally(()=>gs(!1))},[n]);const[Ne,ss]=t.useState(null),[vs,ps]=t.useState(!1);t.useEffect(()=>{os(s.id,n).then(ss).catch(()=>ss(null))},[s.id,n]);const rt=async()=>{ps(!0);try{await ea(s.id,n),i("Budget usage reset successfully","success");const a=await os(s.id,n);ss(a)}catch(a){i(`Failed to reset budget: ${Y(a)}`,"error")}finally{ps(!1)}},[ye,js]=t.useState(!1),[O,Ce]=t.useState({}),[lt,we]=t.useState(!1),[ts,Be]=t.useState(null),Ns=s.state==="idle"||s.state==="paused",Ae=t.useRef(null),ys=t.useRef(null),Ss=t.useRef(null),Oe=t.useRef(0);t.useEffect(()=>()=>{Ae.current&&clearTimeout(Ae.current)},[]);const de=(()=>{if(w!==s.name||S!==s.role||C!==(s.title??"")||p!==(s.icon??"")||z!==(s.reportsTo??"")||L!==(s.bundleConfig?.mode??"")||ce!==(s.bundleConfig?.entryFile??"AGENTS.md")||N!==(s.bundleConfig?.externalPath??"")||JSON.stringify(me)!==JSON.stringify(s.bundleConfig?.files??[]))return!0;for(const q of Pe){const le=v[q.key]?.trim()??"",P=s.metadata[q.key]!==void 0&&s.metadata[q.key]!==null?String(s.metadata[q.key]):"";if(le!==P)return!0}const a=s.runtimeConfig??{};if(B!==rs(s.runtimeConfig)||G!==ls(s.runtimeConfig)||$!==cs(s.runtimeConfig)||h!==zs(s.runtimeConfig))return!0;for(const q of["heartbeatIntervalMs","heartbeatTimeoutMs","maxConcurrentRuns","messageResponseMode"]){const le=F[q]?.trim()??"";let P=a[q]!==void 0&&a[q]!==null?String(a[q]):"";if((q==="heartbeatIntervalMs"||q==="heartbeatTimeoutMs")&&P&&(P=String(Number(P)/1e3)),le!==P)return!0}const u=a.budgetConfig;for(const q of["tokenBudget","budgetPeriod","resetDay"]){const le=r[q]?.trim()??"",P=u?.[q]!==void 0&&u?.[q]!==null?String(u[q]):"";if(le!==P)return!0}const R=r.usageThreshold?.trim()??"",_=u?.usageThreshold!==void 0&&u?.usageThreshold!==null?String(Number(u.usageThreshold)*100):"";if(R!==_)return!0;const ae=Array.isArray(s.metadata?.skills)?s.metadata.skills:[];return JSON.stringify(be)!==JSON.stringify(ae)||fe!==(ke?"runtime":"model")||je!==ze||Fe!==ke})(),ks=t.useRef(null);t.useEffect(()=>{m&&ks.current!==de&&(ks.current=de,m(de))},[de,m]),t.useEffect(()=>()=>{m?.(!1)},[m]),t.useEffect(()=>{const a={id:s.id,updatedAt:s.updatedAt},u=ys.current;(!u||u.id!==a.id||u.updatedAt!==a.updatedAt)&&(de||(ys.current=a,K(Ls(s.runtimeConfig)),W(rs(s.runtimeConfig)),k(ls(s.runtimeConfig)),d(cs(s.runtimeConfig)),b(Hs(s.runtimeConfig)),xs(ze),es(ke),Xe(ke?"runtime":"model")))},[s,de,ze,ke]);const Cs=(a,u)=>{T(R=>({...R,[a]:u})),we(!1),O[a]&&Ce(R=>{const _={...R};return delete _[a],_})},_e=(a,u)=>{K(R=>({...R,[a]:u})),we(!1),O[a]&&Ce(R=>{const _={...R};return delete _[a],_})},ct=a=>{W(a),we(!1)},Ie=(a,u)=>{b(R=>({...R,[a]:u})),we(!1),O[a]&&Ce(R=>{const _={...R};return delete _[a],_})},ge=t.useMemo(()=>{const a=Ca(v);for(const[P,Se]of Object.entries({heartbeatIntervalMs:{label:"Heartbeat Interval",min:1},heartbeatTimeoutMs:{label:"Heartbeat Timeout",min:5},maxConcurrentRuns:{label:"Max Concurrent Runs",min:1}})){const se=F[P]?.trim();if(!se)continue;const xe=Number(se);Number.isNaN(xe)||!Number.isFinite(xe)?a[P]=`"${Se.label}" must be a valid number`:xe<Se.min&&(a[P]=`"${Se.label}" must be at least ${Se.min.toLocaleString()}`)}const u=F.messageResponseMode?.trim();u&&!["immediate","on-heartbeat"].includes(u)&&(a.messageResponseMode='"Message Response Mode" must be either immediate or on-heartbeat');const R=r.tokenBudget?.trim();if(R){const P=Number(R);Number.isNaN(P)||!Number.isFinite(P)?a.tokenBudget='"Token Budget" must be a valid number':P<=0&&(a.tokenBudget='"Token Budget" must be greater than 0')}const _=r.usageThreshold?.trim();if(_){const P=Number(_);Number.isNaN(P)||!Number.isFinite(P)?a.usageThreshold='"Usage Threshold" must be a valid number':(P<1||P>100)&&(a.usageThreshold='"Usage Threshold" must be between 1 and 100')}const ae=r.budgetPeriod?.trim();ae&&!["daily","weekly","monthly","lifetime"].includes(ae)&&(a.budgetPeriod='"Budget Period" must be one of: daily, weekly, monthly, lifetime');const q=r.resetDay?.trim(),le=ae||"lifetime";if(q){const P=Number(q);Number.isNaN(P)||!Number.isFinite(P)?a.resetDay='"Reset Day" must be a valid number':le==="weekly"?(P<0||P>6||!Number.isInteger(P))&&(a.resetDay='"Reset Day" must be between 0 (Sunday) and 6 (Saturday) for weekly period'):le==="monthly"&&(P<1||P>31||!Number.isInteger(P))&&(a.resetDay='"Reset Day" must be between 1 and 31 for monthly period')}return a},[v,F,r]),Rs=t.useCallback(()=>{if(Object.keys(ge).length>0)return null;const a={...s.metadata};for(const se of Pe){const xe=v[se.key]?.trim();xe?se.type==="number"?a[se.key]=Number(xe):a[se.key]=xe:delete a[se.key]}be.length>0?a.skills=be:delete a.skills;const u={...s.runtimeConfig};u.enabled=B,u.autoClaimRelevantTasks=G,u.runMissedHeartbeatOnStartup=$,u.allowParallelExecution=h;for(const se of["heartbeatIntervalMs","heartbeatTimeoutMs","maxConcurrentRuns"]){const xe=F[se]?.trim();if(!xe)delete u[se];else{const Ms=Number(xe);u[se]=se==="maxConcurrentRuns"?Ms:Ms*1e3}}const R=F.messageResponseMode?.trim();if(R?u.messageResponseMode=R:delete u.messageResponseMode,fe==="runtime")Fe.trim()?u.runtimeHint=Fe.trim():delete u.runtimeHint,delete u.modelProvider,delete u.modelId,delete u.model;else if(delete u.runtimeHint,je.trim()){const se=je.indexOf("/");se!==-1&&(u.modelProvider=je.slice(0,se),u.modelId=je.slice(se+1),u.model=je.trim())}else delete u.modelProvider,delete u.modelId,delete u.model;const _={},ae=r.tokenBudget?.trim(),q=r.usageThreshold?.trim(),le=r.budgetPeriod?.trim(),P=r.resetDay?.trim();ae&&(_.tokenBudget=Number(ae)),q&&(_.usageThreshold=Number(q)/100),le&&(_.budgetPeriod=le),P&&(_.resetDay=Number(P)),Object.keys(_).length>0?u.budgetConfig=_:delete u.budgetConfig;let Se;return L&&(Se={mode:L,entryFile:ce||"AGENTS.md",files:me.length>0?me:["AGENTS.md"]},L==="external"&&N.trim()&&(Se.externalPath=N.trim())),{name:w.trim()||void 0,role:S,title:C.trim()||void 0,icon:p.trim()||void 0,reportsTo:z.trim()||void 0,metadata:a,runtimeConfig:u,bundleConfig:Se}},[s.metadata,s.runtimeConfig,h,G,r,ce,N,me,L,v,B,F,p,je,w,z,S,$,fe,Fe,be,C,ge]),Ee=t.useCallback(async(a,u)=>{const R=Rs();if(!R)return Ce(ge),a&&i("Please fix validation errors before saving","error"),u==="auto"&&Be("Fix validation errors to save changes"),!1;const _=JSON.stringify(R);if(_===Ss.current)return!1;const ae=++Oe.current;Ce({}),Be(null),js(!0);try{return await Vt(s.id,R,n),ae!==Oe.current?!1:(Ss.current=_,u==="manual"&&i("Settings saved","success"),Be(null),we(!0),Ae.current&&clearTimeout(Ae.current),Ae.current=setTimeout(()=>we(!1),3e3),await c(),!0)}catch(q){if(ae===Oe.current){const le=Y(q);Be(le),i(`Failed to save settings: ${le}`,"error")}return!1}finally{ae===Oe.current&&js(!1)}},[i,s.id,Rs,c,n,ge]),ot=async()=>{await Ee(!0,"manual")},re=t.useCallback(()=>{if(!(!de||ye)){if(Object.keys(ge).length>0){Ce(ge);return}Ee(!1,"auto")}},[de,ye,Ee,ge]);t.useEffect(()=>{if(!de||ye)return;if(Object.keys(ge).length>0){Ce(ge);return}const a=setTimeout(()=>{Ee(!1,"auto")},xa);return()=>clearTimeout(a)},[de,ye,Ee,ge]);const dt=t.useCallback(async a=>{j(!0);try{await Ut(s.id,a,n),await c(),i("Avatar uploaded","success")}catch(u){i(Y(u),"error")}finally{j(!1),A.current&&(A.current.value="")}},[i,s.id,c,n]),ut=t.useCallback(async()=>{j(!0);try{await Jt(s.id,n),await c(),i("Avatar removed","success")}catch(a){i(Y(a),"error")}finally{j(!1)}},[i,s.id,c,n]),ws=ye?"Saving changes…":ts?`Save failed: ${ts}`:!de&&lt?"All changes saved":null;return e.jsxs("div",{className:"config-tab",children:[e.jsxs("div",{className:"config-section",children:[e.jsx("h3",{children:"Agent Configuration"}),e.jsx("p",{className:"config-description",children:"Configure agent settings and behavior."}),e.jsxs("div",{className:"config-fields",children:[e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"agent-name",children:"Name"}),e.jsx("input",{id:"agent-name",type:"text",className:"input",value:w,onChange:a=>f(a.target.value),onBlur:()=>{re()}})]}),e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"agent-role",children:"Role"}),e.jsxs("select",{id:"agent-role",className:"select",value:S,onChange:a=>{E(a.target.value),re()},children:[e.jsx("option",{value:"triage",children:"Triage"}),e.jsx("option",{value:"executor",children:"Executor"}),e.jsx("option",{value:"reviewer",children:"Reviewer"}),e.jsx("option",{value:"merger",children:"Merger"}),e.jsx("option",{value:"scheduler",children:"Scheduler"}),e.jsx("option",{value:"custom",children:"Custom"})]})]}),e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"agent-title",children:"Title"}),e.jsx("input",{id:"agent-title",type:"text",className:"input",placeholder:"e.g. Senior Code Reviewer",value:C,onChange:a=>o(a.target.value),onBlur:()=>{re()}})]}),e.jsxs("div",{className:"config-field",children:[e.jsx("label",{children:"Avatar"}),e.jsxs("div",{className:"agent-avatar-editor",children:[e.jsx(Us,{agent:s,size:64,className:"agent-avatar-editor-preview"}),e.jsxs("div",{className:"agent-avatar-editor-actions",children:[e.jsx("input",{ref:A,id:"agent-avatar-upload",type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",className:"visually-hidden",disabled:Q,onChange:a=>{const u=a.target.files?.[0];u&&dt(u)}}),e.jsx("button",{type:"button",className:"btn btn-sm",disabled:Q,onClick:()=>A.current?.click(),children:"Upload Avatar"}),s.imageUrl?e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>void ut(),disabled:Q,children:"Remove Avatar"}):null]})]})]}),e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"agent-icon",children:"Icon"}),e.jsx("input",{id:"agent-icon",type:"text",className:"input",placeholder:"e.g. 🤖",value:p,onChange:a=>D(a.target.value),onBlur:()=>{re()}})]}),e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"agent-reports-to",children:"Reports To"}),e.jsxs("select",{id:"agent-reports-to",className:"select",value:z,onChange:a=>{M(a.target.value),re()},disabled:g,children:[e.jsx("option",{value:"",children:"No manager"}),at&&e.jsxs("option",{value:He,children:["Unknown manager (",He,")"]}),bs.map(a=>e.jsxs("option",{value:a.id,children:[a.name," (",a.id,")"]},a.id))]})]})]})]}),e.jsxs("div",{className:"config-section",children:[e.jsx("h3",{children:"Skills"}),e.jsx("p",{className:"config-description",children:"Assign skills to this agent for specialized behavior."}),e.jsx("div",{className:"config-fields",children:e.jsx("div",{className:"config-field",children:e.jsx(ta,{id:"agent-skills",label:"Skills",value:be,onChange:a=>{ve(a),re()},projectId:n})})})]}),e.jsxs("div",{className:"config-section",children:[e.jsx("h3",{children:"Model"}),e.jsx("p",{className:"config-description",children:"Choose either a built-in model or a plugin runtime for this agent. These options are mutually exclusive."}),e.jsxs("div",{className:"config-fields",children:[e.jsxs("div",{className:"config-field",children:[e.jsx("label",{children:"Runtime Source"}),e.jsxs("div",{className:"config-runtime-tabs",role:"tablist","aria-label":"Runtime source",children:[e.jsx("button",{type:"button",className:`config-runtime-tab${fe==="model"?" active":""}`,role:"tab","aria-selected":fe==="model",tabIndex:fe==="model"?0:-1,onClick:()=>{Xe("model"),es(""),re()},children:"Built-in Model"}),e.jsx("button",{type:"button",className:`config-runtime-tab${fe==="runtime"?" active":""}`,role:"tab","aria-selected":fe==="runtime",tabIndex:fe==="runtime"?0:-1,onClick:()=>{Xe("runtime"),re()},children:"Plugin Runtime"})]})]}),fe==="model"?e.jsx("div",{className:"config-field",children:e.jsx(Wt,{models:Qe,value:je,onChange:a=>{xs(a),re()},placeholder:"Use global default",label:"Agent Model",disabled:X,favoriteProviders:Z,onToggleFavorite:nt,favoriteModels:ie,onToggleModelFavorite:it})}):e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"agent-runtime-hint",children:"Runtime"}),tt?e.jsx("span",{className:"config-hint",children:"Loading runtimes…"}):e.jsxs("select",{id:"agent-runtime-hint",className:"select",value:Fe,onChange:a=>{es(a.target.value),re()},children:[e.jsx("option",{value:"",children:Re.length>0?"Select a plugin runtime…":"No plugin runtimes available"}),Re.map(a=>e.jsx("option",{value:a.runtimeId,children:a.description?`${a.name} — ${a.description}`:a.name},`${a.pluginId}:${a.runtimeId}`))]})]})]})]}),e.jsxs("div",{className:"config-section",children:[e.jsx("h3",{children:"Heartbeat Settings"}),e.jsx("p",{className:"config-description",children:"Configure how this agent's heartbeat is monitored. Leave a field empty to use system defaults."}),e.jsxs("div",{className:"config-fields",children:[e.jsxs("div",{className:"config-field",children:[e.jsxs("label",{className:"checkbox-label",htmlFor:"hb-enabled",children:[e.jsx("input",{id:"hb-enabled",type:"checkbox",checked:B,onChange:a=>{ct(a.target.checked),re()}}),"Heartbeat Enabled"]}),e.jsx("span",{className:"config-hint",children:"When enabled, this agent receives scheduled heartbeat runs based on its interval."})]}),e.jsxs("div",{className:"config-field",children:[e.jsxs("label",{className:"checkbox-label",htmlFor:"hb-autoClaimRelevantTasks",children:[e.jsx("input",{id:"hb-autoClaimRelevantTasks",type:"checkbox",checked:G,onChange:a=>{k(a.target.checked),re()}}),"Auto-Claim Relevant Tasks"]}),e.jsx("span",{className:"config-hint",children:"When enabled (default), no-task heartbeats scan open unowned work and auto-claim tasks aligned with this agent's role and soul."})]}),e.jsxs("div",{className:"config-field",children:[e.jsxs("label",{className:"checkbox-label",htmlFor:"hb-runMissedHeartbeatOnStartup",children:[e.jsx("input",{id:"hb-runMissedHeartbeatOnStartup",type:"checkbox",checked:$,onChange:a=>{d(a.target.checked),re()}}),"Run Missed Heartbeat On Startup"]}),e.jsx("span",{className:"config-hint",children:"When enabled, if the server was down across this agent's scheduled heartbeat tick, fire a single catch-up heartbeat at startup. Default: off."})]}),e.jsxs("div",{className:"config-field",children:[e.jsxs("label",{className:"checkbox-label",htmlFor:"hb-allowParallelExecution",children:[e.jsx("input",{id:"hb-allowParallelExecution",type:"checkbox",checked:h,onChange:a=>{l(a.target.checked),re()}}),"Allow Parallel Execution"]}),e.jsx("span",{className:"config-hint",children:"When disabled, the heartbeat and task execution paths serialize for this agent (heartbeat will not start while the agent's task is executing, and vice versa). Permanent agents only."})]}),e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"hb-heartbeatIntervalMs",children:"Heartbeat Interval (s)"}),e.jsx("input",{id:"hb-heartbeatIntervalMs",type:"text",inputMode:"numeric",className:te("input",!!O.heartbeatIntervalMs&&"input--error"),placeholder:String(ds/1e3),value:F.heartbeatIntervalMs??"",onChange:a=>_e("heartbeatIntervalMs",a.target.value)}),O.heartbeatIntervalMs?e.jsx("span",{className:"config-error",children:O.heartbeatIntervalMs}):e.jsxs("span",{className:"config-hint",children:["How often heartbeats are checked. Leave empty for system default (",ds/1e3,"s / ",ga,")."]})]}),e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"hb-heartbeatTimeoutMs",children:"Heartbeat Timeout (s)"}),e.jsx("input",{id:"hb-heartbeatTimeoutMs",type:"text",inputMode:"numeric",className:te("input",!!O.heartbeatTimeoutMs&&"input--error"),placeholder:"60",value:F.heartbeatTimeoutMs??"",onChange:a=>_e("heartbeatTimeoutMs",a.target.value)}),O.heartbeatTimeoutMs?e.jsx("span",{className:"config-error",children:O.heartbeatTimeoutMs}):e.jsx("span",{className:"config-hint",children:"Time without heartbeat before agent is considered unresponsive. Leave empty for system default (60s)"})]}),e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"hb-maxConcurrentRuns",children:"Max Concurrent Runs"}),e.jsx("input",{id:"hb-maxConcurrentRuns",type:"text",inputMode:"numeric",className:te("input",!!O.maxConcurrentRuns&&"input--error"),placeholder:"1",value:F.maxConcurrentRuns??"",onChange:a=>_e("maxConcurrentRuns",a.target.value)}),O.maxConcurrentRuns?e.jsx("span",{className:"config-error",children:O.maxConcurrentRuns}):e.jsx("span",{className:"config-hint",children:"Maximum simultaneous heartbeat runs for this agent. Leave empty for system default (1)."})]}),e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"hb-messageResponseMode",children:"Message Response Mode"}),e.jsxs("select",{id:"hb-messageResponseMode",className:te("select",!!O.messageResponseMode&&"input--error"),value:F.messageResponseMode??"",onChange:a=>_e("messageResponseMode",a.target.value),children:[e.jsx("option",{value:"",children:"System Default (On Heartbeat)"}),e.jsx("option",{value:"on-heartbeat",children:"On Heartbeat"}),e.jsx("option",{value:"immediate",children:"Immediate"})]}),O.messageResponseMode?e.jsx("span",{className:"config-error",children:O.messageResponseMode}):e.jsx("span",{className:"config-hint",children:"How this agent responds to incoming messages. 'Immediate' wakes the agent as soon as a message arrives. 'On Heartbeat' defers processing to the next scheduled heartbeat."})]})]})]}),e.jsxs("div",{className:"config-section",children:[e.jsx("h3",{children:"Budget Settings"}),e.jsx("p",{className:"config-description",children:"Configure token budget limits for this agent. Leave all fields empty to disable budget tracking."}),e.jsxs("div",{className:"config-fields",children:[e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"budget-tokenBudget",children:"Token Budget"}),e.jsx("input",{id:"budget-tokenBudget",type:"text",inputMode:"numeric",className:te("input",!!O.tokenBudget&&"input--error"),placeholder:"No limit",value:r.tokenBudget??"",onChange:a=>Ie("tokenBudget",a.target.value)}),O.tokenBudget?e.jsx("span",{className:"config-error",children:O.tokenBudget}):e.jsx("span",{className:"config-hint",children:"Total token cap (input + output) for this agent. Leave empty for no limit."})]}),e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"budget-usageThreshold",children:"Usage Threshold (%)"}),e.jsx("input",{id:"budget-usageThreshold",type:"text",inputMode:"numeric",className:te("input",!!O.usageThreshold&&"input--error"),placeholder:"80",value:r.usageThreshold??"",onChange:a=>Ie("usageThreshold",a.target.value)}),O.usageThreshold?e.jsx("span",{className:"config-error",children:O.usageThreshold}):e.jsx("span",{className:"config-hint",children:"Warning threshold as a percentage. Agent warns when usage reaches this level. Default: 80%."})]}),e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"budget-budgetPeriod",children:"Budget Period"}),e.jsxs("select",{id:"budget-budgetPeriod",className:te("select",!!O.budgetPeriod&&"input--error"),value:r.budgetPeriod??"",onChange:a=>Ie("budgetPeriod",a.target.value),children:[e.jsx("option",{value:"",children:"No reset (lifetime)"}),e.jsx("option",{value:"daily",children:"Daily"}),e.jsx("option",{value:"weekly",children:"Weekly"}),e.jsx("option",{value:"monthly",children:"Monthly"})]}),O.budgetPeriod?e.jsx("span",{className:"config-error",children:O.budgetPeriod}):e.jsx("span",{className:"config-hint",children:"How often the budget counter resets. Leave empty for lifetime budget."})]}),e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"budget-resetDay",children:"Reset Day"}),e.jsx("input",{id:"budget-resetDay",type:"text",inputMode:"numeric",className:te("input",!!O.resetDay&&"input--error"),placeholder:"Auto",value:r.resetDay??"",onChange:a=>Ie("resetDay",a.target.value)}),O.resetDay?e.jsx("span",{className:"config-error",children:O.resetDay}):e.jsx("span",{className:"config-hint",children:r.budgetPeriod==="weekly"?"Day of week (0=Sunday to 6=Saturday) for reset.":r.budgetPeriod==="monthly"?"Day of month (1-31) for reset.":"Day for reset (weekly: 0-6, monthly: 1-31). Leave empty for automatic."})]}),Ne?.budgetLimit!=null&&e.jsxs("div",{className:"config-field",children:[e.jsx("label",{children:"Current Usage"}),e.jsxs("div",{className:"budget-progress-container",children:[e.jsx("div",{className:"budget-progress-bar",children:e.jsx("div",{className:te("budget-progress-bar__fill",(Ne.usagePercent??0)>=100?"budget-progress-bar__fill--red":(Ne.usagePercent??0)>=80?"budget-progress-bar__fill--amber":"budget-progress-bar__fill--green"),style:{width:`${Math.min(Ne.usagePercent??0,100)}%`}})}),e.jsxs("span",{className:"budget-progress-label",children:[(Ne.currentUsage??0).toLocaleString()," / ",(Ne.budgetLimit??0).toLocaleString()," tokens (",Math.round(Ne.usagePercent??0),"% used)"]})]})]}),Ne?.budgetLimit!=null&&e.jsx("div",{className:"config-field",children:e.jsx("button",{className:"btn btn-reset-budget",onClick:()=>void rt(),disabled:vs,children:vs?e.jsxs(e.Fragment,{children:[e.jsx(I,{size:14,className:"animate-spin"}),"Resetting…"]}):e.jsxs(e.Fragment,{children:[e.jsx(ms,{size:14}),"Reset Budget Usage"]})})})]})]}),e.jsxs("div",{className:"config-section",children:[e.jsx("h3",{children:"Instruction Bundle"}),e.jsx("p",{className:"config-description",children:"Configure the agent's instruction bundle. Leave empty to use inline instructions only."}),e.jsxs("div",{className:"config-fields",children:[e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"bundle-mode",children:"Bundle Mode"}),e.jsxs("select",{id:"bundle-mode",className:"select",value:L,onChange:a=>he(a.target.value),children:[e.jsx("option",{value:"",children:"None (use inline instructions)"}),e.jsx("option",{value:"managed",children:"Managed (system-managed directory)"}),e.jsx("option",{value:"external",children:"External (user-specified path)"})]}),e.jsxs("span",{className:"config-hint",children:[L==="managed"&&"Files will be stored in a system-managed directory within .fusion/agents/",L==="external"&&"Specify an external directory path for the instruction files",!L&&"Select a mode to enable instruction bundling"]})]}),L&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"bundle-entry-file",children:"Entry File"}),e.jsx("input",{id:"bundle-entry-file",type:"text",className:"input",placeholder:"AGENTS.md",value:ce,onChange:a=>ue(a.target.value)}),e.jsx("span",{className:"config-hint",children:"Primary instructions file name (default: AGENTS.md)"})]}),L==="external"&&e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"bundle-external-path",children:"External Path"}),e.jsx("input",{id:"bundle-external-path",type:"text",className:"input",placeholder:"e.g. .fusion/agents/my-agent",value:N,onChange:a=>U(a.target.value)}),e.jsx("span",{className:"config-hint",children:"Absolute or relative path to the external directory"})]}),e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"bundle-files",children:"Files (comma-separated)"}),e.jsx("input",{id:"bundle-files",type:"text",className:"input",placeholder:"AGENTS.md, PROMPTS.md",value:me.join(", "),onChange:a=>Le(a.target.value.split(",").map(u=>u.trim()).filter(Boolean))}),e.jsx("span",{className:"config-hint",children:"List of file names in the bundle directory"})]})]})]})]}),e.jsxs("div",{className:"config-section",children:[e.jsx("h3",{children:"Advanced Settings"}),e.jsx("p",{className:"config-description",children:"Advanced configuration options for this agent. Leave a field empty to use system defaults."}),e.jsx("div",{className:"config-fields",children:Pe.map(a=>{const u=!!O[a.key];return e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:`adv-${a.key}`,children:a.label}),a.type==="select"?e.jsxs("select",{id:`adv-${a.key}`,className:te("select",u&&"input--error"),value:v[a.key]??"",onChange:R=>Cs(a.key,R.target.value),children:[e.jsx("option",{value:"",children:"System Default"}),a.options?.map(R=>e.jsx("option",{value:R.value,children:R.label},R.value))]}):e.jsx("input",{id:`adv-${a.key}`,type:"text",inputMode:a.type==="number"?"numeric":void 0,className:te("input",u&&"input--error"),placeholder:a.placeholder,value:v[a.key]??"",onChange:R=>Cs(a.key,R.target.value)}),u&&e.jsx("span",{className:"config-error",children:O[a.key]}),!u&&a.hint&&e.jsx("span",{className:"config-hint",children:a.hint})]},a.key)})}),e.jsxs("div",{className:"config-actions",children:[e.jsx("button",{className:"btn btn-task-create",disabled:!de||ye,onClick:()=>void ot(),children:ye?e.jsxs(e.Fragment,{children:[e.jsx(I,{size:16,className:"animate-spin"}),"Saving…"]}):e.jsxs(e.Fragment,{children:[e.jsx(ne,{size:16}),"Save Settings"]})}),ws&&e.jsxs("span",{className:te("config-saved-indicator",ts&&"config-saved-indicator--error"),children:[ye?e.jsx(I,{size:14,className:"animate-spin"}):e.jsx(ne,{size:14}),ws]})]})]}),e.jsx(Fa,{agent:s,projectId:n,addToast:i,onSaved:c}),e.jsxs("div",{className:"config-section config-section--danger",children:[e.jsx("h3",{children:"Danger Zone"}),e.jsx("p",{className:"config-description",children:"Permanently delete this agent from the project."}),e.jsx("div",{className:"config-fields",children:e.jsxs("div",{className:"config-field",children:[e.jsxs("button",{className:"btn btn--danger",disabled:!Ns||!x,onClick:()=>void x?.(),children:[e.jsx(We,{size:16}),"Delete Agent"]}),e.jsx("span",{className:"config-danger-note",children:Ns?"Deletion is permanent and cannot be undone.":`Agent deletion is only available when state is idle or paused (current state: ${s.state}).`})]})})]})]})}function Ea({agentId:s,projectId:n,onChildClick:i}){const[c,m]=t.useState([]),[x,w]=t.useState(!0);return t.useEffect(()=>{w(!0),Ht(s,n).then(m).finally(()=>w(!1))},[s,n]),x?e.jsxs("div",{className:"detail-section",children:[e.jsx("div",{className:"detail-section-header",children:e.jsx("h3",{children:"Employees"})}),e.jsxs("div",{className:"detail-section-body detail-section-body--loading",children:[e.jsx(I,{size:16,className:"spin"}),e.jsx("span",{className:"text-muted",children:"Loading employees..."})]})]}):e.jsxs("div",{className:"detail-section",children:[e.jsxs("div",{className:"detail-section-header",children:[e.jsx("h3",{children:"Employees"}),e.jsxs("span",{className:"text-muted",children:["(",c.length,")"]})]}),e.jsx("div",{className:"detail-section-body",children:c.length===0?e.jsxs("div",{className:"agent-empty agent-empty--padded",children:[e.jsx(Gs,{size:32,opacity:.3}),e.jsx("p",{children:"No employees"}),e.jsx("p",{className:"text-muted",children:"This agent has no employees"})]}):e.jsx("div",{className:"agent-tree__children",children:c.map(f=>{const S=hs[f.state];return e.jsxs("div",{className:"agent-tree__node agent-is-child",onClick:()=>i?.(f.id),role:"button",tabIndex:0,onKeyDown:E=>{(E.key==="Enter"||E.key===" ")&&(E.key===" "&&E.preventDefault(),i?.(f.id))},style:{cursor:i?"pointer":"default"},children:[e.jsx("span",{className:"agent-tree__icon",children:f.icon??"🤖"}),e.jsx("span",{className:"agent-tree__name",children:f.name}),e.jsx("span",{className:"agent-tree__badge",style:{background:S?.bg??"var(--state-idle-bg)",color:S?.text??"var(--state-idle-text)",border:`1px solid ${S?.border??"var(--state-idle-border)"}`},children:f.state})]},f.id)})})})]})}export{za as AgentDetailView,Me as relativeTime};
@@ -0,0 +1 @@
1
+ .agent-detail-overlay{position:fixed;inset:0;background:color-mix(in srgb,var(--bg) 60%,transparent);backdrop-filter:blur(4px);display:flex;align-items:center;justify-content:center;z-index:100;padding:var(--space-lg)}.agent-detail-modal{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-lg);width:100%;min-width:calc(var(--space-xl) * 20);max-width:calc(100vw - var(--space-2xl) - var(--space-xs) * 2);min-height:calc(var(--space-xl) * 13 + var(--space-sm));max-height:calc(100dvh - var(--space-2xl) - var(--space-xs) * 2);display:flex;flex-direction:column;overflow:hidden;resize:both;box-shadow:var(--shadow-lg)}.agent-detail-modal:not([style*=width]){width:min(calc(var(--space-xl) * 37 + var(--space-md)),calc(100vw - var(--space-2xl) - var(--space-xs) * 2))}.agent-detail-modal:not([style*=height]){height:min(85vh,calc(100dvh - var(--space-2xl) - var(--space-xs) * 2))}.agent-detail-inline-shell{width:100%;height:100%;min-height:0;display:flex;flex-direction:column;overflow:hidden}.agent-detail-inline{width:100%;height:100%;min-height:0;display:flex;flex-direction:column;overflow:hidden;background:var(--surface);border:1px solid var(--border)}.agent-detail-inline-loading{width:100%;height:100%;min-height:0;display:flex;align-items:center;justify-content:center;overflow:hidden}.agent-detail-loading{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:var(--space-md);padding:calc(var(--space-xl) * 2 + var(--space-md));color:var(--text-muted)}.agent-detail-header{display:flex;align-items:center;justify-content:space-between;gap:var(--space-md);padding:var(--space-md) calc(var(--space-lg) + var(--space-xs));border-bottom:1px solid var(--border);background:var(--bg-secondary)}.agent-detail-identity{display:flex;align-items:center;gap:var(--space-md);flex-shrink:0;min-width:0}.agent-detail-inline-back{display:inline-flex;align-items:center;gap:var(--space-xs);min-height:calc(var(--space-lg) + var(--space-md) + var(--space-xs));padding:calc(var(--space-sm) - var(--space-xs) * .5) calc(var(--space-sm) + var(--space-xs) * .5);flex-shrink:0}.agent-detail-icon{width:calc(var(--space-lg) * 2 + var(--space-xs));height:calc(var(--space-lg) * 2 + var(--space-xs));display:flex;align-items:center;justify-content:center;color:var(--text);flex-shrink:0}.agent-detail-info{min-width:0}.agent-detail-info h2{font-size:calc(var(--space-md) + var(--space-xs));font-weight:600;margin:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.agent-detail-badges{display:flex;gap:var(--space-xs);margin-top:calc(var(--space-xs) * .5)}.agent-detail-header-actions{display:flex;align-items:center;justify-content:flex-end;gap:var(--space-sm);flex:1 1 auto;min-width:0}.agent-detail-controls{display:flex;align-items:center;gap:calc(var(--space-xs) + var(--space-sm) * .25);flex-shrink:0}.btn--compact{padding:calc(var(--space-xs) + var(--space-xs) * .25) calc(var(--space-sm) + var(--space-xs) * .5);font-size:var(--space-md);gap:var(--space-xs)}.agent-detail-utility-actions{display:flex;align-items:center;gap:var(--space-xs);flex-shrink:0}.agent-detail-import-btn{min-height:calc(var(--space-lg) + var(--space-md) + var(--space-xs))}.agent-detail-title{display:flex;align-items:center;gap:var(--space-lg)}.agent-detail-actions{display:flex;align-items:center;gap:var(--space-sm)}.agent-detail-tabs{display:flex;gap:var(--space-xs);padding:0 calc(var(--space-lg) + var(--space-xs));border-bottom:1px solid var(--border);background:var(--bg-secondary)}.agent-detail-tab{display:flex;align-items:center;gap:var(--space-xs);padding:calc(var(--space-sm) + var(--space-xs) * .5) var(--space-md);background:none;border:none;border-bottom:calc(var(--space-xs) * .5) solid transparent;color:var(--text-muted);font-size:calc(var(--space-sm) + var(--space-xs) + var(--space-xs) * .25);cursor:pointer;transition:all var(--transition-fast)}.agent-detail-tab:hover{color:var(--text);background:var(--card-hover)}.agent-detail-tab.active{color:var(--todo);border-bottom-color:var(--todo)}.agent-detail-tab:focus-visible{outline:none;box-shadow:var(--focus-ring-strong);background:color-mix(in srgb,var(--todo) 12%,transparent);color:var(--text);border-radius:var(--radius-sm)}.agent-detail-content{flex:1;overflow-y:auto;padding:var(--space-xl)}.agent-detail-footer{display:flex;align-items:center;gap:var(--space-sm);padding:var(--space-md) var(--space-xl);border-top:1px solid var(--border);background:var(--bg-secondary);font-size:var(--space-md);color:var(--text-muted)}.agent-detail-id{font-family:var(--font-mono);cursor:pointer}.agent-detail-id:hover{color:var(--text)}.dashboard-tab{display:flex;flex-direction:column;gap:var(--space-xl)}.dashboard-summary-layout{padding-bottom:var(--space-md)}.dashboard-summary-health-reason{margin-left:var(--space-xs);font-size:calc(var(--space-sm) + var(--space-xs))}.dashboard-summary-card{background:var(--card);border:1px solid var(--border);border-radius:var(--radius-lg);padding:var(--space-lg);display:flex;flex-direction:column;gap:var(--space-md)}.budget-warning-banner{display:flex;gap:var(--space-sm);align-items:flex-start;border:1px solid var(--color-warning);background:color-mix(in srgb,var(--color-warning) 12%,transparent);border-radius:var(--radius-md);padding:var(--space-md)}.dashboard-summary-hero__heading{display:flex;align-items:center;gap:var(--space-sm)}.dashboard-summary-hero__heading h3{margin:0;font-size:calc(var(--space-lg) + var(--space-xs) * .5);font-weight:600}.dashboard-summary-hero__meta{display:flex;flex-wrap:wrap;gap:var(--space-md);color:var(--text-muted)}.dashboard-summary-skills{display:inline-flex;align-items:center;gap:var(--space-sm)}.dashboard-summary-skill-badges{display:inline-flex;flex-wrap:wrap;gap:var(--space-xs)}.dashboard-summary-skill-badge{max-width:calc(var(--space-xl) * 8);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dashboard-summary-skill-badge-btn{cursor:pointer}.dashboard-summary-skill-badge-btn:focus-visible{outline:none;box-shadow:var(--focus-ring-strong)}.dashboard-summary-skill-badge--selected{border-color:var(--todo);background:color-mix(in srgb,var(--todo) 20%,transparent)}.dashboard-summary-skill-detail{margin-top:var(--space-sm);border:1px solid var(--border);border-radius:var(--radius-md);background:var(--surface);padding:var(--space-md);display:flex;flex-direction:column;gap:var(--space-sm)}.dashboard-summary-skill-detail-header{display:flex;align-items:center;justify-content:space-between;gap:var(--space-sm)}.dashboard-summary-skill-detail-title{font-weight:600;color:var(--text)}.dashboard-summary-skill-detail-loading,.dashboard-summary-skill-detail-empty{display:inline-flex;align-items:center;gap:var(--space-xs);color:var(--text-muted)}.dashboard-summary-skill-detail-error{display:flex;align-items:center;flex-wrap:wrap;gap:var(--space-xs);color:var(--color-error)}.dashboard-summary-skill-detail-content{margin:0;padding:var(--space-sm);border-radius:var(--radius-sm);border:1px solid var(--border);background:var(--card);color:var(--text);white-space:pre-wrap;word-break:break-word;max-height:calc(var(--space-2xl) * 6);overflow:auto}.dashboard-summary-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(calc(var(--space-xl) * 6 + var(--space-sm)),1fr));gap:var(--space-md)}.dashboard-summary-grid p{margin:0}.dashboard-summary-label{font-size:calc(var(--space-sm) + var(--space-xs) * .5);color:var(--text-muted)}.dashboard-summary-health-row{display:inline-flex;align-items:center;gap:var(--space-xs)}.dashboard-summary-health-reason{margin-left:var(--space-xs);font-size:var(--space-md)}.runs-list{display:flex;flex-direction:column;gap:var(--space-sm)}.run-item{display:grid;grid-template-columns:auto 1fr auto;align-items:center;gap:var(--space-sm)}.dashboard-section{background:var(--bg-secondary);border-radius:var(--radius-md);padding:calc(var(--space-lg) + var(--space-xs))}.dashboard-section h3{font-size:calc(var(--space-md) + var(--space-xs) * .5);font-weight:600;margin:0 0 var(--space-lg) 0;color:var(--text-muted);text-transform:uppercase;letter-spacing:calc(var(--space-xs) * .125)}.info-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(calc(var(--space-xl) * 7 + var(--space-sm)),1fr));gap:var(--space-lg)}.info-item{display:flex;flex-direction:column;gap:var(--space-xs)}.info-label{font-size:var(--space-md);color:var(--text-muted)}.info-value{font-size:calc(var(--space-md) + var(--space-xs) * .5);font-weight:500}.inline-badge{display:inline-block;padding:calc(var(--space-xs) * .5) var(--space-sm);border-radius:var(--radius-sm);font-size:var(--space-md);text-transform:capitalize}.stats-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:var(--space-lg)}.stat-card{background:var(--surface);border-radius:var(--radius-md);padding:var(--space-lg);text-align:center}.stat-value{font-size:calc(var(--space-lg) + var(--space-xs) * .5);font-weight:700;color:var(--todo)}.stat-label{font-size:calc(var(--space-sm) + var(--space-xs) * .5);color:var(--text-muted);margin-top:var(--space-xs)}.current-task{display:flex;align-items:center;gap:var(--space-md)}.task-badge{font-family:var(--font-mono);background:var(--surface);padding:var(--space-sm) var(--space-md);border-radius:var(--radius-sm);font-size:calc(var(--space-md) + var(--space-xs) * .25)}.metadata-json{background:var(--surface);padding:var(--space-md);border-radius:var(--radius-sm);font-size:var(--space-md);overflow-x:auto;margin:0}.logs-tab{display:flex;flex-direction:column;height:100%}.logs-header{display:flex;align-items:center;justify-content:space-between;padding-bottom:var(--space-md);margin-bottom:var(--space-md);border-bottom:1px solid var(--border)}.logs-count{font-size:var(--space-md);color:var(--text-muted)}.streaming-indicator{display:flex;align-items:center;gap:calc(var(--space-xs) + var(--space-sm) * .25);font-size:var(--space-md);color:var(--color-success)}.streaming-dot{width:var(--space-sm);height:var(--space-sm);background:var(--color-success);border-radius:50%;animation:pulse 1.5s infinite}.logs-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:calc(var(--space-2xl) + var(--space-lg));color:var(--text-muted);text-align:center}.logs-empty p{margin:var(--space-sm) 0 0 0}.runs-tab{display:flex;flex-direction:column;gap:var(--space-md)}.runs-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:calc(var(--space-2xl) + var(--space-lg));color:var(--text-muted);text-align:center}.runs-empty p{margin:var(--space-sm) 0 0 0}.run-card{background:var(--bg-secondary);border:1px solid var(--border);border-radius:var(--radius-md);padding:var(--space-lg)}.run-card--active{border-color:var(--in-progress);background:color-mix(in srgb,var(--in-progress) 5%,transparent)}.run-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:var(--space-sm)}.run-live-indicator{display:flex;align-items:center;gap:calc(var(--space-xs) + var(--space-sm) * .25);font-weight:600;color:var(--in-progress)}.live-dot{width:var(--space-sm);height:var(--space-sm);background:var(--in-progress);border-radius:50%;animation:pulse 1.5s infinite}.run-id{font-family:var(--font-mono);font-size:calc(var(--space-md) + var(--space-xs) * .25);color:var(--text-muted)}.run-status{display:flex;align-items:center;gap:calc(var(--space-xs) + var(--space-sm) * .25);font-size:calc(var(--space-md) + var(--space-xs) * .25);text-transform:capitalize}.run-status.active{color:var(--in-progress)}.run-status.completed{color:var(--color-success)}.run-status.failed{color:var(--color-error)}.run-status.terminated{color:var(--text-muted)}.run-details{display:flex;gap:var(--space-sm);font-size:var(--space-md);color:var(--text-muted)}.run-logs-container{padding:var(--space-md);background:var(--bg-secondary);border-top:1px solid var(--border);border-bottom:1px solid var(--border)}.run-details-loading-state{display:flex;align-items:center;gap:var(--space-sm);padding:var(--space-sm) 0}.run-output-sections{margin-bottom:var(--space-md)}.run-output-section{margin-bottom:var(--space-sm)}.run-output-label{margin-bottom:var(--space-xs);color:var(--text-muted);font-size:calc(var(--space-sm) + var(--space-xs));font-weight:600;letter-spacing:calc(var(--space-xs) * .1);text-transform:uppercase}.run-output-label--error{color:var(--color-error)}.run-output-panel{margin:0;max-height:calc(var(--space-2xl) * 6.25);overflow:auto;border-radius:var(--radius-sm);padding:var(--space-sm) var(--space-md);background:var(--surface);border:1px solid var(--border);white-space:pre-wrap;word-break:break-word;font-size:calc(var(--space-sm) + var(--space-xs));line-height:1.5}.run-output-panel--error{color:var(--color-error);border-color:color-mix(in srgb,var(--color-error) 35%,var(--border));background:color-mix(in srgb,var(--color-error) 10%,transparent)}.run-context-grid{display:flex;flex-wrap:wrap;gap:var(--space-xs) var(--space-md);font-size:calc(var(--space-sm) + var(--space-xs))}.run-context-item{line-height:1.5}.run-output-empty{padding:var(--space-sm) 0;font-style:italic;font-size:calc(var(--space-sm) + var(--space-xs))}.run-agent-logs-section{margin-top:var(--space-xs);padding-top:var(--space-sm);border-top:1px solid var(--border)}.agent-tasks-list{display:flex;flex-direction:column;gap:var(--space-sm)}.agent-task-item{display:flex;flex-direction:column;gap:calc(var(--space-xs) + var(--space-sm) * .25);padding:var(--space-md) calc(var(--space-md) + var(--space-xs) * .5);border:1px solid var(--border);border-radius:var(--radius-md);background:var(--bg-secondary);text-decoration:none;transition:background var(--transition-fast),border-color var(--transition-fast)}.agent-task-item:hover{background:var(--card-hover);border-color:var(--text-dim)}.agent-task-row{display:flex;align-items:center;justify-content:space-between;gap:var(--space-sm)}.agent-task-id{font-family:var(--font-mono);font-size:var(--space-md);font-weight:600;color:var(--todo)}.agent-task-title{font-size:calc(var(--space-md) + var(--space-xs) * .5);font-weight:500;color:var(--text);line-height:1.4}.agent-task-status{font-size:var(--space-md);color:var(--text-muted)}.agent-task-column{display:inline-flex;align-items:center;padding:calc(var(--space-xs) * .5) var(--space-sm);border-radius:var(--radius-pill);font-size:calc(var(--space-sm) + var(--space-xs) * .5);font-weight:700;text-transform:uppercase;letter-spacing:calc(var(--space-xs) * .1)}.agent-task-column.column-triage{color:var(--triage);background:color-mix(in srgb,var(--triage) 18%,transparent)}.agent-task-column.column-todo{color:var(--todo);background:color-mix(in srgb,var(--todo) 18%,transparent)}.agent-task-column.column-in-progress{color:var(--in-progress);background:color-mix(in srgb,var(--in-progress) 18%,transparent)}.agent-task-column.column-in-review{color:var(--in-review);background:color-mix(in srgb,var(--in-review) 18%,transparent)}.agent-task-column.column-done{color:var(--done);background:color-mix(in srgb,var(--done) 18%,transparent)}.agent-task-column.column-archived{color:var(--text-muted);background:color-mix(in srgb,var(--text-muted) 18%,transparent)}.agent-tasks-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:var(--space-sm);padding:calc(var(--space-2xl) + var(--space-lg));color:var(--text-muted);text-align:center}.agent-tasks-empty p{margin:0}.config-tab{display:flex;flex-direction:column;gap:var(--space-xl)}.config-section{background:var(--bg-secondary);border-radius:var(--radius-md);padding:calc(var(--space-md) + var(--space-sm))}.config-section h3{font-size:calc(var(--space-md) + var(--space-xs));font-weight:600;margin:0 0 var(--space-sm) 0}.config-section--danger{border:1px solid color-mix(in srgb,var(--color-error) 40%,transparent)}.config-danger-note{font-size:calc(var(--space-sm) + var(--space-xs) * .75);color:var(--text-muted)}.agent-content-toolbar{display:flex;align-items:center;gap:var(--space-md);padding:var(--space-sm) var(--space-lg);border-bottom:1px solid var(--border);background:var(--surface);flex-shrink:0}.agent-content-mode-toggle{display:flex;align-items:center;gap:var(--space-xs)}.agent-content-mode-toggle .btn{display:inline-flex;align-items:center;gap:calc(var(--space-xs) + var(--space-sm) * .25)}.agent-content-preview{overflow-y:auto;padding:var(--space-lg);min-height:150px}.agent-content-placeholder{color:var(--text-muted);text-align:center;padding:var(--space-xl);min-height:150px;display:flex;align-items:center;justify-content:center}.config-description{font-size:calc(var(--space-md) + var(--space-xs) * .5);color:var(--text-muted);margin:0 0 calc(var(--space-md) + var(--space-sm)) 0}.config-fields{display:flex;flex-direction:column;gap:var(--space-lg)}.config-field{display:flex;flex-direction:column;gap:calc(var(--space-xs) + var(--space-sm) * .25)}.config-field label{font-size:calc(var(--space-md) + var(--space-xs) * .25);font-weight:500}.agent-avatar-editor{display:flex;align-items:center;gap:var(--space-md)}.agent-avatar-editor-preview{background:var(--card)}.agent-avatar-editor-actions{display:flex;align-items:center;gap:var(--space-sm);flex-wrap:wrap}.config-runtime-tabs{display:grid;grid-template-columns:1fr 1fr;gap:var(--space-sm);margin-bottom:var(--space-md)}.config-runtime-tab{border:1px solid var(--border);border-radius:var(--radius-md);background:var(--card);color:var(--text-muted);padding:var(--space-sm) var(--space-md);font-size:calc(var(--space-sm) + var(--space-xs));font-weight:600;cursor:pointer;transition:border-color var(--transition-fast),background var(--transition-fast),color var(--transition-fast),box-shadow var(--transition-fast)}.config-runtime-tab:hover{border-color:var(--todo);color:var(--text);background:var(--card-hover)}.config-runtime-tab:focus-visible{outline:none;border-color:var(--todo);box-shadow:var(--focus-ring-strong)}.config-runtime-tab.active{border-color:var(--todo);color:var(--text);background:color-mix(in srgb,var(--todo) 12%,transparent)}.config-hint{font-size:calc(var(--space-sm) + var(--space-xs) * .75);color:var(--text-muted);font-style:italic}.config-error{font-size:calc(var(--space-sm) + var(--space-xs) * .75);color:var(--color-error)}.input--error{border-color:var(--color-error)!important}.config-actions{display:flex;align-items:center;gap:var(--space-md);margin-top:calc(var(--space-md) + var(--space-sm));padding-top:var(--space-lg);border-top:1px solid var(--border)}.config-saved-indicator{display:flex;align-items:center;gap:calc(var(--space-sm) - var(--space-xs) * .5);font-size:calc(var(--space-md) + var(--space-xs) * .25);color:var(--color-success)}.config-saved-indicator--error{color:var(--color-error)}.heartbeat-procedure-actions{margin-top:var(--space-sm)}.heartbeat-procedure-viewer{margin-top:var(--space-lg)}.heartbeat-procedure-status{display:inline-flex;align-items:center;gap:var(--space-xs);margin-left:auto}.heartbeat-procedure-status--warning{color:var(--color-warning)}.rating-summary-card{background:var(--bg-secondary);border:1px solid var(--border);border-radius:var(--radius-md);padding:calc(var(--space-md) + var(--space-sm));display:flex;flex-direction:column;gap:var(--space-md)}.rating-score-display{display:flex;align-items:center;gap:var(--space-md)}.rating-average{font-size:var(--space-2xl);font-weight:700;line-height:1}.rating-stats{display:flex;align-items:center;gap:var(--space-md)}.rating-count{font-size:calc(var(--space-md) + var(--space-xs) * .5);color:var(--text-muted)}.rating-trend-badge{font-size:var(--space-md);padding:var(--space-xs) calc(var(--space-md) - var(--space-xs) * .5);border-radius:var(--radius-lg);font-weight:500}.trend-improving{background:color-mix(in srgb,var(--color-success) 15%,transparent);color:var(--color-success)}.trend-declining{background:color-mix(in srgb,var(--color-error) 15%,transparent);color:var(--color-error)}.trend-stable{background:color-mix(in srgb,var(--color-warning) 15%,transparent);color:var(--color-warning)}.trend-insufficient{background:var(--bg-tertiary);color:var(--text-muted)}.category-breakdown{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-md);padding:var(--space-lg)}.category-breakdown h4{margin:0 0 var(--space-md) 0;font-size:calc(var(--space-md) + var(--space-xs) * .25);font-weight:600}.category-breakdown .category-item{display:flex;justify-content:space-between;align-items:center;padding:var(--space-sm) 0;border-bottom:1px solid var(--border)}.category-breakdown .category-item:last-child{border-bottom:none}.category-name{text-transform:capitalize;font-size:calc(var(--space-md) + var(--space-xs) * .25)}.category-score{font-weight:600;font-size:calc(var(--space-md) + var(--space-xs) * .25)}.add-rating-form{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-md);padding:var(--space-lg);display:flex;flex-direction:column;gap:var(--space-md)}.add-rating-form h4{margin:0;font-size:calc(var(--space-md) + var(--space-xs) * .25);font-weight:600}.star-selector{display:flex;gap:var(--space-xs)}.star-btn{background:none;border:none;padding:var(--space-xs);cursor:pointer;border-radius:var(--radius-sm);color:var(--text-muted);transition:background-color var(--transition-fast),color var(--transition-fast)}.star-btn:hover{background:var(--card-hover)}.star-btn:focus-visible{outline:none;box-shadow:var(--focus-ring-strong)}.rating-stars{display:inline-flex;gap:var(--space-xs)}.rating-stars .star-filled{color:var(--color-warning)}.rating-stars .star-empty{color:var(--text-muted)}.add-rating-form .add-rating-category-select,.add-rating-form .add-rating-comment-input{width:100%}.add-rating-form .add-rating-comment-input{resize:vertical;min-height:calc(var(--space-xl) + var(--space-2xl))}.rating-history{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-md);padding:var(--space-lg);max-height:calc(var(--space-xl) * 12 + var(--space-md));overflow-y:auto}.rating-history h4{margin:0 0 var(--space-md) 0;font-size:calc(var(--space-md) + var(--space-xs) * .25);font-weight:600}.rating-history .no-ratings{color:var(--text-muted);font-size:calc(var(--space-md) + var(--space-xs) * .25);text-align:center;padding:var(--space-lg)}.rating-history-item{padding:var(--space-md) 0;border-bottom:1px solid var(--border)}.rating-history-item:last-child{border-bottom:none}.rating-item-header{display:flex;align-items:center;gap:var(--space-sm);flex-wrap:wrap}.rating-category-badge{font-size:calc(var(--space-sm) + var(--space-xs) * .5);padding:calc(var(--space-xs) * .5) var(--space-sm);background:var(--card-hover);border-radius:var(--radius-pill);text-transform:capitalize}.rating-time{font-size:calc(var(--space-sm) + var(--space-xs) * .5);color:var(--text-muted);margin-left:auto}.rating-delete-btn{background:none;border:none;padding:var(--space-xs);cursor:pointer;color:var(--text-muted);border-radius:var(--radius-sm);transition:color var(--transition-fast),background-color var(--transition-fast)}.rating-delete-btn:hover{color:var(--color-error);background:color-mix(in srgb,var(--color-error) 10%,transparent)}.rating-comment{margin:var(--space-sm) 0 0 0;font-size:calc(var(--space-sm) + var(--space-xs));color:var(--text-muted);line-height:1.4}.runs-loading-row{display:flex;align-items:center;justify-content:center;gap:var(--space-sm);padding:var(--space-xl)}.runs-toolbar{padding:var(--space-sm) var(--space-lg);border-bottom:1px solid var(--border)}.runs-toolbar--between{display:flex;justify-content:space-between;align-items:center}.runs-toolbar-meta{font-size:calc(var(--space-sm) + var(--space-xs));color:var(--text-muted)}.run-card--clickable{cursor:pointer}.run-card--clickable:focus-visible{outline:none;box-shadow:var(--focus-ring-strong)}.run-header-group{display:flex;align-items:center;gap:var(--space-sm)}.run-badge--compact{font-size:calc(var(--space-sm) + var(--space-xs) * .5);padding:calc(var(--space-xs) * .25) calc(var(--space-sm) * .75)}.run-output-summary{cursor:pointer;user-select:none}.run-live-indicator--with-margin{margin-left:var(--space-sm)}.detail-section-body--loading{display:flex;align-items:center;gap:var(--space-sm)}.agent-empty--padded{padding:var(--space-xl)}.logs-fallback-label{font-size:calc(var(--space-sm) + var(--space-xs))}.config-textarea-mono{font-family:var(--font-mono);font-size:calc(var(--space-md) + var(--space-xs) * .25);resize:vertical}.config-textarea-top-spacing{margin-top:var(--space-sm)}.config-hint--block-spacing{margin-bottom:var(--space-md)}.config-hint--block{display:block;margin-bottom:var(--space-sm)}.config-hint--top-spacing{margin-top:var(--space-sm)}.config-hint--inline-loader{display:inline-flex;gap:var(--space-xs);margin-top:var(--space-sm)}.config-inline-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:var(--space-sm)}.config-hint--inline-tight{display:flex;align-items:center;gap:var(--space-xs)}.config-hint--warning{color:var(--color-warning)}@media(max-width:768px){.config-runtime-tabs{grid-template-columns:1fr}.agent-detail-overlay{padding:0;align-items:stretch}.agent-detail-modal{min-width:0!important;min-height:0!important;width:100vw!important;height:100dvh!important;max-width:100vw!important;max-height:100dvh;margin:0;border-radius:0;border:none;resize:none}.agent-detail-header{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;column-gap:var(--space-xs);row-gap:0;padding:var(--space-sm) var(--space-md);padding-top:max(var(--space-sm),env(safe-area-inset-top,0))}.agent-detail-identity{grid-column:1;grid-row:1;flex:1 1 auto;min-width:0;gap:var(--space-sm)}.agent-detail-icon{width:calc(var(--space-lg) * 2);height:calc(var(--space-lg) * 2);flex-shrink:0}.agent-detail-icon svg{width:calc(var(--space-sm) + var(--space-xs) * 2);height:calc(var(--space-sm) + var(--space-xs) * 2)}.agent-detail-info h2{font-size:calc(var(--space-md) + var(--space-xs) * .75);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.agent-detail-badges{flex-wrap:wrap}.agent-detail-header-actions{grid-column:2;grid-row:1;flex:0 0 auto;justify-content:flex-end;gap:calc(var(--space-xs) * .5)}.agent-detail-controls{flex:0 0 auto;gap:calc(var(--space-xs) * .5)}.agent-detail-controls .btn--compact{padding:calc(var(--space-sm) - var(--space-xs) * .5) calc(var(--space-md) - var(--space-xs) * .5);font-size:var(--space-md);min-height:calc(var(--space-lg) + var(--space-md) + var(--space-xs))}.agent-detail-controls .agent-detail-mobile-icon-control{min-width:calc(var(--space-lg) + var(--space-md) + var(--space-xs));padding-left:calc(var(--space-sm) - var(--space-xs) * .5);padding-right:calc(var(--space-sm) - var(--space-xs) * .5)}.agent-detail-controls .agent-detail-mobile-icon-control .agent-detail-control-label{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.agent-detail-controls .btn--compact svg{width:calc(var(--space-md) + var(--space-xs) * .5);height:calc(var(--space-md) + var(--space-xs) * .5)}.agent-detail-utility-actions{flex-shrink:0;margin-left:0}.agent-detail-utility-actions .btn-icon{min-height:calc(var(--space-lg) + var(--space-md) + var(--space-xs));min-width:calc(var(--space-lg) + var(--space-md) + var(--space-xs))}.agent-detail-import-btn{min-width:calc(var(--space-xl) * 3 + var(--space-xs))}.agent-detail-title{flex:1 1 auto;min-width:0;gap:var(--space-md)}.agent-detail-actions{flex:1 1 100%;flex-wrap:wrap;gap:calc(var(--space-xs) + var(--space-sm) * .25)}.agent-detail-actions .btn{padding:calc(var(--space-sm) - var(--space-xs) * .5) calc(var(--space-md) - var(--space-xs) * .5);font-size:calc(var(--space-md) + var(--space-xs) * .25);min-height:calc(var(--space-lg) + var(--space-md) + var(--space-xs))}.agent-detail-actions .btn svg{width:calc(var(--space-sm) + var(--space-xs) * 1.5);height:calc(var(--space-sm) + var(--space-xs) * 1.5)}.agent-detail-actions .btn-icon{min-height:calc(var(--space-lg) + var(--space-md) + var(--space-xs));min-width:calc(var(--space-lg) + var(--space-md) + var(--space-xs))}.agent-detail-tabs{padding:0;overflow-x:auto;-webkit-overflow-scrolling:touch;scrollbar-width:none}.agent-detail-tabs::-webkit-scrollbar{display:none}.agent-detail-tab{padding:var(--space-md) calc(var(--space-md) + var(--space-xs) * .5);font-size:calc(var(--space-md) + var(--space-xs) * .25);white-space:nowrap;min-height:calc(var(--space-lg) + var(--space-md) + var(--space-xs))}.agent-detail-content{padding:var(--space-lg)}.agent-detail-footer{flex-wrap:wrap;gap:var(--space-sm);padding:var(--space-sm) var(--space-lg);padding-bottom:max(var(--space-sm),env(safe-area-inset-bottom,0));font-size:calc(var(--space-sm) + var(--space-xs) * .75)}.agent-detail-id{max-width:140px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dashboard-tab{gap:var(--space-lg)}.dashboard-summary-skills,.dashboard-summary-skill-detail-header{flex-direction:column;align-items:flex-start}.dashboard-section{padding:var(--space-lg)}.info-grid{grid-template-columns:repeat(2,1fr);gap:var(--space-md)}.stats-grid{grid-template-columns:repeat(3,1fr);gap:var(--space-md)}.stat-value{font-size:calc(var(--space-lg) + var(--space-xs) * .5)}.logs-empty{padding:var(--space-2xl) var(--space-lg)}.run-card{padding:var(--space-md)}.run-header{flex-wrap:wrap;gap:calc(var(--space-xs) + var(--space-sm) * .25)}.run-details{flex-wrap:wrap}.run-logs-container{padding:var(--space-sm)}.run-output-panel{max-height:calc(var(--space-2xl) * 5)}.run-context-grid{flex-direction:column;gap:var(--space-xs)}.run-details .text-muted{min-width:0;overflow-wrap:anywhere}.config-tab{gap:var(--space-lg)}.config-section{padding:var(--space-lg)}.config-section .input,.config-section .select,.config-section textarea{font-size:calc(var(--space-md) + var(--space-xs));min-height:calc(var(--space-lg) + var(--space-md) + var(--space-xs))}.config-actions{flex-direction:column;align-items:stretch;gap:var(--space-sm)}.config-actions .btn{width:100%;justify-content:center}.heartbeat-procedure-status{margin-left:0}}@media(max-width:480px){.info-grid,.stats-grid{grid-template-columns:1fr}.agent-detail-actions{flex-direction:column;width:100%}.agent-detail-actions .btn{width:100%;justify-content:center}.agent-detail-actions .btn-icon{align-self:flex-end}.agent-detail-footer .divider,.agent-detail-footer .text-muted,.agent-detail-footer .link{display:none}}@media(max-width:768px){.agent-avatar-editor{flex-direction:column;align-items:flex-start}.agent-avatar-editor-actions{width:100%}.agent-avatar-editor-actions .btn{min-height:calc(var(--space-lg) * 2 + var(--space-xs))}.agent-dialog-overlay{padding:0;align-items:stretch}.agent-dialog{width:100vw!important;height:100dvh;max-width:100%!important;max-height:100dvh;border-radius:0;border:none}.agent-dialog-header{padding:max(var(--space-md),env(safe-area-inset-top,0px)) var(--space-lg) var(--space-md) var(--space-lg);flex-shrink:0}.agent-dialog-body{padding:var(--space-lg);-webkit-overflow-scrolling:touch}.agent-dialog-footer{padding:var(--space-md) var(--space-lg);padding-bottom:max(var(--space-md),env(safe-area-inset-bottom,0px));flex-wrap:wrap;gap:var(--space-sm)}.agent-dialog-field .input,.agent-dialog-field .select,.agent-dialog-field textarea{font-size:calc(var(--space-md) + var(--space-xs));min-height:calc(var(--space-lg) * 2 + var(--space-xs))}.agent-dialog-summary-row{flex-direction:column;gap:calc(var(--space-xs) * .5)}.agent-dialog-summary-row>span:first-child,.agent-dialog-summary-row-label{width:auto}.agent-dialog-steps{padding:var(--space-sm) var(--space-lg)}.agent-dialog-step{flex:1;width:auto;height:calc(var(--space-xs) - var(--space-xs) * .25)}.agent-dialog-tabs{grid-template-columns:1fr;gap:calc(var(--space-sm) - var(--space-xs) * .5);margin-bottom:var(--space-md)}.agent-dialog-tab{min-height:calc(var(--space-lg) * 2 + var(--space-xs));text-align:left}.agent-import-file-upload{flex-direction:column;align-items:stretch;gap:var(--space-sm)}.agent-import-textarea{font-size:calc(var(--space-md) + var(--space-xs));min-height:calc(var(--space-xl) * 4 + var(--space-xs))}.agent-import-agent-list{max-height:calc(100dvh - (var(--space-xl) * 10 + var(--space-lg)))}.agent-import-result-stats{flex-direction:column;gap:var(--space-sm);align-items:center}.agent-import-browse-list{max-height:calc(100dvh - (var(--space-xl) * 10 + var(--space-lg)))}.agent-import-skill-list{max-height:calc(100dvh - (var(--space-xl) * 15 + var(--space-md)))}}@media(max-width:480px){.agent-dialog-body{padding:var(--space-md)}.agent-dialog-footer{flex-direction:column}.agent-dialog-footer .btn{width:100%;justify-content:center}}.reflections-tab{padding:var(--space-lg);display:flex;flex-direction:column;gap:var(--space-lg)}.reflections-header{display:flex;align-items:center;justify-content:space-between;gap:var(--space-md)}.reflections-header h3{display:flex;align-items:center;gap:var(--space-sm);font-size:1rem;font-weight:600;color:var(--text)}.reflections-stats-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:var(--space-md)}.reflections-stat-card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-md);padding:var(--space-md);text-align:center}.reflections-stat-card .stat-value{display:flex;align-items:center;justify-content:center;gap:var(--space-sm);font-size:1.5rem;font-weight:700;color:var(--text);margin-bottom:var(--space-xs)}.reflections-stat-card .stat-label{font-size:.75rem;color:var(--text-secondary);text-transform:uppercase;letter-spacing:.05em}.reflections-no-data{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:var(--space-sm);padding:var(--space-xl);color:var(--text-secondary);text-align:center}.reflections-list{display:flex;flex-direction:column;gap:var(--space-md)}.reflections-loading-indicator{display:flex;align-items:center;justify-content:center;gap:var(--space-sm);padding:var(--space-lg)}.reflections-ratings-section{display:flex;flex-direction:column;gap:var(--space-md)}.reflections-ratings-section>h4,.reflections-list h4{font-size:.875rem;font-weight:600;color:var(--text);margin-bottom:var(--space-xs)}.reflection-cards{display:flex;flex-direction:column;gap:var(--space-sm)}.reflection-card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-md);padding:var(--space-md);cursor:pointer;transition:border-color .15s,background-color .15s}.reflection-card:hover{border-color:var(--border-active);background:var(--card-hover)}.reflection-card:focus-visible{outline:none;box-shadow:var(--focus-ring-strong)}.reflection-card--expanded{border-color:var(--color-primary)}.reflection-card-header{display:flex;align-items:center;gap:var(--space-sm);margin-bottom:var(--space-sm)}.reflection-trigger-badge{font-size:.7rem;font-weight:600;padding:2px 6px;border-radius:var(--radius-sm);text-transform:uppercase;letter-spacing:.05em}.reflection-trigger-periodic{background:color-mix(in srgb,var(--color-info) 15%,transparent);color:var(--color-info)}.reflection-trigger-post-task{background:color-mix(in srgb,var(--color-success) 15%,transparent);color:var(--color-success)}.reflection-trigger-manual{background:color-mix(in srgb,var(--color-primary) 15%,transparent);color:var(--color-primary)}.reflection-trigger-user-requested{background:color-mix(in srgb,var(--color-warning) 15%,transparent);color:var(--color-warning)}.reflection-timestamp{font-size:.75rem;color:var(--text-muted);flex:1}.reflection-chevron{color:var(--text-muted)}.reflection-summary{font-size:.875rem;color:var(--text);line-height:1.5}.reflection-details{margin-top:var(--space-md);padding-top:var(--space-md);border-top:1px solid var(--border);display:flex;flex-direction:column;gap:var(--space-md)}.reflection-insights h5,.reflection-suggestions h5{display:flex;align-items:center;gap:var(--space-xs);font-size:.8rem;font-weight:600;color:var(--text);margin-bottom:var(--space-xs)}.reflection-insights ul,.reflection-suggestions ul{list-style:none;display:flex;flex-direction:column;gap:var(--space-xs)}.reflection-insights li,.reflection-suggestions li{font-size:.8rem;color:var(--text-secondary);padding-left:var(--space-md);position:relative}.reflection-insights li:before{content:"•";position:absolute;left:4px;color:var(--color-success)}.reflection-suggestions li:before{content:"→";position:absolute;left:0;color:var(--color-primary)}.reflection-metrics{background:var(--bg);border-radius:var(--radius-sm);padding:var(--space-sm)}.reflection-metrics h5{font-size:.75rem;font-weight:600;color:var(--text-muted);margin-bottom:var(--space-xs)}.metrics-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(100px,1fr));gap:var(--space-sm)}.metric{display:flex;flex-direction:column;gap:2px}.metric-label{font-size:.7rem;color:var(--text-muted)}.metric-value{font-size:.875rem;font-weight:600;color:var(--text)}.reflection-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:var(--space-sm);padding:var(--space-2xl);color:var(--text-secondary);text-align:center}.reflection-empty p{font-size:.875rem}@media(max-width:768px){.reflections-header{flex-wrap:wrap;align-items:flex-start}.reflections-header .btn{width:100%;justify-content:center}}.budget-progress-container{margin-top:4px}.budget-progress-bar{width:100%;height:8px;background:var(--bg-secondary, #161b22);border-radius:4px;overflow:hidden;margin-top:4px}.budget-progress-bar__fill{height:100%;border-radius:4px;transition:width .3s ease,background-color .3s ease}.budget-progress-bar__fill--green{background:var(--state-active-text, #3fb950)}.budget-progress-bar__fill--amber{background:var(--state-paused-text, #e3b541)}.budget-progress-bar__fill--red{background:var(--state-error-text, #f85149)}.budget-progress-label{font-size:.75rem;color:var(--text-secondary, #8b949e);margin-top:4px;display:block}.budget-badge{display:inline-flex;align-items:center;gap:4px;padding:2px 8px;border-radius:12px;font-size:.75rem;font-weight:500}.budget-warning-banner{display:flex;align-items:center;gap:8px;padding:8px 12px;border-radius:6px;background:var(--state-error-bg, rgba(248,81,73,.15));color:var(--state-error-text, #f85149);border:1px solid var(--state-error-border, #f85149);font-size:.875rem;margin-bottom:12px}.btn-reset-budget{margin-top:8px}.chat-sidebar-footer{display:none}@media(max-width:768px){.chat-view{flex-direction:column}.chat-sidebar{width:100%;min-width:100%;height:100%;max-height:none;border-right:none;border-bottom:1px solid var(--border);flex-direction:column}.chat-sidebar-header,.chat-sidebar-search{display:none}.chat-sidebar-list{flex:1;min-height:0;overflow-y:auto}.chat-sidebar-footer{display:flex;padding:var(--space-md);border-top:1px solid var(--border);background:var(--bg-secondary)}.chat-sidebar-footer-btn{flex:1;justify-content:center}.chat-sidebar--hidden{display:none}.chat-message{max-width:90%}.chat-new-dialog{width:95vw;margin:16px}.chat-thread-header{padding:8px 12px}.chat-skill-menu{left:var(--space-md);right:calc(var(--space-md) + var(--mobile-nav-height));min-width:0;max-width:none}}@media(max-width:768px){.file-mention-popup{max-height:200px}.file-mention-popup-item{min-height:36px;padding:10px 12px}.agent-mention-popup{max-width:280px;min-width:200px}}