@wrongstack/webui 0.298.0 → 0.298.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/dist/assets/{AgentRosterView-C8j2NuD1.js → AgentRosterView-RvxaV08Y.js} +4 -4
  2. package/dist/assets/{AnalyticsDashboard-D2_HYmYw.js → AnalyticsDashboard-irejsLMt.js} +1 -1
  3. package/dist/assets/{AudienceMemoryPanel-SzXptIQj.js → AudienceMemoryPanel-DDW_WPjf.js} +2 -2
  4. package/dist/assets/{ChangesView-D31wr7_h.js → ChangesView-Bnd167hf.js} +1 -1
  5. package/dist/assets/ChronicleDashboard-DC62FDEt.js +1 -0
  6. package/dist/assets/CodeEditor-DCWcCQPO.js +1 -0
  7. package/dist/assets/CodeMap-DSqqgBuD.js +1 -0
  8. package/dist/assets/{CronJobsPanel-C9shS0P2.js → CronJobsPanel-BXujnpGC.js} +1 -1
  9. package/dist/assets/{DeadCodeScanPanel-CHud_Ugp.js → DeadCodeScanPanel-HTbGUTMl.js} +1 -1
  10. package/dist/assets/{DebugDashboard-DmqpGXnx.js → DebugDashboard-B5kJBUv0.js} +1 -1
  11. package/dist/assets/{DesignGalleryView-CnAHpKa1.js → DesignGalleryView-BQ0CZpQm.js} +1 -1
  12. package/dist/assets/GoalView-DvaSR6CO.js +1 -0
  13. package/dist/assets/KanbanView-DpWs_i8T.js +3 -0
  14. package/dist/assets/MailboxDetailView-Dh8ekyMw.js +1 -0
  15. package/dist/assets/MemoryManager-CUAbNwsz.js +1 -0
  16. package/dist/assets/{ModelPicker-Dt0wCi90.js → ModelPicker-BxYMTEEN.js} +1 -1
  17. package/dist/assets/OfficeMapPanel-HgERknuN.js +4 -0
  18. package/dist/assets/{ProcessMonitor-Dq760Vqm.js → ProcessMonitor-DVUCtVHZ.js} +1 -1
  19. package/dist/assets/{QueuePanel-ZcJliKcY.js → QueuePanel-n9lScdWu.js} +1 -1
  20. package/dist/assets/{RefreshDebugView-SivBV0LN.js → RefreshDebugView-eZQ3wdxU.js} +1 -1
  21. package/dist/assets/{SageTabs-CGrc4PuM.js → SageTabs-B-eQ--Sb.js} +2 -2
  22. package/dist/assets/SddHub-D81poT6w.js +2 -0
  23. package/dist/assets/SessionsDashboard-CR3NZeHw.js +1 -0
  24. package/dist/assets/{SetupScreen-BWA_dTU0.js → SetupScreen-t6wrhv6l.js} +1 -1
  25. package/dist/assets/SkillDetailView-D6TOvMQU.js +3 -0
  26. package/dist/assets/{SpecsView-CzYtHNbj.js → SpecsView-BYiJr__T.js} +1 -1
  27. package/dist/assets/TechStackView-HEMM3PkG.js +1 -0
  28. package/dist/assets/{TerminalPanel-BRSYloOD.js → TerminalPanel-BgMsGfGa.js} +1 -1
  29. package/dist/assets/{Toaster-Bd6ckyrP.js → Toaster-EXqX2jqp.js} +1 -1
  30. package/dist/assets/{activity-C34aPcFU.js → activity-BBPMHCAJ.js} +1 -1
  31. package/dist/assets/{activity-CBdzUJQ_.js → activity-BJijwuIr.js} +1 -1
  32. package/dist/assets/{activity-Wr0_Gb8A.js → activity-DReNmuta.js} +1 -1
  33. package/dist/assets/{activity-CLYyxeC6.js → activity-DeEOo2zu.js} +1 -1
  34. package/dist/assets/{activity-Cv_EIWjY.js → activity-Dyh19u3P.js} +1 -1
  35. package/dist/assets/{activity-Bo6DncWg.js → activity-GR8KiHvf.js} +1 -1
  36. package/dist/assets/{activity-kCY0dGRC.js → activity-iuGHFz2B.js} +1 -1
  37. package/dist/assets/button-DwmC7ENW.js +1 -0
  38. package/dist/assets/{chat-Du7n7HZ7.js → chat-CRmMDzCb.js} +1 -1
  39. package/dist/assets/{chat-VkTBQmmx.js → chat-CwnuX7tG.js} +1 -1
  40. package/dist/assets/{chat-BJzPxfyr.js → chat-DLn1hY01.js} +1 -1
  41. package/dist/assets/{chat-IRKmQ6we.js → chat-DSEq1Bdz.js} +1 -1
  42. package/dist/assets/{chat-C7ybebfi.js → chat-DxLD17ER.js} +1 -1
  43. package/dist/assets/{chat-BRBVFl4h.js → chat-DzPxYALH.js} +1 -1
  44. package/dist/assets/{chat-Bkom8vQo.js → chat-OunddzYy.js} +1 -1
  45. package/dist/assets/{chat-store-CWhuSNod.js → chat-store-LHzJqRCp.js} +1 -1
  46. package/dist/assets/{codemap-activity-store-C1XWbXeZ.js → codemap-activity-store-B6n7KiS8.js} +1 -1
  47. package/dist/assets/codemap-index-store-oapPwtvI.js +1 -0
  48. package/dist/assets/{dialog-DYJUM0p1.js → dialog-DsCmc6eL.js} +1 -1
  49. package/dist/assets/{empty-state-BV-Y8c35.js → empty-state-02bIS4x7.js} +1 -1
  50. package/dist/assets/{i18n-DOuSY1L8.js → i18n-DxnYsmc-.js} +2 -2
  51. package/dist/assets/index-Bf75VrDE.js +132 -0
  52. package/dist/assets/index-NFp5CXyK.css +1 -0
  53. package/dist/assets/{input-CW-Yw2Wu.js → input-UhWgodVi.js} +1 -1
  54. package/dist/assets/{mailbox-store-_8voaug1.js → mailbox-store-xh2Ux-Xs.js} +1 -1
  55. package/dist/assets/progress-ring-C0O73ZjR.js +1 -0
  56. package/dist/assets/{roster-ws-q8Cp6us7.js → roster-ws-DlQQL7Eh.js} +1 -1
  57. package/dist/assets/{session-store-D4JWBP5w.js → session-store-BE_S1f5v.js} +1 -1
  58. package/dist/assets/settings-B5xal2R3.js +1 -0
  59. package/dist/assets/settings-BHtFy8EG.js +1 -0
  60. package/dist/assets/settings-Bss5hBla.js +1 -0
  61. package/dist/assets/settings-BzrLCVRP.js +1 -0
  62. package/dist/assets/settings-C7RdvmLZ.js +1 -0
  63. package/dist/assets/settings-Dd94HoV6.js +1 -0
  64. package/dist/assets/settings-Dm9THFe8.js +1 -0
  65. package/dist/assets/{shared-DidGznBo.js → shared-bBntASiy.js} +1 -1
  66. package/dist/assets/{stores-CpZiOiOP.js → stores-BS-Bdi-5.js} +1 -1
  67. package/dist/assets/ui-store-C4Ybfoon.js +1 -0
  68. package/dist/assets/{useWebSocket-BTXT0rOW.js → useWebSocket-x8PMoTq8.js} +17 -17
  69. package/dist/assets/{utils-DxDx8yib.js → utils-_s0GyctV.js} +1 -1
  70. package/dist/assets/{vendor-BTDGplXK.js → vendor-CxV3l5PQ.js} +93 -30
  71. package/dist/assets/{view-navigation-BRtuAwZo.js → view-navigation-DLdE7qHU.js} +1 -1
  72. package/dist/assets/ws-client-Cy3oRAmZ.js +1 -0
  73. package/dist/components/MemoryManager/MemoryInjectorPanel.d.ts +19 -0
  74. package/dist/components/SettingsPanel/ModelCatalogPicker.d.ts +22 -0
  75. package/dist/components/SettingsPanel/ModelListEditor.d.ts +41 -0
  76. package/dist/components/SettingsPanel/ModelSchemaEditor.d.ts +32 -0
  77. package/dist/components/SettingsPanel/PluginToggleList.d.ts +11 -1
  78. package/dist/components/SettingsPanel/ProviderModelsPanel.d.ts +2 -1
  79. package/dist/hooks/ws-handlers/misc-handlers.d.ts +1 -0
  80. package/dist/index.html +23 -23
  81. package/dist/index.js +9891 -8571
  82. package/dist/lib/sage-block.d.ts +18 -23
  83. package/dist/lib/ws-client.d.ts +6 -1
  84. package/dist/stores/local-prefs.d.ts +2 -2
  85. package/dist/stores/types.d.ts +2 -1
  86. package/dist/types/client-message.d.ts +19 -0
  87. package/dist/types/server-message.d.ts +11 -0
  88. package/dist/types/system.d.ts +3 -2
  89. package/package.json +10 -9
  90. package/dist/assets/ChronicleDashboard-B7P4f1hr.js +0 -1
  91. package/dist/assets/CodeEditor-BRDwx8Y-.js +0 -1
  92. package/dist/assets/CodeMap-uabWaeJH.js +0 -1
  93. package/dist/assets/GoalView-DaptZIKr.js +0 -1
  94. package/dist/assets/KanbanView-DA5Ulb8C.js +0 -3
  95. package/dist/assets/MailboxDetailView-CQtHeWVs.js +0 -1
  96. package/dist/assets/MemoryManager-BWuSS0Pg.js +0 -1
  97. package/dist/assets/OfficeMapPanel-CUNRI3X7.js +0 -4
  98. package/dist/assets/SddHub-oU47Hv8Y.js +0 -2
  99. package/dist/assets/SessionsDashboard-Dp-Mr844.js +0 -1
  100. package/dist/assets/SkillDetailView-DmRgd_uu.js +0 -3
  101. package/dist/assets/TechStackView-p9PKj9pQ.js +0 -1
  102. package/dist/assets/button-Clh96jMK.js +0 -1
  103. package/dist/assets/codemap-index-store-DDT3gP6t.js +0 -1
  104. package/dist/assets/index-C09Opuro.css +0 -1
  105. package/dist/assets/index-DxZTscTk.js +0 -132
  106. package/dist/assets/progress-ring-DPV94fM-.js +0 -1
  107. package/dist/assets/settings-B9EPDhAL.js +0 -1
  108. package/dist/assets/settings-BBNOO9wC.js +0 -1
  109. package/dist/assets/settings-BoXoFVdx.js +0 -1
  110. package/dist/assets/settings-CkXKHC77.js +0 -1
  111. package/dist/assets/settings-DWIDXI2K.js +0 -1
  112. package/dist/assets/settings-r_KOGrbF.js +0 -1
  113. package/dist/assets/settings-tyKsHhya.js +0 -1
  114. package/dist/assets/ui-store-C-oyG_br.js +0 -1
  115. package/dist/assets/ws-client-DqIqzkfU.js +0 -1
  116. package/dist/components/MemoryManager/MemoryInjectorTrace.d.ts +0 -3
  117. package/dist/components/SageMemoryCard.d.ts +0 -19
@@ -0,0 +1,3 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Bi as t,Bt as n,Dn as r,Ia as i,Mt as a,Ni as o,Oi as s,Ot as c,Pi as l,Qt as u,Rn as d,Si as f,Sn as p,St as m,Ta as h,Ui as g,Un as _,Vi as v,Wt as y,Xi as b,Yi as x,Yn as S,Yt as C,Zt as w,an as T,cn as ee,dt as E,fn as D,gn as O,hi as te,in as ne,jr as re,jt as ie,lt as k,nr as ae,oa as A,pi as oe,pn as se,qi as ce,qr as le,qt as ue,ra as de,ri as fe,rr as pe,sn as me,un as j,va as he,wr as ge,xn as M,yi as _e}from"./vendor-CxV3l5PQ.js";import{n as N}from"./ui-store-C4Ybfoon.js";import{t as ve}from"./ws-client-Cy3oRAmZ.js";import{t as P}from"./utils-_s0GyctV.js";import{t as ye}from"./session-store-BE_S1f5v.js";import{M as be,u as xe,x as F}from"./stores-BS-Bdi-5.js";import{n as Se,t as Ce}from"./ModelPicker-BxYMTEEN.js";import{C as we,S as I,c as Te}from"./index-Bf75VrDE.js";import{n as Ee,t as L}from"./progress-ring-C0O73ZjR.js";var R=e(i(),1);function De(e,t=!0){(0,R.useEffect)(()=>{let n=e.current;if(!n||!t)return;let r=e=>{if(!e.shiftKey||n.scrollWidth<=n.clientWidth+1)return;let t=Math.abs(e.deltaY)>Math.abs(e.deltaX)?e.deltaY:e.deltaX;t!==0&&(e.preventDefault(),n.scrollLeft+=t)},i=e=>{if(!e.ctrlKey&&!e.metaKey||n.scrollWidth<=n.clientWidth+1)return;let t=n.clientWidth*.8;e.key===`ArrowLeft`?(e.preventDefault(),n.scrollLeft-=t):e.key===`ArrowRight`&&(e.preventDefault(),n.scrollLeft+=t)};return n.addEventListener(`wheel`,r,{passive:!1}),n.addEventListener(`keydown`,i),()=>{n.removeEventListener(`wheel`,r),n.removeEventListener(`keydown`,i)}},[e,t])}var z=4320*60*1e3,Oe=new Set([`completed`,`archived`]);function ke(e,t){let n=We(t.now);if(n===null)throw TypeError(`Kanban audit requires a valid current time`);let r=Be(t.liveAgentIdentities),i=Fe(e,t.defaultReviewStaleAfterMs??z),a=Pe(e),o=[];for(let s of e.tasks)Oe.has(s.status)||(Ae(o,s,t.requireDueDate===!0),je(o,s,n,r),Me(o,s,n,i),a.length>1&&Ne(o,s,a));return o.sort(Ge),{issues:o,counts:{error:o.filter(e=>e.severity===`error`).length,warning:o.filter(e=>e.severity===`warning`).length},affectedTaskCount:new Set(o.map(e=>e.taskId)).size}}function Ae(e,t,n){V(t.description)||H(e,t,`missing-description`,`warning`,`Add a description`),Re(t).length===0&&H(e,t,`missing-assignee`,`warning`,`Assign an owner`),n&&!V(t.dueDate)&&H(e,t,`missing-due-date`,`warning`,`Set a due date`),!He(t.labels)&&!He(t.tags)&&H(e,t,`missing-labels`,`warning`,`Add labels or tags`),!He(t.childTaskIds)&&!He(t.subtasks)&&H(e,t,`missing-subtasks`,`warning`,`Define subtasks`),He(t.successCriteria)||H(e,t,`missing-success-criteria`,`warning`,`Add success criteria`)}function je(e,t,n,r){let i=t.assignment;if(!(t.status===`in_progress`||i?.status===`running`))return;let a=Re(t);if(!i||a.length===0||!V(i.leaseId)||!V(i.leaseExpiresAt)){H(e,t,`abandoned-running-task`,`error`,`Running without a complete assignment lease`);return}let o=We(i.leaseExpiresAt);if(o===null||o<=n){H(e,t,`stale-running-task`,`error`,`Assignment lease is expired`);return}a.some(e=>r.has(B(e)))||H(e,t,`abandoned-running-task`,`error`,`Assigned agent is not live`)}function Me(e,t,n,r){if(t.status!==`review`)return;let i=Le(t,`review`)??We(t.updatedAt);i===null||n-i<=r||H(e,t,`stale-review`,`warning`,`Waiting in review for ${Math.max(1,Math.floor((n-i)/(3600*1e3)))}h`)}function Ne(e,t,n){let r=Ie(t);if(r.length<2)return;let i=new Map(n.map((e,t)=>[B(e),t]));for(let n=1;n<r.length;n+=1){let a=r[n-1],o=r[n];if(!a||!o)continue;let s=i.get(B(a.state)),c=i.get(B(o.state));if(!(s===void 0||c===void 0||Math.abs(c-s)<=1)){H(e,t,`skipped-lifecycle-state`,`error`,`Lifecycle skipped ${a.state} → ${o.state}`);return}}}function Pe(e){let t=[e.lifecycle,e.lifecyclePolicy,e.managedLifecycle];for(let e of t){let t=ze(e);if(t.length>1)return t;if(!e||typeof e!=`object`||Array.isArray(e))continue;let n=e;if(n.mode===`managed`&&n.columns){let e=[`backlog`,`todo`,`running`,`review`,`done`].map(e=>n.columns?.[e]).filter(e=>V(e));if(e.length===5)return e}for(let e of[n.states,n.statuses,n.order,n.managedStatuses]){let t=ze(e);if(t.length>1)return t}}return[]}function Fe(e,t){let n=[e,e.lifecycle,e.lifecyclePolicy,e.managedLifecycle];for(let e of n){if(!e||typeof e!=`object`||Array.isArray(e))continue;let t=e;if(Ue(t.staleReviewAfterMs))return t.staleReviewAfterMs;if(Ue(t.reviewStaleAfterMs))return t.reviewStaleAfterMs;if(Ue(t.reviewStaleHours))return t.reviewStaleHours*60*60*1e3}return t}function Ie(e){let t=e.lifecycle?.history??e.lifecycleHistory??e.statusHistory??e.history;if(!Array.isArray(t))return[];let n=[];for(let e of t){if(typeof e==`string`&&V(e)){n.push({state:e.trim(),at:null});continue}if(!e||typeof e!=`object`)continue;let t=e,r=Ve(t.status,t.state,t.toStatus,t.to,t.columnId);r&&n.push({state:r,at:We(t.at??t.ts??t.timestamp??t.changedAt??t.createdAt)})}return n}function Le(e,t){let n=null;for(let r of Ie(e))B(r.state)!==B(t)||r.at===null||(n=n===null?r.at:Math.max(n,r.at));return n}function Re(e){let t=e.assignment;return[e.assignee,e.assignedAgent,t?.agentId,t?.subagentId,t?.name].filter(V)}function ze(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(V(n)){t.push(n.trim());continue}if(!n||typeof n!=`object`)continue;let e=n,r=Ve(e.id,e.status,e.state,e.name);r&&t.push(r)}return t}function Be(e){let t=new Set;if(!e)return t;for(let n of e)V(n)&&t.add(B(n));return t}function B(e){return e.trim().toLocaleLowerCase()}function Ve(...e){for(let t of e)if(V(t))return t.trim();return null}function V(e){return typeof e==`string`&&e.trim().length>0}function He(e){return Array.isArray(e)&&e.length>0}function Ue(e){return typeof e==`number`&&Number.isFinite(e)&&e>0}function We(e){if(e instanceof Date){let t=e.getTime();return Number.isFinite(t)?t:null}if(typeof e==`number`)return Number.isFinite(e)?e:null;if(typeof e!=`string`||!e.trim())return null;let t=Date.parse(e);return Number.isFinite(t)?t:null}function H(e,t,n,r,i){e.push({id:`${t.id}:${n}`,taskId:t.id,taskTitle:t.title,code:n,severity:r,message:i})}function Ge(e,t){let n=Ke(e.severity)-Ke(t.severity);if(n!==0)return n;let r=e.taskTitle.localeCompare(t.taskTitle);return r===0?e.message.localeCompare(t.message):r}function Ke(e){return e===`error`?0:1}function qe(e){let t=be(e=>e.wsUrl),n=be(e=>e.provider),r=be(e=>e.model),[i,a]=(0,R.useState)([]),[o,s]=(0,R.useState)([]),[c,l]=(0,R.useState)({}),[u,d]=(0,R.useState)(``),[f,p]=(0,R.useState)(``);return(0,R.useEffect)(()=>{let e=ve(t).on(`kanban.meta`,e=>{let t=e.payload?.data;t&&(a(t.tools??[]),s(t.skills??[]),l(t.fallbackProfiles??{}),t.sessionProvider&&d(t.sessionProvider),t.sessionModel&&p(t.sessionModel))});return()=>e()},[t]),(0,R.useEffect)(()=>{e&&ve(t).send({type:`kanban.meta`})},[e,t]),{tools:i,skills:o,fallbackProfiles:c,sessionProvider:u||n,sessionModel:f||r}}var U=k();function W({options:e,selected:t,onChange:n,placeholder:r,emptyLabel:i}){let[a,o]=(0,R.useState)(!1),[s,c]=(0,R.useState)(``),l=(0,R.useRef)(null);(0,R.useEffect)(()=>{if(!a)return;let e=e=>{l.current&&!l.current.contains(e.target)&&o(!1)};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[a]);let u=(0,R.useMemo)(()=>{let t=new Map(e.map(e=>[e.value,e.label]));return e=>t.get(e)??e},[e]),d=(0,R.useMemo)(()=>{let t=s.trim().toLowerCase();return(t?e.filter(e=>`${e.value} ${e.label} ${e.tag??``}`.toLowerCase().includes(t)):e).slice(0,80)},[e,s]),f=e=>{n(t.includes(e)?t.filter(t=>t!==e):[...t,e])};return(0,U.jsxs)(`div`,{ref:l,className:`relative`,children:[t.length>0&&(0,U.jsx)(`div`,{className:`mb-1 flex flex-wrap gap-1`,children:t.map(e=>(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-muted px-1.5 py-0.5 text-[11px]`,children:[(0,U.jsx)(`span`,{className:`max-w-[150px] truncate`,children:u(e)}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>f(e),className:`text-muted-foreground hover:text-destructive`,"aria-label":`Remove ${u(e)}`,children:(0,U.jsx)(E,{size:11})})]},e))}),(0,U.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),className:`flex w-full items-center gap-1.5 rounded-md border border-border bg-muted px-2 py-1.5 text-left text-xs transition-colors hover:border-primary/45 hover:bg-muted/80`,children:[(0,U.jsx)(M,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-muted-foreground`,children:r??`Add…`}),(0,U.jsx)(x,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`})]}),a&&(0,U.jsxs)(`div`,{className:`absolute z-50 mt-1 max-h-72 w-full min-w-[240px] overflow-hidden rounded-md border border-border/80 bg-popover shadow-xl`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-border/70 bg-muted/20 px-2 py-1.5`,children:[(0,U.jsx)(`input`,{value:s,onChange:e=>c(e.target.value),placeholder:`Filter…`,className:`min-w-0 flex-1 bg-transparent text-xs outline-none placeholder:text-muted-foreground`}),s&&(0,U.jsx)(`button`,{type:`button`,onClick:()=>c(``),className:`text-muted-foreground hover:text-foreground`,children:(0,U.jsx)(E,{className:`h-3 w-3`})})]}),(0,U.jsxs)(`div`,{className:`max-h-60 overflow-y-auto py-1`,children:[d.map(e=>{let n=t.includes(e.value);return(0,U.jsxs)(`button`,{type:`button`,onClick:()=>f(e.value),className:P(`flex w-full items-start gap-1.5 px-2 py-1.5 text-left text-xs transition-colors hover:bg-muted`,n?`bg-primary/8 text-primary`:`text-foreground`),children:[n?(0,U.jsx)(b,{className:`mt-0.5 h-3 w-3 shrink-0 text-primary`}):(0,U.jsx)(`span`,{className:`w-3 shrink-0`}),(0,U.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`span`,{className:`block truncate`,children:e.label}),e.description&&(0,U.jsx)(`span`,{className:`mt-0.5 block truncate text-[10px] text-muted-foreground`,children:e.description})]}),e.tag&&(0,U.jsx)(`span`,{className:`mt-0.5 shrink-0 font-mono text-[9px] text-muted-foreground`,children:e.tag})]},e.value)}),d.length===0&&(0,U.jsx)(`div`,{className:`px-2 py-3 text-center text-[11px] text-muted-foreground`,children:e.length===0?i??`Nothing available`:`No match`})]})]})]})}function Je(e){let t=Math.max(0,Date.now()-Date.parse(e));return t<6e4?`just now`:t<36e5?`${Math.floor(t/6e4)}m ago`:`${Math.floor(t/36e5)}h ago`}function Ye(e,t){if(!e)return null;let n=Date.parse(e),r=t?Date.parse(t):Date.now();if(!Number.isFinite(n)||!Number.isFinite(r))return null;let i=Math.max(0,Math.floor((r-n)/1e3));if(i<60)return`${i}s`;let a=Math.floor(i/60);if(a<60)return`${a}m`;let o=Math.floor(a/60);return o<24?`${o}h`:`${Math.floor(o/24)}d`}function Xe({presence:e=[]}){return e.length===0?null:(0,U.jsxs)(`section`,{"aria-label":`Board presence`,className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-border bg-card/50 px-4 py-2`,children:[(0,U.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:`Live board users`}),e.map(e=>(0,U.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5 rounded-full border border-border bg-background px-2.5 py-1 text-xs shadow-sm`,title:`Session ${e.sessionId} · last seen ${e.lastSeenAt}`,children:[(0,U.jsx)(`span`,{role:`img`,"aria-label":e.active?`active`:`inactive`,className:P(`h-2 w-2 shrink-0 rounded-full`,e.active?`bg-success`:`bg-muted-foreground/50`)}),(0,U.jsx)(l,{size:13,"aria-hidden":`true`}),(0,U.jsx)(`span`,{className:`max-w-32 truncate font-medium`,children:e.agentName??e.agentId}),(0,U.jsx)(`span`,{className:`max-w-32 truncate text-muted-foreground`,children:e.sessionId}),(0,U.jsx)(s,{size:12,className:`text-muted-foreground`,"aria-hidden":`true`}),(0,U.jsx)(`time`,{dateTime:e.lastSeenAt,className:`tabular-nums text-muted-foreground`,children:Je(e.lastSeenAt)})]},e.id))]})}function Ze({board:e,snapshot:t,sendKanban:n}){let[r,i]=(0,R.useState)(!1),[a,o]=(0,R.useState)(!0),[s,c]=(0,R.useState)(`deterministic`),[l,u]=(0,R.useState)(`session`),[d,f]=(0,R.useState)(``),[p,m]=(0,R.useState)(``),[g,_]=(0,R.useState)(``),[v,y]=(0,R.useState)([]),[b,S]=(0,R.useState)([]),[C,T]=(0,R.useState)(10),E=Se(r&&s===`agentic`),D=qe(r&&s===`agentic`);(0,R.useEffect)(()=>{let t=e.supervisor;o(t?.enabled??!0),c(t?.mode??`deterministic`),u(t?.routing?.mode??`session`),f(t?.routing?.provider??``),m(t?.routing?.model??``),_(t?.routing?.fallbackProfile??``),y(t?.routing?.fallbackModels??[]),S(t?.skills??[]),T(Math.max(2,Math.round((t?.intervalMs??1e4)/1e3)))},[e.id,e.supervisor]);let O=()=>{let t={mode:l,...l===`fixed`&&d?{provider:d}:{},...l===`fixed`&&p?{model:p}:{},...l===`fallback_profile`&&g?{fallbackProfile:g}:{},...v.length?{fallbackModels:v}:{}};n(`kanban.update`,{boardId:e.id,supervisor:{enabled:a,mode:s,intervalMs:Math.max(2,C)*1e3,recoveryMode:`auto`,...s===`agentic`?{routing:t,skills:b}:{}}}),window.setTimeout(()=>n(`kanban.supervisor.audit`,{boardId:e.id}),150)},te=a?t?.status??`starting`:`disabled`;return(0,U.jsxs)(`div`,{className:`shrink-0 border-b bg-background/80`,children:[(0,U.jsxs)(`button`,{type:`button`,onClick:()=>i(e=>!e),className:`flex w-full items-center gap-2 px-4 py-1.5 text-left text-[11px] hover:bg-muted/40`,children:[(0,U.jsx)(w,{size:13,className:te===`healthy`?`text-success`:`text-warning`}),(0,U.jsx)(`span`,{className:`font-semibold`,children:`Kanban Agent`}),(0,U.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 capitalize text-muted-foreground`,children:[s,` · `,te]}),t?.summary&&(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-muted-foreground`,children:t.summary}),(0,U.jsx)(`span`,{className:`ml-auto text-muted-foreground`,children:t?.lastAuditAt?`checked ${Ye(t.lastAuditAt)} ago`:`not checked`}),(0,U.jsx)(x,{size:13,className:P(`transition-transform`,r&&`rotate-180`)})]}),r&&(0,U.jsxs)(`div`,{className:`grid gap-3 border-t p-3 text-xs lg:grid-cols-[220px_220px_1fr_auto]`,children:[(0,U.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md border bg-card px-2 py-2`,children:[(0,U.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>o(e.target.checked)}),(0,U.jsx)(`span`,{children:`Watch this board`})]}),(0,U.jsx)(Qe,{label:`Supervisor engine`,value:s,options:[`deterministic`,`agentic`],onChange:e=>c(e)}),(0,U.jsxs)(`label`,{className:`block`,children:[(0,U.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:`Audit interval (seconds)`}),(0,U.jsx)(`input`,{type:`number`,min:2,value:C,onChange:e=>T(Number(e.target.value)||2),className:`h-8 w-full rounded-md border bg-background px-2 outline-none focus:border-primary`})]}),(0,U.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,U.jsxs)(`button`,{type:`button`,onClick:O,className:`inline-flex h-8 items-center gap-1 rounded-md bg-primary px-3 text-primary-foreground`,children:[(0,U.jsx)(ee,{size:13}),` Save`]}),(0,U.jsxs)(`button`,{type:`button`,onClick:()=>n(`kanban.supervisor.audit`,{boardId:e.id}),className:`inline-flex h-8 items-center gap-1 rounded-md border px-3 hover:bg-muted`,children:[(0,U.jsx)(h,{size:13}),` Audit now`]})]}),s===`deterministic`?(0,U.jsx)(`div`,{className:`lg:col-span-4 rounded-md border border-success/20 bg-success/5 px-3 py-2 text-muted-foreground`,children:`Deterministic mode uses no provider, model, token, or billing. It repairs assignment/status/column drift and recovers expired leases.`}):(0,U.jsxs)(`div`,{className:`grid gap-3 lg:col-span-4 lg:grid-cols-2`,children:[(0,U.jsx)(Qe,{label:`Kanban Agent model source`,value:l,options:[`session`,`fixed`,`fallback_profile`],onChange:e=>u(e)}),l===`fixed`&&(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:`Fixed provider / model`}),(0,U.jsx)(Ce,{value:p||void 0,provider:d||void 0,candidates:E,placeholder:`Select exact provider / model…`,onPick:(e,t)=>{m(e),f(t)}})]}),l===`fallback_profile`&&(0,U.jsx)(Qe,{label:`Fallback profile (first model is primary)`,value:g,options:Object.keys(D.fallbackProfiles),placeholder:`Select configured profile…`,onChange:_}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:`Supervisor skills`}),(0,U.jsx)(W,{options:D.skills.map(e=>({value:e.name,label:e.name,description:e.description,tag:e.source})),selected:b,onChange:S,placeholder:`Force-load agentic skills…`})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:`Extra fallback models`}),(0,U.jsx)(W,{options:E.map(e=>({value:`${e.provider}/${e.model}`,label:e.label,tag:e.provider})),selected:v,onChange:y,placeholder:`Optional ordered fallbacks…`})]})]})]})]})}function Qe({label:e,value:t,options:n,onChange:r,placeholder:i}){return(0,U.jsxs)(`label`,{className:`block`,children:[(0,U.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:e}),(0,U.jsxs)(`select`,{value:t,onChange:e=>r(e.target.value),className:`h-8 w-full rounded-md border bg-background px-2 text-xs outline-none focus:border-primary`,children:[i&&(0,U.jsx)(`option`,{value:``,children:i}),n.map(e=>(0,U.jsx)(`option`,{value:e,children:e},e))]})]})}function $e(e){let t=new Set;for(let n of e)n.status===`running`&&(t.add(n.id),t.add(n.name));return t}function et(e){let t=new Set;e.sessionId&&t.add(e.sessionId);for(let n of e.registrySessionIds)t.add(n);for(let n of e.agents)n.status===`running`&&n.sessionId&&t.add(n.sessionId);return[...t]}function tt(e,t){return e.presence?.some(e=>e.active)===!0||e.tags?.some(e=>e.startsWith(`session:`)&&t.includes(e.slice(8)))===!0}function nt(e){return e?e.tasks.filter(e=>e.status===`in_progress`||e.assignment?.status===`running`||e.assignment?.status===`queued`).reduce((e,t)=>e+(t.costCeilingUsd??0),0):0}function rt(e){let t=e?.tags??[],n=t.includes(`sdd`)?`sdd`:t.includes(`goal`)?`goal`:null;if(!n)return null;let r=t.find(e=>e.startsWith(`run:`))?.slice(4);return{engine:n,...r?{runId:r}:{}}}function it({boardTotal:e,activeBoardTotal:t,orphanedBoardTotal:n,activeBoardId:r,activeBoards:i,orphanedBoards:a,boardPage:o,boardPageSize:s,loading:c,newBoardTitle:l,onClose:u,onRefresh:d,onNewBoardTitleChange:p,onCreateBoard:m,onBoardSelect:h,onBoardPageChange:g}){return(0,U.jsxs)(`aside`,{className:`flex max-h-[45dvh] w-full shrink-0 flex-col border-b bg-card/40 md:max-h-none md:w-[280px] md:border-b-0 md:border-r`,children:[(0,U.jsxs)(`div`,{className:`flex h-12 items-center gap-2 border-b px-3`,children:[(0,U.jsx)(`button`,{type:`button`,title:`Back`,onClick:u,className:`flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,U.jsx)(he,{size:16})}),(0,U.jsx)(f,{size:17,className:`text-primary`}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:`Kanban`}),(0,U.jsxs)(`div`,{className:`truncate text-[11px] text-muted-foreground`,children:[e,` boards · `,t,` active · `,n,` orphaned`]})]}),(0,U.jsx)(`button`,{type:`button`,title:`Refresh`,onClick:d,className:`flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,U.jsx)(O,{size:15,className:c?`animate-spin`:void 0})})]}),(0,U.jsxs)(`div`,{className:`flex gap-1 border-b p-2`,children:[(0,U.jsx)(`input`,{value:l,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&m()},placeholder:`New board`,className:`min-w-0 flex-1 rounded-md border bg-background px-2 py-1.5 text-sm outline-none focus:border-primary`}),(0,U.jsx)(`button`,{type:`button`,title:`Create board`,onClick:m,className:`flex h-8 w-8 items-center justify-center rounded-md bg-primary text-primary-foreground hover:bg-primary/90`,children:(0,U.jsx)(M,{size:16})})]}),(0,U.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-2`,children:[i.length>0&&(0,U.jsxs)(`div`,{className:`mb-1 px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-success`,children:[`Active session · `,t]}),i.map(e=>(0,U.jsx)(at,{board:e,active:r===e.id,dotClassName:`bg-success`,onSelect:h},e.id)),a.length>0&&(0,U.jsxs)(`div`,{className:`mb-1 mt-2 px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[`No active session · `,n]}),a.map(e=>(0,U.jsx)(at,{board:e,active:r===e.id,dotClassName:`bg-muted-foreground/45`,onSelect:h},e.id))]}),(0,U.jsx)(I,{page:o,pageSize:s,totalItems:e,onPageChange:g,compact:!0,itemLabel:`boards`})]})}function at({board:e,active:t,dotClassName:n,onSelect:r}){return(0,U.jsxs)(`button`,{type:`button`,onClick:()=>r(e.id),className:P(`mb-1 w-full rounded-md px-2 py-2 text-left transition-colors`,t?`bg-primary/10 text-foreground`:`text-muted-foreground hover:bg-muted hover:text-foreground`),children:[(0,U.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e.title}),(0,U.jsxs)(`div`,{className:`mt-0.5 flex items-center justify-between text-[11px]`,children:[(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,U.jsx)(`span`,{className:P(`h-1.5 w-1.5 rounded-full`,n)}),e.taskCount,` tasks`]}),(0,U.jsxs)(`span`,{children:[e.completedTaskCount,` done`]})]})]})}var ot={enabled:!1,enforcement:`confirm`,shellAccess:`confirm`,allow:[]};function st({title:e,value:t,inherited:n,onSave:r}){let[i,a]=(0,R.useState)(t??ot),[o,s]=(0,R.useState)(lt(t?.allow??[])),[c,l]=(0,R.useState)(lt(t?.deny??[])),[u,d]=(0,R.useState)(null);return(0,R.useEffect)(()=>{a(t??ot),s(lt(t?.allow??[])),l(lt(t?.deny??[])),d(null)},[t]),(0,U.jsxs)(`details`,{className:`rounded-md border border-primary/25 bg-primary/5`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-3 py-2 text-xs font-semibold`,children:[(0,U.jsx)(w,{size:14,className:`text-primary`}),(0,U.jsx)(`span`,{children:e}),(0,U.jsx)(`span`,{className:`ml-auto font-normal text-muted-foreground`,children:t?.enabled?`${t.enforcement} · ${t.allow.length} allow · shell ${t.shellAccess}`:n?.enabled?`inherits board boundary`:`unrestricted`})]}),(0,U.jsxs)(`div`,{className:`space-y-2 border-t p-3 text-xs`,children:[n?.enabled&&(0,U.jsx)(`div`,{className:`rounded border border-warning/25 bg-warning/10 px-2 py-1.5 text-muted-foreground`,children:`Board policy remains authoritative. This task policy can only narrow that scope.`}),(0,U.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`input`,{type:`checkbox`,checked:i.enabled,onChange:e=>a({...i,enabled:e.target.checked})}),`Enable this boundary layer`]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,U.jsxs)(`label`,{children:[(0,U.jsx)(`span`,{className:`mb-1 block text-[10px] font-medium uppercase text-muted-foreground`,children:`Outside scope`}),(0,U.jsxs)(`select`,{value:i.enforcement,onChange:e=>a({...i,enforcement:e.target.value}),className:`h-8 w-full rounded border bg-background px-2`,children:[(0,U.jsx)(`option`,{value:`confirm`,children:`Ask permission`}),(0,U.jsx)(`option`,{value:`block`,children:`Always block`})]})]}),(0,U.jsxs)(`label`,{children:[(0,U.jsx)(`span`,{className:`mb-1 block text-[10px] font-medium uppercase text-muted-foreground`,children:`Shell / opaque tools`}),(0,U.jsxs)(`select`,{value:i.shellAccess,onChange:e=>a({...i,shellAccess:e.target.value}),className:`h-8 w-full rounded border bg-background px-2`,children:[(0,U.jsx)(`option`,{value:`confirm`,children:`Ask permission`}),(0,U.jsx)(`option`,{value:`block`,children:`Always block`}),(0,U.jsx)(`option`,{value:`allow`,children:`Allow`})]})]})]}),(0,U.jsx)(ct,{label:`Allow selectors`,value:o,onChange:s}),(0,U.jsx)(ct,{label:`Deny selectors`,value:c,onChange:l}),(0,U.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:`One per line: kind:access:path — for example directory:read_write:packages/webui or file:read:README.md. Kinds: file, directory, package, glob. If an access type has no allow selector, it remains unrestricted except for deny rules. Shell “Allow” is opaque and can cross path selectors.`}),u&&(0,U.jsx)(`div`,{className:`text-destructive`,children:u}),(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsxs)(`button`,{type:`button`,onClick:()=>{try{let e=ut(o),t=ut(c);r({...i,allow:e,...t.length?{deny:t}:{}}),d(null)}catch(e){d(e instanceof Error?e.message:String(e))}},className:`inline-flex h-8 flex-1 items-center justify-center gap-2 rounded bg-primary text-primary-foreground`,children:[(0,U.jsx)(ee,{size:13}),` Save boundary`]}),t&&(0,U.jsx)(`button`,{type:`button`,onClick:()=>r(null),className:`h-8 rounded border px-3 text-muted-foreground hover:bg-muted`,children:`Remove layer`})]})]})]})}function ct({label:e,value:t,onChange:n}){return(0,U.jsxs)(`label`,{className:`block`,children:[(0,U.jsx)(`span`,{className:`mb-1 block text-[10px] font-medium uppercase text-muted-foreground`,children:e}),(0,U.jsx)(`textarea`,{rows:3,value:t,onChange:e=>n(e.target.value),className:`w-full resize-y rounded border bg-background px-2 py-1.5 font-mono text-[11px] outline-none focus:border-primary`})]})}function lt(e){return e.map(e=>`${e.kind}:${e.access}:${e.path}`).join(`
2
+ `)}function ut(e){let t=new Set([`file`,`directory`,`package`,`glob`]),n=new Set([`read`,`write`,`read_write`]);return e.split(/\r?\n/).map(e=>e.trim()).filter(Boolean).map((e,r)=>{let i=e.indexOf(`:`),a=e.indexOf(`:`,i+1);if(i<=0||a<=i+1||a===e.length-1)throw Error(`Boundary line ${r+1} must use kind:access:path.`);let o=e.slice(0,i),s=e.slice(i+1,a),c=e.slice(a+1).trim();if(!t.has(o))throw Error(`Boundary line ${r+1} has unknown kind.`);if(!n.has(s))throw Error(`Boundary line ${r+1} has unknown access.`);return{kind:o,access:s,path:c}})}function dt({audit:e,onSelectTask:t}){let[n,r]=(0,R.useState)(!0),i=(0,R.useId)();if((0,R.useEffect)(()=>{e.issues.length>0&&r(!0)},[e.issues.length]),e.issues.length===0)return null;let a=ft(e.issues);return(0,U.jsxs)(`section`,{"aria-labelledby":`${i}-title`,className:`shrink-0 border-b border-warning/25 bg-card/95 shadow-[inset_0_1px_0_hsl(var(--warning)/0.08)]`,children:[(0,U.jsxs)(`div`,{className:`flex min-h-10 flex-wrap items-center gap-2 px-3 py-2 sm:px-4`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,role:`status`,"aria-live":`polite`,children:[(0,U.jsx)(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-warning/25 bg-warning/10 text-warning`,children:(0,U.jsx)(y,{size:14,"aria-hidden":`true`})}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsxs)(`h2`,{id:`${i}-title`,className:`text-xs font-semibold text-foreground`,children:[`Kanban Cleaner found `,e.issues.length,` `,e.issues.length===1?`issue`:`issues`]}),(0,U.jsxs)(`p`,{className:`truncate text-[10px] text-muted-foreground`,children:[e.affectedTaskCount,` `,e.affectedTaskCount===1?`card needs`:`cards need`,` attention`]})]})]}),e.counts.error>0&&(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-destructive/25 bg-destructive/10 px-2 py-0.5 text-[10px] font-medium text-destructive`,children:[(0,U.jsx)(g,{size:11,"aria-hidden":`true`}),` `,e.counts.error,` critical`]}),e.counts.warning>0&&(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-warning/25 bg-warning/10 px-2 py-0.5 text-[10px] font-medium text-warning`,children:[(0,U.jsx)(c,{size:11,"aria-hidden":`true`}),` `,e.counts.warning,` warning`]}),(0,U.jsx)(`button`,{type:`button`,"aria-expanded":n,"aria-controls":i,"aria-label":n?`Collapse Kanban Cleaner issues`:`Expand Kanban Cleaner issues`,onClick:()=>r(e=>!e),className:`flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,children:(0,U.jsx)(x,{size:14,"aria-hidden":`true`,className:P(`transition-transform`,n&&`rotate-180`)})})]}),n&&(0,U.jsx)(`ul`,{id:i,className:`grid max-h-36 gap-1 overflow-y-auto px-3 pb-2 sm:grid-cols-2 sm:px-4 xl:grid-cols-3`,children:a.map(({taskId:e,taskTitle:n,issues:r})=>(0,U.jsx)(`li`,{children:(0,U.jsxs)(`button`,{type:`button`,onClick:()=>t(e),"aria-label":`Open ${n}: ${r.map(e=>e.message).join(`, `)}`,className:`group flex w-full items-start gap-2 rounded-md border border-border/70 bg-background/70 px-2.5 py-2 text-left transition-colors hover:border-primary/40 hover:bg-primary/5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,children:[(0,U.jsx)(`span`,{className:P(`mt-1 h-1.5 w-1.5 shrink-0 rounded-full`,r.some(e=>e.severity===`error`)?`bg-destructive shadow-[0_0_8px_hsl(var(--destructive)/0.55)]`:`bg-warning shadow-[0_0_8px_hsl(var(--warning)/0.45)]`),"aria-hidden":`true`}),(0,U.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`span`,{className:`block truncate text-[11px] font-semibold text-foreground group-hover:text-primary`,children:n}),(0,U.jsx)(`span`,{className:`mt-0.5 block line-clamp-2 text-[10px] leading-4 text-muted-foreground`,children:r.map(e=>e.message).join(` · `)})]})]})},e))})]})}function ft(e){let t=new Map;for(let n of e){let e=t.get(n.taskId);e?e.issues.push(n):t.set(n.taskId,{taskId:n.taskId,taskTitle:n.taskTitle,issues:[n]})}return[...t.values()]}function pt({board:e,sendKanban:t,onSelectTask:n}){let[r,i]=(0,R.useState)(!1),a=e.tasks.filter(e=>e.decomposition?.status===`proposed`);return a.length?(0,U.jsxs)(`div`,{className:`shrink-0 border-b border-warning/30 bg-warning/5 px-4 py-2`,children:[(0,U.jsxs)(`button`,{type:`button`,onClick:()=>i(e=>!e),className:`flex w-full items-center gap-2 text-left text-xs font-semibold text-warning`,children:[r?(0,U.jsx)(ce,{size:13}):(0,U.jsx)(x,{size:13}),(0,U.jsx)(me,{size:13}),a.length,` decomposition proposal`,a.length>1?`s`:``,` awaiting approval`]}),!r&&(0,U.jsx)(`ul`,{className:`mt-1.5 space-y-1`,children:a.map(r=>(0,U.jsxs)(`li`,{className:`flex items-center gap-2 text-xs`,children:[(0,U.jsxs)(`button`,{type:`button`,onClick:()=>n(r.id),className:`min-w-0 flex-1 truncate text-left hover:underline`,children:[r.title,(0,U.jsxs)(`span`,{className:`ml-1.5 text-muted-foreground`,children:[`→ `,r.decomposition?.proposedSubtasks.length??0,` subtasks`]})]}),(0,U.jsxs)(`button`,{type:`button`,onClick:()=>t(`kanban.decomposition.approve`,{boardId:e.id,taskId:r.id,proposalId:r.decomposition.id}),className:`inline-flex items-center gap-1 rounded-md bg-success/10 px-2 py-1 text-[11px] font-medium text-success hover:bg-success/20`,children:[(0,U.jsx)(b,{size:12}),` Approve`]}),(0,U.jsxs)(`button`,{type:`button`,onClick:()=>t(`kanban.decomposition.reject`,{boardId:e.id,taskId:r.id,proposalId:r.decomposition.id}),className:`inline-flex items-center gap-1 rounded-md bg-destructive/10 px-2 py-1 text-[11px] font-medium text-destructive hover:bg-destructive/20`,children:[(0,U.jsx)(E,{size:12}),` Reject`]})]},r.id))})]}):null}var mt=[`assessed`,`proposed`,`approval`,`applied`];function ht(e){let t=e.decomposition?.status;return t===`applied`?3:t===`approved`||t===`rejected`?2:t===`proposed`?1:e.atomicityAssessment?0:-1}function gt({board:e,task:t,sendKanban:n,onSelectTask:r}){let i=t.decomposition,a=ht(t),o=(0,R.useMemo)(()=>{if(!i)return null;let n=(i.appliedChildTaskIds??[]).map(t=>e.tasks.find(e=>e.id===t)).filter(e=>!!e);return{tasks:[{id:t.id,shortId:`parent`,title:t.title,displayStatus:i.status===`applied`?`completed`:`in_progress`,priority:t.priority,deps:[]},...i.proposedSubtasks.map((e,r)=>{let a=n[r];return{id:a?.id??`proposed-${r}`,shortId:`s${r}`,title:e.title,displayStatus:a?a.status===`completed`?`completed`:a.status===`failed`?`failed`:a.status===`in_progress`?`in_progress`:`pending`:i.status===`approved`?`queued`:`pending`,priority:t.priority,deps:(e.dependsOnIndex??[]).map(e=>`s${e}`)}})],columns:[{label:`Parent`,taskIds:[`parent`]},{label:i.status===`applied`?`Subtasks`:`Proposed subtasks`,taskIds:i.proposedSubtasks.map((e,t)=>`s${t}`)}],appliedChildren:n}},[e,i,t]);return!i&&!t.atomicityAssessment?null:(0,U.jsxs)(`div`,{className:`mt-4 rounded-md border p-3`,children:[(0,U.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-xs font-semibold uppercase text-muted-foreground`,children:[(0,U.jsx)(me,{size:13}),`Decomposition`]}),(0,U.jsxs)(`div`,{className:`mb-2 flex items-center gap-1 text-[11px]`,children:[mt.map((e,t)=>(0,U.jsxs)(`div`,{className:`flex items-center gap-1`,children:[t>0&&(0,U.jsx)(`span`,{className:`text-muted-foreground/50`,children:`→`}),(0,U.jsx)(`span`,{className:P(`rounded px-1.5 py-0.5`,i?.status===`rejected`&&t===2?`bg-destructive/10 text-destructive`:t<=a?`bg-primary/10 font-medium text-primary`:`bg-muted text-muted-foreground`),children:i?.status===`rejected`&&t===2?`rejected`:e})]},e)),t.atomicityAssessment&&(0,U.jsxs)(`span`,{className:`ml-auto text-muted-foreground`,children:[t.atomicityAssessment.verdict,` · score `,t.atomicityAssessment.score]})]}),!i&&t.atomicityAssessment?.verdict===`needs_decomposition`&&(0,U.jsxs)(`div`,{className:`rounded-md border border-warning/30 bg-warning/5 p-2 text-[11px] text-warning`,children:[`This task should be split before dispatch:`,(0,U.jsx)(`ul`,{className:`ml-4 mt-1 list-disc`,children:t.atomicityAssessment.criteria.filter(e=>e.score<1).map(e=>(0,U.jsx)(`li`,{children:e.reason},e.id))})]}),i&&o&&(0,U.jsxs)(U.Fragment,{children:[i.rationale&&(0,U.jsxs)(`div`,{className:`mb-2 text-[11px] text-muted-foreground`,children:[`“`,i.rationale,`”`]}),(0,U.jsx)(`div`,{className:`h-64 overflow-hidden rounded-md border`,children:(0,U.jsx)(Ee,{tasks:o.tasks,columns:o.columns,onTaskClick:t=>{e.tasks.some(e=>e.id===t)&&r(t)}})}),(0,U.jsx)(`ul`,{className:`mt-2 space-y-1 text-[11px]`,children:i.proposedSubtasks.map((e,t)=>(0,U.jsxs)(`li`,{className:`rounded bg-muted/40 px-2 py-1`,children:[(0,U.jsx)(`span`,{className:`font-medium`,children:e.title}),e.successCriteria?.length?(0,U.jsxs)(`span`,{className:`ml-1.5 text-muted-foreground`,children:[`✓ `,e.successCriteria.join(` · `)]}):null]},`${e.title}-${t}`))}),i.status===`proposed`&&(0,U.jsxs)(`div`,{className:`mt-2 flex gap-1.5`,children:[(0,U.jsxs)(`button`,{type:`button`,onClick:()=>n(`kanban.decomposition.approve`,{boardId:e.id,taskId:t.id,proposalId:i.id}),className:`inline-flex items-center gap-1 rounded-md bg-success/10 px-2.5 py-1.5 text-xs font-medium text-success hover:bg-success/20`,children:[(0,U.jsx)(b,{size:13}),` Approve & split`]}),(0,U.jsxs)(`button`,{type:`button`,onClick:()=>n(`kanban.decomposition.reject`,{boardId:e.id,taskId:t.id,proposalId:i.id}),className:`inline-flex items-center gap-1 rounded-md bg-destructive/10 px-2.5 py-1.5 text-xs font-medium text-destructive hover:bg-destructive/20`,children:[(0,U.jsx)(E,{size:13}),` Reject`]})]}),i.status===`applied`&&o.appliedChildren.length>0&&(0,U.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:o.appliedChildren.map(e=>(0,U.jsxs)(`button`,{type:`button`,onClick:()=>r(e.id),className:`rounded-md border px-2 py-1 text-[11px] hover:bg-muted`,children:[e.title,(0,U.jsxs)(`span`,{className:`ml-1 text-muted-foreground`,children:[`[`,e.status,`]`]})]},e.id))}),i.status===`rejected`&&i.resolutionReason&&(0,U.jsxs)(`div`,{className:`mt-2 text-[11px] text-muted-foreground`,children:[`Rejected: `,i.resolutionReason]})]})]})}var _t=[`id`,`name`,`type`];function G(e){if(typeof e==`string`)return e.trim()||void 0;if(typeof e==`number`||typeof e==`boolean`)return String(e);if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e;for(let e of _t){let n=t[e];if(typeof n==`string`&&n.trim())return n.trim()}}function vt(e,t){return t?`running`:e.verificationReport?.verdict||`unverified`}var yt=new Set([`completed`,`review`,`failed`]);function bt(e){let t={totalTasks:e.tasks.length,gradedTasks:0,passed:0,failed:0,needsHuman:0,incomplete:0,unverified:0,failingChecks:[],missingEvidence:[],needsDecomposition:[],pendingProposals:[]};for(let n of e.tasks){if(n.status===`archived`)continue;let e=n.verificationReport;if(yt.has(n.status)&&(t.gradedTasks+=1,e?e.verdict===`passed`?t.passed+=1:e.verdict===`failed`?t.failed+=1:e.verdict===`needs_human`?t.needsHuman+=1:t.incomplete+=1:t.unverified+=1),e)for(let r of e.checks)(r.status===`failed`||r.status===`error`)&&t.failingChecks.push({task:n,check:r}),(r.type===`agent`||r.type===`council`)&&r.status===`passed`&&!r.backingRefs?.length&&t.missingEvidence.push({task:n,check:r});!n.childTaskIds?.length&&n.atomicityAssessment?.verdict===`needs_decomposition`&&n.status!==`completed`&&t.needsDecomposition.push(n),n.decomposition?.status===`proposed`&&t.pendingProposals.push(n)}return t}function xt(e){let t=new Map(e.tasks.map(e=>[e.id,e])),n=new Set,r=(e,i)=>{n.add(e.id);let a=e.childTaskIds??[],o=[];for(let e of a){let a=t.get(e);!a||n.has(a.id)||o.push(r(a,i+1))}return{task:e,children:o,depth:i}},i=[];for(let a of e.tasks)a.parentTaskId&&t.get(a.parentTaskId)||n.has(a.id)||i.push(r(a,0));return i}function St(e){let t=[],n=e=>{t.push(e);for(let t of e.children)n(t)};for(let t of e)n(t);return t}function Ct(e,t){return e?.columns.find(e=>e.id===t)?.title??t}function wt({label:e,value:t}){return(0,U.jsxs)(`div`,{className:`rounded-md border bg-background px-2 py-1.5`,children:[(0,U.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground`,children:e}),(0,U.jsx)(`div`,{className:`mt-0.5 truncate text-xs font-medium`,children:t})]})}function K({label:e,value:t,onChange:n}){return(0,U.jsxs)(`label`,{className:`block`,children:[(0,U.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:e}),(0,U.jsx)(`input`,{value:t,onChange:e=>n(e.target.value),className:`h-8 w-full rounded-md border bg-background px-2 text-sm outline-none focus:border-primary`})]})}function q({label:e,value:t,options:n,placeholder:r,onChange:i}){return(0,U.jsxs)(`label`,{className:`block`,children:[(0,U.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:e}),(0,U.jsxs)(`select`,{value:t,onChange:e=>i(e.target.value),className:`h-8 w-full rounded-md border bg-background px-2 text-sm outline-none focus:border-primary`,children:[r&&(0,U.jsx)(`option`,{value:``,children:r}),n.map(e=>(0,U.jsx)(`option`,{value:e,children:e},e))]})]})}function Tt(e){let t=`rounded px-1.5 py-0.5`;return e===`critical`?`${t} bg-destructive/10 text-destructive`:e===`high`?`${t} bg-warning/10 text-warning`:e===`low`?`${t} bg-muted text-muted-foreground`:`${t} bg-info/10 text-info`}function Et(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function Dt(e){return e===`completed`||e===`failed`||e===`cancelled`}function Ot(e,t){return t?Math.round(e/t*100):0}function kt(e,t,n,r=new Date){let i=[],a=n.filter(e=>e.taskId===t.id),o=a.filter(e=>e.type!==`task.created`),s=o.filter(e=>e.type!==`task.assignment.heartbeat`&&e.type!==`task.assignment.snapshot`),c=s.filter(e=>!!e.note?.trim()),l=t.assignment,u=r.getTime(),d=100,f=(e,t=0)=>{i.some(t=>t.id===e.id)||(i.push(e),d=Math.max(0,d-t))};t.dueDate&&![`completed`,`archived`].includes(t.status)&&Date.parse(t.dueDate)<u&&f({id:`overdue`,severity:`critical`,category:`operational`,title:`Task is overdue`,detail:`Due date ${t.dueDate} has passed while status is ${t.status}.`,remediation:`Re-plan the due date or record the blocker and owner response.`});let p=(t.dependsOn??[]).filter(t=>!e.tasks.some(e=>e.id===t));p.length&&f({id:`missing-dependency`,severity:`critical`,category:`operational`,title:`Dependency references are broken`,detail:`${p.length} dependency task${p.length===1?``:`s`} cannot be found.`,remediation:`Repair or remove the missing dependency IDs before dispatch.`});let m=(t.dependsOn??[]).filter(t=>{let n=e.tasks.find(e=>e.id===t);return n&&![`completed`,`archived`].includes(n.status)});m.length&&f({id:`unresolved-dependency`,severity:`warning`,category:`operational`,title:`Dependencies are unresolved`,detail:`${m.length} dependency task${m.length===1?``:`s`} still block execution.`,remediation:`Complete dependencies or explicitly waive them with a decision event.`}),(l?.status===`failed`||l?.error)&&f({id:`assignment-failed`,severity:`critical`,category:`operational`,title:`Latest agent run failed`,detail:l.error??l.lastFailureKind??`Assignment status is failed.`,remediation:`Review the failed attempt evidence, adjust routing, then retry or block the task.`}),l?.status===`failed`&&l.maxAttempts!==void 0&&(l.attempt??0)>=l.maxAttempts&&f({id:`retry-exhausted`,severity:`critical`,category:`operational`,title:`Retry budget is exhausted`,detail:`${l.attempt??0}/${l.maxAttempts} attempts have been consumed.`,remediation:`Escalate for a new route or explicitly increase the attempt budget.`}),l&&[`queued`,`running`].includes(l.status)&&l.leaseExpiresAt&&Date.parse(l.leaseExpiresAt)<=u&&f({id:`lease-expired`,severity:`critical`,category:`operational`,title:`Assignment lease has expired`,detail:`Lease expired at ${l.leaseExpiresAt} while run status is ${l.status}.`,remediation:`Recover, release, or retry the stale assignment.`}),l?.status===`running`&&l.heartbeatAt&&u-Date.parse(l.heartbeatAt)>5*6e4&&f({id:`heartbeat-stale`,severity:`warning`,category:`operational`,title:`Agent heartbeat is stale`,detail:`No heartbeat has been recorded since ${l.heartbeatAt}.`,remediation:`Inspect the subagent/run and recover the assignment if it is no longer alive.`}),t.status===`in_progress`&&!l&&f({id:`unowned-in-progress`,severity:`warning`,category:`operational`,title:`In-progress task has no assignment`,detail:`The task claims active work but has no inspectable agent assignment.`,remediation:`Assign an agent or return the task to ready/blocked.`});let h=(t.successCriteria??[]).filter(e=>e.status===`failed`),g=(t.successCriteria??[]).filter(e=>e.status===`pending`);h.length&&f({id:`failed-checks`,severity:t.status===`completed`?`critical`:`warning`,category:`operational`,title:`Acceptance checks failed`,detail:`${h.length} completion check${h.length===1?``:`s`} failed.`,remediation:`Resolve or explicitly waive failed acceptance evidence.`}),t.status===`completed`&&g.length&&f({id:`completed-with-pending-checks`,severity:`critical`,category:`operational`,title:`Completed task still has pending checks`,detail:`${g.length} acceptance check${g.length===1?``:`s`} remain pending.`,remediation:`Move the task back to review or complete the missing checks.`}),a.length?a.some(e=>e.type===`task.created`)||f({id:`missing-creation-event`,severity:`warning`,category:`audit`,title:`Creation provenance is missing`,detail:`The loaded event range does not contain task.created.`,remediation:`Load deeper history or record the legacy origin explicitly.`},10):f({id:`no-durable-events`,severity:`critical`,category:`audit`,title:`No durable activity events loaded`,detail:`Current state cannot be traced to an append-only task event.`,remediation:`Refresh activity; migrate legacy state or record an observation event.`},25);let _=Ot(o.filter(e=>!!e.actor).length,o.length),v=Ot(o.filter(e=>!!e.sessionId).length,o.length),y=Ot(c.length,s.length);o.length&&_<100&&f({id:`actor-coverage`,severity:`warning`,category:`audit`,title:`Some mutations have no actor`,detail:`Actor coverage is ${_}%.`,remediation:`Ensure every route/tool mutation supplies agent or operator identity.`},10),o.length&&v<100&&f({id:`session-coverage`,severity:`warning`,category:`audit`,title:`Some mutations have no session`,detail:`Session coverage is ${v}%.`,remediation:`Propagate session identity into all task event contexts.`},10),s.length&&y<50&&f({id:`reason-coverage`,severity:`info`,category:`audit`,title:`Decision rationale is sparse`,detail:`Only ${y}% of mutations include a reason or outcome.`,remediation:`Use the change-reason and decision/outcome fields for meaningful mutations.`},10);let b={...Et([...a].sort((e,t)=>t.ts.localeCompare(e.ts)).find(e=>e.type===`task.assigned`||e.type.startsWith(`task.assignment.`))?.after),...l??{}},x=!!(b.provider||b.model||b.modelRouting);l&&!x&&f({id:`missing-route`,severity:`warning`,category:`audit`,title:`Execution route is not inspectable`,detail:`Assignment has no routing mode, provider, or model.`,remediation:`Reassign with explicit session/fixed/fallback routing metadata.`},10);let S=!!(l?.lastResult||l?.error||a.some(e=>Dt(String(Et(e.after).status??``))&&!!e.note?.trim()));return Dt(l?.status)&&!S&&f({id:`missing-terminal-evidence`,severity:`critical`,category:`audit`,title:`Terminal run has no result or error evidence`,detail:`Assignment ended as ${l?.status} without an inspectable output.`,remediation:`Record the final result/error and supporting evidence.`},15),i.sort((e,t)=>{let n={critical:0,warning:1,info:2};return n[e.severity]-n[t.severity]}),{score:d,findings:i,critical:i.filter(e=>e.severity===`critical`).length,warnings:i.filter(e=>e.severity===`warning`).length,coverage:{durableEvents:a.length,actorPercent:_,sessionPercent:v,reasonPercent:y,hasExecutionRoute:x,hasTerminalEvidence:S}}}function At(e){return e===`critical`?`border-destructive/30 bg-destructive/5 text-destructive`:e===`warning`?`border-warning/30 bg-warning/5 text-warning`:`border-info/30 bg-info/5 text-info`}function jt({board:e,task:t,events:n}){let r=kt(e,t,n),i=we(r.findings,8,t.id);return(0,U.jsxs)(`details`,{open:!0,className:`mt-3 rounded-md border border-border/70 bg-muted/10`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-3 py-2.5 [&::-webkit-details-marker]:hidden`,children:[(0,U.jsx)(u,{className:`size-4 text-primary`}),(0,U.jsx)(`span`,{className:`text-xs font-semibold`,children:`Risk & audit quality`}),(0,U.jsxs)(`span`,{className:`rounded px-1.5 py-0.5 text-[9px] ${r.score>=90?`bg-success/10 text-success`:r.score>=70?`bg-warning/10 text-warning`:`bg-destructive/10 text-destructive`}`,children:[`audit `,r.score,`/100`]}),r.critical>0&&(0,U.jsxs)(`span`,{className:`rounded bg-destructive/10 px-1.5 py-0.5 text-[9px] text-destructive`,children:[r.critical,` critical`]}),(0,U.jsx)(x,{className:`ml-auto size-3.5 text-muted-foreground`})]}),(0,U.jsxs)(`div`,{className:`space-y-2 border-t border-border/60 p-2.5`,children:[(0,U.jsx)(`div`,{className:`grid grid-cols-3 gap-1 text-center sm:grid-cols-6`,children:[[`Events`,r.coverage.durableEvents],[`Actor`,`${r.coverage.actorPercent}%`],[`Session`,`${r.coverage.sessionPercent}%`],[`Reasons`,`${r.coverage.reasonPercent}%`],[`Route`,r.coverage.hasExecutionRoute?`yes`:`no`],[`Outcome`,r.coverage.hasTerminalEvidence?`yes`:`no`]].map(([e,t])=>(0,U.jsxs)(`div`,{className:`rounded border bg-background/70 px-1 py-1.5`,children:[(0,U.jsx)(`div`,{className:`text-[11px] font-semibold`,children:t}),(0,U.jsx)(`div`,{className:`text-[8px] uppercase text-muted-foreground`,children:e})]},String(e)))}),r.findings.length===0?(0,U.jsxs)(`div`,{className:`flex items-center gap-2 rounded border border-success/30 bg-success/5 px-2.5 py-2 text-[11px] text-success`,children:[(0,U.jsx)(v,{className:`size-4`}),` No deterministic task risks detected.`]}):(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[i.pageItems.map(e=>(0,U.jsxs)(`section`,{className:`rounded border px-2.5 py-2 ${At(e.severity)}`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] font-semibold`,children:[e.category===`audit`?(0,U.jsx)(te,{className:`size-3.5`}):(0,U.jsx)(c,{className:`size-3.5`}),e.title,(0,U.jsxs)(`span`,{className:`ml-auto text-[8px] uppercase opacity-75`,children:[e.category,` · `,e.severity]})]}),(0,U.jsx)(`p`,{className:`mt-1 text-[10px] leading-4 opacity-90`,children:e.detail}),(0,U.jsxs)(`p`,{className:`mt-1 text-[9px] leading-4 opacity-75`,children:[(0,U.jsx)(`strong`,{children:`Next:`}),` `,e.remediation]})]},e.id)),(0,U.jsx)(I,{page:i.page,pageSize:i.pageSize,totalItems:i.totalItems,onPageChange:i.setPage,compact:!0,itemLabel:`risk findings`})]})]})]})}function Mt(e,t,n){let r=t.assignment,i=kt(e,t,[]).findings.filter(e=>e.category===`operational`),a=G(r?.provider),o=G(r?.model);return{owner:G(r?.name)??G(r?.agentId)??G(r?.role)??G(t.assignee)??G(t.assignedAgent)??`Unassigned`,route:a||o?`${a?`${a}/`:``}${o??`default`}`:r?.modelRouting===`session`?`session default`:`default route`,blockers:(t.dependsOn??[]).filter(t=>{let n=e.tasks.find(e=>e.id===t);return!n||![`completed`,`archived`].includes(n.status)}).length,attempts:r?.attempt?`${r.attempt}${r.maxAttempts?`/${r.maxAttempts}`:``}`:`0`,fallbackCount:+!!r?.fallbackProfile+(r?.fallbackModels?.length??0),activeUsers:(e.presence??[]).filter(e=>e.taskId===t.id&&e.active).length,failed:t.status===`failed`||r?.status===`failed`||!!r?.error,criticalRisks:i.filter(e=>e.severity===`critical`).length,warningRisks:i.filter(e=>e.severity===`warning`).length,verification:vt(t,n?.[`${e.id}:${t.id}`]),subtaskCounts:(()=>{let n=t.childTaskIds??[];if(!n.length)return null;let r=n.map(t=>e.tasks.find(e=>e.id===t)).filter(e=>!!e);return r.length?{done:r.filter(e=>[`completed`,`review`,`archived`].includes(e.status)).length,total:r.length}:null})(),atomicityVerdict:t.atomicityAssessment?.verdict??null,evidenceCount:t.verificationReport?.attachments.length??0,pendingDecomposition:t.decomposition?.status===`proposed`}}function Nt({board:e,column:t,selectedTaskId:n,dragTaskId:r,setDragTaskId:i,onSelectTask:a,onDeleteTask:o,onMoveTask:s}){let c=xe(e=>e.verificationActivity),l=e.tasks.filter(e=>e.columnId===t.id).sort((e,t)=>e.order-t.order);return(0,U.jsxs)(`section`,{className:P(`flex h-full shrink-0 flex-col rounded-md border bg-muted/25 transition-[width] duration-200`,l.length===0?`w-[180px]`:`w-[310px]`),children:[(0,U.jsxs)(`div`,{className:`flex h-10 shrink-0 items-center gap-2 border-b px-3`,children:[(0,U.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-full`,style:{background:t.color??`hsl(var(--primary))`}}),(0,U.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-sm font-semibold`,children:t.title}),(0,U.jsx)(`span`,{className:`rounded bg-background px-1.5 py-0.5 text-[11px] text-muted-foreground`,children:l.length})]}),(0,U.jsx)(`ul`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto p-2 [scrollbar-gutter:stable]`,onDragOver:e=>e.preventDefault(),onDrop:n=>{n.preventDefault(),e.lifecycle?.mode!==`managed`&&r&&s(r,t.id),i(null)},children:l.map(t=>{let r=Mt(e,t,c);return(0,U.jsxs)(`li`,{draggable:e.lifecycle?.mode!==`managed`,onDragStart:()=>{e.lifecycle?.mode!==`managed`&&i(t.id)},onDragEnd:()=>i(null),className:P(`relative rounded-md border bg-background p-3 shadow-sm transition-colors`,n===t.id?`border-primary`:`hover:border-primary/50`),children:[(0,U.jsx)(`button`,{type:`button`,"aria-label":`Select task: ${t.title}`,onClick:()=>a(t.id),className:`absolute inset-0 cursor-pointer rounded-md`}),(0,U.jsxs)(`div`,{className:`pointer-events-none relative flex items-start gap-2`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(t.atomic||r.atomicityVerdict)&&(0,U.jsx)(`span`,{className:P(`shrink-0 rounded px-1 py-0.5 text-[10px] font-medium`,r.atomicityVerdict===`needs_decomposition`?`bg-destructive/15 text-destructive`:r.atomicityVerdict===`composite`?`bg-info/15 text-info`:r.atomicityVerdict===`borderline`||t.atomic?`bg-warning/15 text-warning`:`bg-muted text-muted-foreground`),title:r.atomicityVerdict?`Atomicity: ${r.atomicityVerdict}`:`Atomic task (subtree verification required)`,children:t.atomic?`atomic`:r.atomicityVerdict===`needs_decomposition`?`split me`:r.atomicityVerdict}),(0,U.jsx)(`span`,{className:`line-clamp-2 text-sm font-medium leading-5`,children:t.title})]}),t.description&&(0,U.jsx)(`div`,{className:`mt-1 line-clamp-2 text-xs leading-4 text-muted-foreground`,children:t.description})]}),(0,U.jsx)(`button`,{type:`button`,title:`Delete task`,"aria-label":`Delete task: ${t.title}`,onClick:()=>o(t),className:`pointer-events-auto relative flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-destructive/10 hover:text-destructive`,children:(0,U.jsx)(ie,{size:14})})]}),(0,U.jsxs)(`div`,{className:`pointer-events-none relative mt-2 flex flex-wrap items-center gap-1.5 text-[11px]`,children:[(0,U.jsx)(`span`,{className:Tt(t.priority),children:t.priority}),(0,U.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-muted-foreground`,children:t.status}),r.owner!==`Unassigned`&&(0,U.jsx)(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 text-primary`,children:r.owner}),t.assignment&&(0,U.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-muted-foreground`,children:r.route}),t.assignment?.attempt?(0,U.jsxs)(`span`,{className:`rounded bg-info/10 px-1.5 py-0.5 text-info`,children:[`attempt `,r.attempts]}):null,r.fallbackCount>0&&(0,U.jsxs)(`span`,{className:`rounded bg-info/10 px-1.5 py-0.5 text-info`,children:[r.fallbackCount,` fallback`]}),r.blockers>0?(0,U.jsxs)(`span`,{className:`rounded bg-warning/10 px-1.5 py-0.5 text-warning`,children:[r.blockers,` blocker`]}):null,r.activeUsers>0&&(0,U.jsxs)(`span`,{className:`rounded bg-success/10 px-1.5 py-0.5 text-success`,children:[r.activeUsers,` active`]}),r.failed&&(0,U.jsx)(`span`,{className:`rounded bg-destructive/10 px-1.5 py-0.5 text-destructive`,children:`run failed`}),r.criticalRisks>0&&(0,U.jsxs)(`span`,{className:`rounded bg-destructive/10 px-1.5 py-0.5 text-destructive`,children:[r.criticalRisks,` critical risk`]}),r.warningRisks>0&&(0,U.jsxs)(`span`,{className:`rounded bg-warning/10 px-1.5 py-0.5 text-warning`,children:[r.warningRisks,` warning`]}),t.chain&&(0,U.jsxs)(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 text-primary`,children:[`chain `,t.chain.order+1]}),t.assignment?.skills?.length?(0,U.jsxs)(`span`,{className:`rounded bg-success/10 px-1.5 py-0.5 text-success`,children:[t.assignment.skills.length,` skills`]}):null,r.verification!==`unverified`&&(0,U.jsxs)(`span`,{className:P(`rounded px-1.5 py-0.5`,r.verification===`passed`?`bg-success/10 text-success`:r.verification===`failed`?`bg-destructive/10 text-destructive`:`bg-warning/10 text-warning`),children:[`✓ `,r.verification]}),r.subtaskCounts&&(0,U.jsxs)(`span`,{className:`rounded bg-info/10 px-1.5 py-0.5 text-info`,children:[r.subtaskCounts.done,`/`,r.subtaskCounts.total,` subtasks`]}),r.evidenceCount>0&&(0,U.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-muted-foreground`,children:[r.evidenceCount,` evidence`]}),r.pendingDecomposition&&(0,U.jsx)(`span`,{className:`rounded bg-warning/10 px-1.5 py-0.5 text-warning`,children:`split pending approval`})]})]},t.id)})})]})}function Pt({queueHealth:e,runningCostTotal:t}){return(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-4 border-b px-4 py-2 text-xs text-muted-foreground`,children:[(0,U.jsx)(`span`,{className:`font-medium text-foreground`,children:`Queue health`}),e.counts.ready>0&&(0,U.jsxs)(`span`,{title:`Claimable tasks`,className:`inline-flex items-center gap-1 text-success`,children:[e.counts.ready,` ready`]}),e.counts.running>0&&(0,U.jsxs)(`span`,{title:`Running assignments`,className:`inline-flex items-center gap-1 text-warning`,children:[e.counts.running,` running`]}),e.counts.review>0&&(0,U.jsxs)(`span`,{title:`In review`,className:`inline-flex items-center gap-1 text-primary`,children:[e.counts.review,` review`]}),e.counts.blocked>0&&(0,U.jsxs)(`span`,{title:`Manually blocked`,className:`inline-flex items-center gap-1 text-destructive`,children:[e.counts.blocked,` blocked`]}),e.counts.failed>0&&(0,U.jsxs)(`span`,{title:`Failed tasks`,className:`inline-flex items-center gap-1 text-destructive`,children:[e.counts.failed,` failed`]}),e.dependencyBlocked.count>0&&(0,U.jsxs)(`span`,{title:`Ready/pending tasks blocked by dependencies`,className:`inline-flex items-center gap-1 rounded bg-warning/10 px-1.5 py-0.5 text-warning`,children:[e.dependencyBlocked.count,` blocked by deps`]}),e.staleAssignments.count>0&&(0,U.jsxs)(`span`,{title:`Expired lease assignments`,className:`inline-flex items-center gap-1 rounded bg-destructive/10 px-1.5 py-0.5 text-destructive`,children:[e.staleAssignments.count,` stale`]}),e.heartbeatDue.count===0&&e.staleAssignments.count===0&&e.dependencyBlocked.count===0&&(0,U.jsx)(`span`,{className:`text-success`,children:`healthy`}),t>0&&(0,U.jsxs)(`span`,{title:`Sum of costCeilingUsd for running/queued tasks`,className:`inline-flex items-center gap-1 text-info`,children:[`~$`,t.toFixed(2),` running cost`]})]})}function Ft({runLink:e,sendRaw:t}){let i=e.engine===`sdd`,a=i?`sdd.board`:`goal`,o=N(e=>e.setCurrentView),s=`inline-flex items-center gap-1 rounded-md border px-2 py-1 text-[11px] font-medium hover:bg-muted`;return(0,U.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b bg-primary/5 px-4 py-1.5`,children:[(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-primary/15 px-1.5 py-0.5 text-[10px] font-semibold uppercase text-primary`,children:[(0,U.jsx)(se,{size:11}),` `,e.engine]}),(0,U.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Live run — steer it from here`}),i&&(0,U.jsxs)(`button`,{type:`button`,className:s,title:`Open the live run view (SDD Hub)`,onClick:()=>o(`sddhub`),children:[(0,U.jsx)(se,{size:12}),` Open live run`]}),(0,U.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,U.jsxs)(`button`,{type:`button`,className:s,onClick:()=>t(`${a}.pause`),children:[(0,U.jsx)(r,{size:12}),` Pause`]}),(0,U.jsxs)(`button`,{type:`button`,className:s,onClick:()=>t(`${a}.resume`),children:[(0,U.jsx)(p,{size:12}),` Resume`]}),i&&(0,U.jsxs)(`button`,{type:`button`,className:s,onClick:()=>t(`sdd.board.retry_all_failed`),children:[(0,U.jsx)(D,{size:12}),` Retry failed`]}),(0,U.jsxs)(`button`,{type:`button`,className:P(s,`text-destructive hover:bg-destructive/10`),onClick:()=>t(`${a}.stop`),children:[(0,U.jsx)(n,{size:12}),` Stop`]})]})]})}function It({boardId:e,sendKanban:t}){let n=`inline-flex items-center gap-1 rounded-md border px-2 py-1 text-[11px] font-medium text-primary hover:bg-primary/10`;return(0,U.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b bg-muted/30 px-4 py-1.5`,children:[(0,U.jsx)(se,{size:13,className:`text-primary`}),(0,U.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Run this board as a live agent job:`}),(0,U.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,U.jsx)(`button`,{type:`button`,className:n,onClick:()=>t(`kanban.run.start`,{boardId:e,engine:`goal`}),children:`Start as Goal`}),(0,U.jsx)(`button`,{type:`button`,className:n,onClick:()=>t(`kanban.run.start`,{boardId:e,engine:`sdd`}),children:`Start as SDD`})]})]})}function Lt({runLink:e,runTaskId:t,modelCandidates:r,sendRaw:i}){let a=e.engine===`sdd`,[o,s]=(0,R.useState)(!1),[c,l]=(0,R.useState)(``),u=`inline-flex flex-1 items-center justify-center gap-1 rounded-md border py-1.5 text-xs font-medium hover:bg-muted`,d=()=>{let e=c.trim();e&&(i(a?`sdd.board.reassign`:`goal.assignTask`,{taskId:t,agentName:e}),s(!1),l(``))};return(0,U.jsxs)(`div`,{className:`mt-4 rounded-md border bg-primary/5 p-2.5`,children:[(0,U.jsx)(`div`,{className:`mb-2 text-[10px] font-semibold uppercase tracking-wide text-primary`,children:`Run controls`}),a&&(0,U.jsxs)(`div`,{className:`mb-2`,children:[(0,U.jsx)(`div`,{className:`mb-1 text-[10px] uppercase text-muted-foreground`,children:`Worker model`}),(0,U.jsx)(Ce,{candidates:r,placeholder:`Set model for this task…`,onPick:(e,n)=>i(`sdd.board.set_task_model`,{taskId:t,model:e,provider:n})})]}),o?(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,U.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&d(),e.key===`Escape`&&s(!1)},placeholder:`New worker name`,className:`min-w-0 flex-1 rounded-md border bg-background px-2 py-1.5 text-xs outline-none focus:border-primary`}),(0,U.jsx)(`button`,{type:`button`,onClick:d,className:`rounded-md bg-primary/10 px-2 py-1.5 text-primary`,children:(0,U.jsx)(b,{size:14})}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>s(!1),className:`rounded-md bg-muted px-2 py-1.5`,children:(0,U.jsx)(E,{size:14})})]}):(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,U.jsxs)(`button`,{type:`button`,className:u,onClick:()=>i(a?`sdd.board.retry`:`goal.retryTask`,{taskId:t}),children:[(0,U.jsx)(D,{size:13}),` Retry`]}),(0,U.jsxs)(`button`,{type:`button`,className:u,onClick:()=>s(!0),children:[(0,U.jsx)(m,{size:13}),` Reassign`]}),a?(0,U.jsxs)(`button`,{type:`button`,className:P(u,`text-destructive hover:bg-destructive/10`),onClick:()=>i(`sdd.board.cancel_task`,{taskId:t}),children:[(0,U.jsx)(n,{size:13}),` Cancel`]}):(0,U.jsxs)(`button`,{type:`button`,className:u,onClick:()=>i(`goal.runTask`,{taskId:t}),children:[(0,U.jsx)(p,{size:13}),` Run now`]})]})]})}var Rt={unverified:{label:`unverified`,className:`bg-muted text-muted-foreground`,icon:C},running:{label:`verifying…`,className:`bg-info/10 text-info`,icon:ae},passed:{label:`verified`,className:`bg-success/10 text-success`,icon:w},failed:{label:`verification failed`,className:`bg-destructive/10 text-destructive`,icon:ue},needs_human:{label:`needs review`,className:`bg-warning/10 text-warning`,icon:c},incomplete:{label:`incomplete`,className:`bg-warning/10 text-warning`,icon:c}};function zt({task:e}){return e.status===`completed`?(0,U.jsx)(b,{size:13,className:`text-success`}):e.status===`failed`?(0,U.jsx)(E,{size:13,className:`text-destructive`}):e.status===`in_progress`?(0,U.jsx)(ae,{size:13,className:`animate-spin text-info`}):(0,U.jsx)(t,{size:13,className:`text-muted-foreground`})}function Bt({board:e,selectedTaskId:t,onSelectTask:n}){let r=xe(e=>e.verificationActivity),i=(0,R.useMemo)(()=>St(xt(e)),[e]);return i.length?(0,U.jsx)(`div`,{className:`h-full overflow-y-auto p-4`,children:(0,U.jsx)(`ul`,{className:`space-y-0.5`,children:i.map(({task:i,depth:a,children:o})=>{let s=Rt[vt(i,r[`${e.id}:${i.id}`])],c=s.icon,l=i.atomicityAssessment?.verdict;return(0,U.jsx)(`li`,{children:(0,U.jsxs)(`button`,{type:`button`,onClick:()=>n(i.id),style:{paddingLeft:`${a*22+8}px`},className:P(`flex w-full items-center gap-2 rounded-md border py-1.5 pr-2 text-left text-xs transition-colors`,t===i.id?`border-primary bg-primary/5`:`border-transparent hover:border-primary/40 hover:bg-muted/40`),children:[o.length>0?(0,U.jsx)(ce,{size:12,className:`shrink-0 text-muted-foreground`}):(0,U.jsx)(`span`,{className:`w-3 shrink-0`}),(0,U.jsx)(zt,{task:i}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:i.title}),i.atomic&&(0,U.jsx)(`span`,{className:`shrink-0 rounded bg-warning/15 px-1 py-0.5 text-[10px] text-warning`,children:`atomic`}),l&&l!==`atomic`&&(0,U.jsx)(`span`,{className:P(`shrink-0 rounded px-1 py-0.5 text-[10px]`,l===`needs_decomposition`?`bg-destructive/15 text-destructive`:l===`composite`?`bg-info/15 text-info`:`bg-warning/15 text-warning`),children:l===`needs_decomposition`?`split me`:l}),i.decomposition?.status===`proposed`&&(0,U.jsx)(`span`,{className:`shrink-0 rounded bg-warning/10 px-1 py-0.5 text-[10px] text-warning`,children:`proposal pending`}),(0,U.jsxs)(`span`,{className:P(`inline-flex shrink-0 items-center gap-1 rounded px-1.5 py-0.5 text-[10px]`,s.className),children:[(0,U.jsx)(c,{size:11,className:s.label===`verifying…`?`animate-spin`:void 0}),s.label]})]})},i.id)})})}):(0,U.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`No tasks on this board yet.`})}function Vt({label:e,value:t,tone:n}){return(0,U.jsxs)(`div`,{className:`rounded-md border bg-background p-3`,children:[(0,U.jsx)(`div`,{className:P(`text-xl font-bold`,n===`success`&&`text-success`,n===`destructive`&&`text-destructive`,n===`warning`&&`text-warning`,n===`muted`&&`text-muted-foreground`),children:t}),(0,U.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:e})]})}function Ht({title:e,icon:t,tone:n,rows:r,onSelectTask:i}){return r.length?(0,U.jsxs)(`div`,{className:`rounded-md border bg-background`,children:[(0,U.jsxs)(`div`,{className:P(`flex items-center gap-2 border-b px-3 py-2 text-xs font-semibold`,n),children:[(0,U.jsx)(t,{size:14}),e,(0,U.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:r.length})]}),(0,U.jsx)(`ul`,{className:`divide-y`,children:r.map(e=>(0,U.jsx)(`li`,{children:(0,U.jsxs)(`button`,{type:`button`,onClick:()=>i(e.taskId),className:`flex w-full flex-col items-start gap-0.5 px-3 py-2 text-left text-xs hover:bg-muted/40`,children:[(0,U.jsx)(`span`,{className:`font-medium`,children:e.primary}),e.secondary&&(0,U.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:e.secondary})]})},e.id))})]}):null}function Ut({board:e,onSelectTask:t}){let n=(0,R.useMemo)(()=>bt(e),[e]);return(0,U.jsxs)(`div`,{className:`h-full space-y-4 overflow-y-auto p-4`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-4 rounded-md border bg-background p-4`,children:[(0,U.jsx)(L,{pct:n.gradedTasks?n.passed/n.gradedTasks*100:0}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`div`,{className:`text-sm font-semibold`,children:`Definition of Done`}),(0,U.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[n.passed,` of `,n.gradedTasks,` graded tasks verified passed ·`,` `,n.totalTasks,` tasks total`]})]})]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-5`,children:[(0,U.jsx)(Vt,{label:`verified`,value:n.passed,tone:`success`}),(0,U.jsx)(Vt,{label:`failed`,value:n.failed,tone:`destructive`}),(0,U.jsx)(Vt,{label:`needs human`,value:n.needsHuman,tone:`warning`}),(0,U.jsx)(Vt,{label:`incomplete`,value:n.incomplete,tone:`warning`}),(0,U.jsx)(Vt,{label:`unverified`,value:n.unverified,tone:`muted`})]}),(0,U.jsx)(Ht,{title:`Failing checks`,icon:ue,tone:`text-destructive`,onSelectTask:t,rows:n.failingChecks.map(({task:e,check:t})=>({id:`${e.id}:${t.checkId}`,taskId:e.id,primary:e.title,secondary:`${t.description}${t.error?` — ${t.error}`:``}`}))}),(0,U.jsx)(Ht,{title:`Evidence missing (agent/council checks without backing refs)`,icon:c,tone:`text-warning`,onSelectTask:t,rows:n.missingEvidence.map(({task:e,check:t})=>({id:`${e.id}:${t.checkId}`,taskId:e.id,primary:e.title,secondary:t.description}))}),(0,U.jsx)(Ht,{title:`Needs decomposition`,icon:me,tone:`text-warning`,onSelectTask:t,rows:n.needsDecomposition.map(e=>({id:e.id,taskId:e.id,primary:e.title,secondary:`atomicity score ${e.atomicityAssessment?.score??`?`} — split before dispatch`}))}),(0,U.jsx)(Ht,{title:`Decomposition proposals awaiting approval`,icon:C,tone:`text-info`,onSelectTask:t,rows:n.pendingProposals.map(e=>({id:e.id,taskId:e.id,primary:e.title,secondary:`${e.decomposition?.proposedSubtasks.length??0} proposed subtasks`}))}),n.failingChecks.length===0&&n.missingEvidence.length===0&&n.needsDecomposition.length===0&&n.pendingProposals.length===0&&(0,U.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-success/30 bg-success/5 p-3 text-xs text-success`,children:[(0,U.jsx)(w,{size:14}),`No outstanding verification or decomposition issues on this board.`]})]})}var Wt={assigned:`bg-info/10 text-info`,queued:`bg-info/10 text-info`,running:`bg-warning/10 text-warning`,completed:`bg-success/10 text-success`,failed:`bg-destructive/10 text-destructive`,cancelled:`bg-muted text-muted-foreground`};function Gt(e,t){if(!e)return null;let n=Date.parse(e);if(Number.isNaN(n))return null;let r=t?Date.parse(t):Date.now();if(Number.isNaN(r))return null;let i=Math.max(0,Math.round((r-n)/1e3));if(i<60)return`${i}s`;let a=Math.floor(i/60);return a<60?`${a}m ${i%60}s`:`${Math.floor(a/60)}h ${a%60}m`}function Kt({assignment:e}){let t=e.status===`running`,n=Gt(e.dispatchedAt,e.completedAt),r=G(e.name)??G(e.agentId),i=G(e.role),a=G(e.provider),o=G(e.model),s=[];return r&&s.push({label:`Agent`,value:r}),i&&s.push({label:`Role`,value:i}),e.modelRouting&&s.push({label:`Model source`,value:e.modelRouting}),(a||o)&&s.push({label:`Model`,value:(0,U.jsxs)(`span`,{className:`font-mono text-[11px]`,children:[a?`${a}/`:``,o??`—`]})}),e.subagentId&&s.push({label:`Subagent`,value:(0,U.jsx)(`span`,{className:`font-mono text-[11px]`,children:e.subagentId})}),n&&s.push({label:e.completedAt?`Duration`:`Elapsed`,value:n}),typeof e.attempt==`number`&&s.push({label:`Attempt`,value:`${e.attempt}${e.maxAttempts?` / ${e.maxAttempts}`:``}`}),e.costCeilingUsd&&s.push({label:`Cost ceiling`,value:`$${e.costCeilingUsd.toFixed(2)}`}),e.fallbackProfile&&s.push({label:`Fallback profile`,value:e.fallbackProfile}),e.fallbackModels?.length&&s.push({label:`Fallbacks`,value:e.fallbackModels.join(` → `)}),e.skills?.length&&s.push({label:`Skills`,value:e.skills.join(`, `)}),e.tools?.length&&s.push({label:`Tools`,value:e.tools.join(`, `)}),e.leaseExpiresAt&&s.push({label:`Lease expires`,value:new Date(e.leaseExpiresAt).toLocaleString()}),(0,U.jsxs)(`div`,{className:`mt-4 rounded-md border bg-background p-2.5`,children:[(0,U.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:`Live run`}),(0,U.jsxs)(`span`,{className:P(`ml-auto inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium capitalize`,Wt[e.status]??`bg-muted text-muted-foreground`),children:[t&&(0,U.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse rounded-full bg-current`,"aria-hidden":!0}),e.status]})]}),s.length>0&&(0,U.jsx)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-xs`,children:s.map(e=>(0,U.jsxs)(`div`,{className:`contents`,children:[(0,U.jsx)(`dt`,{className:`text-muted-foreground`,children:e.label}),(0,U.jsx)(`dd`,{className:`min-w-0 truncate text-right text-foreground`,children:e.value})]},e.label))}),e.lastResult&&(0,U.jsxs)(`div`,{className:`mt-2`,children:[(0,U.jsx)(`div`,{className:`mb-1 text-[10px] uppercase text-muted-foreground`,children:`Last result`}),(0,U.jsx)(`div`,{className:`max-h-24 overflow-y-auto whitespace-pre-wrap rounded bg-muted px-2 py-1 text-[11px] leading-relaxed text-foreground`,children:e.lastResult})]}),e.error&&(0,U.jsx)(`div`,{className:`mt-2 rounded border border-destructive/30 bg-destructive/10 px-2 py-1 text-[11px] text-destructive`,children:e.error})]})}function qt({activityKind:e,activityOutcome:t,note:n,details:r,onActivityKindChange:i,onActivityOutcomeChange:a,onNoteChange:o,onDetailsChange:s,onRecordActivity:c}){return(0,U.jsxs)(`div`,{className:`mt-4`,children:[(0,U.jsx)(`div`,{className:`mb-2 text-xs font-semibold uppercase text-muted-foreground`,children:`Record decision / outcome`}),(0,U.jsxs)(`div`,{className:`mb-1.5 grid grid-cols-2 gap-1.5`,children:[(0,U.jsx)(`select`,{value:e,onChange:e=>i(e.target.value),"aria-label":`Task activity kind`,className:`h-8 rounded-md border bg-background px-2 text-xs`,children:[`decision`,`attempt`,`result`,`blocker`,`observation`].map(e=>(0,U.jsx)(`option`,{value:e,children:e},e))}),(0,U.jsx)(`select`,{value:t,onChange:e=>a(e.target.value),"aria-label":`Task activity outcome`,className:`h-8 rounded-md border bg-background px-2 text-xs`,children:[`unknown`,`succeeded`,`failed`,`partial`,`skipped`].map(e=>(0,U.jsx)(`option`,{value:e,children:e},e))})]}),(0,U.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,U.jsx)(`input`,{value:n,onChange:e=>o(e.target.value),onKeyDown:e=>e.key===`Enter`&&c(),placeholder:`What was decided, attempted, or produced?`,className:`h-8 min-w-0 flex-1 rounded-md border bg-background px-2 text-xs outline-none focus:border-primary`}),(0,U.jsx)(`button`,{type:`button`,onClick:c,className:`h-8 rounded-md border px-2 hover:bg-muted`,"aria-label":`Record task decision or outcome`,children:(0,U.jsx)(M,{size:14})})]}),(0,U.jsx)(`input`,{value:r,onChange:e=>s(e.target.value),placeholder:`Optional evidence, rationale, command, link, or failure detail…`,"aria-label":`Task activity details`,className:`mt-1.5 h-8 w-full rounded-md border bg-background px-2 text-xs outline-none focus:border-primary`})]})}function Jt({board:e,task:t,newCheck:n,onNewCheckChange:r,onAddCheck:i,sendKanban:a}){return(0,U.jsxs)(`div`,{className:`mt-5`,children:[(0,U.jsx)(`div`,{className:`mb-2 text-xs font-semibold uppercase text-muted-foreground`,children:`Completion checks`}),(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(t.successCriteria??[]).map(n=>(0,U.jsxs)(`div`,{className:`grid grid-cols-[auto_1fr_92px] items-center gap-2 rounded-md border bg-background px-2 py-1.5 text-xs`,children:[(0,U.jsx)(b,{size:13,className:n.status===`passed`?`text-success`:`text-muted-foreground`}),(0,U.jsx)(`span`,{className:`min-w-0 truncate`,children:n.description}),(0,U.jsx)(`select`,{value:n.status,onChange:r=>a(`kanban.task.check.update`,{boardId:e?.id,taskId:t.id,checkId:n.id,status:r.target.value}),className:`h-7 rounded border bg-background px-1 text-[11px]`,children:[`pending`,`passed`,`failed`,`skipped`].map(e=>(0,U.jsx)(`option`,{value:e,children:e},e))})]},n.id)),(0,U.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,U.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),onKeyDown:e=>e.key===`Enter`&&i(),placeholder:`Add a verifiable completion check…`,className:`h-8 min-w-0 flex-1 rounded-md border bg-background px-2 text-xs outline-none focus:border-primary`}),(0,U.jsx)(`button`,{type:`button`,onClick:i,className:`h-8 rounded-md border px-2 hover:bg-muted`,children:(0,U.jsx)(M,{size:14})})]})]})]})}var Yt=[`architect`,`developer`,`reviewer`,`tester`,`verifier`,`security`,`documenter`,`external`,`leader`,`shadow`,`subagent`],Xt=[{value:`fs.read`,label:`Read files`,description:`fs.read`},{value:`fs.write`,label:`Write files (in project)`,description:`fs.write`},{value:`fs.write.outside-project`,label:`Write outside project`,description:`fs.write.outside-project`},{value:`net.outbound`,label:`Outbound network`,description:`net.outbound`},{value:`shell.exec`,label:`Run project commands`,description:`shell.exec`},{value:`shell.restricted`,label:`Restricted shell`,description:`shell.restricted`},{value:`shell.arbitrary`,label:`Arbitrary shell`,description:`shell.arbitrary`},{value:`session.todo`,label:`Session todos`,description:`session.todo`},{value:`tool.meta`,label:`Tool metadata`,description:`tool.meta`},{value:`tool.mutate.any`,label:`Invoke any tool`,description:`tool.mutate.any`},{value:`memory.read`,label:`Read memory`,description:`memory.read`},{value:`memory.write`,label:`Write memory`,description:`memory.write`},{value:`package.install`,label:`Install packages`,description:`package.install`},{value:`subagent.spawn`,label:`Spawn subagents`,description:`subagent.spawn`},{value:`config.mutate`,label:`Mutate config / trust`,description:`config.mutate`}];function Zt(e,t,n,r=new Date().toISOString()){return{format:`wrongstack-kanban-task-activity`,version:1,exportedAt:r,scope:n,task:e,events:t}}function J(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function Y(e){return typeof e==`string`&&e.trim()?e.trim():void 0}function Qt(e){return e.type.startsWith(`task.file.`)?e.type===`task.file.read`?`execution`:`changes`:e.type.startsWith(`task.activity.`)?Y(J(e.after).outcome)===`failed`?`failures`:e.type===`task.activity.attempt`?`execution`:`notes`:e.type.includes(`failed`)||e.type.includes(`cancelled`)?`failures`:e.type===`task.assigned`||e.type===`task.claimed`||e.type===`task.released`||e.type.startsWith(`task.assignment.`)||e.type===`task.stale_recovered`?`execution`:e.type.includes(`note`)||e.type.includes(`check`)||e.type.includes(`metric`)?`notes`:`changes`}function $t(e){let t=J(e.before),n=J(e.after);return[...new Set([...Object.keys(t),...Object.keys(n)])].filter(e=>JSON.stringify(t[e])!==JSON.stringify(n[e])).map(e=>({field:e,before:t[e],after:n[e]}))}function en(e){if(e.type.startsWith(`task.file.`))return`File ${e.type.slice(10)}`.replace(/\b\w/g,e=>e.toUpperCase());if(e.type.startsWith(`task.activity.`))return`Recorded ${e.type.slice(14)}`.replace(/\b\w/g,e=>e.toUpperCase());switch(e.type){case`task.created`:return`Task created`;case`task.copied`:return`Task copied`;case`task.updated`:return`Task contract updated`;case`task.moved`:return`Task moved`;case`task.assigned`:return`Agent assigned`;case`task.claimed`:return`Task claimed`;case`task.released`:return`Assignment released`;case`task.assignment.updated`:return`Assignment updated`;case`task.assignment.running`:return`Agent started work`;case`task.assignment.completed`:return`Agent completed work`;case`task.assignment.failed`:return`Agent run failed`;case`task.assignment.cancelled`:return`Agent run cancelled`;case`task.assignment.heartbeat`:return`Agent heartbeat`;case`task.note.added`:return`Operator note added`;case`task.check.added`:return`Acceptance check added`;case`task.check.updated`:return`Acceptance check updated`;case`task.metric.added`:return`Goal metric added`;case`task.metric.updated`:return`Goal metric updated`;case`task.lifecycle.transition`:return`Lifecycle advanced`;case`task.assignment.snapshot`:return`Current assignment observed`;case`task.stale_recovered`:return`Stale assignment recovered`;case`task.reconciled`:return`Task state reconciled`;default:return e.type.replace(/^task\./,``).replaceAll(`.`,` `).replace(/\b\w/g,e=>e.toUpperCase())}}function tn(e){let t=J(e.before),n=J(e.after);if(e.type.startsWith(`task.file.`)){let e=Y(n.filePath),t=Y(n.toolName),r=typeof n.durationMs==`number`?n.durationMs:void 0,i=typeof n.lines==`number`?n.lines:void 0;return[e,t?`tool:${t}`:void 0,r===void 0?void 0:`${r}ms`,i===void 0?void 0:`${i} lines`].filter(Boolean).join(` · `)||void 0}if(e.type.startsWith(`task.activity.`))return[Y(n.outcome),Y(n.details)].filter(Boolean).join(` · `)||void 0;if(e.type===`task.moved`){let e=Y(t.columnId),r=Y(n.columnId);if(e||r)return`${e??`unknown`} → ${r??`unknown`}`}if(e.type===`task.updated`){let t=$t(e);if(t.length)return`${t.length} field${t.length===1?``:`s`} changed: ${t.map(e=>e.field).join(`, `)}`}if(e.type===`task.lifecycle.transition`){let e=Y(t.stage),r=Y(n.stage);if(r)return e?`${e} → ${r}`:`Entered ${r}`}if(e.type===`task.assigned`||e.type===`task.assignment.snapshot`){let e=Y(n.name)??Y(n.agentId)??Y(n.role),t=Y(n.provider),r=Y(n.model);return[e,t||r?`${t?`${t}/`:``}${r??`default`}`:void 0].filter(Boolean).join(` · `)||void 0}if(e.type.startsWith(`task.check.`))return[Y(n.description),Y(n.status)].filter(Boolean).join(` · `)||void 0;if(e.type.startsWith(`task.metric.`))return[Y(n.name),Y(n.status)].filter(Boolean).join(` · `)||void 0}function nn(e){let t=e.type;return Y(J(e.after).outcome)===`failed`||t.includes(`failed`)||t.includes(`cancelled`)?`bg-destructive ring-destructive/20`:t.includes(`completed`)||t.includes(`reconciled`)?`bg-success ring-success/20`:t.includes(`running`)||t.includes(`claimed`)||t.includes(`assigned`)?`bg-info ring-info/20`:t.includes(`note`)?`bg-warning ring-warning/20`:`bg-primary ring-primary/20`}function rn(e){let t=Date.parse(e);return Number.isFinite(t)?new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`}).format(t):e}function an(e){if(e===void 0)return`unset`;if(e===null)return`none`;if(typeof e==`string`)return e||`empty`;if(typeof e==`number`||typeof e==`boolean`)return String(e);try{return JSON.stringify(e)}catch{return String(e)}}function on(e,t,n){let r=t.filter(t=>t.taskId===e.id).map(e=>({...e}));(e=>r.some(t=>t.type===e))(`task.created`)||r.push({id:`created:${e.id}`,boardId:``,taskId:e.id,type:`task.created`,ts:e.createdAt,...n?{sessionId:n}:{},after:{title:e.title,status:`created`,columnId:e.columnId}});for(let[t,i]of(e.lifecycle?.history??[]).entries())r.some(e=>e.type===`task.lifecycle.transition`&&e.ts===i.at&&e.actor===i.actor)||r.push({id:`lifecycle:${e.id}:${t}`,boardId:``,taskId:e.id,type:`task.lifecycle.transition`,ts:i.at,actor:i.actor,...n?{sessionId:n}:{},before:i.from?{stage:i.from}:void 0,after:{stage:i.to,action:i.action,attachment:i.attachment},note:i.comment});for(let t of e.notes??[])r.some(e=>e.type===`task.note.added`&&e.note===t.content&&Math.abs(Date.parse(e.ts)-Date.parse(t.createdAt))<2e3)||r.push({id:`note:${t.id}`,boardId:``,taskId:e.id,type:`task.note.added`,ts:t.createdAt,actor:t.author,...n?{sessionId:n}:{},note:t.content});let i=r.some(e=>e.type===`task.assigned`||e.type===`task.claimed`||e.type.startsWith(`task.assignment.`));return e.assignment&&!i&&r.push({id:`assignment:${e.id}`,boardId:``,taskId:e.id,type:`task.assignment.snapshot`,ts:e.assignment.completedAt??e.assignment.dispatchedAt??e.assignment.claimedAt??e.updatedAt,actor:e.assignment.agentId??e.assignment.name??e.assignment.role,...n?{sessionId:n}:{},subagentId:e.assignment.subagentId,runTaskId:e.assignment.runTaskId,after:{...e.assignment},note:e.assignment.error??e.assignment.lastResult}),r.sort((e,t)=>t.ts.localeCompare(e.ts))}function sn({event:e}){let t=J(e.after),n=Y(t.provider),r=Y(t.model),i=Y(t.modelRouting),a=Y(t.fallbackProfile),o=Array.isArray(t.fallbackModels)?t.fallbackModels.filter(e=>typeof e==`string`):[],s=typeof t.attempt==`number`?t.attempt:void 0,c=typeof t.maxAttempts==`number`?t.maxAttempts:void 0,l=Y(t.status);return!n&&!r&&!i&&!a&&!o.length&&s===void 0&&!l?null:(0,U.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap gap-1 font-mono text-[9px] text-muted-foreground`,children:[l&&(0,U.jsxs)(`span`,{className:`rounded border border-border/60 px-1.5 py-0.5`,children:[`status:`,l]}),i&&(0,U.jsxs)(`span`,{className:`rounded border border-border/60 px-1.5 py-0.5`,children:[`route:`,i]}),(n||r)&&(0,U.jsxs)(`span`,{className:`rounded border border-border/60 px-1.5 py-0.5`,children:[`model:`,n?`${n}/`:``,r??`default`]}),a&&(0,U.jsxs)(`span`,{className:`rounded border border-border/60 px-1.5 py-0.5`,children:[`profile:`,a]}),o.map((e,t)=>(0,U.jsxs)(`span`,{className:`rounded border border-border/60 px-1.5 py-0.5`,children:[`fallback-`,t+1,`:`,e]},`${e}:${t}`)),s!==void 0&&(0,U.jsxs)(`span`,{className:`rounded border border-border/60 px-1.5 py-0.5`,children:[`attempt:`,s,c?`/${c}`:``]})]})}function cn({task:e,events:t,sessionId:n,loading:r=!1,error:i,onRefresh:a}){let[o,s]=(0,R.useState)(`all`),[c,l]=(0,R.useState)(``),[u,d]=(0,R.useState)(!1),f=(0,R.useMemo)(()=>on(e,t,n),[e,t,n]),p=(0,R.useMemo)(()=>({all:f.length,execution:f.filter(e=>Qt(e)===`execution`).length,changes:f.filter(e=>Qt(e)===`changes`).length,notes:f.filter(e=>Qt(e)===`notes`).length,failures:f.filter(e=>Qt(e)===`failures`).length}),[f]),m=(0,R.useMemo)(()=>{let e=c.trim().toLowerCase();return f.filter(t=>o!==`all`&&Qt(t)!==o?!1:!e||[en(t),t.type,t.actor,t.sessionId,t.subagentId,t.runTaskId,t.note,JSON.stringify(t.before),JSON.stringify(t.after)].filter(Boolean).join(` `).toLowerCase().includes(e))},[f,o,c]),g=we(m,50,`${o}:${c}`),_=g.pageItems,v=[...new Set(f.map(e=>e.actor).filter(Boolean))].length,y=[...new Set(f.map(e=>e.sessionId??n).filter(Boolean))].length;return(0,U.jsxs)(`section`,{"aria-label":`Task activity`,className:`mt-5`,children:[(0,U.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,U.jsx)(h,{className:`size-3.5 text-primary`}),(0,U.jsx)(`h3`,{className:`text-xs font-semibold uppercase text-muted-foreground`,children:`Activity ledger`}),(0,U.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-[10px] tabular-nums text-muted-foreground`,children:[m.length,`/`,f.length]}),(0,U.jsxs)(`div`,{className:`ml-auto flex items-center gap-0.5`,children:[(0,U.jsx)(`button`,{type:`button`,onClick:async()=>{try{await navigator.clipboard.writeText(JSON.stringify(Zt(e,m,`filtered`),null,2)),d(!0)}catch{d(!1)}},className:`flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground`,"aria-label":`Copy visible task activity JSON`,title:`Copy filtered activity JSON`,children:u?(0,U.jsx)(b,{className:`size-3 text-success`}):(0,U.jsx)(_e,{className:`size-3`})}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>{let t=JSON.stringify(Zt(e,f,`full`),null,2),n=URL.createObjectURL(new Blob([t],{type:`application/json`})),r=document.createElement(`a`);r.href=n,r.download=`${e.title.replace(/[^a-z0-9]+/gi,`-`).replace(/^-|-$/g,``).toLowerCase()||e.id}-activity.json`,r.click(),URL.revokeObjectURL(n)},className:`flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground`,"aria-label":`Download full task activity JSON`,title:`Download full activity JSON`,children:(0,U.jsx)(oe,{className:`size-3`})}),a&&(0,U.jsx)(`button`,{type:`button`,onClick:a,className:`flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground`,"aria-label":`Refresh task activity`,children:(0,U.jsx)(O,{className:P(`size-3`,r&&`animate-spin`)})})]})]}),(0,U.jsx)(`div`,{className:`mb-2 grid grid-cols-4 gap-px overflow-hidden rounded-md border border-border/60 bg-border/60 text-center`,children:[[`Events`,f.length],[`Actors`,v],[`Sessions`,y],[`Failures`,p.failures]].map(([e,t])=>(0,U.jsxs)(`div`,{className:`bg-background/90 px-1 py-1.5`,children:[(0,U.jsx)(`div`,{className:`text-xs font-semibold tabular-nums`,children:t}),(0,U.jsx)(`div`,{className:`text-[8px] uppercase text-muted-foreground`,children:e})]},String(e)))}),(0,U.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-1`,children:[`all`,`execution`,`changes`,`notes`,`failures`].map(e=>(0,U.jsxs)(`button`,{type:`button`,onClick:()=>s(e),className:P(`rounded border px-1.5 py-1 text-[9px] capitalize`,o===e?`border-primary/50 bg-primary/10 text-primary`:`border-border text-muted-foreground hover:text-foreground`),children:[e,` `,p[e]]},e))}),(0,U.jsxs)(`div`,{className:`relative mb-3`,children:[(0,U.jsx)(T,{className:`pointer-events-none absolute left-2 top-1/2 size-3 -translate-y-1/2 text-muted-foreground`}),(0,U.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),"aria-label":`Search task activity`,placeholder:`Search agent, session, model, result, field…`,className:`h-8 w-full rounded-md border bg-background pl-7 pr-7 text-[11px] outline-none focus:border-primary`}),c&&(0,U.jsx)(`button`,{type:`button`,onClick:()=>l(``),"aria-label":`Clear task activity search`,className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,children:(0,U.jsx)(E,{className:`size-3`})})]}),i&&(0,U.jsx)(`div`,{className:`mb-2 rounded-md border border-destructive/30 bg-destructive/5 px-2.5 py-2 text-[11px] text-destructive`,children:i}),m.length===0?(0,U.jsx)(`div`,{className:`rounded-md border border-dashed px-3 py-6 text-center text-[11px] text-muted-foreground`,children:`No activity matches this filter.`}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`ol`,{className:`relative ml-1.5 space-y-0 border-l border-border/70`,children:_.map(e=>{let t=tn(e),r=e.sessionId??n,i=$t(e),a=Qt(e)===`failures`,o=e.type.includes(`completed`)||Y(J(e.after).outcome)===`succeeded`;return(0,U.jsxs)(`li`,{className:`relative pb-4 pl-4 last:pb-0`,children:[(0,U.jsx)(`span`,{className:P(`absolute -left-[5px] top-1.5 size-2 rounded-full ring-4`,nn(e))}),(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`p`,{className:`text-xs font-medium leading-5`,children:en(e)}),(0,U.jsx)(`code`,{className:`block truncate text-[8px] text-muted-foreground/70`,title:e.type,children:e.type})]}),(0,U.jsx)(`time`,{dateTime:e.ts,title:new Date(e.ts).toLocaleString(),className:`shrink-0 text-[9px] text-muted-foreground`,children:rn(e.ts)})]}),t&&(0,U.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap text-[11px] leading-4 text-muted-foreground`,children:t}),e.note&&(0,U.jsxs)(`div`,{className:P(`mt-1.5 max-h-32 overflow-y-auto whitespace-pre-wrap rounded border px-2 py-1.5 text-[10px] leading-4`,a?`border-destructive/30 bg-destructive/5 text-destructive`:o?`border-success/30 bg-success/5 text-success`:`border-border/70 bg-muted/35 text-foreground`),children:[(0,U.jsxs)(`strong`,{children:[a?`Error`:o?`Result`:`Reason / result`,`:`]}),` `,e.note]}),i.length>0&&e.type!==`task.assigned`&&e.type!==`task.assignment.snapshot`&&!e.type.startsWith(`task.file.`)&&(0,U.jsx)(`div`,{className:`mt-1.5 space-y-1 rounded border border-border/60 bg-background/50 p-1.5`,children:i.map(e=>(0,U.jsxs)(`div`,{className:`grid grid-cols-[5rem_minmax(0,1fr)] gap-1.5 text-[9px] leading-4`,children:[(0,U.jsx)(`code`,{className:`truncate text-primary`,title:e.field,children:e.field}),(0,U.jsxs)(`span`,{className:`min-w-0 break-all text-muted-foreground`,children:[(0,U.jsx)(`span`,{className:`line-through opacity-70`,children:an(e.before)}),` `,(0,U.jsx)(`span`,{"aria-hidden":!0,children:`→`}),` `,(0,U.jsx)(`span`,{className:`text-foreground`,children:an(e.after)})]})]},e.field))}),(0,U.jsx)(sn,{event:e}),(e.actor||r||e.subagentId||e.runTaskId||e.correlationId)&&(0,U.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap gap-1 font-mono text-[9px] text-muted-foreground`,children:[e.actor&&(0,U.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5`,children:[`agent:`,e.actor]}),r&&(0,U.jsxs)(`span`,{className:`max-w-52 truncate rounded bg-muted px-1.5 py-0.5`,title:r,children:[`session:`,r]}),e.subagentId&&(0,U.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5`,children:[`subagent:`,e.subagentId]}),e.runTaskId&&(0,U.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5`,children:[`run:`,e.runTaskId]}),e.correlationId&&(0,U.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5`,children:[`trace:`,e.correlationId]})]}),(0,U.jsxs)(`details`,{className:`mt-1.5 text-[9px] text-muted-foreground`,children:[(0,U.jsx)(`summary`,{className:`cursor-pointer hover:text-foreground`,children:`Full event payload`}),(0,U.jsx)(`pre`,{className:`mt-1 max-h-64 overflow-auto rounded border bg-muted/30 p-2 text-[9px] leading-4 text-foreground`,children:JSON.stringify(e,null,2)})]})]},e.id)})}),(0,U.jsx)(I,{page:g.page,pageSize:g.pageSize,totalItems:g.totalItems,onPageChange:g.setPage,className:`mt-3`,itemLabel:`activity events`})]})]})}function ln(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function X(e){return typeof e==`string`&&e.trim()?e.trim():void 0}function un(e){return e.type===`task.assigned`||e.type===`task.claimed`||e.type===`task.released`||e.type===`task.assignment.snapshot`||e.type===`task.stale_recovered`||e.type.startsWith(`task.assignment.`)}function dn(e,t){return X(t.status)||(e.type===`task.claimed`?`claimed`:e.type===`task.released`?`released`:e.type===`task.stale_recovered`?`recovered`:e.type.split(`.`).at(-1)??`unknown`)}function fn(e){return[`completed`,`failed`,`cancelled`,`released`,`recovered`].includes(e)}function pn(e,t){if(!t)return;let n=Date.parse(e),r=Date.parse(t);return Number.isFinite(n)&&Number.isFinite(r)?Math.max(0,r-n):void 0}function mn(e,t,n){let r=on(e,t,n).filter(un).sort((e,t)=>e.ts.localeCompare(t.ts)),i=new Map,a=0,o=0,s=!1;for(let e of r){let t=ln(e.after),r=Number(t.attempt),c=e.type===`task.assigned`||e.type===`task.claimed`;Number.isFinite(r)&&r>0?a=Math.trunc(r):c&&(a===0||s)?a=o+1:a===0&&(a=1),o=Math.max(o,a);let l=dn(e,t),u=i.get(a)??{attempt:a,status:l,startedAt:e.ts,fallbackModels:[],sessionIds:new Set,eventCount:0};u.status=l,u.eventCount+=1,(e.sessionId??n)&&u.sessionIds.add(e.sessionId??n),u.owner=X(t.name)??X(t.agentId)??X(t.role)??e.actor??u.owner,u.provider=X(t.provider)??u.provider,u.model=X(t.model)??u.model,u.routingMode=X(t.modelRouting)??u.routingMode,u.fallbackProfile=X(t.fallbackProfile)??u.fallbackProfile,Array.isArray(t.fallbackModels)&&(u.fallbackModels=t.fallbackModels.filter(e=>typeof e==`string`)),u.subagentId=e.subagentId??X(t.subagentId)??u.subagentId,u.runTaskId=e.runTaskId??X(t.runTaskId)??u.runTaskId,l===`running`&&!u.runningAt&&(u.runningAt=e.ts),l===`completed`&&(u.result=X(t.lastResult)??e.note??u.result),(l===`failed`||l===`cancelled`)&&(u.error=X(t.error)??e.note??u.error),fn(l)&&(u.endedAt=e.ts),i.set(a,u),s=fn(l)}return[...i.values()].map(e=>({...e,sessionIds:[...e.sessionIds],durationMs:pn(e.startedAt,e.endedAt)})).sort((e,t)=>t.attempt-e.attempt)}function hn(e){if(e===void 0)return`running`;if(e<1e3)return`${e}ms`;let t=Math.round(e/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function gn(e){return e===`completed`?`bg-success/10 text-success`:e===`failed`||e===`cancelled`?`bg-destructive/10 text-destructive`:e===`running`?`bg-info/10 text-info`:`bg-muted text-muted-foreground`}function _n({task:e,events:t,sessionId:n}){let r=mn(e,t,n),i=we(r,8,e.id);return r.length?(0,U.jsxs)(`details`,{open:!0,className:`mt-3 rounded-md border border-border/70 bg-muted/15`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-3 py-2.5 [&::-webkit-details-marker]:hidden`,children:[(0,U.jsx)(ge,{className:`size-4 text-primary`}),(0,U.jsx)(`span`,{className:`text-xs font-semibold`,children:`Execution attempts`}),(0,U.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-[9px] text-muted-foreground`,children:[r.length,` total`]}),(0,U.jsxs)(`span`,{className:`rounded px-1.5 py-0.5 text-[9px] ${gn(r[0].status)}`,children:[`latest:`,r[0].status]}),(0,U.jsx)(x,{className:`ml-auto size-3.5 text-muted-foreground`})]}),(0,U.jsxs)(`div`,{className:`space-y-2 border-t border-border/60 p-2.5`,children:[i.pageItems.map(e=>(0,U.jsxs)(`section`,{className:`rounded-md border bg-background/70 p-2.5`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 text-[10px]`,children:[(0,U.jsxs)(`strong`,{className:`text-xs`,children:[`Attempt #`,e.attempt]}),(0,U.jsx)(`span`,{className:`rounded px-1.5 py-0.5 ${gn(e.status)}`,children:e.status}),(0,U.jsxs)(`span`,{className:`ml-auto inline-flex items-center gap-1 text-muted-foreground`,children:[(0,U.jsx)(a,{className:`size-3`}),` `,hn(e.durationMs),` · `,e.eventCount,` `,`events`]})]}),(0,U.jsxs)(`div`,{className:`mt-2 grid gap-1 text-[10px] text-muted-foreground sm:grid-cols-2`,children:[(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,U.jsx)(A,{className:`size-3`}),` `,e.owner??`Unknown agent`]}),(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-mono`,children:[(0,U.jsx)(j,{className:`size-3`}),e.provider||e.model?`${e.provider?`${e.provider}/`:``}${e.model??`default`}`:e.routingMode??`default route`]}),(0,U.jsxs)(`span`,{className:`font-mono`,children:[`session:`,e.sessionIds.join(`, `)||`unknown`]}),(0,U.jsxs)(`span`,{className:`font-mono`,children:[`subagent:`,e.subagentId??`—`,` · run:`,e.runTaskId??`—`]})]}),(e.fallbackProfile||e.fallbackModels.length>0)&&(0,U.jsxs)(`p`,{className:`mt-1.5 break-all font-mono text-[9px] text-muted-foreground`,children:[`fallback:`,[e.fallbackProfile?`profile:${e.fallbackProfile}`:``,...e.fallbackModels].filter(Boolean).join(` → `)]}),e.error&&(0,U.jsxs)(`p`,{className:`mt-2 whitespace-pre-wrap rounded border border-destructive/30 bg-destructive/5 px-2 py-1.5 text-[10px] text-destructive`,children:[(0,U.jsx)(`strong`,{children:`Error:`}),` `,e.error]}),e.result&&(0,U.jsxs)(`p`,{className:`mt-2 max-h-32 overflow-y-auto whitespace-pre-wrap rounded border border-success/30 bg-success/5 px-2 py-1.5 text-[10px] text-success`,children:[(0,U.jsx)(`strong`,{children:`Result:`}),` `,e.result]})]},e.attempt)),(0,U.jsx)(I,{page:i.page,pageSize:i.pageSize,totalItems:i.totalItems,onPageChange:i.setPage,compact:!0,itemLabel:`execution attempts`})]})]}):null}function vn(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function Z(e){return G(e)}function yn(e,t){return(t??[]).map(t=>{let n=e.tasks.find(e=>e.id===t);return{id:t,title:n?.title??t,status:n?.status??`missing`}})}function bn(e,t,n,r,i,a,o){let s=on(t,n,r),c=yn(e,t.dependsOn),l=c.filter(e=>![`completed`,`archived`].includes(e.status)),u=t.assignment,d=(o??e.presence??[]).filter(e=>e.taskId===t.id),f=vn(s.find(e=>e.type===`task.assigned`||e.type===`task.claimed`||e.type.startsWith(`task.assignment.`))?.after),p=Z(u?.modelRouting)??Z(f.modelRouting)??`session`,m=Z(u?.provider)??Z(f.provider)??(p===`session`?Z(i):void 0),h=Z(u?.model)??Z(f.model)??(p===`session`?Z(a):void 0),g=(Array.isArray(u?.fallbackModels)?u.fallbackModels:Array.isArray(f.fallbackModels)?f.fallbackModels:[]).map(Z).filter(e=>e!==void 0),_=Z(u?.fallbackProfile)??Z(f.fallbackProfile),v=Z(u?.name)??Z(u?.agentId)??Z(u?.role)??Z(t.assignee)??Z(t.assignedAgent)??`Unassigned`,y=t.lifecycle?.history.at(-1),b=s.find(e=>e.note&&e.type!==`task.note.added`)?.note,x=`Placed in ${e.columns.find(e=>e.id===t.columnId)?.title??t.columnId}.`;u?.error?x=`Agent run failed: ${u.error}`:l.length?x=`Blocked by ${l.map(e=>e.title).join(`, `)}.`:y?.comment?x=y.comment:b?x=b:t.status===`review`?x=`Implementation is waiting for review evidence or approval.`:t.status===`in_progress`?x=`${v} is currently working on this task.`:t.status===`completed`&&(x=`The task and its current assignment are complete.`);let S=s.map(e=>Number(vn(e.after).attempt)).filter(e=>Number.isFinite(e)),C=s.filter(e=>e.type===`task.claimed`||e.type===`task.assigned`).length,w=s.find(e=>Qt(e)===`failures`),T=s.find(e=>e.type.includes(`completed`));return{column:e.columns.find(e=>e.id===t.columnId)?.title??t.columnId,reason:x,owner:v,routingMode:p,provider:m,model:h,primaryModel:m||h?`${m?`${m}/`:``}${h??`default`}`:`Session default`,fallbackRoute:[_?`profile:${_}`:``,...g].filter(Boolean).join(` → `)||`None configured`,blockers:l,dependencies:c,actors:[...new Set([...s.map(e=>e.actor).filter(e=>!!e),...d.map(e=>e.agentId)])],sessions:[...new Set([...s.map(e=>e.sessionId??r),...d.map(e=>e.sessionId)].filter(e=>!!e))],presence:d.map(e=>`${e.agentName??e.agentId} · ${e.active?`active`:`last seen ${Q(e.lastSeenAt)}`}`),activePresence:d.filter(e=>e.active).length,attempts:Math.max(u?.attempt??0,...S,C),failures:s.filter(e=>e.type.includes(`failed`)).length,completions:s.filter(e=>e.type.includes(`completed`)).length,lastFailure:u?.lastFailureKind??u?.error??w?.note,lastResult:u?.lastResult??T?.note,eventCount:s.length,lastActivity:s[0]}}function Q(e){if(!e)return`—`;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function xn(e,t){if(!e)return`—`;let n=Date.parse(e),r=t?Date.parse(t):Date.now();if(!Number.isFinite(n)||!Number.isFinite(r))return`—`;let i=Math.max(0,Math.round((r-n)/6e4));return i<1?`<1m`:i<60?`${i}m`:`${Math.floor(i/60)}h ${i%60}m`}function $({label:e,value:t,mono:n=!1}){return(0,U.jsxs)(`div`,{className:`grid grid-cols-[7rem_minmax(0,1fr)] gap-2 py-1 text-[11px]`,children:[(0,U.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,U.jsx)(`dd`,{className:n?`break-all font-mono text-[10px]`:`min-w-0 break-words`,children:t})]})}function Sn({icon:e,title:t,children:n}){return(0,U.jsxs)(`section`,{className:`rounded-md border border-border/70 bg-background/55 p-2.5`,children:[(0,U.jsxs)(`h4`,{className:`mb-1.5 flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[e,t]}),(0,U.jsx)(`dl`,{className:`divide-y divide-border/35`,children:n})]})}function Cn({items:e}){return e.length?(0,U.jsx)(`span`,{className:`space-y-1`,children:e.map(e=>(0,U.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsx)(`span`,{className:`truncate`,title:e.title,children:e.title}),(0,U.jsx)(`span`,{className:`shrink-0 rounded bg-muted px-1 py-0.5 text-[9px]`,children:e.status})]},e.id))}):(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:`None`})}function wn({board:e,task:t,events:n,presence:r,sessionId:i,sessionProvider:a,sessionModel:o}){let s=bn(e,t,n,i,a,o,r),c=t.assignment,l=t.successCriteria?.length??0,u=t.successCriteria?.filter(e=>e.status===`passed`).length??0,d=[t.parentTaskId,...t.childTaskIds??[],t.chain?.previousTaskId,t.chain?.nextTaskId,t.mergedIntoTaskId,...t.mergedFromTaskIds??[]].filter(e=>!!e),f=yn(e,[...new Set(d)]);return(0,U.jsxs)(`details`,{open:!0,className:`mt-3 rounded-md border border-primary/25 bg-primary/[0.025]`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-3 py-2.5 [&::-webkit-details-marker]:hidden`,children:[(0,U.jsx)(de,{className:`size-4 text-primary`}),(0,U.jsx)(`span`,{className:`text-xs font-semibold`,children:`Task intelligence`}),(0,U.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-[9px] uppercase text-muted-foreground`,children:t.status}),(0,U.jsxs)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:[s.eventCount,` events`]}),(0,U.jsx)(x,{className:`size-3.5 text-muted-foreground`})]}),(0,U.jsxs)(`div`,{className:`space-y-2.5 border-t border-border/60 p-2.5`,children:[(0,U.jsxs)(`section`,{className:`rounded-md border border-info/25 bg-info/5 p-2.5`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 text-[10px]`,children:[(0,U.jsx)(`span`,{className:`rounded bg-info/10 px-1.5 py-0.5 font-semibold text-info`,children:s.column}),(0,U.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5`,children:[`stage:`,t.lifecycle?.currentStage??`legacy`]}),(0,U.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5`,children:[`priority:`,t.priority]}),(0,U.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5`,children:[`type:`,t.type??`inferred`]})]}),(0,U.jsxs)(`p`,{className:`mt-2 text-[11px] leading-4`,children:[(0,U.jsx)(`strong`,{children:`Why here:`}),` `,s.reason]}),s.blockers.length>0&&(0,U.jsxs)(`p`,{className:`mt-1 text-[10px] text-warning`,children:[s.blockers.length,` unresolved blocker`,s.blockers.length===1?``:`s`]})]}),(0,U.jsxs)(`div`,{className:`grid gap-2 xl:grid-cols-2`,children:[(0,U.jsxs)(Sn,{icon:(0,U.jsx)(A,{className:`size-3`}),title:`Ownership & runtime`,children:[(0,U.jsx)($,{label:`Owner`,value:s.owner}),(0,U.jsx)($,{label:`Assignee`,value:Z(t.assignee)??Z(t.assignedAgent)??`—`}),(0,U.jsx)($,{label:`Agent ID`,value:Z(c?.agentId)??`—`,mono:!0}),(0,U.jsx)($,{label:`Agent name / role`,value:[Z(c?.name),Z(c?.role)].filter(Boolean).join(` · `)||`—`}),(0,U.jsx)($,{label:`Run status`,value:Z(c?.status)??`unassigned`}),(0,U.jsx)($,{label:`Subagent`,value:Z(c?.subagentId)??`—`,mono:!0}),(0,U.jsx)($,{label:`Run task`,value:Z(c?.runTaskId)??`—`,mono:!0}),(0,U.jsx)($,{label:`Session(s)`,value:s.sessions.join(`, `)||`Unknown`,mono:!0}),(0,U.jsx)($,{label:`Users / presence`,value:s.presence.length?s.presence.join(`, `):`No task-scoped presence recorded`})]}),(0,U.jsxs)(Sn,{icon:(0,U.jsx)(j,{className:`size-3`}),title:`Model route & fallback`,children:[(0,U.jsx)($,{label:`Routing mode`,value:s.routingMode}),(0,U.jsx)($,{label:`Primary`,value:s.primaryModel,mono:!0}),(0,U.jsx)($,{label:`Provider`,value:s.provider??`—`,mono:!0}),(0,U.jsx)($,{label:`Model`,value:s.model??`—`,mono:!0}),(0,U.jsx)($,{label:`Fallback route`,value:s.fallbackRoute,mono:!0}),(0,U.jsx)($,{label:`Skills`,value:c?.skills?.map(Z).filter(Boolean).join(`, `)||`Default`}),(0,U.jsx)($,{label:`Tools`,value:c?.tools?.map(Z).filter(Boolean).join(`, `)||`Default toolset`}),(0,U.jsx)($,{label:`Capabilities`,value:c?.allowedCapabilities?.map(Z).filter(Boolean).join(`, `)||`Safe defaults`,mono:!0})]}),(0,U.jsxs)(Sn,{icon:(0,U.jsx)(w,{className:`size-3`}),title:`Execution policy & outcome`,children:[(0,U.jsx)($,{label:`Attempts`,value:`${s.attempts}${c?.maxAttempts?` / ${c.maxAttempts}`:``}`}),(0,U.jsx)($,{label:`Retry policy`,value:c?.retryPolicy??t.retryPolicy??`off`}),(0,U.jsx)($,{label:`Cost ceiling`,value:(c?.costCeilingUsd??t.costCeilingUsd)==null?`Unbounded`:`$${(c?.costCeilingUsd??t.costCeilingUsd).toFixed(2)}`}),(0,U.jsx)($,{label:`Failures / done`,value:`${s.failures} / ${s.completions}`}),(0,U.jsx)($,{label:`Checks`,value:`${u} / ${l} passed`}),(0,U.jsx)($,{label:`Last failure`,value:s.lastFailure??`—`}),(0,U.jsx)($,{label:`Result`,value:s.lastResult??`No result recorded`})]}),(0,U.jsxs)(Sn,{icon:(0,U.jsx)(h,{className:`size-3`}),title:`Timing & audit coverage`,children:[(0,U.jsx)($,{label:`Created`,value:Q(t.createdAt)}),(0,U.jsx)($,{label:`Updated`,value:Q(t.updatedAt)}),(0,U.jsx)($,{label:`Due`,value:Q(t.dueDate)}),(0,U.jsx)($,{label:`Dispatched`,value:Q(c?.dispatchedAt??c?.claimedAt)}),(0,U.jsx)($,{label:`Completed`,value:Q(c?.completedAt??t.completedAt)}),(0,U.jsx)($,{label:`Duration`,value:xn(c?.dispatchedAt??c?.claimedAt,c?.completedAt)}),(0,U.jsx)($,{label:`Heartbeat`,value:Q(c?.heartbeatAt)}),(0,U.jsx)($,{label:`Lease expires`,value:Q(c?.leaseExpiresAt)}),(0,U.jsx)($,{label:`Actors`,value:s.actors.join(`, `)||`Unknown`,mono:!0})]})]}),(0,U.jsxs)(Sn,{icon:(0,U.jsx)(re,{className:`size-3`}),title:`Dependencies, chain & provenance`,children:[(0,U.jsx)($,{label:`Dependencies`,value:(0,U.jsx)(Cn,{items:s.dependencies})}),(0,U.jsx)($,{label:`Other relations`,value:(0,U.jsx)(Cn,{items:f})}),(0,U.jsx)($,{label:`Chain`,value:t.chain?`${t.chain.chainId} · position ${t.chain.order}`:`None`,mono:!0}),(0,U.jsx)($,{label:`Origin system`,value:t.origin?.system??`manual`}),(0,U.jsx)($,{label:`Origin IDs`,value:t.origin&&[t.origin.graphId,t.origin.phaseId,t.origin.taskId,t.origin.specId].filter(Boolean).join(` · `)||`—`,mono:!0}),(0,U.jsx)($,{label:`Task ID`,value:t.id,mono:!0}),(0,U.jsx)($,{label:`Board ID`,value:e.id,mono:!0})]})]})]})}var Tn={passed:{icon:v,label:`Passed`,className:`text-success`},failed:{icon:o,label:`Failed`,className:`text-destructive`},needs_human:{icon:c,label:`Needs Review`,className:`text-warning`},incomplete:{icon:u,label:`Incomplete`,className:`text-muted-foreground`}},En={passed:{label:`Passed`,className:`text-success`},failed:{label:`Failed`,className:`text-destructive`},skipped:{label:`Skipped`,className:`text-muted-foreground`},error:{label:`Error`,className:`text-warning`}};function Dn(e,t){let n=Date.parse(t)-Date.parse(e);return Number.isNaN(n)||n<0?``:n<1e3?`${n}ms`:n<6e4?`${Math.round(n/1e3)}s`:`${Math.floor(n/6e4)}m ${Math.round(n%6e4/1e3)}s`}function On({verdict:e}){let t=Tn[e],n=t.icon;return(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-semibold ${t.className}`,children:[(0,U.jsx)(n,{size:13}),t.label]})}function kn({title:e,icon:t,defaultOpen:n=!1,children:r}){let[i,a]=(0,R.useState)(n);return(0,U.jsxs)(`div`,{className:`rounded-md border bg-background`,children:[(0,U.jsxs)(`button`,{type:`button`,onClick:()=>a(!i),className:`flex w-full items-center gap-2 px-3 py-2 text-xs font-semibold uppercase text-muted-foreground hover:bg-muted/50`,children:[i?(0,U.jsx)(x,{size:13}):(0,U.jsx)(ce,{size:13}),(0,U.jsx)(t,{size:13}),e]}),i&&(0,U.jsx)(`div`,{className:`border-t px-3 py-2 space-y-2`,children:r})]})}function An({check:e}){let t=En[e.status],[n,r]=(0,R.useState)(!1),i=e.error||e.backingRefs?.length;return(0,U.jsxs)(`div`,{className:`rounded border bg-muted/30 px-2.5 py-2 text-xs`,children:[(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,U.jsx)(`span`,{className:`font-medium ${t.className}`,children:t.label}),(0,U.jsx)(`span`,{className:`rounded bg-muted px-1 text-[10px] text-muted-foreground`,children:e.type})]}),(0,U.jsx)(`p`,{className:`mt-0.5 text-muted-foreground`,children:e.description})]}),i&&(0,U.jsx)(`button`,{type:`button`,onClick:()=>r(!n),className:`shrink-0 text-muted-foreground hover:text-foreground`,children:n?(0,U.jsx)(x,{size:13}):(0,U.jsx)(ce,{size:13})})]}),n&&(0,U.jsxs)(`div`,{className:`mt-2 space-y-1.5 border-t pt-2`,children:[e.error&&(0,U.jsx)(`div`,{className:`rounded bg-destructive/10 px-2 py-1 text-destructive`,children:e.error}),e.backingRefs?.map((e,t)=>(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,U.jsx)(fe,{size:11}),(0,U.jsx)(`span`,{className:`font-mono text-[11px]`,children:e.path}),(0,U.jsxs)(`span`,{className:`text-[10px]`,children:[`(`,e.kind,`)`]}),e.summary&&(0,U.jsxs)(`span`,{className:`truncate`,children:[`— `,e.summary]})]},t))]})]})}function jn({fileScope:e}){return(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-3 text-xs`,children:[(0,U.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Expected `,(0,U.jsx)(`strong`,{children:e.expectedChanges}),` changes`]}),(0,U.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Actual `,(0,U.jsx)(`strong`,{children:e.actualChanges}),` changes`]}),(0,U.jsx)(`span`,{className:e.scopeMatches?`text-success`:`text-destructive`,children:e.scopeMatches?`✅ Scope matches`:`❌ Scope mismatch`})]}),(0,U.jsx)(`div`,{className:`space-y-1`,children:e.files.map((e,t)=>(0,U.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-mono text-muted-foreground`,children:[(0,U.jsx)(`span`,{className:e.operation===`create`?`text-success`:e.operation===`delete`?`text-destructive`:`text-muted-foreground`,children:e.operation===`create`?`+`:e.operation===`delete`?`−`:`∼`}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.path}),(0,U.jsxs)(`span`,{className:`text-[10px]`,children:[e.linesChanged,` line`,e.linesChanged===1?``:`s`]}),!e.expected&&(0,U.jsx)(`span`,{className:`rounded bg-warning/10 px-1 text-[10px] text-warning`,children:`unexpected`})]},t))})]})}function Mn({subtasks:e}){return(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground`,children:[(0,U.jsxs)(`span`,{children:[`Total `,(0,U.jsx)(`strong`,{children:e.total})]}),(0,U.jsxs)(`span`,{className:`text-success`,children:[`Completed `,(0,U.jsx)(`strong`,{children:e.completed})]}),e.failed>0&&(0,U.jsxs)(`span`,{className:`text-destructive`,children:[`Failed `,(0,U.jsx)(`strong`,{children:e.failed})]})]}),(0,U.jsx)(`div`,{className:`space-y-1`,children:e.children.map((e,t)=>(0,U.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[e.verdict===`passed`?(0,U.jsx)(`span`,{className:`text-success`,children:`✓`}):e.verdict===`failed`?(0,U.jsx)(`span`,{className:`text-destructive`,children:`✗`}):e.verdict===`needs_human`?(0,U.jsx)(`span`,{className:`text-warning`,children:`⚠`}):(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:`○`}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title})]},t))})]})}function Nn({attachments:e}){return(0,U.jsx)(`div`,{className:`space-y-1`,children:e.map((e,t)=>(0,U.jsxs)(`div`,{className:`flex items-start gap-2 rounded border bg-muted/30 px-2 py-1.5 text-xs`,children:[(0,U.jsx)(le,{size:12,className:`mt-0.5 shrink-0 text-muted-foreground`}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`div`,{className:`font-medium`,children:e.label}),(0,U.jsx)(`div`,{className:`mt-0.5 font-mono text-[11px] text-muted-foreground`,children:e.path?(0,U.jsxs)(`span`,{className:`truncate block`,children:[e.path,(0,U.jsx)(`span`,{className:`ml-1 rounded bg-muted px-1 text-[10px]`,children:e.kind})]}):(0,U.jsx)(`span`,{className:`rounded bg-muted px-1 text-[10px]`,children:e.kind})}),e.content&&(0,U.jsxs)(`pre`,{className:`mt-1 max-h-20 overflow-auto rounded bg-background p-1 text-[10px] text-muted-foreground`,children:[e.content.slice(0,500),e.content.length>500?`
3
+ …`:``]})]})]},t))})}function Pn({report:e}){return(0,U.jsxs)(`div`,{className:`mt-5 space-y-3`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`div`,{className:`text-xs font-semibold uppercase text-muted-foreground`,children:`Verification Report`}),(0,U.jsx)(On,{verdict:e.verdict})]}),e.markdownSummary&&(0,U.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:Dn(e.startedAt,e.completedAt)})]}),e.markdownSummary&&(0,U.jsx)(`div`,{className:`rounded-md border bg-background px-3 py-2 text-xs text-muted-foreground whitespace-pre-wrap`,children:e.markdownSummary}),e.checks.length>0&&(0,U.jsx)(kn,{title:`Check Results`,icon:pe,defaultOpen:e.verdict!==`passed`,children:e.checks.map(e=>(0,U.jsx)(An,{check:e},e.checkId))}),e.fileScope&&(0,U.jsx)(kn,{title:`File Scope`,icon:fe,defaultOpen:!e.fileScope.scopeMatches,children:(0,U.jsx)(jn,{fileScope:e.fileScope})}),e.subtasks&&(0,U.jsx)(kn,{title:`Sub-Tasks`,icon:pe,children:(0,U.jsx)(Mn,{subtasks:e.subtasks})}),e.attachments.length>0&&(0,U.jsx)(kn,{title:`Attachments (${e.attachments.length})`,icon:le,children:(0,U.jsx)(Nn,{attachments:e.attachments})})]})}function Fn({boardId:e,task:t,sendKanban:n}){return vt(t,xe(n=>n.verificationActivity[`${e}:${t.id}`]))===`running`?(0,U.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-md border border-info/30 bg-info/5 p-3 text-xs text-info`,children:[(0,U.jsx)(ae,{size:14,className:`animate-spin`}),`Verification running — checks are being executed…`]}):t.verificationReport?(0,U.jsxs)(`div`,{className:`mt-4`,children:[(0,U.jsx)(Pn,{report:t.verificationReport}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>n(`kanban.task.verify`,{boardId:e,taskId:t.id}),className:`mt-1.5 rounded-md border px-2 py-1 text-[11px] text-muted-foreground hover:bg-muted`,children:`Re-run verification`})]}):(0,U.jsxs)(`div`,{className:`mt-4 rounded-md border border-dashed p-3`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,U.jsx)(C,{size:14}),(0,U.jsx)(`span`,{className:`font-medium`,children:`Unverified`}),(0,U.jsx)(`span`,{children:`— no verification report exists for this task yet.`})]}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>n(`kanban.task.verify`,{boardId:e,taskId:t.id}),className:`mt-2 rounded-md bg-primary/10 px-2.5 py-1.5 text-xs font-medium text-primary hover:bg-primary/20`,children:`Run verification`})]})}function In({boards:e,board:t,task:n,runLink:r,onClose:i,onSelectTask:a,sendKanban:o,sendRaw:s,refreshBoard:c,activityEvents:l,activityPresence:u,activityLoading:f,activityError:p,activitySessionId:h,refreshActivity:g}){let[v,y]=(0,R.useState)(``),[b,C]=(0,R.useState)(``),[T,D]=(0,R.useState)(``),[O,te]=(0,R.useState)(``),[re,ie]=(0,R.useState)(``),[k,ae]=(0,R.useState)(`session`),[A,oe]=(0,R.useState)(``),[se,ce]=(0,R.useState)([]),[le,ue]=(0,R.useState)([]),[de,fe]=(0,R.useState)([]),[pe,me]=(0,R.useState)([]),[j,he]=(0,R.useState)(``),ge=Se(!!n),M=qe(!!n),N=G(M.sessionProvider),ve=G(M.sessionModel),ye=Te(`kanban-task-inspector`,!!n),[be,xe]=(0,R.useState)(!1),[F,we]=(0,R.useState)(!1),[I,Ee]=(0,R.useState)(``),[L,De]=(0,R.useState)(``),[z,Oe]=(0,R.useState)(``),[ke,Ae]=(0,R.useState)(`pending`),[je,Me]=(0,R.useState)(``),[Ne,Pe]=(0,R.useState)(``),[Fe,Ie]=(0,R.useState)(``),[Le,Re]=(0,R.useState)(`medium`),[ze,Be]=(0,R.useState)(`chore`),[B,Ve]=(0,R.useState)(``),[V,He]=(0,R.useState)([]),[Ue,We]=(0,R.useState)([]),[H,Ge]=(0,R.useState)(!1),[Ke,Je]=(0,R.useState)(``),[Ye,Xe]=(0,R.useState)(``),[Ze,Qe]=(0,R.useState)(`off`),[$e,et]=(0,R.useState)(``),[tt,nt]=(0,R.useState)(``),[rt,it]=(0,R.useState)(``),[at,ot]=(0,R.useState)(``),[ct,lt]=(0,R.useState)(``),[ut,dt]=(0,R.useState)(`observation`),[ft,pt]=(0,R.useState)(`unknown`),[mt,ht]=(0,R.useState)(``);(0,R.useEffect)(()=>{let r=G(n?.assignment?.provider),i=G(n?.assignment?.model);y(G(n?.assignment?.agentId)??G(n?.assignedAgent)??``),C(G(n?.assignment?.name)??``),D(G(n?.assignment?.role)??``),te(r??``),ie(i??``),ae(n?.assignment?.modelRouting??(r||i?`fixed`:`session`)),oe(G(n?.assignment?.fallbackProfile)??``),ce(n?.assignment?.fallbackModels??[]),ue(n?.assignment?.skills??[]),fe(n?.assignment?.tools??[]),me(n?.assignment?.allowedCapabilities??[]),he(e.find(e=>e.id!==t?.id)?.id??``),Ee(n?.title??``),De(n?.description??``),Oe(n?.dueDate??``),Ae(n?.status??`pending`),Me(``),Pe(``),Ie(``),Re(n?.priority??`medium`),Be(n?.type??`chore`),Ve(n?.labels?.join(`, `)??``),He(n?.dependsOn??[]),We(n?.chain&&t?t.tasks.filter(e=>e.chain?.chainId===n.chain?.chainId).sort((e,t)=>(e.chain?.order??0)-(t.chain?.order??0)).map(e=>e.id):n?[n.id]:[]),Ge(!1),Je(n?.estimatedHours?.toString()??``),Xe(n?.actualHours?.toString()??``),Qe(n?.retryPolicy??n?.assignment?.retryPolicy??`off`),et((n?.costCeilingUsd??n?.assignment?.costCeilingUsd)?.toString()??``),nt(n?.assignment?.maxAttempts?.toString()??``),it(``),ot(``),lt(``),dt(`observation`),pt(`unknown`),ht(``)},[t?.id,e,n]);let _t=e=>({boardId:t?.id,taskId:n?.id,...v.trim()?{agentId:v.trim()}:{},...b.trim()?{name:b.trim()}:{},...T.trim()?{role:T.trim()}:{},modelRouting:k,...k===`fixed`&&O.trim()?{provider:O.trim()}:{},...k===`fixed`&&re.trim()?{model:re.trim()}:{},...k===`fallback_profile`&&A.trim()?{fallbackProfile:A.trim()}:{},fallbackModels:se,skills:le,tools:de,allowedCapabilities:pe,...tt?{maxAttempts:Number(tt)}:{},...$e?{costCeilingUsd:Number($e)}:{},retryPolicy:Ze,activityNote:mt.trim()||`${e===`dispatch`?`Dispatched`:`Assigned`} from WebUI to ${b.trim()||v.trim()||T.trim()||`the configured agent route`}.`}),vt=()=>{!t||!n||!I.trim()||(o(`kanban.task.update`,{boardId:t.id,taskId:n.id,title:I.trim(),description:L,dueDate:z||null,...t.lifecycle?.mode===`managed`?{}:{status:ke},priority:Le,type:ze,labels:B.split(`,`).map(e=>e.trim()).filter(Boolean),dependsOn:V,...n.chain&&Ue.length<=1?{chain:null}:{},estimatedHours:Ke?Number(Ke):0,actualHours:Ye?Number(Ye):0,retryPolicy:Ze,costCeilingUsd:$e?Number($e):null,activityNote:mt.trim()||`Task contract edited in WebUI.`}),Ue.length>1&&o(`kanban.task.chain`,{boardId:t.id,taskIds:Ue,enforceDependencies:H}),window.setTimeout(()=>c(t.id),180),ht(``))},yt=[`backlog`,`todo`,`running`,`review`,`done`],bt=n?.lifecycle?.currentStage,xt=bt?yt.indexOf(bt):-1,St=xt>=0&&xt<yt.length-1?yt[xt+1]:void 0;return n?(0,U.jsxs)(`aside`,{"aria-label":`Task inspector`,"data-expanded":F?`true`:`false`,className:P(`flex max-h-[42dvh] w-full shrink-0 flex-col border-t bg-card/40 transition-[width] duration-200 ease-out md:max-h-none md:border-l md:border-t-0`,F?`fixed inset-0 z-50 h-dvh max-h-none w-screen border-0 bg-card transition-none md:w-screen md:border-0`:`md:w-[420px] xl:w-[480px]`),children:[(0,U.jsxs)(`div`,{className:P(`flex h-12 items-center gap-2 border-b px-3`,F&&`px-5`),children:[(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:`Task`}),(0,U.jsx)(`div`,{className:`truncate text-[11px] text-muted-foreground`,children:n.id.slice(0,8)})]}),(0,U.jsx)(`button`,{type:`button`,title:F?`Collapse task details`:`Expand task details`,"aria-label":F?`Collapse task details`:`Expand task details`,"aria-pressed":F,onClick:()=>we(e=>!e),className:`flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground`,children:F?(0,U.jsx)(_,{size:16}):(0,U.jsx)(S,{size:16})}),(0,U.jsx)(`button`,{type:`button`,title:`Close`,onClick:()=>{we(!1),i()},className:`flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,U.jsx)(E,{size:16})})]}),n?(0,U.jsxs)(`div`,{ref:ye,className:P(`min-h-0 flex-1 overflow-y-auto overscroll-contain p-3`,F&&`px-5 py-4 xl:px-7`),children:[(0,U.jsxs)(`div`,{className:`space-y-3 rounded-md border bg-background p-2.5`,children:[(0,U.jsx)(st,{title:`Task boundary`,value:n.boundary,inherited:t?.boundary,onSave:e=>{t&&(o(`kanban.task.update`,{boardId:t.id,taskId:n.id,boundary:e,activityNote:`Task boundary edited in WebUI.`}),window.setTimeout(()=>c(t.id),150))}}),(0,U.jsx)(K,{label:`Title`,value:I,onChange:Ee}),(0,U.jsxs)(`label`,{className:`block`,children:[(0,U.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:`Description / working context`}),(0,U.jsx)(`textarea`,{value:L,onChange:e=>De(e.target.value),rows:5,className:`w-full resize-y rounded-md border bg-background px-2 py-1.5 text-xs leading-5 outline-none focus:border-primary`})]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[t?.lifecycle?.mode===`managed`?(0,U.jsxs)(`div`,{className:`rounded-md border bg-muted/30 px-2 py-1.5`,children:[(0,U.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:`Managed stage`}),(0,U.jsx)(`div`,{className:`mt-1 text-xs font-semibold capitalize`,children:n.lifecycle?.currentStage??`Backlog`})]}):(0,U.jsx)(q,{label:`Status`,value:ke,options:[`pending`,`ready`,`in_progress`,`blocked`,`review`,`completed`,`failed`,`archived`],onChange:e=>Ae(e)}),(0,U.jsx)(q,{label:`Priority`,value:Le,options:[`critical`,`high`,`medium`,`low`],onChange:e=>Re(e)}),(0,U.jsx)(q,{label:`Type`,value:ze,options:[`feature`,`bugfix`,`refactor`,`docs`,`test`,`chore`],onChange:e=>Be(e)}),(0,U.jsx)(K,{label:`Labels (comma separated)`,value:B,onChange:Ve})]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,U.jsx)(K,{label:`Due date (ISO or YYYY-MM-DD)`,value:z,onChange:Oe}),(0,U.jsx)(K,{label:`Estimated hours`,value:Ke,onChange:Je}),(0,U.jsx)(K,{label:`Actual hours`,value:Ye,onChange:Xe})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:`Dependencies`}),(0,U.jsx)(W,{options:(t?.tasks??[]).filter(e=>e.id!==n.id).map(e=>({value:e.id,label:e.title,description:e.status})),selected:V,onChange:He,placeholder:`Select blocking tasks…`})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:`Task chain (selection order)`}),(0,U.jsx)(W,{options:(t?.tasks??[]).map(e=>({value:e.id,label:e.title,description:e.status})),selected:Ue,onChange:e=>We(e.includes(n.id)?e:[n.id,...e]),placeholder:`Add tasks to a sequential chain…`}),(0,U.jsxs)(`label`,{className:`mt-1.5 flex items-center gap-2 text-[11px] text-muted-foreground`,children:[(0,U.jsx)(`input`,{type:`checkbox`,checked:H,onChange:e=>Ge(e.target.checked)}),`Enforce chain order as dependencies`]})]}),(0,U.jsx)(K,{label:`Change / assignment reason (persisted to activity)`,value:mt,onChange:ht}),(0,U.jsxs)(`button`,{type:`button`,onClick:vt,className:`inline-flex h-9 w-full items-center justify-center gap-2 rounded-md bg-primary text-sm text-primary-foreground hover:bg-primary/90`,children:[(0,U.jsx)(ee,{size:15}),` Save task contract`]}),t?.lifecycle?.mode===`managed`&&St&&(0,U.jsxs)(`section`,{"aria-label":`Managed lifecycle transition`,className:`space-y-2 rounded-md border border-primary/30 bg-primary/5 p-2.5`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wide text-primary`,children:`Kanban Agent transition`}),(0,U.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[bt,` → `,St,`; no stages can be skipped.`]})]}),(0,U.jsx)(w,{size:16,className:`text-primary`})]}),(0,U.jsx)(K,{label:`Completed action / reviewer action`,value:Ne,onChange:Pe}),(0,U.jsx)(K,{label:`Truthful progress comment (required)`,value:je,onChange:Me}),(0,U.jsx)(K,{label:`Evidence attachment URL`,value:Fe,onChange:Ie}),(0,U.jsxs)(`button`,{type:`button`,disabled:!je.trim(),onClick:()=>{!t||!n||!St||!je.trim()||(o(`kanban.task.transition`,{boardId:t.id,taskId:n.id,to:St,actor:v.trim()||b.trim()||n.assignee||n.assignedAgent||`webui-agent`,comment:je.trim(),...Ne.trim()?{action:Ne.trim()}:{},...Fe.trim()?{attachment:{url:Fe.trim(),type:`url`,title:`Evidence for ${n.title}`}}:{}}),window.setTimeout(()=>c(t.id),180))},className:`inline-flex h-9 w-full items-center justify-center gap-2 rounded-md bg-primary text-sm text-primary-foreground hover:bg-primary/90 disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,U.jsx)(d,{size:15}),` Advance to `,St]})]})]}),t&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(wn,{board:t,task:n,events:l,presence:u,sessionId:h,sessionProvider:N,sessionModel:ve}),(0,U.jsx)(_n,{task:n,events:l,sessionId:h}),(0,U.jsx)(jt,{board:t,task:n,events:l})]}),(0,U.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-2 text-xs`,children:[(0,U.jsx)(wt,{label:`Source`,value:n.origin?.system??`manual`}),(0,U.jsx)(wt,{label:`Task ID`,value:n.id.slice(0,8)}),(0,U.jsx)(wt,{label:`Run`,value:n.assignment?.status??`unassigned`}),(0,U.jsx)(wt,{label:`Column`,value:Ct(t,n.columnId)})]}),n.assignment&&(0,U.jsx)(Kt,{assignment:n.assignment}),r&&n.origin?.taskId&&(0,U.jsx)(Lt,{runLink:r,runTaskId:n.origin.taskId,modelCandidates:ge,sendRaw:s}),!r&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,U.jsx)(q,{label:`Primary model source`,value:k,options:[`session`,`fixed`,`fallback_profile`],onChange:e=>ae(e)}),k===`session`&&(0,U.jsxs)(`div`,{className:`rounded-md border bg-info/5 px-2 py-1.5 text-[11px] text-muted-foreground`,children:[`Uses the live session model: `,N?`${N}/`:``,ve||`not available`,`.`]}),k===`fixed`&&(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:`Fixed provider / model`}),(0,U.jsx)(Ce,{value:re||void 0,provider:O||void 0,candidates:ge,placeholder:`Select exact provider / model…`,onPick:(e,t)=>{ie(e),te(t)}})]}),k===`fallback_profile`&&(0,U.jsx)(q,{label:`Fallback profile (first model is primary)`,value:A,options:Object.keys(M.fallbackProfiles),placeholder:`Select configured profile…`,onChange:oe}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:`Fallback models`}),(0,U.jsx)(W,{options:ge.map(e=>({value:`${e.provider}/${e.model}`,label:e.label,description:e.description,tag:e.provider})),selected:se,onChange:ce,placeholder:`Add fallback model…`,emptyLabel:`No models — add a provider in Settings`})]}),(0,U.jsx)(q,{label:`Role`,value:T,options:Yt,placeholder:`Select a role…`,onChange:D}),(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:[`Agentic skills`,` `,(0,U.jsx)(`span`,{className:`text-muted-foreground/70`,children:`· force-loaded into the worker`})]}),(0,U.jsx)(W,{options:M.skills.map(e=>({value:e.name,label:e.name,description:e.description,tag:e.source})),selected:le,onChange:ue,placeholder:`Assign required skills…`,emptyLabel:`No skills registered`})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:[`Tools`,` `,(0,U.jsx)(`span`,{className:`text-muted-foreground/70`,children:`· blank = full default toolset`})]}),(0,U.jsx)(W,{options:M.tools.map(e=>({value:e.name,label:e.name,description:e.description})),selected:de,onChange:fe,placeholder:`Restrict to specific tools…`,emptyLabel:`Tool list unavailable on this server`})]}),(0,U.jsxs)(`div`,{className:`rounded-md border bg-background/60`,children:[(0,U.jsxs)(`button`,{type:`button`,onClick:()=>xe(e=>!e),className:`flex w-full items-center justify-between px-2 py-1.5 text-[11px] font-medium text-muted-foreground hover:text-foreground`,children:[`Advanced`,(0,U.jsx)(x,{size:13,className:P(`transition-transform`,be&&`rotate-180`)})]}),be&&(0,U.jsxs)(`div`,{className:`space-y-3 border-t p-2`,children:[(0,U.jsx)(K,{label:`Agent name (optional)`,value:b,onChange:C}),(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,U.jsx)(q,{label:`Retry policy`,value:Ze,options:[`off`,`incremental`,`exponential`],onChange:e=>Qe(e)}),(0,U.jsx)(K,{label:`Max attempts`,value:tt,onChange:nt}),(0,U.jsx)(K,{label:`Cost ceiling USD`,value:$e,onChange:et})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:[`Capabilities`,` `,(0,U.jsx)(`span`,{className:`text-muted-foreground/70`,children:`· blank = safe defaults`})]}),(0,U.jsx)(W,{options:Xt,selected:pe,onChange:me,placeholder:`Grant a capability…`})]})]})]})]}),(0,U.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 gap-2`,children:[(0,U.jsxs)(`button`,{type:`button`,onClick:()=>{!t||!n||(o(`kanban.task.assign`,_t(`assign`)),ht(``),window.setTimeout(()=>c(t.id),150))},className:`inline-flex h-9 items-center justify-center gap-2 rounded-md border text-sm hover:bg-muted`,children:[(0,U.jsx)(m,{size:15}),`Assign`]}),(0,U.jsxs)(`button`,{type:`button`,onClick:()=>{!t||!n||(o(`kanban.task.dispatch`,_t(`dispatch`)),ht(``),window.setTimeout(()=>c(t.id),200))},className:`inline-flex h-9 items-center justify-center gap-2 rounded-md bg-primary text-sm text-primary-foreground hover:bg-primary/90`,children:[(0,U.jsx)(ne,{size:15}),`Dispatch`]})]})]}),e.length>1&&!r?(0,U.jsxs)(`div`,{className:`mt-4 space-y-2 rounded-md border bg-background p-2`,children:[(0,U.jsxs)(`label`,{className:`block`,children:[(0,U.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:`Target board`}),(0,U.jsx)(`select`,{value:j,onChange:e=>he(e.target.value),className:`h-8 w-full rounded-md border bg-background px-2 text-sm outline-none focus:border-primary`,children:e.filter(e=>e.id!==t?.id).map(e=>(0,U.jsx)(`option`,{value:e.id,children:e.title},e.id))})]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,U.jsxs)(`button`,{type:`button`,onClick:()=>{!t||!n||!j||o(`kanban.task.copy`,{boardId:t.id,taskId:n.id,targetBoardId:j})},disabled:!j,className:`inline-flex h-9 items-center justify-center gap-2 rounded-md border text-sm hover:bg-muted disabled:opacity-50`,children:[(0,U.jsx)(_e,{size:15}),`Copy`]}),(0,U.jsxs)(`button`,{type:`button`,onClick:()=>{!t||!n||!j||o(`kanban.task.transfer`,{boardId:t.id,taskId:n.id,targetBoardId:j})},disabled:!j,className:`inline-flex h-9 items-center justify-center gap-2 rounded-md border text-sm hover:bg-muted disabled:opacity-50`,children:[(0,U.jsx)(d,{size:15}),`Transfer`]})]})]}):null,(0,U.jsx)(Jt,{board:t,task:n,newCheck:rt,onNewCheckChange:it,onAddCheck:()=>{!t||!n||!rt.trim()||(o(`kanban.task.check.add`,{boardId:t.id,taskId:n.id,description:rt.trim(),checkType:`manual`}),it(``))},sendKanban:o}),t&&(0,U.jsx)(Fn,{boardId:t.id,task:n,sendKanban:o}),t&&(0,U.jsx)(gt,{board:t,task:n,sendKanban:o,onSelectTask:a}),(0,U.jsx)(cn,{task:n,events:l,sessionId:h,loading:f,error:p,onRefresh:g}),(0,U.jsx)(qt,{activityKind:ut,activityOutcome:ft,note:at,details:ct,onActivityKindChange:dt,onActivityOutcomeChange:pt,onNoteChange:ot,onDetailsChange:lt,onRecordActivity:()=>{!t||!n||!at.trim()||(o(`kanban.task.activity.add`,{boardId:t.id,taskId:n.id,kind:ut,outcome:ft,summary:at.trim(),...ct.trim()?{details:ct.trim()}:{},actor:b.trim()||v.trim()||`webui-operator`}),ot(``),lt(``),window.setTimeout(g,150))}})]}):null]}):null}var Ln=[[`board`,`Board`],[`tree`,`Tree`],[`dashboard`,`Verification`]];function Rn({viewMode:e,onViewModeChange:t}){return(0,U.jsx)(`div`,{className:`flex shrink-0 items-center gap-1 border-b px-4 py-1.5`,children:Ln.map(([n,r])=>(0,U.jsx)(`button`,{type:`button`,onClick:()=>t(n),className:P(`rounded-md px-2.5 py-1 text-[11px] font-medium transition-colors`,e===n?`bg-primary/10 text-primary`:`text-muted-foreground hover:bg-muted`),children:r},n))})}function zn(){let[e,t]=(0,R.useState)([]);return(0,R.useEffect)(()=>{let e=!1,n=async()=>{try{let n=await fetch(`/api/sessions`);if(!n.ok)return;let r=await n.json();if(!Array.isArray(r)||e)return;let i=r.filter(e=>!!e&&typeof e==`object`&&typeof e.sessionId==`string`&&e.status!==`lost`).map(e=>e.sessionId).sort();t(e=>e.length===i.length&&e.every((e,t)=>e===i[t])?e:i)}catch{}};n();let r=window.setInterval(n,8e3);return()=>{e=!0,window.clearInterval(r)}},[]),e}var Bn=5e3,Vn=12;function Hn({onClose:e}){let t=be(e=>e.wsUrl),n=ye(e=>e.session?.id??null),r=F(e=>e.agents),{boards:i,boardTotal:a,activeBoardTotal:o,orphanedBoardTotal:s,activeBoardId:c,activeBoard:l,loading:u,error:d,queueHealth:p,supervisorSnapshot:m,setLoading:h,setActiveBoardId:g}=xe(),[_,v]=(0,R.useState)(``),[y,b]=(0,R.useState)(1),x=zn(),[S,C]=(0,R.useState)(``),w=(0,R.useRef)(null);De(w);let[T,ee]=(0,R.useState)(``),[D,O]=(0,R.useState)(null),[te,ne]=(0,R.useState)([]),[re,k]=(0,R.useState)(),[ae,A]=(0,R.useState)(!1),[oe,se]=(0,R.useState)(null),[ce,le]=(0,R.useState)(0),[ue,de]=(0,R.useState)(null),[fe,pe]=(0,R.useState)(`board`),me=(0,R.useRef)(null),j=(0,R.useMemo)(()=>ve(t),[t]),he=l?.tasks.find(e=>e.id===D)??null,ge=(0,R.useMemo)(()=>$e(r.values()),[r]),N=(0,R.useMemo)(()=>et({sessionId:n,registrySessionIds:x,agents:r.values()}),[r,x,n]),P=i.filter(e=>tt(e,N)),Se=i.filter(e=>!tt(e,N)),Ce=(0,R.useMemo)(()=>l?ke(l,{now:Date.now(),liveAgentIdentities:ge,requireDueDate:l.lifecycle?.mode===`managed`}):null,[l,ge]),we=(0,R.useMemo)(()=>nt(l),[l]),I=(e,t={})=>{h(!0),j.send({type:e,payload:t})},Te=(e,t={})=>{j.send({type:e,payload:t})},Ee=(0,R.useMemo)(()=>rt(l),[l]),L=(e=y)=>I(`kanban.list`,{page:e,pageSize:Vn,activeSessionIds:N}),z=(e=c)=>{e&&I(`kanban.get`,{boardId:e})};(0,R.useEffect)(()=>{L()},[]),(0,R.useEffect)(()=>{let e=n?i.find(e=>e.tags?.includes(`session:${n}`)):void 0,t=!!(n&&e)&&me.current!==n,r=t?e:c?void 0:i[0];r?.id&&(t&&(me.current=n),g(r.id),I(`kanban.get`,{boardId:r.id}))},[i,c,n,g]),(0,R.useEffect)(()=>{l&&D&&!l.tasks.some(e=>e.id===D)&&O(null)},[l,D]),(0,R.useEffect)(()=>{c&&(I(`kanban.health`,{boardId:c}),I(`kanban.supervisor.status`,{boardId:c}))},[c]),(0,R.useEffect)(()=>{if(!c)return;let e=setInterval(()=>{j.send({type:`kanban.get`,payload:{boardId:c}}),j.send({type:`kanban.health`,payload:{boardId:c}})},5e3);return()=>clearInterval(e)},[c,j]),(0,R.useEffect)(()=>{let e=setInterval(()=>{j.send({type:`kanban.list`,payload:{page:y,pageSize:Vn,activeSessionIds:N}})},8e3);return()=>clearInterval(e)},[N,y,j]);let Oe=e=>{b(e),g(null),L(e)};(0,R.useEffect)(()=>{k(void 0)},[c,D]),(0,R.useEffect)(()=>{if(!c||!D)return;let e=c,t=D;A(!0),se(null);let n=j.on(`kanban.task.activity`,n=>{let r=n.payload;if(r.success===!1){se(r.error??`Task activity could not be loaded.`),A(!1);return}r.data?.boardId!==e||r.data.taskId!==t||(ne(r.data.events??[]),k(r.data.presence??[]),A(!1))});return j.send({type:`kanban.task.activity`,payload:{boardId:e,taskId:t,limit:Bn}}),n},[c,D,he?.updatedAt,ce,j]),(0,R.useEffect)(()=>{if(!(!c||!D))return j.on.bind(j)(`kanban.task.activity.changed`,e=>{let t=e.payload;t.boardId===c&&t.taskId===D&&le(e=>e+1)})},[c,D,j]);let Ae=()=>{let e=_.trim();e&&(v(``),I(`kanban.create`,{title:e,lifecycle:{mode:`managed`,columns:{backlog:`backlog`,todo:`todo`,running:`in-progress`,review:`review`,done:`done`}}}))},je=()=>{if(!l)return;let e=S.trim();e&&(C(``),I(`kanban.task.add`,{boardId:l.id,title:e,columnId:l.columns[0]?.id??`backlog`,activityNote:`Task created manually in WebUI.`}),window.setTimeout(()=>z(l.id),150))},Me=()=>{if(!l)return;let e=T.trim();e&&(ee(``),I(`kanban.column.add`,{boardId:l.id,title:e}),window.setTimeout(()=>z(l.id),150))},Ne=()=>{l&&(I(`kanban.delete`,{boardId:l.id}),window.setTimeout(L,150))},Pe=()=>{l&&(I(`kanban.duplicate`,{boardId:l.id,title:`${l.title} Copy`}),window.setTimeout(L,150))},Fe=e=>{l&&(I(`kanban.task.remove`,{boardId:l.id,taskId:e.id}),window.setTimeout(()=>z(l.id),150))},Ie=(e,t)=>{if(!l)return;let n=l.tasks.find(t=>t.id===e),r=l.columns.find(e=>e.id===n?.columnId)?.title,i=l.columns.find(e=>e.id===t)?.title??t;I(`kanban.task.move`,{boardId:l.id,taskId:e,columnId:t,activityNote:`Moved in WebUI${r?` from ${r}`:``} to ${i}.`}),window.setTimeout(()=>z(l.id),150)};return(0,U.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col bg-background text-foreground md:flex-row`,children:[(0,U.jsx)(it,{boardTotal:a,activeBoardTotal:o,orphanedBoardTotal:s,activeBoardId:c,activeBoards:P,orphanedBoards:Se,boardPage:y,boardPageSize:Vn,loading:u,newBoardTitle:_,onClose:e,onRefresh:()=>L(),onNewBoardTitleChange:v,onCreateBoard:Ae,onBoardSelect:e=>{g(e),I(`kanban.get`,{boardId:e})},onBoardPageChange:Oe}),(0,U.jsxs)(`main`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,U.jsxs)(`header`,{className:`flex min-h-12 shrink-0 flex-wrap items-center gap-2 border-b px-3 py-2 sm:px-4`,children:[(0,U.jsxs)(`div`,{className:`w-full min-w-0 sm:w-auto sm:flex-1`,children:[(0,U.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:l?.title??`No board selected`}),(0,U.jsx)(`div`,{className:`truncate text-[11px] text-muted-foreground`,children:l?`${l.columns.length} columns / ${l.tasks.length} tasks`:`Create or select a board`})]}),l&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`input`,{value:S,onChange:e=>C(e.target.value),onKeyDown:e=>{e.key===`Enter`&&je()},placeholder:`New task`,className:`h-8 w-[calc(100%-2.5rem)] min-w-0 flex-none rounded-md border bg-background px-2 text-sm outline-none focus:border-primary sm:w-56`}),(0,U.jsx)(`button`,{type:`button`,title:`Add task`,onClick:je,className:`flex h-8 w-8 items-center justify-center rounded-md bg-primary text-primary-foreground hover:bg-primary/90`,children:(0,U.jsx)(M,{size:16})}),(0,U.jsx)(`input`,{value:T,onChange:e=>ee(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Me()},placeholder:`New column`,className:`h-8 w-[calc(100%-2.5rem)] min-w-0 flex-none rounded-md border bg-background px-2 text-sm outline-none focus:border-primary sm:w-44`}),(0,U.jsx)(`button`,{type:`button`,title:`Add column`,onClick:Me,className:`hidden h-8 w-8 items-center justify-center rounded-md border text-muted-foreground hover:bg-muted hover:text-foreground sm:flex`,children:(0,U.jsx)(f,{size:16})}),(0,U.jsx)(`button`,{type:`button`,title:`Duplicate board`,onClick:Pe,className:`flex h-8 w-8 items-center justify-center rounded-md border text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,U.jsx)(_e,{size:16})}),(0,U.jsx)(`button`,{type:`button`,title:`Delete board`,onClick:Ne,className:`hidden h-8 w-8 items-center justify-center rounded-md border text-muted-foreground hover:bg-destructive/10 hover:text-destructive sm:flex`,children:(0,U.jsx)(ie,{size:16})})]})]}),l&&(0,U.jsx)(Xe,{presence:l.presence}),l&&(0,U.jsx)(`div`,{className:`shrink-0 border-b px-3 py-2 sm:px-4`,children:(0,U.jsx)(st,{title:`Board boundary`,value:l.boundary,onSave:e=>{I(`kanban.update`,{boardId:l.id,boundary:e}),window.setTimeout(()=>z(l.id),150)}})}),l&&Ee&&(0,U.jsx)(Ft,{runLink:Ee,sendRaw:Te}),l&&!Ee&&l.tasks.length>0&&(0,U.jsx)(It,{boardId:l.id,sendKanban:I}),l&&(0,U.jsx)(Ze,{board:l,snapshot:m,sendKanban:I}),Ce&&(0,U.jsx)(dt,{audit:Ce,onSelectTask:O}),l&&(0,U.jsx)(pt,{board:l,sendKanban:I,onSelectTask:O}),l&&(0,U.jsx)(Rn,{viewMode:fe,onViewModeChange:pe}),d&&(0,U.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-2 border-b border-destructive/30 bg-destructive/10 px-4 text-sm text-destructive`,children:[(0,U.jsx)(E,{size:15}),(0,U.jsx)(`span`,{className:`truncate`,children:d})]}),(0,U.jsx)(`div`,{ref:w,className:`kanban-scroll-area min-h-0 flex-1 overflow-x-auto overflow-y-hidden overscroll-contain`,children:l?(0,U.jsxs)(U.Fragment,{children:[p&&(0,U.jsx)(Pt,{queueHealth:p,runningCostTotal:we}),fe===`tree`?(0,U.jsx)(Bt,{board:l,selectedTaskId:D,onSelectTask:O}):fe===`dashboard`?(0,U.jsx)(Ut,{board:l,onSelectTask:O}):(0,U.jsx)(`div`,{className:`flex h-full min-w-max gap-3 p-4`,children:[...l.columns].sort((e,t)=>e.order-t.order).map(e=>(0,U.jsx)(Nt,{board:l,column:e,selectedTaskId:D,dragTaskId:ue,setDragTaskId:de,onSelectTask:O,onDeleteTask:Fe,onMoveTask:Ie},e.id))})]}):(0,U.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`No kanban board selected.`})})]}),(0,U.jsx)(In,{boards:i,board:l,task:he,runLink:Ee,onClose:()=>O(null),onSelectTask:O,sendKanban:I,sendRaw:Te,refreshBoard:z,activityEvents:te,activityPresence:re,activityLoading:ae,activityError:oe,activitySessionId:l?.tags?.find(e=>e.startsWith(`session:`))?.slice(8),refreshActivity:()=>le(e=>e+1)})]})}export{Hn as KanbanView};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Di as t,Ft as n,Gn as r,Ia as i,Ii as a,Mi as o,Or as s,Pa as c,Vi as l,Xn as u,an as d,dn as f,dt as p,er as m,hn as h,in as g,ja as _,lt as v,qr as y,ua as b,va as x,xt as S}from"./vendor-CxV3l5PQ.js";import"./i18n-DxnYsmc-.js";import{n as C}from"./ui-store-C4Ybfoon.js";import{t as w}from"./utils-_s0GyctV.js";import{t as T}from"./mailbox-store-xh2Ux-Xs.js";import{o as E}from"./view-navigation-DLdE7qHU.js";import{g as D,u as O}from"./index-Bf75VrDE.js";import{t as k}from"./empty-state-02bIS4x7.js";var A=e(i(),1),j=v(),M={note:y,ask:a,assign:g,steer:f,btw:b,broadcast:g,status:o,result:l,review:d},N={high:`border-destructive/25 bg-destructive/10 text-destructive`,normal:`border-border bg-muted text-muted-foreground`,low:`border-primary/20 bg-primary/10 text-primary`};function P(e){return new Date(e).toLocaleString()}function F(e){let t=new Date(e),n=Date.now()-t.getTime();return n<6e4?c.t(`common:time.justNow`):n<36e5?c.t(`common:time.minutesAgo`,{count:Math.round(n/6e4)}):n<864e5?c.t(`common:time.hoursAgo`,{count:Math.round(n/36e5)}):n<6048e5?c.t(`common:time.daysAgo`,{count:Math.round(n/864e5)}):t.toLocaleDateString()}function I({readBy:e}){let{t}=_(),n=Object.entries(e);return n.length===0?null:(0,j.jsxs)(`div`,{className:`space-y-1`,children:[(0,j.jsx)(`div`,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wide`,children:t(`activity:mailbox.readBy`)}),(0,j.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:n.map(([e,t])=>(0,j.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] bg-success/10 text-success`,title:P(t),children:[(0,j.jsx)(l,{className:`h-2.5 w-2.5`}),e]},e))})]})}function L({className:e}){let{t:i}=_(),a=C(e=>e.selectedMailMessage),o=C(e=>e.setSelectedMailMessage);(0,A.useEffect)(()=>()=>{o(null)},[o]);function c(){o(null),E(`chat`)}if(!a)return(0,j.jsx)(k,{icon:(0,j.jsx)(u,{className:`h-6 w-6`}),title:i(`activity:mailbox.emptyDetail`),description:i(`activity:mailbox.emptyDetailHint`)});let d=M[a.type]??r,f=i(`activity:mailbox.type.${a.type}`,{defaultValue:a.type}),g=N[a.priority]??N.normal,v=a.scope?{scope:a.scope,recipientSessionId:a.recipientSessionId}:T(a.to),y=a.to===`*`||a.to===`all`?i(`activity:mailbox.everyone`):a.to,b=v.scope===`session`?i(`activity:mailbox.sessionScope`,{sid:v.recipientSessionId??``}):v.scope===`project`?i(`activity:mailbox.projectScope`):i(`activity:mailbox.directScope`);return(0,j.jsx)(`div`,{className:w(`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-[hsl(var(--surface-2)/0.45)] p-3`,e),children:(0,j.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-border/70 bg-card/75 shadow-sm`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-border/70 px-3 py-3 sm:px-4 shrink-0`,children:[(0,j.jsx)(`button`,{type:`button`,onClick:c,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md border border-border/70 bg-background/60 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,title:i(`activity:mailbox.backToChat`),children:(0,j.jsx)(x,{className:`h-4 w-4`})}),(0,j.jsx)(`div`,{className:w(`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg`,a.completed?`bg-success/10`:`bg-primary/10`),children:(0,j.jsx)(d,{className:w(`h-4 w-4`,a.completed?`text-success`:`text-primary`)})}),(0,j.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,j.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,j.jsx)(`h2`,{className:`text-sm font-semibold text-foreground truncate`,children:a.subject}),a.completed&&(0,j.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 rounded-md border border-success/25 bg-success/8 px-1.5 py-0.5 text-[10px] font-semibold text-success`,children:[(0,j.jsx)(l,{className:`h-3 w-3`}),i(`activity:mailbox.completed`)]}),(0,j.jsx)(`span`,{className:w(`rounded-md border px-1.5 py-0.5 text-[10px] font-semibold uppercase`,g),children:a.priority||`normal`}),a.audience===`leaders`&&(0,j.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-primary/25 bg-primary/10 px-1.5 py-0.5 text-[10px] font-semibold text-primary`,children:[(0,j.jsx)(m,{className:`h-2.5 w-2.5`}),` `,i(`activity:mailbox.audienceLeaders`)]})]}),(0,j.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-2 text-[11px] text-muted-foreground`,children:[(0,j.jsx)(`span`,{className:`min-w-0 truncate font-medium text-foreground/80`,children:a.from}),(0,j.jsx)(`span`,{children:`→`}),(0,j.jsx)(`span`,{className:`min-w-0 truncate`,children:y}),v.scope===`session`&&(0,j.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-semibold bg-warning/12 text-warning`,title:i(`activity:mailbox.sessionScopeTitle`,{sid:v.recipientSessionId??``}),children:[(0,j.jsx)(m,{className:`h-2.5 w-2.5`}),i(`activity:mailbox.sessionLabel`)]}),v.scope===`project`&&(0,j.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-semibold bg-primary/12 text-primary`,children:[(0,j.jsx)(s,{className:`h-2.5 w-2.5`}),i(`activity:mailbox.projectLabel`)]}),(0,j.jsx)(`span`,{className:`opacity-40`,children:`•`}),(0,j.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,j.jsx)(t,{className:`h-3 w-3`}),F(a.timestamp)]})]})]}),(0,j.jsx)(`button`,{type:`button`,onClick:c,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,title:i(`activity:mailbox.closeTitle`),children:(0,j.jsx)(p,{className:`h-4 w-4`})})]}),(0,j.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,j.jsx)(`div`,{className:`mx-auto w-full max-w-4xl px-4 py-5`,children:(0,j.jsx)(`div`,{className:`markdown-content prose prose-sm dark:prose-invert max-w-none text-sm leading-relaxed`,children:(0,j.jsx)(O,{components:D,children:a.body})})})}),(0,j.jsxs)(`div`,{className:`border-t border-border/70 bg-muted/20 px-4 py-3 shrink-0`,children:[(0,j.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-x-6 gap-y-2 text-xs`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,j.jsx)(n,{className:`h-3 w-3 shrink-0`}),(0,j.jsx)(`span`,{children:f})]}),(0,j.jsx)(`div`,{className:`flex items-center gap-1.5`,children:(0,j.jsx)(`span`,{className:w(`rounded border px-1.5 py-0.5 text-[10px] font-semibold uppercase`,g),children:a.priority||`normal`})}),(0,j.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,j.jsx)(S,{className:`h-3 w-3 shrink-0`}),(0,j.jsx)(`span`,{className:`truncate`,title:a.from,children:a.from})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[v.scope===`session`?(0,j.jsx)(m,{className:`h-3 w-3 shrink-0 text-warning`}):(0,j.jsx)(s,{className:`h-3 w-3 shrink-0 text-primary`}),(0,j.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide shrink-0`,children:i(`activity:mailbox.scopeLabel`)}),(0,j.jsx)(`span`,{className:`truncate`,children:b})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,j.jsx)(t,{className:`h-3 w-3 shrink-0`}),(0,j.jsx)(`span`,{children:P(a.timestamp)})]}),a.replyTo&&(0,j.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground col-span-2`,children:[(0,j.jsx)(h,{className:`h-3 w-3 shrink-0`}),(0,j.jsx)(`span`,{className:`truncate`,children:i(`activity:mailbox.replyTo`,{id:a.replyTo})})]}),a.completed&&a.completedBy&&(0,j.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground col-span-2`,children:[(0,j.jsx)(l,{className:`h-3 w-3 shrink-0 text-success`}),(0,j.jsx)(`span`,{children:a.completedAt?i(`activity:mailbox.completedByAt`,{name:a.completedBy,time:P(a.completedAt)}):i(`activity:mailbox.completedBy`,{name:a.completedBy})})]}),a.outcome&&(0,j.jsxs)(`div`,{className:`flex items-start gap-1.5 text-muted-foreground col-span-2 sm:col-span-4`,children:[(0,j.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide shrink-0 mt-0.5`,children:i(`activity:mailbox.outcome`)}),(0,j.jsx)(`span`,{children:a.outcome})]}),a.taskContext&&(0,j.jsxs)(`div`,{className:`flex items-start gap-1.5 text-muted-foreground col-span-2 sm:col-span-4`,children:[(0,j.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide shrink-0 mt-0.5`,children:i(`activity:mailbox.task`)}),(0,j.jsx)(`span`,{children:a.taskContext})]})]}),Object.keys(a.readBy??{}).length>0&&(0,j.jsx)(`div`,{className:`mt-3 pt-3 border-t border-border/50`,children:(0,j.jsx)(I,{readBy:a.readBy})})]})]})})}export{L as MailboxDetailView};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{An as t,Bi as n,Ca as r,Cn as i,Ft as a,Ia as o,Ir as s,Ln as c,Ni as l,Ot as u,Tn as d,Vt as f,Wt as p,Xi as m,Yi as h,Zt as g,_,a as ee,an as v,cn as y,dt as b,f as x,gn as te,hi as S,i as C,jr as w,jt as T,ki as E,kn as ne,kr as D,la as O,li as re,lr as ie,lt as ae,n as oe,nr as se,oi as k,qi as ce,qr as A,r as le,ra as j,ri as M,s as N,si as ue,va as de,xn as fe}from"./vendor-CxV3l5PQ.js";import{n as pe}from"./ui-store-C4Ybfoon.js";import{t as me}from"./useWebSocket-x8PMoTq8.js";import{t as P}from"./ws-client-Cy3oRAmZ.js";import{t as F}from"./utils-_s0GyctV.js";import{M as he}from"./stores-BS-Bdi-5.js";import{a as ge,i as _e,n as ve,o as ye,r as I,t as L}from"./dialog-DsCmc6eL.js";import{t as R}from"./button-DwmC7ENW.js";import{t as z}from"./input-UhWgodVi.js";import{C as be,S as xe,c as Se}from"./index-Bf75VrDE.js";import{t as Ce}from"./roster-ws-DlQQL7Eh.js";import{_ as we,a as Te,b as Ee,c as De,d as Oe,f as ke,g as B,h as Ae,i as V,l as H,m as U,n as je,o as Me,p as Ne,r as Pe,s as Fe,t as Ie,u as Le,v as Re,y as W}from"./shared-bBntASiy.js";var G=e(o(),1),K=ae(),ze=212,Be=188;function Ve(e){return e.length>14?`${e.slice(0,11)}…`:e}function He(e,t=58){let n=e.replace(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t-1)}…`:n}function Ue(e){return e.type===`symbol`?[e.path,e.symbol?`#${e.symbol}`:``].filter(Boolean).join(``):e.path??e.command??e.symbol??e.role??e.type}function We(e){return e===`active`?`border-success/45 bg-success/10 text-success`:e===`stale`?`border-warning/45 bg-warning/10 text-warning`:e===`contradicted`?`border-destructive/45 bg-destructive/10 text-destructive`:e===`superseded`?`border-warning/35 bg-warning/5 text-warning`:`border-border bg-muted/55 text-muted-foreground`}function Ge({data:e}){let{entry:t,center:n}=e;return(0,K.jsxs)(`div`,{className:n?`border border-primary/70 bg-card px-3 py-2.5 text-card-foreground shadow-[0_0_0_1px_hsl(var(--primary)/0.2),0_0_24px_hsl(var(--primary)/0.12)]`:`border border-border/80 bg-card/95 px-3 py-2.5 text-card-foreground shadow-lg`,style:{width:ze},title:t.text,children:[(0,K.jsx)(N,{type:`target`,position:_.Top,className:`!border-background !bg-muted-foreground`}),(0,K.jsx)(N,{type:`source`,position:_.Bottom,className:`!border-background !bg-primary`}),(0,K.jsx)(N,{type:`source`,position:_.Right,className:`!border-background !bg-primary`}),(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`border px-1.5 py-0.5 text-[9px] font-bold uppercase ${We(t.status)}`,children:t.status}),(0,K.jsx)(`span`,{className:`ml-auto truncate font-mono text-[9px] text-muted-foreground`,children:Ve(t.id)})]}),(0,K.jsx)(`p`,{className:`mt-2 line-clamp-2 text-[11px] leading-4 text-foreground/90`,children:He(t.text)}),(0,K.jsx)(`p`,{className:`mt-1 font-mono text-[9px] uppercase text-muted-foreground`,children:t.kind})]})}function Ke({data:e}){return(0,K.jsxs)(`div`,{className:`border border-info/40 bg-info/8 px-2.5 py-2 text-card-foreground shadow-lg`,style:{width:Be},title:e.label,children:[(0,K.jsx)(N,{type:`target`,position:_.Left,className:`!border-background !bg-info`}),(0,K.jsx)(`p`,{className:`font-mono text-[9px] font-bold uppercase text-info`,children:e.anchor.type}),(0,K.jsx)(`p`,{className:`mt-1 truncate font-mono text-[10px] text-foreground/85`,children:e.label})]})}var qe={memoryNode:Ge,anchorNode:Ke};function Je(e){return{id:e,revision:0,scope:`project`,kind:`fact`,status:`deleted`,text:`Memory is unavailable or has been removed.`,importance:0,confidence:0,freshness:0,tags:[],anchors:[],createdAt:``,updatedAt:``}}function Ye({nodes:e,edges:t,className:n}){return(0,K.jsx)(`div`,{className:F(`w-full`,n),children:(0,K.jsxs)(x,{nodes:e,edges:t,nodeTypes:qe,fitView:!0,fitViewOptions:{padding:.24,maxZoom:1.05},minZoom:.4,maxZoom:1.5,nodesConnectable:!1,elementsSelectable:!1,panOnScroll:!1,zoomOnScroll:!1,proOptions:{hideAttribution:!0},children:[(0,K.jsx)(le,{variant:C.Dots,gap:18,size:1,color:`hsl(var(--muted-foreground) / 0.18)`}),(0,K.jsx)(ee,{showInteractive:!1,className:`!border-border !bg-card !shadow-lg`})]})})}function q({centerMemory:e,allMemories:t,graphEdges:n,loading:r=!1,error:i=null}){let[a,o]=(0,G.useState)(!1),s=`mem:${e.id}`,c=(0,G.useMemo)(()=>n.filter(e=>e.from===s&&e.to.startsWith(`mem:`)||e.to===s&&e.from.startsWith(`mem:`)).slice(0,24),[s,n]),{nodes:l,edges:u}=(0,G.useMemo)(()=>{let n=[],r=[],i=new Map(t.map(e=>[e.id,e]));n.push({id:e.id,type:`memoryNode`,position:{x:320-ze/2,y:120},data:{entry:e,center:!0}});let a=[...e.supersededBy?[{id:e.supersededBy,relation:`superseded by`}]:[],...(e.supersedes??[]).map(e=>({id:e,relation:`supersedes`})),...(e.contradicts??[]).map(e=>({id:e,relation:`contradicts`}))];for(let e of c){let t=(e.from===s?e.to:e.from).slice(4);a.some(n=>n.id===t&&n.relation===e.relation)||a.push({id:t,relation:e.relation,weight:e.weight,evidence:e.evidence})}let o=320-(a.length-1)*220/2;return a.forEach((t,a)=>{let s=i.get(t.id)??Je(t.id),c=t.relation===`superseded by`,l=c?0:280+Math.floor(a/3)*130,u=c?320-ze/2:o+a*220-ze/2;n.push({id:`memory:${t.id}:${a}`,type:`memoryNode`,position:{x:u,y:l},data:{entry:s,center:!1}});let d=t.relation===`contradicts`,f=c?`memory:${t.id}:${a}`:e.id,p=c?e.id:`memory:${t.id}:${a}`;r.push({id:`relation:${t.relation}:${t.id}:${a}`,source:f,target:p,type:`smoothstep`,animated:!d,label:t.weight===void 0?t.relation:`${t.relation} ${t.weight.toFixed(2)}`,data:{evidence:t.evidence??[]},style:{stroke:d?`hsl(var(--destructive))`:`hsl(var(--primary))`,strokeWidth:1.7,...d?{strokeDasharray:`5 4`}:{}},labelStyle:{fill:d?`hsl(var(--destructive))`:`hsl(var(--muted-foreground))`,fontSize:9,fontWeight:700},labelBgStyle:{fill:`hsl(var(--card))`,fillOpacity:.9}})}),e.anchors.forEach((t,i)=>{let a=`anchor:${i}`;n.push({id:a,type:`anchorNode`,position:{x:540,y:120+(i-(e.anchors.length-1)/2)*66},data:{anchor:t,label:Ue(t)}}),r.push({id:`anchor-edge:${i}`,source:e.id,target:a,type:`smoothstep`,style:{stroke:`hsl(var(--info))`,strokeWidth:1.3}})}),{nodes:n,edges:r}},[t,e,s,c]);return l.length<=1&&!r&&!i?null:(0,K.jsxs)(`section`,{className:`overflow-hidden border border-border/75 bg-background/35`,"aria-label":`Memory relationship graph`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/70 bg-card/55 px-3 py-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-muted-foreground`,children:`Relationship map`}),l.length>1&&(0,K.jsxs)(R,{variant:`ghost`,size:`sm`,onClick:()=>o(!0),className:`h-6 gap-1 px-2 text-[9px] font-bold uppercase tracking-[0.12em]`,"aria-label":`Open full screen graph`,children:[(0,K.jsx)(re,{className:`size-3`}),`Open full screen`]})]}),(0,K.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:r?`loading real graph…`:`${l.length} nodes · ${u.length} edges`})]}),i&&(0,K.jsx)(`p`,{className:`border-b border-destructive/25 bg-destructive/5 px-3 py-2 text-[10px] text-destructive`,children:i}),l.length>1&&(0,K.jsx)(Ye,{nodes:l,edges:u,className:`h-[320px]`}),c.some(e=>e.evidence?.length)&&(0,K.jsx)(`div`,{className:`grid gap-1 border-t border-border/70 bg-card/35 px-3 py-2`,children:c.filter(e=>e.evidence?.length).slice(0,12).map(e=>{let t=(e.from===s?e.to:e.from).slice(4);return(0,K.jsxs)(`p`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:[(0,K.jsx)(`span`,{className:`text-info`,children:e.relation}),` `,Ve(t),` · why:`,` `,e.evidence?.join(`, `)]},e.id)})}),a&&(0,K.jsx)(L,{open:a,onOpenChange:o,children:(0,K.jsxs)(ve,{className:`flex max-h-[90dvh] max-w-[90vw] flex-col p-0`,showCloseButton:!1,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/70 bg-card/55 px-4 py-3`,children:[(0,K.jsxs)(`p`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-muted-foreground`,children:[`Relationship map — `,e.id]}),(0,K.jsx)(R,{variant:`ghost`,size:`sm`,onClick:()=>o(!1),className:`h-7 gap-1 px-2 text-[10px]`,children:`Close`})]}),(0,K.jsx)(`div`,{className:`min-h-0 flex-1 px-4 pb-4`,children:(0,K.jsx)(Ye,{nodes:l,edges:u,className:`h-[65vh]`})})]})})]})}function Xe({memory:e,allMemories:t,relatedMemories:n,graphEdges:r,graphLoading:i,graphError:a,onClose:o,onOpenMemory:s,onEdit:c,onDelete:l,onTagSelect:u,onNotice:f}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-border/70 bg-card/65 px-4 py-3 backdrop-blur-xl`,children:[(0,K.jsx)(R,{variant:`ghost`,size:`icon`,className:`md:hidden`,onClick:o,"aria-label":`Back to memory list`,children:(0,K.jsx)(de,{className:`size-4`})}),(0,K.jsx)(`span`,{className:F(`text-[10px] font-bold uppercase tracking-[0.14em]`,Ae(e.kind)),children:Pe[e.kind]??e.kind}),(0,K.jsx)(H,{status:e.status}),(0,K.jsx)(`span`,{className:`border border-border/70 px-2 py-0.5 font-mono text-[9px] uppercase text-muted-foreground`,children:e.scope}),e.audience&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 border border-primary/30 bg-primary/10 px-2 py-0.5 font-mono text-[9px] text-primary`,title:Ne(e.audience),children:[(0,K.jsx)(j,{className:`size-3`}),Ne(e.audience)]}),(0,K.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,K.jsx)(R,{variant:`ghost`,size:`icon`,"aria-label":`Copy memory ID`,title:`Copy memory ID`,onClick:()=>{navigator.clipboard?.writeText(e.id),f(`Memory ID copied.`)},children:(0,K.jsx)(E,{className:`size-4`})}),(0,K.jsxs)(R,{variant:`outline`,size:`sm`,onClick:c,disabled:e.status===`deleted`,children:[(0,K.jsx)(d,{className:`size-3.5`}),` Edit`]}),(0,K.jsxs)(R,{variant:`destructive`,size:`sm`,onClick:l,disabled:e.status===`deleted`,children:[(0,K.jsx)(T,{className:`size-3.5`}),` Delete`]})]})]}),(0,K.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-4 md:p-5`,children:(0,K.jsxs)(`div`,{className:`mx-auto max-w-5xl space-y-5`,children:[(0,K.jsx)(Ze,{memory:e}),(0,K.jsx)(J,{memory:e}),e.tags.length>0&&(0,K.jsx)(Qe,{tags:e.tags,onTagSelect:u}),e.anchors.length>0&&(0,K.jsx)(Y,{anchors:e.anchors}),n.length>0&&(0,K.jsx)($e,{relatedMemories:n,allMemories:t,onOpenMemory:s}),(0,K.jsx)(q,{centerMemory:e,allMemories:t,graphEdges:r,loading:i,error:a}),(0,K.jsx)(X,{memory:e}),e.status===`deleted`&&(0,K.jsx)(et,{contextPolicy:e.contextPolicy})]})})]})}function Ze({memory:e}){return(0,K.jsxs)(`div`,{className:`relative overflow-hidden border border-border/75 bg-card/55 p-5 shadow-[inset_0_1px_0_hsl(var(--foreground)/0.04)]`,children:[(0,K.jsx)(`div`,{className:`pointer-events-none absolute -right-10 -top-10 size-36 bg-[radial-gradient(circle,hsl(var(--info)/0.13),transparent_68%)]`}),(0,K.jsx)(`p`,{className:`relative whitespace-pre-wrap text-sm leading-7 text-foreground md:text-[15px]`,children:e.text}),e.summary&&(0,K.jsx)(`p`,{className:`relative mt-4 border-l-2 border-info/50 pl-3 text-xs italic leading-5 text-muted-foreground`,children:e.summary}),(0,K.jsxs)(`div`,{className:`relative mt-5 flex flex-wrap items-center gap-2 border-t border-border/60 pt-3`,children:[(0,K.jsx)(`code`,{className:`min-w-0 break-all font-mono text-[10px] text-muted-foreground`,children:e.id}),(0,K.jsxs)(`span`,{className:`ml-auto font-mono text-[10px] text-muted-foreground`,children:[`revision `,e.revision]})]})]})}function J({memory:e}){return(0,K.jsx)(`div`,{className:`grid gap-px bg-border/60 sm:grid-cols-3`,children:[[`Importance`,e.importance,g],[`Confidence`,e.confidence,n],[`Freshness`,e.freshness,te]].map(([e,t,n])=>(0,K.jsxs)(`div`,{className:`bg-card/60 p-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(n,{className:`size-3.5 text-info`}),(0,K.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.13em] text-muted-foreground`,children:e}),(0,K.jsxs)(`span`,{className:`ml-auto font-mono text-xs font-bold tabular-nums`,children:[Math.round(t*100),`%`]})]}),(0,K.jsx)(`div`,{className:`mt-2 h-1 bg-muted`,children:(0,K.jsx)(`div`,{className:`h-full bg-info shadow-[0_0_8px_hsl(var(--info)/0.45)]`,style:{width:`${Math.round(t*100)}%`}})})]},e))})}function Qe({tags:e,onTagSelect:t}){return(0,K.jsxs)(`section`,{children:[(0,K.jsxs)(`h3`,{className:`mb-2 flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:[(0,K.jsx)(a,{className:`size-3.5 text-info`}),` Tags`]}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map(e=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>t(e),className:`border border-info/25 bg-info/5 px-2 py-1 font-mono text-[10px] text-info hover:border-info/55 hover:bg-info/10`,children:[`#`,e]},e))})]})}function Y({anchors:e}){return(0,K.jsxs)(`section`,{className:`border border-border/75 bg-card/40`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/65 px-3 py-2.5`,children:[(0,K.jsxs)(`h3`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:[(0,K.jsx)(M,{className:`size-3.5 text-info`}),` Anchors`]}),(0,K.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.length})]}),(0,K.jsx)(`ul`,{className:`divide-y divide-border/55`,children:e.map((e,t)=>(0,K.jsxs)(`li`,{className:`flex min-w-0 items-start gap-3 px-3 py-2.5`,children:[(0,K.jsx)(`span`,{className:`mt-0.5 flex size-7 shrink-0 items-center justify-center border border-info/25 bg-info/5 text-info`,children:e.type===`command`?(0,K.jsx)(f,{className:`size-3.5`}):(0,K.jsx)(M,{className:`size-3.5`})}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-[9px] font-bold uppercase text-muted-foreground`,children:e.type}),(0,K.jsxs)(`p`,{className:`mt-0.5 break-all font-mono text-[10px] leading-4 text-foreground/85`,children:[e.path??e.command??e.role??`—`,e.symbol?`#${e.symbol}`:``]})]}),(e.lineStart||e.lineEnd)&&(0,K.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono text-[9px] text-muted-foreground`,children:[`L`,e.lineStart??`?`,`–`,e.lineEnd??`?`]})]},`${e.type}:${e.path??e.command??e.symbol??e.role}:${t}`))})]})}function $e({relatedMemories:e,allMemories:t,onOpenMemory:n}){return(0,K.jsxs)(`section`,{className:`border border-border/75 bg-card/40`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/65 px-3 py-2.5`,children:[(0,K.jsxs)(`h3`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:[(0,K.jsx)(w,{className:`size-3.5 text-info`}),` Memory relationships`]}),(0,K.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.length})]}),(0,K.jsx)(`ul`,{className:`divide-y divide-border/55`,children:e.map(e=>{let r=t.find(t=>t.id===e.id);return(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{type:`button`,disabled:!r,onClick:()=>r&&n(r.id),className:`group flex w-full min-w-0 items-center gap-3 px-3 py-2.5 text-left hover:bg-info/5 disabled:cursor-not-allowed disabled:opacity-55`,children:[(0,K.jsx)(`span`,{className:F(`w-24 shrink-0 text-[9px] font-bold uppercase`,e.relation===`Contradicts`?`text-destructive`:`text-info`),children:e.relation}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs`,children:r?B(r.text,95):`Referenced memory is unavailable`}),(0,K.jsx)(`code`,{className:`hidden max-w-32 truncate font-mono text-[9px] text-muted-foreground sm:block`,children:e.id}),r&&(0,K.jsx)(ce,{className:`size-3.5 shrink-0 text-muted-foreground group-hover:text-info`})]})},`${e.relation}:${e.id}`)})})]})}function X({memory:e}){return(0,K.jsx)(`section`,{className:`grid gap-px bg-border/60 sm:grid-cols-2 lg:grid-cols-4`,children:[[`Created`,U(e.createdAt),O],[`Updated`,U(e.updatedAt),te],[`Last accessed`,U(e.lastAccessedAt),c],[`Last verified`,U(e.lastVerifiedAt),g]].map(([e,t,n])=>(0,K.jsxs)(`div`,{className:`bg-card/50 p-3`,children:[(0,K.jsx)(n,{className:`size-3.5 text-muted-foreground`}),(0,K.jsx)(`p`,{className:`mt-2 text-[9px] font-bold uppercase tracking-[0.12em] text-muted-foreground`,children:e}),(0,K.jsx)(`p`,{className:`mt-1 text-[10px] leading-4 text-foreground/85`,children:t})]},e))})}function et({contextPolicy:e}){return(0,K.jsxs)(`div`,{className:`flex items-start gap-3 border border-border bg-muted/50 p-4 text-xs text-muted-foreground`,children:[(0,K.jsx)(r,{className:`mt-0.5 size-4 shrink-0`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`font-bold text-foreground`,children:`Deleted memory`}),(0,K.jsx)(`p`,{className:`mt-1 leading-5`,children:e===`never`?`This record is audit-only and carries an absolute ban: it can never enter LLM context.`:`The record is inactive and cannot be edited, but remains eligible as historical evidence when retrieval finds it relevant.`})]})]})}var Z={filePath:``,primaryMatches:[],symbolMatches:[],relatedMatches:[],totalCount:0,activeCount:0,supersededCount:0,reviewPendingCount:0};function tt(e){let{filePath:t,lineStart:n,lineEnd:r,limit:i=50,showSuperseded:a=!0,showDeleted:o=!1,autoFetch:s=!0,sendOptions:c}=e,l=c?JSON.stringify(c):``,[u,d]=(0,G.useState)(null),[f,p]=(0,G.useState)(!1),[m,h]=(0,G.useState)(null),g=(0,G.useRef)(0),_=(0,G.useRef)(null),ee=(0,G.useRef)(c);ee.current=c;let v=(0,G.useCallback)(()=>{if(!t){d(null),h(null),p(!1);return}let e=++g.current;p(!0),h(null);let s=P();if(!s){h(`WebSocket client unavailable`),p(!1);return}_.current?.(),_.current=null;let c=t,l=s.on(`memory.sage.forFile`,t=>{if(e!==g.current)return;let n=t.payload.response;n&&n.filePath!==c||(t.payload.error?(h(t.payload.error),d(null)):(d(n??Z),h(null)),p(!1))});_.current=l;let u={filePath:t,limit:i,showSuperseded:a,showDeleted:o,...n===void 0?{}:{lineStart:n},...r===void 0?{}:{lineEnd:r}};try{s.findMemoriesForFile(u,ee.current??void 0)}catch(t){l(),_.current===l&&(_.current=null),e===g.current&&(h(t instanceof Error?t.message:String(t)),p(!1))}},[t,n,r,i,a,o]);(0,G.useEffect)(()=>{if(s)return v(),()=>{g.current++,_.current?.(),_.current=null}},[s,v,l]);let y=(0,G.useCallback)(()=>{v()},[v]);return(0,G.useEffect)(()=>()=>{_.current?.(),_.current=null},[]),{data:u,loading:f,error:m,refetch:y}}function nt(e){return e>=.9?`bg-success/15 border-success/40`:e>=.7?`bg-info/15 border-info/40`:e>=.4?`bg-warning/10 border-warning/30`:`bg-muted/30 border-border/40`}function Q(e){switch(e){case`scope_file`:return`scope: file`;case`scope_symbol`:return`scope: symbol`;case`anchor_file`:return`anchor: file`;case`anchor_symbol`:return`anchor: symbol`;case`anchor_directory`:return`anchor: directory`;case`mention`:return`text mention`}}function rt({match:e,cursorBoosted:t,onShowMemory:n,onAcceptDeletion:r,onKeep:a,onUpdate:o,onMarkPermanent:s,onRecover:c,pendingAction:l}){let d=e.memory.status===`deleted`,f=e.memory.status===`superseded`,h=e.pendingReview,g=l!==void 0,_=t===!0;return(0,K.jsxs)(`article`,{className:F(`group relative rounded-md border px-3 py-2 text-sm transition-colors`,nt(e.matchStrength),_&&`ring-1 ring-primary/40 ring-offset-0`,d&&`opacity-70`),"data-match-via":e.matchedVia,"data-memory-id":e.memory.id,children:[(0,K.jsx)(`header`,{className:`flex items-start justify-between gap-2`,children:(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] uppercase tracking-wide`,children:[(0,K.jsx)(`span`,{className:F(`font-mono`,Ae(e.memory.kind)),children:Pe[e.memory.kind]??e.memory.kind}),(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:`·`}),(0,K.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:Q(e.matchedVia)}),_&&(0,K.jsxs)(`span`,{className:`flex items-center gap-0.5 rounded-sm bg-primary/15 px-1 py-0.5 font-mono text-primary`,title:`Cursor line range matches this memory's anchor`,children:[(0,K.jsx)(i,{className:`size-2.5`}),` cursor`]}),h&&(0,K.jsxs)(`span`,{className:`flex items-center gap-0.5 rounded-sm bg-warning/15 px-1 py-0.5 font-mono text-warning`,title:`Hygiene review: ${h.reason} (${h.ageDays}d old)`,children:[(0,K.jsx)(u,{className:`size-2.5`}),` review`]}),d&&(0,K.jsx)(`span`,{className:`font-mono text-destructive`,children:`deleted`}),f&&!d&&(0,K.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:`superseded`})]}),(0,K.jsx)(`p`,{className:`mt-1 text-foreground/90`,children:B(e.memory.text,200)}),(0,K.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,K.jsx)(H,{status:e.memory.status}),(0,K.jsxs)(`span`,{children:[`updated `,Re(e.memory.updatedAt)]})]})]})}),(0,K.jsxs)(`footer`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,children:[d&&c&&(0,K.jsxs)(R,{type:`button`,size:`sm`,variant:`outline`,disabled:g,onClick:()=>c(e.memory.id),className:`h-7 gap-1 border-primary/40 px-2 text-[11px] text-primary hover:bg-primary/10`,title:`Restore this memory to active status (PR #1: memory_recover)`,children:[(0,K.jsx)(te,{className:`size-3`}),` Recover`]}),f&&e.supersededByActiveId&&n&&(0,K.jsxs)(R,{type:`button`,size:`sm`,variant:`outline`,disabled:g,onClick:()=>n(e.supersededByActiveId),className:`h-7 gap-1 px-2 text-[11px]`,title:`This version is superseded — jump to the active version`,children:[(0,K.jsx)(D,{className:`size-3`}),` Go to active`]}),h&&(0,K.jsxs)(K.Fragment,{children:[h.suggestedAction===`delete`&&(0,K.jsxs)(R,{type:`button`,size:`sm`,variant:`destructive`,disabled:g,onClick:()=>r?.(h.candidateId,e.memory.id),className:`h-7 gap-1 px-2 text-[11px]`,title:`Accept hygiene's deletion suggestion — memory will be forgotten`,children:[(0,K.jsx)(m,{className:`size-3`}),` Accept Deletion`]}),(0,K.jsxs)(R,{type:`button`,size:`sm`,variant:`outline`,disabled:g,onClick:()=>a?.(h.candidateId,e.memory.id),className:`h-7 gap-1 px-2 text-[11px]`,title:`Reject the suggestion — memory stays as-is and may be re-suggested later`,children:[(0,K.jsx)(b,{className:`size-3`}),` Keep`]}),(0,K.jsxs)(R,{type:`button`,size:`sm`,variant:`outline`,disabled:g,onClick:()=>o?.(e.memory.id),className:`h-7 gap-1 px-2 text-[11px]`,title:`Update the memory's content — versioning creates a new active record`,children:[(0,K.jsx)(p,{className:`size-3`}),` Update`]}),s&&(0,K.jsxs)(R,{type:`button`,size:`sm`,variant:`outline`,disabled:g,onClick:()=>s(e.memory.id),className:`h-7 gap-1 border-warning/40 px-2 text-[11px] text-warning hover:bg-warning/10`,title:"Promote to `permanent` — hygiene will never surface this again",children:[(0,K.jsx)(i,{className:`size-3`}),` Mark as Permanent`]})]}),n&&!d&&(0,K.jsxs)(R,{type:`button`,size:`sm`,variant:`ghost`,disabled:g,onClick:()=>n(e.memory.id),className:`h-7 gap-1 px-2 text-[11px] text-muted-foreground hover:text-foreground`,title:`Open the full record in MemoryManager`,children:[(0,K.jsx)(k,{className:`size-3`}),` Show full`]}),l&&(0,K.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 text-[10px] text-muted-foreground`,children:[(0,K.jsx)(se,{className:`size-3 animate-spin`}),` `,l]})]})]})}function it({icon:e,title:t,count:n,matches:r,cursorBoosted:a=!1,...o}){let s=be(r,10);return r.length===0?null:(0,K.jsxs)(`section`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsxs)(`h3`,{className:`flex items-center gap-1.5 px-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[(0,K.jsx)(e,{className:`size-3`}),(0,K.jsx)(`span`,{children:t}),(0,K.jsxs)(`span`,{className:`font-mono`,children:[`(`,n,`)`]}),a&&(0,K.jsxs)(`span`,{className:`ml-auto flex items-center gap-0.5 font-mono text-[9px] text-primary`,children:[(0,K.jsx)(i,{className:`size-2.5`}),` cursor boost`]})]}),(0,K.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:s.pageItems.map(e=>(0,K.jsx)(rt,{match:e,cursorBoosted:a&&(e.matchedVia===`anchor_symbol`||e.matchedVia===`scope_symbol`),pendingAction:o.pendingActionById.get(e.memory.id),...o},e.memory.id))}),(0,K.jsx)(xe,{page:s.page,pageSize:s.pageSize,totalItems:s.totalItems,onPageChange:s.setPage,compact:!0,itemLabel:`memories`})]})}function at({filePath:e,lineStart:t,lineEnd:n,open:r,onClose:a,onShowMemory:o,onAcceptDeletion:s,onKeep:c,onUpdate:d,onMarkPermanent:f,onRecover:p}){let[m,h]=(0,G.useState)(!1),[g,_]=(0,G.useState)(new Map),{data:ee,loading:v,error:y,refetch:b}=tt({filePath:e,lineStart:t,lineEnd:n,showDeleted:m,autoFetch:r}),x=t!==void 0&&n!==void 0,S=(0,G.useCallback)(async(e,t,n)=>{if(n){_(n=>new Map(n).set(e,t));try{await n(e)}finally{_(t=>{let n=new Map(t);return n.delete(e),n})}}},[]);if((0,G.useEffect)(()=>{h(!1)},[e]),!r)return null;let C=ee,w=C?.totalCount??0;return(0,K.jsxs)(`aside`,{className:`flex h-full min-h-0 w-full flex-col border-l border-border/70 bg-card/15`,"aria-label":`File memory drawer`,"data-file-path":e??``,children:[(0,K.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-border/60 px-3 py-2`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] uppercase tracking-wide text-muted-foreground`,children:[(0,K.jsx)(A,{className:`size-3`}),(0,K.jsx)(`span`,{className:`truncate font-mono`,title:e??``,children:e??`(no file)`})]}),(0,K.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,K.jsxs)(`span`,{className:`font-mono`,children:[w,` memories`]}),C&&C.reviewPendingCount>0&&(0,K.jsxs)(`span`,{className:`flex items-center gap-0.5 font-mono text-warning`,children:[(0,K.jsx)(u,{className:`size-3`}),C.reviewPendingCount,` pending review`]}),C&&C.supersededCount>0&&(0,K.jsxs)(`span`,{className:`font-mono`,children:[C.supersededCount,` superseded`]})]})]}),(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,K.jsx)(R,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>b(),disabled:v||!e,className:`h-7 w-7 p-0`,"aria-label":`Refresh`,title:`Re-query for this file`,children:(0,K.jsx)(te,{className:F(`size-3.5`,v&&`animate-spin`)})}),(0,K.jsx)(R,{type:`button`,size:`sm`,variant:`ghost`,onClick:a,className:`h-7 w-7 p-0`,"aria-label":`Close drawer`,title:`Close memory drawer`,children:(0,K.jsx)(l,{className:`size-3.5`})})]})]}),(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-border/40 bg-background/40 px-3 py-1.5 text-[10px] text-muted-foreground`,children:[(0,K.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:m,onChange:e=>h(e.target.checked),className:`size-3 accent-primary`,disabled:!e,"data-testid":`memory-drawer-show-deleted`}),m?(0,K.jsx)(k,{className:`size-3`}):(0,K.jsx)(ue,{className:`size-3`}),(0,K.jsx)(`span`,{children:`Show recoverable (deleted)`})]}),x&&(0,K.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 font-mono text-[10px] text-primary`,children:[(0,K.jsx)(i,{className:`size-3`}),` lines `,t,`–`,n]})]}),(0,K.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-3 py-3`,children:e?v&&!C?(0,K.jsx)(ot,{loading:!0,message:`Loading memories…`}):y?(0,K.jsx)(ot,{tone:`error`,message:`Error: ${y}`}):!C||w===0?(0,K.jsx)(ot,{message:`No memories attached to ${e} yet.`}):(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsx)(it,{icon:i,title:`Cursor boost`,count:C.symbolMatches.length,cursorBoosted:x,matches:C.symbolMatches,pendingActionById:g,onShowMemory:o,onAcceptDeletion:(e,t)=>S(t,`accepting…`,()=>s?.(e,t)),onKeep:(e,t)=>S(t,`keeping…`,()=>c?.(e,t)),onUpdate:e=>S(e,`updating…`,()=>d?.(e)),onMarkPermanent:e=>S(e,`marking…`,()=>f?.(e)),onRecover:e=>S(e,`recovering…`,()=>p?.(e))}),(0,K.jsx)(it,{icon:A,title:`File-scoped`,count:C.primaryMatches.length,matches:C.primaryMatches,pendingActionById:g,onShowMemory:o,onAcceptDeletion:(e,t)=>S(t,`accepting…`,()=>s?.(e,t)),onKeep:(e,t)=>S(t,`keeping…`,()=>c?.(e,t)),onUpdate:e=>S(e,`updating…`,()=>d?.(e)),onMarkPermanent:e=>S(e,`marking…`,()=>f?.(e)),onRecover:e=>S(e,`recovering…`,()=>p?.(e))}),(0,K.jsx)(it,{icon:k,title:`Mentioned in`,count:C.relatedMatches.length,matches:C.relatedMatches,pendingActionById:g,onShowMemory:o,onAcceptDeletion:(e,t)=>S(t,`accepting…`,()=>s?.(e,t)),onKeep:(e,t)=>S(t,`keeping…`,()=>c?.(e,t)),onUpdate:e=>S(e,`updating…`,()=>d?.(e)),onMarkPermanent:e=>S(e,`marking…`,()=>f?.(e)),onRecover:e=>S(e,`recovering…`,()=>p?.(e))})]}):(0,K.jsx)(ot,{message:`Open a file to see its memories.`})})]})}function ot({message:e,loading:t=!1,tone:n=`default`}){return(0,K.jsxs)(`div`,{className:F(`flex min-h-[120px] flex-col items-center justify-center gap-2 rounded-md border border-dashed border-border/60 px-4 py-6 text-center text-[11px]`,n===`error`?`text-destructive`:`text-muted-foreground`),children:[t&&(0,K.jsx)(se,{className:`size-4 animate-spin`}),(0,K.jsx)(`p`,{children:e})]})}function st({mode:e,draft:t,busy:n,error:r,onChange:i,onCancel:a,onSubmit:o}){let s=(0,G.useRef)(null),[c,l]=(0,G.useState)([]);(0,G.useEffect)(()=>{s.current?.focus();let e=new AbortController;return Ce(`agent-roster.list`,{},e.signal).then(e=>{let t=e.roles;Array.isArray(t)&&l(t.filter(e=>typeof e==`string`))}).catch(()=>void 0),()=>e.abort()},[]);let f=(e,n)=>{i({...t,[e]:n})},m=()=>{f(`anchors`,[...t.anchors,{type:`file`,path:``}])};return(0,K.jsxs)(`form`,{className:`flex min-h-0 flex-1 flex-col`,onSubmit:e=>{e.preventDefault(),o()},"aria-busy":n,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-border/70 bg-card/70 px-4 py-3 backdrop-blur-xl`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`flex size-8 items-center justify-center border border-info/35 bg-info/10 text-info`,children:e===`create`?(0,K.jsx)(p,{className:`size-4`}):(0,K.jsx)(d,{className:`size-4`})}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`p`,{className:`truncate text-sm font-bold`,children:e===`create`?`Capture a memory`:`Edit memory`}),(0,K.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:e===`create`?`Add durable knowledge with retrieval metadata.`:`Update content without losing provenance.`})]})]}),(0,K.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,K.jsxs)(R,{type:`button`,variant:`ghost`,size:`sm`,onClick:a,disabled:n,children:[(0,K.jsx)(b,{className:`size-3.5`}),` Cancel`]}),(0,K.jsxs)(R,{type:`submit`,size:`sm`,disabled:n||!t.text.trim(),children:[n?(0,K.jsx)(se,{className:`size-3.5 animate-spin`}):e===`create`?(0,K.jsx)(fe,{className:`size-3.5`}):(0,K.jsx)(y,{className:`size-3.5`}),n?`Saving…`:e===`create`?`Create memory`:`Save changes`]})]})]}),(0,K.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto overscroll-contain p-4 md:p-5`,children:(0,K.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-5`,children:[r&&(0,K.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-2 border border-destructive/40 bg-destructive/10 px-3 py-2.5 text-sm text-destructive`,children:[(0,K.jsx)(u,{className:`mt-0.5 size-4 shrink-0`}),(0,K.jsx)(`span`,{children:r})]}),(0,K.jsxs)(`section`,{className:`border border-border/75 bg-card/45 p-4`,children:[(0,K.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-xs font-bold uppercase tracking-[0.14em]`,children:`Knowledge`}),(0,K.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:`Write the durable fact or decision in complete, searchable language.`})]}),(0,K.jsxs)(`span`,{className:`font-mono text-[10px] text-muted-foreground tabular-nums`,children:[t.text.length,` chars`]})]}),(0,K.jsx)(`label`,{htmlFor:`memory-text`,className:`sr-only`,children:`Memory content`}),(0,K.jsx)(`textarea`,{ref:s,id:`memory-text`,value:t.text,onChange:e=>f(`text`,e.target.value),rows:7,required:!0,placeholder:`Example: WebUI state is owned by Zustand stores; server messages update those stores through singleton WebSocket handlers.`,className:`min-h-36 w-full resize-y border border-input bg-background/75 px-3 py-3 text-sm leading-6 text-foreground shadow-inner placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`})]}),(0,K.jsxs)(`section`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`label`,{htmlFor:`memory-kind`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Kind`}),(0,K.jsx)(`select`,{id:`memory-kind`,value:t.kind,onChange:e=>f(`kind`,e.target.value),className:`h-10 w-full border border-input bg-background px-3 text-sm`,children:V.map(e=>(0,K.jsx)(`option`,{value:e,children:Pe[e]},e))})]}),e===`create`?(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`label`,{htmlFor:`memory-scope`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Scope`}),(0,K.jsx)(`select`,{id:`memory-scope`,value:t.scope,onChange:e=>f(`scope`,e.target.value),className:`h-10 w-full border border-input bg-background px-3 text-sm`,children:Te.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))})]}):(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`label`,{htmlFor:`memory-status`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Lifecycle status`}),(0,K.jsx)(`select`,{id:`memory-status`,value:t.status,onChange:e=>f(`status`,e.target.value),className:`h-10 w-full border border-input bg-background px-3 text-sm`,children:je.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))})]}),(0,K.jsxs)(`div`,{className:F(`min-w-0`,e===`create`?`sm:col-span-2 lg:col-span-1`:``),children:[(0,K.jsx)(`label`,{htmlFor:`memory-tags`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Tags`}),(0,K.jsx)(z,{id:`memory-tags`,value:t.tags,onChange:e=>f(`tags`,e.target.value),placeholder:`architecture, webui, workflow`,className:`h-10 bg-background`})]})]}),(0,K.jsxs)(`section`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,K.jsx)(De,{id:`memory-importance`,label:`Importance`,value:t.importance,onChange:e=>f(`importance`,e)}),(0,K.jsx)(De,{id:`memory-confidence`,label:`Confidence`,value:t.confidence,onChange:e=>f(`confidence`,e)}),(0,K.jsx)(De,{id:`memory-freshness`,label:`Freshness`,value:t.freshness,onChange:e=>f(`freshness`,e)})]}),(0,K.jsxs)(`section`,{className:`border border-border/75 bg-card/45 p-4`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-xs font-bold uppercase tracking-[0.14em]`,children:`Anchors`}),(0,K.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:`Bind knowledge to files, symbols, packages, tests, Git paths, or commands.`})]}),(0,K.jsxs)(R,{type:`button`,variant:`outline`,size:`sm`,onClick:m,children:[(0,K.jsx)(fe,{className:`size-3.5`}),` Add anchor`]})]}),t.anchors.length===0?(0,K.jsxs)(`button`,{type:`button`,onClick:m,className:`mt-4 flex w-full items-center justify-center gap-2 border border-dashed border-border px-4 py-7 text-xs text-muted-foreground transition-colors hover:border-info/50 hover:bg-info/5 hover:text-info`,children:[(0,K.jsx)(ie,{className:`size-4`}),` No anchors yet — add one to improve retrieval precision`]}):(0,K.jsx)(`div`,{className:`mt-4 space-y-2`,children:t.anchors.map((e,n)=>(0,K.jsxs)(`div`,{className:`grid gap-2 border border-border/65 bg-background/40 p-2 sm:grid-cols-[9rem_minmax(0,1fr)_auto]`,children:[(0,K.jsxs)(`label`,{className:`sr-only`,htmlFor:`anchor-type-${n}`,children:[`Anchor `,n+1,` type`]}),(0,K.jsx)(`select`,{id:`anchor-type-${n}`,value:e.type,onChange:e=>{let r=e.target.value,i=r===`command`?{type:r,command:``}:r===`agent`?{type:r,role:``}:{type:r,path:``},a=t.anchors.map((e,t)=>t===n?i:e);f(`anchors`,a)},className:`h-10 border border-input bg-background px-2 text-xs`,children:Ie.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))}),(0,K.jsxs)(`div`,{className:F(`grid min-w-0 gap-2`,e.type===`symbol`&&`sm:grid-cols-[minmax(0,1fr)_11rem]`),children:[(0,K.jsxs)(`label`,{className:`sr-only`,htmlFor:`anchor-value-${n}`,children:[`Anchor `,n+1,` value`]}),(0,K.jsx)(z,{id:`anchor-value-${n}`,list:e.type===`agent`?`memory-agent-role-options`:void 0,value:Le(e),onChange:e=>{let r=t.anchors.map((t,r)=>r===n?Ee(t,e.target.value):t);f(`anchors`,r)},placeholder:e.type===`command`?`pnpm test --filter webui`:e.type===`agent`?`reviewer`:`packages/webui/src/App.tsx`,className:`h-10 min-w-0 bg-background font-mono text-xs`}),e.type===`symbol`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`label`,{className:`sr-only`,htmlFor:`anchor-symbol-${n}`,children:[`Anchor `,n+1,` symbol`]}),(0,K.jsx)(z,{id:`anchor-symbol-${n}`,value:e.symbol??``,onChange:e=>{let r=t.anchors.map((t,r)=>r===n?{...t,symbol:e.target.value}:t);f(`anchors`,r)},placeholder:`Symbol name`,className:`h-10 bg-background font-mono text-xs`})]})]}),(0,K.jsx)(R,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Remove anchor ${n+1}`,onClick:()=>f(`anchors`,t.anchors.filter((e,t)=>t!==n)),children:(0,K.jsx)(T,{className:`size-4 text-destructive`})})]},`${e.type}:${n}`))}),(0,K.jsx)(`datalist`,{id:`memory-agent-role-options`,children:c.map(e=>(0,K.jsx)(`option`,{value:e},e))})]}),(0,K.jsxs)(`section`,{className:`grid gap-3 border border-border/75 bg-card/45 p-4 sm:grid-cols-2`,children:[(0,K.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,K.jsx)(`h3`,{className:`text-xs font-bold uppercase tracking-[0.14em]`,children:`Relationships`}),(0,K.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:`Reference exact memory IDs. Relationships are validated and graph edges are rebuilt by SAGE.`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{htmlFor:`memory-supersedes`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Supersedes`}),(0,K.jsx)(z,{id:`memory-supersedes`,value:t.supersedes,onChange:e=>f(`supersedes`,e.target.value),placeholder:`mem_id, mem_id`,className:`h-10 bg-background font-mono text-xs`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{htmlFor:`memory-contradicts`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Contradicts`}),(0,K.jsx)(z,{id:`memory-contradicts`,value:t.contradicts,onChange:e=>f(`contradicts`,e.target.value),placeholder:`mem_id, mem_id`,className:`h-10 bg-background font-mono text-xs`})]})]}),(0,K.jsxs)(`section`,{className:`space-y-2`,children:[(0,K.jsx)(`h3`,{className:`text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Audience (Optional)`}),(0,K.jsx)(`p`,{className:`text-[10px] text-muted-foreground/70`,children:`Target this memory to specific agent types. Leave empty for general project memory.`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{htmlFor:`memory-audience-roles`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Roles`}),(0,K.jsx)(z,{id:`memory-audience-roles`,value:t.audienceRoles,onChange:e=>f(`audienceRoles`,e.target.value),placeholder:`reviewer, refactor-planner`,className:`h-9 bg-background font-mono text-xs`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{htmlFor:`memory-audience-task-types`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Task types`}),(0,K.jsx)(z,{id:`memory-audience-task-types`,value:t.audienceTaskTypes,onChange:e=>f(`audienceTaskTypes`,e.target.value),placeholder:`review, refactor, bugfix`,className:`h-9 bg-background font-mono text-xs`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{htmlFor:`memory-audience-modes`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Modes`}),(0,K.jsx)(z,{id:`memory-audience-modes`,value:t.audienceModes,onChange:e=>f(`audienceModes`,e.target.value),placeholder:`teach, code-review`,className:`h-9 bg-background font-mono text-xs`})]})]})]})})]})}function ct({searchQuery:e,statusFilter:t,kindFilter:n,audienceOnly:r,tagFilter:i,hasFilters:o,allTags:c,stats:l,onSearchChange:u,onStatusFilterChange:d,onKindFilterChange:f,onToggleAudienceOnly:p,onTagFilterChange:m,onClearFilters:g}){let[_,ee]=(0,G.useState)(!!i),y=_||!!i,x=c.length>0;return(0,K.jsxs)(`div`,{className:`shrink-0 space-y-2 overflow-hidden border-b border-border/70 bg-card/45 p-3`,children:[(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,K.jsx)(v,{className:`pointer-events-none absolute left-3 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,K.jsx)(z,{"aria-label":`Search memories`,value:e,onChange:e=>u(e.target.value),placeholder:`Search content, IDs, tags, anchors…`,className:`h-10 min-w-0 bg-background pl-9 pr-8 text-xs`}),e&&(0,K.jsx)(`button`,{type:`button`,"aria-label":`Clear search`,onClick:()=>u(``),className:`absolute right-2 top-1/2 -translate-y-1/2 p-1 text-muted-foreground hover:text-foreground`,children:(0,K.jsx)(b,{className:`size-3.5`})})]}),(0,K.jsx)(R,{variant:r?`default`:`ghost`,size:`icon`,onClick:p,"aria-label":`Filter audience-scoped only`,title:`Show only audience-scoped memories`,className:`shrink-0`,children:(0,K.jsx)(j,{className:`size-4`})}),o&&(0,K.jsx)(R,{variant:`ghost`,size:`icon`,onClick:g,"aria-label":`Clear all filters`,title:`Clear all filters`,children:(0,K.jsx)(s,{className:`size-4`})})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,K.jsx)(`label`,{className:`sr-only`,htmlFor:`memory-status-filter`,children:`Filter by status`}),(0,K.jsxs)(`select`,{id:`memory-status-filter`,value:t,onChange:e=>d(e.target.value),className:`h-9 min-w-0 border border-input bg-background px-2 text-xs`,children:[(0,K.jsx)(`option`,{value:`all`,children:`All statuses`}),Me.map(e=>(0,K.jsxs)(`option`,{value:e,children:[e,` · `,l?.byStatus[e]??0]},e))]}),(0,K.jsx)(`label`,{className:`sr-only`,htmlFor:`memory-kind-filter`,children:`Filter by kind`}),(0,K.jsxs)(`select`,{id:`memory-kind-filter`,value:n,onChange:e=>f(e.target.value),className:`h-9 min-w-0 border border-input bg-background px-2 text-xs`,children:[(0,K.jsx)(`option`,{value:`all`,children:`All kinds`}),V.map(e=>(0,K.jsxs)(`option`,{value:e,children:[Pe[e],` · `,l?.byKind[e]??0]},e))]})]}),x&&(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>{i||ee(e=>!e)},"aria-expanded":y,"aria-controls":`memory-tags-panel`,disabled:!!i,className:F(`flex items-center gap-1.5 px-1 py-0.5 text-[10px] uppercase tracking-wide transition-colors`,y?`text-foreground`:`text-muted-foreground hover:text-foreground`,!!i&&`cursor-default`),title:i?`Active filter: ${i} (click the chip to clear)`:y?`Hide tag filters`:`Show tag filters (${c.length})`,children:[(0,K.jsx)(h,{className:F(`size-3 transition-transform`,!y&&`-rotate-90`)}),(0,K.jsx)(a,{className:`size-3`}),(0,K.jsx)(`span`,{className:`font-semibold`,children:`Tags`}),(0,K.jsx)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:c.length})]}),i&&(0,K.jsx)(`span`,{role:`status`,"aria-label":`Active tag filter: ${i}`,className:`border border-info/55 bg-info/10 px-1 font-mono text-[9px] uppercase text-info`,children:i})]}),x&&y&&(0,K.jsxs)(`fieldset`,{id:`memory-tags-panel`,className:`min-w-0 border-0 p-0`,children:[(0,K.jsx)(`legend`,{className:`sr-only`,children:`Popular tags`}),(0,K.jsx)(`div`,{className:`no-scrollbar flex gap-1.5 overflow-x-auto pb-0.5`,children:c.slice(0,18).map(([e,t])=>(0,K.jsxs)(`button`,{type:`button`,"aria-pressed":i===e,onClick:()=>m(i===e?null:e),className:F(`flex shrink-0 items-center gap-1 border px-2 py-1 text-[10px] transition-colors`,i===e?`border-info/55 bg-info/10 text-info`:`border-border/70 bg-background/45 text-muted-foreground hover:border-info/35 hover:text-foreground`),children:[(0,K.jsx)(a,{className:`size-2.5`}),` `,e,(0,K.jsx)(`span`,{className:`font-mono opacity-60`,children:t})]},e))})]})]})}var lt=100;function ut({memoryListRef:e,memories:t,filteredMemories:n,selectedId:r,onSelectMemory:i,onOpenCreate:a,onClearFilters:o}){let s=n.length>lt,c=oe({count:n.length,getScrollElement:()=>e.current,estimateSize:()=>100,overscan:8,enabled:s});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-border/60 px-3 py-2 text-[10px] text-muted-foreground`,children:[(0,K.jsxs)(`span`,{children:[n.length,` of `,t.length,` memories`]}),(0,K.jsx)(`span`,{className:`font-mono uppercase`,children:`updated ↓`})]}),(0,K.jsx)(`section`,{ref:e,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,"aria-label":`Memories`,children:n.length===0?(0,K.jsx)(dt,{hasMemories:t.length>0,onOpenCreate:a,onClearFilters:o}):s?(0,K.jsx)(`div`,{style:{height:`${c.getTotalSize()}px`,width:`100%`,position:`relative`},children:c.getVirtualItems().map(e=>{let t=n[e.index];return t?(0,K.jsx)(`div`,{"data-index":e.index,ref:c.measureElement,style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${e.start}px)`},children:(0,K.jsx)(ft,{memory:t,isSelected:r===t.id,onClick:()=>i(t.id)})},t.id):null})}):n.map(e=>(0,K.jsx)(ft,{memory:e,isSelected:r===e.id,onClick:()=>i(e.id)},e.id))})]})}function dt({hasMemories:e,onOpenCreate:t,onClearFilters:n}){return(0,K.jsxs)(`div`,{className:`flex min-h-64 flex-col items-center justify-center px-6 text-center`,children:[(0,K.jsx)(`span`,{className:`flex size-12 items-center justify-center border border-dashed border-border text-muted-foreground`,children:(0,K.jsx)(S,{className:`size-5`})}),(0,K.jsx)(`h2`,{className:`mt-4 text-sm font-bold`,children:e?`No matching memories`:`Build your memory graph`}),(0,K.jsx)(`p`,{className:`mt-1 max-w-xs text-xs leading-5 text-muted-foreground`,children:e?`Change the filters or clear the search query.`:`Capture durable facts, decisions, conventions, and file-bound notes for every agent.`}),(0,K.jsxs)(R,{className:`mt-4`,variant:`outline`,size:`sm`,onClick:e?n:t,children:[e?(0,K.jsx)(s,{className:`size-3.5`}):(0,K.jsx)(fe,{className:`size-3.5`}),e?`Clear filters`:`Create first memory`]})]})}function ft({memory:e,isSelected:t,onClick:n}){return(0,K.jsxs)(`button`,{type:`button`,"aria-current":t?`true`:void 0,onClick:n,className:F(`group relative block w-full border-b border-border/55 px-3 py-3 text-left transition-[background-color,border-color] hover:bg-info/5`,t&&`bg-info/8`),children:[t&&(0,K.jsx)(`span`,{className:`absolute inset-y-0 left-0 w-0.5 bg-info shadow-[0_0_10px_hsl(var(--info)/0.7)]`}),(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,K.jsx)(`span`,{className:F(`truncate text-[10px] font-bold uppercase tracking-[0.1em]`,Ae(e.kind)),children:Pe[e.kind]??e.kind}),(0,K.jsx)(H,{status:e.status}),(0,K.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono text-[9px] text-muted-foreground`,children:[`r`,e.revision]})]}),(0,K.jsx)(`p`,{className:F(`mt-2 line-clamp-2 text-xs leading-5 text-foreground/90`,e.status===`deleted`&&`line-through opacity-60`),children:B(e.text)}),(0,K.jsxs)(`div`,{className:`mt-2 flex min-w-0 items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:`border border-border/60 bg-background/50 px-1.5 py-0.5 font-mono text-[9px] uppercase text-muted-foreground`,children:e.scope}),e.audience&&(0,K.jsxs)(`span`,{className:`flex items-center gap-0.5 border border-primary/30 bg-primary/10 px-1.5 py-0.5 font-mono text-[9px] text-primary`,children:[(0,K.jsx)(j,{className:`size-2.5`}),(e.audience.roles??e.audience.taskTypes??e.audience.modes??[]).slice(0,1)[0]??`scoped`]}),e.tags.slice(0,2).map(e=>(0,K.jsxs)(`span`,{className:`max-w-24 truncate border border-border/60 px-1.5 py-0.5 font-mono text-[9px] text-muted-foreground`,children:[`#`,e]},e)),e.tags.length>2&&(0,K.jsxs)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:[`+`,e.tags.length-2]}),(0,K.jsx)(`span`,{className:`ml-auto shrink-0 text-[9px] text-muted-foreground`,children:Re(e.updatedAt)}),(0,K.jsx)(ce,{className:`size-3 shrink-0 text-muted-foreground transition-transform group-hover:translate-x-0.5 group-hover:text-info`})]})]})}function pt({busyAction:e,deletingId:t,memories:n,onCancel:r,onConfirm:i,onOpenChange:a}){return(0,K.jsx)(L,{open:!!t,onOpenChange:a,children:(0,K.jsxs)(ve,{className:`max-w-md`,children:[(0,K.jsxs)(ge,{children:[(0,K.jsx)(`span`,{className:`mb-2 flex size-10 items-center justify-center border border-destructive/35 bg-destructive/10 text-destructive`,children:(0,K.jsx)(T,{className:`size-4`})}),(0,K.jsx)(ye,{children:`Delete this memory?`}),(0,K.jsx)(I,{className:`leading-6`,children:`SAGE will mark the record deleted, remove graph edges, and clean references from related memories. The record remains in the audit trail but cannot be restored from this page.`})]}),(0,K.jsx)(`div`,{className:`border border-border/70 bg-background/45 p-3 text-xs text-muted-foreground`,children:B(n.find(e=>e.id===t)?.text??``,180)}),(0,K.jsxs)(_e,{children:[(0,K.jsx)(R,{variant:`outline`,onClick:r,disabled:e===`delete`,children:`Cancel`}),(0,K.jsxs)(R,{variant:`destructive`,onClick:i,disabled:e===`delete`,children:[e===`delete`?(0,K.jsx)(se,{className:`size-4 animate-spin`}):(0,K.jsx)(T,{className:`size-4`}),e===`delete`?`Deleting…`:`Delete memory`]})]})]})})}function mt({onCapture:e}){return(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center p-8 text-center`,children:[(0,K.jsxs)(`div`,{className:`relative flex size-20 items-center justify-center border border-info/25 bg-info/5 text-info`,children:[(0,K.jsx)(j,{className:`size-8`}),(0,K.jsx)(`span`,{className:`absolute inset-2 border border-info/10`})]}),(0,K.jsx)(`h2`,{className:`mt-5 text-lg font-bold`,children:`Your project’s long-term context`}),(0,K.jsx)(`p`,{className:`mt-2 max-w-md text-sm leading-6 text-muted-foreground`,children:`Select a memory to inspect its metadata and relationship graph, or capture knowledge that future agents should retrieve automatically.`}),(0,K.jsxs)(`div`,{className:`mt-6 grid w-full max-w-lg gap-2 sm:grid-cols-3`,children:[(0,K.jsxs)(`div`,{className:`border border-border/70 bg-card/45 p-3`,children:[(0,K.jsx)(m,{className:`mx-auto size-4 text-success`}),(0,K.jsx)(`p`,{className:`mt-2 text-[10px] font-bold uppercase`,children:`Verified anchors`})]}),(0,K.jsxs)(`div`,{className:`border border-border/70 bg-card/45 p-3`,children:[(0,K.jsx)(j,{className:`mx-auto size-4 text-info`}),(0,K.jsx)(`p`,{className:`mt-2 text-[10px] font-bold uppercase`,children:`Typed relations`})]}),(0,K.jsxs)(`div`,{className:`border border-border/70 bg-card/45 p-3`,children:[(0,K.jsx)(fe,{className:`mx-auto size-4 text-warning`}),(0,K.jsx)(`p`,{className:`mt-2 text-[10px] font-bold uppercase`,children:`Agent recall`})]})]}),(0,K.jsxs)(R,{onClick:e,children:[(0,K.jsx)(fe,{className:`size-4`}),` Capture memory`]})]})}function ht(e,t){let n=t.searchQuery.trim().toLowerCase();return e.filter(e=>{if(t.statusFilter!==`all`&&e.status!==t.statusFilter||t.kindFilter!==`all`&&e.kind!==t.kindFilter||t.tagFilter&&!e.tags.includes(t.tagFilter)||t.audienceOnly&&!e.audience)return!1;if(!n)return!0;let r=e.anchors.map(e=>[e.path,e.symbol,e.command,e.role].filter(Boolean).join(` `)).join(` `),i=e.audience?[e.audience.roles?.join(` `)??``,e.audience.taskTypes?.join(` `)??``,e.audience.modes?.join(` `)??``].join(` `):``;return[e.id,e.text,e.summary??``,e.kind,e.scope,e.tags.join(` `),r,i].join(` `).toLowerCase().includes(n)})}function gt(e){let t=new Map;for(let n of e)for(let e of n.tags)t.set(e,(t.get(e)??0)+1);return[...t.entries()].sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0]))}function _t(e){if(!e)return[];let t=[];e.supersededBy&&t.push({relation:`Superseded by`,id:e.supersededBy});for(let n of e.supersedes??[])t.push({relation:`Supersedes`,id:n});for(let n of e.contradicts??[])t.push({relation:`Contradicts`,id:n});return t}function vt(){let{client:e,listSageMemoriesPage:n,rememberSage:r,updateSage:i,deleteSage:a,getSageGraph:o,recoverSage:s,resolveMemoryCandidate:c}=me(),l=he(e=>e.wsConnected),d=pe(e=>e.setCurrentView),f=Se(`memory`),[p,h]=(0,G.useState)([]),[g,_]=(0,G.useState)(null),[ee,v]=(0,G.useState)(!0),[y,b]=(0,G.useState)(!1),[x,S]=(0,G.useState)(null),[C,w]=(0,G.useState)(null),[T,E]=(0,G.useState)(null),[D,O]=(0,G.useState)(null),[re,ie]=(0,G.useState)([]),[ae,oe]=(0,G.useState)([]),[se,k]=(0,G.useState)(null),[ce,A]=(0,G.useState)(!1),[le,M]=(0,G.useState)(!1),[N,ue]=(0,G.useState)(!1),[P,ge]=(0,G.useState)(ke),[_e,ve]=(0,G.useState)(ke),[ye,I]=(0,G.useState)(null),[L,z]=(0,G.useState)(null),[be,xe]=(0,G.useState)(``),[Ce,Te]=(0,G.useState)(`all`),[Ee,De]=(0,G.useState)(`all`),[B,Ae]=(0,G.useState)(!1),[V,H]=(0,G.useState)(null),[U,je]=(0,G.useState)(!1),[Me,Ne]=(0,G.useState)(null),[Pe,Ie]=(0,G.useState)(!1),[Le,Re]=(0,G.useState)(!1),[ze,Be]=(0,G.useState)({}),[Ve,He]=(0,G.useState)(!1),[Ue,We]=(0,G.useState)(null),[Ge,Ke]=(0,G.useState)(void 0),[qe,Je]=(0,G.useState)(void 0),Ye=(0,G.useRef)(!1),q=(0,G.useRef)(!0),Ze=(0,G.useRef)(0),J=(0,G.useRef)(0),Qe=(0,G.useRef)(null),Y=(0,G.useRef)(null),$e=(0,G.useMemo)(()=>JSON.stringify(P)!==JSON.stringify(_e),[_e,P]),X=(0,G.useMemo)(()=>p.find(e=>e.id===D)??null,[p,D]),et=(0,G.useCallback)(t=>{let r=t!==null,i=++Ze.current;Qe.current?.(),S(null),r?Re(!0):(b(!0),Ye.current||v(!0));let a=()=>{},o=null,s=!1,c=()=>{s||(s=!0,o!==null&&clearTimeout(o),a(),Qe.current===c&&(Qe.current=null))};a=e.on(`memory.sage.listPage`,e=>{if(i!==Ze.current||!q.current){c();return}if(c(),e.payload.error)S(e.payload.error);else{let t=e.payload.memories??[];h(e=>r?[...e,...t]:t),Ne(e.payload.nextCursor??null),Ie(!!e.payload.nextCursor);let n=e.payload.statusCounts??{};Be(n);let i=Object.values(n).reduce((e,t)=>e+t,0);e.payload.stats?_(e.payload.stats):_(e=>({total:i,byStatus:n,byKind:e?.byKind??{},edges:e?.edges??0})),Ye.current=!0,r||O(e=>e&&t.some(t=>t.id===e)?e:null)}v(!1),b(!1),Re(!1)}),o=setTimeout(()=>{i!==Ze.current||!q.current||(c(),S(`The memory store did not respond. Check the WebSocket connection and try again.`),v(!1),b(!1),Re(!1))},2e4),Qe.current=c,n({limit:100,...U?{statuses:[`deleted`]}:{},...t?{cursor:t}:{}},{echoToChat:!1})},[e,n,U]),Z=(0,G.useCallback)(()=>{Ne(null),Ie(!1),et(null)},[et]),tt=(0,G.useCallback)(()=>{Le||!Me||et(Me)},[et,Le,Me]);(0,G.useEffect)(()=>(q.current=!0,Z(),()=>{q.current=!1,Ze.current+=1,J.current+=1,Qe.current?.(),Y.current?.()}),[Z]),(0,G.useEffect)(()=>{if(ie([]),oe([]),k(null),!D){A(!1);return}let t=D;A(!0);let n=null,r=e.on(`memory.sage.graph`,e=>{e.payload.query===t&&(n!==null&&clearTimeout(n),ie(e.payload.edges??[]),oe(e.payload.memories??[]),k(e.payload.error??null),A(!1))});return n=setTimeout(()=>{k(`Relationship graph did not respond in time.`),A(!1)},15e3),o(t,{maxDepth:1,limit:120},{echoToChat:!1}),()=>{n!==null&&clearTimeout(n),r()}},[e,o,D]);let nt=(0,G.useRef)(l);(0,G.useEffect)(()=>{l&&!nt.current&&Ye.current&&Z(),nt.current=l},[Z,l]),(0,G.useEffect)(()=>{if(!T)return;let e=setTimeout(()=>E(null),4e3);return()=>clearTimeout(e)},[T]);let Q=(0,G.useCallback)(()=>!$e||!le&&!N||window.confirm(`Discard the unsaved memory changes?`),[N,$e,le]),rt=(0,G.useCallback)(()=>{if(!Q())return;let e=ke();ge(e),ve(e),ue(!0),M(!1),O(null),w(null)},[Q]),it=(0,G.useCallback)(e=>{Q()&&(O(e),ue(!1),M(!1),w(null))},[Q]),ot=(0,G.useCallback)(()=>{if(!X||X.status===`deleted`)return;let e=Oe(X);ge(e),ve(e),M(!0),ue(!1),w(null)},[X]),lt=(0,G.useCallback)(()=>{Q()&&(M(!1),ue(!1),w(null))},[Q]),dt=(0,G.useCallback)((t,n,r)=>{if(!P.text.trim()){w(`Memory content is required.`);return}let i=++J.current;Y.current?.(),I(r),w(null),E(null);let a=()=>{},o=null,s=!1,c=()=>{s||(s=!0,o!==null&&clearTimeout(o),a(),Y.current===c&&(Y.current=null))},l=e=>{if(i!==J.current||!q.current){c();return}if(c(),I(null),e.payload.error||!e.payload.memory){w(e.payload.error??`The server returned no memory record.`);return}let t=e.payload.memory;h(e=>{let n=e.filter(e=>e.id!==t.id);return[t,...n]}),O(t.id),ue(!1),M(!1),E(r===`create`?`Memory captured.`:`Memory updated.`),Z()};a=t===`memory.sage.remember`?e.on(`memory.sage.remember`,l):e.on(`memory.sage.update`,l),o=setTimeout(()=>{i!==J.current||!q.current||(c(),I(null),w(`${r===`create`?`Create`:`Save`} timed out. Your draft is still here.`))},2e4),Y.current=c,n()},[e,P.text,Z]),ft=(0,G.useCallback)(()=>{dt(`memory.sage.remember`,()=>r({text:P.text.trim(),kind:P.kind,scope:P.scope,tags:W(P.tags),importance:P.importance,confidence:P.confidence,freshness:P.freshness,anchors:we(P.anchors),...W(P.audienceRoles).length||W(P.audienceTaskTypes).length||W(P.audienceModes).length?{audience:{roles:W(P.audienceRoles),taskTypes:W(P.audienceTaskTypes),modes:W(P.audienceModes)}}:{},supersedes:W(P.supersedes),contradicts:W(P.contradicts)},{echoToChat:!1}),`create`)},[P,r,dt]),vt=(0,G.useCallback)(()=>{X&&dt(`memory.sage.update`,()=>i(X.id,{text:P.text.trim(),kind:P.kind,status:P.status,tags:W(P.tags),importance:P.importance,confidence:P.confidence,freshness:P.freshness,anchors:we(P.anchors),...W(P.audienceRoles).length||W(P.audienceTaskTypes).length||W(P.audienceModes).length?{audience:{roles:W(P.audienceRoles),taskTypes:W(P.audienceTaskTypes),modes:W(P.audienceModes)}}:{},supersedes:W(P.supersedes),contradicts:W(P.contradicts)},{echoToChat:!1}),`update`)},[P,dt,X,i]),yt=(0,G.useCallback)(()=>{if(!L)return;let t=++J.current;Y.current?.(),I(`delete`),w(null);let n=()=>{},r=null,i=!1,o=()=>{i||(i=!0,r!==null&&clearTimeout(r),n(),Y.current===o&&(Y.current=null))};n=e.on(`memory.sage.delete`,e=>{if(t!==J.current||!q.current){o();return}if(o(),I(null),!e.payload.success){w(e.payload.message||`Delete failed.`);return}z(null),O(null),M(!1),E(`Memory deleted and relationship edges cleaned up.`),Z()}),r=setTimeout(()=>{t!==J.current||!q.current||(o(),I(null),w(`Delete timed out. The memory may still exist; refresh to confirm.`))},2e4),Y.current=o,a(L,`Deleted from the WebUI Memory Manager.`)},[e,a,L,Z]),bt=(0,G.useMemo)(()=>ht(p,{searchQuery:be,statusFilter:Ce,kindFilter:Ee,tagFilter:V,audienceOnly:B}),[B,Ee,p,be,Ce,V]),xt=(0,G.useMemo)(()=>gt(p),[p]),St=(0,G.useMemo)(()=>_t(X),[X]),Ct=(0,G.useCallback)(()=>{xe(``),Te(`all`),De(`all`),Ae(!1),H(null)},[]),wt=!!(be||Ce!==`all`||Ee!==`all`||V||B),Tt=N||!!X,$=Ve&&!!Ue;return ee&&p.length===0?(0,K.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-background`,"aria-busy":`true`,children:[(0,K.jsxs)(`div`,{className:`border-b border-border/70 bg-card/70 px-5 py-4`,children:[(0,K.jsx)(`div`,{className:`h-3 w-28 animate-pulse bg-muted`}),(0,K.jsx)(`div`,{className:`mt-3 h-7 w-56 animate-pulse bg-muted`})]}),(0,K.jsxs)(`div`,{className:`grid flex-1 gap-px bg-border/60 md:grid-cols-[minmax(300px,0.82fr)_minmax(0,1.35fr)]`,children:[(0,K.jsx)(`div`,{className:`space-y-px bg-background p-4`,children:Array.from({length:7},(e,t)=>(0,K.jsx)(`div`,{className:`h-24 animate-pulse border border-border/60 bg-card/45`},t))}),(0,K.jsx)(`div`,{className:`hidden bg-background p-6 md:block`,children:(0,K.jsx)(`div`,{className:`h-full animate-pulse border border-border/60 bg-card/35`})})]}),(0,K.jsx)(`span`,{className:`sr-only`,role:`status`,children:`Loading SAGE content`})]}):x&&p.length===0?(0,K.jsx)(`div`,{className:`flex h-full min-h-0 items-center justify-center bg-background p-6`,children:(0,K.jsxs)(`div`,{className:`max-w-md border border-destructive/35 bg-card p-6 shadow-2xl`,children:[(0,K.jsx)(`span`,{className:`flex size-11 items-center justify-center border border-destructive/35 bg-destructive/10 text-destructive`,children:(0,K.jsx)(u,{className:`size-5`})}),(0,K.jsx)(`h2`,{className:`mt-4 text-lg font-bold`,children:`Memory store unavailable`}),(0,K.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-muted-foreground`,children:x}),(0,K.jsxs)(`div`,{className:`mt-5 flex gap-2`,children:[(0,K.jsxs)(R,{onClick:Z,children:[(0,K.jsx)(te,{className:`size-4`}),` Retry`]}),(0,K.jsxs)(R,{variant:`outline`,onClick:()=>d(`chat`),children:[(0,K.jsx)(de,{className:`size-4`}),` Back to chat`]})]})]})}):(0,K.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-background`,children:[(0,K.jsxs)(`header`,{className:`relative shrink-0 overflow-hidden border-b border-border/70 bg-card/72 px-4 py-3 backdrop-blur-xl sm:px-5`,children:[(0,K.jsx)(`div`,{className:`pointer-events-none absolute inset-y-0 right-0 w-1/2 bg-[radial-gradient(circle_at_right,hsl(var(--info)/0.11),transparent_68%)]`}),(0,K.jsxs)(`div`,{className:`relative flex flex-wrap items-center gap-3`,children:[(0,K.jsx)(R,{variant:`ghost`,size:`icon`,onClick:()=>d(`chat`),"aria-label":`Back to chat`,title:`Back to chat`,children:(0,K.jsx)(de,{className:`size-4`})}),(0,K.jsx)(`span`,{className:`flex size-10 items-center justify-center border border-info/40 bg-info/10 text-info shadow-[0_0_20px_hsl(var(--info)/0.12)]`,children:(0,K.jsx)(j,{className:`size-5`})}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(`h1`,{className:`text-base font-bold sm:text-lg`,children:`SAGE`}),(0,K.jsx)(`span`,{className:`border border-success/35 bg-success/10 px-2 py-0.5 font-mono text-[9px] font-bold uppercase text-success`,children:`project knowledge`})]}),(0,K.jsx)(`p`,{className:`mt-0.5 max-w-2xl text-[10px] text-muted-foreground sm:text-xs`,children:`Inspect, connect, curate, and retire durable context used across agent sessions.`})]}),(0,K.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,K.jsxs)(`span`,{className:F(`hidden items-center gap-1.5 border px-2 py-1 font-mono text-[9px] uppercase sm:flex`,l?`border-success/30 text-success`:`border-warning/30 text-warning`),children:[(0,K.jsx)(`span`,{className:`size-1.5 bg-current`}),` `,l?`live store`:`reconnecting`]}),(0,K.jsxs)(R,{variant:`outline`,size:`sm`,onClick:Z,disabled:y,"aria-label":`Refresh memories`,children:[(0,K.jsx)(te,{className:F(`size-3.5`,y&&`animate-spin`)}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:`Refresh`})]}),(0,K.jsxs)(R,{size:`sm`,onClick:rt,children:[(0,K.jsx)(fe,{className:`size-3.5`}),` New memory`]})]})]})]}),(0,K.jsxs)(`div`,{className:`grid shrink-0 grid-cols-2 gap-px border-b border-border/70 bg-border/60 sm:grid-cols-4`,children:[(0,K.jsx)(Fe,{label:`Memories`,value:g?.total??p.length,hint:`${bt.length} visible`}),(0,K.jsx)(Fe,{label:`Active`,value:g?.byStatus.active??p.filter(e=>e.status===`active`).length,hint:`retrievable`,tone:`success`}),(0,K.jsx)(Fe,{label:`Needs review`,value:(g?.byStatus.stale??0)+(g?.byStatus.contradicted??0),hint:`stale + conflicts`,tone:`warning`}),(0,K.jsx)(`div`,{className:`hidden sm:block`,children:(0,K.jsx)(Fe,{label:`Graph edges`,value:g?.edges??0,hint:`${xt.length} tags`,tone:`info`})})]}),(()=>{let e=p.filter(e=>e.audience).length;if(e===0)return null;let t=new Set;for(let e of p)if(e.audience){for(let n of e.audience.roles??[])t.add(n);for(let n of e.audience.taskTypes??[])t.add(n);for(let n of e.audience.modes??[])t.add(n)}return(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-border/70 bg-primary/5 px-4 py-1.5`,children:[(0,K.jsx)(j,{className:`size-3.5 text-primary`}),(0,K.jsxs)(`span`,{className:`text-[11px] font-medium text-primary`,children:[e,` audience-scoped memory`,e===1?``:`ies`]}),t.size>0&&(0,K.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`(`,[...t].sort().join(`, `),`)`]})]})})(),(T||x||C)&&(0,K.jsxs)(`div`,{className:`shrink-0 border-b border-border/70 px-4 py-2`,"aria-live":`polite`,children:[T&&(0,K.jsxs)(`div`,{role:`status`,className:`flex items-center gap-2 text-xs text-success`,children:[(0,K.jsx)(m,{className:`size-3.5`}),` `,T]}),x&&(0,K.jsxs)(`div`,{role:`alert`,className:`flex items-center gap-2 text-xs text-warning`,children:[(0,K.jsx)(u,{className:`size-3.5`}),` `,x,` Existing content remains available.`]}),C&&!le&&!N&&(0,K.jsxs)(`div`,{role:`alert`,className:`flex items-center gap-2 text-xs text-destructive`,children:[(0,K.jsx)(u,{className:`size-3.5`}),` `,C]})]}),(0,K.jsxs)(`div`,{className:`grid min-h-0 flex-1 md:grid-cols-[minmax(320px,0.82fr)_minmax(0,1.35fr)]`,children:[(0,K.jsxs)(`section`,{className:F(`min-h-0 border-r border-border/70 bg-card/25`,Tt?`hidden md:flex md:flex-col`:`flex flex-col`),"aria-label":`Memory library`,children:[(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 border-b border-border/60 px-3 pt-1`,role:`tablist`,"aria-label":`Memory view`,children:[(0,K.jsx)(R,{type:`button`,variant:`ghost`,size:`sm`,role:`tab`,"aria-selected":!U,onClick:()=>{U&&je(!1)},className:F(`h-7 rounded-b-none border-b-2 px-3 text-[11px]`,U?`border-transparent text-muted-foreground`:`border-primary text-foreground`),children:`Active`}),(0,K.jsxs)(R,{type:`button`,variant:`ghost`,size:`sm`,role:`tab`,"aria-selected":U,onClick:()=>{U||je(!0)},className:F(`h-7 rounded-b-none border-b-2 px-3 text-[11px]`,U?`border-primary text-foreground`:`border-transparent text-muted-foreground`),children:[`Deleted`,typeof ze.deleted==`number`?` (${ze.deleted})`:``]})]}),(0,K.jsx)(ct,{searchQuery:be,statusFilter:Ce,kindFilter:Ee,audienceOnly:B,tagFilter:V,hasFilters:wt,allTags:xt,stats:g,onSearchChange:xe,onStatusFilterChange:Te,onKindFilterChange:De,onToggleAudienceOnly:()=>Ae(e=>!e),onTagFilterChange:H,onClearFilters:Ct}),(0,K.jsx)(ut,{memoryListRef:f,memories:p,filteredMemories:bt,selectedId:D,onSelectMemory:it,onOpenCreate:rt,onClearFilters:Ct}),Pe?(0,K.jsx)(`div`,{className:`shrink-0 border-t border-border/60 p-2`,children:(0,K.jsx)(R,{type:`button`,variant:`outline`,size:`sm`,onClick:tt,disabled:Le,className:`h-7 w-full text-[11px]`,children:Le?`Loading…`:`Load more (${p.length} loaded)`})}):null]}),(0,K.jsxs)(`section`,{className:F(`min-h-0 bg-background`,Tt?`flex flex-col`:`hidden md:flex md:flex-col`),"aria-label":`Memory detail`,children:[p.some(e=>(e.anchors??[]).some(e=>e.type===`file`&&e.path))&&(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-border/60 bg-card/30 px-3 py-1.5`,children:[(0,K.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:`File drawer`}),(0,K.jsxs)(`select`,{value:Ue??``,onChange:e=>{let t=e.target.value||null;We(t),t&&He(!0)},className:`min-w-0 max-w-[260px] flex-1 truncate rounded-sm border border-border/60 bg-background px-1.5 py-0.5 text-[10px] font-mono`,"aria-label":`File for memory drawer`,"data-testid":`memory-drawer-file-select`,children:[(0,K.jsx)(`option`,{value:``,children:`— select a file —`}),p.flatMap(e=>e.anchors??[]).filter(e=>e.type===`file`&&e.path).map((e,t)=>(0,K.jsx)(`option`,{value:e.path,title:e.path,children:e.path},`${e.path}-${t}`))]}),(0,K.jsxs)(R,{type:`button`,size:`sm`,variant:$?`default`:`outline`,onClick:()=>{Ue&&He(e=>!e)},disabled:!Ue,className:`h-7 shrink-0 gap-1 px-2 text-[11px]`,"aria-pressed":$,title:$?`Hide file memory drawer`:`Show file memory drawer`,children:[$?(0,K.jsx)(t,{className:`size-3`}):(0,K.jsx)(ne,{className:`size-3`}),$?`Hide`:`Show`,` drawer`]})]}),N?(0,K.jsx)(st,{mode:`create`,draft:P,busy:ye===`create`,error:C,onChange:ge,onCancel:lt,onSubmit:ft}):X?le?(0,K.jsx)(st,{mode:`edit`,draft:P,busy:ye===`update`,error:C,onChange:ge,onCancel:lt,onSubmit:vt}):$?(0,K.jsx)(at,{filePath:Ue,lineStart:Ge,lineEnd:qe,open:$,onClose:()=>He(!1),onShowMemory:e=>O(e),onAcceptDeletion:async(e,t)=>{c({candidateId:e,action:`accept`}),E(`Accepted hygiene review for ${t.slice(0,12)}… (candidate ${e.slice(0,12)}…).`),setTimeout(()=>{Z()},500)},onKeep:async(e,t)=>{c({candidateId:e,action:`reject`}),E(`Kept ${t.slice(0,12)}… (candidate ${e.slice(0,12)}… rejected).`)},onUpdate:e=>{O(e),ot()},onMarkPermanent:async e=>{I(`update`);try{await i(e,{persistence:`permanent`}),E(`Memory ${e.slice(0,12)}… promoted to permanent.`),await Z()}catch(e){w(e instanceof Error?e.message:String(e))}finally{I(null)}},onRecover:async e=>{s({id:e,reason:`recovered via file drawer`}),E(`Recovered ${e.slice(0,12)}…`),setTimeout(()=>{Z()},500)}}):(0,K.jsx)(Xe,{memory:X,allMemories:[...p,...ae],relatedMemories:St,graphEdges:re,graphLoading:ce,graphError:se,onClose:()=>O(null),onOpenMemory:it,onEdit:ot,onDelete:()=>z(X.id),onTagSelect:e=>{H(e),O(null)},onNotice:E}):(0,K.jsx)(mt,{onCapture:rt})]})]}),(0,K.jsx)(pt,{busyAction:ye,deletingId:L,memories:p,onCancel:()=>z(null),onConfirm:yt,onOpenChange:e=>{!e&&ye!==`delete`&&z(null)}})]})}export{vt as MemoryManager};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Ca as t,Ii as n,Li as r,et as i,ii as a,nn as o,nt as s,va as c}from"./vendor-BTDGplXK.js";import"./i18n-DOuSY1L8.js";import{t as l}from"./useWebSocket-BTXT0rOW.js";import{t as u}from"./ws-client-DqIqzkfU.js";import{t as d}from"./utils-DxDx8yib.js";import{M as f}from"./stores-CpZiOiOP.js";var p=e(t(),1);function m(e){let t=f(e=>e.wsUrl),{listSavedProviders:n,listProviderModels:r}=l(),[i,a]=(0,p.useState)([]),[o,s]=(0,p.useState)({});return(0,p.useEffect)(()=>{let e=u(t),n=e.on(`providers.saved`,e=>{let t=e.payload;a((t.providers??[]).map(e=>e.id))}),r=e.on(`provider.models`,e=>{let t=e.payload;s(e=>({...e,[t.provider]:t.models??[]}))});return()=>{n(),r()}},[t]),(0,p.useEffect)(()=>{e&&n()},[e,n]),(0,p.useEffect)(()=>{if(e)for(let e of i)o[e]||r(e)},[e,i,o,r]),(0,p.useMemo)(()=>{let e=[];for(let t of i)for(let n of o[t]??[])n.outputModalities?.length&&!n.outputModalities.includes(`text`)||e.push({provider:t,model:n.id,label:n.name??n.id,description:n.description,contextWindow:n.contextWindow,outputModalities:n.outputModalities});return e},[i,o])}var h=i();function g({value:e,provider:t,candidates:i,placeholder:l,resetLabel:u,onPick:f,onReset:m,className:g}){let{t:_}=c(),[v,y]=(0,p.useState)(!1),[b,x]=(0,p.useState)(``),S=(0,p.useRef)(null);(0,p.useEffect)(()=>{if(!v)return;let e=e=>{S.current&&!S.current.contains(e.target)&&y(!1)};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[v]);let C=(0,p.useMemo)(()=>{let e=b.trim().toLowerCase();return(e?i.filter(t=>`${t.provider}/${t.model} ${t.label}`.toLowerCase().includes(e)):i).slice(0,60)},[i,b]);return(0,h.jsxs)(`div`,{ref:S,className:d(`relative`,g),children:[(0,h.jsxs)(`button`,{type:`button`,onClick:()=>y(e=>!e),className:`flex w-full items-center gap-1.5 rounded-md border border-border bg-muted px-2 py-1.5 text-left text-xs transition-colors hover:border-primary/45 hover:bg-muted/80`,children:[(0,h.jsx)(a,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,h.jsx)(`span`,{className:d(`min-w-0 flex-1 truncate`,e?`text-foreground`:`text-muted-foreground`),children:e?t?`${t}/${e}`:e:l??_(`activity:model.runDefault`)}),(0,h.jsx)(n,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`})]}),v&&(0,h.jsxs)(`div`,{className:`sdd-rise absolute z-50 mt-1 max-h-72 w-full min-w-[240px] overflow-hidden rounded-md border border-border/80 bg-popover shadow-xl`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-border/70 bg-muted/20 px-2 py-1.5`,children:[(0,h.jsx)(`input`,{value:b,onChange:e=>x(e.target.value),placeholder:_(`activity:model.filterPlaceholder`),className:`min-w-0 flex-1 bg-transparent text-xs outline-none placeholder:text-muted-foreground`}),b&&(0,h.jsx)(`button`,{type:`button`,onClick:()=>x(``),className:`text-muted-foreground hover:text-foreground`,children:(0,h.jsx)(s,{className:`h-3 w-3`})})]}),(0,h.jsxs)(`div`,{className:`max-h-60 overflow-y-auto py-1`,children:[m&&(0,h.jsxs)(`button`,{type:`button`,onClick:()=>{m(),y(!1)},className:`flex w-full items-center gap-1.5 px-2 py-1.5 text-left text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:[(0,h.jsx)(o,{className:`h-3 w-3`}),` `,u??_(`activity:model.useRunDefault`)]}),C.map(n=>{let i=n.model===e&&(!t||n.provider===t);return(0,h.jsxs)(`button`,{type:`button`,onClick:()=>{f(n.model,n.provider),y(!1)},className:d(`flex w-full items-start gap-1.5 px-2 py-1.5 text-left text-xs transition-colors hover:bg-muted`,i?`bg-primary/8 text-primary`:`text-foreground`),children:[i?(0,h.jsx)(r,{className:`mt-0.5 h-3 w-3 shrink-0 text-primary`}):(0,h.jsx)(`span`,{className:`w-3 shrink-0`}),(0,h.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,h.jsx)(`span`,{className:`block truncate`,children:n.label}),n.description&&(0,h.jsx)(`span`,{className:`mt-0.5 block truncate text-[10px] text-muted-foreground`,children:n.description})]}),(0,h.jsx)(`span`,{className:`mt-0.5 shrink-0 font-mono text-[9px] text-muted-foreground`,children:n.provider})]},`${n.provider}/${n.model}`)}),C.length===0&&(0,h.jsx)(`div`,{className:`px-2 py-3 text-center text-[11px] text-muted-foreground`,children:i.length===0?_(`activity:model.loading`):_(`activity:model.noMatch`)})]})]})]})}export{m as n,g as t};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Ia as t,Xi as n,Yi as r,_i as i,dt as a,fn as o,ja as s,lt as c}from"./vendor-CxV3l5PQ.js";import"./i18n-DxnYsmc-.js";import{t as l}from"./useWebSocket-x8PMoTq8.js";import{t as u}from"./ws-client-Cy3oRAmZ.js";import{t as d}from"./utils-_s0GyctV.js";import{M as f}from"./stores-BS-Bdi-5.js";var p=e(t(),1);function m(e){let t=f(e=>e.wsUrl),{listSavedProviders:n,listProviderModels:r}=l(),[i,a]=(0,p.useState)([]),[o,s]=(0,p.useState)({});return(0,p.useEffect)(()=>{let e=u(t),n=e.on(`providers.saved`,e=>{let t=e.payload;a((t.providers??[]).map(e=>e.id))}),r=e.on(`provider.models`,e=>{let t=e.payload;s(e=>({...e,[t.provider]:t.models??[]}))});return()=>{n(),r()}},[t]),(0,p.useEffect)(()=>{e&&n()},[e,n]),(0,p.useEffect)(()=>{if(e)for(let e of i)o[e]||r(e)},[e,i,o,r]),(0,p.useMemo)(()=>{let e=[];for(let t of i)for(let n of o[t]??[])n.outputModalities?.length&&!n.outputModalities.includes(`text`)||e.push({provider:t,model:n.id,label:n.name??n.id,description:n.description,contextWindow:n.contextWindow,outputModalities:n.outputModalities});return e},[i,o])}var h=c();function g({value:e,provider:t,candidates:c,placeholder:l,resetLabel:u,onPick:f,onReset:m,className:g}){let{t:_}=s(),[v,y]=(0,p.useState)(!1),[b,x]=(0,p.useState)(``),S=(0,p.useRef)(null);(0,p.useEffect)(()=>{if(!v)return;let e=e=>{S.current&&!S.current.contains(e.target)&&y(!1)};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[v]);let C=(0,p.useMemo)(()=>{let e=b.trim().toLowerCase();return(e?c.filter(t=>`${t.provider}/${t.model} ${t.label}`.toLowerCase().includes(e)):c).slice(0,60)},[c,b]);return(0,h.jsxs)(`div`,{ref:S,className:d(`relative`,g),children:[(0,h.jsxs)(`button`,{type:`button`,onClick:()=>y(e=>!e),className:`flex w-full items-center gap-1.5 rounded-md border border-border bg-muted px-2 py-1.5 text-left text-xs transition-colors hover:border-primary/45 hover:bg-muted/80`,children:[(0,h.jsx)(i,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,h.jsx)(`span`,{className:d(`min-w-0 flex-1 truncate`,e?`text-foreground`:`text-muted-foreground`),children:e?t?`${t}/${e}`:e:l??_(`activity:model.runDefault`)}),(0,h.jsx)(r,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`})]}),v&&(0,h.jsxs)(`div`,{className:`sdd-rise absolute z-50 mt-1 max-h-72 w-full min-w-[240px] overflow-hidden rounded-md border border-border/80 bg-popover shadow-xl`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-border/70 bg-muted/20 px-2 py-1.5`,children:[(0,h.jsx)(`input`,{value:b,onChange:e=>x(e.target.value),placeholder:_(`activity:model.filterPlaceholder`),className:`min-w-0 flex-1 bg-transparent text-xs outline-none placeholder:text-muted-foreground`}),b&&(0,h.jsx)(`button`,{type:`button`,onClick:()=>x(``),className:`text-muted-foreground hover:text-foreground`,children:(0,h.jsx)(a,{className:`h-3 w-3`})})]}),(0,h.jsxs)(`div`,{className:`max-h-60 overflow-y-auto py-1`,children:[m&&(0,h.jsxs)(`button`,{type:`button`,onClick:()=>{m(),y(!1)},className:`flex w-full items-center gap-1.5 px-2 py-1.5 text-left text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:[(0,h.jsx)(o,{className:`h-3 w-3`}),` `,u??_(`activity:model.useRunDefault`)]}),C.map(r=>{let i=r.model===e&&(!t||r.provider===t);return(0,h.jsxs)(`button`,{type:`button`,onClick:()=>{f(r.model,r.provider),y(!1)},className:d(`flex w-full items-start gap-1.5 px-2 py-1.5 text-left text-xs transition-colors hover:bg-muted`,i?`bg-primary/8 text-primary`:`text-foreground`),children:[i?(0,h.jsx)(n,{className:`mt-0.5 h-3 w-3 shrink-0 text-primary`}):(0,h.jsx)(`span`,{className:`w-3 shrink-0`}),(0,h.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,h.jsx)(`span`,{className:`block truncate`,children:r.label}),r.description&&(0,h.jsx)(`span`,{className:`mt-0.5 block truncate text-[10px] text-muted-foreground`,children:r.description})]}),(0,h.jsx)(`span`,{className:`mt-0.5 shrink-0 font-mono text-[9px] text-muted-foreground`,children:r.provider})]},`${r.provider}/${r.model}`)}),C.length===0&&(0,h.jsx)(`div`,{className:`px-2 py-3 text-center text-[11px] text-muted-foreground`,children:c.length===0?_(`activity:model.loading`):_(`activity:model.noMatch`)})]})]})]})}export{m as n,g as t};