@wrongstack/webui 0.292.1 → 0.293.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/AnalyticsDashboard--x-f8QI-.js +1 -0
- package/dist/assets/AudienceMemoryPanel-j9I0RvhP.js +3 -0
- package/dist/assets/{ChangesView-PgFw9vKk.js → ChangesView-Bb5LXWiI.js} +1 -1
- package/dist/assets/ChronicleDashboard-D34oKMQ_.js +1 -0
- package/dist/assets/{CodeEditor-B_KwrAhN.js → CodeEditor-BkIIR8EU.js} +1 -1
- package/dist/assets/CodeMap-Ej4UNFUm.js +1 -0
- package/dist/assets/{ConfirmModal-Bm9f2Pg9.js → ConfirmModal-4l0Tyazp.js} +1 -1
- package/dist/assets/{CronJobsPanel-CVXW2Y-n.js → CronJobsPanel-ByJqIjCv.js} +1 -1
- package/dist/assets/{DebugDashboard-BldwPA32.js → DebugDashboard-B0pikasm.js} +1 -1
- package/dist/assets/{DesignGalleryView-CUi5RBHH.js → DesignGalleryView-CgLsdzTx.js} +1 -1
- package/dist/assets/{GoalView-p7f1544B.js → GoalView-DXO9txQs.js} +1 -1
- package/dist/assets/KanbanView--bFrj9Xa.js +2 -0
- package/dist/assets/{LazyMarkdown-C1a0wbAZ.js → LazyMarkdown-BHoUIDge.js} +3 -3
- package/dist/assets/{MailboxDetailView-DQpxIh_A.js → MailboxDetailView-C-Vf3h1d.js} +1 -1
- package/dist/assets/MemoryManager-DoHNBnKd.js +1 -0
- package/dist/assets/{ModelPicker-Cwa4UKNc.js → ModelPicker-CEZN673P.js} +1 -1
- package/dist/assets/OfficeMapPanel-BMf4PTWo.js +4 -0
- package/dist/assets/{ProcessMonitor-DjO7eNsN.js → ProcessMonitor-BtfARuHq.js} +1 -1
- package/dist/assets/{QueuePanel-lUChp6xi.js → QueuePanel-DMXksqFS.js} +1 -1
- package/dist/assets/{RefreshDebugView-BNa6ehdH.js → RefreshDebugView-D08bCHA4.js} +1 -1
- package/dist/assets/SddHub-QgMFn_rC.js +2 -0
- package/dist/assets/SessionsDashboard-BY77vax1.js +1 -0
- package/dist/assets/SetupScreen-CU7Mq-5T.js +1 -0
- package/dist/assets/SkillDetailView-6ZIVx1BG.js +3 -0
- package/dist/assets/{SpecsView-CNqNOKqo.js → SpecsView-CZg7e2ml.js} +1 -1
- package/dist/assets/TechStackView-9hfnNKx-.js +1 -0
- package/dist/assets/{TerminalPanel-KysALyRz.js → TerminalPanel-SnRvUh6N.js} +1 -1
- package/dist/assets/{Toaster-B1idXZ-O.js → Toaster-BNdKxZ1U.js} +1 -1
- package/dist/assets/{button-99L74zdE.js → button-Dy0bAtEY.js} +1 -1
- package/dist/assets/{chat-store-Cunk1nDr.js → chat-store-CUODHW6c.js} +2 -2
- package/dist/assets/{codemap-activity-store-BIW6YPvC.js → codemap-activity-store-CgtLR4PV.js} +1 -1
- package/dist/assets/{dialog-CNwwBFw3.js → dialog-CBgO-uqz.js} +1 -1
- package/dist/assets/{i18n-DaR2GB_4.js → i18n-Dk35g-uV.js} +2 -2
- package/dist/assets/index-DGX8tPCe.css +1 -0
- package/dist/assets/index-OmSX-BAb.js +124 -0
- package/dist/assets/{input-DXjUO_X9.js → input-B6FY_vtB.js} +1 -1
- package/dist/assets/{mailbox-store-Dq1wxCRt.js → mailbox-store-BY2SVw-s.js} +1 -1
- package/dist/assets/{session-store-B8icONBU.js → session-store-Coiik-Ib.js} +1 -1
- package/dist/assets/settings-B9dVH8oJ.js +1 -0
- package/dist/assets/settings-BBR9xBqW.js +1 -0
- package/dist/assets/settings-BK1-R1dO.js +1 -0
- package/dist/assets/{settings-CyzkAhwD.js → settings-BXWyZpz5.js} +1 -1
- package/dist/assets/settings-BaZcBGA7.js +1 -0
- package/dist/assets/{settings-llUXRsji.js → settings-C65WW7Jn.js} +1 -1
- package/dist/assets/settings-Dp5NIt-h.js +1 -0
- package/dist/assets/{shared-aSCYBzAV.js → shared-CpXz-tzA.js} +1 -1
- package/dist/assets/{stores-JSLvWOQY.js → stores-CUp_ut8r.js} +2 -2
- package/dist/assets/ui-store-CwOvhFZG.js +1 -0
- package/dist/assets/{useWebSocket-CRYUFxmO.js → useWebSocket-BJorYmOi.js} +1 -1
- package/dist/assets/{utils-C4qVQ63O.js → utils-DEzFewqr.js} +1 -1
- package/dist/assets/{vendor-Di1mdAi5.js → vendor-DffL_bim.js} +30 -30
- package/dist/assets/{view-navigation-BbHlzAQz.js → view-navigation-BjlXpDXc.js} +1 -1
- package/dist/assets/{ws-client-BWO_PH_X.js → ws-client-Fnmzo7vN.js} +1 -1
- package/dist/components/ContextBreakdownModal.d.ts.map +1 -1
- package/dist/components/ContextDashboard.d.ts.map +1 -1
- package/dist/components/InspectorPanel.d.ts.map +1 -1
- package/dist/components/MemoryManager/MemoryGraph.d.ts.map +1 -1
- package/dist/components/MessageBubble/index.d.ts +1 -1
- package/dist/components/MessageBubble/index.d.ts.map +1 -1
- package/dist/components/SettingsPanel/OAuthLoginSection.d.ts +13 -7
- package/dist/components/SettingsPanel/OAuthLoginSection.d.ts.map +1 -1
- package/dist/components/SettingsPanel/ProviderSection.d.ts.map +1 -1
- package/dist/index.html +22 -23
- package/dist/index.js +2683 -2008
- package/dist/index.js.map +4 -4
- package/dist/lib/view-navigation.d.ts.map +1 -1
- package/dist/lib/ws-client.d.ts +1 -1
- package/dist/lib/ws-client.d.ts.map +1 -1
- package/dist/providers.json +10 -0
- package/dist/stores/local-prefs.d.ts +3 -2
- package/dist/stores/local-prefs.d.ts.map +1 -1
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +6 -6
- package/dist/assets/AnalyticsDashboard-DM8YmJuy.js +0 -1
- package/dist/assets/AudienceMemoryPanel-BN1qR1rz.js +0 -3
- package/dist/assets/ChronicleDashboard-CtOiFCYV.js +0 -1
- package/dist/assets/CodeMap-T1dsXVRH.js +0 -1
- package/dist/assets/KanbanView-CD_x5YND.js +0 -2
- package/dist/assets/MemoryManager-BrCVqIJK.js +0 -1
- package/dist/assets/OfficeMapPanel-D01rqjLt.js +0 -4
- package/dist/assets/SddHub-DLVIXlN6.js +0 -2
- package/dist/assets/SessionsDashboard-DsAc_Sx2.js +0 -1
- package/dist/assets/SetupScreen-KqV61-Ir.js +0 -1
- package/dist/assets/SkillDetailView-CK7MB8Uo.js +0 -3
- package/dist/assets/TechStackView-nVNj4kWJ.js +0 -1
- package/dist/assets/index-BwEOo8R-.css +0 -1
- package/dist/assets/index-Du90vd1u.js +0 -119
- package/dist/assets/pagination-Ktuov5iD.js +0 -1
- package/dist/assets/settings-4BR882HN.js +0 -1
- package/dist/assets/settings-B5P4V9M6.js +0 -1
- package/dist/assets/settings-Cjxo5UVP.js +0 -1
- package/dist/assets/settings-CnViO4_M.js +0 -1
- package/dist/assets/settings-jrfJX8W2.js +0 -1
- package/dist/assets/ui-store-BepZz9CZ.js +0 -1
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Ct as t,Dt as n,aa as r,cn as i,gr as a,ot as o,qr as s,qt as c,rn as l,tt as u,vt as d,zt as f}from"./vendor-Di1mdAi5.js";import{t as p}from"./useWebSocket-CRYUFxmO.js";import{t as m}from"./utils-C4qVQ63O.js";import{a as h,i as g,n as _,o as v,r as y,t as b}from"./dialog-CNwwBFw3.js";import{t as x}from"./button-99L74zdE.js";import{t as S}from"./pagination-Ktuov5iD.js";import{t as C}from"./input-DXjUO_X9.js";import{S as w}from"./index-Du90vd1u.js";import{g as T,i as E,r as D,y as O}from"./shared-aSCYBzAV.js";var k=e(r(),1),A=u();function j(e){if(!Array.isArray(e))return;let t=[...new Set(e.filter(e=>typeof e==`string`).map(e=>e.trim()).filter(Boolean))];return t.length>0?t:void 0}function M(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e,n={roles:j(t.roles),taskTypes:j(t.taskTypes),modes:j(t.modes)};return n.roles||n.taskTypes||n.modes?n:void 0}function ee(e){let t=e.trim().replace(/^```(?:json)?\s*/i,``).replace(/\s*```$/,``),n=JSON.parse(t);if(!Array.isArray(n))throw Error(`Input must be a JSON array.`);let r=[],i=0;for(let e of n){if(!e||typeof e!=`object`||Array.isArray(e)){i++;continue}let t=e,n=typeof t.text==`string`?t.text.trim():``,a=M(t.audience);if(!n||!a){i++;continue}let o=typeof t.kind==`string`&&E.some(e=>e===t.kind)?t.kind:void 0,s=j(t.tags);r.push({text:n,audience:a,kind:o,tags:s,importance:typeof t.importance==`number`?t.importance:void 0,confidence:typeof t.confidence==`number`?t.confidence:void 0})}return{entries:r,skipped:i}}function N(e,t){if(!t)return!0;let n=e.audience;return[e.text,e.kind,e.status,...n?.roles??[],...n?.taskTypes??[],...n?.modes??[]].join(` `).toLocaleLowerCase().includes(t.toLocaleLowerCase())}function P(e,t){return[...new Set(e.flatMap(e=>e.audience?.[t]??[]).filter(e=>e.length>0))].sort((e,t)=>e.localeCompare(t))}function F(){let e=p(),[r,u]=(0,k.useState)([]),[f,E]=(0,k.useState)(!0),[D,O]=(0,k.useState)(null),[j,M]=(0,k.useState)(``),[F,R]=(0,k.useState)(!1),[B,V]=(0,k.useState)(!1),[H,U]=(0,k.useState)(null),[W,G]=(0,k.useState)(!1),[K,q]=(0,k.useState)(!1),J=(0,k.useRef)(null),Y=(0,k.useCallback)(()=>{E(!0),O(null),e.listSuperMemories({echoToChat:!1})},[e.listSuperMemories]);(0,k.useEffect)(()=>{let t=e.client,n=t.on(`memory.super.list`,e=>{let t=e.payload;t.error?O({tone:`error`,text:t.error}):u(t.memories??[]),E(!1)}),r=t.on(`memory.super.remember`,e=>{let t=e.payload;if(G(!1),t.error){O({tone:`error`,text:t.error});return}t.memory&&(u(e=>[t.memory,...e.filter(e=>e.id!==t.memory.id)]),R(!1))}),i=t.on(`memory.super.update`,e=>{let t=e.payload;t.error?O({tone:`error`,text:t.error}):t.memory&&(u(e=>e.map(e=>e.id===t.memory.id?t.memory:e)),t.memory.audience||O({tone:`success`,text:`Audience scope removed. The memory is now general.`}))}),a=t.on(`memory.super.delete`,e=>{let t=e.payload,n=J.current;t.success&&n?(u(e=>e.filter(e=>e.id!==n)),O({tone:`success`,text:`Audience memory deleted.`}),U(null),q(!1),J.current=null):t.success?Y():(O({tone:`error`,text:t.message??`Could not delete the memory.`}),q(!1),J.current=null)});return Y(),()=>{n(),r(),i(),a()}},[Y,e.client]);let X=(0,k.useMemo)(()=>r.filter(e=>{let t=e.audience;return!!(t&&(t.roles?.length||t.taskTypes?.length||t.modes?.length))}),[r]),Z=j.trim(),Q=(0,k.useMemo)(()=>X.filter(e=>N(e,Z)),[Z,X]),$=w(Q,16,Z),ie=(0,k.useMemo)(()=>P(X,`roles`),[X]),ae=(0,k.useMemo)(()=>P(X,`taskTypes`),[X]),oe=(0,k.useMemo)(()=>P(X,`modes`),[X]),se=t=>{O(null),e.updateSuperMemory(t,{audience:void 0},{echoToChat:!1})},ce=()=>{H&&(J.current=H,q(!0),O(null),e.deleteSuperMemory(H,`Removed from the audience memory panel.`))},le=async()=>{let e=X.map(e=>({id:e.id,text:e.text,kind:e.kind,status:e.status,audience:e.audience,tags:e.tags,importance:e.importance,confidence:e.confidence}));try{if(!navigator.clipboard)throw Error(`Clipboard access is unavailable.`);await navigator.clipboard.writeText(JSON.stringify(e,null,2)),O({tone:`success`,text:`${e.length} audience memor${e.length===1?`y`:`ies`} copied as JSON.`})}catch(e){O({tone:`error`,text:e instanceof Error?e.message:`Failed to copy JSON to the clipboard.`})}};return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col bg-card/20`,"aria-labelledby":`audience-memory-title`,children:[(0,A.jsxs)(`div`,{className:`shrink-0 border-b border-border/60 p-3`,children:[(0,A.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,A.jsx)(`div`,{className:`min-w-0`,children:(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-md border border-primary/20 bg-primary/10 text-primary`,children:(0,A.jsx)(n,{className:`size-3.5`})}),(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsx)(`h2`,{id:`audience-memory-title`,className:`truncate text-sm font-semibold`,children:`Audience Memory`}),(0,A.jsx)(`p`,{className:`truncate text-[10px] text-muted-foreground`,children:`Guidance routed to matching agents`})]})]})}),(0,A.jsxs)(x,{variant:`default`,size:`sm`,className:`h-7 shrink-0 gap-1 px-2 text-xs`,onClick:()=>R(!0),children:[(0,A.jsx)(i,{className:`size-3`}),`Add`]})]}),(0,A.jsxs)(`div`,{className:`mt-3 grid grid-cols-4 gap-px overflow-hidden rounded-md border border-border/60 bg-border/60`,children:[(0,A.jsx)(I,{value:X.length,label:`Memories`}),(0,A.jsx)(I,{value:ie.length,label:`Roles`}),(0,A.jsx)(I,{value:ae.length,label:`Tasks`}),(0,A.jsx)(I,{value:oe.length,label:`Modes`})]}),(0,A.jsxs)(`div`,{className:`mt-3 flex items-center gap-1.5`,children:[(0,A.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,A.jsx)(c,{className:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,A.jsx)(C,{value:j,onChange:e=>M(e.target.value),placeholder:`Search text, role, task or mode…`,"aria-label":`Search audience memories`,className:`h-8 pl-8 pr-8 text-xs`}),j&&(0,A.jsx)(`button`,{type:`button`,className:`absolute right-2 top-1/2 -translate-y-1/2 rounded-sm p-0.5 text-muted-foreground hover:text-foreground`,onClick:()=>M(``),"aria-label":`Clear audience memory search`,children:(0,A.jsx)(o,{className:`size-3`})})]}),(0,A.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-8 shrink-0`,onClick:Y,"aria-label":`Refresh audience memories`,title:`Refresh`,children:(0,A.jsx)(l,{className:m(`size-3.5`,f&&`animate-spin`)})}),(0,A.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-8 shrink-0`,onClick:()=>V(!0),"aria-label":`Import audience memories`,title:`Import JSON`,children:(0,A.jsx)(d,{className:`size-3.5`})}),(0,A.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-8 shrink-0`,onClick:()=>void le(),"aria-label":`Copy audience memories as JSON`,title:`Copy JSON`,disabled:X.length===0,children:(0,A.jsx)(s,{className:`size-3.5`})})]})]}),D&&(0,A.jsxs)(`div`,{role:D.tone===`error`?`alert`:`status`,className:m(`mx-3 mt-3 flex shrink-0 items-start justify-between gap-2 rounded-md border px-2.5 py-2 text-[11px]`,D.tone===`error`?`border-destructive/30 bg-destructive/5 text-destructive`:`border-success/30 bg-success/5 text-success`),children:[(0,A.jsx)(`span`,{children:D.text}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>O(null),className:`shrink-0 rounded-sm opacity-70 hover:opacity-100`,"aria-label":`Dismiss message`,children:(0,A.jsx)(o,{className:`size-3`})})]}),(0,A.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[!f&&X.length>0&&(0,A.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between px-3 pb-1.5 pt-3 text-[10px] text-muted-foreground`,children:[(0,A.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,A.jsx)(a,{className:`size-3`}),Z?`${Q.length} of ${X.length}`:`${X.length} scoped`]}),Z&&(0,A.jsx)(`button`,{type:`button`,className:`hover:text-foreground`,onClick:()=>M(``),children:`Clear filter`})]}),(0,A.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3`,children:[f?(0,A.jsx)(z,{}):X.length===0?(0,A.jsx)(te,{onAdd:()=>R(!0)}):Q.length===0?(0,A.jsxs)(`div`,{className:`flex h-full min-h-32 flex-col items-center justify-center px-4 text-center`,children:[(0,A.jsx)(c,{className:`mb-2 size-5 text-muted-foreground/60`}),(0,A.jsx)(`p`,{className:`text-xs font-medium`,children:`No matching memories`}),(0,A.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:`Try another role, task, mode, or phrase.`}),(0,A.jsx)(x,{variant:`ghost`,size:`sm`,className:`mt-2 h-7 text-xs`,onClick:()=>M(``),children:`Clear search`})]}):(0,A.jsx)(`ul`,{className:`space-y-2`,children:$.pageItems.map(e=>(0,A.jsx)(L,{memory:e,onFilter:M,onClearScope:()=>se(e.id),onDelete:()=>U(e.id)},e.id))}),(0,A.jsx)(S,{page:$.page,pageSize:$.pageSize,totalItems:$.totalItems,onPageChange:$.setPage,compact:!0,itemLabel:`memories`})]})]})]}),(0,A.jsx)(ne,{open:F,busy:W,onOpenChange:e=>{W||R(e)},onCreate:t=>{O(null),G(!0),e.rememberSuperMemory({text:t.text,kind:t.kind,audience:{roles:t.roles.length>0?t.roles:void 0,taskTypes:t.taskTypes.length>0?t.taskTypes:void 0,modes:t.modes.length>0?t.modes:void 0}},{echoToChat:!1})}}),(0,A.jsx)(re,{open:B,onOpenChange:V,onImport:t=>{try{let{entries:n,skipped:r}=ee(t);if(n.length===0)return O({tone:`error`,text:`No valid audience-scoped memories were found in the JSON.`}),!1;for(let t of n)e.rememberSuperMemory(t,{echoToChat:!1});return O({tone:`success`,text:`${n.length} memor${n.length===1?`y`:`ies`} queued for import${r?`; ${r} invalid ${r===1?`entry was`:`entries were`} skipped`:``}.`}),V(!1),!0}catch(e){return O({tone:`error`,text:e instanceof Error?e.message:`Invalid JSON.`}),!1}}}),(0,A.jsx)(b,{open:!!H,onOpenChange:e=>{!e&&!K&&U(null)},children:(0,A.jsxs)(_,{className:`max-w-md`,children:[(0,A.jsxs)(h,{children:[(0,A.jsx)(v,{children:`Delete this audience memory?`}),(0,A.jsx)(y,{children:`This removes the memory from active use. To keep it as general project guidance, cancel and use the un-scope action instead.`})]}),(0,A.jsx)(`div`,{className:`rounded-md border border-border/70 bg-background/45 p-3 text-xs text-muted-foreground`,children:T(r.find(e=>e.id===H)?.text??``,180)}),(0,A.jsxs)(g,{children:[(0,A.jsx)(x,{variant:`outline`,onClick:()=>U(null),disabled:K,children:`Cancel`}),(0,A.jsxs)(x,{variant:`destructive`,onClick:ce,disabled:K,children:[(0,A.jsx)(t,{className:`size-4`}),K?`Deleting…`:`Delete memory`]})]})]})})]})}function I({value:e,label:t}){return(0,A.jsxs)(`div`,{className:`bg-card/95 px-1.5 py-2 text-center`,children:[(0,A.jsx)(`p`,{className:`text-sm font-semibold tabular-nums`,children:e}),(0,A.jsx)(`p`,{className:`truncate text-[9px] uppercase tracking-wide text-muted-foreground`,children:t})]})}function L({memory:e,onFilter:n,onClearScope:r,onDelete:i}){return(0,A.jsxs)(`li`,{className:`group rounded-md border border-border/65 bg-card/55 p-2.5 transition-colors hover:border-border hover:bg-card/85`,children:[(0,A.jsx)(`p`,{className:`break-words text-xs leading-5`,children:e.text}),e.audience&&(0,A.jsx)(R,{audience:e.audience,onFilter:n}),(0,A.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-2 border-t border-border/45 pt-2`,children:[(0,A.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-[9px] uppercase tracking-wide text-muted-foreground`,children:[(0,A.jsx)(`span`,{className:`truncate`,children:D[e.kind]??e.kind}),(0,A.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,A.jsx)(`span`,{children:e.status})]}),(0,A.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[(0,A.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-6`,onClick:r,"aria-label":`Remove audience scope from ${T(e.text,42)}`,title:`Make general memory`,children:(0,A.jsx)(f,{className:`size-3`})}),(0,A.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-6 text-destructive hover:text-destructive`,onClick:i,"aria-label":`Delete ${T(e.text,42)}`,title:`Delete`,children:(0,A.jsx)(t,{className:`size-3`})})]})]})]})}function R({audience:e,onFilter:t}){return(0,A.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[...(e.roles??[]).map(e=>({label:`role`,value:e})),...(e.taskTypes??[]).map(e=>({label:`task`,value:e})),...(e.modes??[]).map(e=>({label:`mode`,value:e}))].map(({label:e,value:n})=>(0,A.jsxs)(`button`,{type:`button`,className:`max-w-full truncate rounded border border-primary/15 bg-primary/7 px-1.5 py-0.5 font-mono text-[9px] text-primary/90 transition-colors hover:border-primary/35 hover:bg-primary/12`,onClick:()=>t(n),title:`Filter by ${e}: ${n}`,children:[e,`:`,n]},`${e}:${n}`))})}function z(){return(0,A.jsx)(`div`,{className:`space-y-2 pt-3`,role:`status`,"aria-label":`Loading audience memories`,children:[0,1,2].map(e=>(0,A.jsxs)(`div`,{className:`animate-pulse rounded-md border border-border/50 p-3`,children:[(0,A.jsx)(`div`,{className:`h-2.5 w-full rounded bg-muted`}),(0,A.jsx)(`div`,{className:`mt-2 h-2.5 w-2/3 rounded bg-muted`}),(0,A.jsx)(`div`,{className:`mt-3 h-4 w-24 rounded bg-muted`})]},e))})}function te({onAdd:e}){return(0,A.jsxs)(`div`,{className:`flex h-full min-h-44 flex-col items-center justify-center px-5 text-center`,children:[(0,A.jsx)(`span`,{className:`mb-3 flex size-10 items-center justify-center rounded-full border border-dashed border-primary/35 bg-primary/5 text-primary`,children:(0,A.jsx)(n,{className:`size-4`})}),(0,A.jsx)(`p`,{className:`text-xs font-medium`,children:`Route guidance to the right agents`}),(0,A.jsx)(`p`,{className:`mt-1 max-w-52 text-[10px] leading-4 text-muted-foreground`,children:`Scope a memory by role, task type, or operating mode. Matching agents receive it automatically.`}),(0,A.jsxs)(x,{variant:`outline`,size:`sm`,className:`mt-3 h-7 gap-1 text-xs`,onClick:e,children:[(0,A.jsx)(i,{className:`size-3`}),`Add scoped memory`]})]})}function ne({open:e,busy:t,onOpenChange:n,onCreate:r}){let[i,a]=(0,k.useState)(``),[o,s]=(0,k.useState)(`workflow`),[c,l]=(0,k.useState)(``),[u,d]=(0,k.useState)(``),[f,p]=(0,k.useState)(``);(0,k.useEffect)(()=>{e||(a(``),s(`workflow`),l(``),d(``),p(``))},[e]);let m=O(c),S=O(u),C=O(f),w=i.trim().length>0&&(m.length>0||S.length>0||C.length>0);return(0,A.jsx)(b,{open:e,onOpenChange:n,children:(0,A.jsxs)(_,{className:`max-w-xl`,children:[(0,A.jsxs)(h,{children:[(0,A.jsx)(v,{children:`Add audience-scoped memory`}),(0,A.jsx)(y,{children:`This guidance is injected only when an agent matches at least one supplied selector.`})]}),(0,A.jsxs)(`div`,{className:`space-y-4`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{htmlFor:`audience-memory-text`,className:`mb-1.5 block text-xs font-medium`,children:`Memory`}),(0,A.jsx)(`textarea`,{id:`audience-memory-text`,value:i,onChange:e=>a(e.target.value),placeholder:`What should matching agents remember?`,rows:4,autoFocus:!0,className:`w-full resize-y rounded-md border border-input bg-background px-3 py-2 text-sm outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring`})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{htmlFor:`audience-memory-kind`,className:`mb-1.5 block text-xs font-medium`,children:`Kind`}),(0,A.jsx)(`select`,{id:`audience-memory-kind`,value:o,onChange:e=>s(e.target.value),className:`h-9 w-full rounded-md border border-input bg-background px-3 text-xs outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:E.map(e=>(0,A.jsx)(`option`,{value:e,children:D[e]??e},e))})]}),(0,A.jsxs)(`fieldset`,{className:`space-y-3 rounded-md border border-border/70 bg-background/35 p-3`,children:[(0,A.jsx)(`legend`,{className:`px-1 text-xs font-medium`,children:`Audience selectors`}),(0,A.jsx)(B,{id:`audience-memory-roles`,label:`Roles`,value:c,onChange:l,placeholder:`reviewer, refactor-planner`}),(0,A.jsx)(B,{id:`audience-memory-task-types`,label:`Task types`,value:u,onChange:d,placeholder:`review, refactor, bugfix`}),(0,A.jsx)(B,{id:`audience-memory-modes`,label:`Modes`,value:f,onChange:p,placeholder:`teach, code-review`}),(0,A.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Comma-separate multiple values. At least one selector is required.`})]})]}),(0,A.jsxs)(g,{children:[(0,A.jsx)(x,{variant:`outline`,onClick:()=>n(!1),disabled:t,children:`Cancel`}),(0,A.jsx)(x,{onClick:()=>r({text:i.trim(),kind:o,roles:m,taskTypes:S,modes:C}),disabled:!w||t,children:t?`Remembering…`:`Remember`})]})]})})}function B({id:e,label:t,value:n,placeholder:r,onChange:i}){return(0,A.jsxs)(`div`,{className:`grid gap-1.5 sm:grid-cols-[6rem_1fr] sm:items-center`,children:[(0,A.jsx)(`label`,{htmlFor:e,className:`text-[11px] font-medium text-muted-foreground`,children:t}),(0,A.jsx)(C,{id:e,value:n,onChange:e=>i(e.target.value),placeholder:r,className:`h-8 font-mono text-xs`})]})}function re({open:e,onOpenChange:t,onImport:n}){let[r,i]=(0,k.useState)(``);return(0,k.useEffect)(()=>{e||i(``)},[e]),(0,A.jsx)(b,{open:e,onOpenChange:t,children:(0,A.jsxs)(_,{className:`max-w-xl`,children:[(0,A.jsxs)(h,{children:[(0,A.jsx)(v,{children:`Import audience memories`}),(0,A.jsxs)(y,{children:[`Paste the JSON produced here or by `,(0,A.jsx)(`code`,{children:`/memory audience export`}),`. Entries without a valid audience selector are skipped.`]})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{htmlFor:`audience-memory-import`,className:`mb-1.5 block text-xs font-medium`,children:`JSON array`}),(0,A.jsx)(`textarea`,{id:`audience-memory-import`,value:r,onChange:e=>i(e.target.value),placeholder:`[
|
|
2
|
-
{ "text": "…", "audience": { "roles": ["reviewer"] } }
|
|
3
|
-
]`,rows:10,autoFocus:!0,spellCheck:!1,className:`w-full resize-y rounded-md border border-input bg-background p-3 font-mono text-xs outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring`})]}),(0,A.jsxs)(g,{children:[(0,A.jsx)(x,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,A.jsxs)(x,{onClick:()=>n(r),disabled:!r.trim(),children:[(0,A.jsx)(d,{className:`size-4`}),`Import memories`]})]})]})})}export{F as AudienceMemoryPanel};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{$t as t,Ai as n,Bt as r,Ni as i,Nt as a,Rr as o,Yr as s,Zi as c,aa as l,ai as u,bt as d,gr as f,ot as p,pr as m,qt as ee,rn as h,tt as g,xi as _}from"./vendor-Di1mdAi5.js";import{t as v}from"./ws-client-BWO_PH_X.js";import{t as y}from"./utils-C4qVQ63O.js";import{t as b}from"./pagination-Ktuov5iD.js";import{S as x}from"./index-Du90vd1u.js";var S=e(l(),1),C=g(),w=[`eventType`,`providerId`,`modelId`,`outcome`,`resourceKind`],te=[{id:`all`,label:`All signals`,icon:(0,C.jsx)(c,{})},{id:`llm`,label:`LLM`,icon:(0,C.jsx)(n,{})},{id:`agents`,label:`Agents`,icon:(0,C.jsx)(i,{})},{id:`tools`,label:`Tools`,icon:(0,C.jsx)(a,{})},{id:`files`,label:`Files`,icon:(0,C.jsx)(o,{})},{id:`failures`,label:`Failures`,icon:(0,C.jsx)(d,{})}];function T(){let e=v(),[r,s]=(0,S.useState)([]),[c,l]=(0,S.useState)(null),[d,m]=(0,S.useState)({}),[g,_]=(0,S.useState)({limit:300,order:`desc`}),[T,E]=(0,S.useState)({text:``,path:``,providerId:``,modelId:``,sessionId:``}),[j,R]=(0,S.useState)(`all`),[B,V]=(0,S.useState)({total:0,scannedEvents:0,sourceFiles:0,invalidLines:0}),[H,U]=(0,S.useState)(D),[W,G]=(0,S.useState)(!0),[K,q]=(0,S.useState)(null),[ne,J]=(0,S.useState)(null),Y=(0,S.useCallback)(t=>{if(!e.supportsCapability(`chronicle.query`)){G(!1),q(`Restart the backend once to activate Chronicle protocol support.`);return}G(!0),q(null),_(t),e.send({type:`chronicle.query`,payload:{query:t}});for(let n of w)e.send({type:`chronicle.facet`,payload:{field:n,query:t,limit:12}})},[e]);(0,S.useEffect)(()=>{let t=e.on(`chronicle.query_result`,e=>{e.type===`chronicle.query_result`&&(s(e.payload.events),V(e.payload),U(e.payload.summary??D),G(!1))}),n=e.on(`chronicle.facet_result`,e=>{e.type===`chronicle.facet_result`&&m(t=>({...t,[e.payload.field]:e.payload.values}))}),r=e.on(`chronicle.error`,e=>{e.type===`chronicle.error`&&(q(e.payload.message),G(!1))}),i=e.on(`chronicle.graph_result`,e=>{e.type===`chronicle.graph_result`&&J(e.payload)});return Y({limit:300,order:`desc`}),()=>{t(),n(),r(),i()}},[e,Y]);let X=(0,S.useMemo)(()=>r.filter(e=>A(e,j)),[r,j]),Z=x(X,25,j),Q=(0,S.useMemo)(()=>r.find(e=>e.eventType===`runtime.health.sampled`)?.attributes,[r]),$=()=>Y({limit:300,order:`desc`,...T.text?{text:T.text}:{},...T.path?{path:T.path}:{},...T.providerId?{providerId:T.providerId}:{},...T.modelId?{modelId:T.modelId}:{},...T.sessionId?{sessionId:T.sessionId}:{}}),re=()=>{E({text:``,path:``,providerId:``,modelId:``,sessionId:``}),R(`all`),Y({limit:300,order:`desc`})},ie=t=>{l(t),J(null),e.supportsCapability(`chronicle.graph`)&&e.send({type:`chronicle.graph`,payload:{seed:{eventId:t.eventId},hops:2,maxNodes:250}})};return(0,C.jsxs)(`div`,{className:`flex h-full min-h-0 bg-background`,"data-testid":`chronicle-dashboard`,children:[(0,C.jsxs)(`main`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,C.jsx)(`header`,{className:`border-b border-border/70 bg-gradient-to-r from-primary/[0.045] via-background to-background px-5 py-4`,children:(0,C.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsx)(n,{className:`h-5 w-5 text-primary`}),(0,C.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight`,children:`Coding Intelligence`}),(0,C.jsx)(`span`,{className:`rounded-full border border-primary/20 bg-primary/10 px-2 py-0.5 text-[9px] font-semibold tracking-wider text-primary`,children:`CHRONICLE`})]}),(0,C.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`LLM, agent, tool and file evidence — connected from decision to code change.`})]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsx)(`span`,{className:y(`h-2 w-2 rounded-full`,K?`bg-destructive`:W?`animate-pulse bg-warning`:`bg-success`)}),(0,C.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:W?`Reading journal`:K?`Unavailable`:`Live evidence`}),(0,C.jsx)(`button`,{onClick:()=>Y(g),className:`ml-2 rounded-md border border-border bg-card p-2 hover:bg-muted`,title:`Refresh evidence`,children:(0,C.jsx)(h,{className:y(`h-4 w-4`,W&&`animate-spin`)})})]})]})}),(0,C.jsxs)(`section`,{className:`grid grid-cols-2 border-b border-border/70 xl:grid-cols-6`,children:[(0,C.jsx)(P,{icon:(0,C.jsx)(n,{}),label:`LLM requests`,value:H.logicalRequests,detail:`${H.modelAttempts} attempts · ${H.providers} providers · ${H.models} models`}),(0,C.jsx)(P,{icon:(0,C.jsx)(i,{}),label:`Agent work`,value:H.agentEvents,detail:`${H.uniqueAgents} correlated agents · ${H.decisions} decisions`}),(0,C.jsx)(P,{icon:(0,C.jsx)(a,{}),label:`Tool calls`,value:H.toolCalls,detail:`${H.failedTools} failed · ${H.processes} processes`}),(0,C.jsx)(P,{icon:(0,C.jsx)(o,{}),label:`File evidence`,value:H.fileEvents,detail:`${H.uniqueFiles} unique paths`}),(0,C.jsx)(P,{icon:(0,C.jsx)(t,{}),label:`Retries`,value:H.scheduledRetries,detail:`${H.failures} failures · ${H.fallbacks} fallbacks`,tone:H.failures?`danger`:`normal`}),(0,C.jsx)(P,{icon:(0,C.jsx)(u,{}),label:`Provider p95`,value:M(H.providerP95DurationMs),detail:`${M(H.providerAvgDurationMs)} average · all matches`})]}),(0,C.jsxs)(`section`,{className:`flex flex-wrap gap-x-6 gap-y-1 border-b border-border/60 bg-primary/[0.018] px-4 py-1.5 font-mono text-[9px] text-muted-foreground`,children:[(0,C.jsx)(`span`,{className:`font-sans font-semibold uppercase tracking-wider text-primary`,children:`Token economics`}),(0,C.jsxs)(`span`,{children:[`fresh input `,(0,C.jsx)(`b`,{className:`text-foreground`,children:H.inputTokens.toLocaleString()})]}),(0,C.jsxs)(`span`,{children:[`output `,(0,C.jsx)(`b`,{className:`text-foreground`,children:H.outputTokens.toLocaleString()})]}),(0,C.jsxs)(`span`,{children:[`cache read `,(0,C.jsx)(`b`,{className:`text-foreground`,children:H.cacheReadTokens.toLocaleString()})]}),(0,C.jsxs)(`span`,{children:[`cache write `,(0,C.jsx)(`b`,{className:`text-foreground`,children:H.cacheWriteTokens.toLocaleString()})]}),(0,C.jsxs)(`span`,{children:[`cache hit `,(0,C.jsxs)(`b`,{className:`text-foreground`,children:[k(H).toFixed(1),`%`]})]}),(0,C.jsxs)(`span`,{children:[`estimated cost `,(0,C.jsxs)(`b`,{className:`text-foreground`,children:[`$`,H.estimatedCostUsd.toFixed(4)]})]})]}),(0,C.jsx)(`section`,{className:`border-b border-border/70 px-4 py-3`,children:(0,C.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 xl:grid-cols-[1.35fr_1fr_1fr_1fr_1fr_auto]`,children:[(0,C.jsx)(N,{icon:(0,C.jsx)(ee,{}),placeholder:`Search event evidence`,value:T.text,onChange:e=>E(t=>({...t,text:e})),onEnter:$}),(0,C.jsx)(N,{placeholder:`File or directory`,value:T.path,onChange:e=>E(t=>({...t,path:e})),onEnter:$}),(0,C.jsx)(N,{placeholder:`Provider`,value:T.providerId,onChange:e=>E(t=>({...t,providerId:e})),onEnter:$}),(0,C.jsx)(N,{placeholder:`Model`,value:T.modelId,onChange:e=>E(t=>({...t,modelId:e})),onEnter:$}),(0,C.jsx)(N,{placeholder:`Session`,value:T.sessionId,onChange:e=>E(t=>({...t,sessionId:e})),onEnter:$}),(0,C.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,C.jsxs)(`button`,{onClick:$,className:`rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground`,children:[(0,C.jsx)(f,{className:`mr-1 inline h-3 w-3`}),`Apply`]}),(0,C.jsx)(`button`,{onClick:re,className:`rounded-md border border-border px-2.5 text-xs hover:bg-muted`,children:`Clear`})]})]})}),(0,C.jsxs)(`section`,{className:`flex items-center gap-1 overflow-x-auto border-b border-border/70 px-4 py-2`,children:[te.map(e=>(0,C.jsxs)(`button`,{onClick:()=>R(e.id),className:y(`flex shrink-0 items-center gap-1.5 rounded-md px-2.5 py-1.5 text-[11px] transition-colors [&>svg]:h-3.5 [&>svg]:w-3.5`,j===e.id?`bg-primary/10 font-medium text-primary`:`text-muted-foreground hover:bg-muted hover:text-foreground`),children:[e.icon,e.label,(0,C.jsx)(`span`,{className:`ml-1 rounded bg-background/70 px-1 font-mono text-[9px]`,children:O(H,e.id,B.total)})]},e.id)),(0,C.jsxs)(`div`,{className:`ml-auto hidden items-center gap-3 pl-4 text-[9px] text-muted-foreground lg:flex`,children:[(0,C.jsxs)(`span`,{children:[B.total.toLocaleString(),` matched`]}),(0,C.jsxs)(`span`,{children:[B.sourceFiles,` journal files`]}),B.invalidLines>0&&(0,C.jsxs)(`span`,{className:`text-warning`,children:[B.invalidLines,` invalid lines`]})]})]}),Q&&(0,C.jsx)(F,{health:Q}),(0,C.jsx)(`section`,{className:`flex gap-4 overflow-x-auto border-b border-border/60 bg-muted/[0.18] px-4 py-2`,children:[`providerId`,`modelId`,`outcome`].map(e=>(0,C.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,C.jsx)(`span`,{className:`mr-1 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e.replace(`Id`,``)}),(d[e]??[]).slice(0,4).map(t=>(0,C.jsxs)(`button`,{onClick:()=>Y({...g,[e]:t.value}),className:`rounded-full border border-border bg-card px-2 py-0.5 text-[9px] hover:border-primary/50`,children:[t.value,` `,(0,C.jsx)(`b`,{children:t.count})]},t.value))]},e))}),(0,C.jsxs)(`div`,{className:`grid grid-cols-[92px_minmax(190px,1.25fr)_110px_minmax(180px,1fr)_minmax(140px,.8fr)_24px] gap-3 border-b border-border/60 bg-muted/20 px-4 py-1.5 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,C.jsx)(`span`,{children:`Time`}),(0,C.jsx)(`span`,{children:`Signal`}),(0,C.jsx)(`span`,{children:`Outcome`}),(0,C.jsx)(`span`,{children:`Model / agent`}),(0,C.jsx)(`span`,{children:`Resource`}),(0,C.jsx)(`span`,{})]}),(0,C.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:K?(0,C.jsx)(z,{text:K}):!W&&X.length===0?(0,C.jsx)(z,{text:`No coding evidence matches these filters.`}):(0,C.jsx)(`div`,{className:`divide-y divide-border/40`,children:Z.pageItems.map(e=>(0,C.jsx)(I,{event:e,active:c?.eventId===e.eventId,onClick:()=>ie(e)},e.eventId))})}),(0,C.jsx)(b,{page:Z.page,pageSize:Z.pageSize,totalItems:Z.totalItems,onPageChange:Z.setPage,itemLabel:`events`})]}),c&&(0,C.jsxs)(`aside`,{className:`w-[440px] max-w-[48vw] shrink-0 overflow-auto border-l border-border bg-card/60 shadow-[-12px_0_32px_hsl(var(--background)/.35)]`,children:[(0,C.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center justify-between border-b border-border bg-card/95 px-4 py-3 backdrop-blur`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-xs font-semibold`,children:`Evidence & lineage`}),(0,C.jsxs)(`div`,{className:`mt-0.5 font-mono text-[9px] text-muted-foreground`,children:[`#`,c.sequence,` · `,c.eventId]})]}),(0,C.jsx)(`button`,{onClick:()=>l(null),className:`rounded p-1 hover:bg-muted`,children:(0,C.jsx)(p,{className:`h-4 w-4`})})]}),(0,C.jsx)(L,{event:c,graph:ne})]})]})}var E={llm:0,agent:0,tool:0,file:0,memory:0,task:0,decision:0,runtime:0},D={logicalRequests:0,modelAttempts:0,completedAttempts:0,failedAttempts:0,scheduledRetries:0,fallbacks:0,providers:0,models:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheWriteTokens:0,estimatedCostUsd:0,providerAvgDurationMs:0,providerP95DurationMs:0,toolCalls:0,completedTools:0,failedTools:0,toolAvgDurationMs:0,processes:0,failedProcesses:0,fileEvents:0,uniqueFiles:0,agentEvents:0,uniqueAgents:0,decisions:0,escalations:0,failures:0,cancellations:0,families:{...E},failuresByFamily:{...E}};function O(e,t,n){return t===`all`?n:t===`llm`?e.families.llm:t===`agents`?e.families.agent:t===`tools`?e.families.tool:t===`files`?e.families.file:e.failures}function k(e){let t=e.inputTokens+e.cacheReadTokens;return t?e.cacheReadTokens/t*100:0}function A(e,t){return t===`all`?!0:t===`llm`?/^(provider|token|context|compaction)\./.test(e.eventType):t===`agents`?/^(agent|subagent|delegate|fleet|sdd)\./.test(e.eventType):t===`tools`?/^(tool|process|mcp|network)\./.test(e.eventType):t===`files`?e.resource?.kind===`file`||/^(file|worktree|storage)\./.test(e.eventType):e.outcome===`failure`||/(?:failed|error|retry|fallback|blocked|conflict)/i.test(e.eventType)}function j(e){if(!e)return`—`;let t=e/1e6;return t<1?`${(e/1e3).toFixed(0)}µs`:t<1e3?`${t.toFixed(1)}ms`:`${(t/1e3).toFixed(1)}s`}function M(e){return e?e<1?`${(e*1e3).toFixed(0)}µs`:e<1e3?`${e.toFixed(1)}ms`:`${(e/1e3).toFixed(1)}s`:`—`}function N({placeholder:e,value:t,onChange:n,onEnter:r,icon:i}){return(0,C.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md border border-border bg-card px-2.5 py-2 focus-within:border-primary/60`,children:[i&&(0,C.jsx)(`span`,{className:`text-muted-foreground [&>svg]:h-3.5 [&>svg]:w-3.5`,children:i}),(0,C.jsx)(`input`,{className:`w-full bg-transparent text-xs outline-none placeholder:text-muted-foreground/70`,placeholder:e,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{e.key===`Enter`&&r()}})]})}function P({icon:e,label:t,value:n,detail:r,tone:i=`normal`}){return(0,C.jsxs)(`div`,{className:`min-w-0 border-r border-border/60 px-4 py-3`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:[(0,C.jsx)(`span`,{className:`text-primary [&>svg]:h-3.5 [&>svg]:w-3.5`,children:e}),t]}),(0,C.jsx)(`div`,{className:y(`mt-1 text-xl font-semibold tabular-nums`,i===`danger`&&`text-destructive`),children:typeof n==`number`?n.toLocaleString():n}),(0,C.jsx)(`div`,{className:`mt-0.5 truncate text-[9px] text-muted-foreground`,children:r})]})}function F({health:e}){return(0,C.jsxs)(`section`,{className:`flex flex-wrap gap-x-5 gap-y-1 border-b border-border/60 bg-success/[0.025] px-4 py-1.5 font-mono text-[9px] text-muted-foreground`,children:[(0,C.jsx)(`span`,{className:`font-sans font-semibold uppercase tracking-wider text-success`,children:`Collector healthy`}),(0,C.jsxs)(`span`,{children:[`ELU `,(0,C.jsxs)(`b`,{className:`text-foreground`,children:[((e.eventLoop?.utilization??0)*100).toFixed(1),`%`]})]}),(0,C.jsxs)(`span`,{children:[`p95 `,(0,C.jsxs)(`b`,{className:`text-foreground`,children:[(e.eventLoop?.delayP95Ms??0).toFixed(1),`ms`]})]}),(0,C.jsxs)(`span`,{children:[`heap `,(0,C.jsxs)(`b`,{className:`text-foreground`,children:[((e.memory?.heapUsedBytes??0)/1048576).toFixed(0),`MB`]})]}),(0,C.jsxs)(`span`,{children:[`queue `,(0,C.jsx)(`b`,{className:`text-foreground`,children:e.chronicle?.pendingEvents??0})]}),(0,C.jsxs)(`span`,{children:[`dropped `,(0,C.jsx)(`b`,{className:y((e.chronicle?.rejectedEvents??0)>0&&`text-destructive`),children:e.chronicle?.rejectedEvents??0})]})]})}function I({event:e,active:t,onClick:n}){let r=e.occurredAt??e.observedAt,i=e.runtime?.modelId??e.scope.agentId??e.runtime?.providerId??`—`,a=e.resource?.path??e.resource?.id??e.correlation.toolCallId??`—`;return(0,C.jsxs)(`button`,{onClick:n,className:y(`grid w-full grid-cols-[92px_minmax(190px,1.25fr)_110px_minmax(180px,1fr)_minmax(140px,.8fr)_24px] items-center gap-3 px-4 py-2.5 text-left hover:bg-muted/45`,t&&`bg-primary/[0.07]`),children:[(0,C.jsx)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:new Date(r).toLocaleTimeString()}),(0,C.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,C.jsx)(`span`,{className:y(`h-1.5 w-1.5 shrink-0 rounded-full`,e.outcome===`failure`?`bg-destructive`:e.outcome===`success`?`bg-success`:`bg-primary`)}),(0,C.jsx)(`span`,{className:`truncate font-mono text-[11px] font-medium`,children:e.eventType})]}),(0,C.jsx)(`span`,{className:y(`w-fit rounded px-1.5 py-0.5 text-[9px]`,B(e.outcome)),children:e.outcome??`unknown`}),(0,C.jsx)(`span`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:i}),(0,C.jsx)(`span`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:a}),(0,C.jsx)(_,{className:`h-3.5 w-3.5 text-muted-foreground`})]})}function L({event:e,graph:t}){let n=(0,S.useMemo)(()=>[[`Scope`,e.scope],[`Correlation`,e.correlation],[`Runtime`,e.runtime],[`Resource`,e.resource],[`Attributes`,e.attributes],[`Tags`,e.tags]],[e]);return(0,C.jsxs)(`div`,{className:`p-4`,children:[(0,C.jsxs)(`div`,{className:`mb-4 rounded-lg border border-border bg-background/60 p-3`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsx)(`span`,{className:y(`h-2 w-2 rounded-full`,e.outcome===`failure`?`bg-destructive`:e.outcome===`success`?`bg-success`:`bg-primary`)}),(0,C.jsx)(`span`,{className:`font-mono text-xs font-semibold`,children:e.eventType})]}),(0,C.jsxs)(`div`,{className:`mt-2 flex gap-4 text-[9px] text-muted-foreground`,children:[(0,C.jsx)(`span`,{children:new Date(e.occurredAt??e.observedAt).toLocaleString()}),(0,C.jsx)(`span`,{children:j(Number(e.durationNs??0))})]})]}),(0,C.jsxs)(`div`,{className:`mb-4 grid grid-cols-2 gap-2`,children:[(0,C.jsx)(R,{icon:(0,C.jsx)(r,{}),label:`Evidence hash`,value:e.hash.slice(0,16)}),(0,C.jsx)(R,{icon:(0,C.jsx)(s,{}),label:`Sequence`,value:String(e.sequence)})]}),t&&(0,C.jsxs)(`section`,{className:`mb-4`,children:[(0,C.jsxs)(`h3`,{className:`mb-1.5 flex items-center gap-1 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,C.jsx)(m,{className:`h-3 w-3`}),`Lineage · `,t.nodes.length,` nodes · `,t.edges.length,` edges`]}),(0,C.jsx)(`div`,{className:`space-y-1 rounded-md border border-border bg-background/70 p-2`,children:t.edges.slice(0,40).map((e,n)=>(0,C.jsxs)(`div`,{className:`flex items-center gap-2 font-mono text-[9px]`,children:[(0,C.jsx)(`span`,{className:y(`rounded px-1`,e.confidence===`explicit`?`bg-success/10 text-success`:e.confidence===`inferred`?`bg-warning/10 text-warning`:`bg-primary/10 text-primary`),children:e.confidence}),(0,C.jsx)(`span`,{className:`text-muted-foreground`,children:e.kind}),(0,C.jsxs)(`span`,{className:`truncate`,children:[t.nodes.find(t=>t.eventId===e.from)?.eventType,` → `,t.nodes.find(t=>t.eventId===e.to)?.eventType]})]},`${e.from}-${e.to}-${e.kind}-${n}`))}),t.truncated&&(0,C.jsx)(`p`,{className:`mt-1 text-[9px] text-warning`,children:`Lineage truncated at safety limit.`})]}),n.map(([e,t])=>t&&(0,C.jsxs)(`section`,{className:`mb-4`,children:[(0,C.jsx)(`h3`,{className:`mb-1.5 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e}),(0,C.jsx)(`pre`,{className:`overflow-auto rounded-md border border-border bg-background/70 p-3 font-mono text-[9px] leading-relaxed`,children:JSON.stringify(t,null,2)})]},e))]})}function R({icon:e,label:t,value:n}){return(0,C.jsxs)(`div`,{className:`rounded-md border border-border p-2`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-1 text-[8px] uppercase text-muted-foreground`,children:[(0,C.jsx)(`span`,{className:`[&>svg]:h-3 [&>svg]:w-3`,children:e}),t]}),(0,C.jsx)(`div`,{className:`mt-1 truncate font-mono text-[9px]`,children:n})]})}function z({text:e}){return(0,C.jsx)(`div`,{className:`flex h-48 items-center justify-center text-sm text-muted-foreground`,children:e})}function B(e){return e===`failure`?`bg-destructive/10 text-destructive`:e===`success`?`bg-success/10 text-success`:e===`started`?`bg-primary/10 text-primary`:`bg-muted text-muted-foreground`}export{T as ChronicleDashboard};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Bn as t,Bt as n,Ci as r,Cn as i,Et as a,Lr as o,Mi as s,Sn as c,Sr as l,Ur as u,Wi as ee,Zi as d,Zn as f,_ as p,a as te,aa as m,ar as ne,c as re,f as ie,g as h,h as ae,i as oe,in as g,ln as se,m as ce,mn as _,ot as le,p as ue,pr as de,qt as fe,r as pe,s as v,tt as y,u as me,xi as b,xn as he,yr as x}from"./vendor-Di1mdAi5.js";import{t as S}from"./utils-C4qVQ63O.js";import{i as ge,r as _e,t as C}from"./codemap-activity-store-BIW6YPvC.js";var w=e(m(),1);function T(e){return e.level===`packages`?`packages`:e.level===`files`?`files:${e.package}`:`symbols:${e.file}`}function ve(e){return e.level===`packages`?`/api/codemap/packages`:e.level===`files`?`/api/codemap/files?package=${encodeURIComponent(e.package)}`:`/api/codemap/symbols?file=${encodeURIComponent(e.file)}`}function ye(e,t,n){let r=new Map(e.nodes.map(e=>[e.id,e])),i=[];for(let a of e.edges){let e=n===`incoming`?a.target===t?a.source:void 0:a.source===t?a.target:void 0;if(!e)continue;let o=r.get(e);o&&i.push({node:o,edge:a})}return i.sort((e,t)=>t.edge.weight-e.edge.weight||e.node.label.localeCompare(t.node.label))}function be(e,t){let n=new Set([t]);for(let r of e.edges)r.source===t&&n.add(r.target),r.target===t&&n.add(r.source);return n}function xe(e,t){let n=new Map(e.nodes.map(e=>[e.id,0]));for(let r of e.edges)!t.has(r.source)||!t.has(r.target)||(n.set(r.source,(n.get(r.source)??0)+r.weight),r.target!==r.source&&n.set(r.target,(n.get(r.target)??0)+r.weight));return n}function E(e){let t=new Set(e.nodes.map(e=>e.id)),n=xe(e,t),r=new Map(e.nodes.map(e=>[e.id,0])),i=new Map;for(let n of e.edges){if(!t.has(n.source)||!t.has(n.target)||n.source===n.target)continue;r.set(n.target,(r.get(n.target)??0)+1);let e=i.get(n.source)??[];e.push(n.target),i.set(n.source,e)}let a=new Map,o=e.nodes.filter(e=>(r.get(e.id)??0)===0).sort((e,t)=>(n.get(t.id)??0)-(n.get(e.id)??0)).map(e=>e.id);o.length===0&&e.nodes[0]&&o.push(e.nodes[0].id);for(let e of o)a.set(e,0);let s=new Set,c=0;for(;c<o.length;){let e=o[c++];if(!s.has(e)){s.add(e);for(let t of i.get(e)??[])a.set(t,Math.max(a.get(t)??0,Math.min((a.get(e)??0)+1,7))),r.set(t,(r.get(t)??1)-1),(r.get(t)??0)<=0&&o.push(t)}}let l=e.nodes.filter(e=>!a.has(e.id)).sort((e,t)=>(n.get(t.id)??0)-(n.get(e.id)??0));l.forEach((e,t)=>{a.set(e.id,t%Math.min(4,Math.max(1,l.length)))});let u=new Map;for(let t of e.nodes){let e=a.get(t.id)??0,n=u.get(e)??[];n.push(t),u.set(e,n)}for(let e of u.values())e.sort((e,t)=>Number(e.external)-Number(t.external)||(n.get(t.id)??0)-(n.get(e.id)??0)||e.label.localeCompare(t.label));let ee=Math.max(1,...[...u.values()].map(e=>e.length))*160,d=[];for(let[e,t]of[...u.entries()].sort(([e],[t])=>e-t)){let n=(ee-t.length*160)/2;t.forEach((t,r)=>{d.push({node:t,position:{x:e*386,y:n+r*160}})})}return d}function Se(e,t){if(e.nodes.length===0)return[];let n=xe(e,new Set(e.nodes.map(e=>e.id))),r=e.nodes.find(e=>e.id===t)??[...e.nodes].sort((e,t)=>(n.get(t.id)??0)-(n.get(e.id)??0))[0],i=be(e,r.id);i.delete(r.id);let a=e.nodes.filter(e=>i.has(e.id)),o=e.nodes.filter(e=>e.id!==r.id&&!i.has(e.id)),s=[{node:r,position:{x:0,y:0}}],c=(e,t,n)=>{e.forEach((r,i)=>{let a=n+Math.PI*2*i/Math.max(1,e.length);s.push({node:r,position:{x:Math.cos(a)*t,y:Math.sin(a)*t}})})};c(a,Math.max(330,a.length*34),-Math.PI/2);for(let e=0;e<o.length;e+=18)c(o.slice(e,e+18),620+Math.floor(e/18)*280,-Math.PI/2+.12);return s}function Ce(e,t,n){return t===`orbit`?Se(e,n):E(e)}function D(e){let t=(e.file??e.label).replace(/\\/g,`/`),n=e.package??``,r=n.startsWith(`@wrongstack/`)?`/packages/${n.slice(12)}/`:n.startsWith(`app:`)?`/apps/${n.slice(4)}/`:void 0;if(r){let e=t.indexOf(r);if(e>=0)return t.slice(e+r.length)}let i=t.lastIndexOf(`/src/`);return i>=0?t.slice(i+1):t.split(`/`).slice(-3).join(`/`)}var O=new WeakMap;function we(e){let t=O.get(e);if(t)return t;let n={name:``,path:``,directories:[],files:[]};for(let t of e.filter(e=>e.kind===`file`&&!e.external)){let e=D(t).split(`/`).filter(Boolean),r=e.pop()??t.label,i=n;for(let t of e){let e=i.path?`${i.path}/${t}`:t,n=i.directories.find(e=>e.name===t);n||(n={name:t,path:e,directories:[],files:[]},i.directories.push(n)),i=n}i.files.push({...t,label:r})}let r=e=>{e.directories.sort((e,t)=>e.name.localeCompare(t.name)),e.files.sort((e,t)=>e.label.localeCompare(t.label)),e.directories.forEach(r)};return r(n),O.set(e,n),n}var k=y(),Te={nodes:[],edges:[]},A={package:{icon:he,accent:`border-l-primary`,iconStyle:`bg-primary/12 text-primary`},file:{icon:o,accent:`border-l-info`,iconStyle:`bg-info/12 text-info`},symbol:{icon:s,accent:`border-l-success`,iconStyle:`bg-success/12 text-success`}},Ee={call:`hsl(var(--primary))`,import:`hsl(var(--info))`,type_ref:`hsl(var(--success))`,inherit:`hsl(var(--warning))`,implement:`hsl(var(--destructive))`},De={read:`ring-2 ring-info/60 shadow-info/20`,write:`ring-2 ring-warning/70 shadow-warning/30`,edit:`ring-2 ring-warning/80 shadow-warning/40`,delete:`ring-2 ring-destructive/70 shadow-destructive/30`,search:`ring-2 ring-primary/55 shadow-primary/20`,memory:`ring-2 ring-success/60 shadow-success/30`,index:`ring-2 ring-info/50 shadow-info/20`,execute:`ring-2 ring-primary/55 shadow-primary/25`},j=[`bg-primary text-primary-foreground`,`bg-info text-info-foreground`,`bg-success text-success-foreground`,`bg-warning text-warning-foreground`,`bg-destructive text-destructive-foreground`];function M(e){return e.replace(/\\/g,`/`).replace(/^\.\//,``).toLocaleLowerCase()}function Oe(e,t){if(!e||!t)return!1;let n=M(e),r=M(t);return n===r||n.endsWith(`/${r}`)||r.endsWith(`/${n}`)}function ke(e){let t=M(e),n=t.match(/\/packages\/([^/]+)\//);if(n?.[1])return`@wrongstack/${n[1]}`;let r=t.match(/\/apps\/([^/]+)\//);return r?.[1]?`app:${r[1]}`:`(root)`}function N(e,t){return t.kind===`package`?ke(e.filePath)===(t.package??t.label):Oe(e.filePath,t.file)?t.kind!==`symbol`||e.symbol?.id===t.id:!1}function Ae(e){let t=e.trim().split(/[\s:_-]+/).filter(Boolean);return(t.length>1?`${t[0]?.[0]??``}${t[1]?.[0]??``}`:e.slice(0,2)).toLocaleUpperCase()}function je(e){let t=0;for(let n of e)t=t*31+n.charCodeAt(0)|0;return j[Math.abs(t)%j.length]??j[0]}function Me(e){let t=0;for(let n of e)t=t*31+n.charCodeAt(0)|0;return`hsl(${Math.abs(t)%360} 82% 58%)`}function Ne(e){let t=e.replace(/\\/g,`/`),n=t.lastIndexOf(`/packages/`),r=t.lastIndexOf(`/apps/`),i=Math.max(n,r);return i>=0?t.slice(i+1):t.split(`/`).slice(-3).join(`/`)}function Pe(e){return[e.symbol?.name,e.line?`L${e.line}`:void 0].filter(Boolean).join(` · `)}function Fe(e,t){let n=t.filter(t=>t.kind===`symbol`&&!t.external&&Oe(t.file,e.filePath));if(n.length===0)return;if(e.line)return[...n].sort((e,t)=>(t.line??0)-(e.line??0)).find(t=>(t.line??0)<=e.line)??n[0];let r=e.summary.toLocaleLowerCase();return n.find(e=>e.label.length>2&&(r.includes(e.label.toLocaleLowerCase())||!!(e.signature&&r.includes(e.signature.toLocaleLowerCase()))))}var Ie=160;function Le(e,t,n){if(n===`all`||e.nodes.length<=Ie)return e;let r=new Map(e.nodes.map(e=>[e.id,e])),i=new Map;for(let t of e.edges)i.set(t.source,(i.get(t.source)??0)+t.weight),i.set(t.target,(i.get(t.target)??0)+t.weight);let a=[...e.nodes].sort((e,t)=>(i.get(t.id)??0)-(i.get(e.id)??0)||e.label.localeCompare(t.label)),o=new Set,s=e=>{r.has(e)&&o.size<Ie&&o.add(e)};if(t&&r.has(t)){s(t);let n=e.edges.filter(e=>e.source===t||e.target===t).sort((e,t)=>t.weight-e.weight);for(let e of n)s(e.source),s(e.target);let r=new Set(o),i=e.edges.filter(e=>r.has(e.source)||r.has(e.target)).sort((e,t)=>t.weight-e.weight);for(let e of i)s(e.source),s(e.target)}else{let e=a.filter(e=>!e.external).slice(0,124),t=a.filter(e=>e.external).slice(0,36);for(let n of[...e,...t])s(n.id)}for(let e of a)s(e.id);return{nodes:e.nodes.filter(e=>o.has(e.id)),edges:e.edges.filter(e=>o.has(e.source)&&o.has(e.target))}}function Re({data:e}){let{graphNode:t,selected:n,dimmed:r,incoming:i,outgoing:a,isActive:o,activityType:s,activeOperations:c}=e,l=A[t.kind],ee=l.icon,d=t.kind!==`symbol`,f=t.kind===`symbol`?`${t.symbolKind??`symbol`}${t.line?` · L${t.line}`:``}`:t.kind===`file`?D(t):`${t.fileCount??0} files · ${t.symbolCount??0} symbols`;return(0,k.jsxs)(`div`,{className:S(`group relative w-[236px] border border-l-[3px] bg-card text-card-foreground shadow-[0_8px_24px_hsl(var(--shadow-color)/0.08)] transition-[opacity,filter,box-shadow,border-color,background-color]`,l.accent,n&&`border-primary bg-primary/5 shadow-[0_0_0_2px_hsl(var(--primary)/0.18),0_16px_36px_hsl(var(--shadow-color)/0.18)]`,t.external&&`border-dashed bg-muted/75`,r&&`opacity-25 grayscale`,o&&s&&De[s]),children:[c.length>0&&(0,k.jsxs)(`div`,{className:`absolute -top-5 left-2 z-20 flex max-w-[210px] items-center gap-1`,children:[c.slice(0,4).map(e=>{let t=e.agentName??e.agent??`External`,n=`${e.sessionId??`none`}:${e.agentId??t}`;return(0,k.jsxs)(`span`,{className:S(`flex h-6 items-center gap-1 border-2 border-background px-1.5 font-mono text-[8px] font-bold shadow-md`,je(n)),title:`${t} · ${e.type} ${Pe(e)}`,children:[(0,k.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse bg-current`}),Ae(t),e.symbol&&(0,k.jsx)(`span`,{className:`max-w-[80px] truncate`,children:e.symbol.name})]},e.id??`${n}:${e.filePath}`)}),c.length>4&&(0,k.jsxs)(`span`,{className:`border bg-card px-1 font-mono text-[8px] shadow`,children:[`+`,c.length-4]})]}),(0,k.jsx)(v,{type:`target`,position:p.Left,className:`!h-2.5 !w-2.5 !border-2 !border-card !bg-muted-foreground`}),(0,k.jsxs)(`button`,{type:`button`,className:`block w-full text-left`,onClick:n=>{if(n.shiftKey&&t.file){e.onShowHistory(t.file);return}e.onSelect(t)},onDoubleClick:()=>d&&e.onOpen(t),"aria-label":`${t.kind} ${t.label}`,children:[(0,k.jsxs)(`div`,{className:`flex items-start gap-3 p-3 pr-10`,children:[(0,k.jsx)(`span`,{className:S(`flex h-8 w-8 shrink-0 items-center justify-center border`,l.iconStyle),children:(0,k.jsx)(ee,{className:`h-4 w-4`})}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[9px] font-bold uppercase tracking-[0.18em] text-muted-foreground`,children:[(0,k.jsx)(`span`,{children:t.kind}),t.external&&(0,k.jsx)(`span`,{className:`border border-border px-1 py-0.5 text-[8px] text-warning`,children:`external`}),t.lang&&(0,k.jsx)(`span`,{className:`ml-auto font-mono normal-case tracking-normal`,children:t.lang})]}),(0,k.jsx)(`div`,{className:`truncate font-mono text-[13px] font-semibold`,title:t.label,children:t.label}),(0,k.jsx)(`div`,{className:`mt-1 truncate text-[10px] text-muted-foreground`,title:f,children:f})]})]}),(0,k.jsxs)(`div`,{className:`flex items-center gap-3 border-t bg-muted/30 px-3 py-1.5 font-mono text-[9px] text-muted-foreground`,children:[(0,k.jsxs)(`span`,{title:`Incoming relationships`,children:[`← `,i]}),(0,k.jsxs)(`span`,{title:`Outgoing relationships`,children:[`→ `,a]}),t.symbolCount!==void 0&&t.kind===`file`&&(0,k.jsxs)(`span`,{className:`ml-auto`,children:[t.symbolCount,` sym`]}),o&&(0,k.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 font-bold text-warning`,children:[(0,k.jsx)(g,{className:`h-2.5 w-2.5 animate-pulse`}),` LIVE`]})]})]}),d&&(0,k.jsx)(`button`,{type:`button`,className:`absolute right-2 top-2 z-10 flex h-7 w-7 items-center justify-center border border-transparent text-muted-foreground opacity-0 transition hover:border-border hover:bg-muted hover:text-foreground group-hover:opacity-100 focus:opacity-100`,onClick:()=>e.onOpen(t),title:t.kind===`package`?`Open file map`:`Open symbol map`,"aria-label":`Open ${t.label} map`,children:(0,k.jsx)(u,{className:`h-3.5 w-3.5`})}),(0,k.jsx)(v,{type:`source`,position:p.Right,className:`!h-2.5 !w-2.5 !border-2 !border-card !bg-muted-foreground`})]})}function ze(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function P(e,t){return e.graphNode===t.graphNode&&e.selected===t.selected&&e.dimmed===t.dimmed&&e.incoming===t.incoming&&e.outgoing===t.outgoing&&e.isActive===t.isActive&&e.activityType===t.activityType&&e.onSelect===t.onSelect&&e.onOpen===t.onOpen&&e.onShowHistory===t.onShowHistory&&ze(e.activeOperations,t.activeOperations)}var Be={codemap:(0,w.memo)(Re,(e,t)=>P(e.data,t.data))};function Ve(e,t){let n=new Map(e.map(e=>[e.id,e])),r=e.length!==t.length,i=t.map((t,i)=>{let a=n.get(t.id);return a?a.type===t.type&&a.position.x===t.position.x&&a.position.y===t.position.y&&P(a.data,t.data)?(e[i]!==a&&(r=!0),a):(r=!0,{...a,...t,measured:a.measured}):(r=!0,t)});return r?i:e}function He(e){return e.data?.renderKey}function Ue(e,t){let n=new Map(e.map(e=>[e.id,e])),r=e.length!==t.length,i=t.map((t,i)=>{let a=n.get(t.id);return a&&He(a)===He(t)?(e[i]!==a&&(r=!0),a):(r=!0,t)});return r?i:e}function We(e){let{directory:n,packageName:i,depth:a,expandedDirectories:c,expandedFiles:ee,loadingBranches:d,graphForFile:f,onToggleDirectory:p,onToggleFile:te,onSelectFile:m,onOpenFile:ne,onSelectSymbol:re,selectedId:ie,activeOperations:h}=e;return(0,k.jsxs)(k.Fragment,{children:[n.directories.map(t=>{let n=`${i}:${t.path}`,o=c.has(n);return(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`button`,{type:`button`,className:`flex h-7 w-full items-center gap-1.5 pr-2 text-left text-[11px] text-muted-foreground hover:bg-muted hover:text-foreground`,style:{paddingLeft:8+a*12},onClick:()=>p(n),children:[o?(0,k.jsx)(r,{className:`h-3 w-3`}):(0,k.jsx)(b,{className:`h-3 w-3`}),o?(0,k.jsx)(l,{className:`h-3.5 w-3.5 text-warning`}):(0,k.jsx)(x,{className:`h-3.5 w-3.5 text-warning`}),(0,k.jsx)(`span`,{className:`truncate`,children:t.name})]}),o&&(0,k.jsx)(We,{...e,directory:t,depth:a+1})]},n)}),n.files.map(e=>{let n=ee.has(e.file??e.id),i=T({level:`symbols`,file:e.file??e.label}),c=(e.file?f(e.file):void 0)?.nodes.filter(t=>t.kind===`symbol`&&t.file===e.file&&!t.external)??[],l=h.filter(t=>Oe(t.filePath,e.file));return(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`div`,{className:S(`group flex h-7 items-center pr-1 text-[11px] hover:bg-muted`,ie===e.id&&`bg-primary/10 text-primary`),style:{paddingLeft:8+a*12},children:[(0,k.jsx)(`button`,{type:`button`,className:`flex h-6 w-4 shrink-0 items-center justify-center text-muted-foreground`,onClick:()=>te(e),"aria-label":`${n?`Collapse`:`Expand`} ${e.label}`,children:d.has(i)?(0,k.jsx)(t,{className:`h-3 w-3 animate-spin`}):n?(0,k.jsx)(r,{className:`h-3 w-3`}):(0,k.jsx)(b,{className:`h-3 w-3`})}),(0,k.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-1.5 text-left`,onClick:()=>m(e),onDoubleClick:()=>ne(e),children:[(0,k.jsx)(o,{className:`h-3.5 w-3.5 shrink-0 text-info`}),l.length>0&&(0,k.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 animate-pulse bg-success`,title:`${l.length} live operation(s)`}),(0,k.jsx)(`span`,{className:`truncate font-mono`,title:e.file,children:e.label}),(0,k.jsx)(`span`,{className:`ml-auto text-[9px] text-muted-foreground`,children:e.symbolCount??0})]}),(0,k.jsx)(`button`,{type:`button`,className:`ml-1 hidden h-5 w-5 items-center justify-center text-muted-foreground hover:text-foreground group-hover:flex`,onClick:()=>ne(e),title:`Open symbol map`,"aria-label":`Open ${e.label} map`,children:(0,k.jsx)(u,{className:`h-3 w-3`})})]}),n&&c.map(e=>(0,k.jsxs)(`button`,{type:`button`,className:S(`flex h-7 w-full items-center gap-1.5 pr-2 text-left text-[10px] hover:bg-muted`,ie===e.id?`bg-primary/10 text-primary`:`text-muted-foreground`),style:{paddingLeft:38+a*12},onClick:()=>re(e),children:[(0,k.jsx)(s,{className:`h-3 w-3 shrink-0 text-success`}),h.some(t=>t.symbol?.id===e.id)&&(0,k.jsx)(g,{className:`h-3 w-3 shrink-0 animate-pulse text-success`}),(0,k.jsx)(`span`,{className:`truncate font-mono`,children:e.label}),e.line&&(0,k.jsxs)(`span`,{className:`ml-auto font-mono text-[8px] opacity-60`,children:[`:`,e.line]})]},e.id))]},e.id)})]})}function Ge(e){let{title:t,subtitle:n,items:i,graph:a,selectedId:o,expanded:s,onToggle:c,onSelect:l}=e;return(0,k.jsxs)(`section`,{className:`border-b py-3`,children:[(0,k.jsxs)(`div`,{className:`mb-2 flex items-end justify-between px-3`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`h3`,{className:`text-[10px] font-bold uppercase tracking-[0.16em]`,children:t}),(0,k.jsx)(`p`,{className:`mt-0.5 text-[9px] text-muted-foreground`,children:n})]}),(0,k.jsx)(`span`,{className:`border bg-muted px-1.5 py-0.5 font-mono text-[9px]`,children:i.length})]}),i.length===0?(0,k.jsx)(`p`,{className:`px-3 py-2 text-[10px] text-muted-foreground`,children:`No relationships in this view.`}):i.map(e=>{let n=`${t}:${e.node.id}`,i=s.has(n),u=[...ye(a,e.node.id,`incoming`),...ye(a,e.node.id,`outgoing`)].filter((e,t,n)=>e.node.id!==o&&n.findIndex(t=>t.node.id===e.node.id)===t).slice(0,8);return(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`div`,{className:`group flex min-h-9 items-center gap-1 px-2 hover:bg-muted/70`,children:[(0,k.jsx)(`button`,{type:`button`,className:`flex h-6 w-5 shrink-0 items-center justify-center text-muted-foreground`,onClick:()=>u.length>0&&c(n),"aria-label":`${i?`Collapse`:`Expand`} relation ${e.node.label}`,children:u.length>0?i?(0,k.jsx)(r,{className:`h-3 w-3`}):(0,k.jsx)(b,{className:`h-3 w-3`}):(0,k.jsx)(`span`,{className:`h-px w-2 bg-border`})}),(0,k.jsxs)(`button`,{type:`button`,className:`min-w-0 flex-1 py-1 text-left`,onClick:()=>l(e.node),children:[(0,k.jsx)(`span`,{className:`block truncate font-mono text-[10px] font-semibold`,title:e.node.label,children:e.node.label}),(0,k.jsx)(`span`,{className:`block truncate text-[9px] text-muted-foreground`,children:e.node.package??e.node.symbolKind??e.node.kind})]}),(0,k.jsx)(`span`,{className:`border px-1 py-0.5 font-mono text-[8px] text-muted-foreground`,children:e.edge.refType}),(0,k.jsxs)(`span`,{className:`w-5 text-right font-mono text-[9px] text-muted-foreground`,children:[`×`,e.edge.weight]})]}),i&&u.map(e=>(0,k.jsxs)(`button`,{type:`button`,className:`relative flex h-7 w-full items-center gap-2 border-l border-border pl-11 pr-3 text-left text-[9px] text-muted-foreground hover:bg-muted hover:text-foreground`,onClick:()=>l(e.node),children:[(0,k.jsx)(`span`,{className:`absolute left-7 top-1/2 h-px w-3 bg-border`}),(0,k.jsx)(de,{className:`h-3 w-3 shrink-0`}),(0,k.jsx)(`span`,{className:`truncate font-mono`,children:e.node.label}),(0,k.jsx)(`span`,{className:`ml-auto font-mono opacity-70`,children:e.edge.refType})]},`${n}:${e.node.id}`))]},n)})]})}function F({activity:e}){return(0,k.jsx)(`span`,{className:S(`shrink-0 border px-1.5 py-0.5 font-mono text-[8px] font-bold uppercase`,e.type===`delete`?`border-destructive/50 bg-destructive/10 text-destructive`:e.type===`read`?`border-info/50 bg-info/10 text-info`:e.type===`search`||e.type===`index`?`border-primary/50 bg-primary/10 text-primary`:`border-warning/50 bg-warning/10 text-warning`),children:e.filePath.startsWith(`(tool:`)?e.toolName:e.type})}function I({activity:e,onLocate:t,showAgent:r=!1}){let i=e.agentName??e.agent??`External process`,o=`${e.sessionId??`none`}:${e.agentId??i}`;return(0,k.jsxs)(`button`,{type:`button`,className:`group flex w-full items-start gap-2 border-b px-3 py-2 text-left last:border-b-0 hover:bg-muted/70`,onClick:()=>!e.filePath.startsWith(`(`)&&t(e),title:`Locate ${e.filePath}`,children:[r&&(0,k.jsx)(`span`,{className:S(`mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center font-mono text-[8px] font-black`,je(o)),children:Ae(i)}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,k.jsx)(F,{activity:e}),r&&(0,k.jsx)(`span`,{className:`truncate text-[9px] font-semibold`,children:i}),e.status===`active`&&(0,k.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 font-mono text-[8px] font-bold text-success`,children:[(0,k.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse bg-success`}),` LIVE`]}),e.watcherConfirmed&&(0,k.jsx)(n,{className:`ml-auto h-3 w-3 text-success`,"aria-label":`Filesystem confirmed`}),e.attribution===`correlated`&&!e.watcherConfirmed&&(0,k.jsx)(`span`,{className:`ml-auto font-mono text-[7px] uppercase text-warning`,title:`Correlated from the only active tool`,children:`~ correlated`}),e.attribution===`external`&&(0,k.jsx)(`span`,{className:`ml-auto font-mono text-[7px] uppercase text-destructive`,children:`external`})]}),(0,k.jsx)(`div`,{className:`mt-1 truncate font-mono text-[9px] font-semibold`,title:e.filePath,children:Ne(e.filePath)}),(e.symbol||e.line)&&(0,k.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-1 truncate font-mono text-[8px] text-success`,children:[(0,k.jsx)(a,{className:`h-2.5 w-2.5 shrink-0`}),e.symbol?.name??`line ${e.line}`,e.symbol?.kind&&(0,k.jsxs)(`span`,{className:`text-muted-foreground`,children:[`· `,e.symbol.kind]})]}),e.change&&(0,k.jsxs)(`div`,{className:`mt-1 flex items-center gap-1 font-mono text-[8px]`,children:[(0,k.jsxs)(`span`,{className:`border border-success/40 bg-success/10 px-1 text-success`,children:[`+`,e.change.added]}),(0,k.jsxs)(`span`,{className:`border border-destructive/40 bg-destructive/10 px-1 text-destructive`,children:[`−`,e.change.removed]}),e.durationMs!==void 0&&(0,k.jsxs)(`span`,{className:`ml-auto text-muted-foreground`,children:[e.durationMs,`ms`]})]}),e.summary&&e.summary!==e.toolName&&(0,k.jsx)(`div`,{className:`mt-1 line-clamp-2 text-[8px] leading-3 text-muted-foreground`,children:e.summary})]}),!e.filePath.startsWith(`(`)&&(0,k.jsx)(u,{className:`mt-1 h-3 w-3 shrink-0 text-muted-foreground opacity-0 group-hover:opacity-100`})]})}function Ke({presences:e,onLocate:t}){return e.length===0?null:(0,k.jsxs)(`section`,{className:`pointer-events-auto absolute left-3 top-14 z-20 w-[304px] border bg-card/95 shadow-xl backdrop-blur`,children:[(0,k.jsxs)(`div`,{className:`flex h-9 items-center gap-2 border-b px-3`,children:[(0,k.jsx)(g,{className:`h-3.5 w-3.5 animate-pulse text-success`}),(0,k.jsx)(`h2`,{className:`text-[9px] font-black uppercase tracking-[0.18em]`,children:`Live agent operations`}),(0,k.jsxs)(`span`,{className:`ml-auto bg-success px-1.5 py-0.5 font-mono text-[8px] font-bold text-success-foreground`,children:[e.length,` ONLINE`]})]}),(0,k.jsx)(`div`,{className:`max-h-[330px] overflow-y-auto`,children:e.map(e=>(0,k.jsxs)(`div`,{className:`border-b last:border-b-0`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2 bg-muted/35 px-3 py-1.5`,children:[(0,k.jsx)(`span`,{className:S(`flex h-6 w-6 items-center justify-center font-mono text-[8px] font-black`,je(e.key)),children:Ae(e.agentName)}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsx)(`div`,{className:`truncate text-[9px] font-bold`,children:e.agentName}),(0,k.jsxs)(`div`,{className:`truncate font-mono text-[7px] text-muted-foreground`,children:[`session `,e.sessionId.slice(0,12),` · agent `,e.agentId.slice(0,12)]})]}),(0,k.jsxs)(`span`,{className:`font-mono text-[8px] text-success`,children:[e.operations.length,` op`]})]}),e.operations.map(e=>(0,k.jsx)(I,{activity:e,onLocate:t},e.id??`${e.toolUseId}:${e.filePath}`))]},e.key))})]})}function qe({paused:e,followLive:t,agentFilter:n,agents:r,onTogglePaused:i,onToggleFollow:o,onAgentFilter:s}){return(0,k.jsxs)(`div`,{className:`pointer-events-auto absolute right-3 top-14 z-20 flex h-9 items-center border bg-card/95 shadow-lg backdrop-blur`,children:[(0,k.jsxs)(`button`,{type:`button`,className:S(`flex h-full items-center gap-1.5 border-r px-2.5 text-[8px] font-bold uppercase tracking-wider`,t?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-muted`),onClick:o,title:`Automatically enter the file/function used by the newest visible agent`,children:[(0,k.jsx)(a,{className:`h-3 w-3`}),` Follow`]}),(0,k.jsxs)(`button`,{type:`button`,className:S(`flex h-full items-center gap-1.5 border-r px-2.5 text-[8px] font-bold uppercase tracking-wider`,e?`bg-warning text-warning-foreground`:`text-success hover:bg-success/10`),onClick:i,title:e?`Resume the live telemetry stream`:`Freeze the current telemetry frame`,children:[e?(0,k.jsx)(se,{className:`h-3 w-3`}):(0,k.jsx)(_,{className:`h-3 w-3`}),e?`Resume`:`Live`]}),(0,k.jsxs)(`label`,{className:`flex h-full items-center gap-1.5 px-2 text-[8px] uppercase text-muted-foreground`,children:[`Agent`,(0,k.jsxs)(`select`,{"aria-label":`Filter CodeMap by agent and session`,className:`h-6 max-w-[170px] border bg-background px-1.5 font-mono text-[8px] text-foreground outline-none focus:border-primary`,value:n,onChange:e=>s(e.target.value),children:[(0,k.jsx)(`option`,{value:`all`,children:`ALL AGENTS`}),r.map(e=>(0,k.jsxs)(`option`,{value:e.key,children:[e.agentName,` · `,e.sessionId.slice(0,10)]},e.key))]})]})]})}function Je(){let[e,n]=(0,w.useState)({level:`packages`}),a=T(e),[o,s]=(0,w.useState)(Te),[l,p]=(0,w.useState)(!0),[m,se]=(0,w.useState)(null),[_,v]=(0,w.useState)(null),[y,me]=(0,w.useState)(`layers`),[x,xe]=(0,w.useState)(`smart`),[E,Se]=(0,w.useState)(`all`),[O,De]=(0,w.useState)(``),[j,M]=(0,w.useState)(new Set),[je,Ne]=(0,w.useState)(new Set),[Pe,Ie]=(0,w.useState)(new Set),[Re,ze]=(0,w.useState)(new Set),[P,He]=(0,w.useState)(new Set),[F,Je]=(0,w.useState)(0),[L,Ye]=(0,w.useState)(null),[Xe,Ze]=(0,w.useState)(!1),[R,Qe]=(0,w.useState)(`all`),[z,$e]=(0,w.useState)(null),[et,tt]=(0,w.useState)(null),[nt,rt]=(0,w.useState)(0),B=(0,w.useRef)(new Map),V=(0,w.useRef)(null),H=(0,w.useRef)(null),it=(0,w.useRef)(``),U=ge(),W=(0,w.useMemo)(()=>[...U.activeOperations.values()].flat(),[U.activeOperations]),at=(0,w.useMemo)(()=>[...U.pulses.keys()].map(e=>U.history.get(e)?.[0]).filter(e=>!!e),[U.history,U.pulses]),G=(0,w.useMemo)(()=>{let e=[];for(let t of U.history.values())e.push(...t.slice(0,16));return e.sort((e,t)=>t.timestamp-e.timestamp).slice(0,16)},[U.history]),ot=(0,w.useMemo)(()=>_e([...W,...G]),[W,G]),K=(0,w.useMemo)(()=>{let e=z??W;return R===`all`?e:e.filter(e=>C(e)===R)},[W,R,z]),st=(0,w.useMemo)(()=>{let e=et??G;return R===`all`?e:e.filter(e=>C(e)===R)},[R,et,G]),ct=(0,w.useMemo)(()=>_e(K),[K]),[lt,ut,dt]=ce([]),[ft,pt,mt]=ue([]),{fitView:ht}=ae(),q=(0,w.useCallback)(async(e,t=!1)=>{let n=T(e),r=B.current.get(n);if(r&&!t)return r;let i=await fetch(ve(e));if(!i.ok){let e=await i.json().catch(()=>({error:i.statusText}));throw Error(e.error??`HTTP ${i.status}`)}let a=await i.json();return B.current.set(n,a),Je(e=>e+1),a},[]);(0,w.useEffect)(()=>{let t=!1;return p(!0),se(null),q(e).then(e=>{if(t)return;s(e);let n=V.current;V.current=null,v(n&&e.nodes.some(e=>e.id===n)?n:null),p(!1)}).catch(e=>{t||(se(e instanceof Error?e.message:String(e)),s(Te),p(!1))}),()=>{t=!0}},[a,q]);let J=(0,w.useCallback)((e,t)=>{if(V.current=t??null,T(e)===a){v(t??null),V.current=null;return}n(e)},[a]),Y=(0,w.useCallback)(async e=>{let t=T(e);if(!(B.current.has(t)||P.has(t))){He(e=>new Set(e).add(t));try{await q(e)}finally{He(e=>{let n=new Set(e);return n.delete(t),n})}}},[q,P]);(0,w.useEffect)(()=>{let e=!1;for(let t of W)t.symbol||!t.toolUseId||t.filePath.startsWith(`(`)||q({level:`symbols`,file:t.filePath}).then(n=>{if(e)return;let r=Fe(t,n.nodes);r&&U.resolveActivitySymbol(t.toolUseId,t.filePath,{id:r.id,name:r.label,...r.symbolKind?{kind:r.symbolKind}:{},...r.line?{line:r.line}:{}})}).catch(()=>void 0);return()=>{e=!0}},[W,U.resolveActivitySymbol,q]);let X=(0,w.useMemo)(()=>({nodes:o.nodes,edges:E===`all`?o.edges:o.edges.filter(e=>e.refType===E)}),[o,E]),Z=o.nodes.find(e=>e.id===_),Q=(0,w.useMemo)(()=>Le(X,_,x),[x,X,_]),gt=(0,w.useMemo)(()=>_?be(X,_):new Set,[X,_]),{incomingCounts:_t,outgoingCounts:vt}=(0,w.useMemo)(()=>{let e=new Map,t=new Map;for(let n of X.edges)t.set(n.source,(t.get(n.source)??0)+1),e.set(n.target,(e.get(n.target)??0)+1);return{incomingCounts:e,outgoingCounts:t}},[X]),yt=y===`orbit`?_??void 0:void 0,bt=(0,w.useMemo)(()=>Ce(Q,y,yt),[Q,y,yt]),xt=(0,w.useMemo)(()=>[a,y,y===`orbit`?_??``:``,Q.nodes.map(e=>e.id).join(``),Q.edges.map(e=>`${e.source}>${e.target}:${e.refType}`).join(``)].join(``),[Q,a,y,_]),St=(0,w.useCallback)(e=>{v(e.id),ze(new Set)},[]),Ct=(0,w.useCallback)(e=>{e.kind===`package`&&J({level:`files`,package:e.package??e.label}),e.kind===`file`&&e.file&&J({level:`symbols`,file:e.file,package:e.package})},[J]);(0,w.useEffect)(()=>{let e=new Set(bt.filter(({node:e})=>K.some(t=>N(t,e))).map(({node:e})=>e.id)),t=bt.map(({node:e,position:t})=>{let n=K.filter(t=>N(t,e)),r=n[0]??at.find(t=>N(t,e));return{id:e.id,type:`codemap`,position:t,data:{graphNode:e,selected:e.id===_,dimmed:!!_&&!gt.has(e.id),incoming:_t.get(e.id)??0,outgoing:vt.get(e.id)??0,isActive:!!r,...r?{activityType:r.type}:{},activeOperations:n,onSelect:St,onOpen:Ct,onShowHistory:Ye}}});ut(e=>Ve(e,t));let n=Q.edges.map((t,n)=>{let r=!!_&&(t.source===_||t.target===_),i=e.has(t.source)||e.has(t.target),a=Ee[t.refType]??`hsl(var(--muted-foreground))`;return{id:`edge:${t.source}:${t.target}:${n}`,source:t.source,target:t.target,type:`smoothstep`,animated:i,label:r?`${t.refType}${t.weight>1?` ×${t.weight}`:``}`:void 0,markerEnd:{type:h.ArrowClosed,color:a,width:14,height:14},style:{stroke:a,strokeWidth:i?Math.min(2.5+Math.log2(t.weight+1)*.65,5):r?Math.min(1.25+Math.log2(t.weight+1)*.65,4):1,opacity:i?1:_?r?.88:.08:.52},labelStyle:{fontSize:9,fontFamily:`var(--font-mono)`,fill:`hsl(var(--muted-foreground))`},labelBgStyle:{fill:`hsl(var(--card))`,fillOpacity:.92},labelBgPadding:[4,2],zIndex:i?4:r?2:0,data:{renderKey:`${t.refType}:${t.weight}:${_?r?`focused`:`dimmed`:`idle`}:${i?`live`:`still`}`}}}),r=new Map,i=new Set(K.map(C));for(let e of[...st].sort((e,t)=>e.timestamp-t.timestamp)){let t=C(e);r.set(t,[...r.get(t)??[],e])}let a=[];for(let[e,t]of r){let n=i.has(e),r=t.map(e=>({activity:e,node:Q.nodes.find(t=>N(e,t))})).filter(e=>!!e.node).filter((e,t,n)=>t===0||e.node.id!==n[t-1]?.node.id),o=Me(e);for(let t=1;t<r.length;t++){let i=r[t-1],s=r[t];a.push({id:`trail:${e}:${i.activity.timestamp}:${s.activity.timestamp}`,source:i.node.id,target:s.node.id,type:`smoothstep`,animated:n,label:t===r.length-1?`${Ae(s.activity.agentName??s.activity.agent??`agent`)} TRAIL`:void 0,markerEnd:{type:h.ArrowClosed,color:o,width:13,height:13},style:{stroke:o,strokeWidth:2.5,strokeDasharray:`7 5`,opacity:.9},labelStyle:{fontSize:8,fontWeight:700,fill:o},labelBgStyle:{fill:`hsl(var(--card))`,fillOpacity:.94},labelBgPadding:[4,2],zIndex:6,data:{renderKey:`${o}:${t===r.length-1?`label`:`plain`}:${n?`live`:`still`}`}})}}if(rt(a.length),pt(e=>Ue(e,[...n,...a])),it.current===xt)return;let o=window.setTimeout(()=>{it.current=xt,ht({padding:.2,duration:240,maxZoom:1.25})},20);return()=>window.clearTimeout(o)},[Q,_,K,st,xt,gt,ht,Ct,St,_t,vt,bt,at,pt,ut]),(0,w.useEffect)(()=>{let e=window.setInterval(()=>{U._sweep()},2e3);return()=>window.clearInterval(e)},[U._sweep]);let wt=B.current.get(`packages`)??(e.level===`packages`?o:Te),Tt=(0,w.useCallback)(e=>B.current.get(T({level:`files`,package:e})),[F]),Et=(0,w.useCallback)(e=>B.current.get(T({level:`symbols`,file:e})),[F]),$=(0,w.useCallback)(e=>{let t=e.filePath,n=ke(e.filePath),r=`file:${e.filePath}`;for(let i of B.current.values()){let a=i.nodes.find(t=>t.kind===`file`&&!t.external&&Oe(t.file,e.filePath));if(a){t=a.file??t,n=a.package??n,r=a.id;break}}if(e.symbol){J({level:`symbols`,file:t,package:n},e.symbol.id);return}J({level:`files`,package:n},r)},[J]);(0,w.useEffect)(()=>{if(!Xe||z)return;let e=[...K].filter(e=>!e.filePath.startsWith(`(`)).sort((e,t)=>t.timestamp-e.timestamp)[0];if(!e)return;let t=`${e.id??e.toolUseId}:${e.filePath}:${e.symbol?.id??`file`}`;H.current!==t&&(H.current=t,$(e))},[K,Xe,$,z]);let Dt=(0,w.useCallback)(()=>{if(z){$e(null),tt(null);return}$e([...W]),tt([...G])},[W,z,G]),Ot=(0,w.useCallback)(e=>{let t=e.package??e.label,n=!j.has(t);M(e=>{let r=new Set(e);return n?r.add(t):r.delete(t),r}),n&&Y({level:`files`,package:t}).then(()=>{let e=B.current.get(T({level:`files`,package:t})),n=e?we(e.nodes):void 0;n?.directories.length===1&&n.directories[0]&&Ne(e=>new Set(e).add(`${t}:${n.directories[0].path}`))}).catch(()=>void 0)},[Y,j]),kt=(0,w.useCallback)(e=>{if(!e.file)return;let t=!Pe.has(e.file);Ie(n=>{let r=new Set(n);return t?r.add(e.file):r.delete(e.file),r}),t&&Y({level:`symbols`,file:e.file,package:e.package}).catch(()=>void 0)},[Y,Pe]),At=(0,w.useCallback)(e=>{Ne(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),jt=(0,w.useCallback)(e=>{J({level:`files`,package:e.package??`(root)`},e.id)},[J]),Mt=(0,w.useCallback)(e=>{e.file&&J({level:`symbols`,file:e.file,package:e.package},e.id)},[J]),Nt=(0,w.useMemo)(()=>{let e=O.trim().toLocaleLowerCase();if(!e)return[];let t=new Map;for(let n of B.current.values())for(let r of n.nodes)`${r.label} ${r.file??``} ${r.signature??``} ${r.package??``}`.toLocaleLowerCase().includes(e)&&t.set(r.id,r);return[...t.values()].sort((e,t)=>e.kind.localeCompare(t.kind)||e.label.localeCompare(t.label)).slice(0,80)},[O,F]),Pt=(0,w.useCallback)(e=>{e.kind===`package`?J({level:`packages`},e.id):e.kind===`file`?J({level:`files`,package:e.package??`(root)`},e.id):e.file&&J({level:`symbols`,file:e.file,package:e.package},e.id)},[J]),{incoming:Ft,outgoing:It}=(0,w.useMemo)(()=>({incoming:Z?ye(X,Z.id,`incoming`):[],outgoing:Z?ye(X,Z.id,`outgoing`):[]}),[X,Z]),{edgeWeight:Lt,connectedNodeCount:Rt}=(0,w.useMemo)(()=>{let e=0,t=new Set;for(let n of X.edges)e+=n.weight,t.add(n.source),t.add(n.target);return{edgeWeight:e,connectedNodeCount:t.size}},[X]),zt=Z?K.filter(e=>N(e,Z)):[],Bt=L?U.getActivityForFile(L):[];return(0,k.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-background`,children:[(0,k.jsxs)(`header`,{className:`flex h-[62px] shrink-0 items-center gap-4 border-b bg-card px-4`,children:[(0,k.jsxs)(`div`,{className:`flex min-w-[220px] items-center gap-3`,children:[(0,k.jsx)(`span`,{className:`flex h-9 w-9 items-center justify-center border border-primary bg-primary/10 text-primary`,children:(0,k.jsx)(i,{className:`h-4 w-4`})}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`h1`,{className:`font-display text-sm font-semibold tracking-tight`,children:`Code Atlas`}),(0,k.jsx)(`p`,{className:`text-[9px] uppercase tracking-[0.18em] text-muted-foreground`,children:`Architecture intelligence`})]})]}),(0,k.jsxs)(`nav`,{className:`flex min-w-0 flex-1 items-center gap-1 font-mono text-[10px]`,"aria-label":`Code map breadcrumb`,children:[e.level!==`packages`&&(0,k.jsx)(`button`,{type:`button`,className:`mr-1 flex h-7 w-7 items-center justify-center border text-muted-foreground hover:bg-muted`,onClick:()=>{e.level===`symbols`?J({level:`files`,package:e.package??`(root)`}):J({level:`packages`})},"aria-label":`Back`,children:(0,k.jsx)(ee,{className:`h-3.5 w-3.5`})}),(0,k.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1.5 px-1.5 py-1 text-muted-foreground hover:text-foreground`,onClick:()=>J({level:`packages`}),children:[(0,k.jsx)(ne,{className:`h-3 w-3`}),` workspace`]}),e.level!==`packages`&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(b,{className:`h-3 w-3 text-muted-foreground`}),(0,k.jsx)(`button`,{type:`button`,className:`max-w-[220px] truncate px-1.5 py-1 hover:text-primary`,onClick:()=>J({level:`files`,package:e.package??`(root)`}),children:e.package??`(root)`})]}),e.level===`symbols`&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(b,{className:`h-3 w-3 text-muted-foreground`}),(0,k.jsx)(`span`,{className:`truncate px-1.5 py-1 text-primary`,children:D({id:``,label:e.file,kind:`file`,file:e.file,package:e.package})})]})]}),(0,k.jsxs)(`div`,{className:`hidden items-center gap-5 xl:flex`,children:[(0,k.jsxs)(`div`,{className:S(`flex h-8 items-center gap-2 border px-2.5`,ct.length>0?`border-success/50 bg-success/10 text-success`:`text-muted-foreground`),children:[(0,k.jsx)(g,{className:S(`h-3 w-3`,ct.length>0&&`animate-pulse`)}),(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`div`,{className:`font-mono text-[10px] font-bold`,children:[ct.length,` LIVE`]}),(0,k.jsx)(`div`,{className:`text-[7px] uppercase tracking-wider`,children:`agents`})]})]}),(0,k.jsxs)(`div`,{className:`text-right`,children:[(0,k.jsx)(`div`,{className:`font-mono text-sm font-semibold`,children:o.nodes.length}),(0,k.jsx)(`div`,{className:`text-[8px] uppercase tracking-wider text-muted-foreground`,children:`nodes`})]}),(0,k.jsxs)(`div`,{className:`text-right`,children:[(0,k.jsx)(`div`,{className:`font-mono text-sm font-semibold`,children:o.edges.length}),(0,k.jsx)(`div`,{className:`text-[8px] uppercase tracking-wider text-muted-foreground`,children:`links`})]}),(0,k.jsxs)(`div`,{className:`text-right`,children:[(0,k.jsx)(`div`,{className:`font-mono text-sm font-semibold`,children:Lt}),(0,k.jsx)(`div`,{className:`text-[8px] uppercase tracking-wider text-muted-foreground`,children:`references`})]}),(0,k.jsxs)(`div`,{className:`text-right`,children:[(0,k.jsx)(`div`,{className:`font-mono text-sm font-semibold`,children:Rt}),(0,k.jsx)(`div`,{className:`text-[8px] uppercase tracking-wider text-muted-foreground`,children:`connected`})]})]})]}),(0,k.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,k.jsxs)(`aside`,{className:`flex w-[286px] shrink-0 flex-col border-r bg-card/70`,children:[(0,k.jsxs)(`div`,{className:`border-b p-3`,children:[(0,k.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,k.jsx)(`h2`,{className:`text-[10px] font-bold uppercase tracking-[0.18em]`,children:`Code tree`}),(0,k.jsxs)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:[wt.nodes.length,` roots`]})]}),(0,k.jsxs)(`label`,{className:`flex h-8 items-center gap-2 border bg-background px-2 focus-within:border-primary`,children:[(0,k.jsx)(fe,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,k.jsx)(`input`,{className:`min-w-0 flex-1 bg-transparent font-mono text-[10px] outline-none placeholder:text-muted-foreground`,value:O,onChange:e=>De(e.target.value),placeholder:`Find package, file, symbol…`}),O&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>De(``),"aria-label":`Clear search`,children:(0,k.jsx)(le,{className:`h-3 w-3 text-muted-foreground`})})]})]}),(0,k.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-2`,children:O.trim()?(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`div`,{className:`px-3 pb-2 text-[9px] text-muted-foreground`,children:[Nt.length,` loaded-map results`]}),Nt.map(e=>{let t=A[e.kind].icon;return(0,k.jsxs)(`button`,{type:`button`,className:`flex min-h-8 w-full items-center gap-2 px-3 py-1 text-left hover:bg-muted`,onClick:()=>Pt(e),children:[(0,k.jsx)(t,{className:S(`h-3.5 w-3.5 shrink-0`,e.kind===`package`?`text-primary`:e.kind===`file`?`text-info`:`text-success`)}),(0,k.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,k.jsx)(`span`,{className:`block truncate font-mono text-[10px]`,children:e.label}),(0,k.jsx)(`span`,{className:`block truncate text-[8px] text-muted-foreground`,children:e.file??e.package??e.symbolKind})]}),(0,k.jsx)(`span`,{className:`text-[8px] uppercase text-muted-foreground`,children:e.kind.slice(0,3)})]},e.id)}),Nt.length===0&&(0,k.jsxs)(`p`,{className:`px-3 py-8 text-center text-[10px] text-muted-foreground`,children:[`No match in loaded branches.`,(0,k.jsx)(`br`,{}),`Expand a package to search its files.`]})]}):wt.nodes.map(e=>{let n=e.package??e.label,i=j.has(n),a=T({level:`files`,package:n}),o=Tt(n),s=o?we(o.nodes):void 0;return(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`div`,{className:S(`group flex h-8 items-center px-2 hover:bg-muted`,_===e.id&&`bg-primary/10 text-primary`),children:[(0,k.jsx)(`button`,{type:`button`,className:`flex h-6 w-5 items-center justify-center text-muted-foreground`,onClick:()=>Ot(e),"aria-label":`${i?`Collapse`:`Expand`} ${n}`,children:P.has(a)?(0,k.jsx)(t,{className:`h-3 w-3 animate-spin`}):i?(0,k.jsx)(r,{className:`h-3 w-3`}):(0,k.jsx)(b,{className:`h-3 w-3`})}),(0,k.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-2 text-left`,onClick:()=>J({level:`packages`},e.id),onDoubleClick:()=>J({level:`files`,package:n}),children:[(0,k.jsx)(he,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,k.jsx)(`span`,{className:`truncate font-mono text-[10px] font-semibold`,children:e.label}),(0,k.jsx)(`span`,{className:`ml-auto text-[9px] text-muted-foreground`,children:e.fileCount??0})]}),(0,k.jsx)(`button`,{type:`button`,className:`ml-1 hidden h-5 w-5 items-center justify-center text-muted-foreground hover:text-foreground group-hover:flex`,onClick:()=>J({level:`files`,package:n}),title:`Open file map`,"aria-label":`Open ${n} map`,children:(0,k.jsx)(u,{className:`h-3 w-3`})})]}),i&&s&&(0,k.jsx)(We,{directory:s,packageName:n,depth:1,expandedDirectories:je,expandedFiles:Pe,loadingBranches:P,graphForFile:Et,onToggleDirectory:At,onToggleFile:kt,onSelectFile:jt,onOpenFile:Ct,onSelectSymbol:Mt,selectedId:_,activeOperations:K})]},e.id)})}),(0,k.jsxs)(`div`,{className:`border-t px-3 py-2 text-[9px] leading-relaxed text-muted-foreground`,children:[`Click to focus · double-click to enter`,(0,k.jsx)(`br`,{}),`Branches stay open while the map changes`]})]}),(0,k.jsxs)(`main`,{className:`relative min-w-0 flex-1 bg-[radial-gradient(circle_at_50%_0%,hsl(var(--primary)/0.055),transparent_38%)]`,children:[(0,k.jsxs)(`div`,{className:`absolute left-3 right-3 top-3 z-10 flex items-center gap-2 pointer-events-none`,children:[(0,k.jsxs)(`div`,{className:`pointer-events-auto flex border bg-card/95 shadow-md backdrop-blur`,children:[(0,k.jsxs)(`button`,{type:`button`,className:S(`flex h-8 items-center gap-1.5 border-r px-2.5 text-[9px] font-semibold uppercase tracking-wider`,y===`layers`?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-muted`),onClick:()=>me(`layers`),children:[(0,k.jsx)(f,{className:`h-3 w-3`}),` Layers`]}),(0,k.jsxs)(`button`,{type:`button`,className:S(`flex h-8 items-center gap-1.5 px-2.5 text-[9px] font-semibold uppercase tracking-wider`,y===`orbit`?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-muted`),onClick:()=>me(`orbit`),children:[(0,k.jsx)(c,{className:`h-3 w-3`}),` Relations`]})]}),(0,k.jsxs)(`div`,{className:`pointer-events-auto flex border bg-card/95 shadow-md backdrop-blur`,children:[(0,k.jsxs)(`button`,{type:`button`,className:S(`h-8 border-r px-2.5 font-mono text-[9px] font-bold`,x===`smart`?`bg-success text-success-foreground`:`text-muted-foreground hover:bg-muted`),onClick:()=>xe(`smart`),title:`Keep the full tree, show the strongest relations and selected neighbourhood`,children:[`SMART `,Q.nodes.length,`/`,o.nodes.length]}),(0,k.jsx)(`button`,{type:`button`,className:S(`h-8 px-2.5 font-mono text-[9px] font-bold`,x===`all`?`bg-foreground text-background`:`text-muted-foreground hover:bg-muted`),onClick:()=>xe(`all`),title:`Render every node and relation in this scope`,children:`ALL`})]}),(0,k.jsx)(`div`,{className:`pointer-events-auto ml-auto flex max-w-[60%] overflow-x-auto border bg-card/95 shadow-md backdrop-blur`,children:[`all`,`import`,`call`,`type_ref`,`inherit`,`implement`].map(e=>(0,k.jsx)(`button`,{type:`button`,className:S(`h-8 whitespace-nowrap border-r px-2.5 font-mono text-[9px] last:border-r-0`,E===e?`bg-foreground text-background`:`text-muted-foreground hover:bg-muted`),onClick:()=>Se(e),children:e===`all`?`ALL LINKS`:e.replace(`_`,` `).toUpperCase()},e))})]}),(0,k.jsx)(Ke,{presences:ct,onLocate:$}),(0,k.jsx)(qe,{paused:z!==null,followLive:Xe,agentFilter:R,agents:ot,onTogglePaused:Dt,onToggleFollow:()=>{H.current=null,Ze(e=>!e)},onAgentFilter:e=>{H.current=null,Qe(e)}}),l&&(0,k.jsxs)(`div`,{className:`absolute inset-0 z-20 flex flex-col items-center justify-center gap-3 bg-background/75 backdrop-blur-sm`,children:[(0,k.jsx)(t,{className:`h-7 w-7 animate-spin text-primary`}),(0,k.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-widest text-muted-foreground`,children:`Mapping relationships`})]}),m&&!l&&(0,k.jsxs)(`div`,{className:`absolute inset-0 z-20 flex flex-col items-center justify-center gap-3 p-8 text-center`,children:[(0,k.jsx)(i,{className:`h-10 w-10 text-destructive`}),(0,k.jsx)(`p`,{className:`font-mono text-sm text-destructive`,children:m}),(0,k.jsxs)(`p`,{className:`max-w-md text-xs text-muted-foreground`,children:[`The map needs a codebase index. Run`,` `,(0,k.jsx)(`code`,{className:`border bg-muted px-1.5 py-0.5`,children:`codebase-index`}),` once, then reopen this view.`]})]}),!l&&!m&&o.nodes.length===0&&(0,k.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-2 text-muted-foreground`,children:[(0,k.jsx)(i,{className:`h-8 w-8 opacity-40`}),(0,k.jsx)(`p`,{className:`text-xs`,children:`No indexed nodes at this level.`})]}),!l&&!m&&o.nodes.length>1&&o.edges.length===0&&(0,k.jsxs)(`div`,{className:`pointer-events-none absolute left-1/2 top-14 z-10 -translate-x-1/2 border border-warning/40 bg-warning/10 px-3 py-2 text-center shadow backdrop-blur`,children:[(0,k.jsx)(`div`,{className:`font-mono text-[9px] font-bold uppercase tracking-wider text-warning`,children:`No resolved relations in this scope`}),(0,k.jsx)(`div`,{className:`mt-0.5 text-[8px] text-muted-foreground`,children:`The upgraded index will rebuild and resolve call/import/type links automatically.`})]}),!m&&o.nodes.length>0&&(0,k.jsxs)(ie,{nodes:lt,edges:ft,onNodesChange:dt,onEdgesChange:mt,nodeTypes:Be,nodesConnectable:!1,nodesDraggable:!1,edgesFocusable:!1,elementsSelectable:!1,onlyRenderVisibleElements:Q.nodes.length>80,minZoom:.08,maxZoom:2.2,proOptions:{hideAttribution:!0},children:[(0,k.jsx)(pe,{variant:oe.Dots,gap:22,size:1,color:`hsl(var(--muted-foreground))`,className:`!opacity-25`}),(0,k.jsx)(te,{position:`bottom-left`,showInteractive:!1,className:`!border !border-border !bg-card !shadow-md [&>button]:!border-border [&>button]:!bg-card [&>button]:!fill-foreground`}),(0,k.jsx)(re,{position:`bottom-right`,pannable:!0,zoomable:!0,className:`!h-[112px] !w-[180px] !border !border-border !bg-card !shadow-md`,maskColor:`hsl(var(--background) / 0.72)`,nodeColor:e=>{let t=e.data?.graphNode.kind;return t===`package`?`hsl(var(--primary))`:t===`file`?`hsl(var(--info))`:`hsl(var(--success))`}})]}),(0,k.jsxs)(`div`,{className:`pointer-events-none absolute bottom-3 left-1/2 z-10 flex -translate-x-1/2 items-center gap-3 border bg-card/90 px-3 py-1.5 font-mono text-[8px] text-muted-foreground shadow backdrop-blur`,children:[Object.entries(Ee).map(([e,t])=>(0,k.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,k.jsx)(`span`,{className:`h-0.5 w-3`,style:{backgroundColor:t}}),e.replace(`_`,` `)]},e)),(0,k.jsxs)(`span`,{className:`flex items-center gap-1 text-primary`,"data-testid":`agent-trail-count`,children:[(0,k.jsx)(`span`,{className:`w-4 border-t-2 border-dashed border-primary`}),`agent trail`,nt>0?` ×${nt}`:``]})]})]}),(0,k.jsxs)(`aside`,{className:`flex w-[326px] shrink-0 flex-col border-l bg-card/80`,children:[(0,k.jsxs)(`div`,{className:`flex h-10 items-center justify-between border-b px-3`,children:[(0,k.jsx)(`h2`,{className:`text-[10px] font-bold uppercase tracking-[0.18em]`,children:`Relation inspector`}),Z&&(0,k.jsx)(`button`,{type:`button`,className:`text-muted-foreground hover:text-foreground`,onClick:()=>v(null),"aria-label":`Clear selection`,children:(0,k.jsx)(le,{className:`h-3.5 w-3.5`})})]}),Z?(0,k.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[(0,k.jsxs)(`div`,{className:`border-b bg-muted/25 p-3`,children:[(0,k.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,k.jsx)(`span`,{className:S(`flex h-8 w-8 items-center justify-center border`,A[Z.kind].iconStyle),children:(()=>{let e=A[Z.kind].icon;return(0,k.jsx)(e,{className:`h-4 w-4`})})()}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsxs)(`div`,{className:`text-[8px] font-bold uppercase tracking-[0.18em] text-muted-foreground`,children:[Z.external?`external `:``,Z.kind]}),(0,k.jsx)(`div`,{className:`truncate font-mono text-xs font-semibold`,title:Z.label,children:Z.label})]})]}),(0,k.jsx)(`div`,{className:`break-all font-mono text-[9px] leading-relaxed text-muted-foreground`,children:Z.file?D(Z):Z.package}),Z.signature&&(0,k.jsx)(`pre`,{className:`mt-3 overflow-x-auto border bg-background p-2 font-mono text-[9px] leading-relaxed text-foreground`,children:Z.signature}),(0,k.jsxs)(`div`,{className:`mt-3 grid grid-cols-3 border`,children:[(0,k.jsxs)(`div`,{className:`border-r p-2 text-center`,children:[(0,k.jsx)(`div`,{className:`font-mono text-sm font-semibold text-info`,children:Ft.length}),(0,k.jsx)(`div`,{className:`text-[8px] uppercase text-muted-foreground`,children:`incoming`})]}),(0,k.jsxs)(`div`,{className:`border-r p-2 text-center`,children:[(0,k.jsx)(`div`,{className:`font-mono text-sm font-semibold text-primary`,children:It.length}),(0,k.jsx)(`div`,{className:`text-[8px] uppercase text-muted-foreground`,children:`outgoing`})]}),(0,k.jsxs)(`div`,{className:`p-2 text-center`,children:[(0,k.jsx)(`div`,{className:`font-mono text-sm font-semibold`,children:Z.symbolCount??Z.fileCount??Z.line??`—`}),(0,k.jsx)(`div`,{className:`text-[8px] uppercase text-muted-foreground`,children:Z.kind===`package`?`files`:Z.kind===`file`?`symbols`:`line`})]})]}),(0,k.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[Z.kind!==`symbol`&&(0,k.jsxs)(`button`,{type:`button`,className:`flex h-7 flex-1 items-center justify-center gap-1.5 border bg-foreground text-[9px] font-semibold uppercase tracking-wider text-background hover:opacity-90`,onClick:()=>Ct(Z),children:[(0,k.jsx)(u,{className:`h-3 w-3`}),` Open`,` `,Z.kind===`package`?`files`:`symbols`]}),Z.file&&(0,k.jsxs)(`button`,{type:`button`,className:`flex h-7 items-center justify-center gap-1.5 border px-2 text-[9px] uppercase text-muted-foreground hover:bg-muted`,onClick:()=>Ye(Z.file),children:[(0,k.jsx)(d,{className:`h-3 w-3`}),` Activity`]})]})]}),zt.length>0&&(0,k.jsxs)(`section`,{className:`border-b bg-success/5 py-2`,children:[(0,k.jsxs)(`div`,{className:`mb-1 flex items-center gap-2 px-3`,children:[(0,k.jsx)(g,{className:`h-3 w-3 animate-pulse text-success`}),(0,k.jsx)(`h3`,{className:`text-[9px] font-bold uppercase tracking-[0.16em]`,children:`Agents on this node`}),(0,k.jsx)(`span`,{className:`ml-auto font-mono text-[9px] text-success`,children:zt.length})]}),zt.map(e=>(0,k.jsx)(I,{activity:e,onLocate:$,showAgent:!0},e.id??`${e.toolUseId}:${e.filePath}`))]}),(0,k.jsx)(Ge,{title:`Incoming`,subtitle:`Who depends on this`,items:Ft,graph:X,selectedId:Z.id,expanded:Re,onToggle:e=>ze(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),onSelect:St}),(0,k.jsx)(Ge,{title:`Outgoing`,subtitle:`What this depends on`,items:It,graph:X,selectedId:Z.id,expanded:Re,onToggle:e=>ze(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),onSelect:St})]}):(0,k.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[K.length>0&&(0,k.jsxs)(`section`,{className:`border-b`,children:[(0,k.jsxs)(`div`,{className:`flex h-9 items-center gap-2 border-b bg-success/5 px-3`,children:[(0,k.jsx)(g,{className:`h-3 w-3 animate-pulse text-success`}),(0,k.jsx)(`h3`,{className:`text-[9px] font-bold uppercase tracking-[0.16em]`,children:`Active now`}),(0,k.jsx)(`span`,{className:`ml-auto font-mono text-[9px] text-success`,children:K.length})]}),K.map(e=>(0,k.jsx)(I,{activity:e,onLocate:$,showAgent:!0},e.id??`${e.toolUseId}:${e.filePath}`))]}),(0,k.jsxs)(`section`,{children:[(0,k.jsxs)(`div`,{className:`flex h-9 items-center gap-2 border-b px-3`,children:[(0,k.jsx)(d,{className:`h-3 w-3 text-muted-foreground`}),(0,k.jsx)(`h3`,{className:`text-[9px] font-bold uppercase tracking-[0.16em]`,children:`Event stream`}),(0,k.jsxs)(`span`,{className:`ml-auto font-mono text-[8px] text-muted-foreground`,children:[U.totalCount,` total`]})]}),st.length>0?st.map((e,t)=>(0,k.jsx)(I,{activity:e,onLocate:$,showAgent:!0},e.id??`${e.timestamp}:${t}`)):(0,k.jsxs)(`div`,{className:`flex flex-col items-center justify-center px-7 py-16 text-center`,children:[(0,k.jsx)(`span`,{className:`mb-4 flex h-12 w-12 items-center justify-center border bg-muted text-muted-foreground`,children:(0,k.jsx)(de,{className:`h-5 w-5`})}),(0,k.jsx)(`h3`,{className:`text-xs font-semibold`,children:`Select a node or wait for an agent`}),(0,k.jsx)(`p`,{className:`mt-2 text-[10px] leading-relaxed text-muted-foreground`,children:`Relations appear on selection. Tool calls and external filesystem touches stream here live.`})]})]})]})]})]}),L&&(0,k.jsxs)(`div`,{className:`absolute right-0 top-0 z-50 flex h-full w-[390px] max-w-[90%] flex-col border-l bg-card shadow-2xl`,children:[(0,k.jsxs)(`div`,{className:`flex h-12 items-center justify-between border-b px-4`,children:[(0,k.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,k.jsx)(d,{className:`h-4 w-4 shrink-0 text-warning`}),(0,k.jsx)(`span`,{className:`truncate font-mono text-[11px] font-semibold`,title:L,children:L})]}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>Ye(null),className:`flex h-7 w-7 items-center justify-center border text-muted-foreground hover:bg-muted`,"aria-label":`Close activity`,children:(0,k.jsx)(le,{className:`h-3.5 w-3.5`})})]}),(0,k.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-3`,children:Bt.length===0?(0,k.jsx)(`p`,{className:`py-12 text-center text-[10px] text-muted-foreground`,children:`No activity recorded for this file yet.`}):Bt.map((e,t)=>(0,k.jsxs)(`div`,{className:`mb-1 flex items-start gap-2 border p-2 text-[10px]`,children:[(0,k.jsx)(`span`,{className:S(`border px-1.5 py-0.5 font-mono text-[8px] font-bold uppercase`,e.type===`delete`?`border-destructive/40 text-destructive`:e.type===`read`?`border-info/40 text-info`:`border-warning/40 text-warning`),children:e.type}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsx)(`div`,{className:`font-mono text-[9px] text-muted-foreground`,children:new Date(e.timestamp).toLocaleTimeString()}),e.toolName&&(0,k.jsxs)(`div`,{className:`mt-1`,children:[`via `,e.toolName]}),e.agent&&(0,k.jsx)(`div`,{className:`text-muted-foreground`,children:e.agent}),e.summary&&(0,k.jsx)(`div`,{className:`mt-1 text-muted-foreground`,children:e.summary}),e.change&&(0,k.jsxs)(`div`,{className:`mt-1 flex items-center gap-1 font-mono text-[8px]`,children:[(0,k.jsxs)(`span`,{className:`border border-success/40 bg-success/10 px-1 text-success`,children:[`+`,e.change.added]}),(0,k.jsxs)(`span`,{className:`border border-destructive/40 bg-destructive/10 px-1 text-destructive`,children:[`−`,e.change.removed]}),e.change.before&&(0,k.jsx)(`span`,{className:`ml-1 truncate text-destructive/80`,title:e.change.before,children:e.change.before}),e.change.after&&(0,k.jsxs)(`span`,{className:`truncate text-success/80`,title:e.change.after,children:[`→ `,e.change.after]})]}),(0,k.jsxs)(`div`,{className:`mt-1 flex gap-2 font-mono text-[8px] uppercase text-muted-foreground`,children:[(0,k.jsx)(`span`,{children:e.status??`observed`}),(0,k.jsx)(`span`,{children:e.source??`legacy`}),e.durationMs!==void 0&&(0,k.jsxs)(`span`,{children:[e.durationMs,`ms`]}),e.watcherConfirmed&&(0,k.jsx)(`span`,{className:`text-success`,children:`fs verified`})]})]})]},`${e.timestamp}-${t}`))}),(0,k.jsxs)(`div`,{className:`border-t px-4 py-2 font-mono text-[9px] text-muted-foreground`,children:[Bt.length,` events · newest first`]})]})]})}function L(){return(0,k.jsx)(me,{children:(0,k.jsx)(Je,{})})}export{L as CodeMap};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{$r as t,$t as n,Ai as r,Bt as i,Ci as a,Ct as o,Ft as s,Kt as c,Mt as l,Ni as u,Pn as d,Vt as f,Wi as p,Yr as m,Yt as h,Zi as g,Zt as _,_i as v,aa as y,ai as b,bt as x,cn as S,en as C,gi as w,ht as ee,kn as te,ln as T,mn as ne,or as re,ot as E,pr as ie,qr as D,qt as ae,rn as O,ti as oe,tt as se,ui as ce,wi as le,wn as ue,wt as de}from"./vendor-Di1mdAi5.js";import{t as fe}from"./ws-client-BWO_PH_X.js";import{t as k}from"./utils-C4qVQ63O.js";import{t as pe}from"./session-store-B8icONBU.js";import{b as me,j as he,u as ge}from"./stores-JSLvWOQY.js";import{n as _e,t as ve}from"./ModelPicker-Cwa4UKNc.js";import{t as ye}from"./pagination-Ktuov5iD.js";import{S as be,g as xe}from"./index-Du90vd1u.js";var A=e(y(),1);function Se(e){let t=he(e=>e.wsUrl),n=he(e=>e.provider),r=he(e=>e.model),[i,a]=(0,A.useState)([]),[o,s]=(0,A.useState)([]),[c,l]=(0,A.useState)({}),[u,d]=(0,A.useState)(``),[f,p]=(0,A.useState)(``);return(0,A.useEffect)(()=>{let e=fe(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,A.useEffect)(()=>{e&&fe(t).send({type:`kanban.meta`})},[e,t]),{tools:i,skills:o,fallbackProfiles:c,sessionProvider:u||n,sessionModel:f||r}}function j(e,t=!0){(0,A.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 Ce=4320*60*1e3,we=new Set([`completed`,`archived`]);function Te(e,t){let n=B(t.now);if(n===null)throw TypeError(`Kanban audit requires a valid current time`);let r=P(t.liveAgentIdentities),i=N(e,t.defaultReviewStaleAfterMs??Ce),a=ke(e),o=[];for(let s of e.tasks)we.has(s.status)||(Ee(o,s,t.requireDueDate===!0),M(o,s,n,r),De(o,s,n,i),a.length>1&&Oe(o,s,a));return o.sort(Pe),{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 Ee(e,t,n){L(t.description)||V(e,t,`missing-description`,`warning`,`Add a description`),Me(t).length===0&&V(e,t,`missing-assignee`,`warning`,`Assign an owner`),n&&!L(t.dueDate)&&V(e,t,`missing-due-date`,`warning`,`Set a due date`),!R(t.labels)&&!R(t.tags)&&V(e,t,`missing-labels`,`warning`,`Add labels or tags`),!R(t.childTaskIds)&&!R(t.subtasks)&&V(e,t,`missing-subtasks`,`warning`,`Define subtasks`),R(t.successCriteria)||V(e,t,`missing-success-criteria`,`warning`,`Add success criteria`)}function M(e,t,n,r){let i=t.assignment;if(!(t.status===`in_progress`||i?.status===`running`))return;let a=Me(t);if(!i||a.length===0||!L(i.leaseId)||!L(i.leaseExpiresAt)){V(e,t,`abandoned-running-task`,`error`,`Running without a complete assignment lease`);return}let o=B(i.leaseExpiresAt);if(o===null||o<=n){V(e,t,`stale-running-task`,`error`,`Assignment lease is expired`);return}a.some(e=>r.has(F(e)))||V(e,t,`abandoned-running-task`,`error`,`Assigned agent is not live`)}function De(e,t,n,r){if(t.status!==`review`)return;let i=je(t,`review`)??B(t.updatedAt);i===null||n-i<=r||V(e,t,`stale-review`,`warning`,`Waiting in review for ${Math.max(1,Math.floor((n-i)/(3600*1e3)))}h`)}function Oe(e,t,n){let r=Ae(t);if(r.length<2)return;let i=new Map(n.map((e,t)=>[F(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(F(a.state)),c=i.get(F(o.state));if(!(s===void 0||c===void 0||Math.abs(c-s)<=1)){V(e,t,`skipped-lifecycle-state`,`error`,`Lifecycle skipped ${a.state} → ${o.state}`);return}}}function ke(e){let t=[e.lifecycle,e.lifecyclePolicy,e.managedLifecycle];for(let e of t){let t=Ne(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=>L(e));if(e.length===5)return e}for(let e of[n.states,n.statuses,n.order,n.managedStatuses]){let t=Ne(e);if(t.length>1)return t}}return[]}function N(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(z(t.staleReviewAfterMs))return t.staleReviewAfterMs;if(z(t.reviewStaleAfterMs))return t.reviewStaleAfterMs;if(z(t.reviewStaleHours))return t.reviewStaleHours*60*60*1e3}return t}function Ae(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`&&L(e)){n.push({state:e.trim(),at:null});continue}if(!e||typeof e!=`object`)continue;let t=e,r=I(t.status,t.state,t.toStatus,t.to,t.columnId);r&&n.push({state:r,at:B(t.at??t.ts??t.timestamp??t.changedAt??t.createdAt)})}return n}function je(e,t){let n=null;for(let r of Ae(e))F(r.state)!==F(t)||r.at===null||(n=n===null?r.at:Math.max(n,r.at));return n}function Me(e){let t=e.assignment;return[e.assignee,e.assignedAgent,t?.agentId,t?.subagentId,t?.name].filter(L)}function Ne(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(L(n)){t.push(n.trim());continue}if(!n||typeof n!=`object`)continue;let e=n,r=I(e.id,e.status,e.state,e.name);r&&t.push(r)}return t}function P(e){let t=new Set;if(!e)return t;for(let n of e)L(n)&&t.add(F(n));return t}function F(e){return e.trim().toLocaleLowerCase()}function I(...e){for(let t of e)if(L(t))return t.trim();return null}function L(e){return typeof e==`string`&&e.trim().length>0}function R(e){return Array.isArray(e)&&e.length>0}function z(e){return typeof e==`number`&&Number.isFinite(e)&&e>0}function B(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 V(e,t,n,r,i){e.push({id:`${t.id}:${n}`,taskId:t.id,taskTitle:t.title,code:n,severity:r,message:i})}function Pe(e,t){let n=Fe(e.severity)-Fe(t.severity);if(n!==0)return n;let r=e.taskTitle.localeCompare(t.taskTitle);return r===0?e.message.localeCompare(t.message):r}function Fe(e){return e===`error`?0:1}var Ie=[`id`,`name`,`type`];function H(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 Ie){let n=t[e];if(typeof n==`string`&&n.trim())return n.trim()}}var U=se();function W({options:e,selected:t,onChange:n,placeholder:r,emptyLabel:i}){let[o,s]=(0,A.useState)(!1),[c,l]=(0,A.useState)(``),u=(0,A.useRef)(null);(0,A.useEffect)(()=>{if(!o)return;let e=e=>{u.current&&!u.current.contains(e.target)&&s(!1)};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[o]);let d=(0,A.useMemo)(()=>{let t=new Map(e.map(e=>[e.value,e.label]));return e=>t.get(e)??e},[e]),f=(0,A.useMemo)(()=>{let t=c.trim().toLowerCase();return(t?e.filter(e=>`${e.value} ${e.label} ${e.tag??``}`.toLowerCase().includes(t)):e).slice(0,80)},[e,c]),p=e=>{n(t.includes(e)?t.filter(t=>t!==e):[...t,e])};return(0,U.jsxs)(`div`,{ref:u,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:d(e)}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>p(e),className:`text-muted-foreground hover:text-destructive`,"aria-label":`Remove ${d(e)}`,children:(0,U.jsx)(E,{size:11})})]},e))}),(0,U.jsxs)(`button`,{type:`button`,onClick:()=>s(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)(S,{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)(a,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`})]}),o&&(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:c,onChange:e=>l(e.target.value),placeholder:`Filter…`,className:`min-w-0 flex-1 bg-transparent text-xs outline-none placeholder:text-muted-foreground`}),c&&(0,U.jsx)(`button`,{type:`button`,onClick:()=>l(``),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:[f.map(e=>{let n=t.includes(e.value);return(0,U.jsxs)(`button`,{type:`button`,onClick:()=>p(e.value),className:k(`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)(le,{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)}),f.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 Le({audit:e,onSelectTask:t}){let[n,r]=(0,A.useState)(!0),i=(0,A.useId)();if((0,A.useEffect)(()=>{e.issues.length>0&&r(!0)},[e.issues.length]),e.issues.length===0)return null;let o=Re(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)(s,{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)(v,{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)(x,{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)(a,{size:14,"aria-hidden":`true`,className:k(`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:o.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:k(`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 Re(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()]}var ze={enabled:!1,enforcement:`confirm`,shellAccess:`confirm`,allow:[]};function Be({title:e,value:t,inherited:n,onSave:r}){let[a,o]=(0,A.useState)(t??ze),[s,c]=(0,A.useState)(He(t?.allow??[])),[l,u]=(0,A.useState)(He(t?.deny??[])),[d,f]=(0,A.useState)(null);return(0,A.useEffect)(()=>{o(t??ze),c(He(t?.allow??[])),u(He(t?.deny??[])),f(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)(i,{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:a.enabled,onChange:e=>o({...a,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:a.enforcement,onChange:e=>o({...a,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:a.shellAccess,onChange:e=>o({...a,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)(Ve,{label:`Allow selectors`,value:s,onChange:c}),(0,U.jsx)(Ve,{label:`Deny selectors`,value:l,onChange:u}),(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.`}),d&&(0,U.jsx)(`div`,{className:`text-destructive`,children:d}),(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsxs)(`button`,{type:`button`,onClick:()=>{try{let e=Ue(s),t=Ue(l);r({...a,allow:e,...t.length?{deny:t}:{}}),f(null)}catch(e){f(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)(h,{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 Ve({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 He(e){return e.map(e=>`${e.kind}:${e.access}:${e.path}`).join(`
|
|
2
|
-
`)}function Ue(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 We(e,t,n,r=new Date().toISOString()){return{format:`wrongstack-kanban-task-activity`,version:1,exportedAt:r,scope:n,task:e,events:t}}function G(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function K(e){return typeof e==`string`&&e.trim()?e.trim():void 0}function q(e){return e.type.startsWith(`task.file.`)?e.type===`task.file.read`?`execution`:`changes`:e.type.startsWith(`task.activity.`)?K(G(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 Ge(e){let t=G(e.before),n=G(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 Ke(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 qe(e){let t=G(e.before),n=G(e.after);if(e.type.startsWith(`task.file.`)){let e=K(n.filePath),t=K(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[K(n.outcome),K(n.details)].filter(Boolean).join(` · `)||void 0;if(e.type===`task.moved`){let e=K(t.columnId),r=K(n.columnId);if(e||r)return`${e??`unknown`} → ${r??`unknown`}`}if(e.type===`task.updated`){let t=Ge(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=K(t.stage),r=K(n.stage);if(r)return e?`${e} → ${r}`:`Entered ${r}`}if(e.type===`task.assigned`||e.type===`task.assignment.snapshot`){let e=K(n.name)??K(n.agentId)??K(n.role),t=K(n.provider),r=K(n.model);return[e,t||r?`${t?`${t}/`:``}${r??`default`}`:void 0].filter(Boolean).join(` · `)||void 0}if(e.type.startsWith(`task.check.`))return[K(n.description),K(n.status)].filter(Boolean).join(` · `)||void 0;if(e.type.startsWith(`task.metric.`))return[K(n.name),K(n.status)].filter(Boolean).join(` · `)||void 0}function Je(e){let t=e.type;return K(G(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 Ye(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 Xe(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 Ze(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 Qe({event:e}){let t=G(e.after),n=K(t.provider),r=K(t.model),i=K(t.modelRouting),a=K(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=K(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 $e({task:e,events:n,sessionId:r,loading:i=!1,error:a,onRefresh:o}){let[s,c]=(0,A.useState)(`all`),[l,u]=(0,A.useState)(``),[d,f]=(0,A.useState)(!1),p=(0,A.useMemo)(()=>Ze(e,n,r),[e,n,r]),m=(0,A.useMemo)(()=>({all:p.length,execution:p.filter(e=>q(e)===`execution`).length,changes:p.filter(e=>q(e)===`changes`).length,notes:p.filter(e=>q(e)===`notes`).length,failures:p.filter(e=>q(e)===`failures`).length}),[p]),h=(0,A.useMemo)(()=>{let e=l.trim().toLowerCase();return p.filter(t=>s!==`all`&&q(t)!==s?!1:!e||[Ke(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))},[p,s,l]),_=be(h,50,`${s}:${l}`),v=_.pageItems,y=[...new Set(p.map(e=>e.actor).filter(Boolean))].length,b=[...new Set(p.map(e=>e.sessionId??r).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)(g,{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:[h.length,`/`,p.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(We(e,h,`filtered`),null,2)),f(!0)}catch{f(!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:d?(0,U.jsx)(le,{className:`size-3 text-success`}):(0,U.jsx)(t,{className:`size-3`})}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>{let t=JSON.stringify(We(e,p,`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)(D,{className:`size-3`})}),o&&(0,U.jsx)(`button`,{type:`button`,onClick:o,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:k(`size-3`,i&&`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`,p.length],[`Actors`,y],[`Sessions`,b],[`Failures`,m.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:()=>c(e),className:k(`rounded border px-1.5 py-1 text-[9px] capitalize`,s===e?`border-primary/50 bg-primary/10 text-primary`:`border-border text-muted-foreground hover:text-foreground`),children:[e,` `,m[e]]},e))}),(0,U.jsxs)(`div`,{className:`relative mb-3`,children:[(0,U.jsx)(ae,{className:`pointer-events-none absolute left-2 top-1/2 size-3 -translate-y-1/2 text-muted-foreground`}),(0,U.jsx)(`input`,{value:l,onChange:e=>u(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`}),l&&(0,U.jsx)(`button`,{type:`button`,onClick:()=>u(``),"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`})})]}),a&&(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:a}),h.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:v.map(e=>{let t=qe(e),n=e.sessionId??r,i=Ge(e),a=q(e)===`failures`,o=e.type.includes(`completed`)||K(G(e.after).outcome)===`succeeded`;return(0,U.jsxs)(`li`,{className:`relative pb-4 pl-4 last:pb-0`,children:[(0,U.jsx)(`span`,{className:k(`absolute -left-[5px] top-1.5 size-2 rounded-full ring-4`,Je(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:Ke(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:Ye(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:k(`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:Xe(e.before)}),` `,(0,U.jsx)(`span`,{"aria-hidden":!0,children:`→`}),` `,(0,U.jsx)(`span`,{className:`text-foreground`,children:Xe(e.after)})]})]},e.field))}),(0,U.jsx)(Qe,{event:e}),(e.actor||n||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]}),n&&(0,U.jsxs)(`span`,{className:`max-w-52 truncate rounded bg-muted px-1.5 py-0.5`,title:n,children:[`session:`,n]}),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)(ye,{page:_.page,pageSize:_.pageSize,totalItems:_.totalItems,onPageChange:_.setPage,className:`mt-3`,itemLabel:`activity events`})]})]})}function et(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function J(e){return typeof e==`string`&&e.trim()?e.trim():void 0}function tt(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 nt(e,t){return J(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 rt(e){return[`completed`,`failed`,`cancelled`,`released`,`recovered`].includes(e)}function it(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 at(e,t,n){let r=Ze(e,t,n).filter(tt).sort((e,t)=>e.ts.localeCompare(t.ts)),i=new Map,a=0,o=0,s=!1;for(let e of r){let t=et(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=nt(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=J(t.name)??J(t.agentId)??J(t.role)??e.actor??u.owner,u.provider=J(t.provider)??u.provider,u.model=J(t.model)??u.model,u.routingMode=J(t.modelRouting)??u.routingMode,u.fallbackProfile=J(t.fallbackProfile)??u.fallbackProfile,Array.isArray(t.fallbackModels)&&(u.fallbackModels=t.fallbackModels.filter(e=>typeof e==`string`)),u.subagentId=e.subagentId??J(t.subagentId)??u.subagentId,u.runTaskId=e.runTaskId??J(t.runTaskId)??u.runTaskId,l===`running`&&!u.runningAt&&(u.runningAt=e.ts),l===`completed`&&(u.result=J(t.lastResult)??e.note??u.result),(l===`failed`||l===`cancelled`)&&(u.error=J(t.error)??e.note??u.error),rt(l)&&(u.endedAt=e.ts),i.set(a,u),s=rt(l)}return[...i.values()].map(e=>({...e,sessionIds:[...e.sessionIds],durationMs:it(e.startedAt,e.endedAt)})).sort((e,t)=>t.attempt-e.attempt)}function ot(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 st(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 ct({task:e,events:t,sessionId:n}){let r=at(e,t,n),i=be(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)(re,{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] ${st(r[0].status)}`,children:[`latest:`,r[0].status]}),(0,U.jsx)(a,{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 ${st(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)(de,{className:`size-3`}),` `,ot(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)(u,{className:`size-3`}),` `,e.owner??`Unknown agent`]}),(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-mono`,children:[(0,U.jsx)(_,{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)(ye,{page:i.page,pageSize:i.pageSize,totalItems:i.totalItems,onPageChange:i.setPage,compact:!0,itemLabel:`execution attempts`})]})]}):null}function lt(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function Y(e){return H(e)}function ut(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 dt(e,t,n,r,i,a,o){let s=Ze(t,n,r),c=ut(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=lt(s.find(e=>e.type===`task.assigned`||e.type===`task.claimed`||e.type.startsWith(`task.assignment.`))?.after),p=Y(u?.modelRouting)??Y(f.modelRouting)??`session`,m=Y(u?.provider)??Y(f.provider)??(p===`session`?Y(i):void 0),h=Y(u?.model)??Y(f.model)??(p===`session`?Y(a):void 0),g=(Array.isArray(u?.fallbackModels)?u.fallbackModels:Array.isArray(f.fallbackModels)?f.fallbackModels:[]).map(Y).filter(e=>e!==void 0),_=Y(u?.fallbackProfile)??Y(f.fallbackProfile),v=Y(u?.name)??Y(u?.agentId)??Y(u?.role)??Y(t.assignee)??Y(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(lt(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=>q(e)===`failures`),ee=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 ${X(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??ee?.note,eventCount:s.length,lastActivity:s[0]}}function X(e){if(!e)return`—`;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function ft(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 Z({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 pt({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 mt({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 ht({board:e,task:t,events:n,presence:o,sessionId:s,sessionProvider:c,sessionModel:l}){let d=dt(e,t,n,s,c,l,o),f=t.assignment,p=t.successCriteria?.length??0,m=t.successCriteria?.filter(e=>e.status===`passed`).length??0,h=[t.parentTaskId,...t.childTaskIds??[],t.chain?.previousTaskId,t.chain?.nextTaskId,t.mergedIntoTaskId,...t.mergedFromTaskIds??[]].filter(e=>!!e),v=ut(e,[...new Set(h)]);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)(r,{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:[d.eventCount,` events`]}),(0,U.jsx)(a,{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:d.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:`}),` `,d.reason]}),d.blockers.length>0&&(0,U.jsxs)(`p`,{className:`mt-1 text-[10px] text-warning`,children:[d.blockers.length,` unresolved blocker`,d.blockers.length===1?``:`s`]})]}),(0,U.jsxs)(`div`,{className:`grid gap-2 xl:grid-cols-2`,children:[(0,U.jsxs)(pt,{icon:(0,U.jsx)(u,{className:`size-3`}),title:`Ownership & runtime`,children:[(0,U.jsx)(Z,{label:`Owner`,value:d.owner}),(0,U.jsx)(Z,{label:`Assignee`,value:Y(t.assignee)??Y(t.assignedAgent)??`—`}),(0,U.jsx)(Z,{label:`Agent ID`,value:Y(f?.agentId)??`—`,mono:!0}),(0,U.jsx)(Z,{label:`Agent name / role`,value:[Y(f?.name),Y(f?.role)].filter(Boolean).join(` · `)||`—`}),(0,U.jsx)(Z,{label:`Run status`,value:Y(f?.status)??`unassigned`}),(0,U.jsx)(Z,{label:`Subagent`,value:Y(f?.subagentId)??`—`,mono:!0}),(0,U.jsx)(Z,{label:`Run task`,value:Y(f?.runTaskId)??`—`,mono:!0}),(0,U.jsx)(Z,{label:`Session(s)`,value:d.sessions.join(`, `)||`Unknown`,mono:!0}),(0,U.jsx)(Z,{label:`Users / presence`,value:d.presence.length?d.presence.join(`, `):`No task-scoped presence recorded`})]}),(0,U.jsxs)(pt,{icon:(0,U.jsx)(_,{className:`size-3`}),title:`Model route & fallback`,children:[(0,U.jsx)(Z,{label:`Routing mode`,value:d.routingMode}),(0,U.jsx)(Z,{label:`Primary`,value:d.primaryModel,mono:!0}),(0,U.jsx)(Z,{label:`Provider`,value:d.provider??`—`,mono:!0}),(0,U.jsx)(Z,{label:`Model`,value:d.model??`—`,mono:!0}),(0,U.jsx)(Z,{label:`Fallback route`,value:d.fallbackRoute,mono:!0}),(0,U.jsx)(Z,{label:`Skills`,value:f?.skills?.map(Y).filter(Boolean).join(`, `)||`Default`}),(0,U.jsx)(Z,{label:`Tools`,value:f?.tools?.map(Y).filter(Boolean).join(`, `)||`Default toolset`}),(0,U.jsx)(Z,{label:`Capabilities`,value:f?.allowedCapabilities?.map(Y).filter(Boolean).join(`, `)||`Safe defaults`,mono:!0})]}),(0,U.jsxs)(pt,{icon:(0,U.jsx)(i,{className:`size-3`}),title:`Execution policy & outcome`,children:[(0,U.jsx)(Z,{label:`Attempts`,value:`${d.attempts}${f?.maxAttempts?` / ${f.maxAttempts}`:``}`}),(0,U.jsx)(Z,{label:`Retry policy`,value:f?.retryPolicy??t.retryPolicy??`off`}),(0,U.jsx)(Z,{label:`Cost ceiling`,value:(f?.costCeilingUsd??t.costCeilingUsd)==null?`Unbounded`:`$${(f?.costCeilingUsd??t.costCeilingUsd).toFixed(2)}`}),(0,U.jsx)(Z,{label:`Failures / done`,value:`${d.failures} / ${d.completions}`}),(0,U.jsx)(Z,{label:`Checks`,value:`${m} / ${p} passed`}),(0,U.jsx)(Z,{label:`Last failure`,value:d.lastFailure??`—`}),(0,U.jsx)(Z,{label:`Result`,value:d.lastResult??`No result recorded`})]}),(0,U.jsxs)(pt,{icon:(0,U.jsx)(g,{className:`size-3`}),title:`Timing & audit coverage`,children:[(0,U.jsx)(Z,{label:`Created`,value:X(t.createdAt)}),(0,U.jsx)(Z,{label:`Updated`,value:X(t.updatedAt)}),(0,U.jsx)(Z,{label:`Due`,value:X(t.dueDate)}),(0,U.jsx)(Z,{label:`Dispatched`,value:X(f?.dispatchedAt??f?.claimedAt)}),(0,U.jsx)(Z,{label:`Completed`,value:X(f?.completedAt??t.completedAt)}),(0,U.jsx)(Z,{label:`Duration`,value:ft(f?.dispatchedAt??f?.claimedAt,f?.completedAt)}),(0,U.jsx)(Z,{label:`Heartbeat`,value:X(f?.heartbeatAt)}),(0,U.jsx)(Z,{label:`Lease expires`,value:X(f?.leaseExpiresAt)}),(0,U.jsx)(Z,{label:`Actors`,value:d.actors.join(`, `)||`Unknown`,mono:!0})]})]}),(0,U.jsxs)(pt,{icon:(0,U.jsx)(ie,{className:`size-3`}),title:`Dependencies, chain & provenance`,children:[(0,U.jsx)(Z,{label:`Dependencies`,value:(0,U.jsx)(mt,{items:d.dependencies})}),(0,U.jsx)(Z,{label:`Other relations`,value:(0,U.jsx)(mt,{items:v})}),(0,U.jsx)(Z,{label:`Chain`,value:t.chain?`${t.chain.chainId} · position ${t.chain.order}`:`None`,mono:!0}),(0,U.jsx)(Z,{label:`Origin system`,value:t.origin?.system??`manual`}),(0,U.jsx)(Z,{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)(Z,{label:`Task ID`,value:t.id,mono:!0}),(0,U.jsx)(Z,{label:`Board ID`,value:e.id,mono:!0})]})]})]})}function gt(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function _t(e){return e===`completed`||e===`failed`||e===`cancelled`}function vt(e,t){return t?Math.round(e/t*100):0}function yt(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 _=vt(o.filter(e=>!!e.actor).length,o.length),v=vt(o.filter(e=>!!e.sessionId).length,o.length),y=vt(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={...gt([...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=>_t(String(gt(e.after).status??``))&&!!e.note?.trim()));return _t(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 bt(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 xt({board:e,task:t,events:n}){let r=yt(e,t,n),i=be(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)(f,{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)(a,{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)(w,{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 ${bt(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)(m,{className:`size-3.5`}):(0,U.jsx)(x,{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)(ye,{page:i.page,pageSize:i.pageSize,totalItems:i.totalItems,onPageChange:i.setPage,compact:!0,itemLabel:`risk findings`})]})]})]})}var St=5e3,Ct=12;function wt(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 Tt({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:k(`h-2 w-2 shrink-0 rounded-full`,e.active?`bg-success`:`bg-muted-foreground/50`)}),(0,U.jsx)(ce,{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)(b,{size:12,className:`text-muted-foreground`,"aria-hidden":`true`}),(0,U.jsx)(`time`,{dateTime:e.lastSeenAt,className:`tabular-nums text-muted-foreground`,children:wt(e.lastSeenAt)})]},e.id))]})}function Et({board:e,snapshot:t,sendKanban:n}){let[r,o]=(0,A.useState)(!1),[s,c]=(0,A.useState)(!0),[l,u]=(0,A.useState)(`deterministic`),[d,f]=(0,A.useState)(`session`),[p,m]=(0,A.useState)(``),[_,v]=(0,A.useState)(``),[y,b]=(0,A.useState)(``),[x,S]=(0,A.useState)([]),[C,w]=(0,A.useState)([]),[ee,te]=(0,A.useState)(10),T=_e(r&&l===`agentic`),ne=Se(r&&l===`agentic`);(0,A.useEffect)(()=>{let t=e.supervisor;c(t?.enabled??!0),u(t?.mode??`deterministic`),f(t?.routing?.mode??`session`),m(t?.routing?.provider??``),v(t?.routing?.model??``),b(t?.routing?.fallbackProfile??``),S(t?.routing?.fallbackModels??[]),w(t?.skills??[]),te(Math.max(2,Math.round((t?.intervalMs??1e4)/1e3)))},[e.id,e.supervisor]);let re=()=>{let t={mode:d,...d===`fixed`&&p?{provider:p}:{},...d===`fixed`&&_?{model:_}:{},...d===`fallback_profile`&&y?{fallbackProfile:y}:{},...x.length?{fallbackModels:x}:{}};n(`kanban.update`,{boardId:e.id,supervisor:{enabled:s,mode:l,intervalMs:Math.max(2,ee)*1e3,recoveryMode:`auto`,...l===`agentic`?{routing:t,skills:C}:{}}}),window.setTimeout(()=>n(`kanban.supervisor.audit`,{boardId:e.id}),150)},E=s?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:()=>o(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)(i,{size:13,className:E===`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:[l,` · `,E]}),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 ${zt(t.lastAuditAt)} ago`:`not checked`}),(0,U.jsx)(a,{size:13,className:k(`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:s,onChange:e=>c(e.target.checked)}),(0,U.jsx)(`span`,{children:`Watch this board`})]}),(0,U.jsx)($,{label:`Supervisor engine`,value:l,options:[`deterministic`,`agentic`],onChange:e=>u(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:ee,onChange:e=>te(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:re,className:`inline-flex h-8 items-center gap-1 rounded-md bg-primary px-3 text-primary-foreground`,children:[(0,U.jsx)(h,{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)(g,{size:13}),` Audit now`]})]}),l===`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)($,{label:`Kanban Agent model source`,value:d,options:[`session`,`fixed`,`fallback_profile`],onChange:e=>f(e)}),d===`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)(ve,{value:_||void 0,provider:p||void 0,candidates:T,placeholder:`Select exact provider / model…`,onPick:(e,t)=>{v(e),m(t)}})]}),d===`fallback_profile`&&(0,U.jsx)($,{label:`Fallback profile (first model is primary)`,value:y,options:Object.keys(ne.fallbackProfiles),placeholder:`Select configured profile…`,onChange:b}),(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:ne.skills.map(e=>({value:e.name,label:e.name,description:e.description,tag:e.source})),selected:C,onChange:w,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:T.map(e=>({value:`${e.provider}/${e.model}`,label:e.label,tag:e.provider})),selected:x,onChange:S,placeholder:`Optional ordered fallbacks…`})]})]})]})]})}function Dt(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 Ot({onClose:e}){let n=he(e=>e.wsUrl),r=pe(e=>e.session?.id??null),i=me(e=>e.agents),{boards:a,boardTotal:s,activeBoardTotal:c,orphanedBoardTotal:l,activeBoardId:u,activeBoard:d,loading:f,error:m,queueHealth:h,supervisorSnapshot:g,setLoading:_,setActiveBoardId:v}=ge(),[y,b]=(0,A.useState)(``),[x,C]=(0,A.useState)(1),[w,ee]=(0,A.useState)([]),[te,T]=(0,A.useState)(``),ne=(0,A.useRef)(null);j(ne);let[re,ie]=(0,A.useState)(``),[D,ae]=(0,A.useState)(null),[se,ce]=(0,A.useState)([]),[le,ue]=(0,A.useState)(),[de,_e]=(0,A.useState)(!1),[ve,be]=(0,A.useState)(null),[xe,Se]=(0,A.useState)(0),[Ce,we]=(0,A.useState)(null),Ee=(0,A.useRef)(null),M=(0,A.useMemo)(()=>fe(n),[n]),De=d?.tasks.find(e=>e.id===D)??null,Oe=(0,A.useMemo)(()=>{let e=new Set;for(let t of i.values())t.status===`running`&&(e.add(t.id),e.add(t.name));return e},[i]),ke=(0,A.useMemo)(()=>{let e=new Set;r&&e.add(r);for(let t of w)e.add(t);for(let t of i.values())t.status===`running`&&t.sessionId&&e.add(t.sessionId);return[...e]},[i,w,r]),N=e=>e.presence?.some(e=>e.active)===!0||e.tags?.some(e=>e.startsWith(`session:`)&&ke.includes(e.slice(8)))===!0,Ae=a.filter(N),je=a.filter(e=>!N(e)),Me=(0,A.useMemo)(()=>d?Te(d,{now:Date.now(),liveAgentIdentities:Oe,requireDueDate:d.lifecycle?.mode===`managed`}):null,[d,Oe]),Ne=(0,A.useMemo)(()=>d?d.tasks.filter(e=>e.status===`in_progress`||e.assignment?.status===`running`||e.assignment?.status===`queued`).reduce((e,t)=>e+(t.costCeilingUsd??0),0):0,[d]),P=(e,t={})=>{_(!0),M.send({type:e,payload:t})},F=(e,t={})=>{M.send({type:e,payload:t})},I=(0,A.useMemo)(()=>Dt(d),[d]),L=(e=x)=>P(`kanban.list`,{page:e,pageSize:Ct,activeSessionIds:ke}),R=(e=u)=>{e&&P(`kanban.get`,{boardId:e})};(0,A.useEffect)(()=>{L()},[]),(0,A.useEffect)(()=>{let e=!1,t=async()=>{try{let t=await fetch(`/api/sessions`);if(!t.ok)return;let n=await t.json();if(!Array.isArray(n)||e)return;let r=n.filter(e=>!!e&&typeof e==`object`&&typeof e.sessionId==`string`&&e.status!==`lost`).map(e=>e.sessionId).sort();ee(e=>e.length===r.length&&e.every((e,t)=>e===r[t])?e:r)}catch{}};t();let n=window.setInterval(t,8e3);return()=>{e=!0,window.clearInterval(n)}},[]),(0,A.useEffect)(()=>{let e=r?a.find(e=>e.tags?.includes(`session:${r}`)):void 0,t=!!(r&&e)&&Ee.current!==r,n=t?e:u?void 0:a[0];n?.id&&(t&&(Ee.current=r),v(n.id),P(`kanban.get`,{boardId:n.id}))},[a,u,r,v]),(0,A.useEffect)(()=>{d&&D&&!d.tasks.some(e=>e.id===D)&&ae(null)},[d,D]),(0,A.useEffect)(()=>{u&&(P(`kanban.health`,{boardId:u}),P(`kanban.supervisor.status`,{boardId:u}))},[u]),(0,A.useEffect)(()=>{if(!u)return;let e=setInterval(()=>{M.send({type:`kanban.get`,payload:{boardId:u}}),M.send({type:`kanban.health`,payload:{boardId:u}})},5e3);return()=>clearInterval(e)},[u,M]),(0,A.useEffect)(()=>{let e=setInterval(()=>{M.send({type:`kanban.list`,payload:{page:x,pageSize:Ct,activeSessionIds:ke}})},8e3);return()=>clearInterval(e)},[ke,x,M]);let z=e=>{C(e),v(null),L(e)};(0,A.useEffect)(()=>{ue(void 0)},[u,D]),(0,A.useEffect)(()=>{if(!u||!D)return;let e=u,t=D;_e(!0),be(null);let n=M.on(`kanban.task.activity`,n=>{let r=n.payload;if(r.success===!1){be(r.error??`Task activity could not be loaded.`),_e(!1);return}r.data?.boardId!==e||r.data.taskId!==t||(ce(r.data.events??[]),ue(r.data.presence??[]),_e(!1))});return M.send({type:`kanban.task.activity`,payload:{boardId:e,taskId:t,limit:St}}),n},[u,D,De?.updatedAt,xe,M]),(0,A.useEffect)(()=>{if(!(!u||!D))return M.on.bind(M)(`kanban.task.activity.changed`,e=>{let t=e.payload;t.boardId===u&&t.taskId===D&&Se(e=>e+1)})},[u,D,M]);let B=()=>{let e=y.trim();e&&(b(``),P(`kanban.create`,{title:e,lifecycle:{mode:`managed`,columns:{backlog:`backlog`,todo:`todo`,running:`in-progress`,review:`review`,done:`done`}}}))},V=()=>{if(!d)return;let e=te.trim();e&&(T(``),P(`kanban.task.add`,{boardId:d.id,title:e,columnId:d.columns[0]?.id??`backlog`,activityNote:`Task created manually in WebUI.`}),window.setTimeout(()=>R(d.id),150))},Pe=()=>{if(!d)return;let e=re.trim();e&&(ie(``),P(`kanban.column.add`,{boardId:d.id,title:e}),window.setTimeout(()=>R(d.id),150))},Fe=()=>{d&&(P(`kanban.delete`,{boardId:d.id}),window.setTimeout(L,150))},Ie=()=>{d&&(P(`kanban.duplicate`,{boardId:d.id,title:`${d.title} Copy`}),window.setTimeout(L,150))},H=e=>{d&&(P(`kanban.task.remove`,{boardId:d.id,taskId:e.id}),window.setTimeout(()=>R(d.id),150))},W=(e,t)=>{if(!d)return;let n=d.tasks.find(t=>t.id===e),r=d.columns.find(e=>e.id===n?.columnId)?.title,i=d.columns.find(e=>e.id===t)?.title??t;P(`kanban.task.move`,{boardId:d.id,taskId:e,columnId:t,activityNote:`Moved in WebUI${r?` from ${r}`:``} to ${i}.`}),window.setTimeout(()=>R(d.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.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:e,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)(p,{size:16})}),(0,U.jsx)(oe,{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:[s,` boards · `,c,` active · `,l,` orphaned`]})]}),(0,U.jsx)(`button`,{type:`button`,title:`Refresh`,onClick:()=>L(),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:f?`animate-spin`:void 0})})]}),(0,U.jsxs)(`div`,{className:`flex gap-1 border-b p-2`,children:[(0,U.jsx)(`input`,{value:y,onChange:e=>b(e.target.value),onKeyDown:e=>{e.key===`Enter`&&B()},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:B,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)(S,{size:16})})]}),(0,U.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-2`,children:[Ae.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 · `,c]}),Ae.map(e=>(0,U.jsxs)(`button`,{type:`button`,onClick:()=>{v(e.id),P(`kanban.get`,{boardId:e.id})},className:k(`mb-1 w-full rounded-md px-2 py-2 text-left transition-colors`,u===e.id?`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:`h-1.5 w-1.5 rounded-full bg-success`}),e.taskCount,` tasks`]}),(0,U.jsxs)(`span`,{children:[e.completedTaskCount,` done`]})]})]},e.id)),je.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 · `,l]}),je.map(e=>(0,U.jsxs)(`button`,{type:`button`,onClick:()=>{v(e.id),P(`kanban.get`,{boardId:e.id})},className:k(`mb-1 w-full rounded-md px-2 py-2 text-left transition-colors`,u===e.id?`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:`h-1.5 w-1.5 rounded-full bg-muted-foreground/45`}),e.taskCount,` tasks`]}),(0,U.jsxs)(`span`,{children:[e.completedTaskCount,` done`]})]})]},e.id))]}),(0,U.jsx)(ye,{page:x,pageSize:Ct,totalItems:s,onPageChange:z,compact:!0,itemLabel:`boards`})]}),(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:d?.title??`No board selected`}),(0,U.jsx)(`div`,{className:`truncate text-[11px] text-muted-foreground`,children:d?`${d.columns.length} columns / ${d.tasks.length} tasks`:`Create or select a board`})]}),d&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`input`,{value:te,onChange:e=>T(e.target.value),onKeyDown:e=>{e.key===`Enter`&&V()},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:V,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)(S,{size:16})}),(0,U.jsx)(`input`,{value:re,onChange:e=>ie(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Pe()},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:Pe,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)(oe,{size:16})}),(0,U.jsx)(`button`,{type:`button`,title:`Duplicate board`,onClick:Ie,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)(t,{size:16})}),(0,U.jsx)(`button`,{type:`button`,title:`Delete board`,onClick:Fe,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)(o,{size:16})})]})]}),d&&(0,U.jsx)(Tt,{presence:d.presence}),d&&(0,U.jsx)(`div`,{className:`shrink-0 border-b px-3 py-2 sm:px-4`,children:(0,U.jsx)(Be,{title:`Board boundary`,value:d.boundary,onSave:e=>{P(`kanban.update`,{boardId:d.id,boundary:e}),window.setTimeout(()=>R(d.id),150)}})}),d&&I&&(0,U.jsx)(kt,{runLink:I,sendRaw:F}),d&&!I&&d.tasks.length>0&&(0,U.jsx)(At,{boardId:d.id,sendKanban:P}),d&&(0,U.jsx)(Et,{board:d,snapshot:g,sendKanban:P}),Me&&(0,U.jsx)(Le,{audit:Me,onSelectTask:ae}),m&&(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:m})]}),(0,U.jsx)(`div`,{ref:ne,className:`kanban-scroll-area min-h-0 flex-1 overflow-x-auto overflow-y-hidden overscroll-contain`,children:d?(0,U.jsxs)(U.Fragment,{children:[h&&(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`}),h.counts.ready>0&&(0,U.jsxs)(`span`,{title:`Claimable tasks`,className:`inline-flex items-center gap-1 text-success`,children:[h.counts.ready,` ready`]}),h.counts.running>0&&(0,U.jsxs)(`span`,{title:`Running assignments`,className:`inline-flex items-center gap-1 text-warning`,children:[h.counts.running,` running`]}),h.counts.review>0&&(0,U.jsxs)(`span`,{title:`In review`,className:`inline-flex items-center gap-1 text-primary`,children:[h.counts.review,` review`]}),h.counts.blocked>0&&(0,U.jsxs)(`span`,{title:`Manually blocked`,className:`inline-flex items-center gap-1 text-destructive`,children:[h.counts.blocked,` blocked`]}),h.counts.failed>0&&(0,U.jsxs)(`span`,{title:`Failed tasks`,className:`inline-flex items-center gap-1 text-destructive`,children:[h.counts.failed,` failed`]}),h.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:[h.dependencyBlocked.count,` blocked by deps`]}),h.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:[h.staleAssignments.count,` stale`]}),h.heartbeatDue.count===0&&h.staleAssignments.count===0&&h.dependencyBlocked.count===0&&(0,U.jsx)(`span`,{className:`text-success`,children:`healthy`}),Ne>0&&(0,U.jsxs)(`span`,{title:`Sum of costCeilingUsd for running/queued tasks`,className:`inline-flex items-center gap-1 text-info`,children:[`~$`,Ne.toFixed(2),` running cost`]})]}),(0,U.jsx)(`div`,{className:`flex h-full min-w-max gap-3 p-4`,children:[...d.columns].sort((e,t)=>e.order-t.order).map(e=>(0,U.jsx)(Nt,{board:d,column:e,selectedTaskId:D,dragTaskId:Ce,setDragTaskId:we,onSelectTask:ae,onDeleteTask:H,onMoveTask:W},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)(It,{boards:a,board:d,task:De,runLink:I,onClose:()=>ae(null),sendKanban:P,sendRaw:F,refreshBoard:R,activityEvents:se,activityPresence:le,activityLoading:de,activityError:ve,activitySessionId:d?.tags?.find(e=>e.startsWith(`session:`))?.slice(8),refreshActivity:()=>Se(e=>e+1)})]})}function kt({runLink:e,sendRaw:t}){let r=e.engine===`sdd`,i=r?`sdd.board`:`goal`,a=`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)(C,{size:11}),` `,e.engine]}),(0,U.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Live run — steer it from here`}),(0,U.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,U.jsxs)(`button`,{type:`button`,className:a,onClick:()=>t(`${i}.pause`),children:[(0,U.jsx)(ne,{size:12}),` Pause`]}),(0,U.jsxs)(`button`,{type:`button`,className:a,onClick:()=>t(`${i}.resume`),children:[(0,U.jsx)(T,{size:12}),` Resume`]}),r&&(0,U.jsxs)(`button`,{type:`button`,className:a,onClick:()=>t(`sdd.board.retry_all_failed`),children:[(0,U.jsx)(n,{size:12}),` Retry failed`]}),(0,U.jsxs)(`button`,{type:`button`,className:k(a,`text-destructive hover:bg-destructive/10`),onClick:()=>t(`${i}.stop`),children:[(0,U.jsx)(l,{size:12}),` Stop`]})]})]})}function At({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)(C,{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 jt({runLink:e,runTaskId:t,modelCandidates:r,sendRaw:i}){let a=e.engine===`sdd`,[o,s]=(0,A.useState)(!1),[c,u]=(0,A.useState)(``),d=`inline-flex flex-1 items-center justify-center gap-1 rounded-md border py-1.5 text-xs font-medium hover:bg-muted`,f=()=>{let e=c.trim();e&&(i(a?`sdd.board.reassign`:`goal.assignTask`,{taskId:t,agentName:e}),s(!1),u(``))};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)(ve,{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=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&f(),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:f,className:`rounded-md bg-primary/10 px-2 py-1.5 text-primary`,children:(0,U.jsx)(le,{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:d,onClick:()=>i(a?`sdd.board.retry`:`goal.retryTask`,{taskId:t}),children:[(0,U.jsx)(n,{size:13}),` Retry`]}),(0,U.jsxs)(`button`,{type:`button`,className:d,onClick:()=>s(!0),children:[(0,U.jsx)(ee,{size:13}),` Reassign`]}),a?(0,U.jsxs)(`button`,{type:`button`,className:k(d,`text-destructive hover:bg-destructive/10`),onClick:()=>i(`sdd.board.cancel_task`,{taskId:t}),children:[(0,U.jsx)(l,{size:13}),` Cancel`]}):(0,U.jsxs)(`button`,{type:`button`,className:d,onClick:()=>i(`goal.runTask`,{taskId:t}),children:[(0,U.jsx)(T,{size:13}),` Run now`]})]})]})}function Mt(e,t){let n=t.assignment,r=yt(e,t,[]).findings.filter(e=>e.category===`operational`),i=H(n?.provider),a=H(n?.model);return{owner:H(n?.name)??H(n?.agentId)??H(n?.role)??H(t.assignee)??H(t.assignedAgent)??`Unassigned`,route:i||a?`${i?`${i}/`:``}${a??`default`}`:n?.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:n?.attempt?`${n.attempt}${n.maxAttempts?`/${n.maxAttempts}`:``}`:`0`,fallbackCount:+!!n?.fallbackProfile+(n?.fallbackModels?.length??0),activeUsers:(e.presence??[]).filter(e=>e.taskId===t.id&&e.active).length,failed:t.status===`failed`||n?.status===`failed`||!!n?.error,criticalRisks:r.filter(e=>e.severity===`critical`).length,warningRisks:r.filter(e=>e.severity===`warning`).length}}function Nt({board:e,column:t,selectedTaskId:n,dragTaskId:r,setDragTaskId:i,onSelectTask:a,onDeleteTask:s,onMoveTask:c}){let l=e.tasks.filter(e=>e.columnId===t.id).sort((e,t)=>e.order-t.order);return(0,U.jsxs)(`section`,{className:k(`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&&c(r,t.id),i(null)},children:l.map(t=>{let r=Mt(e,t);return(0,U.jsxs)(`li`,{draggable:e.lifecycle?.mode!==`managed`,onDragStart:()=>{e.lifecycle?.mode!==`managed`&&i(t.id)},onDragEnd:()=>i(null),className:k(`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.jsx)(`div`,{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:()=>s(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)(o,{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:Ht(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]})]},t.id)})})]})}var Pt=[`architect`,`developer`,`reviewer`,`tester`,`verifier`,`security`,`documenter`,`external`,`leader`,`shadow`,`subagent`],Ft=[{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 It({boards:e,board:n,task:r,runLink:o,onClose:s,sendKanban:l,sendRaw:u,refreshBoard:f,activityEvents:p,activityPresence:m,activityLoading:g,activityError:_,activitySessionId:v,refreshActivity:y}){let[b,x]=(0,A.useState)(``),[C,w]=(0,A.useState)(``),[T,ne]=(0,A.useState)(``),[re,ie]=(0,A.useState)(``),[D,ae]=(0,A.useState)(``),[O,oe]=(0,A.useState)(`session`),[se,ce]=(0,A.useState)(``),[de,fe]=(0,A.useState)([]),[pe,me]=(0,A.useState)([]),[he,ge]=(0,A.useState)([]),[ye,be]=(0,A.useState)([]),[j,Ce]=(0,A.useState)(``),we=_e(!!r),Te=Se(!!r),Ee=H(Te.sessionProvider),M=H(Te.sessionModel),De=xe(`kanban-task-inspector`,!!r),[Oe,ke]=(0,A.useState)(!1),[N,Ae]=(0,A.useState)(!1),[je,Me]=(0,A.useState)(``),[Ne,P]=(0,A.useState)(``),[F,I]=(0,A.useState)(``),[L,R]=(0,A.useState)(`pending`),[z,B]=(0,A.useState)(``),[V,Pe]=(0,A.useState)(``),[Fe,Ie]=(0,A.useState)(``),[Le,Re]=(0,A.useState)(`medium`),[ze,Ve]=(0,A.useState)(`chore`),[He,Ue]=(0,A.useState)(``),[We,G]=(0,A.useState)([]),[K,q]=(0,A.useState)([]),[Ge,Ke]=(0,A.useState)(!1),[qe,Je]=(0,A.useState)(``),[Ye,Xe]=(0,A.useState)(``),[Ze,Qe]=(0,A.useState)(`off`),[et,J]=(0,A.useState)(``),[tt,nt]=(0,A.useState)(``),[rt,it]=(0,A.useState)(``),[at,ot]=(0,A.useState)(``),[st,lt]=(0,A.useState)(``),[Y,ut]=(0,A.useState)(`observation`),[dt,X]=(0,A.useState)(`unknown`),[ft,Z]=(0,A.useState)(``);(0,A.useEffect)(()=>{let t=H(r?.assignment?.provider),i=H(r?.assignment?.model);x(H(r?.assignment?.agentId)??H(r?.assignedAgent)??``),w(H(r?.assignment?.name)??``),ne(H(r?.assignment?.role)??``),ie(t??``),ae(i??``),oe(r?.assignment?.modelRouting??(t||i?`fixed`:`session`)),ce(H(r?.assignment?.fallbackProfile)??``),fe(r?.assignment?.fallbackModels??[]),me(r?.assignment?.skills??[]),ge(r?.assignment?.tools??[]),be(r?.assignment?.allowedCapabilities??[]),Ce(e.find(e=>e.id!==n?.id)?.id??``),Me(r?.title??``),P(r?.description??``),I(r?.dueDate??``),R(r?.status??`pending`),B(``),Pe(``),Ie(``),Re(r?.priority??`medium`),Ve(r?.type??`chore`),Ue(r?.labels?.join(`, `)??``),G(r?.dependsOn??[]),q(r?.chain&&n?n.tasks.filter(e=>e.chain?.chainId===r.chain?.chainId).sort((e,t)=>(e.chain?.order??0)-(t.chain?.order??0)).map(e=>e.id):r?[r.id]:[]),Ke(!1),Je(r?.estimatedHours?.toString()??``),Xe(r?.actualHours?.toString()??``),Qe(r?.retryPolicy??r?.assignment?.retryPolicy??`off`),J((r?.costCeilingUsd??r?.assignment?.costCeilingUsd)?.toString()??``),nt(r?.assignment?.maxAttempts?.toString()??``),it(``),ot(``),lt(``),ut(`observation`),X(`unknown`),Z(``)},[n?.id,e,r]);let pt=e=>({boardId:n?.id,taskId:r?.id,...b.trim()?{agentId:b.trim()}:{},...C.trim()?{name:C.trim()}:{},...T.trim()?{role:T.trim()}:{},modelRouting:O,...O===`fixed`&&re.trim()?{provider:re.trim()}:{},...O===`fixed`&&D.trim()?{model:D.trim()}:{},...O===`fallback_profile`&&se.trim()?{fallbackProfile:se.trim()}:{},fallbackModels:de,skills:pe,tools:he,allowedCapabilities:ye,...tt?{maxAttempts:Number(tt)}:{},...et?{costCeilingUsd:Number(et)}:{},retryPolicy:Ze,activityNote:ft.trim()||`${e===`dispatch`?`Dispatched`:`Assigned`} from WebUI to ${C.trim()||b.trim()||T.trim()||`the configured agent route`}.`}),mt=()=>{!n||!r||!je.trim()||(l(`kanban.task.update`,{boardId:n.id,taskId:r.id,title:je.trim(),description:Ne,dueDate:F||null,...n.lifecycle?.mode===`managed`?{}:{status:L},priority:Le,type:ze,labels:He.split(`,`).map(e=>e.trim()).filter(Boolean),dependsOn:We,...r.chain&&K.length<=1?{chain:null}:{},estimatedHours:qe?Number(qe):0,actualHours:Ye?Number(Ye):0,retryPolicy:Ze,costCeilingUsd:et?Number(et):null,activityNote:ft.trim()||`Task contract edited in WebUI.`}),K.length>1&&l(`kanban.task.chain`,{boardId:n.id,taskIds:K,enforceDependencies:Ge}),window.setTimeout(()=>f(n.id),180),Z(``))},gt=[`backlog`,`todo`,`running`,`review`,`done`],_t=r?.lifecycle?.currentStage,vt=_t?gt.indexOf(_t):-1,yt=vt>=0&&vt<gt.length-1?gt[vt+1]:void 0,bt=()=>{!n||!r||!yt||!z.trim()||(l(`kanban.task.transition`,{boardId:n.id,taskId:r.id,to:yt,actor:b.trim()||C.trim()||r.assignee||r.assignedAgent||`webui-agent`,comment:z.trim(),...V.trim()?{action:V.trim()}:{},...Fe.trim()?{attachment:{url:Fe.trim(),type:`url`,title:`Evidence for ${r.title}`}}:{}}),window.setTimeout(()=>f(n.id),180))},St=()=>{!n||!r||!rt.trim()||(l(`kanban.task.check.add`,{boardId:n.id,taskId:r.id,description:rt.trim(),checkType:`manual`}),it(``))},Ct=()=>{!n||!r||!at.trim()||(l(`kanban.task.activity.add`,{boardId:n.id,taskId:r.id,kind:Y,outcome:dt,summary:at.trim(),...st.trim()?{details:st.trim()}:{},actor:C.trim()||b.trim()||`webui-operator`}),ot(``),lt(``),window.setTimeout(y,150))};return r?(0,U.jsxs)(`aside`,{"aria-label":`Task inspector`,"data-expanded":N?`true`:`false`,className:k(`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`,N?`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:k(`flex h-12 items-center gap-2 border-b px-3`,N&&`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:r.id.slice(0,8)})]}),(0,U.jsx)(`button`,{type:`button`,title:N?`Collapse task details`:`Expand task details`,"aria-label":N?`Collapse task details`:`Expand task details`,"aria-pressed":N,onClick:()=>Ae(e=>!e),className:`flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground`,children:N?(0,U.jsx)(te,{size:16}):(0,U.jsx)(d,{size:16})}),(0,U.jsx)(`button`,{type:`button`,title:`Close`,onClick:()=>{Ae(!1),s()},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})})]}),r?(0,U.jsxs)(`div`,{ref:De,className:k(`min-h-0 flex-1 overflow-y-auto overscroll-contain p-3`,N&&`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)(Be,{title:`Task boundary`,value:r.boundary,inherited:n?.boundary,onSave:e=>{n&&(l(`kanban.task.update`,{boardId:n.id,taskId:r.id,boundary:e,activityNote:`Task boundary edited in WebUI.`}),window.setTimeout(()=>f(n.id),150))}}),(0,U.jsx)(Q,{label:`Title`,value:je,onChange:Me}),(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:Ne,onChange:e=>P(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:[n?.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:r.lifecycle?.currentStage??`Backlog`})]}):(0,U.jsx)($,{label:`Status`,value:L,options:[`pending`,`ready`,`in_progress`,`blocked`,`review`,`completed`,`failed`,`archived`],onChange:e=>R(e)}),(0,U.jsx)($,{label:`Priority`,value:Le,options:[`critical`,`high`,`medium`,`low`],onChange:e=>Re(e)}),(0,U.jsx)($,{label:`Type`,value:ze,options:[`feature`,`bugfix`,`refactor`,`docs`,`test`,`chore`],onChange:e=>Ve(e)}),(0,U.jsx)(Q,{label:`Labels (comma separated)`,value:He,onChange:Ue})]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,U.jsx)(Q,{label:`Due date (ISO or YYYY-MM-DD)`,value:F,onChange:I}),(0,U.jsx)(Q,{label:`Estimated hours`,value:qe,onChange:Je}),(0,U.jsx)(Q,{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:(n?.tasks??[]).filter(e=>e.id!==r.id).map(e=>({value:e.id,label:e.title,description:e.status})),selected:We,onChange:G,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:(n?.tasks??[]).map(e=>({value:e.id,label:e.title,description:e.status})),selected:K,onChange:e=>q(e.includes(r.id)?e:[r.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:Ge,onChange:e=>Ke(e.target.checked)}),`Enforce chain order as dependencies`]})]}),(0,U.jsx)(Q,{label:`Change / assignment reason (persisted to activity)`,value:ft,onChange:Z}),(0,U.jsxs)(`button`,{type:`button`,onClick:mt,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)(h,{size:15}),` Save task contract`]}),n?.lifecycle?.mode===`managed`&&yt&&(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:[_t,` → `,yt,`; no stages can be skipped.`]})]}),(0,U.jsx)(i,{size:16,className:`text-primary`})]}),(0,U.jsx)(Q,{label:`Completed action / reviewer action`,value:V,onChange:Pe}),(0,U.jsx)(Q,{label:`Truthful progress comment (required)`,value:z,onChange:B}),(0,U.jsx)(Q,{label:`Evidence attachment URL`,value:Fe,onChange:Ie}),(0,U.jsxs)(`button`,{type:`button`,disabled:!z.trim(),onClick:bt,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)(ue,{size:15}),` Advance to `,yt]})]})]}),n&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(ht,{board:n,task:r,events:p,presence:m,sessionId:v,sessionProvider:Ee,sessionModel:M}),(0,U.jsx)(ct,{task:r,events:p,sessionId:v}),(0,U.jsx)(xt,{board:n,task:r,events:p})]}),(0,U.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-2 text-xs`,children:[(0,U.jsx)(Vt,{label:`Source`,value:r.origin?.system??`manual`}),(0,U.jsx)(Vt,{label:`Task ID`,value:r.id.slice(0,8)}),(0,U.jsx)(Vt,{label:`Run`,value:r.assignment?.status??`unassigned`}),(0,U.jsx)(Vt,{label:`Column`,value:Lt(n,r.columnId)})]}),r.assignment&&(0,U.jsx)(Bt,{assignment:r.assignment}),o&&r.origin?.taskId&&(0,U.jsx)(jt,{runLink:o,runTaskId:r.origin.taskId,modelCandidates:we,sendRaw:u}),!o&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,U.jsx)($,{label:`Primary model source`,value:O,options:[`session`,`fixed`,`fallback_profile`],onChange:e=>oe(e)}),O===`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: `,Ee?`${Ee}/`:``,M||`not available`,`.`]}),O===`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)(ve,{value:D||void 0,provider:re||void 0,candidates:we,placeholder:`Select exact provider / model…`,onPick:(e,t)=>{ae(e),ie(t)}})]}),O===`fallback_profile`&&(0,U.jsx)($,{label:`Fallback profile (first model is primary)`,value:se,options:Object.keys(Te.fallbackProfiles),placeholder:`Select configured profile…`,onChange:ce}),(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:we.map(e=>({value:`${e.provider}/${e.model}`,label:e.label,description:e.description,tag:e.provider})),selected:de,onChange:fe,placeholder:`Add fallback model…`,emptyLabel:`No models — add a provider in Settings`})]}),(0,U.jsx)($,{label:`Role`,value:T,options:Pt,placeholder:`Select a role…`,onChange:ne}),(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:Te.skills.map(e=>({value:e.name,label:e.name,description:e.description,tag:e.source})),selected:pe,onChange:me,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:Te.tools.map(e=>({value:e.name,label:e.name,description:e.description})),selected:he,onChange:ge,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:()=>ke(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)(a,{size:13,className:k(`transition-transform`,Oe&&`rotate-180`)})]}),Oe&&(0,U.jsxs)(`div`,{className:`space-y-3 border-t p-2`,children:[(0,U.jsx)(Q,{label:`Agent name (optional)`,value:C,onChange:w}),(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,U.jsx)($,{label:`Retry policy`,value:Ze,options:[`off`,`incremental`,`exponential`],onChange:e=>Qe(e)}),(0,U.jsx)(Q,{label:`Max attempts`,value:tt,onChange:nt}),(0,U.jsx)(Q,{label:`Cost ceiling USD`,value:et,onChange:J})]}),(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:Ft,selected:ye,onChange:be,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:()=>{!n||!r||(l(`kanban.task.assign`,pt(`assign`)),Z(``),window.setTimeout(()=>f(n.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)(ee,{size:15}),`Assign`]}),(0,U.jsxs)(`button`,{type:`button`,onClick:()=>{!n||!r||(l(`kanban.task.dispatch`,pt(`dispatch`)),Z(``),window.setTimeout(()=>f(n.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)(c,{size:15}),`Dispatch`]})]})]}),e.length>1&&!o?(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=>Ce(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!==n?.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:()=>{!n||!r||!j||l(`kanban.task.copy`,{boardId:n.id,taskId:r.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)(t,{size:15}),`Copy`]}),(0,U.jsxs)(`button`,{type:`button`,onClick:()=>{!n||!r||!j||l(`kanban.task.transfer`,{boardId:n.id,taskId:r.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)(ue,{size:15}),`Transfer`]})]})]}):null,(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:[(r.successCriteria??[]).map(e=>(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)(le,{size:13,className:e.status===`passed`?`text-success`:`text-muted-foreground`}),(0,U.jsx)(`span`,{className:`min-w-0 truncate`,children:e.description}),(0,U.jsx)(`select`,{value:e.status,onChange:t=>l(`kanban.task.check.update`,{boardId:n?.id,taskId:r.id,checkId:e.id,status:t.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))})]},e.id)),(0,U.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,U.jsx)(`input`,{value:rt,onChange:e=>it(e.target.value),onKeyDown:e=>e.key===`Enter`&&St(),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:St,className:`h-8 rounded-md border px-2 hover:bg-muted`,children:(0,U.jsx)(S,{size:14})})]})]})]}),(0,U.jsx)($e,{task:r,events:p,sessionId:v,loading:g,error:_,onRefresh:y}),(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:Y,onChange:e=>ut(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:dt,onChange:e=>X(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:at,onChange:e=>ot(e.target.value),onKeyDown:e=>e.key===`Enter`&&Ct(),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:Ct,className:`h-8 rounded-md border px-2 hover:bg-muted`,"aria-label":`Record task decision or outcome`,children:(0,U.jsx)(S,{size:14})})]}),(0,U.jsx)(`input`,{value:st,onChange:e=>lt(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`})]})]}):null]}):null}function Lt(e,t){return e?.columns.find(e=>e.id===t)?.title??t}var Rt={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 zt(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 Bt({assignment:e}){let t=e.status===`running`,n=zt(e.dispatchedAt,e.completedAt),r=H(e.name)??H(e.agentId),i=H(e.role),a=H(e.provider),o=H(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:k(`ml-auto inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium capitalize`,Rt[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 Vt({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 Q({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 $({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 Ht(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`}export{Ot as KanbanView};
|