@humwick/server 0.130.3 → 0.130.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/docs/openapi.json +103 -1
  2. package/package.json +6 -6
  3. package/public/assets/{MessageBubble-Bq9kr21N.js → MessageBubble-BOkmEvgZ.js} +2 -2
  4. package/public/assets/{PlanGraphPanel-Dqiroy06.js → PlanGraphPanel-BkaDJp0r.js} +2 -2
  5. package/public/assets/{TraceView-DYU962-H.js → TraceView-B99Uu2yT.js} +2 -2
  6. package/public/assets/{VaultDecisionCard-DhPfzioE.js → VaultDecisionCard-DUIfTTFF.js} +2 -2
  7. package/public/assets/{activity-DzCcQTee.js → activity-ZIX0N1El.js} +2 -2
  8. package/public/assets/{agent-lineage-SgDt9i3T.js → agent-lineage-kq9TPYFw.js} +2 -2
  9. package/public/assets/agent-liveness-DSQY1Aa_.js +2 -0
  10. package/public/assets/{agent-name-CcY3Aijy.js → agent-name-C_7F4DFR.js} +2 -2
  11. package/public/assets/{agent-profiles-cxtRBn6O.js → agent-profiles-BNOcrGcY.js} +2 -2
  12. package/public/assets/{agent-project-badge-DGYbIhaI.js → agent-project-badge-B6yAh70a.js} +2 -2
  13. package/public/assets/{agent-tools-DHbftV0N.js → agent-tools-CcrhmOzF.js} +2 -2
  14. package/public/assets/{agent-type-icon-CY113sp-.js → agent-type-icon-CXSLrKiq.js} +2 -2
  15. package/public/assets/{agents-BPzY7IlQ.js → agents-DIZG97_X.js} +2 -2
  16. package/public/assets/{analytics-DENFPv_a.js → analytics-rasmoPjR.js} +2 -2
  17. package/public/assets/{artifact-viewer-KRvSc7sl.js → artifact-viewer-tBpTrEPb.js} +2 -2
  18. package/public/assets/{artifacts-C9gSmL3s.js → artifacts-BNkrynP1.js} +2 -2
  19. package/public/assets/{artifacts-DT-HkI5O.js → artifacts-Bjq-ZyBA.js} +2 -2
  20. package/public/assets/{automation-BsmjQhKD.js → automation-Cx422L3L.js} +2 -2
  21. package/public/assets/{backlog-8NYH_62t.js → backlog-RuFQ8PUu.js} +2 -2
  22. package/public/assets/{busy-health-D3hwvYb4.js → busy-health-BvNQ9g5x.js} +2 -2
  23. package/public/assets/{channels-DCJ5WL7O.js → channels-DNbKAS0I.js} +2 -2
  24. package/public/assets/{chat-DAIl357U.js → chat-Bp3Fx73h.js} +2 -2
  25. package/public/assets/{code-preview-CzrZfr9U.js → code-preview-KIRZA6cz.js} +2 -2
  26. package/public/assets/{connectors-xTxtlyou.js → connectors-k7vO4vvc.js} +2 -2
  27. package/public/assets/{cosmos-BpebFLK2.js → cosmos-BuVoq1aw.js} +2 -2
  28. package/public/assets/{crate-agent-BHvI5wXC.js → crate-agent-irqlt4NH.js} +2 -2
  29. package/public/assets/{dependency-graph-DGT0o3wJ.js → dependency-graph-D_rurNBz.js} +2 -2
  30. package/public/assets/{deploys-hqWOHSHE.js → deploys-yzZqIpxE.js} +2 -2
  31. package/public/assets/{display-CDeH4I8T.js → display-BemJG1f_.js} +2 -2
  32. package/public/assets/{files-BTeGVmTg.js → files-DXWcrxOz.js} +2 -2
  33. package/public/assets/{fleet-DgXtNgCa.js → fleet-TEuOCZXE.js} +2 -2
  34. package/public/assets/{fleet-metrics-BHEt5yc_.js → fleet-metrics-BGoDAFI-.js} +2 -2
  35. package/public/assets/{formatted-body-impl-CAe664Z8.js → formatted-body-impl-BB9eq9nN.js} +2 -2
  36. package/public/assets/{formatted-body-MLtodyPp.js → formatted-body-qy2nTD_1.js} +3 -3
  37. package/public/assets/{host-providers-dialog-mapF4Fj9.js → host-providers-dialog-BGPHxuwT.js} +2 -2
  38. package/public/assets/{index-CqqgOI5R.js → index-BC5XZc0z.js} +5 -5
  39. package/public/assets/{index-MYAIwYTX.css → index-D8Rp9pz2.css} +1 -1
  40. package/public/assets/{insights-DNyf7IzF.js → insights-C-KQG0h-.js} +2 -2
  41. package/public/assets/{integrations-DlYOHq7T.js → integrations-ClPRPyKU.js} +2 -2
  42. package/public/assets/{issue-ref-chip-CeWBNWn7.js → issue-ref-chip-DbH8J9Ak.js} +2 -2
  43. package/public/assets/{log-viewer-Cib8nqdE.js → log-viewer-PH4zVn24.js} +2 -2
  44. package/public/assets/{maintenance-DSn1cPm7.js → maintenance-5lV43uTL.js} +2 -2
  45. package/public/assets/{managed-agents-C3CkM81m.js → managed-agents-BdgU35aX.js} +2 -2
  46. package/public/assets/{markdown-preview-W4VQQPAv.js → markdown-preview-DNT4OUwQ.js} +3 -3
  47. package/public/assets/{markdown-preview-impl-CMsTdhjq.js → markdown-preview-impl-CnCcPy0A.js} +2 -2
  48. package/public/assets/{memory-BV17qtO4.js → memory--GgWH1gH.js} +2 -2
  49. package/public/assets/{messages-Bm_1AqSA.js → messages-CzFl_97O.js} +2 -2
  50. package/public/assets/{orchestrators-Dg-vfP09.js → orchestrators-CVvJVkzv.js} +2 -2
  51. package/public/assets/overview-DsrZvE86.js +2 -0
  52. package/public/assets/{pairs-8o9nuG3V.js → pairs-D2d0d2py.js} +2 -2
  53. package/public/assets/{profile-icon-BsRyBMea.js → profile-icon-_SMuSbYF.js} +2 -2
  54. package/public/assets/{project-profile-instructions-DETKFn_E.js → project-profile-instructions-Apn15y43.js} +2 -2
  55. package/public/assets/{projects-M_m6AHws.js → projects-D3B6kto5.js} +2 -2
  56. package/public/assets/{prompt-settings-C_mNCgeL.js → prompt-settings-DnPB6Ez6.js} +2 -2
  57. package/public/assets/provider-display-bWwiuedV.js +2 -0
  58. package/public/assets/{registry-DDHHHE5N.js → registry-D790cIhN.js} +2 -2
  59. package/public/assets/{run-card-Dt4I4jaP.js → run-card-BCro-Odj.js} +2 -2
  60. package/public/assets/{secrets-BkVwxI5O.js → secrets-CVXvfvbU.js} +2 -2
  61. package/public/assets/{service-access-settings-Crq-6a-B.js → service-access-settings-D3Xxqb9w.js} +2 -2
  62. package/public/assets/{settings-CYcavMFu.js → settings-CoUC7Jci.js} +2 -2
  63. package/public/assets/{shipping-H6gzEeZB.js → shipping-D_Lp9n_J.js} +2 -2
  64. package/public/assets/{stats-BJVeWkpV.js → stats-CXiNjB9S.js} +2 -2
  65. package/public/assets/{status-dot-BcHyw1Vw.js → status-dot-C703YIy1.js} +2 -2
  66. package/public/assets/store-BgDALGIX.js +9 -0
  67. package/public/assets/{tasks-qJjlQPpx.js → tasks-DO0WpJCx.js} +2 -2
  68. package/public/assets/{teams-Cd5Sk1uX.js → teams-FGkdi_tL.js} +2 -2
  69. package/public/assets/{terminal-viewer-CpY5_m7W.js → terminal-viewer-Dh8dSC7e.js} +3 -3
  70. package/public/assets/{terminal-viewer-impl-DI_2llFR.js → terminal-viewer-impl-B5Zriip3.js} +2 -2
  71. package/public/assets/{use-agent-terminal-0yJA_buM.js → use-agent-terminal-CRUVDvLC.js} +2 -2
  72. package/public/assets/{use-decisions-uJXHf34W.js → use-decisions-CoaqRh4l.js} +2 -2
  73. package/public/assets/{use-project-list-CpWl6eHQ.js → use-project-list-X-BgT53X.js} +2 -2
  74. package/public/assets/{use-selectors-BdxBW8mL.js → use-selectors-0X_UZkk-.js} +2 -2
  75. package/public/assets/{user-avatar-3IndfpOc.js → user-avatar-CkLhVBGu.js} +2 -2
  76. package/public/assets/{versioned-prompt-editor-CIVg7XB1.js → versioned-prompt-editor-BkTi7eim.js} +2 -2
  77. package/public/assets/{work-queue-B9rnLwHZ.js → work-queue-DDOLEyKo.js} +2 -2
  78. package/public/assets/{workflow-marker-X8wxyhzC.js → workflow-marker-CzOsB8BM.js} +2 -2
  79. package/public/assets/{workflows-o5YyMFW7.js → workflows-DJilvmRM.js} +2 -2
  80. package/public/assets/{workspaces-CzEGoAng.js → workspaces-CHcfbLR3.js} +2 -2
  81. package/public/cosmos.html +4 -4
  82. package/public/index.html +29 -29
  83. package/runner/plugins/claude/.claude-plugin/plugin.json +1 -1
  84. package/runner/src/adapters/claude-api.ts +1 -1
  85. package/runner/src/provider-setup.ts +2 -2
  86. package/src/auth/login-link.ts +35 -0
  87. package/src/cli/index.ts +7 -1
  88. package/src/cli/init.ts +53 -0
  89. package/src/cli/orchestrator.ts +1 -7
  90. package/src/cli/setup.ts +6 -4
  91. package/src/db/spawn-delegation.ts +2 -1
  92. package/src/db/workflow-execution.ts +3 -3
  93. package/src/dev.ts +4 -13
  94. package/src/init.ts +299 -0
  95. package/src/invite-link.ts +16 -9
  96. package/src/routes/auth.ts +30 -2
  97. package/src/routes/host-providers.ts +18 -0
  98. package/src/routes/index.ts +5 -2
  99. package/src/routes/orchestrator-bootstrap.ts +2 -0
  100. package/src/routes/secrets-backup.ts +2 -3
  101. package/src/routes/secrets-import.ts +2 -3
  102. package/src/routes/secrets-vault.ts +5 -7
  103. package/src/runtime-install.ts +30 -0
  104. package/src/server.ts +4 -4
  105. package/src/services/auth-context.ts +6 -0
  106. package/src/services/provider-api-key.ts +73 -0
  107. package/src/setup.ts +47 -8
  108. package/src/utils.ts +7 -0
  109. package/public/assets/agent-liveness-Bq-s73jW.js +0 -2
  110. package/public/assets/overview-DcYCrvlr.js +0 -2
  111. package/public/assets/provider-display-BEeLXC_D.js +0 -2
  112. package/public/assets/store-DKPDIZBe.js +0 -9
@@ -1,6 +1,6 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{o as t,p as n,u as r}from"./dist-DeW2Y1R5.js";import{t as i}from"./react-dom-DSFxiC7T.js";import{At as a,C as o,Ct as s,Dt as c,K as l,S as u,T as d,Vt as f,_ as p,b as m,bt as h,ct as g,g as _,h as v,jt as y,kt as b,lt as x,m as S,ot as C,st as w,t as T,v as E,w as ee,x as te,xt as D,y as O,yt as ne}from"./store-DKPDIZBe.js";import{O as k,b as A,i as j,m as M,o as re,p as ie,r as ae,t as oe,w as N}from"./provider-display-BEeLXC_D.js";import{F as P,G as se,I as ce,R as le,S as F,Z as ue,et as I,f as L,i as R,it as de,j as fe,o as pe,q as me,r as z,rt as B,s as V,st as H,tt as U,v as he,y as W}from"./display-CDeH4I8T.js";import{n as ge,r as G,t as _e}from"./PlanGraphPanel-Dqiroy06.js";import{g as ve,o as ye,t as be}from"./api-CIIVBtAV.js";import{r as xe,s as Se,t as Ce}from"./dialog-uuJ9_geR.js";import{a as we,c as Te,n as Ee,o as De,r as K,s as q,t as Oe}from"./dropdown-menu-BXiNephE.js";import{t as ke}from"./label-BPBzm9FJ.js";import{a as Ae,n as je,t as Me}from"./popover-8w1TWKMG.js";import{t as Ne}from"./switch-DuCA7mrB.js";import{_ as Pe,a as Fe,c as Ie,d as Le,f as Re,g as ze,h as J,l as Be,n as Ve,o as He,s as Ue,t as We,u as Ge,v as Ke}from"./files-BTeGVmTg.js";import{_ as qe,c as Je,d as Ye,h as Xe,l as Ze,o as Qe,t as $e,u as et,v as tt}from"./agent-lineage-SgDt9i3T.js";import{n as nt}from"./radio-Bn0_qc0G.js";import{A as rt,C as it,E as at,F as ot,G as st,L as ct,M as lt,P as ut,R as dt,S as Y,T as ft,U as pt,_ as mt,a as ht,b as gt,c as _t,d as vt,f as yt,g as bt,i as xt,l as St,m as X,n as Ct,o as wt,r as Tt,s as Et,t as Dt,u as Ot,x as kt,y as At,z as jt}from"./TraceView-DYU962-H.js";import{t as Mt}from"./bot-B0NpDNhr.js";import{t as Nt}from"./check-B3M9Ug1P.js";import{t as Pt}from"./chevron-down-BoG3JCZn.js";import{t as Ft}from"./chevron-right-iljytE0x.js";import{t as It}from"./chevron-up-Bv3yC5ma.js";import{t as Lt}from"./circle-alert-CryagaZd.js";import{t as Rt}from"./circle-check-CkUkN96J.js";import{n as zt}from"./zap-DGuDTw4w.js";import{t as Bt}from"./download-KgtpDbt5.js";import{t as Vt}from"./eye-BAP6fHrX.js";import{t as Ht}from"./file-text-CKuoMR2U.js";import{t as Ut}from"./flag-CnEG9PH-.js";import{t as Wt}from"./folder-open-CBUCMSlu.js";import{t as Gt}from"./gauge-BIODY-BQ.js";import{t as Kt}from"./hourglass-txu4ax6n.js";import{t as qt}from"./list-checks-CwnS3hly.js";import{t as Jt}from"./loader-circle-BfPd4kOD.js";import{t as Yt}from"./message-square-C-1G8dMM.js";import{t as Xt}from"./minimize-2-BkK6XoMP.js";import{t as Zt}from"./paperclip-CNpKZKum.js";import{t as Qt}from"./pencil-B1Hf2V_J.js";import{t as $t}from"./plus-D5Ek4e2S.js";import{t as en}from"./power-6tZOhYPg.js";import{r as tn}from"./workflow-marker-X8wxyhzC.js";import{t as nn}from"./search-DjzbnTbf.js";import{t as rn}from"./terminal-Bl2u7KxT.js";import{t as an}from"./triangle-alert-BBNhfgMi.js";import{t as on}from"./agent-type-icon-CY113sp-.js";import{t as sn}from"./volume-2-XrcRKD9Z.js";import{t as cn}from"./x-Bge17hWJ.js";import{t as ln}from"./zoom-in-Bs8Qv8VL.js";import{t as Z}from"./button-Do6Z3vvn.js";import{t as un}from"./badge-DqJRtj_p.js";import{t as dn}from"./copy-button-CjOj4HEf.js";import{t as fn}from"./agent-name-CcY3Aijy.js";import{f as pn,n as mn,s as hn}from"./use-selectors-BdxBW8mL.js";import{t as gn}from"./input-CsTB6jIx.js";import{t as _n}from"./status-dot-BcHyw1Vw.js";import{t as vn}from"./terminal-viewer-CpY5_m7W.js";import{n as yn,t as bn}from"./profile-icon-BsRyBMea.js";import{t as xn}from"./textarea-hs6Mpyfl.js";import{t as Sn}from"./formatted-body-MLtodyPp.js";import{a as Cn,i as wn,n as Tn,o as En,r as Dn,t as On}from"./MessageBubble-Bq9kr21N.js";import{t as kn}from"./use-agent-terminal-0yJA_buM.js";import{i as An,n as jn,r as Mn,t as Nn}from"./use-decisions-uJXHf34W.js";import{n as Pn}from"./run-card-Dt4I4jaP.js";import{n as Fn,r as In,t as Ln}from"./esm-ZSuD7QuY.js";var Q=e(n(),1);function Rn(e,t,n,r,i){if(i.includes(e))return!1;if(r.includes(e)||n)return!0;let a=t[e];return!!(a&&k(a.spawnedBy??``))}function zn(){let e=T(e=>e.agents),t=T(e=>e.agentsById),n=T(e=>e.showBuiltIns),r=T(e=>e.showOffline),i=T(e=>e.chatAgentSearch),a=T(e=>e.chatAgentProviderFilter),o=T(e=>e.chatAgentStatusFilter),s=T(e=>e.chatAgentTagFilter),c=T(e=>e.chatAgentCapFilter),l=T(e=>e.chatAgentHostFilter),u=T(e=>e.chatAgentSort),d=T(e=>e.chatAgentSortDir),f=T(e=>e.managedPolicies),p=T(e=>e.feedObserveAll),m=T(e=>e.coordinatorFollows),h=T(e=>e.coordinatorMutes),g=hn();return(0,Q.useMemo)(()=>{let _=new Set(g.map(e=>e.peer)),v=de(e,n,f);if(r||(v=v.filter(e=>e.status!==`offline`)),v=p?v.filter(e=>!h.includes(e.id)):v.filter(e=>Rn(e.id,t,_.has(e.id),m,h)),i){let e=i.toLowerCase();v=v.filter(t=>t.id.toLowerCase().includes(e)||(t.name||``).toLowerCase().includes(e)||(t.label||``).toLowerCase().includes(e)||(t.tags||[]).some(t=>t.toLowerCase().includes(e))||(t.capabilities||[]).some(t=>t.toLowerCase().includes(e)))}a&&(v=v.filter(e=>V(e)===a)),o&&(v=v.filter(e=>e.status===o)),s&&(v=v.filter(e=>(e.tags||[]).includes(s))),c&&(v=v.filter(e=>(e.capabilities||[]).includes(c))),l&&(v=v.filter(e=>(e.machine||``)===l));let y=d===`desc`?-1:1;return[...v].sort((e,t)=>u===`name`?L(e).localeCompare(L(t))*y:u===`lastSeen`?at(U(e.lastSeen),U(t.lastSeen),y)||L(e).localeCompare(L(t)):((H[e.status]??9)-(H[t.status]??9))*y||L(e).localeCompare(L(t)))},[e,t,n,r,f,i,a,o,s,c,l,u,d,p,m,h,g])}var $=r();function Bn({agents:e,now:t}){return(0,$.jsx)(`span`,{"data-testid":`child-agent-strip`,className:`ml-auto flex min-w-0 flex-1 justify-end overflow-hidden py-0.5 pl-2`,children:e.map(e=>{let n=yn(e);return(0,$.jsxs)(`span`,{title:n?`${L(e)} · ${n}`:L(e),className:`relative h-3.5 min-w-[7px] shrink basis-[18px] last:shrink-0 last:basis-3.5`,children:[(0,$.jsx)(on,{agent:e,className:`h-3.5 w-3.5 border-0 bg-transparent`}),n&&(0,$.jsx)(bn,{profile:n,className:`absolute -left-px -top-1 text-[9px]`}),(0,$.jsx)(_n,{agent:e,now:t,className:`absolute -bottom-0.5 left-0 h-1.5 w-1.5 ring-1 ring-background`})]},e.id)})})}function Vn({agentId:e}){let t=jn(e),n=T(e=>e.decisionsDockCollapsed),r=T(e=>e.setDecisionsDockCollapsed),i=s();if(!t.length)return null;let a=l(t,i);return(0,$.jsxs)(`div`,{"data-testid":`decisions-dock`,className:`shrink-0 border-t border-border/60 bg-background/95 px-3 py-2`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{r(!n)},className:`flex w-full items-center gap-1.5 text-xs font-medium text-tone-warning-fg`,children:[n?(0,$.jsx)(Ft,{className:`h-3.5 w-3.5`}):(0,$.jsx)(Pt,{className:`h-3.5 w-3.5`}),(0,$.jsx)(zt,{className:`h-3.5 w-3.5`}),a>0?`Waiting on you (${a})`:`Expired requests`]}),!n&&(0,$.jsx)(`div`,{className:`mt-2 flex max-h-[45vh] flex-col gap-2 overflow-y-auto`,children:t.map(e=>(0,$.jsx)(An,{decision:e},Nn(e)))})]})}function Hn({count:e}){return e?(0,$.jsxs)(un,{"data-testid":`decisions-badge`,title:`${e} waiting on you`,className:`bg-tone-warning/20 text-tone-warning-fg border border-tone-warning/40 h-[18px] gap-0.5 px-1 rounded-full text-[11px] leading-none`,children:[(0,$.jsx)(zt,{className:`h-2.5 w-2.5`}),e]}):null}var Un=[{re:/`([^`]+)`/,recurse:!1,wrap:(e,t)=>(0,$.jsx)(`code`,{className:`rounded bg-muted px-1 font-mono text-[0.9em]`,children:e},t)},{re:/\*\*([^*]+)\*\*/,recurse:!0,wrap:(e,t)=>(0,$.jsx)(`strong`,{className:`font-semibold text-foreground/90`,children:e},t)},{re:/__([^_]+)__/,recurse:!0,wrap:(e,t)=>(0,$.jsx)(`strong`,{className:`font-semibold text-foreground/90`,children:e},t)},{re:/~~([^~]+)~~/,recurse:!0,wrap:(e,t)=>(0,$.jsx)(`s`,{children:e},t)},{re:/\*([^*]+)\*/,recurse:!0,wrap:(e,t)=>(0,$.jsx)(`em`,{children:e},t)},{re:/_([^_]+)_/,recurse:!0,wrap:(e,t)=>(0,$.jsx)(`em`,{children:e},t)},{re:/\[([^\]]+)\]\([^)]+\)/,recurse:!0,wrap:(e,t)=>(0,$.jsx)(`span`,{className:`underline decoration-dotted underline-offset-2`,children:e},t)}];function Wn(e,t=`i`){let n=null;for(let t of Un){let r=t.re.exec(e);r&&r[1]&&(n===null||r.index<n.index)&&(n={index:r.index,length:r[0].length,inner:r[1],pattern:t})}if(!n)return[e];let r=[];n.index>0&&r.push(e.slice(0,n.index));let i=n.pattern.recurse?Wn(n.inner,`${t}x`):n.inner;r.push(n.pattern.wrap(i,`${t}m`));let a=e.slice(n.index+n.length);return a&&r.push(...Wn(a,`${t}r`)),r}var Gn=`sub-coordinator`,Kn=(0,Q.memo)(function({agent:e,depth:n,parent:r,childCount:i,foldedChildren:a,childrenCollapsed:o,thread:s,selected:c,muted:l,followed:u,decisionCount:d,now:f}){let p=T(e=>e.openInboxThread),m=T(e=>e.toggleChatChildrenCollapsed),h=T(e=>e.toggleCoordinatorFollow),g=T(e=>e.toggleCoordinatorMute),_=s?.attention.unread||0,v=R(e),y=s?.previewMessage,b=rt(s)||jt(s),x=Ye(e),S=et(e),C=x.Icon,w=i>0,E=yn(e)===Gn;return(0,$.jsxs)(`li`,{className:`relative group`,style:{paddingLeft:n*16},children:[n>0&&(0,$.jsx)(`div`,{className:`absolute left-2 top-3.5 text-muted-foreground/55`,children:(0,$.jsx)(J,{className:`h-3.5 w-3.5`})}),(0,$.jsxs)(`div`,{className:`absolute right-1.5 top-1.5 z-10 hidden items-center gap-0.5 rounded-md border border-border/60 bg-popover/95 px-0.5 py-0.5 shadow-sm backdrop-blur-sm group-hover:flex`,children:[(0,$.jsx)(`button`,{type:`button`,title:u?`Unfollow (stop pinning into scoped view)`:`Follow (keep visible even in scoped view)`,onClick:t=>{t.stopPropagation(),h(e.id)},className:t(`rounded p-1 transition-colors`,u?`text-primary bg-primary/15 hover:bg-primary/25`:`text-muted-foreground hover:text-foreground hover:bg-muted`),children:(0,$.jsx)(He,{className:`h-3 w-3`})}),(0,$.jsx)(`button`,{type:`button`,title:l?`Unmute`:`Mute (hide from all views)`,onClick:t=>{t.stopPropagation(),g(e.id)},className:t(`rounded p-1 transition-colors`,l?`text-tone-orange-fg bg-tone-orange/15 hover:bg-tone-orange/20`:`text-muted-foreground hover:text-foreground hover:bg-muted`),children:(0,$.jsx)(Pe,{className:`h-3 w-3`})})]}),(0,$.jsxs)(`button`,{className:t(`w-full text-left px-3 py-2.5 flex items-start gap-2.5 hover:bg-muted/50 transition-colors border-b border-border/50`,n>0&&`bg-muted/15`,c&&`bg-muted/60`,l&&`opacity-50`),onClick:()=>p(e.id,s?.messages),children:[(0,$.jsxs)(`div`,{className:`relative shrink-0 mt-0.5`,children:[(0,$.jsx)(on,{agent:e}),e.id!==N&&(0,$.jsx)(_n,{agent:e,now:f,className:`absolute -bottom-0.5 -right-0.5 w-2 h-2`})]}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-1 mb-0.5`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-1 min-w-0`,children:[(0,$.jsx)(bn,{profile:yn(e),className:`text-xs shrink-0`}),(0,$.jsx)(fn,{agent:e,className:`text-xs font-medium`}),E&&(0,$.jsxs)(un,{variant:`outline`,"data-testid":`sub-coordinator-badge`,className:`h-4 shrink-0 px-1 text-[9px] text-muted-foreground`,title:`Sub-coordinator · ${i} ${i===1?`worker`:`workers`}`,children:[`sub-coord · `,i]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0 transition-opacity group-hover:opacity-0`,children:[u&&(0,$.jsx)(He,{className:`h-3 w-3 text-primary`,"aria-label":`Followed`}),b>0&&(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,title:he(b),children:I(f,b)}),(0,$.jsx)(Hn,{count:d}),_>0&&(0,$.jsx)(un,{className:`bg-tone-danger-fg text-background text-[11px] font-semibold leading-none tabular-nums min-w-[18px] h-[18px] flex items-center justify-center shrink-0 px-1 rounded-full`,children:_}),!_&&v&&(0,$.jsx)(un,{className:`bg-tone-warning text-black min-w-[18px] h-[18px] flex items-center justify-center shrink-0 px-1 rounded-full`,title:`Needs response`,children:(0,$.jsx)(Lt,{className:`h-3 w-3`})})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-0.5 text-[10px] text-muted-foreground`,children:[e.id!==N&&(0,$.jsx)(`span`,{title:x.title,className:`inline-flex shrink-0`,children:(0,$.jsx)(C,{className:t(`h-3 w-3`,x.iconColor)})}),(0,$.jsx)(`span`,{className:`truncate`,children:e.id===N?`Checks messages on request`:S||x.label}),Ze(e)&&(0,$.jsx)(`span`,{className:`ml-auto shrink-0`,children:(0,$.jsx)(Je,{context:e.context,expected:!0,size:18})})]}),n===0&&e.spawnedBy&&(0,$.jsx)(`div`,{className:`mb-0.5`,children:(0,$.jsx)(un,{variant:`outline`,className:`max-w-full text-[9px] h-4 px-1.5 text-muted-foreground`,children:(0,$.jsxs)(`span`,{className:`truncate`,children:[`spawned by `,(0,$.jsx)(fn,{agent:r,fallback:e.spawnedBy})]})})}),y&&(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground truncate leading-tight`,children:[k(y.from)?`You: `:``,Wn(le(y).replace(/\s+/g,` `))]})]})]}),w&&(0,$.jsxs)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),m(e.id)},className:`flex w-full items-center gap-1.5 border-b border-border/50 bg-muted/20 py-1 pl-8 pr-3 text-[10px] text-muted-foreground transition-colors hover:bg-muted/40 hover:text-foreground`,"aria-expanded":!o,title:o?`Show ${i} child ${i===1?`agent`:`agents`}`:`Hide children`,children:[o?(0,$.jsx)(Ft,{className:`h-3.5 w-3.5 shrink-0`}):(0,$.jsx)(Pt,{className:`h-3.5 w-3.5 shrink-0`}),(0,$.jsxs)(`span`,{className:`shrink-0 font-medium`,children:[i,` child `,i===1?`agent`:`agents`]}),a&&(0,$.jsx)(Bn,{agents:a,now:f})]})]})});function qn(e){return[e.chatAgentProviderFilter,e.chatAgentStatusFilter,e.chatAgentTagFilter,e.chatAgentCapFilter,e.chatAgentHostFilter].filter(Boolean).length}var Jn=(0,Q.memo)(function({tagsKey:e,capsKey:n}){let r=T(e=>e.set),i=T(e=>e.openAgentSpawn),a=T(e=>e.chatAgentSearch),o=T(e=>e.chatAgentSort),s=T(e=>e.chatAgentSortDir),c=T(e=>e.chatAgentProviderFilter),l=T(e=>e.chatAgentStatusFilter),u=T(e=>e.chatAgentTagFilter),d=T(e=>e.chatAgentCapFilter),f=T(e=>e.chatAgentHostFilter),p=T(e=>e.chatAgentGroupBy),m=T(e=>e.chatAgentFiltersCollapsed),h=T(e=>e.feedObserveAll),g=T(e=>e.setFeedObserveAll),_=T(qn),v=pn(),y=(0,Q.useMemo)(()=>e?e.split(`
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{o as t,p as n,u as r}from"./dist-DeW2Y1R5.js";import{t as i}from"./react-dom-DSFxiC7T.js";import{At as a,C as o,Ct as s,Dt as c,K as l,S as u,T as d,Vt as f,_ as p,b as m,bt as h,ct as g,g as _,h as v,jt as y,kt as b,lt as x,m as S,ot as C,st as w,t as T,v as E,w as ee,x as te,xt as D,y as O,yt as ne}from"./store-BgDALGIX.js";import{O as k,b as A,i as j,m as M,o as re,p as ie,r as ae,t as oe,w as N}from"./provider-display-bWwiuedV.js";import{F as P,G as se,I as ce,R as le,S as F,Z as ue,et as I,f as L,i as R,it as de,j as fe,o as pe,q as me,r as z,rt as B,s as V,st as H,tt as U,v as he,y as W}from"./display-BemJG1f_.js";import{n as ge,r as G,t as _e}from"./PlanGraphPanel-BkaDJp0r.js";import{g as ve,o as ye,t as be}from"./api-CIIVBtAV.js";import{r as xe,s as Se,t as Ce}from"./dialog-uuJ9_geR.js";import{a as we,c as Te,n as Ee,o as De,r as K,s as q,t as Oe}from"./dropdown-menu-BXiNephE.js";import{t as ke}from"./label-BPBzm9FJ.js";import{a as Ae,n as je,t as Me}from"./popover-8w1TWKMG.js";import{t as Ne}from"./switch-DuCA7mrB.js";import{_ as Pe,a as Fe,c as Ie,d as Le,f as Re,g as ze,h as J,l as Be,n as Ve,o as He,s as Ue,t as We,u as Ge,v as Ke}from"./files-DXWcrxOz.js";import{_ as qe,c as Je,d as Ye,h as Xe,l as Ze,o as Qe,t as $e,u as et,v as tt}from"./agent-lineage-kq9TPYFw.js";import{n as nt}from"./radio-Bn0_qc0G.js";import{A as rt,C as it,E as at,F as ot,G as st,L as ct,M as lt,P as ut,R as dt,S as Y,T as ft,U as pt,_ as mt,a as ht,b as gt,c as _t,d as vt,f as yt,g as bt,i as xt,l as St,m as X,n as Ct,o as wt,r as Tt,s as Et,t as Dt,u as Ot,x as kt,y as At,z as jt}from"./TraceView-B99Uu2yT.js";import{t as Mt}from"./bot-B0NpDNhr.js";import{t as Nt}from"./check-B3M9Ug1P.js";import{t as Pt}from"./chevron-down-BoG3JCZn.js";import{t as Ft}from"./chevron-right-iljytE0x.js";import{t as It}from"./chevron-up-Bv3yC5ma.js";import{t as Lt}from"./circle-alert-CryagaZd.js";import{t as Rt}from"./circle-check-CkUkN96J.js";import{n as zt}from"./zap-DGuDTw4w.js";import{t as Bt}from"./download-KgtpDbt5.js";import{t as Vt}from"./eye-BAP6fHrX.js";import{t as Ht}from"./file-text-CKuoMR2U.js";import{t as Ut}from"./flag-CnEG9PH-.js";import{t as Wt}from"./folder-open-CBUCMSlu.js";import{t as Gt}from"./gauge-BIODY-BQ.js";import{t as Kt}from"./hourglass-txu4ax6n.js";import{t as qt}from"./list-checks-CwnS3hly.js";import{t as Jt}from"./loader-circle-BfPd4kOD.js";import{t as Yt}from"./message-square-C-1G8dMM.js";import{t as Xt}from"./minimize-2-BkK6XoMP.js";import{t as Zt}from"./paperclip-CNpKZKum.js";import{t as Qt}from"./pencil-B1Hf2V_J.js";import{t as $t}from"./plus-D5Ek4e2S.js";import{t as en}from"./power-6tZOhYPg.js";import{r as tn}from"./workflow-marker-CzOsB8BM.js";import{t as nn}from"./search-DjzbnTbf.js";import{t as rn}from"./terminal-Bl2u7KxT.js";import{t as an}from"./triangle-alert-BBNhfgMi.js";import{t as on}from"./agent-type-icon-CXSLrKiq.js";import{t as sn}from"./volume-2-XrcRKD9Z.js";import{t as cn}from"./x-Bge17hWJ.js";import{t as ln}from"./zoom-in-Bs8Qv8VL.js";import{t as Z}from"./button-Do6Z3vvn.js";import{t as un}from"./badge-DqJRtj_p.js";import{t as dn}from"./copy-button-CjOj4HEf.js";import{t as fn}from"./agent-name-C_7F4DFR.js";import{f as pn,n as mn,s as hn}from"./use-selectors-0X_UZkk-.js";import{t as gn}from"./input-CsTB6jIx.js";import{t as _n}from"./status-dot-C703YIy1.js";import{t as vn}from"./terminal-viewer-Dh8dSC7e.js";import{n as yn,t as bn}from"./profile-icon-_SMuSbYF.js";import{t as xn}from"./textarea-hs6Mpyfl.js";import{t as Sn}from"./formatted-body-qy2nTD_1.js";import{a as Cn,i as wn,n as Tn,o as En,r as Dn,t as On}from"./MessageBubble-BOkmEvgZ.js";import{t as kn}from"./use-agent-terminal-CRUVDvLC.js";import{i as An,n as jn,r as Mn,t as Nn}from"./use-decisions-CoaqRh4l.js";import{n as Pn}from"./run-card-BCro-Odj.js";import{n as Fn,r as In,t as Ln}from"./esm-ZSuD7QuY.js";var Q=e(n(),1);function Rn(e,t,n,r,i){if(i.includes(e))return!1;if(r.includes(e)||n)return!0;let a=t[e];return!!(a&&k(a.spawnedBy??``))}function zn(){let e=T(e=>e.agents),t=T(e=>e.agentsById),n=T(e=>e.showBuiltIns),r=T(e=>e.showOffline),i=T(e=>e.chatAgentSearch),a=T(e=>e.chatAgentProviderFilter),o=T(e=>e.chatAgentStatusFilter),s=T(e=>e.chatAgentTagFilter),c=T(e=>e.chatAgentCapFilter),l=T(e=>e.chatAgentHostFilter),u=T(e=>e.chatAgentSort),d=T(e=>e.chatAgentSortDir),f=T(e=>e.managedPolicies),p=T(e=>e.feedObserveAll),m=T(e=>e.coordinatorFollows),h=T(e=>e.coordinatorMutes),g=hn();return(0,Q.useMemo)(()=>{let _=new Set(g.map(e=>e.peer)),v=de(e,n,f);if(r||(v=v.filter(e=>e.status!==`offline`)),v=p?v.filter(e=>!h.includes(e.id)):v.filter(e=>Rn(e.id,t,_.has(e.id),m,h)),i){let e=i.toLowerCase();v=v.filter(t=>t.id.toLowerCase().includes(e)||(t.name||``).toLowerCase().includes(e)||(t.label||``).toLowerCase().includes(e)||(t.tags||[]).some(t=>t.toLowerCase().includes(e))||(t.capabilities||[]).some(t=>t.toLowerCase().includes(e)))}a&&(v=v.filter(e=>V(e)===a)),o&&(v=v.filter(e=>e.status===o)),s&&(v=v.filter(e=>(e.tags||[]).includes(s))),c&&(v=v.filter(e=>(e.capabilities||[]).includes(c))),l&&(v=v.filter(e=>(e.machine||``)===l));let y=d===`desc`?-1:1;return[...v].sort((e,t)=>u===`name`?L(e).localeCompare(L(t))*y:u===`lastSeen`?at(U(e.lastSeen),U(t.lastSeen),y)||L(e).localeCompare(L(t)):((H[e.status]??9)-(H[t.status]??9))*y||L(e).localeCompare(L(t)))},[e,t,n,r,f,i,a,o,s,c,l,u,d,p,m,h,g])}var $=r();function Bn({agents:e,now:t}){return(0,$.jsx)(`span`,{"data-testid":`child-agent-strip`,className:`ml-auto flex min-w-0 flex-1 justify-end overflow-hidden py-0.5 pl-2`,children:e.map(e=>{let n=yn(e);return(0,$.jsxs)(`span`,{title:n?`${L(e)} · ${n}`:L(e),className:`relative h-3.5 min-w-[7px] shrink basis-[18px] last:shrink-0 last:basis-3.5`,children:[(0,$.jsx)(on,{agent:e,className:`h-3.5 w-3.5 border-0 bg-transparent`}),n&&(0,$.jsx)(bn,{profile:n,className:`absolute -left-px -top-1 text-[9px]`}),(0,$.jsx)(_n,{agent:e,now:t,className:`absolute -bottom-0.5 left-0 h-1.5 w-1.5 ring-1 ring-background`})]},e.id)})})}function Vn({agentId:e}){let t=jn(e),n=T(e=>e.decisionsDockCollapsed),r=T(e=>e.setDecisionsDockCollapsed),i=s();if(!t.length)return null;let a=l(t,i);return(0,$.jsxs)(`div`,{"data-testid":`decisions-dock`,className:`shrink-0 border-t border-border/60 bg-background/95 px-3 py-2`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{r(!n)},className:`flex w-full items-center gap-1.5 text-xs font-medium text-tone-warning-fg`,children:[n?(0,$.jsx)(Ft,{className:`h-3.5 w-3.5`}):(0,$.jsx)(Pt,{className:`h-3.5 w-3.5`}),(0,$.jsx)(zt,{className:`h-3.5 w-3.5`}),a>0?`Waiting on you (${a})`:`Expired requests`]}),!n&&(0,$.jsx)(`div`,{className:`mt-2 flex max-h-[45vh] flex-col gap-2 overflow-y-auto`,children:t.map(e=>(0,$.jsx)(An,{decision:e},Nn(e)))})]})}function Hn({count:e}){return e?(0,$.jsxs)(un,{"data-testid":`decisions-badge`,title:`${e} waiting on you`,className:`bg-tone-warning/20 text-tone-warning-fg border border-tone-warning/40 h-[18px] gap-0.5 px-1 rounded-full text-[11px] leading-none`,children:[(0,$.jsx)(zt,{className:`h-2.5 w-2.5`}),e]}):null}var Un=[{re:/`([^`]+)`/,recurse:!1,wrap:(e,t)=>(0,$.jsx)(`code`,{className:`rounded bg-muted px-1 font-mono text-[0.9em]`,children:e},t)},{re:/\*\*([^*]+)\*\*/,recurse:!0,wrap:(e,t)=>(0,$.jsx)(`strong`,{className:`font-semibold text-foreground/90`,children:e},t)},{re:/__([^_]+)__/,recurse:!0,wrap:(e,t)=>(0,$.jsx)(`strong`,{className:`font-semibold text-foreground/90`,children:e},t)},{re:/~~([^~]+)~~/,recurse:!0,wrap:(e,t)=>(0,$.jsx)(`s`,{children:e},t)},{re:/\*([^*]+)\*/,recurse:!0,wrap:(e,t)=>(0,$.jsx)(`em`,{children:e},t)},{re:/_([^_]+)_/,recurse:!0,wrap:(e,t)=>(0,$.jsx)(`em`,{children:e},t)},{re:/\[([^\]]+)\]\([^)]+\)/,recurse:!0,wrap:(e,t)=>(0,$.jsx)(`span`,{className:`underline decoration-dotted underline-offset-2`,children:e},t)}];function Wn(e,t=`i`){let n=null;for(let t of Un){let r=t.re.exec(e);r&&r[1]&&(n===null||r.index<n.index)&&(n={index:r.index,length:r[0].length,inner:r[1],pattern:t})}if(!n)return[e];let r=[];n.index>0&&r.push(e.slice(0,n.index));let i=n.pattern.recurse?Wn(n.inner,`${t}x`):n.inner;r.push(n.pattern.wrap(i,`${t}m`));let a=e.slice(n.index+n.length);return a&&r.push(...Wn(a,`${t}r`)),r}var Gn=`sub-coordinator`,Kn=(0,Q.memo)(function({agent:e,depth:n,parent:r,childCount:i,foldedChildren:a,childrenCollapsed:o,thread:s,selected:c,muted:l,followed:u,decisionCount:d,now:f}){let p=T(e=>e.openInboxThread),m=T(e=>e.toggleChatChildrenCollapsed),h=T(e=>e.toggleCoordinatorFollow),g=T(e=>e.toggleCoordinatorMute),_=s?.attention.unread||0,v=R(e),y=s?.previewMessage,b=rt(s)||jt(s),x=Ye(e),S=et(e),C=x.Icon,w=i>0,E=yn(e)===Gn;return(0,$.jsxs)(`li`,{className:`relative group`,style:{paddingLeft:n*16},children:[n>0&&(0,$.jsx)(`div`,{className:`absolute left-2 top-3.5 text-muted-foreground/55`,children:(0,$.jsx)(J,{className:`h-3.5 w-3.5`})}),(0,$.jsxs)(`div`,{className:`absolute right-1.5 top-1.5 z-10 hidden items-center gap-0.5 rounded-md border border-border/60 bg-popover/95 px-0.5 py-0.5 shadow-sm backdrop-blur-sm group-hover:flex`,children:[(0,$.jsx)(`button`,{type:`button`,title:u?`Unfollow (stop pinning into scoped view)`:`Follow (keep visible even in scoped view)`,onClick:t=>{t.stopPropagation(),h(e.id)},className:t(`rounded p-1 transition-colors`,u?`text-primary bg-primary/15 hover:bg-primary/25`:`text-muted-foreground hover:text-foreground hover:bg-muted`),children:(0,$.jsx)(He,{className:`h-3 w-3`})}),(0,$.jsx)(`button`,{type:`button`,title:l?`Unmute`:`Mute (hide from all views)`,onClick:t=>{t.stopPropagation(),g(e.id)},className:t(`rounded p-1 transition-colors`,l?`text-tone-orange-fg bg-tone-orange/15 hover:bg-tone-orange/20`:`text-muted-foreground hover:text-foreground hover:bg-muted`),children:(0,$.jsx)(Pe,{className:`h-3 w-3`})})]}),(0,$.jsxs)(`button`,{className:t(`w-full text-left px-3 py-2.5 flex items-start gap-2.5 hover:bg-muted/50 transition-colors border-b border-border/50`,n>0&&`bg-muted/15`,c&&`bg-muted/60`,l&&`opacity-50`),onClick:()=>p(e.id,s?.messages),children:[(0,$.jsxs)(`div`,{className:`relative shrink-0 mt-0.5`,children:[(0,$.jsx)(on,{agent:e}),e.id!==N&&(0,$.jsx)(_n,{agent:e,now:f,className:`absolute -bottom-0.5 -right-0.5 w-2 h-2`})]}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-1 mb-0.5`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-1 min-w-0`,children:[(0,$.jsx)(bn,{profile:yn(e),className:`text-xs shrink-0`}),(0,$.jsx)(fn,{agent:e,className:`text-xs font-medium`}),E&&(0,$.jsxs)(un,{variant:`outline`,"data-testid":`sub-coordinator-badge`,className:`h-4 shrink-0 px-1 text-[9px] text-muted-foreground`,title:`Sub-coordinator · ${i} ${i===1?`worker`:`workers`}`,children:[`sub-coord · `,i]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0 transition-opacity group-hover:opacity-0`,children:[u&&(0,$.jsx)(He,{className:`h-3 w-3 text-primary`,"aria-label":`Followed`}),b>0&&(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,title:he(b),children:I(f,b)}),(0,$.jsx)(Hn,{count:d}),_>0&&(0,$.jsx)(un,{className:`bg-tone-danger-fg text-background text-[11px] font-semibold leading-none tabular-nums min-w-[18px] h-[18px] flex items-center justify-center shrink-0 px-1 rounded-full`,children:_}),!_&&v&&(0,$.jsx)(un,{className:`bg-tone-warning text-black min-w-[18px] h-[18px] flex items-center justify-center shrink-0 px-1 rounded-full`,title:`Needs response`,children:(0,$.jsx)(Lt,{className:`h-3 w-3`})})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-0.5 text-[10px] text-muted-foreground`,children:[e.id!==N&&(0,$.jsx)(`span`,{title:x.title,className:`inline-flex shrink-0`,children:(0,$.jsx)(C,{className:t(`h-3 w-3`,x.iconColor)})}),(0,$.jsx)(`span`,{className:`truncate`,children:e.id===N?`Checks messages on request`:S||x.label}),Ze(e)&&(0,$.jsx)(`span`,{className:`ml-auto shrink-0`,children:(0,$.jsx)(Je,{context:e.context,expected:!0,size:18})})]}),n===0&&e.spawnedBy&&(0,$.jsx)(`div`,{className:`mb-0.5`,children:(0,$.jsx)(un,{variant:`outline`,className:`max-w-full text-[9px] h-4 px-1.5 text-muted-foreground`,children:(0,$.jsxs)(`span`,{className:`truncate`,children:[`spawned by `,(0,$.jsx)(fn,{agent:r,fallback:e.spawnedBy})]})})}),y&&(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground truncate leading-tight`,children:[k(y.from)?`You: `:``,Wn(le(y).replace(/\s+/g,` `))]})]})]}),w&&(0,$.jsxs)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),m(e.id)},className:`flex w-full items-center gap-1.5 border-b border-border/50 bg-muted/20 py-1 pl-8 pr-3 text-[10px] text-muted-foreground transition-colors hover:bg-muted/40 hover:text-foreground`,"aria-expanded":!o,title:o?`Show ${i} child ${i===1?`agent`:`agents`}`:`Hide children`,children:[o?(0,$.jsx)(Ft,{className:`h-3.5 w-3.5 shrink-0`}):(0,$.jsx)(Pt,{className:`h-3.5 w-3.5 shrink-0`}),(0,$.jsxs)(`span`,{className:`shrink-0 font-medium`,children:[i,` child `,i===1?`agent`:`agents`]}),a&&(0,$.jsx)(Bn,{agents:a,now:f})]})]})});function qn(e){return[e.chatAgentProviderFilter,e.chatAgentStatusFilter,e.chatAgentTagFilter,e.chatAgentCapFilter,e.chatAgentHostFilter].filter(Boolean).length}var Jn=(0,Q.memo)(function({tagsKey:e,capsKey:n}){let r=T(e=>e.set),i=T(e=>e.openAgentSpawn),a=T(e=>e.chatAgentSearch),o=T(e=>e.chatAgentSort),s=T(e=>e.chatAgentSortDir),c=T(e=>e.chatAgentProviderFilter),l=T(e=>e.chatAgentStatusFilter),u=T(e=>e.chatAgentTagFilter),d=T(e=>e.chatAgentCapFilter),f=T(e=>e.chatAgentHostFilter),p=T(e=>e.chatAgentGroupBy),m=T(e=>e.chatAgentFiltersCollapsed),h=T(e=>e.feedObserveAll),g=T(e=>e.setFeedObserveAll),_=T(qn),v=pn(),y=(0,Q.useMemo)(()=>e?e.split(`
2
2
  `):[],[e]),b=(0,Q.useMemo)(()=>n?n.split(`
3
3
  `):[],[n]);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`p-3 border-b border-border space-y-2`,children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(nn,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground pointer-events-none`}),(0,$.jsx)(gn,{placeholder:`Search agents...`,value:a,onChange:e=>r({chatAgentSearch:e.target.value}),className:`pl-8 h-7 text-xs`})]}),(0,$.jsxs)(`div`,{className:`flex h-7 items-center rounded-md border border-border bg-background p-0.5 text-xs`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>g(!1),title:`Show only conversations where you're in the audience (agents you spawned or messaged)`,"aria-pressed":!h,className:t(`flex h-full flex-1 items-center justify-center gap-1.5 rounded-[5px] transition-colors`,h?`text-muted-foreground hover:text-foreground`:`bg-primary/15 text-primary font-medium`),children:[(0,$.jsx)(Re,{className:`h-3.5 w-3.5`}),`Scoped`]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>g(!0),title:`Show every agent conversation, including agent-to-agent chatter`,"aria-pressed":h,className:t(`flex h-full flex-1 items-center justify-center gap-1.5 rounded-[5px] transition-colors`,h?`bg-primary/15 text-primary font-medium`:`text-muted-foreground hover:text-foreground`),children:[(0,$.jsx)(Vt,{className:`h-3.5 w-3.5`}),`All`]})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>r({chatAgentFiltersCollapsed:!m}),className:`sm:hidden flex w-full items-center justify-between h-6 px-1.5 text-xs rounded-md border border-border bg-background text-muted-foreground`,children:[(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,$.jsx)(q,{className:`w-3.5 h-3.5`}),`Filters & sort`,_>0&&(0,$.jsx)(un,{className:`bg-primary/20 text-primary text-[10px] h-4 min-w-4 px-1 flex items-center justify-center`,children:_})]}),m?(0,$.jsx)(Pt,{className:`w-3.5 h-3.5`}):(0,$.jsx)(It,{className:`w-3.5 h-3.5`})]}),(0,$.jsxs)(`div`,{className:t(`space-y-2`,m?`hidden`:`block`,`sm:block`),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsxs)(`select`,{value:o,onChange:e=>r({chatAgentSort:e.target.value}),className:`flex-1 h-6 text-xs rounded-md border border-border bg-background px-1.5 text-foreground`,children:[(0,$.jsx)(`option`,{value:`status`,children:`By status`}),(0,$.jsx)(`option`,{value:`name`,children:`By name`}),(0,$.jsx)(`option`,{value:`lastSeen`,children:`By last seen`}),(0,$.jsx)(`option`,{value:`lastMessage`,children:`By last activity`})]}),(0,$.jsx)(Z,{variant:`ghost`,size:`icon-xs`,onClick:()=>r({chatAgentSortDir:s===`asc`?`desc`:`asc`}),children:s===`asc`?(0,$.jsx)(qe,{className:`w-3.5 h-3.5`}):(0,$.jsx)(tt,{className:`w-3.5 h-3.5`})})]}),(0,$.jsxs)(`select`,{value:p,onChange:e=>r({chatAgentGroupBy:e.target.value}),className:`w-full h-6 text-xs rounded-md border border-border bg-background px-1.5 text-foreground`,children:[(0,$.jsx)(`option`,{value:``,children:`No grouping`}),(0,$.jsx)(`option`,{value:`project`,children:`Group by project`})]}),(0,$.jsxs)(`div`,{className:`flex gap-1`,children:[(0,$.jsxs)(`select`,{value:c,onChange:e=>r({chatAgentProviderFilter:e.target.value}),className:`flex-1 h-6 text-xs rounded-md border border-border bg-background px-1.5 text-foreground`,children:[(0,$.jsx)(`option`,{value:``,children:`All types`}),oe().map(e=>(0,$.jsx)(`option`,{value:e,children:ae(e)},e)),(0,$.jsx)(`option`,{value:`agent`,children:`Agent`}),(0,$.jsx)(`option`,{value:`user`,children:`User`})]}),(0,$.jsxs)(`select`,{value:l,onChange:e=>r({chatAgentStatusFilter:e.target.value}),className:`flex-1 h-6 text-xs rounded-md border border-border bg-background px-1.5 text-foreground`,children:[(0,$.jsx)(`option`,{value:``,children:`All status`}),(0,$.jsx)(`option`,{value:`online`,children:`Online`}),(0,$.jsx)(`option`,{value:`idle`,children:`Idle`}),(0,$.jsx)(`option`,{value:`busy`,children:`Busy`}),(0,$.jsx)(`option`,{value:`offline`,children:`Offline`})]}),v.length>1&&(0,$.jsxs)(`select`,{value:f,onChange:e=>r({chatAgentHostFilter:e.target.value}),className:`flex-1 h-6 text-xs rounded-md border border-border bg-background px-1.5 text-foreground`,children:[(0,$.jsx)(`option`,{value:``,children:`All hosts`}),v.map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))]})]}),(y.length>0||b.length>0)&&(0,$.jsxs)(`div`,{className:`flex gap-1`,children:[y.length>0&&(0,$.jsxs)(`select`,{value:u,onChange:e=>r({chatAgentTagFilter:e.target.value}),className:`flex-1 h-6 text-xs rounded-md border border-border bg-background px-1.5 text-foreground`,children:[(0,$.jsx)(`option`,{value:``,children:`All tags`}),y.map(e=>(0,$.jsxs)(`option`,{value:e,children:[`#`,e]},e))]}),b.length>0&&(0,$.jsxs)(`select`,{value:d,onChange:e=>r({chatAgentCapFilter:e.target.value}),className:`flex-1 h-6 text-xs rounded-md border border-border bg-background px-1.5 text-foreground`,children:[(0,$.jsx)(`option`,{value:``,children:`All caps`}),b.map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))]})]})]})]}),(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full shrink-0 items-center gap-2.5 border-b border-border px-3 py-2 text-left transition-colors hover:bg-muted/50`,onClick:i,children:[(0,$.jsx)(`div`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-full border border-dashed border-primary/50 bg-primary/10 text-primary`,children:(0,$.jsx)($t,{className:`h-3.5 w-3.5`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium`,children:`New Agent`}),(0,$.jsx)(`div`,{className:`truncate text-[10px] text-muted-foreground`,children:`Spawn a fresh chat agent`})]})]})]})});function Yn({threads:e}){let t=T(e=>e.selectedInboxThread),n=T(e=>e.chatAgentSearch),r=T(e=>e.chatAgentSort),i=T(e=>e.chatAgentSortDir),a=T(e=>e.chatAgentGroupBy),o=T(qn),c=T(e=>e.agentsById),l=T(e=>e.chatCollapsedChildren),u=T(e=>e.feedObserveAll),d=T(e=>e.setFeedObserveAll),f=T(e=>e.coordinatorFollows),p=T(e=>e.coordinatorMutes),m=s(),h=zn(),g=(0,Q.useMemo)(()=>new Set(l),[l]),_=(0,Q.useMemo)(()=>{let t=new Map;for(let n of e)t.set(n.peer,n);return t},[e]),v=(0,Q.useMemo)(()=>{if(r!==`lastMessage`)return h;let e=i===`desc`?-1:1;return[...h].sort((t,n)=>at(jt(_.get(t.id)),jt(_.get(n.id)),e)||L(t).localeCompare(L(n)))},[h,r,i,_]),y=(0,Q.useMemo)(()=>[...new Set(h.flatMap(e=>e.tags||[]))].join(`
4
4
  `),[h]),b=(0,Q.useMemo)(()=>[...new Set(h.flatMap(e=>B(e.capabilities||[])))].join(`
5
5
  `),[h]),x=(0,Q.useMemo)(()=>{if(a!==`project`)return null;let e=new Map;for(let t of v){let n=et(t)||`No project`,r=e.get(n);r?r.push(t):e.set(n,[t])}return[...e.entries()].sort((e,t)=>e[0].localeCompare(t[0]))},[v,a]),S=(0,Q.useMemo)(()=>$e(v,c,m,g),[v,c,m,g]),C=Mn();function w(e){let{agent:n}=e,r=g.has(n.id);return(0,$.jsx)(Kn,{agent:n,depth:e.depth,parent:e.parent,childCount:e.children.length,foldedChildren:e.folded,childrenCollapsed:r,thread:_.get(n.id),selected:t===n.id,muted:p.includes(n.id),followed:f.includes(n.id),decisionCount:C.get(n.id),now:m},n.id)}return(0,$.jsxs)(`div`,{className:`flex flex-col h-full border-r border-border min-w-0`,children:[(0,$.jsx)(Jn,{tagsKey:y,capsKey:b}),(0,$.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:v.length===0?!u&&!n&&o===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-10 text-center px-6`,children:[(0,$.jsx)(He,{className:`w-8 h-8 text-muted-foreground/40 mb-3`}),(0,$.jsx)(`p`,{className:`text-xs font-medium text-foreground/80`,children:`No conversations in your audience`}),(0,$.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:`Agents you spawn or message show up here.`}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>d(!0),className:`mt-3 inline-flex items-center gap-1.5 rounded-md border border-border bg-background px-2.5 py-1 text-[11px] text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground`,children:[(0,$.jsx)(Vt,{className:`h-3.5 w-3.5`}),` Show all agents`]})]}):(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-10 text-center px-4`,children:[(0,$.jsx)(Mt,{className:`w-8 h-8 text-muted-foreground/40 mb-2`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No agents match filters`})]}):x?x.map(([e,t])=>(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center gap-1.5 border-b border-border/50 bg-background/95 px-3 py-1 text-[10px] font-medium uppercase tracking-wide text-muted-foreground backdrop-blur`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:e}),(0,$.jsx)(`span`,{className:`text-muted-foreground/50`,children:t.length})]}),(0,$.jsx)(`ul`,{children:$e(t,c,m,g).map(w)})]},e)):(0,$.jsx)(`ul`,{children:S.map(w)})})]})}function Xn(e,t,n,r){let i=T(e=>e.loadOlder),a=T(e=>e.loadChatAround),o=T(e=>e.loadNewer);return{loadOlderForAgent:(0,Q.useCallback)(()=>{!e||!t||n||i(e)},[e,t,n,i]),loadNewerForAgent:(0,Q.useCallback)(()=>{!e||!r||o(e)},[e,o,r]),loadAroundForAgent:(0,Q.useCallback)(t=>e?a(e,t):Promise.resolve(),[e,a])}}var Zn=[{name:`/reply`,source:`skill`,description:`Reply to a relay message by id`,argumentHint:`<messageId> <body>`},{name:`/message`,source:`skill`,description:`Send a relay message to an agent, label, tag, or broadcast`,argumentHint:`<target> <body>`},{name:`/pair`,source:`skill`,description:`Start or manage a two-agent pair session`},{name:`/react`,source:`skill`,description:`Add a reaction to a relay message`,argumentHint:`<messageId> <emoji>`},{name:`/read-message`,source:`skill`,description:`Fetch a full relay message by id`,argumentHint:`<messageId>`},{name:`/send-claimable`,source:`skill`,description:`Enqueue a claimable work item for one agent to claim`},{name:`/status`,source:`skill`,description:`Show this agent's relay status`},{name:`/tags`,source:`skill`,description:`List or update this agent's relay tags`},{name:`/label`,source:`skill`,description:`Read, set, or clear this agent's relay label`},{name:`/disconnect`,source:`skill`,description:`End the current relay pair session`}],Qn={"/clear":{description:`Clear conversation history and free up context`},"/compact":{description:`Compact the conversation to reclaim context`,argumentHint:`[instructions]`},"/model":{description:`Switch the active model`,argumentHint:`[model]`},"/help":{description:`Show help`},"/new":{description:`Start a new thread`}};function $n(e,t=!1){return[...((e?j(e):void 0)?.slashCommands??[]).map(e=>({name:e,source:`builtin`,...Qn[e],...e===`/compact`&&!t?{argumentHint:void 0}:{}})),...Zn]}var er=15e3;function tr({agentId:e,className:n,now:r=Date.now()}){let i=T(t=>t.presenceByAgent[e]),a=T(e=>e.usersById),o=ve(),s=(i??[]).filter(e=>e.clientId!==o);if(s.length===0)return null;let c=Array.from(new Set(s.map(e=>F(e.userId,a)))),l=s.some(e=>e.typing&&r-e.lastSeen<er),u=c.length===1?c[0]:`${c.length} viewers`,d=l?Qt:Vt;return(0,$.jsxs)(`span`,{title:`${c.join(`, `)}${l?` · typing`:` · viewing`}`,className:t(`inline-flex items-center gap-1 rounded-full bg-muted/40 px-2 py-0.5 text-[11px] text-muted-foreground`,n),children:[(0,$.jsx)(d,{className:t(`h-3 w-3 shrink-0`,l&&`text-tone-success-fg`)}),(0,$.jsxs)(`span`,{className:`truncate max-w-[12ch]`,children:[u,l&&c.length===1?` is typing…`:``]})]})}function nr({runs:e}){let t=T(e=>e.agentsById),n=Date.now();return(0,$.jsx)($.Fragment,{children:e.map(e=>(0,$.jsx)(Pn,{run:e,agentsById:t,now:n},e.runId))})}function rr({agentId:e}){let t=T(e=>e.workflowLiveRuns),n=(0,Q.useMemo)(()=>t.filter(t=>t.coordinator===e),[t,e]),[r,i]=(0,Q.useState)(!1);if(!n.length)return null;let a=n.length===1?`Running workflow: ${n[0].workflow}`:`${n.length} running workflows`;return(0,$.jsxs)(Me,{open:r,onOpenChange:i,children:[(0,$.jsx)(Ae,{asChild:!0,children:(0,$.jsxs)(Z,{variant:`ghost`,size:`icon-sm`,"data-testid":`chat-workflow-runs`,"aria-label":a,title:a,className:`wf-marker relative`,children:[(0,$.jsx)(tn,{className:`w-3.5 h-3.5`}),n.length>1&&(0,$.jsx)(`span`,{className:`absolute -right-0.5 -top-0.5 font-mono text-[9px] font-semibold tabular-nums leading-none`,children:n.length})]})}),(0,$.jsx)(je,{align:`end`,collisionPadding:16,"data-testid":`chat-workflow-run-views`,"aria-label":`Running workflows`,className:`max-h-[70vh] w-[min(46rem,calc(100vw-2rem))] gap-2 overflow-y-auto`,children:r&&(0,$.jsx)(nr,{runs:n})})]})}var ir=[{title:`Agent activity`,items:[[`narration`,`Progress notes`],[`tools`,`Tool calls`],[`reasoning`,`Reasoning`]]},{title:`Injected context`,items:[[`memories`,`Project memories`],[`startup`,`Startup context`],[`injected`,`Other injected context`]]},{title:`Messages`,items:[[`agentMessages`,`Agent-to-agent messages`]]},{title:`Notices`,items:[[`workflow`,`Workflow runs`],[`land`,`Land & merge`],[`task`,`Tasks`],[`agents`,`Agents & spawns`],[`other`,`Other notices`]]},{title:`Delivery`,items:[[`undelivered`,`Not delivered to the agent (FYI)`]]}],ar={calm:`Calm`,everything:`Everything`};function or({category:e,label:t}){let n=(0,Q.useId)(),r=T(e=>e.chatFilters),i=T(e=>e.setChatFilters);return(0,$.jsxs)(`div`,{className:`flex min-h-9 items-center justify-between gap-3`,children:[(0,$.jsx)(`label`,{htmlFor:n,className:`min-w-0 flex-1 text-sm`,children:t}),(0,$.jsx)(Ne,{id:n,checked:r[e],onCheckedChange:t=>Cn(()=>void i({...r,[e]:t}))})]})}function sr(){let e=T(e=>e.chatFilters),n=T(e=>e.setChatFilters),r=M(e);return(0,$.jsxs)(Me,{children:[(0,$.jsx)(Ae,{asChild:!0,children:(0,$.jsx)(Z,{variant:`ghost`,size:`icon-sm`,"aria-label":`Chat filters`,title:`Chat filters: ${r?ar[r]:`custom`}`,className:t(`relative`,r!==`calm`&&`text-primary`),children:(0,$.jsx)(q,{className:`w-3.5 h-3.5`})})}),(0,$.jsxs)(je,{align:`end`,collisionPadding:16,"aria-label":`Chat filters`,className:`max-h-[min(75vh,var(--radix-popover-content-available-height))] w-[min(22rem,calc(100vw-2rem))] gap-3 overflow-y-auto overscroll-contain`,children:[(0,$.jsx)(`div`,{className:`grid grid-cols-2 gap-1 rounded-lg bg-muted p-1`,role:`group`,"aria-label":`Presets`,children:Object.keys(ie).map(e=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":r===e,onClick:()=>Cn(()=>void n(ie[e])),className:t(`min-h-9 rounded-md text-sm font-medium transition-colors`,r===e?`bg-background shadow-sm`:`text-muted-foreground hover:text-foreground`),children:ar[e]},e))}),(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[r===`calm`?`Only the notices that woke the agent.`:r===`everything`?`Every step, tool call, injected context and FYI.`:`Your own mix.`,` Your messages and the agent's replies always show.`]}),ir.map(e=>(0,$.jsxs)(`section`,{"aria-label":e.title,children:[(0,$.jsx)(`h3`,{className:`mb-0.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:e.title}),e.items.map(([e,t])=>(0,$.jsx)(or,{category:e,label:t},e))]},e.title))]})]})}function cr({selectedInboxThread:e,agent:n,now:r,blockedState:i,thread:a,exportableThread:o,importedHistory:s,showBackButton:c,onBack:l,openAgentDetail:u,openWorkspaceFocus:d,voiceTtsEnabled:f,setVoiceTtsEnabled:p,canOpenTerminal:m,terminalOpening:h,handleOpenTerminal:g,canInterrupt:_,interruptAgent:v,canCompact:b,canClearContext:x,canShutdown:S,openConfirm:C,workspaceAction:w,doAgentAction:T,openFilesForAgent:E,forkFromAgent:ee,markInboxThreadUnread:te,markInboxThreadRead:D,exportThread:O,onOpenSearch:ne}){return(0,$.jsxs)(`div`,{"data-testid":`chat-header`,className:`flex items-center justify-between px-3 md:px-4 py-2.5 md:py-3 border-b border-border shrink-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 md:gap-2.5 min-w-0`,children:[c&&(0,$.jsx)(Z,{variant:`ghost`,size:`icon-sm`,onClick:l,className:`shrink-0 -ml-1`,children:(0,$.jsx)(nt,{className:`w-4 h-4`})}),(0,$.jsxs)(`button`,{type:`button`,className:`flex items-center gap-2 md:gap-2.5 min-w-0 hover:opacity-80 transition-opacity`,onClick:()=>n&&u(n),disabled:!n,children:[(0,$.jsxs)(`div`,{className:`relative shrink-0`,children:[(0,$.jsx)(on,{agent:n}),n?.id!==N&&(0,$.jsx)(_n,{agent:n,now:r,className:`absolute -bottom-0.5 -right-0.5 w-2 h-2`})]}),(0,$.jsxs)(`div`,{className:`min-w-0 text-left`,children:[(0,$.jsxs)(`p`,{className:`flex items-center gap-1 text-sm font-medium truncate`,children:[n&&(0,$.jsx)(bn,{profile:yn(n),className:`shrink-0`}),(0,$.jsx)(fn,{agent:n,fallback:e})]}),n&&(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground truncate`,children:[n.id===N?`Checks messages on request`:i?`blocked: ${i.label}`:n.status,n.machine&&` · ${n.machine}`,typeof n.meta?.cwd==`string`&&n.meta.cwd&&` · ${ue(n.meta.cwd,1)}`]})]})]}),n&&(0,$.jsx)(Qe,{agent:n,compact:!0,className:`hidden @4xl/chat:flex shrink-0`}),n&&Ze(n)&&(0,$.jsx)(Je,{context:n.context,expected:!0}),n?.landState&&(0,$.jsxs)(un,{variant:`outline`,className:t(`shrink-0 border-tone-violet/30 text-tone-violet-fg text-[10px]`,n.branchWorkspaceId&&`cursor-pointer hover:brightness-125 focus:outline-none focus:ring-1 focus:ring-current`),title:n.branchWorkspaceId?`Workspace lifecycle state — click to open this workspace.`:`Workspace lifecycle state`,role:n.branchWorkspaceId?`button`:void 0,tabIndex:n.branchWorkspaceId?0:void 0,onClick:n.branchWorkspaceId?()=>void d(n.branchWorkspaceId):void 0,onKeyDown:n.branchWorkspaceId?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),d(n.branchWorkspaceId))}:void 0,children:[n.landState,n.landWaitReason?` · ${n.landWaitReason}`:``,n.landStateAt?` (${I(r,n.landStateAt)})`:``]}),a?.attention.unread?(0,$.jsxs)(un,{className:`bg-tone-danger/20 text-tone-danger-fg text-xs shrink-0 hidden @2xl/chat:flex`,children:[a.attention.unread,` unread`]}):null,n&&(0,$.jsx)(tr,{agentId:n.id,className:`shrink-0 hidden @3xl/chat:inline-flex`})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-0.5 md:gap-1 shrink-0`,children:n&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(rr,{agentId:n.id}),(0,$.jsx)(dn,{value:n.id,label:`Copy agent ID`,size:`icon-sm`}),(0,$.jsx)(sr,{}),ne&&(0,$.jsx)(Z,{variant:`ghost`,size:`icon-sm`,title:`Search this chat`,onClick:ne,children:(0,$.jsx)(nn,{className:`w-3.5 h-3.5`})}),y.available&&(0,$.jsx)(Z,{variant:`ghost`,size:`icon-sm`,title:f?`Speaking agent responses aloud — click to mute (engine & voice in Settings)`:`Speak agent responses aloud (active chat) — engine & voice in Settings`,className:f?`text-primary`:``,onClick:()=>p(!f),children:f?(0,$.jsx)(sn,{className:`w-3.5 h-3.5`}):(0,$.jsx)(Fe,{className:`w-3.5 h-3.5`})}),m&&(0,$.jsx)(Z,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,disabled:h,title:`Terminal`,onClick:()=>void g(),children:(0,$.jsx)(rn,{className:`w-3.5 h-3.5`})}),_&&(0,$.jsx)(Z,{variant:`ghost`,size:`icon-sm`,className:`text-tone-danger-fg hover:text-tone-danger-fg`,title:`Interrupt`,onClick:v,children:(0,$.jsx)(st,{className:`w-3.5 h-3.5`})}),(n.branchState===`changes`||n.branchState===`idle`)&&n.branchWorkspaceId&&(0,$.jsx)(Z,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex text-tone-warning-fg hover:text-tone-warning-fg`,title:`Mark workspace ready — hand off to the auto-merge`,onClick:()=>C(`Mark Workspace Ready`,`Mark ${L(n)}'s branch ready to land? The relay auto-merge will rebase and land it.`,()=>w(n.branchWorkspaceId,`ready`)),children:(0,$.jsx)(Ut,{className:`w-3.5 h-3.5`})}),b&&(0,$.jsx)(Z,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Compact`,onClick:()=>C(`Compact Agent`,`Compact context for ${L(n)}?`,()=>T(n,`compact`)),children:(0,$.jsx)(Xt,{className:`w-3.5 h-3.5`})}),x&&(0,$.jsx)(Z,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Clear context`,onClick:()=>C(`Clear Context`,`Clear context for ${L(n)}?`,()=>T(n,`clearContext`)),children:(0,$.jsx)(Xe,{className:`w-3.5 h-3.5`})}),S&&(0,$.jsx)(Z,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Shutdown`,onClick:()=>C(`Shutdown Agent`,`Shutdown ${L(n)}?`,()=>T(n,`shutdown`)),children:(0,$.jsx)(en,{className:`w-3.5 h-3.5`})}),n&&typeof n.meta?.cwd==`string`&&n.meta.cwd&&(0,$.jsx)(Z,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Open ${n.meta.cwd} in Files`,onClick:()=>void E(n),children:(0,$.jsx)(Wt,{className:`w-3.5 h-3.5`})}),n&&a&&a.messages.length>0&&(0,$.jsx)(Z,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Fork — spawn new agent with this chat history`,onClick:()=>ee(n.id,a.messages),children:(0,$.jsx)(pt,{className:`w-3.5 h-3.5`})}),a&&(0,$.jsx)(Z,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Mark unread`,onClick:()=>te(e),children:(0,$.jsx)(Ge,{className:`w-3.5 h-3.5`})}),a&&(0,$.jsx)(Z,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Mark read`,onClick:()=>D(a.peer,a.messages),children:(0,$.jsx)(Le,{className:`w-3.5 h-3.5`})}),o&&(0,$.jsx)(Z,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Export thread`,onClick:()=>O({...o,importedHistory:s},`json`),children:(0,$.jsx)(Bt,{className:`w-3.5 h-3.5`})}),(0,$.jsxs)(Oe,{children:[(0,$.jsx)(De,{asChild:!0,children:(0,$.jsx)(Z,{variant:`ghost`,size:`icon-sm`,className:`@4xl/chat:hidden`,children:(0,$.jsx)(Te,{className:`w-3.5 h-3.5`})})}),(0,$.jsxs)(Ee,{align:`end`,children:[m&&(0,$.jsxs)(K,{disabled:h,onClick:()=>void g(),children:[(0,$.jsx)(rn,{className:`w-3.5 h-3.5`}),`Terminal`]}),_&&(0,$.jsxs)(K,{onClick:v,children:[(0,$.jsx)(st,{className:`w-3.5 h-3.5`}),`Interrupt`]}),(n.branchState===`changes`||n.branchState===`idle`)&&n.branchWorkspaceId&&(0,$.jsxs)(K,{onClick:()=>C(`Mark Workspace Ready`,`Mark ${L(n)}'s branch ready to land? The relay auto-merge will rebase and land it.`,()=>w(n.branchWorkspaceId,`ready`)),children:[(0,$.jsx)(Ut,{className:`w-3.5 h-3.5`}),`Mark Ready`]}),b&&(0,$.jsxs)(K,{onClick:()=>C(`Compact Agent`,`Compact context for ${L(n)}?`,()=>T(n,`compact`)),children:[(0,$.jsx)(Xt,{className:`w-3.5 h-3.5`}),`Compact`]}),x&&(0,$.jsxs)(K,{onClick:()=>C(`Clear Context`,`Clear context for ${L(n)}?`,()=>T(n,`clearContext`)),children:[(0,$.jsx)(Xe,{className:`w-3.5 h-3.5`}),`Clear Context`]}),S&&(0,$.jsxs)(K,{onClick:()=>C(`Shutdown Agent`,`Shutdown ${L(n)}?`,()=>T(n,`shutdown`)),children:[(0,$.jsx)(en,{className:`w-3.5 h-3.5`}),`Shutdown`]}),n&&typeof n.meta?.cwd==`string`&&n.meta.cwd&&(0,$.jsxs)(K,{onClick:()=>void E(n),children:[(0,$.jsx)(Wt,{className:`w-3.5 h-3.5`}),`Open Files`]}),n&&a&&a.messages.length>0&&(0,$.jsxs)(K,{onClick:()=>ee(n.id,a.messages),children:[(0,$.jsx)(pt,{className:`w-3.5 h-3.5`}),`Fork`]}),(m||b||x||S)&&(0,$.jsx)(we,{}),a&&(0,$.jsxs)(K,{onClick:()=>te(e),children:[(0,$.jsx)(Ge,{className:`w-3.5 h-3.5`}),`Mark Unread`]}),a&&(0,$.jsxs)(K,{onClick:()=>D(a.peer,a.messages),children:[(0,$.jsx)(Le,{className:`w-3.5 h-3.5`}),`Mark Read`]}),o&&(0,$.jsxs)(K,{onClick:()=>O({...o,importedHistory:s},`json`),children:[(0,$.jsx)(Bt,{className:`w-3.5 h-3.5`}),`Download`]})]})]})]})})]})}var lr=(0,Q.memo)(cr);function ur({query:e,position:t,total:n,onQueryChange:r,onNext:i,onPrev:a,onClose:o}){let s=(0,Q.useRef)(null),c=e.trim().length>0,l=c&&n===0;function u(e){if(e.key===`Escape`){e.preventDefault(),o();return}e.key===`Enter`&&(e.preventDefault(),e.shiftKey?a():i())}return(0,$.jsxs)(`section`,{className:`flex shrink-0 items-center gap-2 border-b border-border bg-card/45 px-3 py-2`,children:[(0,$.jsx)(nn,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,$.jsx)(gn,{ref:s,autoFocus:!0,value:e,onChange:e=>r(e.target.value),onKeyDown:u,placeholder:`Search this chat…`,"aria-label":`Search this chat`,className:`h-7 flex-1 text-sm`}),(0,$.jsx)(`span`,{className:`shrink-0 tabular-nums text-xs `+(l?`text-tone-danger-fg`:`text-muted-foreground`),children:c?l?`No results`:`${t}/${n}`:``}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`icon-sm`,title:`Previous match (Shift+Enter)`,disabled:n===0,onClick:a,children:(0,$.jsx)(It,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`icon-sm`,title:`Next match (Enter)`,disabled:n===0,onClick:i,children:(0,$.jsx)(Pt,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`icon-sm`,title:`Close search (Esc)`,onClick:o,children:(0,$.jsx)(cn,{className:`h-3.5 w-3.5`})})]})]})}function dr({open:e,onOpenChange:t,src:n,title:r,actions:i}){return(0,$.jsx)(Ce,{open:e,onOpenChange:t,children:(0,$.jsxs)(xe,{className:`max-w-[95vw] w-auto p-0 bg-black/95 border-white/10 gap-0`,showCloseButton:!1,children:[(0,$.jsx)(Se,{className:`sr-only`,children:r}),(0,$.jsxs)(`div`,{className:`relative flex items-center justify-center min-h-[200px]`,children:[(0,$.jsx)(`img`,{src:n,alt:r,className:`max-w-[93vw] max-h-(--dialog-max-h) object-contain`}),(0,$.jsxs)(`div`,{className:`absolute top-2 right-2 flex gap-1`,children:[i,(0,$.jsx)(`button`,{type:`button`,onClick:()=>t(!1),className:`rounded-md bg-black/60 hover:bg-black/80 p-2 text-white transition-colors`,title:`Close`,children:(0,$.jsx)(cn,{className:`w-4 h-4`})})]})]})]})})}function fr({matches:e,activeIndex:n,onAccept:r,onHover:i}){return e.length===0?null:(0,$.jsx)(`div`,{className:`absolute bottom-full left-3 right-3 md:left-4 md:right-4 mb-2 z-20 max-h-64 overflow-auto rounded-xl border border-border bg-popover shadow-lg`,children:e.map((e,a)=>(0,$.jsxs)(`button`,{onMouseDown:t=>{t.preventDefault(),r(e)},onMouseEnter:()=>i(a),className:t(`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-sm`,a===n?`bg-accent`:`hover:bg-accent/50`),children:[(0,$.jsx)(`span`,{className:`font-medium shrink-0`,children:e.name}),e.argumentHint&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground shrink-0`,children:e.argumentHint}),e.description&&(0,$.jsx)(`span`,{className:`ml-auto truncate text-xs text-muted-foreground/70`,children:e.description})]},e.name))})}var pr=e=>`/agents/`+encodeURIComponent(e)+`/self-effort`,mr=f((e,t)=>{let n=(n,r)=>e({grants:{...t().grants,[n]:r}});return{grants:{},async load(e){try{let{selfEffort:t}=await be(`GET`,pr(e));n(e,{policy:t??null})}catch(r){n(e,{...t().grants[e],error:r.message})}},async save(e,r){let i=t().grants[e];n(e,{policy:i?.policy,saving:!0});let a=r?r===`band`?{selfEffort:!0}:{selfEffort:!0,selfEffortCeiling:r}:{selfEffort:!1};try{let{selfEffort:t}=await be(`PUT`,pr(e),{...a,surface:{component:`composer-self-effort`}});n(e,{policy:t??null})}catch(t){n(e,{policy:i?.policy,error:t.message})}}}});function hr(e){return e.band?`${e.floor} to ${e.ceiling}`:`up to ${e.ceiling}`}function gr({agentId:e,efforts:t,className:n}){let[r,i]=(0,Q.useState)(!1),a=mr(t=>t.grants[e]),o=mr(e=>e.load),s=mr(e=>e.save),c=a?.policy,l=!!c,u=c?c.band?x:c.ceiling:``,d=c&&!c.band&&!t.includes(c.ceiling)?[...t,c.ceiling]:t,f=c===void 0||!!a?.saving,p=c===void 0?``:c?c.band?`${c.floor}–${c.ceiling}`:`≤ ${c.ceiling}`:`off`;return(0,$.jsxs)(Me,{open:r,onOpenChange:t=>{i(t),t&&o(e)},children:[(0,$.jsx)(Ae,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,"aria-label":`Agent's own effort`,title:`Let the agent change its own effort`,className:n,children:[`self`,p&&(0,$.jsxs)(`span`,{className:`max-md:sr-only`,children:[` `,p]})]})}),r&&(0,$.jsxs)(je,{align:`end`,className:`w-64 text-left text-xs`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(ke,{htmlFor:`self-effort-${e}`,className:`text-xs`,children:`Let the agent change its own effort`}),(0,$.jsx)(Ne,{id:`self-effort-${e}`,size:`sm`,checked:l,disabled:f,onCheckedChange:t=>void s(e,t?`band`:null)})]}),c&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(ke,{htmlFor:`self-effort-ceiling-${e}`,className:`shrink-0 text-xs text-muted-foreground`,children:`Range`}),(0,$.jsxs)(`select`,{id:`self-effort-ceiling-${e}`,value:u,disabled:f,onChange:t=>void s(e,t.target.value),className:`w-full rounded-md border border-input bg-background px-2 py-1 text-xs`,children:[(0,$.jsx)(`option`,{value:`band`,children:`One step from base`}),d.map(e=>(0,$.jsxs)(`option`,{value:e,children:[`Up to `,e]},e))]})]}),(0,$.jsx)(`p`,{className:`text-muted-foreground`,children:c===void 0?`Loading…`:c?`From its next turn it can set its own effort ${hr(c)}${c.band?` (base ${c.base})`:``}. You can still set any level. This holds across restarts; for a managed agent it applies to the whole policy.`:`Only you and its coordinator can change its effort.`}),a?.error&&(0,$.jsx)(`p`,{role:`alert`,className:`text-tone-danger-fg`,children:a.error})]})]})}var _r=`min-w-0 max-w-full text-right text-[11px] text-muted-foreground`,vr=`min-h-11 min-w-11 shrink-0 text-center cursor-pointer appearance-none field-sizing-content rounded bg-background px-1 text-[11px] text-muted-foreground underline decoration-dotted underline-offset-2 hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring md:min-h-0 md:min-w-0 md:px-0.5`;function yr({agent:e}){let n=T(e=>e.providerCatalog),r=D(t=>e?t.states[e.id]:void 0),i=D(t=>e?t.refused[e.id]:void 0),a=D(e=>e.request),o=D(e=>e.load),s=D(e=>e.dismiss),c=e?.providerCapabilities?.model,l=c?.effortSwitch===!0?e?.id:void 0;(0,Q.useEffect)(()=>{l&&o(l).catch(()=>{})},[l,o]);let u=re(c,n);if(!e||!c||!u)return null;let{label:d,entry:f}=u,p=c.effortSwitch===!0&&e.status!==`offline`?f?.efforts??[]:[];if(!p.length)return(0,$.jsxs)(`p`,{"data-testid":`composer-model`,className:`${_r} break-words`,children:[d,c.effort?` (${c.effort})`:``]});let m=c.effort??``,g=h(r),_=m&&!p.includes(m)?[m,...p]:p;return(0,$.jsxs)(`div`,{className:_r,children:[(0,$.jsxs)(`p`,{"data-testid":`composer-model`,className:`flex min-w-0 items-center justify-end gap-1`,children:[(0,$.jsxs)(`span`,{className:`min-w-0 truncate`,children:[d,` ·`]}),(0,$.jsxs)(`select`,{"aria-label":`Effort`,title:g?`Effort ${g} applies when the current turn ends; pick again to replace it`:`Change effort for the next turn; the prompt cache is kept`,value:g??m,onChange:t=>{t.target.value&&a(e.id,t.target.value)},className:t(vr,g&&`max-md:animate-pulse`),children:[!m&&(0,$.jsx)(`option`,{value:``,children:`default`}),_.map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))]}),g&&(0,$.jsx)(`span`,{"data-testid":`effort-pending`,className:`shrink-0 max-md:sr-only`,children:e.status===`busy`?`pending until the turn ends`:`switching`}),(0,$.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,$.jsx)(gr,{agentId:e.id,efforts:p,className:vr})]}),i&&(0,$.jsxs)(`p`,{role:`alert`,className:`mt-0.5 flex items-start justify-end gap-1 text-tone-danger-fg`,children:[(0,$.jsxs)(`span`,{children:[`Effort not changed to `,i.effort,`: `,i.error]}),(0,$.jsx)(`button`,{type:`button`,title:`Dismiss`,onClick:()=>s(e.id),className:`shrink-0 hover:text-foreground`,children:(0,$.jsx)(cn,{className:`h-3 w-3`})})]})]})}var br=`size-11 shrink-0 rounded-xl md:size-[42px]`;function xr({inputRef:e,value:n,onChange:r,onKeyDown:i,onPaste:a,onBlur:o,placeholder:s,className:c}){return(0,Q.useLayoutEffect)(()=>{let t=e.current,n=t?.parentElement;!t||!n||(n.style.minHeight=`${n.offsetHeight}px`,t.style.height=`auto`,t.style.height=Math.min(t.scrollHeight,200)+`px`,n.style.minHeight=``)},[n,e]),(0,$.jsx)(`div`,{className:t(`min-w-0`,c),children:(0,$.jsx)(`textarea`,{ref:e,value:n,onChange:r,onKeyDown:i,onPaste:a,onBlur:o,placeholder:s,rows:1,className:t(`block w-full resize-none rounded-xl border border-border bg-background px-3.5 py-2.5 text-sm`,`placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,`min-h-[42px] max-h-[200px] overflow-y-auto`)})})}function Sr({item:e,onRemove:n}){let[r,i]=(0,Q.useState)(!1),a=!!(e.previewUrl&&!e.error);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 rounded-md border border-border bg-card px-2.5 py-2 text-xs`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:!a,onClick:()=>i(!0),className:`group/pending relative flex h-9 w-9 shrink-0 items-center justify-center overflow-hidden rounded bg-muted disabled:cursor-default`,title:a?`Preview image`:e.fileName,children:e.previewUrl?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`img`,{src:e.previewUrl,alt:e.fileName,className:`h-full w-full object-cover`}),(0,$.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center bg-black/0 group-hover/pending:bg-black/30 transition-colors`,children:(0,$.jsx)(ln,{className:`h-3.5 w-3.5 text-white opacity-0 group-hover/pending:opacity-100 transition-opacity drop-shadow-md`})})]}):e.error?(0,$.jsx)(Lt,{className:`h-4 w-4 text-tone-danger-fg`}):e.uploading?(0,$.jsx)(Jt,{className:`h-4 w-4 animate-spin text-muted-foreground`}):(0,$.jsx)(Ht,{className:`h-4 w-4 text-muted-foreground`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`truncate font-medium`,children:e.fileName}),(0,$.jsx)(`p`,{className:t(`truncate text-muted-foreground`,e.error&&`text-tone-danger-fg`),children:e.error||(e.uploading?`Uploading`:W(e.size))})]}),(0,$.jsx)(Z,{variant:`ghost`,size:`icon-sm`,title:`Remove attachment`,onClick:n,children:(0,$.jsx)(cn,{className:`h-3.5 w-3.5`})})]}),e.previewUrl&&(0,$.jsx)(dr,{open:r,onOpenChange:i,src:e.previewUrl,title:e.fileName})]})}function Cr({draft:e,placeholder:n,chatSending:r,disabled:i,hasPendingUploads:a,readyAttachmentCount:o,pendingAttachments:s,micAvailable:c,micState:l,slashMatches:u,slashActiveIndex:d,onDraftChange:f,onDraftBlur:p,onKeyDown:m,onPaste:h,onUploadFiles:g,onRemovePendingAttachment:_,onSend:v,onAcceptSlash:y,onSlashHover:b,onStartPtt:x,onStopPtt:S,footerText:C,agent:w}){let T=(0,Q.useRef)(null),E=(0,Q.useRef)(null),ee=(0,Q.useRef)(!1),[te,D]=(0,Q.useState)(!1),O=!e.trim()&&o===0||a||r||i;return(0,$.jsxs)(`div`,{className:t(`relative shrink-0 border-t border-border px-3 md:px-4 py-2.5 md:py-3 safe-area-bottom`,te&&`bg-primary/5 ring-1 ring-primary/40`),onDragOver:e=>{e.preventDefault(),D(!0)},onDragLeave:()=>D(!1),onDrop:e=>{e.preventDefault(),D(!1),g(e.dataTransfer.files)},children:[w?.id===N&&(0,$.jsx)(`p`,{className:`mb-2 text-xs text-muted-foreground`,children:`Messages wait here until you ask Claude in the app: "Any messages for me?"`}),s.length>0&&(0,$.jsx)(`div`,{className:`mb-2 grid gap-2 sm:grid-cols-2`,children:s.map(e=>(0,$.jsx)(Sr,{item:e,onRemove:()=>_(e.id)},e.id))}),(0,$.jsx)(`input`,{ref:T,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{e.target.files&&g(e.target.files),e.currentTarget.value=``}}),(0,$.jsx)(fr,{matches:u,activeIndex:d,onAccept:y,onHover:b}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-end gap-x-1 gap-y-1.5 md:gap-2`,children:[(0,$.jsx)(Z,{variant:`ghost`,size:`icon`,title:`Attach files`,disabled:r,onClick:()=>T.current?.click(),className:br,children:(0,$.jsx)(Zt,{className:`w-4 h-4`})}),c&&(0,$.jsx)(Z,{variant:`ghost`,size:`icon`,title:l===`recording`?`Release to transcribe`:`Hold to talk`,disabled:r||l===`transcribing`,onPointerDown:e=>{e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),x()},onPointerUp:e=>{e.preventDefault();try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}S()},className:t(br,`md:order-1`,l===`recording`&&`text-tone-danger-fg animate-pulse`),children:l===`transcribing`?(0,$.jsx)(Jt,{className:`w-4 h-4 animate-spin`}):(0,$.jsx)(Ie,{className:`w-4 h-4`})}),(0,$.jsx)(xr,{inputRef:E,value:e,onChange:e=>f(e.target.value),onKeyDown:m,onPaste:h,onBlur:p,placeholder:n,className:`order-first basis-full md:order-none md:min-w-48 md:flex-1 md:basis-0`}),(0,$.jsx)(`div`,{className:`flex min-h-11 min-w-0 flex-1 basis-0 flex-col items-end justify-center md:min-h-[42px] md:max-w-64 md:flex-none md:basis-auto`,children:(0,$.jsx)(yr,{agent:w})}),(0,$.jsx)(Z,{size:`icon`,"aria-label":`Send message`,title:`Send (Enter) · Shift+Enter for a new line`,disabled:O,onPointerDown:e=>{ee.current=e.pointerType!==`mouse`},onMouseDown:e=>e.preventDefault(),onClick:()=>{v(),ee.current&&E.current?.blur(),ee.current=!1},className:t(br,`md:order-2`),children:(0,$.jsx)(Ue,{className:`w-4 h-4`})})]}),C&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1.5`,children:C})]})}var wr=e(i(),1);function Tr({preview:e,error:t,onReadError:n,onMouseEnter:r,onMouseLeave:i}){let{anchor:a}=e,o=Math.min(560,window.innerWidth-24),s=Math.min(380,window.innerHeight-24),c=Math.max(12,Math.min(a.left,window.innerWidth-o-12));return(0,wr.createPortal)((0,$.jsxs)(`div`,{className:`fixed z-50 flex flex-col overflow-hidden rounded-lg border border-border bg-background shadow-xl`,style:{top:window.innerHeight-a.bottom>=s+8?a.bottom+8:a.top-8-s>=12?a.top-8-s:Math.max(12,window.innerHeight-s-12),left:c,width:o,height:s},onMouseEnter:r,onMouseLeave:i,children:[(0,$.jsxs)(`div`,{className:`flex h-8 shrink-0 items-center gap-2 border-b border-border px-2.5`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[11px] font-medium text-muted-foreground`,children:e.path}),t&&(0,$.jsx)(`span`,{className:`max-w-[12rem] truncate text-[11px] text-tone-danger-fg`,children:t}),(0,$.jsx)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground/70`,children:`click to pin`})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:e.type===`directory`?(0,$.jsx)(We,{orchestratorId:e.orchestratorId,selectedPath:e.path,onReadError:n}):(0,$.jsx)(Ve,{orchestratorId:e.orchestratorId,selectedPath:e.path,line:e.line,onReadError:n})})]}),document.body)}var Er=[];function Dr(e){return T(t=>t.chatStatusEvents[e]??Er)}function Or(e,t){let n=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(!e)return;n.current||=(window.history.pushState({chatGuard:!0},``),!0);function r(e){(e.state?.chatGuard!==void 0||!n.current)&&(window.history.pushState({chatGuard:!0},``),t())}function i(e){e.preventDefault()}return window.addEventListener(`popstate`,r),window.addEventListener(`beforeunload`,i),()=>{window.removeEventListener(`popstate`,r),window.removeEventListener(`beforeunload`,i)}},[e,t]),(0,Q.useEffect)(()=>{!e&&n.current&&(n.current=!1)},[e])}function kr(e,t){let n=e.toLowerCase(),r=t.trim().toLowerCase();return r?n.includes(r)?!0:/\s/.test(r)||r.length<4?!1:Ar(n,r):!1}function Ar(e,t,n=4){let r=0,i=-1;for(let a=0;a<e.length&&r<t.length;a+=1)if(e[a]===t[r]){if(i!==-1&&a-i-1>n)return!1;i=a,r+=1}return r===t.length}function jr(e,t){let n=t.trim();if(!n)return[];let r=[];for(let t of e){let e=it(t);e&&kr(e,n)&&r.push(Y(t))}return r}function Mr(e){let[t,n]=(0,Q.useState)(!1),[r,i]=(0,Q.useState)(``),[a,o]=(0,Q.useState)(0),s=(0,Q.useMemo)(()=>t?jr(e,r):[],[t,r,e]),c=(0,Q.useMemo)(()=>new Set(s),[s]),l=s.length,u=l?Math.min(a,l-1):0,d=l?s[u]??null:null,f=(0,Q.useCallback)(()=>n(!0),[]),p=(0,Q.useCallback)(()=>{n(!1),i(``),o(0)},[]),m=(0,Q.useCallback)(e=>{i(e),o(0)},[]),h=(0,Q.useCallback)(()=>{o(e=>l?(e+1)%l:0)},[l]),g=(0,Q.useCallback)(()=>{o(e=>l?(e-1+l)%l:0)},[l]);return{open:t,query:r,matchKeys:s,matchKeySet:c,total:l,position:l?u+1:0,currentKey:d,openSearch:f,close:p,setQuery:m,next:h,prev:g}}function Nr(e,t,n){let[r,i]=(0,Q.useState)(e),a=(0,Q.useRef)(null),o=(0,Q.useRef)(e),s=(0,Q.useRef)(e),c=(0,Q.useRef)(n);return(0,Q.useEffect)(()=>{if(o.current=e,s.current===e)return;s.current=e;let r=c.current!==n;if(c.current=n,a.current!==null){if(!r)return;clearTimeout(a.current)}i(e),a.current=setTimeout(()=>{a.current=null,i(e=>e===o.current?e:o.current)},t)},[e,t,n]),(0,Q.useEffect)(()=>()=>{a.current!==null&&clearTimeout(a.current)},[]),r}function Pr({agentId:e,filters:t,threadMessages:n,statusEvents:r,effortChanges:i,createdAt:a,importedHistory:o,spawnedById:s,spawnedByProvider:c,window:l}){let u=l?.loading??!1,d=l?.loadedInitial??!1,f=l?.hasMore??!1,p=_(l),m=d&&!f,h=Nr((0,Q.useMemo)(()=>({threadMessages:n,statusEvents:r,effortChanges:i,createdAt:a,importedHistory:o,spawnedById:s,spawnedByProvider:c,historyStart:m,loading:u,loadedInitial:d,hasMore:f,hasNewer:p}),[n,r,i,a,o,s,c,m,u,d,f,p]),120,`${u}:${d}:${f}:${p}`);return{timeline:(0,Q.useMemo)(()=>bt(h.threadMessages,h.statusEvents,h.createdAt,h.importedHistory,{...h.spawnedById?{spawnedBy:{agentId:h.spawnedById,provider:h.spawnedByProvider}}:{},historyStart:h.historyStart,historyEnd:!h.hasNewer,effortChanges:h.effortChanges,include:n=>Dn(n,e,t)}),[h.threadMessages,h.statusEvents,h.effortChanges,h.createdAt,h.importedHistory,h.spawnedById,h.spawnedByProvider,h.historyStart,h.hasNewer,e,t]),loading:h.loading,loadedInitial:h.loadedInitial,hasMore:h.hasMore,hasNewer:h.hasNewer}}var Fr=1e4;function Ir(e,t){let n=T(e=>e.announcePresence),r=(0,Q.useRef)(t);r.current=t,(0,Q.useEffect)(()=>{if(!e)return;n(e,r.current);let t=setInterval(()=>{n(e,r.current)},Fr);return()=>{clearInterval(t),n(e,!1,!0)}},[e,n]),(0,Q.useEffect)(()=>{e&&n(e,t)},[e,t,n])}function Lr(e,t){switch(e.type){case`message`:return[0,!k(e.msg.from)&&!k(e.msg.to)?.375:.75];case`initial-prompt`:case`imported-message`:case`work-final`:return[0,.75];case`activity`:return e.steps.some(e=>t||e.kind!==`reasoning`)?[0,.5]:null;case`prompt-resolution`:return[0,0];default:return[.25,.25]}}function Rr(e,t,n){let r=0,i=null,a=e.map(e=>{let a=Lr(e,t);if(!a)return{paddingTop:`0rem`};let o=Math.max(r,a[0]),s=o;if(n){let t=Y(e),r=n.get(t);r!==void 0&&r<=o&&i?s=r:n.set(t,o)}return s<o&&(i.paddingBottom=`${o-s}rem`),r=a[1],i={paddingTop:`${s}rem`}});return n&&n.size>2*e.length&&zr(n,e),{rows:a,end:`${r}rem`}}function zr(e,t){let n=new Set(t.map(Y));for(let t of e.keys())n.has(t)||e.delete(t)}var Br={"workspace-ready":`workspace ready`,"task-deliver":`task deliver`,"task-done":`task done`,"explicit-reply":`explicit reply`,"report-final":`report final`,"edge-fallback":`inferred at exit`};function Vr({windowId:e,members:t,issueRepo:n}){let r=t[0],i=T(e=>r?e.agentsById[r.msg.from]:void 0);if(!r)return null;let a=ft(r.msg.occurredAt??r.msg.createdAt),o=r.source===`edge-fallback`,s=r.source?Br[r.source]:void 0,c=A(r.msg),l=P(r.msg).trim()||`Final report`,u=o?`border-tone-warning/40 bg-tone-warning/[0.06] text-tone-warning-fg`:`border-tone-success/40 bg-tone-success/[0.06] text-tone-success-fg`;return(0,$.jsx)(`div`,{"data-msg-id":r.msg.id,"data-window-id":e,className:`flex justify-start mb-3`,children:(0,$.jsx)(X,{id:`work-final-${e}`,icon:Rt,label:(0,$.jsxs)($.Fragment,{children:[`Final report from `,(0,$.jsx)(fn,{agent:i,fallback:r.msg.from,className:`whitespace-normal text-clip [overflow-wrap:anywhere]`})]}),summary:l,trailing:(0,$.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-x-1.5 gap-y-1`,children:[o&&(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-tone-warning/40 bg-tone-warning/10 px-1.5 py-0.5 text-[10px] font-medium text-tone-warning-fg`,title:`This work window was closed by a crash/idle-exit edge, not an explicit workspace-ready or task-done signal.`,children:[(0,$.jsx)(an,{className:`h-3 w-3`}),`inferred at exit`]}),!o&&s&&(0,$.jsxs)(`span`,{children:[`via `,s]}),c&&(0,$.jsx)(`span`,{className:`rounded border border-tone-success/40 px-1.5 py-0.5 text-[10px]`,children:`Final turn`}),r.msg.sourceMessageId&&(0,$.jsxs)(`a`,{className:`text-[10px] underline`,href:`#message-${r.msg.sourceMessageId}`,children:[`source #`,r.msg.sourceMessageId]}),(0,$.jsx)(`span`,{children:a})]}),tone:u,wrapHeader:!0,className:`max-w-[85%] md:max-w-[75%]`,children:(0,$.jsx)(`div`,{className:`space-y-2`,children:t.map(e=>(0,$.jsxs)(`div`,{"data-msg-id":e.msg.id,children:[(0,$.jsx)(Sn,{text:P(e.msg),rawBody:e.msg.body,issueRepo:n,className:`text-sm leading-relaxed text-foreground`}),e.confidence===`reconstructed`&&(0,$.jsx)(`p`,{className:`mt-0.5 text-[10px] italic text-muted-foreground/50`,title:`This report was reconstructed from persisted state (e.g. after a relay restart), not captured live.`,children:`reconstructed`})]},e.msg.id))})})})}function Hr(){return(0,$.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5 text-[11px] text-muted-foreground`,children:[(0,$.jsx)(Kt,{className:`h-3 w-3 shrink-0`}),(0,$.jsx)(`span`,{children:`Thinking may still be arriving…`})]})}function Ur({agentId:e,approval:t}){let n=T(e=>e.sendPermissionDecision),[r,i]=(0,Q.useState)(null);if(!t)return null;if(t.questions&&t.questions.length)return(0,$.jsx)(Kr,{agentId:e,approval:t,questions:t.questions});let a=t,o=t.choices.length?t.choices:[{id:`approve`,label:`Approve`},{id:`deny`,label:`Deny`}];async function s(t){if(!r){i(t.id);try{await n(e,a.id,t.id)}finally{i(null)}}}let c=t.kind===`plan`;return(0,$.jsx)(`div`,{className:`flex justify-start mb-3`,children:(0,$.jsx)(`div`,{className:`max-w-[92%] md:max-w-[78%] rounded-2xl rounded-bl-sm bg-card ring-1 ring-tone-warning/35 px-3.5 py-3 text-sm`,children:(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[c?(0,$.jsx)(qt,{className:`mt-0.5 h-4 w-4 shrink-0 text-tone-warning-fg`}):(0,$.jsx)(Lt,{className:`mt-0.5 h-4 w-4 shrink-0 text-tone-warning-fg`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-tone-warning-fg`,children:t.title}),t.reasoningSettled===!1&&(0,$.jsx)(Hr,{}),t.body&&(c?(0,$.jsx)(`div`,{className:`mt-2 max-h-72 overflow-auto rounded-md bg-background/60 p-2.5 text-xs leading-relaxed`,children:(0,$.jsx)(Sn,{text:t.body,rawBody:t.body,className:`leading-relaxed`})}):(0,$.jsx)(`pre`,{className:`mt-2 max-h-44 overflow-auto whitespace-pre-wrap break-words rounded-md bg-background/80 p-2 font-mono text-xs leading-relaxed text-muted-foreground`,children:t.body})),(0,$.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:o.map(e=>(0,$.jsxs)(Z,{size:`sm`,variant:e.id===`deny`||e.id===`abort`?`outline`:`default`,disabled:!!r,onClick:()=>void s(e),className:`h-7 px-2 text-xs`,children:[r===e.id&&(0,$.jsx)(Jt,{className:`mr-1.5 h-3 w-3 animate-spin`}),e.label]},e.id))})]})]})})})}function Wr(e){return e?e.otherActive&&e.other.trim()?!0:e.labels.length>0:!1}function Gr(e){let t=[...e.labels];return e.otherActive&&e.other.trim()&&t.push(e.other.trim()),t.join(`, `)}function Kr({agentId:e,approval:n,questions:r}){let i=T(e=>e.sendPermissionDecision),[a,o]=(0,Q.useState)(0),[s,c]=(0,Q.useState)({}),[l,u]=(0,Q.useState)(null),d=r[Math.min(a,r.length-1)],f=s[a];if(!d)return null;let p=!!d.multiSelect,m=r.length,h=a===m-1,g=Wr(f),_=r.every((e,t)=>Wr(s[t])),v=!!l;function y(e){c(t=>{let n=t[a]??{labels:[],other:``,otherActive:!1};return{...t,[a]:{...n,...e}}})}function b(e){if(p){let t=f?.labels.includes(e);y({labels:t?(f?.labels??[]).filter(t=>t!==e):[...f?.labels??[],e]})}else y({labels:[e],otherActive:!1})}function x(){y(p?{otherActive:!f?.otherActive}:{labels:[],otherActive:!0})}async function S(){if(!(!_||v)){u(`answer`);try{let t={};r.forEach((e,n)=>{let r=s[n];r&&(t[e.question]=Gr(r))}),await i(e,n.id,`answer`,t)}finally{u(null)}}}async function C(){if(!v){u(`dismiss`);try{await i(e,n.id,`deny`)}finally{u(null)}}}let w=!!f?.otherActive;return(0,$.jsx)(`div`,{className:`flex justify-start mb-3`,children:(0,$.jsxs)(`div`,{className:`w-full max-w-[92%] md:max-w-[78%] rounded-2xl rounded-bl-sm bg-card ring-1 ring-tone-warning/35 px-3.5 py-3 text-sm`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Be,{className:`h-4 w-4 shrink-0 text-tone-warning-fg`}),(0,$.jsx)(`div`,{className:`text-sm font-medium text-tone-warning-fg`,children:n.title}),m>1&&(0,$.jsxs)(un,{variant:`outline`,className:`ml-auto h-5 px-1.5 text-[10px] text-muted-foreground`,children:[a+1,` / `,m]})]}),n.reasoningSettled===!1&&(0,$.jsx)(Hr,{}),(0,$.jsxs)(`div`,{className:`mt-3`,children:[d.header&&(0,$.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-wide text-tone-warning-fg`,children:d.header}),(0,$.jsx)(`div`,{className:`mt-0.5 text-sm text-foreground whitespace-pre-wrap break-words`,children:d.question}),p&&(0,$.jsx)(`div`,{className:`mt-0.5 text-[11px] text-muted-foreground`,children:`Select all that apply`}),(0,$.jsxs)(`div`,{className:`mt-2 flex flex-col gap-1.5`,children:[d.options.map(e=>{let n=!!f?.labels.includes(e.label);return(0,$.jsxs)(`button`,{type:`button`,disabled:v,onClick:()=>b(e.label),className:t(`flex items-start gap-2 rounded-lg border px-2.5 py-2 text-left transition-colors`,n?`border-tone-warning/60 bg-tone-warning/10`:`border-border bg-background/60 hover:bg-background`,v&&`opacity-60`),children:[(0,$.jsx)(`span`,{className:t(`mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center border text-tone-warning-fg`,p?`rounded`:`rounded-full`,n?`border-tone-warning bg-tone-warning/20`:`border-muted-foreground/40`),children:n&&(0,$.jsx)(Nt,{className:`h-3 w-3`})}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`text-sm text-foreground`,children:e.label}),e.description&&(0,$.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:e.description})]})]},e.label)}),(0,$.jsxs)(`button`,{type:`button`,disabled:v,onClick:x,className:t(`flex items-start gap-2 rounded-lg border px-2.5 py-2 text-left transition-colors`,w?`border-tone-warning/60 bg-tone-warning/10`:`border-border bg-background/60 hover:bg-background`,v&&`opacity-60`),children:[(0,$.jsx)(`span`,{className:t(`mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center border text-tone-warning-fg`,p?`rounded`:`rounded-full`,w?`border-tone-warning bg-tone-warning/20`:`border-muted-foreground/40`),children:w&&(0,$.jsx)(Nt,{className:`h-3 w-3`})}),(0,$.jsx)(`span`,{className:`text-sm text-foreground`,children:`Other…`})]}),w&&(0,$.jsx)(xn,{autoFocus:!0,rows:2,disabled:v,value:f?.other??``,onChange:e=>y({other:e.target.value,otherActive:!0}),placeholder:`Type your answer`,className:`mt-1 text-sm`})]})]}),(0,$.jsxs)(`div`,{className:`mt-3 flex items-center gap-1.5`,children:[a>0&&(0,$.jsxs)(Z,{size:`sm`,variant:`outline`,disabled:v,onClick:()=>o(e=>e-1),className:`h-7 px-2 text-xs`,children:[(0,$.jsx)(ze,{className:`mr-1 h-3 w-3`}),`Back`]}),h?(0,$.jsxs)(Z,{size:`sm`,disabled:v||!_,onClick:()=>void S(),className:`h-7 px-2 text-xs`,children:[l===`answer`&&(0,$.jsx)(Jt,{className:`mr-1.5 h-3 w-3 animate-spin`}),`Send answer`,m>1?`s`:``]}):(0,$.jsxs)(Z,{size:`sm`,disabled:v||!g,onClick:()=>o(e=>e+1),className:`h-7 px-2 text-xs`,children:[`Next`,(0,$.jsx)(Ft,{className:`ml-1 h-3 w-3`})]}),(0,$.jsxs)(Z,{size:`sm`,variant:`ghost`,disabled:v,onClick:()=>void C(),className:`ml-auto h-7 px-2 text-xs text-muted-foreground`,children:[l===`dismiss`&&(0,$.jsx)(Jt,{className:`mr-1.5 h-3 w-3 animate-spin`}),`Dismiss`]})]})]})})}function qr({actor:e}){let t=T(e=>e.usersById);return e.role===`self`?(0,$.jsx)(`span`,{children:`the agent itself`}):e.role===`operator`?(0,$.jsx)(`span`,{children:e.user?F(e.user,t):`the operator`}):e.id?(0,$.jsxs)(`span`,{className:`inline-flex items-center`,children:[(0,$.jsx)(Ct,{agentId:e.id,noIcon:!0,className:`px-0.5`}),(0,$.jsx)(`span`,{className:`opacity-70`,children:`(coordinator)`})]}):(0,$.jsx)(`span`,{children:`its coordinator`})}function Jr({change:e}){return(0,$.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-2 my-1`,children:[(0,$.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,$.jsxs)(`div`,{className:`flex max-w-[85%] flex-wrap items-center justify-center gap-x-1.5 gap-y-0.5 border border-border bg-muted/30 px-2.5 py-1 text-xs text-muted-foreground md:max-w-[75%] ${e.reason?`rounded-xl`:`rounded-full`}`,children:[(0,$.jsx)(Gt,{className:`h-3 w-3 shrink-0`}),(0,$.jsxs)(`span`,{children:[`Effort `,e.previousEffort,` → `,e.effort]}),(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(`span`,{className:`opacity-70`,children:`by`}),(0,$.jsx)(qr,{actor:e.actor})]}),e.reason&&(0,$.jsxs)(`span`,{className:`min-w-0 break-words text-muted-foreground/80`,children:[`· '`,e.reason,`'`]}),(0,$.jsx)(`span`,{className:`text-muted-foreground/60`,children:ft(e.at)})]}),(0,$.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}var Yr=`px-3 md:px-4`;function Xr({context:e}){if(!e)return null;let{agentId:t,busy:n,latestKey:r,pendingApproval:i,blockedLabel:a,canInterrupt:o,onInterrupt:s,endGap:c}=e,l=n&&(!i||i.reasoningSettled===!1);return!i&&!l?(0,$.jsx)(`div`,{"data-timeline-end":!0,style:{paddingTop:c}}):(0,$.jsxs)(`div`,{"data-timeline-end":!0,className:`${Yr} pb-3 md:pb-4`,style:{paddingTop:c},children:[i&&(0,$.jsx)(Ur,{agentId:t,approval:i},i.id),l&&(0,$.jsx)(Tt,{blockedLabel:a,onInterrupt:o?s:void 0,activityKey:r})]})}function Zr({context:e}){return e?(0,$.jsx)(`div`,{className:Yr,children:(0,$.jsx)(ei,{hasMore:e.hasMore,loading:e.loading,loadedInitial:e.loadedInitial,hasItems:e.hasItems})}):null}function Qr({context:e}){let t=e?.loading??!1;return(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center text-center`,children:[t?(0,$.jsx)(Jt,{className:`mb-2 h-5 w-5 animate-spin text-muted-foreground`}):(0,$.jsx)(Yt,{className:`mb-2 h-8 w-8 text-tone-neutral-fg`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t?`Loading messages`:`No messages yet`})]})}function $r({entry:e,dataIndex:n,timeline:r,rowSpacing:i,agentId:a,showReasoning:o,searchActive:s,searchCurrentKey:c,searchMatchKeys:l,originalHighlightKey:u,onOpenReferencedPath:d,onPreviewReferencedPath:f,onPreviewReferencedPathEnd:p}){let m=s||u?Y(e):``,h=s&&l?.has(m),g=h&&m===c,_=u!==null&&m===u,v=e.type===`message`||e.type===`initial-prompt`?e.msg.from:null,y=r[n+1],b=y?.type===`message`||y?.type===`initial-prompt`?y.msg.from:null,x=v!==null&&v!==b;return(0,$.jsx)(`div`,{className:`flow-root [&>div>div]:my-0 ${Yr}`,style:i[n],children:(0,$.jsx)(`div`,{className:t(h&&`rounded-xl ring-1 ring-tone-warning/40 transition-shadow`,g&&`ring-2 ring-tone-warning bg-tone-warning/5`,_&&`rounded-xl ring-2 ring-primary bg-primary/5 transition-shadow`),children:(0,$.jsx)(ri,{entry:e,agentId:a,showReasoning:o,showAvatar:x,onOpenReferencedPath:d,onPreviewReferencedPath:f,onPreviewReferencedPathEnd:p})})})}function ei({hasMore:e,loading:t,loadedInitial:n,hasItems:r}){return t?(0,$.jsxs)(`div`,{className:`flex items-center justify-center gap-2 pb-3 text-xs text-muted-foreground`,children:[(0,$.jsx)(Jt,{className:`h-3.5 w-3.5 animate-spin`}),(0,$.jsx)(`span`,{children:`Loading earlier messages`})]}):!e&&n&&r?(0,$.jsxs)(`div`,{className:`flex items-center justify-center gap-2 pb-3 text-xs text-muted-foreground/70`,children:[(0,$.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,$.jsx)(`span`,{children:`Beginning of conversation`}),(0,$.jsx)(`div`,{className:`h-px flex-1 bg-border`})]}):(0,$.jsx)(`div`,{"aria-hidden":!0,className:`pb-3`,children:(0,$.jsx)(`div`,{className:`h-4`})})}function ti({entry:e,agentId:t,showReasoning:n,showAvatar:r,onOpenReferencedPath:i,onPreviewReferencedPath:a,onPreviewReferencedPathEnd:o}){let s=T(e=>e.agentsById[t]?.issueRepo);return e.type===`message`?(0,$.jsx)(On,{msg:e.msg,peer:t,showAvatar:r,onOpenReferencedPath:i,onPreviewReferencedPath:a,onPreviewReferencedPathEnd:o}):e.type===`initial-prompt`?(0,$.jsx)(_t,{msg:e.msg,issueRepo:s}):e.type===`notice`?(0,$.jsx)(Tn,{msg:e.msg}):e.type===`relay-injection`?(0,$.jsx)(Ot,{entry:e}):e.type===`prompt-resolution`?(0,$.jsx)(St,{entry:e}):e.type===`agent-action`?(0,$.jsx)(Dt,{entry:e}):e.type===`activity`?(0,$.jsx)(wn,{steps:e.steps,showReasoning:n,issueRepo:s}):e.type===`import-boundary`?(0,$.jsx)(wt,{history:e.history}):e.type===`imported-message`?(0,$.jsx)(Et,{entry:e.entry,sourceLabel:e.history.sourceAgentLabel||e.history.sourcePeerId,issueRepo:s}):e.type===`status`?(0,$.jsx)(vt,{event:e.event}):e.type===`effort-change`?(0,$.jsx)(Jr,{change:e.change}):e.type===`date`?(0,$.jsx)(ht,{date:e.date}):e.type===`work-final`?(0,$.jsx)(Vr,{windowId:e.windowId,members:e.members,issueRepo:s}):(0,$.jsx)(xt,{timestamp:e.timestamp})}function ni(e,t){return e.agentId===t.agentId&&e.showReasoning===t.showReasoning&&e.showAvatar===t.showAvatar&&e.onOpenReferencedPath===t.onOpenReferencedPath&&e.onPreviewReferencedPath===t.onPreviewReferencedPath&&e.onPreviewReferencedPathEnd===t.onPreviewReferencedPathEnd&&gt(e.entry,t.entry)}var ri=(0,Q.memo)(ti,ni);function ii({newCount:e,onClick:t}){return(0,$.jsxs)(Z,{type:`button`,size:`sm`,variant:`secondary`,className:`absolute bottom-3 right-4 z-20 h-8 gap-1.5 rounded-full border border-border/70 bg-background/95 px-3 text-xs shadow-lg backdrop-blur`,onClick:t,children:[(0,$.jsx)(Ke,{className:`h-3.5 w-3.5`}),`Latest`,e>0&&(0,$.jsx)(`span`,{className:`ml-0.5 min-w-4 rounded-full bg-primary px-1.5 py-0.5 text-[10px] font-medium leading-none text-primary-foreground`,children:e>99?`99+`:e})]})}function ai(e,t){if(!t)return null;let n=e.findIndex(e=>Y(e)===t.firstKey),r=e.findIndex(e=>Y(e)===t.lastKey);return n<0||r<0?null:[Math.min(n,r),Math.max(n,r)]}function oi(e,t){let n=(e?.nodeType===Node.ELEMENT_NODE?e:e?.parentElement)?.closest(`[data-row-key]`);return n&&t.contains(n)?n.dataset.rowKey??null:null}function si(e,t,n){let[r,i]=(0,Q.useState)(null),a=(0,Q.useRef)(!1),o=(0,Q.useRef)(new Map).current,s=(0,Q.useCallback)(()=>{let e=document.getSelection(),n=t.current;n&&(n.contains(e?.anchorNode??null)||n.contains(e?.focusNode??null))&&e?.removeAllRanges(),a.current=!1,o.clear(),i(null)},[t,o]);(0,Q.useLayoutEffect)(()=>{let e=()=>{let e=document.getSelection(),r=t.current,s=r&&oi(e?.anchorNode??null,r),c=r&&oi(e?.focusNode??null,r);if(!e||e.isCollapsed||!s||!c){a.current=!1,o.clear(),i(null);return}a.current||n(),a.current=!0,i(e=>e?.firstKey===s&&e.lastKey===c?e:{firstKey:s,lastKey:c})};return document.addEventListener(`selectionchange`,e),()=>document.removeEventListener(`selectionchange`,e)},[t,s,n]);let c=(0,Q.useMemo)(()=>ai(e,r),[e,r]);r&&!c&&(a.current=!1,i(null));let l=new Set;if(c)for(let t=c[0];t<=c[1];t++){let n=e[t],r=Y(n);l.add(r),o.has(r)||o.set(r,n)}for(let e of o.keys())l.has(e)||o.delete(e);return{held:c!==null,heldRef:a,span:r,indexes:c,heldEntries:o,clearSelection:s}}var ci=new Map,li=new WeakMap;function ui(e){return e.type===`message`?[e.msg]:e.type===`work-final`?e.members.map(e=>e.msg):null}function di(e,t){for(let n of e)for(let e of ui(n)??[])t(e)}var fi=(e,t)=>e.id>t&&!k(e.from);function pi(e){let t=li.get(e);return t===void 0?(t=-1,di(e,e=>{e.id>t&&(t=e.id)}),li.set(e,t),t):t}function mi(e,t){let n=pi(t),r=ci.get(e);if(!r){n>=0&&ci.set(e,{seen:n,unseen:new Set,noted:null,counted:null});return}n>r.seen&&(r.seen=n),r.unseen.size&&r.unseen.clear()}function hi(e,t){let n=ci.get(e);!n||n.noted?.deref()===t||(n.noted=new WeakRef(t),di(t,e=>{fi(e,n.seen)&&n.unseen.add(e.id)}))}function gi(e,t){let n=ci.get(e);if(!n)return 0;let r=n.counted;if(r?.timeline.deref()===t&&r.seen===n.seen&&r.unseen===n.unseen.size)return r.count;let i=n.unseen.size;return di(t,e=>{fi(e,n.seen)&&!n.unseen.has(e.id)&&i++}),n.counted={timeline:new WeakRef(t),seen:n.seen,unseen:n.unseen.size,count:i},i}var _i=120,vi=100,yi=_i,bi=0;function xi(e){e>0&&(bi=Math.min(bi+1,vi),yi+=(e-yi)/bi)}function Si(e,t){let n=e.get(t);return n===void 0&&e.set(t,n=Math.round(yi)),n}function Ci(e,t,n){if(e.size<=2*t)return;let r=new Set(n());for(let t of e.keys())r.has(t)||e.delete(t)}var wi=.25;function Ti(e,t,n,r){let i=new Map;e.forEach((e,t)=>i.set(e,t));let a=[],o=-1;for(let e=0;e<t.length;e++){let s=i.get(t[e]);if(s===void 0){o<0&&(o=e);continue}if(o>0&&i.get(t[o-1])===s-1&&Ei(o,e,r)&&n(s))for(let n=o;n<e;n++)a.push(t[n]);o=-1}return a}function Ei(e,t,n){for(let r=e;r<t;r++)if(n(r))return!0;return!1}function Di(e,t){let n=[];for(let r of Array.from(e.querySelectorAll(`[data-item-index]`))){let e=Number(r.dataset.itemIndex);if(e<0||e>=t)continue;let i=r.getBoundingClientRect();n.push({dataIndex:e,top:i.top,bottom:i.bottom})}return n.sort((e,t)=>e.dataIndex-t.dataIndex)}function Oi(e,t,n,r,i,a){if(!e||!n.keys.length)return null;let o=null,s=()=>{if(o)return o;let{top:t,bottom:r,height:i}=e.getBoundingClientRect(),a=Di(e,n.timeline.length).filter(e=>e.bottom>t&&e.top<r);return o={top:t,rows:a,reader:(a.find(e=>e.top>=t+i*wi)??a[a.length-1])?.dataIndex??-1}},c=e=>{let{top:t,rows:n,reader:r}=s();return e<=r&&n.some(n=>n.dataIndex===e&&n.top>t)},l=null,u=Ti(n.keys,r.keys,c,e=>{if(l===null){l=1/0;for(let e of n.timeline)l=Math.min(l,kt(e)?.messageId??l)}let t=kt(r.timeline[e]);return!!t&&t.messageId<l});for(let e of u)i.set(e,0),t?.itemSizeCache.delete(e);if(!a||!u.length&&r.keys.indexOf(n.keys[0])<=0)return null;let{top:d,rows:f,reader:p}=s();return mt(n.timeline,u.length?f.filter(e=>e.dataIndex>=p):f,d)}var ki=e=>e.length,Ai=16,ji=2,Mi=6,Ni=6;function Pi(e){let{agentId:t,timeline:n,loadedInitial:r,loading:i,latestKey:a,onScrollerRef:s}=e,c=(0,Q.useRef)(null),l=(0,Q.useRef)(n);l.current=n;let d=(0,Q.useRef)(e);d.current=e;let[f,h]=(0,Q.useState)(null),_=(0,Q.useRef)(null),[y,b]=(0,Q.useState)(null),x=(0,Q.useRef)(`idle`),[,T]=(0,Q.useReducer)(e=>e+1,0),[,D]=(0,Q.useReducer)(e=>e+1,0),ne=(0,Q.useRef)(!1),k=(0,Q.useRef)(null),A=(0,Q.useRef)(`start`),j=(0,Q.useRef)(null),M=(0,Q.useRef)(O()),re=(0,Q.useRef)(0),[ie,ae]=(0,Q.useState)(Ai),oe=(0,Q.useRef)(null),N=(0,Q.useCallback)(()=>{oe.current?.cancelScroll(),A.current=`start`,ne.current=!0,k.current=null},[]),{held:P,heldRef:se,indexes:ce,heldEntries:le,clearSelection:F}=si(n,c,N);ki(n);let ue=(0,Q.useRef)(new Map);Ci(ue.current,n.length,()=>n.map(Y));let I=(0,Q.useRef)(null),L=(0,Q.useRef)(null);if(I.current?.timeline!==n){let e=n.map(Y);I.current&&(L.current=Oi(c.current,oe.current,I.current,{timeline:n,keys:e},ue.current,_.current?.kind===`anchored`)),I.current={timeline:n,keys:e}}let R=!P&&f?.kind===`follow`,de=k.current&&_.current?.kind===`anchored`?Li(n,_.current.anchor):-1,fe=(0,Q.useRef)(null),pe=fe.current?Ii(n,fe.current).join(`,`):``,me=(0,Q.useCallback)(e=>{let t=Fn(e),n=[];if(ce)for(let e=ce[0];e<=ce[1];e++)n.push(e);if(de>=0&&n.push(de),pe)for(let e of pe.split(`,`))n.push(Number(e));let r=R?Fi(oe.current,e.count):null;if(r&&(r[0]<e.startIndex||r[1]>e.endIndex))for(let e=r[0];e<=r[1];e++)n.push(e);return n.length?[...new Set([...t,...n])].sort((e,t)=>e-t):t},[de,pe,ce,R]),z=Ln({count:n.length+1,getScrollElement:()=>c.current,getItemKey:e=>{let t=l.current[e];return t?Y(t):`footer:${a??``}`},estimateSize:e=>{let t=l.current[e];return t?Si(ue.current,Y(t)):re.current},measureElement:(e,t,n)=>{let r=In(e,t,n),i=n.indexFromElement(e);return i===n.options.count-1?re.current=r:n.itemSizeCache.has(n.options.getItemKey(i))||xi(r),r},indexAttribute:`data-item-index`,paddingStart:ie,overscan:Ni,rangeExtractor:me,anchorTo:`end`,followOnAppend:R,scrollEndThreshold:R?ji:-1/0,scrollPaddingStart:f?.kind===`anchored`&&A.current===`start`?-f.anchor.offset:0});oe.current=z,z.shouldAdjustScrollPositionOnItemSizeChange??=(e,t,n)=>{let r=n.scrollOffset??0;return n.itemSizeCache.has(e.key)?e.end<=r&&n.scrollDirection!==`backward`:e.start<r||ue.current.get(String(e.key))===0};let B=(0,Q.useCallback)(()=>{A.current=`start`,M.current={commands:M.current.commands+1},z.scrollToEnd()},[z]),V=(0,Q.useCallback)(e=>{let t=_.current;if(t?.kind!==`anchored`)return;let n=Li(l.current,t.anchor);if(n<0)return;e&&(ne.current=!1,k.current=O());let r=k.current;r&&(k.current={commands:r.commands+1},z.scrollToIndex(n,{align:A.current}))},[z]),H=(0,Q.useCallback)(e=>{let n=_.current;if(!n)return;let r=o(n,e);r!==n&&(_.current=r,h(r),g(t,m(r)),r.kind===`follow`&&n.kind!==`follow`&&(k.current=null,M.current=O(),d.current.hasNewer&&d.current.onLoadNewer?.()))},[t]);(0,Q.useLayoutEffect)(()=>{let e=!1;return w().then(()=>{e||b(te(C(t)))}),()=>{e=!0}},[t]),(0,Q.useLayoutEffect)(()=>{if(_.current||!y||!r)return;let e=y.kind===`anchored`&&Li(l.current,y.anchor)>=0,n=d.current.onLoadAround?x.current:`unavailable`,a=u(y,{settled:!i,resolves:e,around:n});if(a.kind!==`wait`){if(a.kind===`fetch-around`){x.current=`requested`,d.current.onLoadAround(a.messageId).catch(()=>{}).then(()=>{x.current=`settled`,T()});return}a.mode!==y&&g(t,m(a.mode)),_.current=a.mode,h(a.mode)}});let U=f!==null;(0,Q.useLayoutEffect)(()=>{if(_.current?.kind!==`follow`)return V(!0);B(),d.current.hasNewer&&d.current.onLoadNewer?.()},[U]);let he=(e,t,n)=>{if(j.current===null){let t=n.querySelector(`[data-item-index="${e}"]`);t&&(j.current=t.offsetHeight)}return((j.current??t)-n.clientHeight)/2},W=(0,Q.useCallback)(()=>{let e=c.current;return e&&mt(l.current,Di(e,l.current.length),e.getBoundingClientRect().top)},[]);(0,Q.useLayoutEffect)(()=>{if(!U||_.current?.kind!==`follow`)return;let e=c.current,t=z.isAtEnd(ji)||!!e&&e.scrollHeight-e.clientHeight-e.scrollTop<=ji;if(se.current){t||H({type:`selection-held`,fold:W()});return}let n=E(M.current,t);n===`reset`?M.current=O():n===`command`&&B()});let ge=(0,Q.useRef)(null),G=(0,Q.useRef)(!1);(0,Q.useLayoutEffect)(()=>{let e=L.current;L.current=null,!(!e||!U||_.current?.kind!==`anchored`||G.current||A.current!==`start`)&&(H({type:`scrolled`,fold:e}),k.current=O())}),(0,Q.useLayoutEffect)(()=>{let e=_.current;if(!U||e?.kind!==`anchored`)return void(ge.current=null);let t=Li(l.current,e.anchor),n=ge.current;ge.current={anchor:e.anchor,index:t},!(n?.anchor!==e.anchor||n.index===t||t<0||G.current)&&(k.current=O())}),(0,Q.useLayoutEffect)(()=>{let e=k.current,t=_.current;if(!U||!e||t?.kind!==`anchored`)return;let n=Li(l.current,t.anchor),r=n>=0?z.measurementsCache[n]:void 0,i=A.current,a=n>=0?z.getOffsetForIndex(n,i)?.[0]:void 0,o=c.current;if(!r||a===void 0||!o)return;let s=z.getVirtualItems().find(e=>e.index===n),u=o.scrollTop+(s?r.start-s.start:0),d=i===`center`?he(n,r.size,o):t.anchor.offset,f=ee(e,u,r.start+d,a);f===`retire`?k.current=null:f===`command`?V(!1):e.commands&&(k.current=O())});let _e=(0,Q.useRef)(null),ve=(0,Q.useCallback)(e=>{if(_e.current?.disconnect(),_e.current=null,!e)return;let t=()=>ae(e.offsetHeight);t(),!(typeof ResizeObserver>`u`)&&(_e.current=new ResizeObserver(t),_e.current.observe(e))},[]);(0,Q.useLayoutEffect)(()=>(v(t,()=>{let e=_.current;if(!e)return null;if(e.kind===`follow`)return{kind:`follow`};let t=c.current,n=k.current?e.anchor:t&&t.scrollHeight-t.clientHeight-t.scrollTop<=ji?null:W()??e.anchor;return n?{kind:`anchored`,anchorId:n.anchorMessageId??-1/0}:{kind:`at-end`}}),S(t,()=>{if(F(),_.current){H({type:`own-prompt-sent`}),B();return}g(t,m(p)),b(p)}),()=>{v(t,null),S(t,null)}),[t,W,H,F,B]);let ye=(0,Q.useRef)(null),be=(0,Q.useCallback)(e=>{if(ye.current?.(),ye.current=null,c.current=e,s?.(e),!e)return;let t=()=>{let{hasMore:e,loading:t,onLoadOlder:n}=d.current,r=oe.current?.calculateRange()?.startIndex;e&&!t&&!k.current&&r!==void 0&&r<=Ni&&n()},n=0,r=!1,i=()=>{n||=(G.current=!0,requestAnimationFrame(()=>{n=0,G.current=!1;let e=_.current?.kind===`anchored`?W():null;e&&H({type:`scrolled`,fold:e}),r&&t(),r=!1}))},a=()=>{N(),H({type:`gesture-up`,fold:W()}),t()},o=()=>e.scrollHeight-e.clientHeight-e.scrollTop<=ji,l=()=>{k.current=null,i();let{hasNewer:e,onLoadNewer:t}=d.current;e&&t?.(),H({type:`reached-end`,tailDetached:e})},u=()=>{N(),_.current?.kind===`anchored`&&o()&&l()},f=e.scrollTop,p=()=>{let t=e.scrollTop,n=t>f,a=t<f,s=a&&o();if(f=t,_.current?.kind===`anchored`){if(s)return V(!0);if(ne.current){if(n&&o())return l();r||=a,i()}}},m=e=>{e.deltaY<0?a():e.deltaY>0?u():N()},h=0,g=e=>{h=e.touches[0]?.clientY??0},v=e=>{let t=(e.touches[0]?.clientY??0)-h;t>Mi?a():t<-6&&u()},y=e=>{let t=e.key===`ArrowUp`||e.key===`PageUp`||e.key===`Home`||e.key===` `&&e.shiftKey,n=e.key===`ArrowDown`||e.key===`PageDown`||e.key===`End`||e.key===` `;t?a():n&&u()},b=t=>{t.target===e&&t.pointerType===`mouse`&&a()};e.addEventListener(`scroll`,p,{passive:!0}),e.addEventListener(`wheel`,m,{passive:!0}),e.addEventListener(`touchstart`,g,{passive:!0}),e.addEventListener(`touchmove`,v,{passive:!0}),e.addEventListener(`keydown`,y),e.addEventListener(`pointerdown`,b,{passive:!0});let x=e.clientHeight,S=typeof ResizeObserver>`u`?null:new ResizeObserver(()=>{e.clientHeight!==x&&(x=e.clientHeight,k.current?D():_.current?.kind===`follow`&&!se.current&&!o()&&(M.current=O(),B()))});S?.observe(e);let C=En(e,{nudge(t){oe.current?.cancelScroll(),k.current=null,e.scrollTop+=t,i()},pin(e){fe.current=e}});ye.current=()=>{C(),S?.disconnect(),cancelAnimationFrame(n),G.current=!1,e.removeEventListener(`scroll`,p),e.removeEventListener(`wheel`,m),e.removeEventListener(`touchstart`,g),e.removeEventListener(`touchmove`,v),e.removeEventListener(`keydown`,y),e.removeEventListener(`pointerdown`,b)}},[W,H,s,V,N,D,se,B]),xe=(0,Q.useCallback)(e=>{if(!_.current)return!1;F();let t=l.current.findIndex(t=>Y(t)===e);if(t<0)return!1;let n=l.current[t],r=kt(n);return A.current=`center`,j.current=null,H({type:`jump-to`,anchor:{topKey:e,anchorMessageId:r?.messageId,anchorEndMessageId:r?.endMessageId,offset:((z.measurementsCache[t]?.size??0)-(c.current?.clientHeight??0))/2}}),V(!0),!0},[H,z,F,V]);(0,Q.useLayoutEffect)(()=>{let e=_.current;if(A.current!==`center`||e?.kind!==`anchored`)return;let t=Li(l.current,e.anchor),n=z.measurementsCache[t],r=c.current;n&&r&&H({type:`scrolled`,fold:{...e.anchor,offset:he(t,n.size,r)}})});let Se=(0,Q.useCallback)(()=>{F(),H({type:`latest-click`}),B()},[F,H,B]),Ce=!e.hasNewer&&z.isAtEnd(ji);return(0,Q.useLayoutEffect)(()=>hi(t,n),[t,n]),(0,Q.useLayoutEffect)(()=>{let r=c.current;U&&!e.hasNewer&&r&&r.scrollHeight-r.clientHeight-r.scrollTop<=ji&&mi(t,n)}),{virtualizer:z,scrollerRef:be,headerRef:ve,mode:f??{kind:`follow`},opened:U,latestClick:Se,jumpTo:xe,atEnd:Ce,newCount:gi(t,n),held:P,heldEntries:le}}function Fi(e,t){let n=e?.scrollRect?.height;if(!e||!n||t===0)return null;let r=e.getVirtualItemForOffset(Math.max(0,e.getTotalSize()-n))?.index??0;return[Math.max(0,r-Ni),t-1]}function Ii(e,t){let n=[];return e.forEach((e,r)=>{let i=kt(e);i&&t.some(e=>e>=i.messageId&&e<=i.endMessageId)&&n.push(r)}),n}function Li(e,{topKey:t,anchorMessageId:n,anchorEndMessageId:r}){return At(e,{topKey:t,messageId:n,endMessageId:r})}function Ri(e){return(0,$.jsx)(zi,{...e},e.agentId)}function zi({agentId:e,agentStatus:t,timeline:n,hasMore:r,loading:i,loadedInitial:a,showReasoning:o,pendingApproval:s,blockedLabel:c,canInterrupt:l,searchActive:u,searchCurrentKey:d,searchMatchKeys:f,scrollToOriginalKey:p,scrollToOriginalNonce:m,onScrollerRef:h,hasNewer:g=!1,onLoadOlder:_,onLoadNewer:v,onLoadAround:y,onInterrupt:b,onOpenReferencedPath:x,onPreviewReferencedPath:S,onPreviewReferencedPathEnd:C}){let w=n.length>0?n[n.length-1]:null,T=w?Y(w):null,{virtualizer:E,scrollerRef:ee,headerRef:te,mode:D,opened:O,latestClick:ne,jumpTo:k,atEnd:A,newCount:j,held:M,heldEntries:re}=Pi({agentId:e,timeline:n,loadedInitial:a,hasMore:r,loading:i,latestKey:T,hasNewer:g,onLoadOlder:_,onLoadNewer:v,onLoadAround:y,onScrollerRef:h}),[ie,ae]=(0,Q.useState)(null);(0,Q.useLayoutEffect)(()=>{u&&d&&k(d)},[O,u,d,k]),(0,Q.useLayoutEffect)(()=>{if(!p||!m||!k(p))return;ae(p);let e=setTimeout(()=>ae(null),1600);return()=>clearTimeout(e)},[O,p,m,k]);let oe=(0,Q.useRef)(new Map),N=(0,Q.useMemo)(()=>Rr(n,o,oe.current),[n,o]),P=n.length>0,se=(0,Q.useMemo)(()=>({agentId:e,hasMore:r,loading:i,loadedInitial:a,hasItems:P,latestKey:T,busy:t===`busy`,pendingApproval:s,blockedLabel:c,canInterrupt:l,onInterrupt:b,endGap:N.end}),[e,r,i,a,P,T,t,s,c,l,b,N.end]),ce=ki(n);return(0,$.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,$.jsx)(`div`,{ref:ee,"data-testid":`chat-scroller`,"data-selecting":M||void 0,"data-scroll-mode":O?D.kind:void 0,className:`h-full`,style:{overflowY:`auto`,overflowX:`hidden`,overscrollBehavior:`contain`,overflowAnchor:`none`},children:(0,$.jsxs)(`div`,{style:{position:`relative`,height:E.getTotalSize(),visibility:O?void 0:`hidden`},children:[(0,$.jsx)(`div`,{ref:te,className:`pt-3 md:pt-4`,style:{position:`absolute`,top:0,left:0,width:`100%`},children:(0,$.jsx)(Zr,{context:se})}),E.getVirtualItems().map(t=>{let r=t.index===ce,i=re.get(String(t.key))??n[t.index];return(0,$.jsx)(`div`,{ref:E.measureElement,"data-item-index":t.index,"data-row-key":r?void 0:String(t.key),style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${t.start}px)`},children:r||!i?(0,$.jsx)(`div`,{className:`pb-3 md:pb-4`,children:(0,$.jsx)(Xr,{context:se})}):$r({entry:i,dataIndex:t.index,timeline:n,rowSpacing:N.rows,agentId:e,showReasoning:o,searchActive:u,searchCurrentKey:d,searchMatchKeys:f,originalHighlightKey:ie,onOpenReferencedPath:x,onPreviewReferencedPath:S,onPreviewReferencedPathEnd:C})},r?`footer`:String(t.key))})]})}),!P&&(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-0`,children:(0,$.jsx)(Qr,{context:se})}),P&&!A&&(D.kind===`anchored`||g)&&(0,$.jsx)(ii,{newCount:j,onClick:ne})]})}var Bi=[],Vi=15e3;function Hi(e){return e.kind===`session`&&e.payload?.session?.type===`prompt`}function Ui(e){let t=e.filter(e=>e.kind===`chat`&&k(e.from));return t.length?e.filter(e=>{if(!Hi(e)||!k(e.from))return!0;let n=P(e).trim();if(!n)return!0;let r=U(e.createdAt);return!t.some(e=>P(e).trim()===n&&Math.abs(U(e.createdAt)-r)<=Vi)}):e}var Wi=(0,Q.memo)(function({thread:e=null,onBack:t,showBackButton:n}){let r=T(e=>e.selectedInboxThread),i=T(e=>e.selectedInboxThread?e.agentsById[e.selectedInboxThread]:void 0)||null,o=T(e=>e.inboxDrafts),l=s(),u=T(e=>e.sendChatMessage),f=T(e=>e.openFilesAt),p=T(e=>e.openFilesForAgent),m=T(e=>e.openAgentDetail),h=T(e=>e.chatSending),g=T(e=>e.markInboxThreadRead),v=T(e=>e.markInboxThreadUnread),x=T(e=>e.setReplyDraft),S=T(e=>e.exportThread),C=T(e=>e.doAgentAction),w=T(e=>e.workspaceAction),E=T(e=>e.openWorkspaceFocus),ee=T(e=>e.forkFromAgent),te=T(e=>e.chatHistoryImports),D=T(e=>e.agentChatByAgent[e.selectedInboxThread]),O=D?.messages??Bi,k=T(e=>e.openConfirm),A=T(e=>e.showError),j=T(e=>e.orchestrators),M=T(e=>e.fetchOrchestrators),re=T(e=>e.chatFilters.reasoning),ie=T(e=>e.voiceTtsEnabled),ae=T(e=>e.setVoiceTtsEnabled),oe=T(e=>e.voiceInputMode),N=T(e=>e.plansByThread);(0,Q.useRef)(null);let P=(0,Q.useRef)(null),[le,F]=(0,Q.useState)(`idle`),ue=(0,Q.useRef)([]),[I,R]=(0,Q.useState)([]),[de,B]=(0,Q.useState)(!1),[V,H]=(0,Q.useState)(null),[he,W]=(0,Q.useState)(null),[G,ve]=(0,Q.useState)(``),xe=(0,Q.useRef)(null),Se=(0,Q.useRef)(0),[Ce,we]=(0,Q.useState)(null),[Te,Ee]=(0,Q.useState)(null),De=(0,Q.useCallback)(e=>Ee(t=>({key:e,nonce:(t?.nonce??0)+1})),[]),K=Dr(r),q=(0,Q.useMemo)(()=>Ui(O.filter(e=>ce(r,e)&&!fe(e)).sort((e,t)=>e.id-t.id)),[O,r]),Oe=typeof i?.meta?.lifecycleAction==`string`&&i.meta.lifecycleAction.startsWith(`finalizing-`),{terminalOpen:ke,terminalTarget:Ae,terminalOpening:je,openTerminal:Me,closeTerminal:Ne}=kn(i?.id),Pe=typeof i?.meta?.spawnRequestId==`string`?i.meta.spawnRequestId:``,Fe=(0,Q.useMemo)(()=>te.filter(e=>e.targetAgentId===r||!!(Pe&&e.targetSpawnRequestId===Pe)),[Pe,te,r]),Ie=(0,Q.useMemo)(()=>se(i),[me(i)]),Le=Ie?.pendingApproval,Re=(0,Q.useMemo)(()=>{if(!r||!e&&q.length===0)return null;let t=q[q.length-1]??e?.lastMessage??null,n=e?.previewMessage&&q.some(t=>t.id===e.previewMessage?.id)?e.previewMessage:t;return{id:e?.id??r,peer:r,messages:q,lastMessage:t,previewMessage:n,attention:e?.attention??{unread:0,needsHumanResponse:!1,score:0},archived:e?.archived??!1,draft:e?.draft??``}},[r,e,q]),ze=Re||(Fe.length>0?{peer:r,messages:[],importedHistory:Fe}:null),J=o[r]||``,Be=typeof i?.meta?.tmuxSession==`string`&&i.meta.tmuxSession.trim()?i.meta.tmuxSession:null,He=Be?j.find(e=>e.managedAgents?.some(e=>e.agentId===i.id||e.tmuxSession===Be))??null:null,Ue=!!(Be&&He?.status===`online`&&i?.providerCapabilities?.terminal?.live?.read),Ge=z(i,Ue),Ke=i?.providerCapabilities?.terminal?.attach?.create===!0,qe=Ue||Ke,Je=pe(i,`compact`),Ye=pe(i,`clearContext`),Xe=pe(i,`shutdown`),Ze=pe(i,`interrupt`),Qe=(0,Q.useCallback)(()=>{i&&C(i,`interrupt`)},[i,C]),[$e,et]=(0,Q.useState)(0),[tt,nt]=(0,Q.useState)(!1),rt=i?.providerCapabilities?.liveSession?.slashCommands===!0,it=i?.providerCapabilities?.model?.provider??(typeof i?.meta?.provider==`string`?i.meta.provider:void 0),at=rt&&!tt&&/^\/\S*$/.test(J)?$n(it,i?.providerCapabilities?.context?.compactInstructions===!0).filter(e=>e.name.toLowerCase().startsWith(J.toLowerCase())):[],st=at.length?Math.min($e,at.length-1):0;function Y(e){x(r,`${e.name} `),et(0)}function ft(e){x(r,e),tt&&nt(!1),et(0)}let pt=I.some(e=>e.uploading),mt=I.filter(e=>e.artifact),ht=J.trim().length>0||I.length>0;Ir(i?.id??``,J.trim().length>0),Or(ht,(0,Q.useCallback)(()=>{},[])),ue.current=I,(0,Q.useEffect)(()=>()=>{ct(ue.current)},[]),(0,Q.useEffect)(()=>{i?.meta?.tmuxSession&&j.length===0&&M()},[i?.id,i?.meta?.tmuxSession,j.length]),(0,Q.useEffect)(()=>()=>{xe.current!==null&&window.clearTimeout(xe.current)},[]);let gt=typeof i?.spawnedBy==`string`?i.spawnedBy:void 0,_t=T(e=>gt?e.agentsById[gt]?.meta?.provider:void 0),vt=ne(r,D?.loadedInitial?D.hasMore?q[0]?U(q[0].occurredAt??q[0].createdAt):null:0:null),bt=Pr({agentId:r,filters:T(e=>e.chatFilters),threadMessages:q,statusEvents:K,effortChanges:vt,createdAt:i?.createdAt,importedHistory:Fe,spawnedById:gt,spawnedByProvider:_t,window:D}),xt=bt.timeline,St=(0,Q.useMemo)(()=>ot(i,q,Re?.lastMessage,N),[i,Re?.lastMessage,N,q]),X=Mr(xt),Ct=Xn(r,D?.hasMore??!1,D?.loading??!1,_(D)),wt=(0,Q.useCallback)(()=>{xe.current!==null&&(window.clearTimeout(xe.current),xe.current=null)},[]),Tt=(0,Q.useCallback)(async e=>{let t=lt(j,e);if(!t)return null;try{let n=await be(`GET`,`/orchestrators/${encodeURIComponent(t.id)}/files/stat?path=${encodeURIComponent(e)}`);return{orchestratorId:t.id,path:n.path,type:n.type}}catch{return null}},[j]),Et=(0,Q.useCallback)((e,t,n)=>{if(!dt()||!n)return;let r=++Se.current;Tt(e).then(e=>{Se.current===r&&e&&(wt(),W({...e,line:t||0,anchor:n}),ve(``))})},[wt,Tt]),Dt=(0,Q.useCallback)(()=>{Se.current+=1,wt(),xe.current=window.setTimeout(()=>{W(null)},250)},[wt]),Ot=(0,Q.useCallback)((e,t)=>{Tt(e).then(n=>{if(!n){A(`File Not Found`,e);return}if(dt()){Se.current+=1,wt(),W(null),H({...n,line:t||0}),ve(``);return}n.type===`directory`?f({orchestratorId:n.orchestratorId,path:n.path,overlay:!0}):f({orchestratorId:n.orchestratorId,path:ut(n.path),selectedPath:n.path,line:t,overlay:!0})})},[wt,f,Tt,A]);function kt(){H(null),ve(``)}async function At(e){let t=Array.from(e).filter(e=>e.size>0);if(!t.length)return;let n=t.map(e=>({id:`${Date.now()}-${e.name}-${Math.random().toString(16).slice(2)}`,fileName:e.name,size:e.size,previewUrl:e.type.startsWith(`image/`)?URL.createObjectURL(e):void 0,uploading:!0}));R(e=>[...e,...n]);for(let e=0;e<t.length;e+=1){let r=t[e],i=n[e];try{let e=await ye(`/artifacts`,r,{filename:r.name,sensitivity:`normal`});R(t=>t.map(t=>t.id===i.id?{...t,artifact:e,uploading:!1}:t))}catch(e){R(t=>t.map(t=>t.id===i.id?{...t,error:e.message,uploading:!1}:t))}}}function jt(e){R(t=>{let n=t.find(t=>t.id===e);return n?.previewUrl&&URL.revokeObjectURL(n.previewUrl),t.filter(t=>t.id!==e)})}function Mt(){ct(I),R([])}function Nt(){if(!J.trim()&&mt.length===0||!r||h||pt||Oe)return;let e=mt.map(e=>({artifactId:e.artifact.id,kind:e.artifact.kind,role:`media`,title:e.artifact.filename||e.fileName}));u(J,{peer:r,lastMessage:Re?.lastMessage||null},e),Mt()}function Pt(e){if(at.length){if(e.key===`ArrowDown`){e.preventDefault(),et(e=>Math.min(e+1,at.length-1));return}if(e.key===`ArrowUp`){e.preventDefault(),et(e=>Math.max(e-1,0));return}if(e.key===`Escape`){e.preventDefault(),nt(!0);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault();let t=at[st];t&&Y(t);return}}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),Nt())}function Ft(e){let t=Array.from(e.clipboardData.files).filter(e=>e.type.startsWith(`image/`));t.length&&(e.preventDefault(),At(t))}async function It(){if(!b||le!==`idle`||!r)return;y.bargeIn();let e=new c;try{await e.start(),P.current=e,F(`recording`)}catch(e){P.current=null,F(`idle`),A(`Microphone unavailable`,e?.message||`Could not access the microphone.`)}}async function Lt(){let e=P.current;if(!(!e||le!==`recording`)){P.current=null,F(`transcribing`);try{let t=await e.stop();if(!t)return;let n=await a(t);if(!n)return;let i=J?`${J} ${n}`:n;if(oe===`autosend`&&!h&&!pt){let e=mt.map(e=>({artifactId:e.artifact.id,kind:e.artifact.kind,role:`media`,title:e.artifact.filename||e.fileName}));u(i,{peer:r,lastMessage:Re?.lastMessage||null},e),Mt()}else x(r,i)}catch(e){A(`Transcription failed`,e?.message||`Could not transcribe audio.`,e)}finally{F(`idle`)}}}return r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex h-full min-w-0`,children:[(0,$.jsxs)(`div`,{className:`@container/chat flex h-full min-w-0 flex-1 flex-col`,children:[(0,$.jsx)(lr,{selectedInboxThread:r,agent:i,now:l,blockedState:Ie,thread:Re,exportableThread:ze,importedHistory:Fe,showBackButton:n,onBack:t,openAgentDetail:m,openWorkspaceFocus:E,voiceTtsEnabled:ie,setVoiceTtsEnabled:ae,canOpenTerminal:qe,terminalOpening:je,handleOpenTerminal:Me,canInterrupt:Ze,interruptAgent:Qe,canCompact:Je,canClearContext:Ye,canShutdown:Xe,openConfirm:k,workspaceAction:w,doAgentAction:C,openFilesForAgent:p,forkFromAgent:ee,markInboxThreadUnread:v,markInboxThreadRead:g,exportThread:S,onOpenSearch:X.openSearch}),(0,$.jsx)(_e,{threadId:St&&`threadId`in St?St.threadId:null,teamId:St&&`teamId`in St?St.teamId:void 0,channel:St?.channel}),r&&(0,$.jsx)(ge,{agentId:r}),X.open&&(0,$.jsx)(ur,{query:X.query,position:X.position,total:X.total,onQueryChange:X.setQuery,onNext:X.next,onPrev:X.prev,onClose:X.close}),(0,$.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[(0,$.jsx)(yt,{scrollEl:Ce,timeline:xt,issueRepo:i?.issueRepo,onScrollToOriginal:De}),(0,$.jsx)(Ri,{agentId:r,agentStatus:i?.status,timeline:xt,hasMore:bt.hasMore,loading:bt.loading,loadedInitial:bt.loadedInitial,showReasoning:re,pendingApproval:Le,blockedLabel:Ie?.label,canInterrupt:Ze,searchActive:X.open,searchCurrentKey:X.currentKey,searchMatchKeys:X.matchKeySet,scrollToOriginalKey:Te?.key??null,scrollToOriginalNonce:Te?.nonce??0,onScrollerRef:we,hasNewer:bt.hasNewer,onLoadOlder:Ct.loadOlderForAgent,onLoadNewer:Ct.loadNewerForAgent,onLoadAround:Ct.loadAroundForAgent,onInterrupt:Qe,onOpenReferencedPath:Ot,onPreviewReferencedPath:Et,onPreviewReferencedPathEnd:Dt})]}),(0,$.jsx)(Vn,{agentId:r}),(0,$.jsx)(Cr,{agent:i,draft:J,placeholder:`Message ${i?L(i):r}…`,chatSending:h,disabled:Oe,hasPendingUploads:pt,readyAttachmentCount:mt.length,pendingAttachments:I,micAvailable:b,micState:le,slashMatches:at,slashActiveIndex:st,onDraftChange:ft,onDraftBlur:()=>d(r),onKeyDown:Pt,onPaste:Ft,onUploadFiles:e=>{At(e)},onRemovePendingAttachment:jt,onSend:Nt,onAcceptSlash:Y,onSlashHover:et,onStartPtt:()=>{It()},onStopPtt:()=>{Lt()},footerText:Oe?`${i?L(i):`Agent`} is wrapping up (${(i?.meta?.lifecycleAction).slice(11)}) — messaging paused`:void 0})]}),V&&(0,$.jsxs)(`aside`,{className:`hidden h-full w-[min(44vw,720px)] min-w-[360px] shrink-0 flex-col border-l border-border bg-background xl:flex`,children:[(0,$.jsxs)(`div`,{className:`flex h-10 shrink-0 items-center gap-2 border-b border-border px-3`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-xs font-medium text-muted-foreground`,children:`File preview`}),G&&(0,$.jsx)(`span`,{className:`max-w-[18rem] truncate text-xs text-tone-danger-fg`,children:G}),(0,$.jsx)(Z,{variant:`ghost`,size:`icon-sm`,title:`Close preview`,onClick:kt,children:(0,$.jsx)(cn,{className:`h-3.5 w-3.5`})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:V.type===`directory`?(0,$.jsx)(We,{orchestratorId:V.orchestratorId,selectedPath:V.path,onReadError:ve}):(0,$.jsx)(Ve,{orchestratorId:V.orchestratorId,selectedPath:V.path,line:V.line,onReadError:ve})})]})]}),he&&(0,$.jsx)(Tr,{preview:he,error:G,onReadError:ve,onMouseEnter:wt,onMouseLeave:Dt}),Ae&&(0,$.jsx)(vn,{open:ke,onOpenChange:Ne,orchestratorId:Ae.orchestratorId,session:Ae.session,interactive:Ae.interactive||Ge,canWrite:Ge,onSessionChanged:()=>void Me()})]}):(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full text-center px-4`,children:[(0,$.jsx)(Yt,{className:`w-12 h-12 text-tone-neutral-fg mb-3`}),(0,$.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Select an agent to start chatting`})]})});function Gi(){(0,Q.useEffect)(()=>{let{inboxDrafts:e,agentsById:t,set:n}=T.getState(),r=Object.keys(e);if(r.length===0)return;let i=r.filter(e=>!t[e]&&!k(e));if(i.length===0)return;let a=setTimeout(()=>{let e=T.getState().agentsById,t={...T.getState().inboxDrafts},r=!1;for(let n of i)e[n]||(delete t[n],r=!0);r&&n({inboxDrafts:t})},3e4);return()=>clearTimeout(a)},[])}function Ki(e,t){(0,Q.useEffect)(()=>{if(typeof window>`u`||!e||!window.matchMedia(`(max-width: 767px)`).matches)return;window.history.pushState({chatOpen:!0},``);function n(e){e.state?.chatOpen||t()}return window.addEventListener(`popstate`,n),()=>{window.removeEventListener(`popstate`,n),window.history.state?.chatOpen&&window.history.back()}},[e,t])}function qi(){let e=mn(),t=T(e=>e.selectedInboxThread),n=T(e=>e.closeInboxThread),r=T(e=>e.loadAgentChat),i=T(e=>e.fetchChatHistoryImports),a=!!t,o=(0,Q.useMemo)(()=>e.find(e=>e.peer===t)??null,[e,t]),s=G();return Gi(),(0,Q.useEffect)(()=>{t&&(r(t),i(t))},[t,r,i]),Ki(a,n),(0,$.jsx)(`div`,{className:`flex h-full min-h-0`,children:s?(0,$.jsx)(`div`,{className:`flex w-full overflow-hidden`,children:a?(0,$.jsx)(Ji,{children:(0,$.jsx)(Wi,{thread:o,onBack:n,showBackButton:!0},t||`empty`)}):(0,$.jsx)(`div`,{className:`w-full flex flex-col overflow-hidden`,children:(0,$.jsx)(Yn,{threads:e})})}):(0,$.jsxs)(`div`,{className:`flex w-full`,children:[(0,$.jsx)(`div`,{className:`w-1/3 min-w-[240px] max-w-xs flex flex-col overflow-hidden`,children:(0,$.jsx)(Yn,{threads:e})}),(0,$.jsx)(`div`,{className:`flex-1 flex flex-col overflow-hidden`,children:(0,$.jsx)(Wi,{thread:o},t||`empty`)})]})})}function Ji({children:e}){return(0,$.jsx)(`div`,{className:`fixed inset-x-0 top-0 z-40 flex h-[var(--app-h)] flex-col bg-background pt-[var(--sat)]`,children:e})}export{qi as ChatView};
6
- //# sourceMappingURL=chat-DAIl357U.js.map
6
+ //# sourceMappingURL=chat-Bp3Fx73h.js.map
@@ -1,3 +1,3 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./bundle-web-ifbJd0t-.js","./rolldown-runtime-QTnfLwEv.js","./preload-helper-HclGiUj8.js","./lib-D7DTGM1F.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{p as t,u as n}from"./dist-DeW2Y1R5.js";import{t as r}from"./store-DKPDIZBe.js";import{t as i}from"./themes-G5j9m1Ji.js";import{t as a}from"./loader-circle-BfPd4kOD.js";import{t as o}from"./copy-button-CjOj4HEf.js";import{t as s}from"./preload-helper-HclGiUj8.js";var c=e(t(),1),l=n(),u=500*1024,d={bash:`bash`,c:`c`,conf:`properties`,cpp:`cpp`,cs:`csharp`,css:`css`,csv:`csv`,cts:`typescript`,diff:`diff`,dockerfile:`dockerfile`,env:`dotenv`,gemspec:`ruby`,go:`go`,graphql:`graphql`,h:`c`,hcl:`hcl`,hpp:`cpp`,html:`html`,ini:`ini`,java:`java`,js:`javascript`,json:`json`,jsonc:`jsonc`,jsx:`jsx`,kt:`kotlin`,less:`less`,log:`log`,lua:`lua`,mjs:`javascript`,mts:`typescript`,patch:`diff`,php:`php`,plist:`xml`,podspec:`ruby`,properties:`properties`,py:`python`,rake:`ruby`,rb:`ruby`,rs:`rust`,scss:`scss`,sh:`bash`,sql:`sql`,svelte:`svelte`,swift:`swift`,toml:`toml`,ts:`typescript`,tsx:`tsx`,txt:`text`,vue:`vue`,webmanifest:`json`,xml:`xml`,yaml:`yaml`,yml:`yaml`,zsh:`bash`},f={".bashrc":`bash`,".env":`dotenv`,".eslintrc":`json`,".gitignore":`gitignore`,".npmrc":`properties`,".prettierrc":`json`,".swiftformat":`properties`,".swiftlint.yml":`yaml`,".watchmanconfig":`json`,"app.config":`json`,"app.webmanifest":`json`,berksfile:`ruby`,brewfile:`ruby`,"bun.lock":`json`,capfile:`ruby`,cartfile:`ruby`,"composer.lock":`json`,dangerfile:`ruby`,"deno.lock":`json`,fastfile:`ruby`,"flake.lock":`json`,gemfile:`ruby`,guardfile:`ruby`,podfile:`ruby`,rakefile:`ruby`,dockerfile:`dockerfile`,makefile:`make`},p=null;function m(){return p??=s(()=>import(`./bundle-web-ifbJd0t-.js`),__vite__mapDeps([0,1,2,3]),import.meta.url),p}function h(e){return new TextEncoder().encode(e).length}function g(e){return e.split(`/`).filter(Boolean).pop()||e}function _(e){let t=e?.slice(0,240).split(/\r?\n/,1)[0]?.toLowerCase()||``;return t.startsWith(`#!`)?/\b(bash|dash|ksh|sh|zsh)\b/.test(t)?`bash`:/\bfish\b/.test(t)?`fish`:/\b(ts-node|tsx)\b/.test(t)?`typescript`:/\b(node|bun|deno)\b/.test(t)?`javascript`:/\bpython[0-9.]*\b/.test(t)?`python`:/\bruby\b/.test(t)?`ruby`:/\bswift\b/.test(t)?`swift`:/\bperl\b/.test(t)?`perl`:/\bphp\b/.test(t)?`php`:null:null}function v(e,t,n,r){if(n)return n;let i=g(e).toLowerCase();if(f[i])return f[i];if(i.endsWith(`.d.ts`))return`typescript`;let a=_(r);if(a)return a;let o=i.includes(`.`)?i.slice(i.lastIndexOf(`.`)+1):``;return o&&d[o]?d[o]:t?.includes(`json`)?`json`:t?.includes(`javascript`)?`javascript`:t?.includes(`typescript`)?`typescript`:t?.includes(`xml`)?`xml`:t?.includes(`yaml`)||t?.includes(`yml`)?`yaml`:t?.includes(`shellscript`)?`bash`:null}function y(e,t,n,r){let i=v(e,t,n,r);return!!(i&&i!==`text`&&i!==`log`)}var b=(0,c.memo)(function({content:e,path:t,mediaType:n,languageHint:s,compact:d=!1}){let f=r(e=>e.theme),p=i.find(e=>e.id===f)?.dark??!0,g=(0,c.useMemo)(()=>v(t,n,s,e)||`text`,[e,s,n,t]),_=h(e)>u,[y,b]=(0,c.useState)(``),[x,S]=(0,c.useState)(!1),[C,w]=(0,c.useState)(!1);function T(){return(0,l.jsx)(o,{value:e,label:`Copy code`,copiedLabel:`Copied code`,size:`icon`,variant:`ghost`,className:`absolute right-2 top-2 h-7 w-7 bg-background/80 opacity-0 shadow-sm backdrop-blur transition-opacity hover:bg-muted group-hover/code:opacity-100 focus-visible:opacity-100`})}return(0,c.useEffect)(()=>{if(_||g===`text`||g===`log`){b(``),S(!1),w(!1);return}let t=!1;return S(!0),w(!1),m().then(({codeToHtml:t})=>t(e,{lang:g,theme:p?`github-dark-default`:`github-light-default`})).then(e=>{t||b(e)}).catch(()=>{t||(b(``),w(!0))}).finally(()=>{t||S(!1)}),()=>{t=!0}},[e,p,g,_]),x?(0,l.jsxs)(`div`,{className:`flex items-center gap-2 p-4 text-sm text-muted-foreground`,children:[(0,l.jsx)(a,{className:`h-4 w-4 animate-spin`}),`Highlighting`]}):_||C||!y?(0,l.jsxs)(`div`,{className:`group/code relative`,children:[T(),(0,l.jsx)(`pre`,{className:`overflow-auto whitespace-pre-wrap break-words font-mono text-xs leading-5 ${d?`p-3`:`p-4`}`,children:e||` `})]}):(0,l.jsxs)(`div`,{className:`group/code relative`,children:[T(),(0,l.jsx)(`div`,{className:`code-preview overflow-auto font-mono text-xs leading-5 ${d?`p-3`:`p-4`}`,dangerouslySetInnerHTML:{__html:y}})]})});export{y as n,b as t};
3
- //# sourceMappingURL=code-preview-CzrZfr9U.js.map
2
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{p as t,u as n}from"./dist-DeW2Y1R5.js";import{t as r}from"./store-BgDALGIX.js";import{t as i}from"./themes-G5j9m1Ji.js";import{t as a}from"./loader-circle-BfPd4kOD.js";import{t as o}from"./copy-button-CjOj4HEf.js";import{t as s}from"./preload-helper-HclGiUj8.js";var c=e(t(),1),l=n(),u=500*1024,d={bash:`bash`,c:`c`,conf:`properties`,cpp:`cpp`,cs:`csharp`,css:`css`,csv:`csv`,cts:`typescript`,diff:`diff`,dockerfile:`dockerfile`,env:`dotenv`,gemspec:`ruby`,go:`go`,graphql:`graphql`,h:`c`,hcl:`hcl`,hpp:`cpp`,html:`html`,ini:`ini`,java:`java`,js:`javascript`,json:`json`,jsonc:`jsonc`,jsx:`jsx`,kt:`kotlin`,less:`less`,log:`log`,lua:`lua`,mjs:`javascript`,mts:`typescript`,patch:`diff`,php:`php`,plist:`xml`,podspec:`ruby`,properties:`properties`,py:`python`,rake:`ruby`,rb:`ruby`,rs:`rust`,scss:`scss`,sh:`bash`,sql:`sql`,svelte:`svelte`,swift:`swift`,toml:`toml`,ts:`typescript`,tsx:`tsx`,txt:`text`,vue:`vue`,webmanifest:`json`,xml:`xml`,yaml:`yaml`,yml:`yaml`,zsh:`bash`},f={".bashrc":`bash`,".env":`dotenv`,".eslintrc":`json`,".gitignore":`gitignore`,".npmrc":`properties`,".prettierrc":`json`,".swiftformat":`properties`,".swiftlint.yml":`yaml`,".watchmanconfig":`json`,"app.config":`json`,"app.webmanifest":`json`,berksfile:`ruby`,brewfile:`ruby`,"bun.lock":`json`,capfile:`ruby`,cartfile:`ruby`,"composer.lock":`json`,dangerfile:`ruby`,"deno.lock":`json`,fastfile:`ruby`,"flake.lock":`json`,gemfile:`ruby`,guardfile:`ruby`,podfile:`ruby`,rakefile:`ruby`,dockerfile:`dockerfile`,makefile:`make`},p=null;function m(){return p??=s(()=>import(`./bundle-web-ifbJd0t-.js`),__vite__mapDeps([0,1,2,3]),import.meta.url),p}function h(e){return new TextEncoder().encode(e).length}function g(e){return e.split(`/`).filter(Boolean).pop()||e}function _(e){let t=e?.slice(0,240).split(/\r?\n/,1)[0]?.toLowerCase()||``;return t.startsWith(`#!`)?/\b(bash|dash|ksh|sh|zsh)\b/.test(t)?`bash`:/\bfish\b/.test(t)?`fish`:/\b(ts-node|tsx)\b/.test(t)?`typescript`:/\b(node|bun|deno)\b/.test(t)?`javascript`:/\bpython[0-9.]*\b/.test(t)?`python`:/\bruby\b/.test(t)?`ruby`:/\bswift\b/.test(t)?`swift`:/\bperl\b/.test(t)?`perl`:/\bphp\b/.test(t)?`php`:null:null}function v(e,t,n,r){if(n)return n;let i=g(e).toLowerCase();if(f[i])return f[i];if(i.endsWith(`.d.ts`))return`typescript`;let a=_(r);if(a)return a;let o=i.includes(`.`)?i.slice(i.lastIndexOf(`.`)+1):``;return o&&d[o]?d[o]:t?.includes(`json`)?`json`:t?.includes(`javascript`)?`javascript`:t?.includes(`typescript`)?`typescript`:t?.includes(`xml`)?`xml`:t?.includes(`yaml`)||t?.includes(`yml`)?`yaml`:t?.includes(`shellscript`)?`bash`:null}function y(e,t,n,r){let i=v(e,t,n,r);return!!(i&&i!==`text`&&i!==`log`)}var b=(0,c.memo)(function({content:e,path:t,mediaType:n,languageHint:s,compact:d=!1}){let f=r(e=>e.theme),p=i.find(e=>e.id===f)?.dark??!0,g=(0,c.useMemo)(()=>v(t,n,s,e)||`text`,[e,s,n,t]),_=h(e)>u,[y,b]=(0,c.useState)(``),[x,S]=(0,c.useState)(!1),[C,w]=(0,c.useState)(!1);function T(){return(0,l.jsx)(o,{value:e,label:`Copy code`,copiedLabel:`Copied code`,size:`icon`,variant:`ghost`,className:`absolute right-2 top-2 h-7 w-7 bg-background/80 opacity-0 shadow-sm backdrop-blur transition-opacity hover:bg-muted group-hover/code:opacity-100 focus-visible:opacity-100`})}return(0,c.useEffect)(()=>{if(_||g===`text`||g===`log`){b(``),S(!1),w(!1);return}let t=!1;return S(!0),w(!1),m().then(({codeToHtml:t})=>t(e,{lang:g,theme:p?`github-dark-default`:`github-light-default`})).then(e=>{t||b(e)}).catch(()=>{t||(b(``),w(!0))}).finally(()=>{t||S(!1)}),()=>{t=!0}},[e,p,g,_]),x?(0,l.jsxs)(`div`,{className:`flex items-center gap-2 p-4 text-sm text-muted-foreground`,children:[(0,l.jsx)(a,{className:`h-4 w-4 animate-spin`}),`Highlighting`]}):_||C||!y?(0,l.jsxs)(`div`,{className:`group/code relative`,children:[T(),(0,l.jsx)(`pre`,{className:`overflow-auto whitespace-pre-wrap break-words font-mono text-xs leading-5 ${d?`p-3`:`p-4`}`,children:e||` `})]}):(0,l.jsxs)(`div`,{className:`group/code relative`,children:[T(),(0,l.jsx)(`div`,{className:`code-preview overflow-auto font-mono text-xs leading-5 ${d?`p-3`:`p-4`}`,dangerouslySetInnerHTML:{__html:y}})]})});export{y as n,b as t};
3
+ //# sourceMappingURL=code-preview-KIRZA6cz.js.map
@@ -1,2 +1,2 @@
1
- import{u as e}from"./dist-DeW2Y1R5.js";import{t}from"./store-DKPDIZBe.js";import{nt as n,rt as r,u as i}from"./display-CDeH4I8T.js";import{t as a}from"./play-BbT8m7A0.js";import{t as o}from"./plug-vIyO9_P8.js";import{t as s}from"./power-6tZOhYPg.js";import{t as c}from"./rotate-cw-FPtkDewA.js";import{t as l}from"./square-Bqly37YM.js";import{t as u}from"./stethoscope-SCBrnQQ8.js";import{t as d}from"./button-Do6Z3vvn.js";import{t as f}from"./badge-DqJRtj_p.js";import{o as p,r as m,s as h,t as g}from"./card-C4QJ4hCW.js";var _=e();function v({connector:e}){let v=t(e=>e.runConnectorAction),y=t(e=>e.openConfirm),b=t(e=>e.showNotification),x=i(e),S=e.runtime,C=e.manifest?.commands||{},w=S.installed,T=!!C.start&&w&&!S.running,E=!!C.stop&&S.running,D=!!C.restart&&w,O=!!C.doctor&&w,k=e.displayName||e.id,A=async t=>{try{await v(e.id,t),b(`${t.charAt(0).toUpperCase()+t.slice(1)} completed for ${k}`)}catch{}};return(0,_.jsxs)(g,{className:`hover:border-tone-neutral transition-colors`,children:[(0,_.jsx)(p,{className:`pb-2 pt-4 px-4`,children:(0,_.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,_.jsx)(`div`,{className:`p-1.5 rounded-md ${S.running?`bg-tone-success/10`:`bg-muted`}`,children:(0,_.jsx)(o,{className:`w-4 h-4 ${S.running?`text-tone-success-fg`:`text-tone-neutral-fg`}`})}),(0,_.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,_.jsx)(h,{className:`text-sm font-medium truncate`,children:e.displayName||e.id}),(0,_.jsx)(`div`,{className:`text-xs text-muted-foreground mt-0.5`,children:e.kind})]}),(0,_.jsx)(f,{className:`text-[10px] shrink-0 ${n(x.tone)}`,children:x.label})]})}),(0,_.jsxs)(m,{className:`px-4 pb-4 space-y-2.5`,children:[e.description&&(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed line-clamp-2`,children:e.description}),S.detail&&(0,_.jsx)(`div`,{className:`text-xs px-2 py-1 rounded ${S.status===`error`?`bg-tone-danger/10 text-tone-danger-fg`:S.status===`warn`?`bg-tone-yellow/10 text-tone-yellow-fg`:`bg-muted text-muted-foreground`}`,children:S.detail}),r(e.capabilities).length>0&&(0,_.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:r(e.capabilities).map(e=>(0,_.jsx)(f,{variant:`secondary`,className:`text-[9px] px-1 py-0 h-4`,children:e},e))}),e.version&&(0,_.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`v`,e.version]}),(0,_.jsxs)(`div`,{className:`flex flex-wrap gap-1.5 pt-0.5`,children:[T&&(0,_.jsxs)(d,{size:`sm`,variant:`outline`,className:`h-7 text-xs gap-1 text-tone-success-fg border-tone-success/30 hover:text-tone-success-fg`,onClick:()=>A(`start`),children:[(0,_.jsx)(a,{className:`w-3 h-3`}),`Start`]}),E&&(0,_.jsxs)(d,{size:`sm`,variant:`outline`,className:`h-7 text-xs gap-1 text-tone-danger-fg border-tone-danger/30 hover:text-tone-danger-fg`,onClick:()=>y(`Stop Connector`,`Stop ${e.displayName||e.id}?`,()=>A(`stop`)),children:[(0,_.jsx)(l,{className:`w-3 h-3`}),`Stop`]}),D&&(0,_.jsxs)(d,{size:`sm`,variant:`outline`,className:`h-7 text-xs gap-1`,onClick:()=>y(`Restart Connector`,`Restart ${e.displayName||e.id}?`,()=>A(`restart`)),children:[(0,_.jsx)(c,{className:`w-3 h-3`}),`Restart`]}),O&&(0,_.jsxs)(d,{size:`sm`,variant:`ghost`,className:`h-7 text-xs gap-1 text-muted-foreground`,onClick:()=>A(`doctor`),children:[(0,_.jsx)(u,{className:`w-3 h-3`}),`Doctor`]}),!w&&C.install&&(0,_.jsxs)(d,{size:`sm`,variant:`outline`,className:`h-7 text-xs gap-1`,onClick:()=>A(`install`),children:[(0,_.jsx)(s,{className:`w-3 h-3`}),`Install`]}),w&&C.uninstall&&(0,_.jsx)(d,{size:`sm`,variant:`ghost`,className:`h-7 text-xs text-muted-foreground hover:text-tone-danger-fg`,onClick:()=>y(`Uninstall Connector`,`Uninstall ${e.displayName||e.id}? This will remove the systemd service.`,()=>A(`uninstall`)),children:`Uninstall`})]})]})]})}function y(){let e=t(e=>e.connectors),n=e.filter(e=>e.runtime.running).length;return(0,_.jsxs)(`div`,{className:`space-y-4`,children:[(0,_.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`h2`,{className:`text-base font-semibold`,children:`Connectors`}),(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Installed service connectors and integrations`})]}),(0,_.jsxs)(`div`,{className:`flex items-center gap-2 ml-auto`,children:[(0,_.jsxs)(f,{variant:`outline`,className:`text-xs`,children:[e.length,` total`]}),n>0&&(0,_.jsxs)(f,{className:`text-xs bg-tone-success/15 text-tone-success-fg border-tone-success/30`,children:[n,` running`]})]})]}),e.length===0?(0,_.jsx)(`div`,{className:`text-center py-16 text-muted-foreground text-sm`,children:`No connectors registered.`}):(0,_.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4`,children:e.map(e=>(0,_.jsx)(v,{connector:e},e.id))})]})}export{y as ConnectorsView};
2
- //# sourceMappingURL=connectors-xTxtlyou.js.map
1
+ import{u as e}from"./dist-DeW2Y1R5.js";import{t}from"./store-BgDALGIX.js";import{nt as n,rt as r,u as i}from"./display-BemJG1f_.js";import{t as a}from"./play-BbT8m7A0.js";import{t as o}from"./plug-vIyO9_P8.js";import{t as s}from"./power-6tZOhYPg.js";import{t as c}from"./rotate-cw-FPtkDewA.js";import{t as l}from"./square-Bqly37YM.js";import{t as u}from"./stethoscope-SCBrnQQ8.js";import{t as d}from"./button-Do6Z3vvn.js";import{t as f}from"./badge-DqJRtj_p.js";import{o as p,r as m,s as h,t as g}from"./card-C4QJ4hCW.js";var _=e();function v({connector:e}){let v=t(e=>e.runConnectorAction),y=t(e=>e.openConfirm),b=t(e=>e.showNotification),x=i(e),S=e.runtime,C=e.manifest?.commands||{},w=S.installed,T=!!C.start&&w&&!S.running,E=!!C.stop&&S.running,D=!!C.restart&&w,O=!!C.doctor&&w,k=e.displayName||e.id,A=async t=>{try{await v(e.id,t),b(`${t.charAt(0).toUpperCase()+t.slice(1)} completed for ${k}`)}catch{}};return(0,_.jsxs)(g,{className:`hover:border-tone-neutral transition-colors`,children:[(0,_.jsx)(p,{className:`pb-2 pt-4 px-4`,children:(0,_.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,_.jsx)(`div`,{className:`p-1.5 rounded-md ${S.running?`bg-tone-success/10`:`bg-muted`}`,children:(0,_.jsx)(o,{className:`w-4 h-4 ${S.running?`text-tone-success-fg`:`text-tone-neutral-fg`}`})}),(0,_.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,_.jsx)(h,{className:`text-sm font-medium truncate`,children:e.displayName||e.id}),(0,_.jsx)(`div`,{className:`text-xs text-muted-foreground mt-0.5`,children:e.kind})]}),(0,_.jsx)(f,{className:`text-[10px] shrink-0 ${n(x.tone)}`,children:x.label})]})}),(0,_.jsxs)(m,{className:`px-4 pb-4 space-y-2.5`,children:[e.description&&(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed line-clamp-2`,children:e.description}),S.detail&&(0,_.jsx)(`div`,{className:`text-xs px-2 py-1 rounded ${S.status===`error`?`bg-tone-danger/10 text-tone-danger-fg`:S.status===`warn`?`bg-tone-yellow/10 text-tone-yellow-fg`:`bg-muted text-muted-foreground`}`,children:S.detail}),r(e.capabilities).length>0&&(0,_.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:r(e.capabilities).map(e=>(0,_.jsx)(f,{variant:`secondary`,className:`text-[9px] px-1 py-0 h-4`,children:e},e))}),e.version&&(0,_.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`v`,e.version]}),(0,_.jsxs)(`div`,{className:`flex flex-wrap gap-1.5 pt-0.5`,children:[T&&(0,_.jsxs)(d,{size:`sm`,variant:`outline`,className:`h-7 text-xs gap-1 text-tone-success-fg border-tone-success/30 hover:text-tone-success-fg`,onClick:()=>A(`start`),children:[(0,_.jsx)(a,{className:`w-3 h-3`}),`Start`]}),E&&(0,_.jsxs)(d,{size:`sm`,variant:`outline`,className:`h-7 text-xs gap-1 text-tone-danger-fg border-tone-danger/30 hover:text-tone-danger-fg`,onClick:()=>y(`Stop Connector`,`Stop ${e.displayName||e.id}?`,()=>A(`stop`)),children:[(0,_.jsx)(l,{className:`w-3 h-3`}),`Stop`]}),D&&(0,_.jsxs)(d,{size:`sm`,variant:`outline`,className:`h-7 text-xs gap-1`,onClick:()=>y(`Restart Connector`,`Restart ${e.displayName||e.id}?`,()=>A(`restart`)),children:[(0,_.jsx)(c,{className:`w-3 h-3`}),`Restart`]}),O&&(0,_.jsxs)(d,{size:`sm`,variant:`ghost`,className:`h-7 text-xs gap-1 text-muted-foreground`,onClick:()=>A(`doctor`),children:[(0,_.jsx)(u,{className:`w-3 h-3`}),`Doctor`]}),!w&&C.install&&(0,_.jsxs)(d,{size:`sm`,variant:`outline`,className:`h-7 text-xs gap-1`,onClick:()=>A(`install`),children:[(0,_.jsx)(s,{className:`w-3 h-3`}),`Install`]}),w&&C.uninstall&&(0,_.jsx)(d,{size:`sm`,variant:`ghost`,className:`h-7 text-xs text-muted-foreground hover:text-tone-danger-fg`,onClick:()=>y(`Uninstall Connector`,`Uninstall ${e.displayName||e.id}? This will remove the systemd service.`,()=>A(`uninstall`)),children:`Uninstall`})]})]})]})}function y(){let e=t(e=>e.connectors),n=e.filter(e=>e.runtime.running).length;return(0,_.jsxs)(`div`,{className:`space-y-4`,children:[(0,_.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`h2`,{className:`text-base font-semibold`,children:`Connectors`}),(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Installed service connectors and integrations`})]}),(0,_.jsxs)(`div`,{className:`flex items-center gap-2 ml-auto`,children:[(0,_.jsxs)(f,{variant:`outline`,className:`text-xs`,children:[e.length,` total`]}),n>0&&(0,_.jsxs)(f,{className:`text-xs bg-tone-success/15 text-tone-success-fg border-tone-success/30`,children:[n,` running`]})]})]}),e.length===0?(0,_.jsx)(`div`,{className:`text-center py-16 text-muted-foreground text-sm`,children:`No connectors registered.`}):(0,_.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4`,children:e.map(e=>(0,_.jsx)(v,{connector:e},e.id))})]})}export{y as ConnectorsView};
2
+ //# sourceMappingURL=connectors-k7vO4vvc.js.map