@wrongstack/webui 0.296.4 → 0.297.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/dist/App.d.ts.map +1 -1
  2. package/dist/assets/{AgentRosterView-DTbg5NoZ.js → AgentRosterView-Cje2NBtU.js} +4 -4
  3. package/dist/assets/AnalyticsDashboard-CkceglT6.js +1 -0
  4. package/dist/assets/{AudienceMemoryPanel-C1mj_XOq.js → AudienceMemoryPanel-DB-8ISNP.js} +2 -2
  5. package/dist/assets/{ChangesView-W_UTPolz.js → ChangesView-DouwIaDk.js} +1 -1
  6. package/dist/assets/ChronicleDashboard-B4Khm6hu.js +1 -0
  7. package/dist/assets/CodeEditor-CrKbA5s8.js +1 -0
  8. package/dist/assets/CodeMap-Dz8yNlUe.js +1 -0
  9. package/dist/assets/{CronJobsPanel-0virGKLS.js → CronJobsPanel-CAImDL8t.js} +1 -1
  10. package/dist/assets/{DeadCodeScanPanel-DHsw8Nn4.js → DeadCodeScanPanel-C5ehBTQF.js} +1 -1
  11. package/dist/assets/DebugDashboard-DLNPZIEI.js +1 -0
  12. package/dist/assets/{DesignGalleryView-BSBDNBNf.js → DesignGalleryView-D0azMq2e.js} +1 -1
  13. package/dist/assets/GoalView-gtQRK78W.js +1 -0
  14. package/dist/assets/KanbanView-BXKe19EI.js +3 -0
  15. package/dist/assets/{LazyMarkdown-Bt3iw3ZV.js → LazyMarkdown-BGwFjYKr.js} +3 -3
  16. package/dist/assets/MailboxDetailView-D4fXipos.js +1 -0
  17. package/dist/assets/MemoryManager-D_rquas9.js +1 -0
  18. package/dist/assets/{ModelPicker-CJBOoZME.js → ModelPicker-CN-UD3lc.js} +1 -1
  19. package/dist/assets/OfficeMapPanel-CJFrTNmg.js +4 -0
  20. package/dist/assets/{ProcessMonitor-d_5Iwyo7.js → ProcessMonitor-ButM8C0T.js} +1 -1
  21. package/dist/assets/{QueuePanel-DlNF8CUn.js → QueuePanel-C5oihwYM.js} +1 -1
  22. package/dist/assets/{RefreshDebugView-gPMro5jy.js → RefreshDebugView-DVvWsh9A.js} +1 -1
  23. package/dist/assets/{SageTabs-yP5fr4lP.js → SageTabs-C9vAgvCD.js} +2 -2
  24. package/dist/assets/SddHub-D_nsWjuM.js +2 -0
  25. package/dist/assets/SessionsDashboard-DdwU3Ma5.js +1 -0
  26. package/dist/assets/{SetupScreen-Dsek43zs.js → SetupScreen-CQCfLdPI.js} +1 -1
  27. package/dist/assets/SkillDetailView-mVxi-9jo.js +3 -0
  28. package/dist/assets/{SpecsView-Bu8xHf5j.js → SpecsView-BJs_okSx.js} +1 -1
  29. package/dist/assets/TechStackView-BZ4M7TYc.js +1 -0
  30. package/dist/assets/{TerminalPanel-gA6ThdVE.js → TerminalPanel-W2V0X7b9.js} +1 -1
  31. package/dist/assets/{Toaster-DTJHnKyl.js → Toaster-CbcX_Cou.js} +1 -1
  32. package/dist/assets/{button-Bmh1yFe5.js → button-uGqXvobk.js} +1 -1
  33. package/dist/assets/chat-store-CM1dMeuY.js +17 -0
  34. package/dist/assets/{codemap-activity-store-CkJTt5go.js → codemap-activity-store-DP3mCZu1.js} +1 -1
  35. package/dist/assets/codemap-index-store-DyAe3ZYJ.js +1 -0
  36. package/dist/assets/{dialog-BLr7olIX.js → dialog-CT1PTjzK.js} +1 -1
  37. package/dist/assets/{empty-state-DoEewhfx.js → empty-state-CdyXy96A.js} +1 -1
  38. package/dist/assets/{i18n-C2VyJ0Kz.js → i18n-1BkaqMgr.js} +1 -1
  39. package/dist/assets/index-BPfIz78e.js +131 -0
  40. package/dist/assets/{index-3CuRO3-V.css → index-BlceaIyu.css} +1 -1
  41. package/dist/assets/{input-BRS2rHSR.js → input-B-VCX2sG.js} +1 -1
  42. package/dist/assets/{mailbox-store-BN2cGkN_.js → mailbox-store-DVoNbOZr.js} +1 -1
  43. package/dist/assets/{progress-ring-BEsRLdjq.js → progress-ring-CFOvGxw7.js} +1 -1
  44. package/dist/assets/{roster-ws-CVCrt_ih.js → roster-ws-DXm0krqH.js} +1 -1
  45. package/dist/assets/session-store-BsNYnfOc.js +1 -0
  46. package/dist/assets/{shared-DYL4K3aB.js → shared-jvJxtKc5.js} +1 -1
  47. package/dist/assets/{stores-hEu6z1qz.js → stores-mpa0202y.js} +1 -1
  48. package/dist/assets/{ui-store-BI3LH2q8.js → ui-store-CS-njcmT.js} +1 -1
  49. package/dist/assets/useWebSocket-Dh3aAFDE.js +28 -0
  50. package/dist/assets/{utils-DzRQUvln.js → utils-CN2sfDVP.js} +1 -1
  51. package/dist/assets/{vendor-9hC4n4Me.js → vendor-2VBBgNb5.js} +27 -27
  52. package/dist/assets/{view-navigation-BSA3_knE.js → view-navigation-Cgy5xh9q.js} +1 -1
  53. package/dist/assets/ws-client-WVGn8ORh.js +1 -0
  54. package/dist/components/AnalyticsDashboard.d.ts.map +1 -1
  55. package/dist/components/DebugDashboard.d.ts.map +1 -1
  56. package/dist/components/UpdateBanner.d.ts +8 -0
  57. package/dist/components/UpdateBanner.d.ts.map +1 -0
  58. package/dist/hooks/ws-handlers/chat-handlers.d.ts.map +1 -1
  59. package/dist/hooks/ws-handlers/files-mailbox-handlers.d.ts +2 -1
  60. package/dist/hooks/ws-handlers/files-mailbox-handlers.d.ts.map +1 -1
  61. package/dist/hooks/ws-handlers/session-handlers.d.ts.map +1 -1
  62. package/dist/index.html +21 -21
  63. package/dist/index.js +9165 -8858
  64. package/dist/index.js.map +4 -4
  65. package/dist/lib/ws-client.d.ts.map +1 -1
  66. package/dist/stores/chat-store.d.ts +17 -1
  67. package/dist/stores/chat-store.d.ts.map +1 -1
  68. package/dist/stores/session-store.d.ts +11 -0
  69. package/dist/stores/session-store.d.ts.map +1 -1
  70. package/dist/types/server-message.d.ts +9 -0
  71. package/dist/types/server-message.d.ts.map +1 -1
  72. package/package.json +7 -7
  73. package/dist/assets/AnalyticsDashboard-Xc8aG4ev.js +0 -1
  74. package/dist/assets/ChronicleDashboard-BivxCmdl.js +0 -1
  75. package/dist/assets/CodeEditor-NAOGCzZS.js +0 -1
  76. package/dist/assets/CodeMap-BOhBy8OQ.js +0 -1
  77. package/dist/assets/DebugDashboard-DYEVc0PA.js +0 -1
  78. package/dist/assets/GoalView-C_wodXvj.js +0 -1
  79. package/dist/assets/KanbanView-D7SKeieE.js +0 -3
  80. package/dist/assets/MailboxDetailView-BaFQIyhC.js +0 -1
  81. package/dist/assets/MemoryManager-CWkdwf8F.js +0 -1
  82. package/dist/assets/OfficeMapPanel-BopbmfGN.js +0 -4
  83. package/dist/assets/SddHub-DjeM7IaL.js +0 -2
  84. package/dist/assets/SessionsDashboard-D7b7aEse.js +0 -1
  85. package/dist/assets/SkillDetailView-DxdqTQ5E.js +0 -3
  86. package/dist/assets/TechStackView--7TPHg0R.js +0 -1
  87. package/dist/assets/chat-store-DaSs2P3S.js +0 -13
  88. package/dist/assets/codemap-index-store-8v-MK2XF.js +0 -1
  89. package/dist/assets/index-DSXHr5yP.js +0 -131
  90. package/dist/assets/session-store-w5G2euPs.js +0 -1
  91. package/dist/assets/useWebSocket-Ba38Sknk.js +0 -28
  92. package/dist/assets/ws-client-eyEv8wbm.js +0 -1
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Ai as t,Ct as n,Di as r,Kn as i,Kr as a,Mr as o,Zt as s,_i as c,_n as l,at as u,bt as d,cn as f,ct as p,et as m,ga as h,gi as g,ji as _,jt as v,ln as y,mn as ee,oi as b,ot as te,pa as x,pr as S,rt as C,st as w,wi as T,xa as E,ya as D}from"./vendor-9hC4n4Me.js";import"./i18n-C2VyJ0Kz.js";import{n as O}from"./ui-store-BI3LH2q8.js";import{t as k}from"./useWebSocket-Ba38Sknk.js";import{t as A}from"./utils-DzRQUvln.js";import{t as j}from"./session-store-w5G2euPs.js";import{M as ne,d as M}from"./stores-hEu6z1qz.js";import{_ as N,b as P,f as re,g as F,h as I,v as L,x as ie}from"./index-DSXHr5yP.js";var R=e(E(),1),z=m(),ae=10,oe=20,B=e=>{if(!e)return 0;let t=Date.parse(e);return Number.isNaN(t)?0:t},V=e=>(e.iterationCount??0)+(e.toolCallCount??0)+(e.fileChangeCount??0),se=e=>{let t=Date.parse(e);if(Number.isNaN(t))return``;let n=Math.max(0,Date.now()-t);if(n<6e4)return D.t(`common:time.justNow`);if(n<36e5)return D.t(`common:time.minutesAgo`,{count:Math.floor(n/6e4)});if(n<864e5)return D.t(`common:time.hoursAgo`,{count:Math.floor(n/36e5)});let r=Math.floor(n/864e5);return r<7?D.t(`common:time.daysAgo`,{count:r}):new Date(t).toLocaleDateString()},H=e=>e.lastActivityAt??e.endedAt??e.startedAt;function ce(e){let t=B(e.startedAt);if(!t)return``;let n=e.isCurrent?Date.now():B(e.endedAt)||t,r=Math.max(0,Math.floor((n-t)/6e4));if(r<1)return`<1m`;if(r<60)return`${r}m`;let i=Math.floor(r/60);return i<24?`${i}h ${r%60}m`:`${Math.floor(i/24)}d ${i%24}h`}function U(e){return new Intl.NumberFormat(void 0,{notation:e>=1e3?`compact`:`standard`,maximumFractionDigits:1}).format(e)}function le(e){return e.filter(e=>e.tokenTotal===0&&!e.isCurrent).map(e=>e.id)}function ue(e,t){let n=t.query.trim().toLocaleLowerCase(),r=new Set(t.favoriteIds);return[...e.filter(e=>{if(!(!n||[e.name,e.title,e.lastUserMessage,e.model,e.provider,e.id,...Object.keys(e.toolBreakdown??{})].some(e=>e?.toLocaleLowerCase().includes(n))))return!1;switch(t.filter){case`favorites`:return r.has(e.id);case`active`:return e.isCurrent;case`completed`:return!e.isCurrent&&(e.outcome===`completed`||e.outcome===void 0&&!!e.endedAt);case`issues`:return e.outcome===`error`||e.outcome===`timeout`||e.outcome===`aborted`||(e.toolErrorCount??0)>0;default:return!0}})].sort((e,n)=>{if(t.sort===`tokens`&&n.tokenTotal!==e.tokenTotal)return n.tokenTotal-e.tokenTotal;if(t.sort===`activity`){let t=V(n)-V(e);if(t!==0)return t}return B(H(n))-B(H(e))})}function de(e,t,n=Date.now()){let r=new Date(n);r.setHours(0,0,0,0);let i=r.getTime(),a=i-864e5,o=i-6*864e5,s=new Set(t),c=e.filter(e=>s.has(e.id)),l={today:[],yesterday:[],thisWeek:[],earlier:[]};for(let t of e){if(s.has(t.id))continue;let e=B(H(t));e>=i?l.today.push(t):e>=a?l.yesterday.push(t):e>=o?l.thisWeek.push(t):l.earlier.push(t)}let u=[];c.length>0&&u.push({label:`favorites`,rows:c,favorite:!0});for(let e of[`today`,`yesterday`,`thisWeek`,`earlier`])l[e].length>0&&u.push({label:e,rows:l[e]});return u}function fe(e){return e.reduce((e,t)=>({sessions:e.sessions+1,active:e.active+ +!!t.isCurrent,tokens:e.tokens+t.tokenTotal,tools:e.tools+(t.toolCallCount??0),files:e.files+(t.fileChangeCount??0),errors:e.errors+(t.toolErrorCount??0)+ +(t.outcome===`error`)}),{sessions:0,active:0,tokens:0,tools:0,files:0,errors:0})}function pe(e){if(e.isCurrent)return{icon:x,label:`active`,defaultLabel:`Active`,className:`text-primary`};switch(e.outcome){case`completed`:return{icon:t,label:`completed`,defaultLabel:`Completed`,className:`text-success`};case`error`:return{icon:d,label:`error`,defaultLabel:`Error`,className:`text-destructive`};case`timeout`:return{icon:c,label:`timeout`,defaultLabel:`Timed out`,className:`text-warning`};case`aborted`:return{icon:T,label:`aborted`,defaultLabel:`Aborted`,className:`text-muted-foreground`};default:return e.endedAt?{icon:t,label:`completed`,defaultLabel:`Completed`,className:`text-success`}:{icon:S,label:`saved`,defaultLabel:`Saved session`,className:`text-muted-foreground`}}}function me({stats:e}){let{t}=h();return(0,z.jsx)(`div`,{className:`grid grid-cols-2 border-b border-border/75 bg-card md:grid-cols-5`,children:[{label:t(`activity:sessions.stats.sessions`,{defaultValue:`Sessions`}),value:e.sessions,icon:S},{label:t(`activity:sessions.stats.tokens`,{defaultValue:`Tokens`}),value:e.tokens,icon:x},{label:t(`activity:sessions.stats.tools`,{defaultValue:`Tool calls`}),value:e.tools,icon:te},{label:t(`activity:sessions.stats.files`,{defaultValue:`Files changed`}),value:e.files,icon:a},{label:t(`activity:sessions.stats.errors`,{defaultValue:`Errors`}),value:e.errors,icon:d}].map(e=>{let t=e.icon;return(0,z.jsxs)(`div`,{className:`border-b border-r border-border/75 px-4 py-3 md:border-b-0`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-[0.12em] text-muted-foreground`,children:[(0,z.jsx)(t,{className:`h-3 w-3`}),e.label]}),(0,z.jsx)(`div`,{className:`mt-1 font-mono text-xl font-semibold tabular-nums`,children:U(e.value)})]},e.label)})})}function W({historyQuery:e,setHistoryQuery:t,historyEntries:r,historyLoading:o,historyError:c,wsConnected:p,listSessions:m,resumeSession:g,deleteSession:_,renameSession:y,variant:b=`sidebar`}){let{t:x}=h(),C=O(e=>e.favoriteSessionIds),w=O(e=>e.toggleFavoriteSession),T=O(e=>e.sessionNicknames),E=O(e=>e.setSessionNickname),[D,k]=(0,R.useState)(`all`),[j,ne]=(0,R.useState)(`recent`),[M,N]=(0,R.useState)(null),[P,F]=(0,R.useState)(``),[I,L]=(0,R.useState)(null),[B,V]=(0,R.useState)(1),W=(0,R.useRef)(null),G=(0,R.useRef)(null),K=b===`workspace`,q=(0,R.useCallback)(e=>e.name||T[e.id]||e.title||x(`activity:sessions.empty`),[T,x]),J=(0,R.useCallback)(e=>{N(e.id),F(e.name??T[e.id]??e.title??``)},[T]),Y=(0,R.useCallback)(e=>{N(null),E(e,P),y(e,P)},[P,y,E]);(0,R.useEffect)(()=>{I&&r.some(e=>e.id===I&&e.isCurrent)&&(L(null),W.current&&clearTimeout(W.current))},[r,I]),(0,R.useEffect)(()=>{M&&(G.current?.focus(),G.current?.select())},[M]),(0,R.useEffect)(()=>()=>{W.current&&clearTimeout(W.current)},[]);let X=(0,R.useCallback)(e=>{L(e),g(e),W.current&&clearTimeout(W.current),W.current=setTimeout(()=>L(null),1e4)},[g]),Z=(0,R.useMemo)(()=>le(r),[r]),Q=(0,R.useMemo)(()=>ue(r,{query:e,filter:D,sort:j,favoriteIds:C}),[C,D,r,e,j]),$=K?oe:ae,he=(0,R.useMemo)(()=>Q.slice((B-1)*$,B*$),[B,$,Q]),ge=(0,R.useMemo)(()=>de(he,C),[C,he]),_e=(0,R.useMemo)(()=>fe(r),[r]);(0,R.useEffect)(()=>{V(1)},[D,e,j]),(0,R.useEffect)(()=>{let e=Math.max(1,Math.ceil(Q.length/$));B>e&&V(e)},[B,$,Q.length]);let ve=(0,R.useCallback)(async()=>{if(Z.length!==0&&await ie({title:x(`activity:sessions.deleteEmptyTitle`,{count:Z.length}),message:x(`activity:sessions.deleteEmptyConfirmBody`),confirmLabel:x(`common:action.delete`),danger:!0}))for(let e of Z)_(e)},[_,Z,x]),ye=[{id:`all`,label:x(`activity:sessions.filters.all`,{defaultValue:`All`})},{id:`favorites`,label:x(`activity:sessions.filters.favorites`,{defaultValue:`Pinned`})},{id:`active`,label:x(`activity:sessions.filters.active`,{defaultValue:`Active`})},{id:`completed`,label:x(`activity:sessions.filters.completed`,{defaultValue:`Completed`})},{id:`issues`,label:x(`activity:sessions.filters.issues`,{defaultValue:`Issues`})}];return(0,z.jsxs)(`div`,{className:A(`flex min-h-0 min-w-0 flex-1 flex-col bg-background`,K&&`h-full`),"data-history-variant":b,children:[K?(0,z.jsx)(me,{stats:_e}):null,(0,z.jsxs)(`div`,{className:A(`border-b border-border/75 bg-card`,K?`px-4 py-3`:`px-3 py-2`),children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:x(`activity:sessions.recentSessions`)}),K?(0,z.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:x(`activity:sessions.workspaceHint`,{defaultValue:`Search, inspect, pin and resume every project conversation.`})}):null]}),(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center border border-border/75`,children:[Z.length>0?(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex h-8 items-center justify-center gap-1 border-r border-border/75 px-2 text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive disabled:opacity-40`,onClick:ve,disabled:!p,title:x(`activity:sessions.deleteEmptyTitle`,{count:Z.length}),children:[(0,z.jsx)(n,{className:`h-3.5 w-3.5`}),K?(0,z.jsx)(`span`,{className:`text-[10px]`,children:Z.length}):null]}):null,(0,z.jsx)(`button`,{type:`button`,className:`inline-flex h-8 w-8 items-center justify-center text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-40`,onClick:()=>m(200),disabled:!p,title:x(`common:action.refresh`),children:o?(0,z.jsx)(i,{className:`h-3.5 w-3.5 animate-spin`}):(0,z.jsx)(f,{className:`h-3.5 w-3.5`})})]})]}),(0,z.jsxs)(`div`,{className:A(`grid gap-2`,K?`mt-3 lg:grid-cols-[minmax(18rem,1fr)_auto_auto]`:`mt-2`),children:[(0,z.jsxs)(`div`,{className:`relative min-w-0`,children:[(0,z.jsx)(s,{className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,z.jsx)(`input`,{type:`search`,value:e,onChange:e=>t(e.target.value),placeholder:x(`activity:sessions.filterPlaceholder`),"aria-label":x(`activity:sessions.filterPlaceholder`),className:`h-9 w-full border border-border/75 bg-background pl-8 pr-8 text-xs outline-none transition-colors placeholder:text-muted-foreground/70 focus:border-primary focus:ring-1 focus:ring-primary`}),e?(0,z.jsx)(`button`,{type:`button`,onClick:()=>t(``),className:`absolute right-0 top-0 inline-flex h-9 w-8 items-center justify-center text-muted-foreground hover:text-foreground`,title:x(`activity:sessions.clearFilter`),children:(0,z.jsx)(u,{className:`h-3.5 w-3.5`})}):null]}),(0,z.jsxs)(`fieldset`,{className:`flex min-w-0 overflow-x-auto border border-border/75`,children:[(0,z.jsx)(`legend`,{className:`sr-only`,children:`History filters`}),ye.map(e=>(0,z.jsx)(`button`,{type:`button`,onClick:()=>k(e.id),"aria-pressed":D===e.id,className:A(`h-9 shrink-0 border-r border-border/75 px-2.5 text-[10px] font-semibold uppercase tracking-[0.08em] transition-colors last:border-r-0`,D===e.id?`bg-foreground text-background`:`bg-background text-muted-foreground hover:bg-muted hover:text-foreground`),children:e.label},e.id))]}),(0,z.jsxs)(`select`,{value:j,onChange:e=>ne(e.target.value),"aria-label":x(`activity:sessions.sort.label`,{defaultValue:`Sort sessions`}),className:`h-9 border border-border/75 bg-background px-2 text-[10px] font-semibold uppercase tracking-[0.08em] text-muted-foreground outline-none focus:border-primary`,children:[(0,z.jsx)(`option`,{value:`recent`,children:x(`activity:sessions.sort.recent`,{defaultValue:`Recent`})}),(0,z.jsx)(`option`,{value:`tokens`,children:x(`activity:sessions.sort.tokens`,{defaultValue:`Most tokens`})}),(0,z.jsx)(`option`,{value:`activity`,children:x(`activity:sessions.sort.activity`,{defaultValue:`Most activity`})})]})]})]}),c?(0,z.jsx)(`div`,{className:`border-b border-destructive/30 bg-destructive/5 px-4 py-2 text-xs text-destructive`,children:c}):null,(0,z.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain overflow-x-hidden [scrollbar-gutter:stable]`,children:r.length===0&&!o?(0,z.jsxs)(`div`,{className:`flex min-h-56 flex-col items-center justify-center px-4 py-10 text-center text-muted-foreground`,children:[(0,z.jsx)(S,{className:`h-9 w-9 opacity-25`}),(0,z.jsx)(`p`,{className:`mt-3 text-sm font-medium text-foreground`,children:x(`activity:sessions.noHistory`)}),(0,z.jsx)(`p`,{className:`mt-1 text-xs`,children:x(`activity:sessions.noHistoryHint`)})]}):ge.length===0?(0,z.jsxs)(`div`,{className:`flex min-h-56 flex-col items-center justify-center px-4 py-10 text-center text-muted-foreground`,children:[(0,z.jsx)(s,{className:`h-9 w-9 opacity-25`}),(0,z.jsx)(`p`,{className:`mt-3 text-sm font-medium text-foreground`,children:x(`activity:sessions.noMatches`)}),(0,z.jsx)(`p`,{className:`mt-1 text-xs`,children:x(`activity:sessions.noMatchesHint`)})]}):(0,z.jsxs)(`div`,{className:A(K?`mx-auto w-full max-w-7xl p-4 lg:p-6`:`p-2`),children:[(0,z.jsx)(`div`,{className:A(`space-y-5`,K&&`grid gap-x-5 space-y-0 xl:grid-cols-2`),children:ge.map(e=>(0,z.jsxs)(`section`,{className:`min-w-0`,children:[(0,z.jsxs)(`div`,{className:A(`sticky top-0 z-[1] flex items-center gap-1 border-b border-border/75 bg-background/95 px-1 py-2 text-[10px] font-semibold uppercase tracking-[0.14em] backdrop-blur-sm`,e.favorite?`text-warning`:`text-muted-foreground`),children:[e.favorite?(0,z.jsx)(v,{className:`h-3 w-3 fill-current`}):null,x(`activity:sessions.group.${e.label}`),(0,z.jsx)(`span`,{className:`ml-1 font-mono font-normal text-muted-foreground`,children:e.rows.length})]}),(0,z.jsx)(`div`,{className:`divide-y divide-border/75 border-x border-b border-border/75`,children:e.rows.map(e=>{let t=C.includes(e.id),r=pe(e),o=r.icon,s=M===e.id,c=I===e.id;return(0,z.jsxs)(`article`,{className:A(`group grid min-w-0 grid-cols-[minmax(0,1fr)_auto] bg-card transition-colors`,e.isCurrent?`border-l-2 border-l-primary bg-primary/5`:`border-l-2 border-l-transparent hover:bg-muted/45`),"data-session-id":e.id,children:[s?(0,z.jsxs)(`div`,{className:`min-w-0 px-3 py-3`,children:[(0,z.jsx)(`label`,{className:`block text-[10px] font-semibold uppercase tracking-[0.1em] text-muted-foreground`,htmlFor:`session-name-${e.id}`,children:x(`activity:sessions.rename`,{defaultValue:`Session name`})}),(0,z.jsx)(`input`,{ref:G,id:`session-name-${e.id}`,value:P,onChange:e=>F(e.target.value),onBlur:()=>Y(e.id),onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),Y(e.id)):t.key===`Escape`&&(t.preventDefault(),N(null))},placeholder:e.title||x(`activity:sessions.nicknamePlaceholder`),className:`mt-1 h-8 w-full border border-primary bg-background px-2 text-sm outline-none ring-1 ring-primary`})]}):(0,z.jsx)(`button`,{type:`button`,disabled:e.isCurrent||I!==null,onClick:()=>X(e.id),onDoubleClick:()=>J(e),"aria-current":e.isCurrent?`page`:void 0,className:`min-w-0 px-3 py-3 text-left outline-none focus-visible:bg-muted focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary disabled:cursor-default`,children:(0,z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,z.jsx)(`span`,{className:A(`mt-0.5 shrink-0`,r.className),title:x(`activity:sessions.status.${r.label}`,{defaultValue:r.defaultLabel}),children:(0,z.jsx)(o,{className:A(`h-3.5 w-3.5`,e.isCurrent&&`animate-pulse`)})}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`div`,{className:`truncate text-sm font-semibold text-foreground`,title:q(e),children:q(e)}),(0,z.jsxs)(`div`,{className:`mt-0.5 truncate font-mono text-[10px] text-muted-foreground`,children:[e.provider,`/`,e.model]}),e.lastUserMessage?(0,z.jsx)(`div`,{className:`mt-1 truncate text-xs text-muted-foreground`,title:e.lastUserMessage,children:e.lastUserMessage}):null,(0,z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-2 gap-y-1 font-mono text-[10px] text-muted-foreground`,children:[c?(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-sans font-semibold text-primary`,children:[(0,z.jsx)(i,{className:`h-3 w-3 animate-spin`}),x(`activity:sessions.resuming`)]}):(0,z.jsx)(`span`,{title:new Date(H(e)).toLocaleString(),children:se(H(e))}),(0,z.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,z.jsx)(`span`,{children:ce(e)}),e.tokenTotal>0?(0,z.jsxs)(`span`,{children:[U(e.tokenTotal),` tok`]}):null,(e.messageCount??0)>0?(0,z.jsxs)(`span`,{children:[U(e.messageCount??0),` msg`]}):null,(e.toolCallCount??0)>0?(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,z.jsx)(te,{className:`h-3 w-3`}),e.toolCallCount]}):null,(e.fileChangeCount??0)>0?(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,z.jsx)(a,{className:`h-3 w-3`}),e.fileChangeCount]}):null,(e.toolErrorCount??0)>0?(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-destructive`,children:[(0,z.jsx)(d,{className:`h-3 w-3`}),e.toolErrorCount]}):null]})]})]})}),(0,z.jsxs)(`div`,{className:`flex items-start gap-0.5 p-2`,children:[!e.isCurrent&&K&&!s?(0,z.jsxs)(`button`,{type:`button`,onClick:()=>X(e.id),disabled:I!==null,className:`inline-flex h-7 items-center gap-1 border border-border/75 px-2 text-[10px] font-semibold uppercase tracking-[0.08em] text-muted-foreground hover:border-primary hover:text-primary disabled:opacity-40`,title:x(`activity:sessions.resume`,{defaultValue:`Resume session`}),children:[(0,z.jsx)(ee,{className:`h-3 w-3`}),x(`activity:sessions.resumeShort`,{defaultValue:`Resume`})]}):null,(0,z.jsx)(`button`,{type:`button`,onClick:()=>w(e.id),"aria-pressed":t,className:A(`inline-flex h-7 w-7 items-center justify-center transition-colors hover:bg-warning/10 hover:text-warning`,t?`text-warning`:`text-muted-foreground`),title:x(t?`activity:sessions.unfavorite`:`activity:sessions.markFavorite`),children:(0,z.jsx)(v,{className:A(`h-3.5 w-3.5`,t&&`fill-current`)})}),s?null:(0,z.jsx)(`button`,{type:`button`,onClick:()=>J(e),className:`inline-flex h-7 w-7 items-center justify-center text-muted-foreground transition-colors hover:bg-primary/10 hover:text-primary`,title:x(`activity:sessions.renameAction`,{defaultValue:`Rename`}),children:(0,z.jsx)(l,{className:`h-3.5 w-3.5`})}),e.isCurrent?null:(0,z.jsx)(`button`,{type:`button`,onClick:async()=>{await ie({title:x(`activity:sessions.deleteSessionConfirmTitle`),message:x(`activity:sessions.deleteSessionConfirmBody`,{name:q(e)}),confirmLabel:x(`common:action.delete`),danger:!0})&&_(e.id)},className:`inline-flex h-7 w-7 items-center justify-center text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive`,title:x(`activity:sessions.deleteSessionTitle`),children:(0,z.jsx)(n,{className:`h-3.5 w-3.5`})})]})]},e.id)})})]},e.label))}),(0,z.jsx)(re,{page:B,pageSize:$,totalItems:Q.length,onPageChange:V,compact:!K,itemLabel:`sessions`})]})})]})}var G=12;async function K(e){try{let t=await e.clone().json(),n=typeof t.error==`string`?t.error:t.message;if(typeof n==`string`&&n.trim())return n}catch{try{let t=await e.text();if(t.trim())return t.trim()}catch{}}return e.statusText||`HTTP ${e.status}`}function q(e){switch(e){case`running`:return{icon:(0,z.jsx)(x,{className:`h-3.5 w-3.5`}),cls:`text-success`};case`streaming`:return{icon:(0,z.jsx)(y,{className:`h-3.5 w-3.5`}),cls:`text-primary`};case`waiting_user`:return{icon:(0,z.jsx)(g,{className:`h-3.5 w-3.5`}),cls:`text-warning`};case`error`:return{icon:(0,z.jsx)(_,{className:`h-3.5 w-3.5`}),cls:`text-destructive`};case`idle`:return{icon:(0,z.jsx)(r,{className:`h-3.5 w-3.5`}),cls:`text-muted-foreground`};default:return{icon:(0,z.jsx)(t,{className:`h-3.5 w-3.5`}),cls:`text-muted-foreground`}}}function J(e){switch(e){case`active`:return{icon:(0,z.jsx)(w,{className:`h-3.5 w-3.5`}),cls:`text-success`,badge:`border-success/25 bg-success/8 text-success`};case`idle`:return{icon:(0,z.jsx)(p,{className:`h-3.5 w-3.5`}),cls:`text-primary`,badge:`border-primary/25 bg-primary/10 text-primary`};case`closing`:return{icon:(0,z.jsx)(g,{className:`h-3.5 w-3.5`}),cls:`text-warning`,badge:`border-warning/25 bg-warning/10 text-warning`};case`lost`:return{icon:(0,z.jsx)(p,{className:`h-3.5 w-3.5`}),cls:`text-destructive/60`,badge:`border-destructive/15 bg-destructive/5 text-destructive/70`};default:return{icon:(0,z.jsx)(p,{className:`h-3.5 w-3.5`}),cls:`text-muted-foreground`,badge:`border-border bg-muted text-muted-foreground`}}}function Y(e){let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<1)return`<1m`;if(n<60)return`${n}m`;let r=Math.floor(n/60);return r<24?`${r}h ${n%60}m`:`${Math.floor(r/24)}d`}function X(e){let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/1e3);if(n<10)return D.t(`common:time.justNow`);if(n<60)return D.t(`common:time.secondsAgo`,{count:n});let r=Math.floor(n/60);return r<60?D.t(`common:time.minutesAgo`,{count:r}):D.t(`common:time.hoursAgo`,{count:Math.floor(r/60)})}function Z(){let e=ne(e=>e.wsConnected),t=j(e=>e.session?.id),{entries:n,loading:r,error:i}=M(C(e=>({entries:e.entries,loading:e.loading,error:e.error}))),{listSessions:a,resumeSession:o,deleteSession:s,renameSession:c}=k(),[l,u]=(0,R.useState)(``);return(0,R.useEffect)(()=>{e&&a(200)},[t,a,e]),(0,z.jsx)(W,{historyQuery:l,setHistoryQuery:u,historyEntries:n,historyLoading:r,historyError:i,wsConnected:e,listSessions:a,resumeSession:o,deleteSession:s,renameSession:c,variant:`workspace`})}function Q(){let{t:e}=h();return(0,z.jsxs)(I,{defaultValue:`history`,className:`flex h-full min-h-0 flex-col bg-background`,"data-testid":`sessions-workspace`,children:[(0,z.jsxs)(`header`,{className:`flex shrink-0 flex-col gap-3 border-b border-border/75 bg-card px-4 py-3 lg:flex-row lg:items-center lg:justify-between`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.16em] text-primary`,children:e(`activity:sessions.workspaceEyebrow`,{defaultValue:`Conversation control`})}),(0,z.jsx)(`h1`,{className:`mt-0.5 text-lg font-semibold tracking-tight`,children:e(`activity:sessions.workspaceTitle`,{defaultValue:`Sessions`})})]}),(0,z.jsxs)(N,{className:`h-9 min-h-9 justify-start border-border/75 bg-background p-0 shadow-none`,children:[(0,z.jsxs)(L,{value:`history`,className:`h-9 gap-1.5 border-r border-border/75 px-3 text-xs shadow-none data-[state=active]:bg-foreground data-[state=active]:text-background data-[state=active]:ring-0`,children:[(0,z.jsx)(S,{className:`h-3.5 w-3.5`}),e(`activity:sessions.tabs.history`,{defaultValue:`History`})]}),(0,z.jsxs)(L,{value:`live`,className:`h-9 gap-1.5 px-3 text-xs shadow-none data-[state=active]:bg-foreground data-[state=active]:text-background data-[state=active]:ring-0`,children:[(0,z.jsx)(y,{className:`h-3.5 w-3.5`}),e(`activity:sessions.tabs.live`,{defaultValue:`Live sessions`})]})]})]}),(0,z.jsx)(F,{value:`history`,className:`mt-0 min-h-0 flex-1 overflow-hidden ring-0`,children:(0,z.jsx)(Z,{})}),(0,z.jsx)(F,{value:`live`,className:`mt-0 min-h-0 flex-1 overflow-hidden ring-0`,children:(0,z.jsx)($,{})})]})}function $(){let{t:e}=h(),[t,n]=(0,R.useState)([]),[r,a]=(0,R.useState)(!0),[s,c]=(0,R.useState)(null),[l,u]=(0,R.useState)(1),d=P(`sessions`,!r&&!s&&t.length>0),f=(0,R.useCallback)(async()=>{try{let e=await fetch(`/api/sessions`);if(!e.ok){if(e.status===404){c(null),n([]);return}throw Error(`HTTP ${e.status}: ${await K(e)}`)}if(!(e.headers.get(`content-type`)?.toLowerCase()??``).includes(`application/json`)){c(null),n([]);return}let t=await e.json();if(!Array.isArray(t)){c(null),n([]);return}n(e=>{let n=t;if(e.length===n.length){let t=!0;for(let r=0;r<n.length;r++){let i=n[r],a=e[r];if(i.sessionId!==a.sessionId||i.status!==a.status||i.agentCount!==a.agentCount||i.startedAt!==a.startedAt){t=!1;break}}if(t)return e}return n}),c(null)}catch(e){if(e instanceof SyntaxError){c(null),n([]);return}c(e instanceof Error?e.message:String(e))}finally{a(!1)}},[]);(0,R.useEffect)(()=>{f();let e=setInterval(f,5e3);return()=>clearInterval(e)},[f]);let m=t.filter(e=>e.status===`active`).length,v=t.reduce((e,t)=>e+t.agentCount,0),y=t.slice((l-1)*G,l*G);return(0,R.useEffect)(()=>{let e=Math.max(1,Math.ceil(t.length/G));l>e&&u(e)},[l,t.length]),r?(0,z.jsx)(`div`,{className:`flex h-full min-h-0 items-center justify-center bg-[hsl(var(--surface-2)/0.45)] p-4`,children:(0,z.jsxs)(`div`,{className:`ws-surface flex items-center gap-2 px-4 py-3 text-sm text-muted-foreground`,children:[(0,z.jsx)(i,{className:`h-4 w-4 animate-spin text-primary`}),e(`activity:liveSessions.loading`)]})}):s?(0,z.jsx)(`div`,{className:`flex h-full min-h-0 items-center justify-center bg-[hsl(var(--surface-2)/0.45)] p-4`,children:(0,z.jsxs)(`div`,{className:`ws-surface max-w-lg p-5 text-center`,children:[(0,z.jsx)(_,{className:`mx-auto h-8 w-8 text-warning`}),(0,z.jsx)(`p`,{className:`mt-3 text-sm font-medium`,children:e(`activity:liveSessions.apiUnavailable`)}),(0,z.jsx)(`p`,{className:`mt-1 break-words text-xs text-muted-foreground`,children:s})]})}):t.length===0?(0,z.jsx)(`div`,{className:`flex h-full min-h-0 items-center justify-center bg-[hsl(var(--surface-2)/0.45)] p-4`,children:(0,z.jsxs)(`div`,{className:`ws-surface max-w-md p-6 text-center text-muted-foreground`,children:[(0,z.jsx)(p,{className:`mx-auto h-9 w-9 opacity-50`}),(0,z.jsx)(`p`,{className:`mt-3 text-sm font-medium text-foreground`,children:e(`activity:liveSessions.empty`)}),(0,z.jsx)(`p`,{className:`mt-1 text-xs`,children:e(`activity:liveSessions.autoRefresh`)})]})}):(0,z.jsx)(`div`,{ref:d,className:`h-full min-h-0 overflow-y-auto overscroll-contain bg-[hsl(var(--surface-2)/0.45)] p-4 sm:p-6`,children:(0,z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-6xl flex-col gap-4`,children:[(0,z.jsx)(`header`,{className:`border border-border/70 bg-card/75 p-4`,children:(0,z.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(w,{className:`h-4 w-4 text-primary`}),(0,z.jsx)(`h2`,{className:`text-base font-semibold`,children:e(`activity:liveSessions.heading`,{count:t.length})})]}),(0,z.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:e(`activity:liveSessions.autoRefresh`)})]}),(0,z.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 text-center sm:min-w-[22rem]`,children:[(0,z.jsxs)(`div`,{className:`border border-border/70 bg-background/60 px-3 py-2`,children:[(0,z.jsx)(`div`,{className:`text-lg font-semibold tabular-nums`,children:t.length}),(0,z.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground`,children:`Sessions`})]}),(0,z.jsxs)(`div`,{className:`border border-border/70 bg-background/60 px-3 py-2`,children:[(0,z.jsx)(`div`,{className:`text-lg font-semibold tabular-nums text-success`,children:m}),(0,z.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground`,children:`Active`})]}),(0,z.jsxs)(`div`,{className:`border border-border/70 bg-background/60 px-3 py-2`,children:[(0,z.jsx)(`div`,{className:`text-lg font-semibold tabular-nums`,children:v}),(0,z.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground`,children:`Agents`})]})]})]})}),(0,z.jsx)(`div`,{className:`grid gap-3`,children:y.map(t=>{let n=J(t.status);return(0,z.jsxs)(`article`,{className:`border border-border/70 bg-card/75 p-3 sm:p-4`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3 lg:flex-row lg:items-start lg:justify-between`,children:[(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,z.jsx)(`span`,{className:n.cls,children:n.icon}),(0,z.jsx)(`h3`,{className:`min-w-0 truncate text-sm font-semibold`,title:t.projectName,children:t.projectName}),(0,z.jsx)(`span`,{className:`bg-muted px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground`,children:t.projectSlug}),(0,z.jsx)(`span`,{className:`inline-flex items-center border px-1.5 py-0.5 text-[10px] font-semibold uppercase ${n.badge}`,children:t.status})]}),(0,z.jsxs)(`div`,{className:`mt-2 grid gap-1.5 text-xs text-muted-foreground md:grid-cols-[minmax(0,1fr)_auto]`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,z.jsx)(b,{className:`h-3.5 w-3.5 shrink-0`}),(0,z.jsx)(`span`,{className:`min-w-0 truncate font-mono`,title:t.workingDir,children:t.workingDir})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[t.gitBranch?(0,z.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-1 text-primary`,children:[(0,z.jsx)(o,{className:`h-3.5 w-3.5 shrink-0`}),(0,z.jsx)(`span`,{className:`truncate font-mono`,children:t.gitBranch})]}):null,(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,z.jsx)(g,{className:`h-3.5 w-3.5`}),Y(t.startedAt)]}),(0,z.jsx)(`span`,{className:`font-mono`,children:e(`activity:liveSessions.pidLabel`,{pid:t.pid})})]})]})]}),(0,z.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-xs sm:grid-cols-3 lg:w-64`,children:[(0,z.jsxs)(`div`,{className:`border border-border/70 bg-background/50 px-2 py-1.5`,children:[(0,z.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:`Agents`}),(0,z.jsx)(`div`,{className:`font-semibold tabular-nums`,children:t.agentCount})]}),(0,z.jsxs)(`div`,{className:`border border-border/70 bg-background/50 px-2 py-1.5`,children:[(0,z.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:`Status`}),(0,z.jsx)(`div`,{className:`truncate font-mono font-semibold`,children:t.status})]}),(0,z.jsxs)(`div`,{className:`border border-border/70 bg-background/50 px-2 py-1.5`,children:[(0,z.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:`Runtime`}),(0,z.jsx)(`div`,{className:`font-mono font-semibold`,children:Y(t.startedAt)})]})]})]}),(0,z.jsxs)(`div`,{className:`mt-3 overflow-hidden border border-border/70 bg-background/45`,children:[t.agents.length===0?(0,z.jsx)(`div`,{className:`px-3 py-3 text-xs text-muted-foreground`,children:e(`activity:liveSessions.noAgents`)}):(0,z.jsx)(`div`,{className:`divide-y divide-border/60`,children:t.agents.slice(0,5).map(t=>{let n=q(t.status);return(0,z.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[auto_minmax(0,1fr)] gap-x-2 gap-y-1 px-3 py-2 text-xs sm:grid-cols-[auto_minmax(0,1fr)_minmax(0,14rem)_auto]`,children:[(0,z.jsx)(`span`,{className:A(`mt-0.5 shrink-0`,n.cls),children:n.icon}),(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`div`,{className:`truncate font-medium`,title:t.name,children:t.name}),(0,z.jsx)(`div`,{className:`font-mono text-[10px] text-muted-foreground`,children:e(`activity:liveSessions.agentMeta`,{iter:t.iterations,tools:t.toolCalls,ago:X(t.lastActivityAt)})})]}),(0,z.jsx)(`div`,{className:`min-w-0 font-mono text-[10px] text-muted-foreground sm:text-xs`,children:t.currentTool?(0,z.jsx)(`span`,{className:`block truncate`,title:t.currentTool,children:t.currentTool}):(0,z.jsx)(`span`,{className:`text-muted-foreground/75`,children:t.status})}),(0,z.jsx)(`span`,{className:`hidden font-mono text-[10px] text-muted-foreground sm:block`,children:X(t.lastActivityAt)})]},t.id)})}),t.agents.length>5?(0,z.jsx)(`div`,{className:`border-t border-border/60 px-3 py-2 text-xs text-muted-foreground`,children:e(`activity:liveSessions.andMore`,{count:t.agents.length-5})}):null]})]},t.sessionId)})}),(0,z.jsx)(re,{page:l,pageSize:G,totalItems:t.length,onPageChange:u,itemLabel:`sessions`})]})})}export{Q as SessionsDashboard};
@@ -1,3 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-9hC4n4Me.js","assets/rolldown-runtime-QTnfLwEv.js","assets/monaco-BLUV5g0U.js","assets/monaco-Bowa0-zp.css","assets/markdown-L6DLSM7f.js","assets/vendor-BMdWcCR4.css"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Ar as t,Ct as n,Fi as r,Ii as ee,Ir as te,It as ne,Kn as i,Ri as re,Xi as ie,_n as ae,_r as oe,at as se,ci as ce,cn as le,et as a,ga as o,ni as ue,ta as s,xa as c,xn as de,ya as l}from"./vendor-9hC4n4Me.js";import"./i18n-C2VyJ0Kz.js";import{n as fe}from"./ui-store-BI3LH2q8.js";import{s as u}from"./monaco-BLUV5g0U.js";import{t as pe}from"./useWebSocket-Ba38Sknk.js";import{t as d}from"./utils-DzRQUvln.js";import{o as me}from"./view-navigation-BSA3_knE.js";import{a as he,n as ge,o as _e,t as ve}from"./dialog-BLr7olIX.js";import{d as f}from"./markdown-L6DLSM7f.js";import{s as ye,t as p}from"./LazyMarkdown-Bt3iw3ZV.js";import{b as be}from"./index-DSXHr5yP.js";import{t as xe}from"./empty-state-DoEewhfx.js";var m=e(c(),1),h=a(),g=(0,m.lazy)(()=>u(()=>import(`./vendor-9hC4n4Me.js`).then(e=>e.S),__vite__mapDeps([0,1,2,3,4,5])));function _(e){return e===`project`||e===`user`}function Se(e){let t=e.match(/^(.+?)\/SKILL(?:\.save)?\.md$/);return t?t[1]:null}function Ce({source:e}){let{t}=o(),n=e===`project`?`project`:e===`user`?`user`:`bundled`;return(0,h.jsx)(`span`,{className:d(`inline-flex items-center rounded-md border px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide`,n===`project`&&`border-success/25 bg-success/8 text-success`,n===`user`&&`border-primary/25 bg-primary/10 text-primary`,n===`bundled`&&`border-border/70 bg-muted/60 text-muted-foreground`),children:t(`activity:skillDetail.${{project:`scopeProject`,user:`scopeGlobal`,bundled:`scopeBundled`}[n]}`)})}function v({className:e}){let{t:a}=o(),{client:c}=pe(),u=fe(e=>e.skillsState),v=fe(e=>e.setSkillsState),y=u.selectedSkill,b=u.navHistory,x=u.historyIndex,[S,we]=(0,m.useState)(null),[Te,C]=(0,m.useState)(!1),[w,T]=(0,m.useState)(null),Ee=be(`skill-detail`,!!S),[E,D]=(0,m.useState)(!1),[O,k]=(0,m.useState)(``),[A,j]=(0,m.useState)(!1),[M,N]=(0,m.useState)(null),[P,F]=(0,m.useState)(!1),[I,L]=(0,m.useState)(null),[R,z]=(0,m.useState)(!1),B=(0,m.useRef)(``),[V,H]=(0,m.useState)(!1),[U,W]=(0,m.useState)(null),[De,Oe]=(0,m.useState)(!1),[G,K]=(0,m.useState)(null),[q,ke]=(0,m.useState)(!1),[Ae,je]=(0,m.useState)([]),J=(0,m.useRef)(u);J.current=u;let Y=(0,m.useRef)(!1),X=(0,m.useMemo)(()=>O?{lines:O.split(`
3
- `).length,words:O.trim()?O.trim().split(/\s+/).length:0,chars:O.length}:{lines:0,words:0,chars:0},[O]),Z=(0,m.useMemo)(()=>{if(!O)return null;let e=5*1024*1024,t=new Blob([O]).size;return t>=e?{level:`critical`,used:t,limit:e}:t>=4194304?{level:`warn`,used:t,limit:e}:null},[O]);(0,m.useEffect)(()=>{if(!I)return;let e=setTimeout(()=>L(null),2e3);return()=>clearTimeout(e)},[I]),(0,m.useEffect)(()=>{if(!E||!y)return;let e=setInterval(()=>{O&&O!==B.current&&(B.current=O,localStorage.setItem(`skills_draft_${y.name}`,JSON.stringify({content:O,savedAt:Date.now()})),L(Date.now()))},5e3);return()=>clearInterval(e)},[E,O,y]),(0,m.useEffect)(()=>{if(!y||!E)return;let e=localStorage.getItem(`skills_draft_${y.name}`);if(e)try{let{content:t}=JSON.parse(e);t&&t!==O&&t!==B.current&&(k(t),B.current=t,z(!0))}catch{}},[y?.name,E]),(0,m.useEffect)(()=>{if(!c||!y)return;C(!0),we(null),T(null);let e=setTimeout(()=>{C(!1),T(l.t(`activity:skillDetail.timeoutError`))},1e4),t=t=>{clearTimeout(e);let n=t;n.payload.error?T(n.payload.error):n.payload.name&&we(n.payload),C(!1)},n=e=>{let t=e;H(!1);let n=J.current;if(t.payload.success){let e={...n.knownRefs};for(let n of t.payload.updated??[])e[n.name]=n.newRef;v({...n,knownRefs:e,updateAvailableCount:0}),W({updated:t.payload.updated??[],unchanged:t.payload.unchanged??[],errors:t.payload.errors??[]}),c.send({type:`skills.list`},{echoToChat:!1})}else W({updated:[],unchanged:[],errors:[{name:``,error:t.payload.error??l.t(`activity:skillDetail.updateFailed`)}]})},r=e=>{let t=e;t.payload.skills&&je(t.payload.skills)};return c.on(`skills.content`,t),c.on(`skills.updated`,n),c.on(`skills.list`,r),c.send({type:`skills.content`,payload:{name:y.name,source:y.source}}),()=>{clearTimeout(e),c.off(`skills.content`,t),c.off(`skills.updated`,n),c.off(`skills.list`,r)}},[c,y?.name,y?.source]),(0,m.useEffect)(()=>{E&&(D(!1),k(``),N(null))},[y?.name]);let Q=(0,m.useCallback)(e=>Ae.find(t=>t.name.toLowerCase()===e.toLowerCase()),[Ae]),Me=(0,m.useCallback)(e=>{let t=Q(e);if(t){Y.current=!1;let e=b.slice(0,x+1);e.push(t),v({...J.current,selectedSkill:t,navHistory:e,historyIndex:e.length-1}),D(!1),k(``),W(null)}},[Q,b,x,v]),Ne=(0,m.useCallback)(()=>{if(x<=0)return;Y.current=!0;let e=x-1,t=b[e];v({...J.current,selectedSkill:t,historyIndex:e}),D(!1),k(``),W(null)},[x,b,v]),Pe=(0,m.useCallback)(()=>{if(x>=b.length-1)return;Y.current=!0;let e=x+1,t=b[e];v({...J.current,selectedSkill:t,historyIndex:e}),D(!1),k(``),W(null)},[x,b,v]),$=(0,m.useCallback)(()=>{me(`chat`)},[]),Fe=(0,m.useCallback)(()=>{S&&(k(S.body),B.current=S.body,z(!1),N(null),D(!0),F(!1))},[S]),Ie=(0,m.useCallback)(()=>{D(!1),k(``),N(null),F(!1),z(!1),y&&localStorage.removeItem(`skills_draft_${y.name}`)},[y]),Le=(0,m.useCallback)(()=>{!y||!S||(z(!1),k(S.body),B.current=S.body,y&&localStorage.removeItem(`skills_draft_${y.name}`))},[y,S]),Re=(0,m.useCallback)(()=>{if(!c||!y||!O.trim())return;j(!0),N(null);let e=t=>{let n=t;j(!1),n.payload.success?(B.current=``,localStorage.removeItem(`skills_draft_${y.name}`),z(!1),D(!1),c.send({type:`skills.content`,payload:{name:y.name,source:y.source}}),c.send({type:`skills.list`},{echoToChat:!1})):N(n.payload.error??l.t(`activity:skillDetail.saveFailed`)),c.off(`skills.edited`,e)};c.on(`skills.edited`,e),c.editSkill(y.name,O)},[c,y,O]),ze=(0,m.useCallback)(()=>{!c||!y||(H(!0),W(null),c.checkForUpdates(y.name,y.source===`user`))},[c,y]),Be=(0,m.useCallback)(()=>{y?.sourceUrl&&navigator.clipboard.writeText(y.sourceUrl).then(()=>{Oe(!0),setTimeout(()=>Oe(!1),2e3)})},[y]),Ve=(0,m.useCallback)(()=>{if(!S?.body)return;let e=new Blob([S.body],{type:`text/markdown`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`${S.name.replace(/\//g,`_`)}-SKILL.md`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)},[S]),He=(0,m.useCallback)(async e=>{if(!c||!e)return;ke(!0);let t=e=>{let n=e;ke(!1),n.payload.success?(K(null),c.send({type:`skills.list`},{echoToChat:!1}),$()):N(n.payload.error??l.t(`activity:skillDetail.uninstallFailed`)),c.off(`skills.uninstalled`,t)};c.on(`skills.uninstalled`,t),c.uninstallSkill(e.name,e.source===`user`)},[c,$]);return y?(0,h.jsxs)(`div`,{className:d(`flex h-full min-h-0 min-w-0 flex-col gap-3 overflow-hidden bg-[hsl(var(--surface-2)/0.45)] p-3`,e),children:[(0,h.jsxs)(`div`,{className:`shrink-0 rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,h.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-start lg:justify-between`,children:[(0,h.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,h.jsx)(`span`,{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,h.jsx)(ne,{className:`h-4 w-4`})}),(0,h.jsx)(`h1`,{className:`min-w-0 truncate text-base font-semibold`,children:y.name}),y.version&&(0,h.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`v`,y.version]}),(0,h.jsx)(Ce,{source:y.source})]}),(0,h.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1 line-clamp-2`,children:y.description||y.trigger}),y.sourceUrl&&(0,h.jsxs)(`div`,{className:`mt-2 flex min-w-0 items-center gap-1`,children:[(0,h.jsxs)(`a`,{href:`https://${y.sourceUrl.replace(`github:`,``)}`,target:`_blank`,rel:`noopener noreferrer`,className:`flex min-w-0 items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground`,title:a(`activity:skillDetail.openSourceRepo`),children:[(0,h.jsx)(oe,{className:`h-3 w-3 shrink-0`}),(0,h.jsx)(`span`,{className:`truncate font-mono`,children:y.sourceUrl})]}),(0,h.jsx)(`button`,{type:`button`,onClick:Be,className:`flex shrink-0 items-center text-muted-foreground transition-colors hover:text-foreground`,title:a(`activity:skillDetail.copySourceUrl`),children:De?(0,h.jsx)(re,{className:`h-3 w-3 text-success`}):(0,h.jsx)(ce,{className:`h-3 w-3`})})]}),y.scope.length>0&&(0,h.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-2`,children:y.scope.map(e=>(0,h.jsx)(`span`,{className:`px-1.5 py-0.5 text-[10px] rounded bg-muted text-muted-foreground`,children:e},e))}),U&&(0,h.jsxs)(`div`,{className:`mt-2 text-xs space-y-1`,children:[U.updated.length>0&&(0,h.jsx)(`div`,{className:`text-success`,children:a(`activity:skillDetail.updatedLabel`,{list:U.updated.map(e=>`${e.name} (${e.oldRef} → ${e.newRef})`).join(`, `)})}),U.unchanged.length>0&&(0,h.jsx)(`div`,{className:`text-muted-foreground`,children:a(`activity:skillDetail.upToDateLabel`,{list:U.unchanged.join(`, `)})}),U.errors.length>0&&(0,h.jsx)(`div`,{className:`text-destructive`,children:a(`activity:skillDetail.errorsLabel`,{list:U.errors.map(e=>`${e.name?`${e.name}: `:``}${e.error}`).join(`; `)})})]})]}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 lg:ml-auto lg:shrink-0 lg:justify-end`,children:[_(y.source)&&y.sourceUrl&&(0,h.jsx)(`button`,{type:`button`,onClick:ze,disabled:V,className:`flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:opacity-50`,title:a(`activity:skillDetail.checkUpdatesTitle`),children:V?(0,h.jsx)(i,{className:`h-3.5 w-3.5 animate-spin`}):(0,h.jsx)(le,{className:`h-3.5 w-3.5`})}),y.source!==`bundled`&&!E&&(0,h.jsx)(`button`,{type:`button`,onClick:Ve,className:`flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,title:a(`activity:skillDetail.exportTitle`),children:(0,h.jsx)(ue,{className:`h-3.5 w-3.5`})}),_(y.source)&&!E&&(0,h.jsx)(`button`,{type:`button`,onClick:Fe,className:`flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,title:a(`activity:skillDetail.editTitle`),children:(0,h.jsx)(ae,{className:`h-3.5 w-3.5`})}),_(y.source)&&(0,h.jsx)(`button`,{type:`button`,onClick:()=>K(y),className:`flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive`,title:a(`activity:skillDetail.uninstallTitle`),children:(0,h.jsx)(n,{className:`h-3.5 w-3.5`})}),(0,h.jsx)(`button`,{type:`button`,onClick:$,className:`flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground`,title:a(`activity:skillDetail.closeTitle`),children:(0,h.jsx)(se,{className:`h-4 w-4`})})]})]}),b.length>1&&(0,h.jsxs)(`div`,{className:`mt-3 flex min-w-0 items-center gap-1 rounded-lg border border-border/60 bg-muted/35 px-2 py-1`,children:[(0,h.jsx)(`button`,{type:`button`,onClick:Ne,disabled:x<=0,className:d(`rounded p-1 transition-colors`,x<=0?`text-muted-foreground/65 cursor-not-allowed`:`hover:bg-accent text-muted-foreground cursor-pointer`),title:a(`activity:skillDetail.backTitle`),children:(0,h.jsx)(ee,{className:`h-4 w-4`})}),(0,h.jsx)(`button`,{type:`button`,onClick:Pe,disabled:x>=b.length-1,className:d(`rounded p-1 transition-colors`,x>=b.length-1?`text-muted-foreground/65 cursor-not-allowed`:`hover:bg-accent text-muted-foreground cursor-pointer`),title:a(`activity:skillDetail.forwardTitle`),children:(0,h.jsx)(r,{className:`h-4 w-4`})}),(0,h.jsx)(`div`,{className:`flex items-center gap-0.5 overflow-x-auto text-xs`,children:b.map((e,t)=>(0,h.jsxs)(`span`,{className:`flex items-center shrink-0`,children:[t>0&&(0,h.jsx)(r,{className:`h-3 w-3 text-muted-foreground/65 mx-0.5 shrink-0`}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>{t<x&&(Y.current=!0,v({...J.current,selectedSkill:e,historyIndex:t}),D(!1),k(``),W(null))},className:d(`hover:text-primary cursor-pointer transition-colors`,t===x?`text-primary font-medium`:`text-muted-foreground`),children:e.name})]},e.name+t))})]})]}),S&&(S.relatedFiles.length>0||S.references.length>0)&&(0,h.jsxs)(`div`,{className:`shrink-0 space-y-2 rounded-xl border border-border/70 bg-card/70 px-4 py-3 shadow-sm`,children:[S.relatedFiles.length>0&&(0,h.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground`,children:[(0,h.jsx)(t,{className:`h-3 w-3`}),(0,h.jsx)(`span`,{className:`font-medium uppercase tracking-wide`,children:a(`activity:skillDetail.relatedFiles`)})]}),S.relatedFiles.map(e=>{let t=Se(e);return t&&Q(t)?(0,h.jsxs)(`button`,{type:`button`,onClick:()=>Me(t),className:`inline-flex min-w-0 items-center gap-1 rounded-md border border-border/70 bg-background/60 px-1.5 py-0.5 text-[10px] transition-colors hover:border-primary/40 hover:text-primary`,title:a(`activity:skillDetail.goToSkillTitle`,{name:t}),children:[(0,h.jsx)(s,{className:`h-2.5 w-2.5`}),e]},e):(0,h.jsx)(`span`,{className:`rounded-md border border-border/70 bg-background/60 px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:e},e)})]}),S.references.length>0&&(0,h.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground`,children:[(0,h.jsx)(te,{className:`h-3 w-3`}),(0,h.jsx)(`span`,{className:`font-medium uppercase tracking-wide`,children:a(`activity:skillDetail.references`)})]}),S.references.map(e=>{let t=Se(e)??e.replace(/\.md$/,``);return Q(t)?(0,h.jsxs)(`button`,{type:`button`,onClick:()=>Me(t),className:`inline-flex min-w-0 items-center gap-1 rounded-md border border-primary/20 bg-primary/5 px-1.5 py-0.5 text-[10px] text-primary transition-colors hover:border-primary/30 hover:bg-primary/10`,title:a(`activity:skillDetail.goToSkillTitle`,{name:t}),children:[(0,h.jsx)(s,{className:`h-2.5 w-2.5`}),t]},e):(0,h.jsx)(`span`,{className:`rounded-md bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:t},e)})]})]}),(0,h.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-hidden rounded-xl border border-border/70 bg-card/70 shadow-sm`,children:Te?(0,h.jsxs)(`div`,{className:`flex h-full min-h-[16rem] flex-col items-center justify-center p-8 text-center text-muted-foreground`,children:[(0,h.jsx)(i,{className:`mx-auto mb-2 h-6 w-6 animate-spin text-primary`}),(0,h.jsx)(`p`,{children:a(`activity:skillDetail.loadingContent`)})]}):E?(0,h.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,h.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2 border-b border-border/70 bg-muted/30 px-4 py-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,h.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:a(`activity:skillDetail.editingLabel`,{name:y.name})}),(0,h.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:a(`activity:skillDetail.editStats`,{lines:X.lines,words:X.words,chars:X.chars})}),Z&&(0,h.jsx)(`span`,{className:`text-xs tabular-nums ${Z.level===`critical`?`font-medium text-destructive`:`text-warning`}`,children:a(`activity:skillDetail.charsWarningFmt`,{used:(Z.used/(1024*1024)).toFixed(1),limit:(Z.limit/(1024*1024)).toFixed(0)})}),I&&(0,h.jsx)(`span`,{className:`text-xs text-success animate-pulse`,children:a(`activity:skillDetail.draftSaved`)}),R&&(0,h.jsx)(`span`,{className:`animate-pulse text-xs text-warning`,children:a(`activity:skillDetail.draftRestored`)})]}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[M&&(0,h.jsx)(`span`,{className:`text-xs text-destructive`,children:M}),R&&(0,h.jsx)(`button`,{type:`button`,onClick:Le,className:`rounded-md border border-warning/35 px-2 py-1 text-[10px] text-warning transition-colors hover:bg-warning/10`,children:a(`activity:skillDetail.discardDraft`)}),(0,h.jsx)(`button`,{type:`button`,onClick:Ie,className:`rounded-md border border-border/70 px-2 py-1 text-xs transition-colors hover:bg-accent`,children:a(`common:action.cancel`)}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>F(e=>!e),title:a(P?`activity:skillDetail.hidePreviewTitle`:`activity:skillDetail.splitViewTitle`),className:`rounded-md border px-2 py-1 text-xs transition-colors ${P?`border-primary/40 bg-primary/10 text-primary`:`border-border/70 text-muted-foreground hover:bg-accent`}`,children:(0,h.jsx)(de,{className:`h-3 w-3 inline`})}),(0,h.jsx)(`button`,{type:`button`,onClick:Re,disabled:A||!O.trim(),className:`rounded-md bg-primary px-3 py-1 text-xs text-primary-foreground shadow-sm shadow-primary/15 transition-colors hover:bg-primary/90 disabled:opacity-50`,children:A?(0,h.jsx)(i,{className:`h-3 w-3 animate-spin inline`}):a(`common:action.save`)})]})]}),P?(0,h.jsxs)(`div`,{className:`flex flex-1 min-h-0 gap-0.5`,children:[(0,h.jsx)(`div`,{className:`flex-1 min-w-0 flex flex-col min-h-0`,children:(0,h.jsx)(m.Suspense,{fallback:null,children:(0,h.jsx)(g,{value:O,onChange:e=>k(e.target.value??``),language:`markdown`,className:`flex-1`,style:{fontSize:12,backgroundColor:`transparent`,minHeight:0},placeholder:a(`activity:skillDetail.contentPlaceholder`)})})}),(0,h.jsx)(`div`,{className:`w-px bg-border flex-shrink-0`}),(0,h.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain bg-background/45 p-4 prose prose-sm dark:prose-invert max-w-none`,children:(0,h.jsx)(p,{rehypePlugins:[f],components:ye,children:O})})]}):(0,h.jsx)(m.Suspense,{fallback:null,children:(0,h.jsx)(g,{value:O,onChange:e=>k(e.target.value??``),language:`markdown`,className:`flex-1`,style:{fontSize:12,backgroundColor:`transparent`,minHeight:0},placeholder:a(`activity:skillDetail.contentPlaceholder`)})})]}):S?(0,h.jsx)(`div`,{ref:Ee,className:`h-full min-h-0 overflow-y-auto overscroll-contain p-5 sm:p-6 prose prose-sm dark:prose-invert max-w-none`,children:(0,h.jsx)(p,{rehypePlugins:[f],components:ye,children:S.body})}):w?(0,h.jsxs)(`div`,{className:`flex h-full min-h-[16rem] flex-col items-center justify-center p-8 text-center`,children:[(0,h.jsx)(`p`,{className:`text-destructive mb-2`,children:a(`activity:skillDetail.loadFailed`)}),(0,h.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:w}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>{c&&y&&(C(!0),T(null),c.send({type:`skills.content`,payload:{name:y.name,source:y.source}}))},className:`mt-4 rounded-md border border-border/70 px-3 py-1.5 text-xs transition-colors hover:bg-accent`,children:a(`common:action.retry`)})]}):(0,h.jsx)(`div`,{className:`flex h-full min-h-[16rem] items-center justify-center p-8 text-center text-muted-foreground`,children:a(`activity:skillDetail.noContent`)})}),(0,h.jsx)(ve,{open:!!G,onOpenChange:e=>{e||K(null)},children:(0,h.jsxs)(ge,{className:`flex max-h-[calc(100dvh-2rem)] w-[380px] max-w-[90vw] flex-col gap-0 overflow-hidden p-0`,showCloseButton:!1,children:[(0,h.jsxs)(he,{className:`flex shrink-0 items-center justify-between border-b border-border/70 p-4 sm:flex-row sm:justify-between sm:space-y-0`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(n,{className:`h-4 w-4 text-destructive`}),(0,h.jsx)(_e,{className:`font-semibold text-sm`,children:a(`activity:skillDetail.uninstallSkillHeading`)})]}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>K(null),"aria-label":a(`common:action.close`),className:`rounded p-1 text-muted-foreground hover:bg-accent hover:text-accent-foreground`,children:(0,h.jsx)(se,{className:`h-4 w-4`})})]}),(0,h.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto overscroll-contain p-4`,children:[(0,h.jsx)(`p`,{className:`text-sm`,children:G&&a(`activity:skillDetail.uninstallConfirm`,{name:G.name})}),(0,h.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:G&&a(`activity:skillDetail.uninstallRemovePath`,{path:G.path})})]}),(0,h.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-border/70 bg-muted/20 p-4`,children:[(0,h.jsx)(`button`,{type:`button`,onClick:()=>K(null),disabled:q,className:`rounded-md border border-border/70 px-3 py-1.5 text-xs transition-colors hover:bg-accent disabled:opacity-50`,children:a(`common:action.cancel`)}),(0,h.jsxs)(`button`,{type:`button`,onClick:()=>G&&He(G),disabled:q,className:`flex items-center gap-1.5 rounded-md bg-destructive px-3 py-1.5 text-xs text-destructive-foreground transition-colors hover:bg-destructive/90 disabled:cursor-not-allowed disabled:opacity-50`,children:[q&&(0,h.jsx)(i,{className:`h-3 w-3 animate-spin`}),a(`activity:skillDetail.uninstallAction`)]})]})]})})]}):(0,h.jsx)(xe,{icon:(0,h.jsx)(ie,{className:`h-6 w-6`}),title:a(`activity:skillDetail.noSkillSelected`),description:a(`activity:skillDetail.selectSkillHint`),action:{label:a(`activity:skillDetail.goToChat`),onClick:$},className:e})}export{v as SkillDetailView};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Bt as t,En as n,It as r,Ki as i,Kn as a,Mn as o,N as s,Sr as c,Tr as l,Tt as u,Zr as d,Zt as f,an as p,at as ee,cn as m,da as h,et as g,hi as _,it as v,li as y,ni as te,oa as b,pi as x,qi as S,xa as C}from"./vendor-9hC4n4Me.js";import{t as w}from"./utils-DzRQUvln.js";import{n as T}from"./stores-hEu6z1qz.js";import{t as E}from"./button-Bmh1yFe5.js";import{t as ne}from"./input-BRS2rHSR.js";import{f as D,p as O}from"./index-DSXHr5yP.js";var k=e(C(),1),A=g(),re={current:{label:`Current`,badge:`border-success/35 bg-success/10 text-success`,dot:`bg-success`,weight:0},update_available_safe:{label:`Update available`,badge:`border-info/35 bg-info/10 text-info`,dot:`bg-info`,weight:30},update_available_breaking:{label:`Major update`,badge:`border-warning/35 bg-warning/10 text-warning`,dot:`bg-warning`,weight:50},vulnerable:{label:`Vulnerable`,badge:`border-destructive/45 bg-destructive/15 text-destructive`,dot:`bg-destructive`,weight:100},deprecated:{label:`Deprecated`,badge:`border-destructive/35 bg-destructive/10 text-destructive`,dot:`bg-destructive`,weight:70},yanked:{label:`Yanked`,badge:`border-destructive/45 bg-destructive/15 text-destructive`,dot:`bg-destructive`,weight:80},unmaintained_suspected:{label:`Unmaintained?`,badge:`border-warning/35 bg-warning/10 text-warning`,dot:`bg-warning`,weight:60},blocked_by_constraints:{label:`Blocked`,badge:`border-warning/30 bg-warning/5 text-warning`,dot:`bg-warning`,weight:40},private_or_unresolved:{label:`Private`,badge:`border-border/70 bg-muted text-muted-foreground`,dot:`bg-muted-foreground`,weight:10},local_path:{label:`Local path`,badge:`border-border/70 bg-muted text-muted-foreground`,dot:`bg-muted-foreground`,weight:5},git_dependency:{label:`Git`,badge:`border-border/70 bg-muted text-muted-foreground`,dot:`bg-muted-foreground`,weight:5},unsupported:{label:`Unsupported`,badge:`border-border/70 bg-muted text-muted-foreground`,dot:`bg-muted-foreground`,weight:5},unknown:{label:`Unknown`,badge:`border-border/70 bg-muted text-muted-foreground`,dot:`bg-muted-foreground`,weight:20}},ie={label:`Unknown`,badge:`border-border/70 bg-muted text-muted-foreground`,dot:`bg-muted-foreground`,weight:0};function j(e){return re[e]??ie}var M={npm:{label:`npm / Node.js`,icon:n},python:{label:`Python`,icon:x},rust:{label:`Rust`,icon:t},go:{label:`Go`,icon:p},dotnet:{label:`.NET`,icon:o},php:{label:`PHP`,icon:u},dart:{label:`Dart / Flutter`,icon:y},maven:{label:`Maven`,icon:h},gradle:{label:`Gradle`,icon:S},ruby:{label:`Ruby`,icon:c},swift:{label:`Swift`,icon:v},elixir:{label:`Elixir`,icon:u},cpp:{label:`C / C++`,icon:_}},N={label:`Unknown`};function P(e){return M[e]??N}function F({ecosystem:e,className:t=`size-3.5 shrink-0`}){let n=P(e);if(!n.icon)return null;let r=n.icon;return(0,A.jsx)(r,{className:t})}function ae(e){return j(e.status).weight>=50}var I=[`critical`,`high`,`medium`,`low`,`info`],L={critical:{label:`Critical`,badge:`border-destructive/45 bg-destructive/15 text-destructive`},high:{label:`High`,badge:`border-destructive/35 bg-destructive/10 text-destructive`},medium:{label:`Medium`,badge:`border-warning/35 bg-warning/10 text-warning`},low:{label:`Low`,badge:`border-info/35 bg-info/10 text-info`},info:{label:`Info`,badge:`border-border/70 bg-muted text-muted-foreground`}},R={none:`No action`,upgrade_patch:`Patch upgrade`,upgrade_minor:`Minor upgrade`,upgrade_major:`Major upgrade`,replace:`Replace`,remove:`Remove`,investigate:`Investigate`},z={full:{label:`Full`,badge:`border-success/35 bg-success/10 text-success`,note:void 0},partial:{label:`Partial`,badge:`border-warning/35 bg-warning/10 text-warning`,note:`limited`},unsupported:{label:`Unsupported`,badge:`border-border/70 bg-muted text-muted-foreground`,note:`best-effort`}};function B(e){return z[e]??z.unsupported}function V(e){if(!e)return null;let t=/^\D*(\d+)/.exec(e);if(!t?.[1])return null;let n=Number(t[1]);return Number.isFinite(n)?n:null}function H(e){let t=V(e.locked??e.installed??e.requested),n=V(e.latestStable);if(t===null||n===null||n<=t)return{majorsBehind:0,label:null};let r=n-t;return{majorsBehind:r,label:`${r} major${r===1?``:`s`} behind`}}function U(e){return e.locked??e.installed??e.requested??null}function W(e){return e.confidence<1}function G({className:e,children:t}){return(0,A.jsx)(`span`,{className:w(`inline-flex shrink-0 items-center gap-1 border px-1.5 py-0.5 text-[10px] font-medium`,e),children:t})}function K({label:e,value:t,hint:n,tone:r=`default`}){let i={default:`text-foreground`,success:`text-success`,warning:`text-warning`,info:`text-info`,destructive:`text-destructive`}[r];return(0,A.jsxs)(`div`,{className:`border border-border/70 bg-card/55 px-3 py-2.5 shadow-[inset_0_1px_0_hsl(var(--foreground)/0.035)]`,children:[(0,A.jsx)(`p`,{className:`text-[9px] font-bold uppercase tracking-[0.16em] text-muted-foreground`,children:e}),(0,A.jsxs)(`div`,{className:`mt-1 flex items-end justify-between gap-2`,children:[(0,A.jsx)(`p`,{className:w(`font-mono text-xl font-bold tabular-nums`,i),children:t}),(0,A.jsx)(`p`,{className:`truncate text-[9px] text-muted-foreground`,children:n})]})]})}function oe({dependency:e,findings:t,deepDive:n,onDeepDive:i,onBack:o,coverage:s}){let c=j(e.status),l=U(e),u=H(e),f=s?B(s).note:void 0;return(0,A.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,A.jsxs)(`header`,{className:`shrink-0 border-b border-border/70 bg-card/45 p-3`,children:[(0,A.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,A.jsx)(E,{variant:`ghost`,size:`icon`,onClick:o,"aria-label":`Back to dependency list`,className:`shrink-0 md:hidden`,children:(0,A.jsx)(b,{className:`size-4`})}),(0,A.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,A.jsx)(`h2`,{className:`min-w-0 truncate font-mono text-sm font-bold text-foreground`,children:e.name}),(0,A.jsx)(G,{className:c.badge,children:c.label})]}),(0,A.jsxs)(`p`,{className:`mt-0.5 truncate text-[10px] text-muted-foreground`,children:[P(e.ecosystem).label,` ·`,` `,e.direct?`direct`:`transitive`,` · `,e.scope,` ·`,` `,e.sourceType,f&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`span`,{"aria-hidden":`true`,children:` · `}),(0,A.jsx)(`span`,{className:`text-warning`,children:f})]})]})]})]}),(0,A.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-baseline gap-2 font-mono text-xs`,children:[(0,A.jsx)(`span`,{className:`text-foreground`,children:l??`—`}),e.latestStable&&e.latestStable!==l&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`span`,{className:`text-muted-foreground`,children:`→`}),(0,A.jsx)(`span`,{className:`text-info`,children:e.latestStable})]}),u.label&&(0,A.jsxs)(`span`,{className:`text-[10px] text-warning`,children:[`(`,u.label,`)`]})]})]}),(0,A.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto p-3`,children:[(0,A.jsxs)(`dl`,{className:`grid grid-cols-2 gap-px border border-border/70 bg-border/60`,children:[(0,A.jsx)(q,{label:`Constraint`,value:e.requested??`—`,mono:!0}),(0,A.jsx)(q,{label:`Locked`,value:e.locked??`—`,mono:!0}),(0,A.jsx)(q,{label:`Latest stable`,value:e.latestStable??`—`,mono:!0}),(0,A.jsx)(q,{label:`License`,value:e.license??`—`}),e.wanted&&(0,A.jsx)(q,{label:`Wanted`,value:e.wanted,mono:!0}),e.resolvable&&(0,A.jsx)(q,{label:`Resolvable`,value:e.resolvable,mono:!0}),e.purl&&(0,A.jsx)(q,{label:`PURL`,value:e.purl,mono:!0}),(0,A.jsx)(q,{label:`Registry flags`,value:[e.deprecated&&`deprecated`,e.yanked&&`yanked`].filter(Boolean).join(`, `)||`none`})]}),(0,A.jsxs)(`section`,{className:`mt-4`,children:[(0,A.jsxs)(`div`,{className:`mb-1.5 flex flex-wrap items-center justify-between gap-2`,children:[(0,A.jsx)(`h3`,{className:`text-[9px] font-bold uppercase tracking-[0.16em] text-muted-foreground`,children:`Findings`}),(0,A.jsxs)(E,{variant:`outline`,size:`sm`,onClick:()=>i(e),disabled:n.status===`loading`,className:`h-7 text-[10px]`,children:[n.status===`loading`?(0,A.jsx)(a,{className:`size-3 animate-spin`}):(0,A.jsx)(r,{className:`size-3`}),n.status===`loading`?`Researching…`:`Deep dive`]})]}),n.status===`error`&&n.error&&(0,A.jsx)(`p`,{role:`alert`,className:`mb-1.5 text-[10px] text-destructive`,children:n.error}),t.length===0?(0,A.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Nothing flagged. Run a deep dive to have the model research this package against the web.`}):(0,A.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:t.map(e=>(0,A.jsxs)(`div`,{className:`border border-border/70 bg-card/40 p-2`,children:[(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,A.jsx)(G,{className:L[e.severity].badge,children:L[e.severity].label}),(0,A.jsx)(G,{className:`border-border/70 bg-muted text-muted-foreground`,children:R[e.action]??e.action}),W(e)&&(0,A.jsxs)(G,{className:`border-info/35 bg-info/10 text-info`,children:[(0,A.jsx)(r,{className:`size-2.5`}),`AI · `,Math.round(e.confidence*100),`%`]})]}),(0,A.jsx)(`p`,{className:`mt-1 text-[11px] leading-relaxed text-muted-foreground`,children:e.rationale}),e.breakingRisk&&(0,A.jsx)(`p`,{className:`mt-1 border-l-2 border-warning/40 pl-2 text-[10px] leading-relaxed text-warning`,children:e.breakingRisk})]},e.id))})]}),(0,A.jsxs)(`section`,{className:`mt-4`,children:[(0,A.jsx)(`h3`,{className:`mb-1.5 text-[9px] font-bold uppercase tracking-[0.16em] text-muted-foreground`,children:`Evidence`}),e.evidence.length===0?(0,A.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`No evidence recorded.`}):(0,A.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.evidence.map((t,n)=>(0,A.jsxs)(`li`,{className:`border border-border/70 bg-card/40 p-2`,children:[(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,A.jsx)(G,{className:`border-border/70 bg-muted text-muted-foreground`,children:t.kind}),(0,A.jsx)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:new Date(t.retrievedAt).toLocaleString()})]}),t.source.startsWith(`http`)?(0,A.jsxs)(`a`,{href:t.source,target:`_blank`,rel:`noreferrer noopener`,className:`mt-1 flex min-w-0 items-center gap-1 truncate text-[10px] text-info underline-offset-2 hover:underline`,children:[(0,A.jsx)(`span`,{className:`truncate`,children:t.source}),(0,A.jsx)(d,{className:`size-2.5 shrink-0`})]}):(0,A.jsx)(`p`,{className:`mt-1 truncate font-mono text-[10px] text-muted-foreground`,children:t.source}),t.detail&&(0,A.jsx)(`p`,{className:`mt-0.5 text-[10px] leading-relaxed text-muted-foreground`,children:t.detail})]},`${e.id}-evidence-${n}`))})]})]})]})}function q({label:e,value:t,mono:n}){return(0,A.jsxs)(`div`,{className:`bg-card/55 px-2.5 py-1.5`,children:[(0,A.jsx)(`dt`,{className:`text-[9px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:e}),(0,A.jsx)(`dd`,{className:w(`mt-0.5 truncate text-[11px] text-foreground`,n&&`font-mono`),children:t})]})}var J=`grid grid-cols-[minmax(0,2.2fr)_minmax(0,1.6fr)_minmax(0,1.1fr)] gap-2`;function se({dependencies:e,selectedId:t,hasDependencies:n,coverageByWorkspaceId:r,onSelect:i}){let a=O(e,30);return e.length===0?(0,A.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8 text-center`,children:(0,A.jsx)(`p`,{className:`max-w-xs text-xs text-muted-foreground`,children:n?`No dependencies match the current filters.`:`No dependencies inventoried yet. Run a scan to populate the inventory.`})}):(0,A.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,A.jsxs)(`div`,{className:w(J,`shrink-0 border-b border-border/70 bg-card/45 px-3 py-1.5 text-[9px] font-bold uppercase tracking-[0.14em] text-muted-foreground`),children:[(0,A.jsx)(`span`,{children:`Package`}),(0,A.jsx)(`span`,{children:`Installed → Latest`}),(0,A.jsx)(`span`,{children:`Status`})]}),(0,A.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,A.jsx)(s,{className:`h-full`,"aria-label":`Dependencies`,children:a.pageItems.map(e=>(0,A.jsx)(Y,{dependency:e,selected:e.id===t,coverage:r?.get(e.workspaceId),onSelect:i},e.id))})}),(0,A.jsx)(D,{page:a.page,pageSize:a.pageSize,totalItems:a.totalItems,onPageChange:a.setPage,itemLabel:`dependencies`})]})}function Y({dependency:e,selected:t,coverage:n,onSelect:r}){let i=j(e.status),a=U(e),o=H(e),s=n?B(n).note:void 0;return(0,A.jsxs)(`button`,{type:`button`,onClick:()=>r(e),"aria-current":t,className:w(J,`w-full items-center border-b border-border/40 px-3 py-2 text-left transition-colors hover:bg-accent/40`,t&&`bg-accent/60`),children:[(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,A.jsx)(`span`,{className:w(`size-1.5 shrink-0`,i.dot),"aria-hidden":`true`}),(0,A.jsx)(`span`,{className:`truncate font-mono text-xs text-foreground`,children:e.name})]}),(0,A.jsxs)(`p`,{className:`mt-0.5 truncate text-[10px] text-muted-foreground`,children:[(0,A.jsx)(F,{ecosystem:e.ecosystem,className:`mr-0.5 inline-block size-3 align-text-bottom`}),P(e.ecosystem).label,` · `,e.direct?`direct`:`transitive`,` · `,e.scope,s&&(0,A.jsxs)(A.Fragment,{children:[` · `,(0,A.jsx)(`span`,{className:`text-warning`,children:s})]})]})]}),(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-1.5 font-mono text-[11px]`,children:[(0,A.jsx)(`span`,{className:`truncate text-foreground`,children:a??`—`}),e.latestStable&&e.latestStable!==a&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:`→`}),(0,A.jsx)(`span`,{className:`truncate text-info`,children:e.latestStable})]})]}),o.label?(0,A.jsx)(`p`,{className:`mt-0.5 truncate text-[10px] text-warning`,children:o.label}):e.requested&&(0,A.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-[10px] text-muted-foreground`,children:e.requested})]}),(0,A.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1`,children:[(0,A.jsx)(G,{className:i.badge,children:i.label}),e.deprecated&&(0,A.jsx)(G,{className:`border-destructive/35 bg-destructive/10 text-destructive`,children:`dep`}),e.yanked&&(0,A.jsx)(G,{className:`border-destructive/45 bg-destructive/15 text-destructive`,children:`yank`})]})]})}function ce({findings:e,dependenciesById:t,onSelectDependency:n}){let r=O(e,20);return e.length===0?(0,A.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8 text-center`,children:(0,A.jsxs)(`p`,{className:`max-w-sm text-xs text-muted-foreground`,children:[`No findings. Run `,(0,A.jsx)(`span`,{className:`font-mono text-foreground`,children:`Analyze`}),` to check versions and advisories against upstream registries, then interpret the results.`]})}):(0,A.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,A.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-3`,children:(0,A.jsx)(`div`,{className:`flex flex-col gap-4`,children:I.map(e=>[e,r.pageItems.filter(t=>t.severity===e)]).filter(([,e])=>e.length>0).map(([e,r])=>(0,A.jsxs)(`section`,{children:[(0,A.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2`,children:[(0,A.jsx)(G,{className:L[e].badge,children:L[e].label}),(0,A.jsx)(`span`,{className:`font-mono text-[10px] tabular-nums text-muted-foreground`,children:r.length})]}),(0,A.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:r.map(e=>(0,A.jsx)(X,{finding:e,dependency:t.get(e.dependencyId),onSelectDependency:n},e.id))})]},e))})}),(0,A.jsx)(D,{page:r.page,pageSize:r.pageSize,totalItems:r.totalItems,onPageChange:r.setPage,itemLabel:`findings`})]})}function X({finding:e,dependency:t,onSelectDependency:n}){let i=W(e);return(0,A.jsxs)(`div`,{className:`border border-border/70 bg-card/40 p-2.5`,children:[(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:()=>n(e.dependencyId),className:`min-w-0 truncate font-mono text-xs text-foreground underline-offset-2 hover:underline`,children:t?.name??e.dependencyId}),(0,A.jsx)(G,{className:`border-border/70 bg-muted text-muted-foreground`,children:R[e.action]??e.action}),i&&(0,A.jsxs)(G,{className:`border-info/35 bg-info/10 text-info`,children:[(0,A.jsx)(r,{className:`size-2.5`}),`AI · `,Math.round(e.confidence*100),`%`]})]}),(0,A.jsx)(`p`,{className:`mt-1.5 text-[11px] leading-relaxed text-muted-foreground`,children:e.rationale}),e.breakingRisk&&(0,A.jsx)(`p`,{className:`mt-1 border-l-2 border-warning/40 pl-2 text-[10px] leading-relaxed text-warning`,children:e.breakingRisk}),e.evidence.length>0&&(0,A.jsx)(`ul`,{className:w(`mt-1.5 flex flex-col gap-0.5`),children:e.evidence.slice(0,4).map((t,n)=>(0,A.jsx)(`li`,{className:`min-w-0 truncate text-[10px]`,children:t.source.startsWith(`http`)?(0,A.jsx)(`a`,{href:t.source,target:`_blank`,rel:`noreferrer noopener`,className:`text-info underline-offset-2 hover:underline`,children:t.detail??t.source}):(0,A.jsx)(`span`,{className:`text-muted-foreground`,children:t.detail??t.source})},`${e.id}-${n}`))})]})}function le({searchQuery:e,ecosystemFilter:t,statusFilter:n,directOnly:r,sort:i,hasFilters:a,ecosystems:o,statuses:s,visibleCount:c,totalCount:u,onSearchChange:d,onEcosystemFilterChange:p,onStatusFilterChange:m,onToggleDirectOnly:h,onSortChange:g,onClearFilters:_}){return(0,A.jsxs)(`div`,{className:`shrink-0 space-y-2 border-b border-border/70 bg-card/45 p-3`,children:[(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,A.jsx)(f,{className:`pointer-events-none absolute left-3 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,A.jsx)(ne,{"aria-label":`Search dependencies`,value:e,onChange:e=>d(e.target.value),placeholder:`Search by package name…`,className:`h-10 min-w-0 bg-background pl-9 pr-8 text-xs`}),e&&(0,A.jsx)(`button`,{type:`button`,"aria-label":`Clear search`,onClick:()=>d(``),className:`absolute right-2 top-1/2 -translate-y-1/2 p-1 text-muted-foreground hover:text-foreground`,children:(0,A.jsx)(ee,{className:`size-3.5`})})]}),(0,A.jsx)(E,{variant:r?`default`:`outline`,size:`sm`,onClick:h,"aria-pressed":r,title:`Show only dependencies this project declares itself`,className:`shrink-0`,children:`Direct only`}),a&&(0,A.jsx)(E,{variant:`ghost`,size:`icon`,onClick:_,"aria-label":`Clear all filters`,title:`Clear all filters`,className:`shrink-0`,children:(0,A.jsx)(l,{className:`size-4`})})]}),(0,A.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`sr-only`,htmlFor:`techstack-ecosystem-filter`,children:`Filter by ecosystem`}),(0,A.jsxs)(`select`,{id:`techstack-ecosystem-filter`,value:t,onChange:e=>p(e.target.value),className:`h-9 w-full min-w-0 border border-input bg-background px-2 text-xs`,children:[(0,A.jsx)(`option`,{value:`all`,children:`All ecosystems`}),o.map(([e,t])=>(0,A.jsxs)(`option`,{value:e,children:[P(e).label,` · `,t]},e))]})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`sr-only`,htmlFor:`techstack-status-filter`,children:`Filter by status`}),(0,A.jsxs)(`select`,{id:`techstack-status-filter`,value:n,onChange:e=>m(e.target.value),className:`h-9 w-full min-w-0 border border-input bg-background px-2 text-xs`,children:[(0,A.jsx)(`option`,{value:`all`,children:`All statuses`}),s.map(([e,t])=>(0,A.jsxs)(`option`,{value:e,children:[j(e).label,` · `,t]},e))]})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`sr-only`,htmlFor:`techstack-sort`,children:`Sort dependencies`}),(0,A.jsxs)(`select`,{id:`techstack-sort`,value:i,onChange:e=>g(e.target.value),className:`h-9 w-full min-w-0 border border-input bg-background px-2 text-xs`,children:[(0,A.jsx)(`option`,{value:`attention`,children:`Sort: needs attention`}),(0,A.jsx)(`option`,{value:`drift`,children:`Sort: most out of date`}),(0,A.jsx)(`option`,{value:`name`,children:`Sort: name`})]})]})]}),(0,A.jsx)(`p`,{className:w(`text-[10px] text-muted-foreground`,a&&`text-info`),children:c===u?`${u} dependencies`:`${c} of ${u} dependencies`})]})}var ue=[{id:`dependencies`,label:`Dependencies`},{id:`findings`,label:`Findings`},{id:`workspaces`,label:`Workspaces`},{id:`trends`,label:`Trends`},{id:`remediation`,label:`Remediation`}],Z=new Set([`npm`,`python`,`rust`,`go`,`php`,`dotnet`]);function de(){let e=T(e=>e.snapshot),t=T(e=>e.stale),n=T(e=>e.loading),i=T(e=>e.error),o=T(e=>e.activeJob),[s,c]=(0,k.useState)(`dependencies`),[l,u]=(0,k.useState)(``),[d,f]=(0,k.useState)(`all`),[p,h]=(0,k.useState)(`all`),[g,_]=(0,k.useState)(!1),[v,y]=(0,k.useState)(`attention`),[b,x]=(0,k.useState)(null),[S,C]=(0,k.useState)([]),[ne,D]=(0,k.useState)({status:`idle`,error:null}),[O,re]=(0,k.useState)(null),[ie,M]=(0,k.useState)(null),[N,P]=(0,k.useState)(new Set),[F,I]=(0,k.useState)(!1),L=(0,k.useCallback)(async()=>{let e=T.getState();e.setLoading(!0),e.setError(null);try{let t=await fetch(`/api/techstack/snapshot`);if(t.status===404){e.setSnapshot(null,!1);return}if(!t.ok)throw Error(`HTTP ${t.status}: ${t.statusText}`);let n=await t.json();e.setSnapshot(n.snapshot,n.stale)}catch(t){e.setError(t instanceof Error?t.message:String(t))}},[]),R=(0,k.useCallback)(async e=>{let t=T.getState();t.setLoading(!0),t.setError(null);try{let n=await fetch(`/api/techstack/${e}`,{method:`POST`}),r=await n.json();if(!n.ok||!r.jobId)throw Error(r.error??`HTTP ${n.status}: ${n.statusText}`);t.jobStarted(r.jobId,e)}catch(e){t.setError(e instanceof Error?e.message:String(e))}},[]),z=(0,k.useCallback)(async()=>{let e=T.getState().activeJob;if(e)try{let t=await fetch(`/api/techstack/jobs/${encodeURIComponent(e.id)}/cancel`,{method:`POST`});if(!t.ok)throw Error(`HTTP ${t.status}: ${t.statusText}`);T.getState().jobCancelled(e.id)}catch(e){T.getState().setError(e instanceof Error?e.message:String(e))}},[]),B=(0,k.useCallback)(async e=>{D({status:`loading`,error:null});try{let t=await fetch(`/api/techstack/deps/${encodeURIComponent(e.id)}/research`,{method:`POST`}),n=await t.json();if(!t.ok)throw Error(n.error??`HTTP ${t.status}`);C(n.findings??[]),D({status:`idle`,error:null})}catch(e){D({status:`error`,error:e instanceof Error?e.message:String(e)})}},[]);(0,k.useEffect)(()=>{L()},[L]),(0,k.useEffect)(()=>{s!==`trends`&&s!==`remediation`||fetch(`/api/techstack/${s===`trends`?`trends`:`remediation`}`).then(async e=>{let t=await e.json();if(!e.ok)throw Error(t.error??`HTTP ${e.status}`);t.trend&&re(t.trend),t.plan&&M(t.plan)}).catch(e=>T.getState().setError(e instanceof Error?e.message:String(e)))},[s,e?.id]);let V=(0,k.useCallback)(async()=>{if(N.size!==0){I(!0);try{let e=await fetch(`/api/techstack/remediation/apply`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({approvedItems:[...N]})}),t=await e.json();if(!e.ok)throw Error(t.error??`HTTP ${e.status}`);P(new Set),await R(`inventory`)}catch(e){T.getState().setError(e instanceof Error?e.message:String(e))}finally{I(!1)}}},[N,R]);(0,k.useEffect)(()=>{C([]),D({status:`idle`,error:null})},[e?.id]);let U=(0,k.useMemo)(()=>e?.dependencies??[],[e]),W=(0,k.useMemo)(()=>e?.findings??[],[e]),G=(0,k.useMemo)(()=>new Map(U.map(e=>[e.id,e])),[U]),q=(0,k.useMemo)(()=>ge(U.map(e=>e.ecosystem)),[U]),J=(0,k.useMemo)(()=>ge(U.map(e=>e.status)),[U]),Y=(0,k.useMemo)(()=>new Map(e?.workspaces.map(e=>[e.id,e.coverage])??[]),[e]),X=(0,k.useMemo)(()=>{let e=l.trim().toLowerCase(),t=[...U.filter(t=>!(e&&!t.name.toLowerCase().includes(e)||d!==`all`&&t.ecosystem!==d||p!==`all`&&t.status!==p||g&&!t.direct))];return v===`name`?t.sort((e,t)=>e.name.localeCompare(t.name)):v===`drift`?t.sort((e,t)=>H(t).majorsBehind-H(e).majorsBehind||e.name.localeCompare(t.name)):t.sort((e,t)=>j(t.status).weight-j(e.status).weight||Number(t.direct)-Number(e.direct)||e.name.localeCompare(t.name)),t},[U,l,d,p,g,v]),Z=b?G.get(b):void 0,de=(0,k.useMemo)(()=>Z?[...W.filter(e=>e.dependencyId===Z.id),...S.filter(e=>e.dependencyId===Z.id)]:[],[W,S,Z]),ve=(0,k.useMemo)(()=>U.filter(ae).length,[U]),ye=(0,k.useMemo)(()=>U.filter(e=>H(e).majorsBehind>0).length,[U]),be=(0,k.useMemo)(()=>U.filter(e=>e.status===`vulnerable`).length,[U]),xe=l.trim()!==``||d!==`all`||p!==`all`||g,Se=(0,k.useCallback)(()=>{u(``),f(`all`),h(`all`),_(!1)},[]),$=!!(o&&![`completed`,`failed`,`cancelled`].includes(o.status)),Ce=(0,k.useCallback)(e=>{x(e),c(`dependencies`)},[]);return(0,A.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,A.jsx)(`header`,{className:`shrink-0 border-b border-border/70 px-4 py-3`,children:(0,A.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3`,children:[(0,A.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,A.jsx)(`h1`,{className:`text-base font-bold sm:text-lg`,children:`TechStack`}),(0,A.jsx)(`span`,{className:`border border-info/35 bg-info/10 px-2 py-0.5 font-mono text-[9px] font-bold uppercase text-info`,children:e?`${e.workspaces.length} workspaces`:`no scan yet`}),t&&(0,A.jsx)(`span`,{className:`border border-warning/35 bg-warning/10 px-2 py-0.5 font-mono text-[9px] font-bold uppercase text-warning`,children:`stale >24h`})]}),(0,A.jsx)(`p`,{className:`mt-0.5 truncate text-[10px] text-muted-foreground sm:text-xs`,children:e?`${e.targetRoot} · scanned ${new Date(e.createdAt).toLocaleString()}`:`Scan the open project to inventory its dependencies.`})]}),(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,A.jsxs)(E,{variant:`outline`,size:`sm`,onClick:()=>void R(`inventory`),disabled:$,title:`Offline: re-read manifests and lockfiles`,children:[(0,A.jsx)(m,{className:w(`size-3.5`,$&&`animate-spin`)}),(0,A.jsx)(`span`,{className:`hidden sm:inline`,children:`Refresh`})]}),(0,A.jsxs)(E,{size:`sm`,onClick:()=>void R(`analyze`),disabled:$,title:`Check registries and advisories, then interpret the results with the model`,children:[(0,A.jsx)(r,{className:`size-3.5`}),`Analyze`]}),$&&(0,A.jsx)(E,{variant:`ghost`,size:`icon`,onClick:()=>void z(),"aria-label":`Cancel job`,children:(0,A.jsx)(ee,{className:`size-4`})}),(0,A.jsx)(E,{variant:`ghost`,size:`icon`,onClick:()=>e&&_e(e),disabled:!e,"aria-label":`Export snapshot as JSON`,title:`Export snapshot as JSON`,children:(0,A.jsx)(te,{className:`size-4`})})]})]})}),e&&(0,A.jsxs)(`div`,{className:`grid shrink-0 grid-cols-2 gap-px border-b border-border/70 bg-border/60 sm:grid-cols-4`,children:[(0,A.jsx)(K,{label:`Dependencies`,value:U.length,hint:`${X.length} visible`}),(0,A.jsx)(K,{label:`Outdated`,value:ye,hint:`majors behind`,tone:ye>0?`warning`:`success`}),(0,A.jsx)(K,{label:`Vulnerable`,value:be,hint:`known advisories`,tone:be>0?`destructive`:`success`}),(0,A.jsx)(K,{label:`Findings`,value:W.length,hint:`${ve} need attention`,tone:W.length>0?`info`:`default`})]}),($||i)&&(0,A.jsxs)(`div`,{className:`shrink-0 border-b border-border/70 px-4 py-2`,"aria-live":`polite`,children:[$&&o&&(0,A.jsxs)(`div`,{role:`status`,className:`flex items-center gap-2 text-xs text-info`,children:[(0,A.jsx)(a,{className:`size-3.5 animate-spin`}),(0,A.jsx)(`span`,{className:`font-mono`,children:o.status}),o.progress&&(0,A.jsxs)(`span`,{className:`text-muted-foreground`,children:[o.progress.completed,`/`,o.progress.total]})]}),i&&(0,A.jsxs)(`div`,{role:`alert`,className:`flex items-center gap-2 text-xs text-destructive`,children:[(0,A.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:i}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>void L(),className:`underline`,children:`Retry`})]})]}),n&&!e?(0,A.jsx)(Q,{}):e?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`nav`,{className:`flex shrink-0 gap-1 border-b border-border/70 px-2`,children:ue.map(e=>(0,A.jsxs)(`button`,{type:`button`,onClick:()=>c(e.id),"aria-current":s===e.id,className:w(`border-b-2 px-3 py-2 text-xs font-medium transition-colors`,s===e.id?`border-primary text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`),children:[e.label,e.id===`findings`&&W.length>0&&(0,A.jsx)(`span`,{className:`ml-1.5 font-mono text-[10px] tabular-nums text-muted-foreground`,children:W.length})]},e.id))}),s===`dependencies`&&(0,A.jsxs)(`div`,{className:`grid min-h-0 flex-1 md:grid-cols-[minmax(340px,1fr)_minmax(0,1.15fr)]`,children:[(0,A.jsxs)(`section`,{className:w(`min-h-0 border-r border-border/70`,Z?`hidden md:flex md:flex-col`:`flex flex-col`),"aria-label":`Dependency list`,children:[(0,A.jsx)(le,{searchQuery:l,ecosystemFilter:d,statusFilter:p,directOnly:g,sort:v,hasFilters:xe,ecosystems:q,statuses:J,visibleCount:X.length,totalCount:U.length,onSearchChange:u,onEcosystemFilterChange:f,onStatusFilterChange:h,onToggleDirectOnly:()=>_(e=>!e),onSortChange:y,onClearFilters:Se}),(0,A.jsx)(se,{dependencies:X,selectedId:b,hasDependencies:U.length>0,coverageByWorkspaceId:Y,onSelect:e=>x(e.id)})]}),(0,A.jsx)(`section`,{className:w(`min-h-0`,Z?`flex flex-col`:`hidden md:flex md:flex-col`),"aria-label":`Dependency detail`,children:Z?(0,A.jsx)(oe,{dependency:Z,findings:de,deepDive:ne,onDeepDive:B,onBack:()=>x(null),coverage:Y.get(Z.workspaceId)}):(0,A.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8 text-center`,children:(0,A.jsx)(`p`,{className:`max-w-xs text-xs text-muted-foreground`,children:`Select a dependency to see its versions, evidence, and findings.`})})})]}),s===`findings`&&(0,A.jsx)(ce,{findings:W,dependenciesById:G,onSelectDependency:Ce}),s===`workspaces`&&(0,A.jsx)(me,{snapshot:e}),s===`trends`&&(0,A.jsx)(fe,{trend:O}),s===`remediation`&&(0,A.jsx)(pe,{plan:ie,approved:N,applying:F,onToggle:e=>P(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),onApply:()=>void V()})]}):(0,A.jsx)(he,{onScan:()=>void R(`inventory`),disabled:$})]})}function fe({trend:e}){return e?(0,A.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto p-3`,children:[(0,A.jsxs)(`p`,{className:`mb-3 text-xs text-muted-foreground`,children:[e.snapshots,` snapshots`,e.vulnerabilityHalfLifeMs===void 0?``:` · vulnerability half-life ${(e.vulnerabilityHalfLifeMs/864e5).toFixed(1)} days`]}),(0,A.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:e.points.map(e=>(0,A.jsxs)(`div`,{className:`grid grid-cols-4 border border-border/70 bg-card/40 p-2 text-xs`,children:[(0,A.jsx)(`span`,{children:new Date(e.createdAt).toLocaleDateString()}),(0,A.jsxs)(`span`,{children:[e.dependencies,` deps`]}),(0,A.jsxs)(`span`,{className:`text-warning`,children:[e.outdated,` outdated`]}),(0,A.jsxs)(`span`,{className:`text-destructive`,children:[e.vulnerable,` vulnerable`]})]},e.snapshotId))})]}):(0,A.jsx)(Q,{})}function pe({plan:e,approved:t,applying:n,onToggle:r,onApply:i}){return e?(0,A.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto p-3`,children:[(0,A.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.warning}),(0,A.jsxs)(E,{size:`sm`,disabled:t.size===0||n,onClick:i,children:[n&&(0,A.jsx)(a,{className:`size-3.5 animate-spin`}),`Apply `,t.size>0?t.size:``]})]}),(0,A.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e.items.map(e=>{let n=`${e.workspaceId}:${e.ecosystem}:${e.dependencyName}:${e.action}`,i=e.action===`replace`||e.action===`investigate`||!Z.has(e.ecosystem);return(0,A.jsxs)(`label`,{className:w(`flex gap-3 border border-border/70 bg-card/40 p-2.5`,i?`cursor-not-allowed opacity-65`:`cursor-pointer`),children:[(0,A.jsx)(`input`,{type:`checkbox`,disabled:i,checked:t.has(n),onChange:()=>r(n)}),(0,A.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,A.jsxs)(`span`,{className:`block font-mono text-xs`,children:[e.dependencyName,` · `,e.action]}),(0,A.jsxs)(`span`,{className:`block text-[10px] text-muted-foreground`,children:[e.currentVersion??`?`,` → `,e.targetVersion??`latest`,` · `,e.rationale]}),i&&(0,A.jsx)(`span`,{className:`block text-[10px] text-warning`,children:`Requires a manual package choice.`})]})]},n)}),e.items.length===0&&(0,A.jsx)(`p`,{className:`p-8 text-center text-xs text-muted-foreground`,children:`No remediation needed.`})]})]}):(0,A.jsx)(Q,{})}function me({snapshot:e}){let t=(0,k.useMemo)(()=>{let t=new Map;for(let n of e.dependencies)t.set(n.workspaceId,(t.get(n.workspaceId)??0)+1);return t},[e]);return e.workspaces.length===0?(0,A.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8`,children:(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No workspaces detected.`})}):(0,A.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-3`,children:(0,A.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:e.workspaces.map(e=>{let n=z[e.coverage];return(0,A.jsxs)(`div`,{className:`border border-border/70 bg-card/40 p-2.5`,children:[(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsx)(`p`,{className:`truncate font-mono text-xs text-foreground`,children:e.relativeRoot}),(0,A.jsxs)(`p`,{className:`mt-0.5 flex items-center gap-1 truncate text-[10px] text-muted-foreground`,children:[(0,A.jsx)(F,{ecosystem:e.ecosystem}),(0,A.jsx)(`span`,{children:P(e.ecosystem).label}),e.packageManager?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,A.jsx)(`span`,{children:e.packageManager})]}):null,(0,A.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,A.jsxs)(`span`,{children:[t.get(e.id)??0,` deps`]})]})]}),(0,A.jsx)(`span`,{className:w(`shrink-0 border px-1.5 py-0.5 text-[10px] font-medium`,n.badge),children:n.label})]}),e.manifests.length>0&&(0,A.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:e.manifests.map(e=>(0,A.jsx)(`span`,{className:`border border-border/70 bg-background/45 px-1.5 py-0.5 font-mono text-[9px] text-muted-foreground`,children:e.split(/[/\\]/).pop()},e))})]},e.id)})})})}function Q(){return(0,A.jsx)(`div`,{className:`flex flex-1 items-center justify-center`,children:(0,A.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,A.jsx)(a,{className:`size-5 animate-spin text-muted-foreground`}),(0,A.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Loading snapshot…`})]})})}function he({onScan:e,disabled:t}){let n=(0,k.useMemo)(()=>Object.values(M).map(e=>e.label).join(`, `),[]);return(0,A.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8`,children:(0,A.jsxs)(`div`,{className:`flex max-w-md flex-col items-center gap-3 text-center`,children:[(0,A.jsx)(`div`,{className:`flex size-14 items-center justify-center border border-info/25 bg-info/5 text-info`,children:(0,A.jsx)(i,{className:`size-6`})}),(0,A.jsx)(`h2`,{className:`text-sm font-semibold`,children:`No inventory yet`}),(0,A.jsxs)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:[`TechStack reads every manifest and lockfile in the open project — `,n,` — and compares what you have against the upstream registries.`]}),(0,A.jsxs)(E,{size:`sm`,onClick:e,disabled:t,children:[(0,A.jsx)(m,{className:w(`size-3.5`,t&&`animate-spin`)}),`Scan this project`]})]})})}function ge(e){let t=new Map;for(let n of e)t.set(n,(t.get(n)??0)+1);return[...t.entries()].sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0]))}function _e(e){let t=new Blob([JSON.stringify(e,null,2)],{type:`application/json`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`techstack.json`,r.click(),URL.revokeObjectURL(n)}export{de as TechStackView};
@@ -1,13 +0,0 @@
1
- import{ha as e,ma as t}from"./vendor-9hC4n4Me.js";import{n}from"./utils-DzRQUvln.js";function r(e,t){if(e==null){let e=Error(t?`Expected ${t} to be defined`:`Expected value to be defined`);throw e.name=`ExpectDefinedError`,e}return e}var i=/<nextsteps\b[^>]*>\s*\n+/i,a=/^(?:(\d+)[.)]\s*|[-*•]\s*)(.+?)(\s+auto="true")?$/,o=6;function s(e,t=!1,n=!0){return n?u(e,t):l(e)}function c(e,t,n,r){e.push(r?{index:t,text:n,auto:!0}:{index:t,text:n})}function l(e){let t=e.split(`
2
- `),n=[],r=new Set;for(let e of t){let t=e.trim();if(!t)continue;let i=a.exec(t);if(!i)continue;let s=i[1],l=i[2].trim(),u;if(u=s===void 0?n.length+1:Number.parseInt(s,10),r.has(u))continue;r.add(u);let d=!!i[3]&&n.length===0&&u===1;if(c(n,u,l,d),n.length>=o)break}return{steps:n,texts:n.map(e=>e.text),stripped:e,autoTexts:n.filter(e=>e.auto).map(e=>e.text)}}function u(e,t){let n=i.exec(e);if(!n)return{steps:[],texts:[],stripped:e,autoTexts:[]};let r=n.index+n[0].length,s=e.slice(r),l=s.split(`
3
- `),u=[],f=new Set;for(let e of l){let t=e.trim();if(!t)continue;let n=a.exec(t);if(!n)break;let r=n[1],i=n[2].trim(),s;if(s=r===void 0?u.length+1:Number.parseInt(r,10),f.has(s))continue;f.add(s);let l=!!n[3]&&u.length===0&&s===1;if(c(u,s,i,l),u.length>=o)break}if(u.length===0||!s.includes(`</nextsteps>`))return{steps:[],texts:[],stripped:e,autoTexts:[]};let p=u.map(e=>e.text),m=u.filter(e=>e.auto).map(e=>e.text),h=n.index,g=n[0].length+d(s,u.length);return{steps:u,texts:p,stripped:(e.slice(0,h)+e.slice(h+g)).replace(/\n{3,}/g,`
4
-
5
- `).trim(),autoTexts:m}}function d(e,t){let n=e.indexOf(`</nextsteps>`);if(n!==-1){let t=n+12;return e[t]===`
6
- `&&(t+=1),t}let r=e.split(`
7
- `),i=0,o=0;for(let e of r){let n=e.trim();if(!n||!a.exec(n))break;if(i+=e.length+1,o++,o>=t){--i;break}}return i}function f(e){return e.replace(/<next_?steps\b[^>]*>[\s\S]*?<\/next_?steps>/gi,``).replace(/<next_?steps\b[^>]*\/?>/gi,``).replace(/\n{3,}/g,`
8
-
9
- `).trim()}function p(e){if(!e)return e;let t=e.split(/\n{2,}/),n=[];for(let e of t)n.length>0&&n[n.length-1]?.trim()===e.trim()||n.push(e);return n.map(e=>{let t=e.split(`
10
- `),n=[];for(let e of t)n.length>0&&e.trim().length>0&&n[n.length-1]?.trim()===e.trim()||n.push(e);return n.join(`
11
- `)}).join(`
12
-
13
- `)}var m=1e3;function h(e){let t=new Map;for(let n of e)n.role===`tool`&&n.toolUseId&&t.set(n.toolUseId,n.id);return t}var g=e()(t((e,t)=>({messages:[],currentAssistantMessageId:null,currentToolId:null,isLoading:!1,abortController:null,executions:new Map,toolMessageIdsByUseId:new Map,queue:[],runStart:null,refining:!1,pendingRefinement:null,thinkingBuffer:``,thinkingStartedAt:null,thinkingLogBuffer:``,thinkingLogStartedAt:null,boundSessionId:null,addMessage:t=>{let r=`msg_${Date.now()}_${n().slice(0,8)}`,i={...t,id:r,timestamp:t.timestamp??Date.now()};return e(e=>{let n;n=e.messages.length>=m?[...e.messages.slice(e.messages.length-m+1),i]:[...e.messages,i];let a=h(n),o=e.executions;if(o.size>0){let e=new Map,t=!1;for(let[n,r]of o)a.has(n)?e.set(n,r):t=!0;t&&(o=e)}let s={messages:n,currentAssistantMessageId:t.role===`assistant`?r:e.currentAssistantMessageId,toolMessageIdsByUseId:a};if(i.role===`tool`&&i.toolUseId){let e=new Map(a);e.set(i.toolUseId,r),s.toolMessageIdsByUseId=e}return o!==e.executions&&(s.executions=o),s}),r},setMessages:t=>{e({messages:t,currentAssistantMessageId:null,currentToolId:null,executions:new Map,toolMessageIdsByUseId:h(t),thinkingBuffer:``,thinkingStartedAt:null,thinkingLogBuffer:``,thinkingLogStartedAt:null})},updateMessage:(t,n)=>{e(e=>({messages:e.messages.map(e=>e.id===t?{...e,...n}:e)}))},appendToMessage:(t,n)=>{e(e=>({messages:e.messages.map(e=>e.id===t?{...e,content:e.content+n}:e)}))},finalizeMessage:t=>{e(e=>({messages:e.messages.map(e=>{if(e.id!==t)return e;if(e.role!==`assistant`)return{...e,content:p(e.content),streaming:!1};let n=s(e.content),r=n.steps.length>0?{steps:n.steps}:void 0;return{...e,content:p(n.stripped),streaming:!1,...r?{nextSteps:r}:{}}})}))},setToolResult:(t,n,r)=>{e(e=>({messages:e.messages.map(e=>e.id===t?{...e,toolResult:n,isError:!r,progressLines:void 0}:e)}))},appendToolProgress:(e,n)=>{t().appendToolProgressLines(e,[n])},appendToolProgressLines:(t,n)=>{n.length!==0&&e(e=>({messages:e.messages.map(e=>{if(e.id!==t)return e;let r=e.progressLines??[];return r.push(...n),r.length>30&&r.splice(0,r.length-30),{...e,progressLines:r}})}))},getToolMessageId:e=>t().toolMessageIdsByUseId.get(e),setToolResultByUseId:(e,n,r)=>{let i=t().toolMessageIdsByUseId.get(e);i&&t().setToolResult(i,n,r)},appendToolProgressLinesByUseId:(e,n)=>{let r=t().toolMessageIdsByUseId.get(e);r&&t().appendToolProgressLines(r,n)},setLoading:t=>e({isLoading:t}),setAbortController:t=>e({abortController:t}),clearMessages:()=>e({messages:[],currentAssistantMessageId:null,currentToolId:null,executions:new Map,toolMessageIdsByUseId:new Map,thinkingBuffer:``,thinkingStartedAt:null,thinkingLogBuffer:``,thinkingLogStartedAt:null,boundSessionId:null}),setBoundSessionId:t=>e({boundSessionId:t}),setCurrentAssistantMessage:t=>e({currentAssistantMessageId:t}),setCurrentToolId:t=>e({currentToolId:t}),truncateAfter:t=>e(e=>{let n=e.messages.findIndex(e=>e.id===t);if(n===-1)return e;let r=e.messages.slice(0,n+1);return{messages:r,currentAssistantMessageId:null,currentToolId:null,toolMessageIdsByUseId:h(r)}}),addExecution:t=>{e(e=>{let n=new Map(e.executions);return n.set(t.id,t),{executions:n}})},updateExecution:(t,n)=>{e(e=>{let r=new Map(e.executions),i=r.get(t);return i&&r.set(t,{...i,...n}),{executions:r}})},setRefining:t=>e({refining:t}),setPendingRefinement:(t,n)=>e({pendingRefinement:t===null?null:{text:t,images:n??[]}}),enqueue:(t,n=`queue`,r)=>e(e=>({queue:[...e.queue,{text:t,mode:n,addedAt:Date.now(),...r?.length?{images:r}:{}}]})),dequeue:()=>{let{queue:n}=t();if(n.length===0)return null;let[i,...a]=n;return e({queue:a}),r(i)},removeQueued:t=>e(e=>({queue:e.queue.filter((e,n)=>n!==t)})),clearQueue:()=>e({queue:[]}),removeMessage:t=>e(e=>{let n=e.messages.filter(e=>e.id!==t);return{messages:n,toolMessageIdsByUseId:h(n)}}),updateLastUserMessage:t=>e(e=>{let n=e.messages;for(let e=n.length-1;e>=0;e--)if(n[e].role===`user`){let r={...n[e],content:t},i=[...n];return i[e]=r,{messages:i}}return e}),setRunStart:t=>e({runStart:t}),appendThinking:t=>e(e=>({thinkingBuffer:e.thinkingBuffer+t,thinkingStartedAt:e.thinkingStartedAt??Date.now(),thinkingLogBuffer:e.thinkingLogBuffer+t,thinkingLogStartedAt:e.thinkingLogStartedAt??Date.now()})),clearThinking:()=>e({thinkingBuffer:``,thinkingStartedAt:null}),flushThinkingLog:e=>{let{thinkingLogBuffer:n,thinkingLogStartedAt:r}=t(),i=n.trim();if(!i)return;let a=r??Date.now();t().addMessage({role:`system`,content:``,thinkingLog:{iteration:e,text:i,startedAt:a,durationMs:Math.max(0,Date.now()-a)}}),t().clearThinkingLog()},clearThinkingLog:()=>e({thinkingLogBuffer:``,thinkingLogStartedAt:null})}),{name:`wrongstack-chat`,version:1,partialize:e=>({messages:e.messages.map(e=>e.attachments?.some(e=>e.dataUrl)?{...e,attachments:e.attachments.map(e=>({...e,dataUrl:void 0}))}:e),queue:e.queue.map(e=>e.images?{...e,images:void 0}:e),boundSessionId:e.boundSessionId,thinkingLogBuffer:e.thinkingLogBuffer}),migrate:(e,t)=>{if(t>1)return null;let n=e??{};return{messages:Array.isArray(n.messages)?n.messages:[],queue:Array.isArray(n.queue)?n.queue:[],boundSessionId:typeof n.boundSessionId==`string`?n.boundSessionId:null,thinkingLogBuffer:typeof n.thinkingLogBuffer==`string`?n.thinkingLogBuffer:``}},onRehydrateStorage:()=>(e,t)=>{t||typeof window<`u`&&(window.__wrongstackChatRehydrated=!0)}}));export{r as i,s as n,f as r,g as t};
@@ -1 +0,0 @@
1
- import{ha as e}from"./vendor-9hC4n4Me.js";var t=e(e=>({generation:0,lastUpdatedAt:null,notifyIndexUpdated(t=Date.now()){e(e=>({generation:e.generation+1,lastUpdatedAt:t}))}}));export{t};