@kaitranntt/ccs 7.19.2-dev.1 → 7.19.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/config-command.d.ts.map +1 -1
- package/dist/commands/config-command.js +1 -37
- package/dist/commands/config-command.js.map +1 -1
- package/dist/commands/help-command.d.ts.map +1 -1
- package/dist/commands/help-command.js +0 -2
- package/dist/commands/help-command.js.map +1 -1
- package/dist/config/unified-config-loader.d.ts +1 -6
- package/dist/config/unified-config-loader.d.ts.map +1 -1
- package/dist/config/unified-config-loader.js +1 -41
- package/dist/config/unified-config-loader.js.map +1 -1
- package/dist/config/unified-config-types.d.ts +0 -22
- package/dist/config/unified-config-types.d.ts.map +1 -1
- package/dist/config/unified-config-types.js +1 -12
- package/dist/config/unified-config-types.js.map +1 -1
- package/dist/ui/assets/accounts-CJISzCiC.js +1 -0
- package/dist/ui/assets/{alert-dialog-BihHyQWt.js → alert-dialog-CnDvl5IB.js} +1 -1
- package/dist/ui/assets/api-DP559Tqr.js +1 -0
- package/dist/ui/assets/{auth-section-2VOlqT5f.js → auth-section-DbZac9VD.js} +1 -1
- package/dist/ui/assets/card-nbrHgs37.js +1 -0
- package/dist/ui/assets/{charts-BBPXh0Ar.js → charts-CJC4bH8P.js} +1 -1
- package/dist/ui/assets/{cliproxy-control-panel-BmdGbwrb.js → cliproxy-control-panel-CP-dhv4O.js} +1 -1
- package/dist/ui/assets/cliproxy-ssaB44zs.js +3 -0
- package/dist/ui/assets/{code-highlight-BRUf_pqB.js → code-highlight-DKN39ySy.js} +1 -1
- package/dist/ui/assets/{confirm-dialog-mqF6YOLY.js → confirm-dialog-w5D52_lL.js} +1 -1
- package/dist/ui/assets/copilot-DsYQqfFs.js +4 -0
- package/dist/ui/assets/{form-utils-C-pVd1--.js → form-utils-kUVlZZAO.js} +1 -1
- package/dist/ui/assets/globalenv-section-Bli3PW-y.js +1 -0
- package/dist/ui/assets/{health-BNmfbrDj.js → health-BaRdlHhs.js} +1 -1
- package/dist/ui/assets/icons-CZDQWWm2.js +1 -0
- package/dist/ui/assets/index-B7MyxZLG.js +47 -0
- package/dist/ui/assets/index-BX0IVNt5.css +1 -0
- package/dist/ui/assets/{index-NRrX9V9T.js → index-BuLI32Lk.js} +1 -1
- package/dist/ui/assets/{index-Ukp0OKvb.js → index-CAdQ23xy.js} +1 -1
- package/dist/ui/assets/index-DIrZx85u.js +1 -0
- package/dist/ui/assets/{notifications-B2HqRBj7.js → notifications-dJQY2-U6.js} +1 -1
- package/dist/ui/assets/{radix-ui-CFOhsBGh.js → radix-ui-CBgg0XeO.js} +4 -4
- package/dist/ui/assets/{react-vendor-CNOkPC89.js → react-vendor-B_CU-WTZ.js} +2 -2
- package/dist/ui/assets/shared-CNbeCoBd.js +1 -0
- package/dist/ui/assets/{switch-Cyuniy_w.js → switch-Kx7oj3ow.js} +1 -1
- package/dist/ui/assets/{tanstack-U3Rle5gh.js → tanstack-CxYN0q6L.js} +1 -1
- package/dist/ui/index.html +9 -9
- package/dist/web-server/index.d.ts.map +1 -1
- package/dist/web-server/index.js +0 -5
- package/dist/web-server/index.js.map +1 -1
- package/dist/web-server/routes/index.d.ts.map +1 -1
- package/dist/web-server/routes/index.js +0 -3
- package/dist/web-server/routes/index.js.map +1 -1
- package/package.json +1 -6
- package/dist/commands/config-auth/disable-command.d.ts +0 -10
- package/dist/commands/config-auth/disable-command.d.ts.map +0 -1
- package/dist/commands/config-auth/disable-command.js +0 -64
- package/dist/commands/config-auth/disable-command.js.map +0 -1
- package/dist/commands/config-auth/index.d.ts +0 -14
- package/dist/commands/config-auth/index.d.ts.map +0 -1
- package/dist/commands/config-auth/index.js +0 -84
- package/dist/commands/config-auth/index.js.map +0 -1
- package/dist/commands/config-auth/setup-command.d.ts +0 -13
- package/dist/commands/config-auth/setup-command.d.ts.map +0 -1
- package/dist/commands/config-auth/setup-command.js +0 -121
- package/dist/commands/config-auth/setup-command.js.map +0 -1
- package/dist/commands/config-auth/show-command.d.ts +0 -10
- package/dist/commands/config-auth/show-command.d.ts.map +0 -1
- package/dist/commands/config-auth/show-command.js +0 -79
- package/dist/commands/config-auth/show-command.js.map +0 -1
- package/dist/commands/config-auth/types.d.ts +0 -25
- package/dist/commands/config-auth/types.d.ts.map +0 -1
- package/dist/commands/config-auth/types.js +0 -8
- package/dist/commands/config-auth/types.js.map +0 -1
- package/dist/ui/assets/accounts-BalhEi_Q.js +0 -1
- package/dist/ui/assets/api-DfXVyQ9q.js +0 -1
- package/dist/ui/assets/cliproxy-D7dRdfxQ.js +0 -3
- package/dist/ui/assets/copilot-2sX-I5wM.js +0 -4
- package/dist/ui/assets/globalenv-section-BxLXeomI.js +0 -1
- package/dist/ui/assets/icons-WqZToXEO.js +0 -1
- package/dist/ui/assets/index-CNsISHN_.css +0 -1
- package/dist/ui/assets/index-Dn2mUxH5.js +0 -47
- package/dist/ui/assets/index-rYsMzAsc.js +0 -1
- package/dist/ui/assets/shared-CT1Buk-w.js +0 -1
- package/dist/web-server/middleware/auth-middleware.d.ts +0 -27
- package/dist/web-server/middleware/auth-middleware.d.ts.map +0 -1
- package/dist/web-server/middleware/auth-middleware.js +0 -116
- package/dist/web-server/middleware/auth-middleware.js.map +0 -1
- package/dist/web-server/routes/auth-routes.d.ts +0 -7
- package/dist/web-server/routes/auth-routes.d.ts.map +0 -1
- package/dist/web-server/routes/auth-routes.js +0 -108
- package/dist/web-server/routes/auth-routes.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-CFOhsBGh.js";import{r as f,c as fe}from"./react-vendor-CNOkPC89.js";import{u as M,C as p,a as g,S as h,c as d,P as y,B as I,b as H,d as ee,e as pe,f as se,g as ge,h as te,i as N,j as S,k as je,l as Ne,m as ye,n as be}from"./index-Dn2mUxH5.js";import{z as we,a5 as ae,a6 as _,a7 as re,x as ne,Y as ve,G as ke,a8 as Ce,a2 as $e,v as Q,U as Se,Z as le,s as Le,a0 as G,a9 as De,u as Te,b as Fe,aa as Re,ab as Me}from"./icons-WqZToXEO.js";import{u as Pe,a as P}from"./tanstack-U3Rle5gh.js";import{K as D,L as Y,f as k,H as Ae}from"./utils-CzKF5WmX.js";import{R as ie,A as Be,C as Ue,X as qe,Y as V,T as oe,a as Z,P as Ie,b as Oe,c as Ke}from"./charts-BBPXh0Ar.js";import"./notifications-B2HqRBj7.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";function Ee({data:s,isLoading:t}){const{privacyMode:a}=M();if(t)return e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 xl:grid-cols-5 gap-4",children:[1,2,3,4,5].map(o=>e.jsx(p,{children:e.jsx(g,{className:"p-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{className:"h-4 w-[100px]"}),e.jsx(h,{className:"h-8 w-[80px]"})]}),e.jsx(h,{className:"h-8 w-8 rounded-lg"})]})})},o))});const l=(s?.tokenBreakdown?.cacheCreation?.cost??0)+(s?.tokenBreakdown?.cacheRead?.cost??0),r=s?.totalCost?Math.round(l/s.totalCost*100):0,i=[{title:"Total Tokens",value:s?.totalTokens??0,icon:we,format:o=>R(o),color:"text-blue-600",bgColor:"bg-blue-100 dark:bg-blue-900/20",subtitle:`${R(s?.totalInputTokens??0)} in / ${R(s?.totalOutputTokens??0)} out`},{title:"Total Cost",value:s?.totalCost??0,icon:ae,format:o=>`$${o.toFixed(2)}`,color:"text-green-600",bgColor:"bg-green-100 dark:bg-green-900/20",subtitle:`$${s?.averageCostPerDay?.toFixed(2)??"0.00"}/day avg`},{title:"Cache Tokens",value:s?.totalCacheTokens??0,icon:_,format:o=>R(o),color:"text-cyan-600",bgColor:"bg-cyan-100 dark:bg-cyan-900/20",subtitle:`$${l.toFixed(2)} (${r}% of cost)`},{title:"Input Cost",value:s?.tokenBreakdown?.input?.cost??0,icon:re,format:o=>`$${o.toFixed(2)}`,color:"text-purple-600",bgColor:"bg-purple-100 dark:bg-purple-900/20",subtitle:`${R(s?.tokenBreakdown?.input?.tokens??0)} tokens`},{title:"Output Cost",value:s?.tokenBreakdown?.output?.cost??0,icon:ne,format:o=>`$${o.toFixed(2)}`,color:"text-orange-600",bgColor:"bg-orange-100 dark:bg-orange-900/20",subtitle:`${R(s?.tokenBreakdown?.output?.tokens??0)} tokens`}];return e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 xl:grid-cols-5 gap-4",children:i.map((o,n)=>{const c=o.icon;return e.jsx(p,{className:"hover:shadow-md transition-shadow",children:e.jsx(g,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between space-x-2",children:[e.jsxs("div",{className:"space-y-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground truncate",children:o.title}),e.jsx("p",{className:d("text-xl font-bold truncate",a&&y),children:o.format(o.value)}),o.subtitle&&e.jsx("p",{className:d("text-[10px] text-muted-foreground truncate",a&&y),children:o.subtitle})]}),e.jsx("div",{className:d("p-2 rounded-lg shrink-0",o.bgColor),children:e.jsx(c,{className:d("h-4 w-4",o.color)})})]})})},n)})})}function R(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function Ge({model:s}){const{privacyMode:t}=M(),a=We(s.ioRatio);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{className:"h-4 w-4 text-primary shrink-0"}),e.jsx("h4",{className:"font-semibold leading-none truncate",title:s.model,children:s.model})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(I,{variant:"secondary",className:"text-[10px] h-5 px-1.5",children:[s.percentage.toFixed(1),"% usage"]}),e.jsxs(I,{variant:a.variant,className:"text-[10px] h-5 px-1.5",children:[s.ioRatio.toFixed(0),":1 I/O"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("p",{className:d("text-lg font-bold",t&&y),children:["$",s.cost.toFixed(2)]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Total Cost"})]}),e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsx("p",{className:d("text-lg font-bold",t&&y),children:ze(s.tokens)}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Total Tokens"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h5",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wider",children:"Token Breakdown"}),e.jsxs("div",{className:d("space-y-1",t&&y),children:[e.jsx(W,{label:"Input",tokens:s.inputTokens,cost:s.costBreakdown.input.cost,color:"#335c67",icon:re}),e.jsx(W,{label:"Output",tokens:s.outputTokens,cost:s.costBreakdown.output.cost,color:"#fff3b0",icon:ne}),e.jsx(W,{label:"Cache Write",tokens:s.cacheCreationTokens,cost:s.costBreakdown.cacheCreation.cost,color:"#e09f3e",icon:_}),e.jsx(W,{label:"Cache Read",tokens:s.cacheReadTokens,cost:s.costBreakdown.cacheRead.cost,color:"#9e2a2b",icon:_})]})]}),e.jsxs("div",{className:"p-2.5 rounded-md border bg-muted/20 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ke,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs font-medium",children:"Input/Output Ratio"})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground leading-snug",children:a.description})]})]})}function W({label:s,tokens:t,cost:a,color:l,icon:r}){return t===0?null:e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("div",{className:"w-1 h-6 rounded-full shrink-0",style:{backgroundColor:l}}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium truncate",children:s}),e.jsxs("span",{className:"font-mono text-muted-foreground",children:["$",a.toFixed(3)]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[e.jsx(r,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:He(t)})]})]})]})}function We(s){return s>=200?{variant:"destructive",description:"Extended thinking or large context loading. Expected for reasoning models."}:s>=50?{variant:"secondary",description:"More input than output. Typical for analysis tasks."}:s>=5?{variant:"outline",description:"Balanced input/output ratio for typical coding tasks."}:{variant:"default",description:"More output than input. Generation-heavy workload."}}function He(s){return s.toLocaleString()}function ze(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toString()}const _e="/api";function w(s){const t=s.getFullYear(),a=String(s.getMonth()+1).padStart(2,"0"),l=String(s.getDate()).padStart(2,"0");return`${t}${a}${l}`}const T={summary:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),s?.profile&&t.append("profile",s.profile),L(`/usage/summary?${t}`)},trends:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),s?.profile&&t.append("profile",s.profile),L(`/usage/daily?${t}`)},hourly:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),L(`/usage/hourly?${t}`)},models:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),s?.profile&&t.append("profile",s.profile),L(`/usage/models?${t}`)},sessions:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),s?.profile&&t.append("profile",s.profile),s?.limit&&t.append("limit",s.limit.toString()),s?.offset&&t.append("offset",s.offset.toString()),L(`/usage/sessions?${t}`)},monthly:(s,t)=>{const a=new URLSearchParams;return s&&a.append("months",s.toString()),t&&a.append("profile",t),L(`/usage/monthly?${a}`)},refresh:async()=>{if(!(await fetch(`${_e}/usage/refresh`,{method:"POST",headers:{"Content-Type":"application/json"}})).ok)throw new Error("Failed to refresh usage cache")},status:()=>L("/usage/status"),insights:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),s?.profile&&t.append("profile",s.profile),L(`/usage/insights?${t}`)}};async function L(s){const a=await fetch(`/api${s}`,{headers:{"Content-Type":"application/json"}});if(!a.ok){const r=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(r.error||a.statusText)}const l=await a.json();return l.data||l}function Ye(s){return P({queryKey:["usage","summary",s],queryFn:()=>T.summary(s),staleTime:60*1e3})}function Qe(s){return P({queryKey:["usage","trends",s],queryFn:()=>T.trends(s),staleTime:60*1e3})}function Ve(s){return P({queryKey:["usage","hourly",s],queryFn:()=>T.hourly(s),staleTime:60*1e3})}function Ze(s){return P({queryKey:["usage","models",s],queryFn:()=>T.models(s),staleTime:60*1e3})}function Xe(){const s=Pe();return f.useCallback(async()=>{await T.refresh(),await s.invalidateQueries({queryKey:["usage"]})},[s])}function Je(){return P({queryKey:["usage","status"],queryFn:()=>T.status(),staleTime:10*1e3,refetchInterval:30*1e3})}function es(s){return P({queryKey:["usage","sessions",s],queryFn:()=>T.sessions(s),staleTime:60*1e3})}function ss(){const[s,t]=f.useState({from:D(new Date,30),to:new Date}),[a,l]=f.useState(!1),[r,i]=f.useState(null),[o,n]=f.useState(null),[c,x]=f.useState("daily"),u=Xe(),m=f.useCallback(async()=>{l(!0);try{await u()}finally{l(!1)}},[u]),j=f.useMemo(()=>({startDate:s?.from,endDate:s?.to}),[s?.from,s?.to]),{data:b,isLoading:v}=Ye(j),{data:C,isLoading:$}=Qe(j),{data:A,isLoading:B}=Ve(j),{data:U,isLoading:q}=Ze(j),{data:z,isLoading:O}=es({...j,limit:3}),{data:K}=Je(),ce=f.useCallback(()=>{const F=new Date;t({from:D(F,1),to:F}),x("hourly")},[]),de=f.useCallback(F=>{t(F),x("daily")},[]),xe=f.useMemo(()=>K?.lastFetch?Y(new Date(K.lastFetch),{addSuffix:!0}):null,[K?.lastFetch]),ue=f.useCallback((F,he)=>{const E=he.currentTarget.getBoundingClientRect();n({x:E.left+E.width/2,y:E.top+E.height/2}),i(F)},[]),me=f.useCallback(()=>{i(null),n(null)},[]);return{dateRange:s,isRefreshing:a,viewMode:c,selectedModel:r,popoverPosition:o,summary:b,trends:C,hourlyData:A,models:U,sessions:z,status:K,isSummaryLoading:v,isTrendsLoading:$,isHourlyLoading:B,isModelsLoading:q,isSessionsLoading:O,isLoading:v||$||q||O,handleRefresh:m,handleTodayClick:ce,handleDateRangeChange:de,handleModelClick:ue,handlePopoverClose:me,lastUpdatedText:xe}}function ts({value:s,onChange:t,presets:a=[{label:"Last 7 days",range:{from:D(new Date,7),to:new Date}},{label:"Last 30 days",range:{from:D(new Date,30),to:new Date}},{label:"Last 90 days",range:{from:D(new Date,90),to:new Date}}],className:l}){const[r,i]=fe.useState(!1),o=n=>!s||!s.from||!s.to||!n.from||!n.to?!1:k(s.from,"yyyy-MM-dd")===k(n.from,"yyyy-MM-dd")&&k(s.to,"yyyy-MM-dd")===k(n.to,"yyyy-MM-dd");return e.jsxs("div",{className:d("flex items-center gap-2",l),children:[a.map(n=>e.jsx(H,{variant:o(n.range)?"default":"outline",size:"sm",onClick:()=>t(n.range),children:n.label},n.label)),e.jsxs(ee,{open:r,onOpenChange:i,children:[e.jsx(pe,{asChild:!0,children:e.jsxs(H,{id:"date",variant:"outline",className:d("w-auto min-w-[240px] justify-start text-left font-normal",!s&&"text-muted-foreground"),children:[e.jsx(Ce,{className:"mr-2 h-4 w-4"}),s?.from?s.to?e.jsxs(e.Fragment,{children:[k(s.from,"LLL dd, y")," - ",k(s.to,"LLL dd, y")]}):k(s.from,"LLL dd, y"):e.jsx("span",{children:"Pick a date"})]})}),e.jsx(se,{className:"w-auto p-0",align:"end",children:e.jsx(ge,{initialFocus:!0,mode:"range",defaultMonth:s?.from,selected:s,onSelect:t,numberOfMonths:2})})]})]})}function as({dateRange:s,onDateRangeChange:t,onTodayClick:a,onRefresh:l,isRefreshing:r,lastUpdatedText:i,viewMode:o}){return e.jsxs("div",{className:"flex items-center justify-between shrink-0",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold",children:"Analytics"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Track usage & insights"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(H,{variant:o==="hourly"?"default":"outline",size:"sm",className:"h-8",onClick:a,children:"24H"}),e.jsx(ts,{value:s,onChange:t,presets:[{label:"7D",range:{from:D(new Date,7),to:new Date}},{label:"30D",range:{from:D(new Date,30),to:new Date}},{label:"Month",range:{from:Ae(new Date),to:new Date}},{label:"All Time",range:{from:void 0,to:new Date}}]}),i&&e.jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:["Updated ",i]}),e.jsx(H,{variant:"outline",size:"sm",className:"gap-2 h-8",onClick:l,disabled:r,children:e.jsx($e,{className:`w-3.5 h-3.5 ${r?"animate-spin":""}`})})]})]})}function rs({data:s,isLoading:t,granularity:a="daily",className:l}){const{privacyMode:r}=M(),i=f.useMemo(()=>!s||s.length===0?[]:(a==="hourly"?s:[...s].reverse()).map(c=>{const x="hour"in c?c.hour:c.date;return{...c,dateFormatted:ns(x,a),costRounded:Number(c.cost.toFixed(4))}}),[s,a]);if(t)return e.jsx(h,{className:d("h-full w-full",l)});if(!s||s.length===0)return e.jsx("div",{className:d("h-full flex items-center justify-center",l),children:e.jsx("p",{className:"text-muted-foreground",children:a==="hourly"?"No usage data for today":"No usage data available"})});const o=({x:n,y:c,payload:x,isRight:u})=>{const m=u?`$${x.value}`:X(Number(x.value));return e.jsx("text",{x:n,y:c,dy:4,textAnchor:u?"start":"end",fontSize:12,fill:"currentColor",className:d("fill-muted-foreground",r&&"blur-[4px]"),children:m})};return e.jsx("div",{className:d("w-full h-full",l),children:e.jsx(ie,{width:"100%",height:"100%",children:e.jsxs(Be,{data:i,margin:{top:5,right:30,left:20,bottom:5},children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"tokenGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#0080FF",stopOpacity:.8}),e.jsx("stop",{offset:"95%",stopColor:"#0080FF",stopOpacity:.1})]}),e.jsxs("linearGradient",{id:"costGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#00C49F",stopOpacity:.8}),e.jsx("stop",{offset:"95%",stopColor:"#00C49F",stopOpacity:.1})]})]}),e.jsx(Ue,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(qe,{dataKey:"dateFormatted",tick:{fontSize:12},tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(V,{yAxisId:"left",orientation:"left",tick:n=>e.jsx(o,{...n,isRight:!1}),tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(V,{yAxisId:"right",orientation:"right",tick:n=>e.jsx(o,{...n,isRight:!0}),tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(oe,{content:({active:n,payload:c,label:x})=>{if(!n||!c||!c.length)return null;const u=c[0].payload;return e.jsxs("div",{className:"rounded-lg border bg-background p-3 shadow-lg",children:[e.jsx("p",{className:"font-medium mb-2",children:x}),c.map((m,j)=>e.jsxs("p",{className:d("text-sm",r&&y),style:{color:m.color},children:[m.name,":"," ",m.name==="Tokens"?X(Number(m.value)||0):`$${m.value}`]},j)),"requests"in u&&e.jsxs("p",{className:d("text-sm text-muted-foreground mt-1",r&&y),children:["Requests: ",u.requests]})]})}}),e.jsx(Z,{yAxisId:"left",type:"monotone",dataKey:"tokens",stroke:"#0080FF",strokeWidth:2,fillOpacity:1,fill:"url(#tokenGradient)",name:"Tokens"}),e.jsx(Z,{yAxisId:"right",type:"monotone",dataKey:"costRounded",stroke:"#00C49F",strokeWidth:2,fillOpacity:1,fill:"url(#costGradient)",name:"Cost"})]})})})}function ns(s,t){if(t==="hourly"){const[l,r]=s.split(" ");if(l&&r){const i=new Date(`${l}T${r}:00Z`);return k(i,"HH:mm")}return s}const a=new Date(s);return t==="monthly"?k(a,"MMM yyyy"):k(a,"MMM dd")}function X(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function ls({data:s,isLoading:t,className:a}){const{privacyMode:l}=M(),r=f.useMemo(()=>!s||s.length===0?[]:s.map(n=>({name:n.model,value:n.tokens,cost:n.cost,percentage:n.percentage,fill:te(n.model)})),[s]);if(t)return e.jsx(h,{className:d("h-[300px] w-full",a)});if(!s||s.length===0)return e.jsx("div",{className:d("h-[300px] flex items-center justify-center",a),children:e.jsx("p",{className:"text-muted-foreground",children:"No model data available"})});const i=({active:n,payload:c})=>{if(!n||!c)return null;const x=c;if(!x.length)return null;const u=x[0].payload;return e.jsxs("div",{className:"rounded-lg border bg-background p-2 shadow-lg text-xs",children:[e.jsx("p",{className:"font-medium mb-1",children:u.name}),e.jsxs("p",{className:d("text-muted-foreground",l&&y),children:[is(u.value)," (",u.percentage.toFixed(1),"%)"]}),e.jsxs("p",{className:d("text-muted-foreground",l&&y),children:["$",u.cost.toFixed(4)]})]})},o=n=>n.percentage>5?`${n.percentage.toFixed(1)}%`:"";return e.jsx("div",{className:d("w-full",a),children:e.jsx(ie,{width:"100%",height:250,children:e.jsxs(Ie,{children:[e.jsx(Oe,{data:r,cx:"50%",cy:"50%",labelLine:!1,label:o,innerRadius:50,outerRadius:70,paddingAngle:2,dataKey:"value",children:r.map((n,c)=>e.jsx(Ke,{fill:n.fill,strokeWidth:1},`cell-${c}`))}),e.jsx(oe,{content:i})]})})})}function is(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function os({data:s,isLoading:t,className:a}){const{privacyMode:l}=M(),r=f.useMemo(()=>{if(!s?.sessions||s.sessions.length===0)return null;const i=s.sessions,o=s.total,n=i.reduce((b,v)=>b+(v.inputTokens+v.outputTokens),0),c=Math.round(n/i.length),u=i.reduce((b,v)=>b+v.cost,0)/i.length,m=i[0],j=m?Y(new Date(m.lastActivity),{addSuffix:!0}):"N/A";return{totalSessions:o,avgTokens:c,avgCost:u,lastActive:j,recentSessions:i.slice(0,3)}},[s]);return t?e.jsxs(p,{className:d("flex flex-col h-full",a),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsx(h,{className:"h-5 w-32"})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsx(h,{className:"h-full w-full"})})]}):r?e.jsxs(p,{className:d("flex flex-col h-full shadow-sm",a),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Q,{className:"w-4 h-4"}),"Session Stats"]})}),e.jsxs(g,{className:"px-3 pb-3 pt-0 flex-1 flex flex-col gap-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-blue-600 dark:text-blue-400",children:[e.jsx(Se,{className:"w-4 h-4"}),e.jsx("span",{className:"text-xl font-bold",children:r.totalSessions})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mt-0.5",children:"Total Sessions"})]}),e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-green-600 dark:text-green-400",children:[e.jsx(le,{className:"w-4 h-4"}),e.jsxs("span",{className:d("text-xl font-bold",l&&y),children:["$",r.avgCost.toFixed(2)]})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mt-0.5",children:"Avg Cost/Session"})]})]}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground font-medium mb-1",children:[e.jsx(Le,{className:"w-3 h-3"}),"Recent Activity"]}),e.jsx("div",{className:"space-y-1.5",children:r.recentSessions.map(i=>e.jsxs("div",{className:"flex items-center justify-between text-xs p-1.5 rounded bg-muted/30 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[e.jsx("span",{className:"font-medium truncate",title:i.projectPath,children:i.projectPath.split("/").pop()}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:Y(new Date(i.lastActivity),{addSuffix:!0})})]}),e.jsxs("div",{className:d("text-right shrink-0 ml-2",l&&y),children:[e.jsxs("div",{className:"font-mono",children:["$",i.cost.toFixed(2)]}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[cs(i.inputTokens+i.outputTokens)," toks"]})]})]},i.sessionId))})]})]})]}):e.jsxs(p,{className:d("flex flex-col h-full",a),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Q,{className:"w-4 h-4"}),"Session Stats"]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1 flex items-center justify-center",children:e.jsx("p",{className:"text-sm text-muted-foreground text-center",children:"No session data available"})})]})}function cs(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toString()}function ds({className:s,isLoading:t}){const{data:a,isLoading:l}=je(),{data:r,isLoading:i,error:o}=Ne(a?.running);if(t||l||a?.running&&i)return e.jsxs(p,{className:d("flex flex-col h-full",s),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4"}),"CLIProxy Stats"]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx(h,{className:"h-4 w-[100px]"}),e.jsx(h,{className:"h-16 w-full"})]})})]});if(!a?.running)return e.jsxs(p,{className:d("flex flex-col h-full border-dashed",s),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4 text-muted-foreground"}),"CLIProxy Stats"]}),e.jsx(I,{variant:"secondary",className:"text-[10px] h-5",children:"Offline"})]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1 flex items-center justify-center",children:e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Start a CLIProxy session (gemini, codex, agy) to collect stats."})})]});if(o)return e.jsxs(p,{className:d("flex flex-col h-full border-destructive/50",s),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4"}),"CLIProxy Stats"]}),e.jsx(I,{variant:"destructive",className:"text-[10px] h-5",children:"Error"})]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsx("p",{className:"text-xs text-destructive",children:o.message})})]});const c=r?.totalRequests??0,x=r?.quotaExceededCount??0,u=c-x,m=c>0?Math.round(u/c*100):100,j=r?.tokens?.total??0,b=Object.entries(r?.requestsByModel??{}).sort((C,$)=>$[1]-C[1]).slice(0,4),v=b.length>0?b[0][1]:1;return e.jsxs(p,{className:d("flex flex-col h-full overflow-hidden",s),children:[e.jsx(N,{className:"px-3 py-2 border-b bg-muted/5",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4"}),"CLIProxy Stats"]}),e.jsxs(I,{variant:"outline",className:"text-[10px] h-5 text-green-600 border-green-200 bg-green-50 dark:bg-green-900/10 dark:border-green-800",children:[e.jsx(le,{className:"h-3 w-3 mr-0.5"}),"Running"]})]})}),e.jsx(g,{className:"p-0 flex-1 min-h-0",children:e.jsx(ye,{className:"h-full",children:e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"relative",children:[e.jsxs("svg",{className:"w-10 h-10 -rotate-90",viewBox:"0 0 36 36",children:[e.jsx("circle",{cx:"18",cy:"18",r:"14",fill:"none",stroke:"currentColor",strokeWidth:"3",className:"text-muted/30"}),e.jsx("circle",{cx:"18",cy:"18",r:"14",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeDasharray:`${m*.88} 88`,strokeLinecap:"round",className:m>=90?"text-green-500":"text-amber-500"})]}),e.jsxs("span",{className:"absolute inset-0 flex items-center justify-center text-[8px] font-bold",children:[m,"%"]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-lg font-bold leading-none",children:J(c)}),e.jsx("div",{className:"text-[9px] text-muted-foreground mt-0.5",children:x>0?`${x} failed`:"All success"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-muted/30",children:[e.jsx("div",{className:"p-1.5 rounded-md bg-purple-100 dark:bg-purple-900/20",children:e.jsx(De,{className:"h-4 w-4 text-purple-600"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-lg font-bold leading-none",children:J(j)}),e.jsx("div",{className:"text-[9px] text-muted-foreground mt-0.5",children:"Total tokens"})]})]})]}),b.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-medium text-muted-foreground",children:[e.jsx(Te,{className:"h-3 w-3"}),"Models Used"]}),e.jsx("div",{className:"space-y-1",children:b.map(([C,$])=>{const A=Math.round($/v*100),B=xs(C);return e.jsxs("div",{className:"group",children:[e.jsxs("div",{className:"flex items-center justify-between text-[10px] mb-0.5",children:[e.jsx("span",{className:"truncate font-medium",title:C,children:B}),e.jsx("span",{className:"text-muted-foreground shrink-0 ml-2",children:$})]}),e.jsx("div",{className:"h-1 bg-muted/50 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-accent/70 rounded-full transition-all",style:{width:`${A}%`}})})]},C)})})]})]})})})]})}function J(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function xs(s){let t=s.replace(/^gemini-claude-/,"").replace(/^gemini-/,"").replace(/^claude-/,"").replace(/^anthropic\./,"").replace(/-thinking$/," Thinking");return t=t.split(/[-_]/).map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" "),t.length>20&&(t=t.slice(0,18)+"..."),t}function us(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(0)}K`:s.toString()}function ms({models:s,isLoading:t,onModelClick:a,privacyMode:l}){return e.jsxs(p,{className:"flex flex-col h-full min-h-0 shadow-sm lg:col-span-4",children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(ae,{className:"w-4 h-4"}),"Cost by Model"]})}),e.jsx(g,{className:"px-2 pb-2 pt-0 flex-1 min-h-0 overflow-y-auto",children:t?e.jsx(h,{className:"h-full w-full"}):e.jsxs("div",{className:"space-y-0.5",children:[[...s||[]].sort((r,i)=>i.cost-r.cost).map(r=>e.jsxs("button",{className:"group flex items-center text-xs w-full hover:bg-muted/50 rounded px-2 py-1.5 transition-colors cursor-pointer gap-3",onClick:i=>a(r,i),title:"Click for details",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 w-[180px] shrink-0",children:[e.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:te(r.model)}}),e.jsx("span",{className:"font-medium truncate group-hover:underline underline-offset-2",children:r.model})]}),e.jsx(hs,{model:r}),e.jsx("span",{className:d("text-[10px] text-muted-foreground w-14 text-right shrink-0",l&&y),children:us(r.tokens)}),e.jsxs("span",{className:d("font-mono font-medium w-16 text-right shrink-0",l&&y),children:["$",r.cost.toFixed(2)]}),e.jsx(Fe,{className:"w-3 h-3 opacity-0 group-hover:opacity-50 transition-opacity shrink-0"})]},r.model)),e.jsx(fs,{})]})})]})}function hs({model:s}){const t={input:"#335c67",output:"#fff3b0",cacheWrite:"#e09f3e",cacheRead:"#9e2a2b"},a=l=>s.cost>0?l/s.cost*100:0;return e.jsx("div",{className:"flex-1 flex items-center gap-1 min-w-0",children:e.jsxs("div",{className:"flex-1 h-2 bg-muted rounded-full overflow-hidden flex",children:[e.jsx("div",{className:"h-full",style:{backgroundColor:t.input,width:`${a(s.costBreakdown.input.cost)}%`},title:`Input: $${s.costBreakdown.input.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:t.output,width:`${a(s.costBreakdown.output.cost)}%`},title:`Output: $${s.costBreakdown.output.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:t.cacheWrite,width:`${a(s.costBreakdown.cacheCreation.cost)}%`},title:`Cache Write: $${s.costBreakdown.cacheCreation.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:t.cacheRead,width:`${a(s.costBreakdown.cacheRead.cost)}%`},title:`Cache Read: $${s.costBreakdown.cacheRead.cost.toFixed(2)}`})]})})}function fs(){const s=[{color:"#335c67",label:"Input"},{color:"#fff3b0",label:"Output",hasBorder:!0},{color:"#e09f3e",label:"Cache Write"},{color:"#9e2a2b",label:"Cache Read"}];return e.jsx("div",{className:"flex items-center gap-3 pt-2 px-2 text-[10px] text-muted-foreground border-t mt-2",children:s.map(({color:t,label:a,hasBorder:l})=>e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("div",{className:d("w-2 h-2 rounded-full",l&&"border border-muted-foreground/30"),style:{backgroundColor:t}}),a]},a))})}function ps({viewMode:s,trends:t,hourlyData:a,models:l,sessions:r,isTrendsLoading:i,isHourlyLoading:o,isModelsLoading:n,isSessionsLoading:c,isSummaryLoading:x,onModelClick:u}){const{privacyMode:m}=M();return e.jsxs("div",{className:"flex-1 flex flex-col min-h-0 gap-4",children:[e.jsxs(p,{className:"flex flex-col flex-1 min-h-0 max-h-[500px] overflow-hidden shadow-sm",children:[e.jsx(N,{className:"px-3 py-2 shrink-0",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Re,{className:"w-4 h-4"}),s==="hourly"?"Last 24 Hours":"Usage Trends"]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1 min-h-0",children:e.jsx(rs,{data:s==="hourly"?a||[]:t||[],isLoading:s==="hourly"?o:i,granularity:s==="hourly"?"hourly":"daily"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-10 gap-4 h-auto lg:h-[180px] shrink-0",children:[e.jsx(ms,{models:l,isLoading:n,onModelClick:u,privacyMode:m}),e.jsxs(p,{className:"flex flex-col h-full min-h-0 shadow-sm lg:col-span-2",children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Me,{className:"w-4 h-4"}),"Model Usage"]})}),e.jsx(g,{className:"px-2 pb-2 pt-0 flex-1 min-h-0 flex items-center justify-center",children:e.jsx(ls,{data:l||[],isLoading:n,className:"h-full w-full"})})]}),e.jsx(os,{data:r,isLoading:c,className:"lg:col-span-2"}),e.jsx(ds,{isLoading:x,className:"lg:col-span-2"})]})]})}function Ss(){return e.jsxs("div",{className:"space-y-4 h-full overflow-hidden",children:[e.jsxs(p,{className:"flex flex-col min-h-[300px]",children:[e.jsx(N,{className:"p-4 pb-2",children:e.jsx(h,{className:"h-4 w-32"})}),e.jsx(g,{className:"p-4 pt-0 flex-1",children:e.jsx(h,{className:"h-full w-full"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsxs(p,{className:"flex flex-col min-h-[250px]",children:[e.jsx(N,{className:"p-4 pb-2",children:e.jsx(h,{className:"h-4 w-28"})}),e.jsx(g,{className:"p-4 pt-2",children:e.jsx("div",{className:"space-y-3",children:[1,2,3,4,5].map(s=>e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(h,{className:"w-2.5 h-2.5 rounded-full"}),e.jsx(h,{className:"h-3 w-24"})]}),e.jsx(h,{className:"h-3 w-16"})]},s))})})]}),e.jsxs(p,{className:"flex flex-col min-h-[250px]",children:[e.jsx(N,{className:"p-4 pb-2",children:e.jsx(h,{className:"h-4 w-28"})}),e.jsx(g,{className:"p-4 pt-0 flex-1",children:e.jsxs("div",{className:"flex w-full h-full items-center",children:[e.jsx("div",{className:"flex-1 flex justify-center",children:e.jsx(h,{className:"h-[180px] w-[180px] rounded-full"})}),e.jsx("div",{className:"w-[140px] shrink-0 pl-2 space-y-2",children:[1,2,3,4].map(s=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(h,{className:"w-2 h-2 rounded-full"}),e.jsx(h,{className:"h-3 w-20"})]},s))})]})})]})]})]})}function Ls(){const s=f.useRef(null),{dateRange:t,handleDateRangeChange:a,handleTodayClick:l,handleRefresh:r,isRefreshing:i,lastUpdatedText:o,viewMode:n,summary:c,isSummaryLoading:x,trends:u,hourlyData:m,models:j,sessions:b,isTrendsLoading:v,isHourlyLoading:C,isModelsLoading:$,isSessionsLoading:A,handleModelClick:B,selectedModel:U,popoverPosition:q,handlePopoverClose:z}=ss();return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden px-4 pt-4 pb-50 gap-4",children:[e.jsx(as,{dateRange:t,onDateRangeChange:a,onTodayClick:l,onRefresh:r,isRefreshing:i,lastUpdatedText:o,viewMode:n}),e.jsx(Ee,{data:c,isLoading:x}),e.jsx(ps,{viewMode:n,trends:u,hourlyData:m,models:j,sessions:b,isTrendsLoading:v,isHourlyLoading:C,isModelsLoading:$,isSessionsLoading:A,isSummaryLoading:x,onModelClick:B}),e.jsxs(ee,{open:!!U,onOpenChange:O=>!O&&z(),children:[e.jsx(be,{asChild:!0,children:e.jsx("div",{ref:s,className:"fixed pointer-events-none",style:{left:q?.x??0,top:q?.y??0,width:1,height:1}})}),e.jsx(se,{className:"w-80 p-3",side:"top",align:"center",children:U&&e.jsx(Ge,{model:U})})]})]})}export{Ls as AnalyticsPage,Ss as AnalyticsSkeleton};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as s}from"./radix-ui-CFOhsBGh.js";import{r as l}from"./react-vendor-CNOkPC89.js";import{aK as o,aL as m,aM as c,aN as x,aO as u,b as h,C as p,a as g}from"./index-Dn2mUxH5.js";import{z as j,Y as f,aA as N,T as b}from"./icons-WqZToXEO.js";import"./tanstack-U3Rle5gh.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";function R(){const[t,i]=l.useState("commands"),{data:e}=o(),{data:n,isLoading:r}=m(t),d=[{id:"commands",label:"Commands",icon:j,count:e?.commands??0},{id:"skills",label:"Skills",icon:f,count:e?.skills??0},{id:"agents",label:"Agents",icon:N,count:e?.agents??0}];return s.jsxs("div",{className:"p-6 max-w-6xl mx-auto space-y-8",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold",children:"Shared Data"}),s.jsx("p",{className:"text-muted-foreground",children:"Commands, skills, and agents shared across Claude instances"})]}),e&&!e.symlinkStatus.valid&&s.jsxs(c,{variant:"warning",children:[s.jsx(b,{className:"h-4 w-4"}),s.jsx(x,{children:"Configuration Required"}),s.jsxs(u,{children:[e.symlinkStatus.message,". Run `ccs sync` to configure."]})]}),s.jsx("div",{className:"flex gap-2 border-b pb-2",children:d.map(a=>s.jsxs(h,{variant:t===a.id?"default":"ghost",size:"sm",onClick:()=>i(a.id),className:"flex items-center gap-2",children:[s.jsx(a.icon,{className:"w-4 h-4"}),a.label," (",a.count,")"]},a.id))}),s.jsx("div",{className:"mt-4",children:r?s.jsx("div",{className:"text-muted-foreground",children:"Loading..."}):n?.items.length===0?s.jsxs("div",{className:"text-muted-foreground",children:["No ",t," found"]}):s.jsx("div",{className:"grid gap-3",children:n?.items.map(a=>s.jsx(p,{children:s.jsxs(g,{children:[s.jsx("div",{className:"font-medium",children:a.name}),s.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:a.description}),s.jsx("p",{className:"text-xs text-muted-foreground mt-2 font-mono truncate",children:a.path})]})},a.name))})})]})}export{R as SharedPage};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Dashboard Authentication Middleware
|
|
3
|
-
* Session-based auth with httpOnly cookies for CCS dashboard.
|
|
4
|
-
*/
|
|
5
|
-
/// <reference types="qs" />
|
|
6
|
-
import type { Request, Response, NextFunction } from 'express';
|
|
7
|
-
declare module 'express-session' {
|
|
8
|
-
interface SessionData {
|
|
9
|
-
authenticated: boolean;
|
|
10
|
-
username: string;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Rate limiter for login attempts.
|
|
15
|
-
* 5 attempts per 15 minutes per IP.
|
|
16
|
-
*/
|
|
17
|
-
export declare const loginRateLimiter: import("express-rate-limit").RateLimitRequestHandler;
|
|
18
|
-
/**
|
|
19
|
-
* Create session middleware configured for CCS dashboard.
|
|
20
|
-
*/
|
|
21
|
-
export declare function createSessionMiddleware(): import("express").RequestHandler<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
|
|
22
|
-
/**
|
|
23
|
-
* Auth middleware that protects all routes except public paths.
|
|
24
|
-
* Only active when dashboard_auth.enabled = true.
|
|
25
|
-
*/
|
|
26
|
-
export declare function authMiddleware(req: Request, res: Response, next: NextFunction): void;
|
|
27
|
-
//# sourceMappingURL=auth-middleware.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth-middleware.d.ts","sourceRoot":"","sources":["../../../src/web-server/middleware/auth-middleware.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAU/D,OAAO,QAAQ,iBAAiB,CAAC;IAC/B,UAAU,WAAW;QACnB,aAAa,EAAE,OAAO,CAAC;QACvB,QAAQ,EAAE,MAAM,CAAC;KAClB;CACF;AA8CD;;;GAGG;AACH,eAAO,MAAM,gBAAgB,sDAO3B,CAAC;AAEH;;GAEG;AACH,wBAAgB,uBAAuB,iJAetC;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,GAAG,IAAI,CA0BpF"}
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Dashboard Authentication Middleware
|
|
4
|
-
* Session-based auth with httpOnly cookies for CCS dashboard.
|
|
5
|
-
*/
|
|
6
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
-
};
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.authMiddleware = exports.createSessionMiddleware = exports.loginRateLimiter = void 0;
|
|
11
|
-
const express_session_1 = __importDefault(require("express-session"));
|
|
12
|
-
const express_rate_limit_1 = __importDefault(require("express-rate-limit"));
|
|
13
|
-
const unified_config_loader_1 = require("../../config/unified-config-loader");
|
|
14
|
-
const crypto_1 = __importDefault(require("crypto"));
|
|
15
|
-
const fs_1 = __importDefault(require("fs"));
|
|
16
|
-
const path_1 = __importDefault(require("path"));
|
|
17
|
-
const os_1 = __importDefault(require("os"));
|
|
18
|
-
/** Public paths that bypass auth (lowercase for case-insensitive matching) */
|
|
19
|
-
const PUBLIC_PATHS = ['/api/auth/login', '/api/auth/check', '/api/auth/setup', '/api/health'];
|
|
20
|
-
/** Path to persistent session secret file */
|
|
21
|
-
const SESSION_SECRET_PATH = path_1.default.join(os_1.default.homedir(), '.ccs', '.session-secret');
|
|
22
|
-
/**
|
|
23
|
-
* Generate or retrieve persistent session secret.
|
|
24
|
-
* Priority: ENV var > persisted file > generate new
|
|
25
|
-
*/
|
|
26
|
-
function getSessionSecret() {
|
|
27
|
-
// 1. Check ENV var first
|
|
28
|
-
if (process.env.CCS_SESSION_SECRET) {
|
|
29
|
-
return process.env.CCS_SESSION_SECRET;
|
|
30
|
-
}
|
|
31
|
-
// 2. Try to read persisted secret
|
|
32
|
-
try {
|
|
33
|
-
if (fs_1.default.existsSync(SESSION_SECRET_PATH)) {
|
|
34
|
-
const secret = fs_1.default.readFileSync(SESSION_SECRET_PATH, 'utf-8').trim();
|
|
35
|
-
if (secret.length >= 32) {
|
|
36
|
-
return secret;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
catch {
|
|
41
|
-
// Ignore read errors, generate new secret
|
|
42
|
-
}
|
|
43
|
-
// 3. Generate and persist new random secret
|
|
44
|
-
const newSecret = crypto_1.default.randomBytes(32).toString('hex');
|
|
45
|
-
try {
|
|
46
|
-
const dir = path_1.default.dirname(SESSION_SECRET_PATH);
|
|
47
|
-
if (!fs_1.default.existsSync(dir)) {
|
|
48
|
-
fs_1.default.mkdirSync(dir, { recursive: true });
|
|
49
|
-
}
|
|
50
|
-
fs_1.default.writeFileSync(SESSION_SECRET_PATH, newSecret, { mode: 0o600 });
|
|
51
|
-
}
|
|
52
|
-
catch (err) {
|
|
53
|
-
// Log warning - sessions won't persist across restarts
|
|
54
|
-
console.warn('[!] Failed to persist session secret:', err.message);
|
|
55
|
-
}
|
|
56
|
-
return newSecret;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Rate limiter for login attempts.
|
|
60
|
-
* 5 attempts per 15 minutes per IP.
|
|
61
|
-
*/
|
|
62
|
-
exports.loginRateLimiter = (0, express_rate_limit_1.default)({
|
|
63
|
-
windowMs: 15 * 60 * 1000, // 15 minutes
|
|
64
|
-
max: 5, // 5 attempts
|
|
65
|
-
message: { error: 'Too many login attempts. Please try again later.' },
|
|
66
|
-
standardHeaders: true,
|
|
67
|
-
legacyHeaders: false,
|
|
68
|
-
skip: () => !(0, unified_config_loader_1.getDashboardAuthConfig)().enabled,
|
|
69
|
-
});
|
|
70
|
-
/**
|
|
71
|
-
* Create session middleware configured for CCS dashboard.
|
|
72
|
-
*/
|
|
73
|
-
function createSessionMiddleware() {
|
|
74
|
-
const authConfig = (0, unified_config_loader_1.getDashboardAuthConfig)();
|
|
75
|
-
const maxAge = (authConfig.session_timeout_hours ?? 24) * 60 * 60 * 1000;
|
|
76
|
-
return (0, express_session_1.default)({
|
|
77
|
-
secret: getSessionSecret(),
|
|
78
|
-
resave: false,
|
|
79
|
-
saveUninitialized: false,
|
|
80
|
-
cookie: {
|
|
81
|
-
secure: false, // Local CLI uses HTTP
|
|
82
|
-
httpOnly: true,
|
|
83
|
-
maxAge,
|
|
84
|
-
sameSite: 'strict',
|
|
85
|
-
},
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
exports.createSessionMiddleware = createSessionMiddleware;
|
|
89
|
-
/**
|
|
90
|
-
* Auth middleware that protects all routes except public paths.
|
|
91
|
-
* Only active when dashboard_auth.enabled = true.
|
|
92
|
-
*/
|
|
93
|
-
function authMiddleware(req, res, next) {
|
|
94
|
-
const authConfig = (0, unified_config_loader_1.getDashboardAuthConfig)();
|
|
95
|
-
// Skip auth if disabled
|
|
96
|
-
if (!authConfig.enabled) {
|
|
97
|
-
return next();
|
|
98
|
-
}
|
|
99
|
-
// Allow public paths (case-insensitive)
|
|
100
|
-
const pathLower = req.path.toLowerCase();
|
|
101
|
-
if (PUBLIC_PATHS.some((p) => pathLower.startsWith(p))) {
|
|
102
|
-
return next();
|
|
103
|
-
}
|
|
104
|
-
// Allow static assets and SPA routes (non-API)
|
|
105
|
-
if (!req.path.startsWith('/api/')) {
|
|
106
|
-
return next();
|
|
107
|
-
}
|
|
108
|
-
// Check session
|
|
109
|
-
if (req.session?.authenticated) {
|
|
110
|
-
return next();
|
|
111
|
-
}
|
|
112
|
-
// Unauthorized
|
|
113
|
-
res.status(401).json({ error: 'Authentication required' });
|
|
114
|
-
}
|
|
115
|
-
exports.authMiddleware = authMiddleware;
|
|
116
|
-
//# sourceMappingURL=auth-middleware.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth-middleware.js","sourceRoot":"","sources":["../../../src/web-server/middleware/auth-middleware.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAGH,sEAAsC;AACtC,4EAA2C;AAC3C,8EAA4E;AAC5E,oDAA4B;AAC5B,4CAAoB;AACpB,gDAAwB;AACxB,4CAAoB;AAUpB,8EAA8E;AAC9E,MAAM,YAAY,GAAG,CAAC,iBAAiB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,aAAa,CAAC,CAAC;AAE9F,6CAA6C;AAC7C,MAAM,mBAAmB,GAAG,cAAI,CAAC,IAAI,CAAC,YAAE,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAE/E;;;GAGG;AACH,SAAS,gBAAgB;IACvB,yBAAyB;IACzB,IAAI,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,CAAC;QACnC,OAAO,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC;IACxC,CAAC;IAED,kCAAkC;IAClC,IAAI,CAAC;QACH,IAAI,YAAE,CAAC,UAAU,CAAC,mBAAmB,CAAC,EAAE,CAAC;YACvC,MAAM,MAAM,GAAG,YAAE,CAAC,YAAY,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC;YACpE,IAAI,MAAM,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC;gBACxB,OAAO,MAAM,CAAC;YAChB,CAAC;QACH,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,0CA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G;AAqBH,QAAA,MAAM,MAAM,4CAAW,CAAC;AA8FxB,eAAe,MAAM,CAAC"}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Dashboard Authentication Routes
|
|
4
|
-
* Handles login, logout, session check, and setup status.
|
|
5
|
-
*/
|
|
6
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
-
};
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
const express_1 = require("express");
|
|
11
|
-
const bcrypt_1 = __importDefault(require("bcrypt"));
|
|
12
|
-
const crypto_1 = __importDefault(require("crypto"));
|
|
13
|
-
const unified_config_loader_1 = require("../../config/unified-config-loader");
|
|
14
|
-
const auth_middleware_1 = require("../middleware/auth-middleware");
|
|
15
|
-
/**
|
|
16
|
-
* Timing-safe string comparison to prevent timing attacks.
|
|
17
|
-
* Returns true if strings match, false otherwise.
|
|
18
|
-
*/
|
|
19
|
-
function timingSafeEqual(a, b) {
|
|
20
|
-
if (a.length !== b.length) {
|
|
21
|
-
// Still compare to avoid length-based timing leak
|
|
22
|
-
crypto_1.default.timingSafeEqual(Buffer.from(a), Buffer.from(a));
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
return crypto_1.default.timingSafeEqual(Buffer.from(a), Buffer.from(b));
|
|
26
|
-
}
|
|
27
|
-
const router = (0, express_1.Router)();
|
|
28
|
-
/**
|
|
29
|
-
* POST /api/auth/login
|
|
30
|
-
* Authenticate user with username/password.
|
|
31
|
-
* Rate limited: 5 attempts per 15 minutes.
|
|
32
|
-
*/
|
|
33
|
-
router.post('/login', auth_middleware_1.loginRateLimiter, async (req, res) => {
|
|
34
|
-
const { username, password } = req.body;
|
|
35
|
-
if (!username || !password) {
|
|
36
|
-
res.status(400).json({ error: 'Username and password required' });
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
const authConfig = (0, unified_config_loader_1.getDashboardAuthConfig)();
|
|
40
|
-
// Check if auth is configured
|
|
41
|
-
if (!authConfig.enabled || !authConfig.username || !authConfig.password_hash) {
|
|
42
|
-
res.status(400).json({ error: 'Authentication not configured' });
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
// Validate bcrypt hash format to prevent bcrypt.compare errors
|
|
46
|
-
const isBcryptHash = /^\$2[aby]?\$\d{2}\$.{53}$/.test(authConfig.password_hash);
|
|
47
|
-
if (!isBcryptHash) {
|
|
48
|
-
res.status(500).json({ error: 'Invalid password hash format in config' });
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
// Verify credentials (timing-safe comparison for username)
|
|
52
|
-
const usernameMatch = timingSafeEqual(username, authConfig.username);
|
|
53
|
-
const passwordMatch = await bcrypt_1.default.compare(password, authConfig.password_hash);
|
|
54
|
-
if (!usernameMatch || !passwordMatch) {
|
|
55
|
-
res.status(401).json({ error: 'Invalid credentials' });
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
// Regenerate session to prevent session fixation, then set auth
|
|
59
|
-
req.session.regenerate((err) => {
|
|
60
|
-
if (err) {
|
|
61
|
-
res.status(500).json({ error: 'Session error' });
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
req.session.authenticated = true;
|
|
65
|
-
req.session.username = username;
|
|
66
|
-
res.json({ success: true, username });
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
/**
|
|
70
|
-
* POST /api/auth/logout
|
|
71
|
-
* Clear session and log out user.
|
|
72
|
-
*/
|
|
73
|
-
router.post('/logout', (req, res) => {
|
|
74
|
-
req.session.destroy((err) => {
|
|
75
|
-
if (err) {
|
|
76
|
-
res.status(500).json({ error: 'Failed to logout' });
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
res.clearCookie('connect.sid');
|
|
80
|
-
res.json({ success: true });
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
/**
|
|
84
|
-
* GET /api/auth/check
|
|
85
|
-
* Check if user is authenticated and if auth is required.
|
|
86
|
-
*/
|
|
87
|
-
router.get('/check', (req, res) => {
|
|
88
|
-
const authConfig = (0, unified_config_loader_1.getDashboardAuthConfig)();
|
|
89
|
-
res.json({
|
|
90
|
-
authRequired: authConfig.enabled,
|
|
91
|
-
authenticated: req.session?.authenticated ?? false,
|
|
92
|
-
username: req.session?.username ?? null,
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
/**
|
|
96
|
-
* GET /api/auth/setup
|
|
97
|
-
* Check if authentication is properly configured.
|
|
98
|
-
*/
|
|
99
|
-
router.get('/setup', (_req, res) => {
|
|
100
|
-
const authConfig = (0, unified_config_loader_1.getDashboardAuthConfig)();
|
|
101
|
-
res.json({
|
|
102
|
-
enabled: authConfig.enabled,
|
|
103
|
-
configured: !!(authConfig.username && authConfig.password_hash),
|
|
104
|
-
sessionTimeoutHours: authConfig.session_timeout_hours ?? 24,
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
exports.default = router;
|
|
108
|
-
//# sourceMappingURL=auth-routes.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth-routes.js","sourceRoot":"","sources":["../../../src/web-server/routes/auth-routes.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;AAEH,qCAA8D;AAC9D,oDAA4B;AAC5B,oDAA4B;AAC5B,8EAA4E;AAC5E,mEAAiE;AAEjE;;;GAGG;AACH,SAAS,eAAe,CAAC,CAAS,EAAE,CAAS;IAC3C,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;QAC1B,kDAAkD;QAClD,gBAAM,CAAC,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QACvD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,gBAAM,CAAC,eAAe,CAAC,MA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