@kaitranntt/ccs 7.47.0-dev.1 → 7.47.0-dev.3
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/ccs.js +68 -97
- package/dist/ccs.js.map +1 -1
- package/dist/cliproxy/config/extended-context-config.d.ts +1 -8
- package/dist/cliproxy/config/extended-context-config.d.ts.map +1 -1
- package/dist/cliproxy/config/extended-context-config.js +8 -24
- package/dist/cliproxy/config/extended-context-config.js.map +1 -1
- package/dist/cliproxy/config/generator.d.ts +3 -1
- package/dist/cliproxy/config/generator.d.ts.map +1 -1
- package/dist/cliproxy/config/generator.js +210 -39
- package/dist/cliproxy/config/generator.js.map +1 -1
- package/dist/cliproxy/provider-capabilities.d.ts +6 -0
- package/dist/cliproxy/provider-capabilities.d.ts.map +1 -1
- package/dist/cliproxy/provider-capabilities.js +23 -2
- package/dist/cliproxy/provider-capabilities.js.map +1 -1
- package/dist/cliproxy/types.d.ts +1 -1
- package/dist/cliproxy/types.d.ts.map +1 -1
- package/dist/commands/api-command.d.ts +13 -0
- package/dist/commands/api-command.d.ts.map +1 -1
- package/dist/commands/api-command.js +85 -24
- package/dist/commands/api-command.js.map +1 -1
- package/dist/commands/arg-extractor.d.ts +29 -0
- package/dist/commands/arg-extractor.d.ts.map +1 -0
- package/dist/commands/arg-extractor.js +81 -0
- package/dist/commands/arg-extractor.js.map +1 -0
- package/dist/commands/cliproxy/help-subcommand.d.ts.map +1 -1
- package/dist/commands/cliproxy/help-subcommand.js +2 -1
- package/dist/commands/cliproxy/help-subcommand.js.map +1 -1
- package/dist/commands/cliproxy/index.d.ts.map +1 -1
- package/dist/commands/cliproxy/index.js +57 -123
- package/dist/commands/cliproxy/index.js.map +1 -1
- package/dist/commands/cliproxy/quota-subcommand.d.ts +2 -1
- package/dist/commands/cliproxy/quota-subcommand.d.ts.map +1 -1
- package/dist/commands/cliproxy/quota-subcommand.js +56 -46
- package/dist/commands/cliproxy/quota-subcommand.js.map +1 -1
- package/dist/commands/config-command.d.ts.map +1 -1
- package/dist/commands/config-command.js +17 -16
- package/dist/commands/config-command.js.map +1 -1
- package/dist/commands/config-image-analysis-command.d.ts.map +1 -1
- package/dist/commands/config-image-analysis-command.js +37 -27
- package/dist/commands/config-image-analysis-command.js.map +1 -1
- package/dist/commands/persist-command.d.ts.map +1 -1
- package/dist/commands/persist-command.js +76 -49
- package/dist/commands/persist-command.js.map +1 -1
- package/dist/management/checks/config-check.d.ts.map +1 -1
- package/dist/management/checks/config-check.js +2 -2
- package/dist/management/checks/config-check.js.map +1 -1
- package/dist/shared/extended-context-utils.d.ts +14 -0
- package/dist/shared/extended-context-utils.d.ts.map +1 -0
- package/dist/shared/extended-context-utils.js +35 -0
- package/dist/shared/extended-context-utils.js.map +1 -0
- package/dist/ui/assets/{accounts-BiL_RD2P.js → accounts-X_MzF4zx.js} +1 -1
- package/dist/ui/assets/{alert-dialog-BoSPpkH2.js → alert-dialog-Cw-P0uZM.js} +1 -1
- package/dist/ui/assets/{api-BrHcZxrF.js → api-BcwoMARb.js} +1 -1
- package/dist/ui/assets/{auth-section-CNEQOji9.js → auth-section-BqSvZ_5J.js} +1 -1
- package/dist/ui/assets/{backups-section-CYPJq2Y6.js → backups-section-CGOotFRy.js} +1 -1
- package/dist/ui/assets/{cliproxy-CDDlPp51.js → cliproxy-CWhMMbBa.js} +1 -1
- package/dist/ui/assets/{cliproxy-control-panel-XSSdoJ3f.js → cliproxy-control-panel-DAirmXSD.js} +1 -1
- package/dist/ui/assets/{confirm-dialog-JGLPn0Pg.js → confirm-dialog-BjFaR6B6.js} +1 -1
- package/dist/ui/assets/{copilot-Bt-S8kHA.js → copilot-DCp1_azM.js} +1 -1
- package/dist/ui/assets/{cursor-Qg3y30M0.js → cursor-DEUfi3ZN.js} +1 -1
- package/dist/ui/assets/{globalenv-section-Dxrj87dw.js → globalenv-section-Cu4vanAq.js} +1 -1
- package/dist/ui/assets/{health-Bjnrp81E.js → health-ChhDKSPa.js} +1 -1
- package/dist/ui/assets/{index-UVFLMRYY.js → index-BZ51hp4b.js} +1 -1
- package/dist/ui/assets/{index-DOQkTkq-.js → index-CHArFy3-.js} +1 -1
- package/dist/ui/assets/{index-ApptKWow.js → index-FdjOeYn2.js} +1 -1
- package/dist/ui/assets/{index-Ce5AiHY_.js → index-UX7yyQwV.js} +17 -17
- package/dist/ui/assets/{index-XJ9726WB.js → index-s9bW25En.js} +1 -1
- package/dist/ui/assets/{proxy-status-widget-PLX0fi09.js → proxy-status-widget-BLLMunUG.js} +1 -1
- package/dist/ui/assets/{separator-yZDNbi3M.js → separator-Nl0gQ6QN.js} +1 -1
- package/dist/ui/assets/{shared-DZ3QOOgF.js → shared-D7ILUK83.js} +1 -1
- package/dist/ui/assets/{switch-DsTWD8-1.js → switch-P5H3pmrk.js} +1 -1
- package/dist/ui/index.html +1 -1
- package/dist/utils/claude-config-path.d.ts +11 -0
- package/dist/utils/claude-config-path.d.ts.map +1 -0
- package/dist/utils/claude-config-path.js +51 -0
- package/dist/utils/claude-config-path.js.map +1 -0
- package/dist/utils/websearch/hook-config.d.ts.map +1 -1
- package/dist/utils/websearch/hook-config.js +9 -23
- package/dist/utils/websearch/hook-config.js.map +1 -1
- package/dist/web-server/jsonl-parser.d.ts +0 -4
- package/dist/web-server/jsonl-parser.d.ts.map +1 -1
- package/dist/web-server/jsonl-parser.js +52 -29
- package/dist/web-server/jsonl-parser.js.map +1 -1
- package/dist/web-server/routes/persist-routes.d.ts.map +1 -1
- package/dist/web-server/routes/persist-routes.js +54 -44
- package/dist/web-server/routes/persist-routes.js.map +1 -1
- package/dist/web-server/routes/route-helpers.d.ts +0 -5
- package/dist/web-server/routes/route-helpers.d.ts.map +1 -1
- package/dist/web-server/routes/route-helpers.js +52 -6
- package/dist/web-server/routes/route-helpers.js.map +1 -1
- package/dist/web-server/shared-routes.js +2 -2
- package/dist/web-server/shared-routes.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-qEZD5MMp.js";import{r as d}from"./react-vendor-CNOkPC89.js";import{b0 as ye,b1 as je,ae as L,I as T,X as ve,Y as Ne,Z as ke,_ as Ce,$ as z,b as Q,b2 as Pe,b3 as Se,b4 as we,aT as O,aV as V,m as Ie}from"./index-Ce5AiHY_.js";import{S as _}from"./switch-DsTWD8-1.js";import{C as D}from"./default-ports-1QQSffYX.js";import{aC as ee,R as U,e as Ee,q as te,W as Te,a1 as Le,aD as Ae,aE as _e,T as X,aF as De}from"./icons-DGASzt3M.js";import{P as Re}from"./proxy-status-widget-PLX0fi09.js";import{t as Z}from"./notifications-B2HqRBj7.js";import"./tanstack-De4wvi8X.js";import"./utils-CzKF5WmX.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-BoSPpkH2.js";function Be(){const{state:t}=ye(),s=je(),[n,m]=d.useState(null),[h,b]=d.useState(null),[g,u]=d.useState(null),[v,N]=d.useState(null),[f,k]=d.useState(null),C=d.useCallback(async()=>{try{s.setProxyLoading(!0),s.setProxyError(null);const l=await L.cliproxyServer.get();s.setProxyConfig(l)}catch(l){s.setProxyError(l.message)}finally{s.setProxyLoading(!1)}},[s]),P=d.useCallback(async l=>{const i=t.proxyConfig;if(!i)return;const p={remote:{...i.remote,...l.remote},fallback:{...i.fallback,...l.fallback},local:{...i.local,...l.local}};s.setProxyConfig(p),s.setProxyTestResult(null);try{s.setProxySaving(!0),s.setProxyError(null);const a=await L.cliproxyServer.update(l);s.setProxyConfig(a),s.setProxySuccess(!0),setTimeout(()=>s.setProxySuccess(!1),1500)}catch(a){s.setProxyConfig(i),s.setProxyError(a.message)}finally{s.setProxySaving(!1)}},[t.proxyConfig,s]),S=d.useCallback(async l=>{const{host:i,port:p,protocol:a,authToken:w}=l;if(!i){s.setProxyError("Host is required");return}try{s.setProxyTesting(!0),s.setProxyError(null),s.setProxyTestResult(null);const o=p?parseInt(p,10):void 0,I=await L.cliproxyServer.test({host:i,port:o||void 0,protocol:a,authToken:w||void 0});s.setProxyTestResult(I)}catch(o){s.setProxyError(o.message)}finally{s.setProxyTesting(!1)}},[s]);return{config:t.proxyConfig,loading:t.proxyLoading,saving:t.proxySaving,error:t.proxyError,success:t.proxySuccess,testResult:t.proxyTestResult,testing:t.proxyTesting,editedHost:n,setEditedHost:m,editedPort:h,setEditedPort:b,editedAuthToken:g,setEditedAuthToken:u,editedManagementKey:v,setEditedManagementKey:N,editedLocalPort:f,setEditedLocalPort:k,fetchConfig:C,saveConfig:P,testConnection:S}}function Me({config:t,saving:s,displayLocalPort:n,setEditedLocalPort:m,onSaveLocalPort:h,onSaveConfig:b}){const g=t.local;return e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Local Proxy"}),e.jsxs("div",{className:"space-y-3 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"Port"}),e.jsx(T,{type:"text",inputMode:"numeric",value:n,onChange:u=>m(u.target.value.replace(/\D/g,"")),onBlur:h,placeholder:`${D}`,className:"font-mono max-w-32",disabled:s})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:"Auto-start"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Start local proxy automatically when needed"})]}),e.jsx(_,{checked:g.auto_start??!0,onCheckedChange:u=>b({local:{...g,auto_start:u}}),disabled:s})]})]})]})}function Ke({config:t,saving:s,testing:n,testResult:m,displayHost:h,displayPort:b,displayAuthToken:g,displayManagementKey:u,setEditedHost:v,setEditedPort:N,setEditedAuthToken:f,setEditedManagementKey:k,onSaveHost:C,onSavePort:P,onSaveAuthToken:S,onSaveManagementKey:l,onSaveConfig:i,onTestConnection:p}){const a=t.remote,w=o=>o==="https"?443:D;return e.jsxs("div",{className:"space-y-4 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("h4",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(ee,{className:"w-4 h-4"}),"Remote Server Configuration"]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"Host"}),e.jsx(T,{value:h,onChange:o=>v(o.target.value),onBlur:C,placeholder:"192.168.1.100 or proxy.example.com",className:"font-mono",disabled:s})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("label",{className:"text-sm text-muted-foreground",children:["Port"," ",e.jsxs("span",{className:"text-xs opacity-70",children:["(default: ",w(t.remote.protocol||"http"),")"]})]}),e.jsx(T,{type:"text",inputMode:"numeric",value:b,onChange:o=>N(o.target.value.replace(/\D/g,"")),onBlur:P,placeholder:`Leave empty for ${w(t.remote.protocol||"http")}`,className:"font-mono",disabled:s})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"Protocol"}),e.jsxs(ve,{value:t.remote.protocol||"http",onValueChange:o=>i({remote:{...a,protocol:o}}),disabled:s,children:[e.jsx(Ne,{children:e.jsx(ke,{})}),e.jsxs(Ce,{children:[e.jsx(z,{value:"http",children:"HTTP"}),e.jsx(z,{value:"https",children:"HTTPS"})]})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"API Key (optional)"}),e.jsx(T,{type:"password",value:g,onChange:o=>f(o.target.value),onBlur:S,placeholder:"For /v1/* API endpoints",className:"font-mono",disabled:s}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Used for API requests to /v1/chat/completions"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"Management Key (optional)"}),e.jsx(T,{type:"password",value:u,onChange:o=>k(o.target.value),onBlur:l,placeholder:"For /v0/management/* endpoints",className:"font-mono",disabled:s}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Used for dashboard management APIs. Falls back to API Key if not set."})]}),e.jsxs("div",{className:"space-y-3 pt-2",children:[e.jsx(Q,{onClick:p,disabled:n||!h,variant:"outline",className:"w-full",children:n?e.jsxs(e.Fragment,{children:[e.jsx(U,{className:"w-4 h-4 mr-2 animate-spin"}),"Testing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ee,{className:"w-4 h-4 mr-2"}),"Test Connection"]})}),m&&e.jsx("div",{className:`p-3 rounded-md ${m.reachable?"bg-green-50 border border-green-200 dark:bg-green-900/20 dark:border-green-900/50":"bg-red-50 border border-red-200 dark:bg-red-900/20 dark:border-red-900/50"}`,children:e.jsx("div",{className:"flex items-center gap-2",children:m.reachable?e.jsxs(e.Fragment,{children:[e.jsx(te,{className:"w-4 h-4 text-green-600 dark:text-green-400"}),e.jsxs("span",{className:"text-sm font-medium text-green-700 dark:text-green-300",children:["Connected (",m.latencyMs,"ms)"]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Te,{className:"w-4 h-4 text-red-600 dark:text-red-400"}),e.jsx("span",{className:"text-sm font-medium text-red-700 dark:text-red-300",children:m.error||"Connection failed"})]})})})]})]})}const J="ccs_debug_mode",Fe=["kiro","ghcp"];function Qe(){const{config:t,loading:s,saving:n,error:m,success:h,testResult:b,testing:g,editedHost:u,setEditedHost:v,editedPort:N,setEditedPort:f,editedAuthToken:k,setEditedAuthToken:C,editedManagementKey:P,setEditedManagementKey:S,editedLocalPort:l,setEditedLocalPort:i,fetchConfig:p,saveConfig:a,testConnection:w}=Be(),{fetchRawConfig:o}=Pe(),[I,se]=d.useState(()=>{try{return localStorage.getItem(J)==="true"}catch{return!1}}),re=r=>{se(r);try{localStorage.setItem(J,String(r))}catch{}},[y,R]=d.useState("plus"),[ae,oe]=d.useState(!1),B=Se(),{data:ne}=we(),G=ne?.running??!1,M=d.useCallback(async()=>{try{const r=await L.cliproxyServer.getBackend();R(r.backend)}catch(r){console.error("[Proxy] Failed to fetch backend:",r)}},[]),K=d.useCallback(async()=>{try{const c=(await L.cliproxy.list()).variants.some(be=>Fe.includes(be.provider));oe(c)}catch(r){console.error("[Proxy] Failed to check variants:",r)}},[]),W=r=>{const c=y;R(r),B.mutate({backend:r},{onError:()=>{R(c)}})};if(d.useEffect(()=>{if(I&&t){const r={...t,remote:{...t.remote,auth_token:t.remote.auth_token?"[REDACTED]":void 0,management_key:t.remote.management_key?"[REDACTED]":void 0}};console.log("[CCS Debug] Debug mode enabled - proxy config:",r)}},[I,t]),d.useEffect(()=>{p(),o(),M(),K()},[p,o,M,K]),s||!t)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx(U,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:"Loading..."})]})});const x=t.remote.enabled??!1,A=!x&&G,j=t.remote,E=t.fallback,le=t.remote.host??"",ce=t.remote.port!==void 0?t.remote.port.toString():"",de=t.remote.auth_token??"",ie=t.remote.management_key??"",me=(t.local.port??D).toString(),F=u??le,$=N??ce,H=k??de,Y=P??ie,q=l??me,xe=()=>{const r=u??F;r!==t.remote.host&&a({remote:{...j,host:r}}),v(null)},ue=()=>{const r=(N??$).trim();if(r===""){t.remote.port!==void 0&&a({remote:{...j,port:void 0}}),f(null);return}const c=Number(r);if(!Number.isInteger(c)||c<1||c>65535){Z.error("Port must be an integer between 1 and 65535, or empty for default"),f(null);return}c!==t.remote.port&&a({remote:{...j,port:c}}),f(null)},pe=()=>{const r=k??H;r!==t.remote.auth_token&&a({remote:{...j,auth_token:r}}),C(null)},he=()=>{const r=P??Y;r!==t.remote.management_key&&a({remote:{...j,management_key:r||void 0}}),S(null)},ge=()=>{const r=(l??q).trim(),c=r===""?D:Number(r);if(!Number.isInteger(c)||c<1||c>65535){Z.error("Local port must be an integer between 1 and 65535"),i(null);return}c!==t.local.port&&a({local:{...t.local,port:c}}),i(null)},fe=()=>{w({host:F,port:$,protocol:t.remote.protocol||"http",authToken:H})};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${m||h?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[m&&e.jsxs(O,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(Le,{className:"h-4 w-4"}),e.jsx(V,{children:m})]}),h&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md border border-green-200 bg-green-50 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(te,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:"Saved"})]})]}),e.jsx(Ie,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Configure local or remote ",y==="plus"?"CLIProxy Plus":"CLIProxy"," connection for proxy-based profiles"]}),!x&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Instance Status"}),e.jsx(Re,{})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Connection Mode"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("button",{onClick:()=>a({remote:{...j,enabled:!1}}),disabled:n,className:`p-4 rounded-lg border-2 text-left transition-all ${x?"border-border hover:border-muted-foreground/50":"border-primary bg-primary/5"}`,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(Ae,{className:`w-5 h-5 ${x?"text-muted-foreground":"text-primary"}`}),e.jsx("span",{className:"font-medium",children:"Local"})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Run ",y==="plus"?"CLIProxy Plus":"CLIProxy"," binary on this machine"]})]}),e.jsxs("button",{onClick:()=>a({remote:{...j,enabled:!0}}),disabled:n,className:`p-4 rounded-lg border-2 text-left transition-all ${x?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/50"}`,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(ee,{className:`w-5 h-5 ${x?"text-primary":"text-muted-foreground"}`}),e.jsx("span",{className:"font-medium",children:"Remote"})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Connect to a remote ",y==="plus"?"CLIProxy Plus":"CLIProxy"," server"]})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-base font-medium flex items-center gap-2",children:[e.jsx(_e,{className:"w-4 h-4"}),"Backend Binary"]}),!x&&G&&e.jsxs(O,{className:"py-2 border-amber-200 bg-amber-50 dark:border-amber-900/50 dark:bg-amber-900/20 [&>svg]:top-2.5",children:[e.jsx(X,{className:"h-4 w-4 text-amber-600"}),e.jsx(V,{className:"text-amber-700 dark:text-amber-400",children:"Stop the running proxy in Instance Status to switch backend."})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("button",{onClick:()=>W("plus"),disabled:B.isPending||A,className:`p-4 rounded-lg border-2 text-left transition-all ${y==="plus"?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/50"} ${A?"opacity-60 cursor-not-allowed":""}`,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("span",{className:"font-medium",children:"CLIProxyAPIPlus"}),e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-green-100 text-green-700 dark:bg-green-900/50 dark:text-green-400",children:"Default"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Full provider support including Kiro and GitHub Copilot"})]}),e.jsxs("button",{onClick:()=>W("original"),disabled:B.isPending||A,className:`p-4 rounded-lg border-2 text-left transition-all ${y==="original"?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/50"} ${A?"opacity-60 cursor-not-allowed":""}`,children:[e.jsx("div",{className:"flex items-center gap-3 mb-2",children:e.jsx("span",{className:"font-medium",children:"CLIProxyAPI"})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Original binary (Gemini, Codex, Antigravity only)"})]})]}),y==="original"&&ae&&e.jsxs(O,{variant:"destructive",className:"py-2",children:[e.jsx(X,{className:"h-4 w-4"}),e.jsx(V,{children:"Existing Kiro/Copilot variants will not work with CLIProxyAPI. Switch to CLIProxyAPIPlus or remove those variants."})]})]}),x&&e.jsx(Ke,{config:t,saving:n,testing:g,testResult:b,displayHost:F,displayPort:$,displayAuthToken:H,displayManagementKey:Y,setEditedHost:v,setEditedPort:f,setEditedAuthToken:C,setEditedManagementKey:S,onSaveHost:xe,onSavePort:ue,onSaveAuthToken:pe,onSaveManagementKey:he,onSaveConfig:a,onTestConnection:fe}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Fallback Settings"}),e.jsxs("div",{className:"space-y-3 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:"Enable fallback to local"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Use local proxy if remote is unreachable"})]}),e.jsx(_,{checked:E.enabled??!0,onCheckedChange:r=>a({fallback:{...E,enabled:r}}),disabled:n||!x})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:"Auto-start local proxy"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Automatically start local proxy on fallback"})]}),e.jsx(_,{checked:E.auto_start??!1,onCheckedChange:r=>a({fallback:{...E,auto_start:r}}),disabled:n||!x||!E.enabled})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-base font-medium flex items-center gap-2",children:[e.jsx(De,{className:"w-4 h-4"}),"Advanced"]}),e.jsxs("div",{className:"space-y-3 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:"Debug Mode"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Enable developer diagnostics in browser console"})]}),e.jsx(_,{checked:I,onCheckedChange:re,disabled:n})]}),I&&e.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400 pl-0.5",children:"Debug mode enabled. Check browser console for detailed logs."})]})]}),!x&&e.jsx(Me,{config:t,saving:n,displayLocalPort:q,setEditedLocalPort:i,onSaveLocalPort:ge,onSaveConfig:a})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(Q,{variant:"outline",size:"sm",onClick:()=>{p(),o(),M(),K()},disabled:s||n,className:"w-full",children:[e.jsx(U,{className:`w-4 h-4 mr-2 ${s?"animate-spin":""}`}),"Refresh"]})})]})}export{Qe as default};
|
|
1
|
+
import{j as e}from"./radix-ui-qEZD5MMp.js";import{r as d}from"./react-vendor-CNOkPC89.js";import{b0 as ye,b1 as je,ae as L,I as T,X as ve,Y as Ne,Z as ke,_ as Ce,$ as z,b as Q,b2 as Pe,b3 as Se,b4 as we,aT as O,aV as V,m as Ie}from"./index-UX7yyQwV.js";import{S as _}from"./switch-P5H3pmrk.js";import{C as D}from"./default-ports-1QQSffYX.js";import{aC as ee,R as U,e as Ee,q as te,W as Te,a1 as Le,aD as Ae,aE as _e,T as X,aF as De}from"./icons-DGASzt3M.js";import{P as Re}from"./proxy-status-widget-BLLMunUG.js";import{t as Z}from"./notifications-B2HqRBj7.js";import"./tanstack-De4wvi8X.js";import"./utils-CzKF5WmX.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-Cw-P0uZM.js";function Be(){const{state:t}=ye(),s=je(),[n,m]=d.useState(null),[h,b]=d.useState(null),[g,u]=d.useState(null),[v,N]=d.useState(null),[f,k]=d.useState(null),C=d.useCallback(async()=>{try{s.setProxyLoading(!0),s.setProxyError(null);const l=await L.cliproxyServer.get();s.setProxyConfig(l)}catch(l){s.setProxyError(l.message)}finally{s.setProxyLoading(!1)}},[s]),P=d.useCallback(async l=>{const i=t.proxyConfig;if(!i)return;const p={remote:{...i.remote,...l.remote},fallback:{...i.fallback,...l.fallback},local:{...i.local,...l.local}};s.setProxyConfig(p),s.setProxyTestResult(null);try{s.setProxySaving(!0),s.setProxyError(null);const a=await L.cliproxyServer.update(l);s.setProxyConfig(a),s.setProxySuccess(!0),setTimeout(()=>s.setProxySuccess(!1),1500)}catch(a){s.setProxyConfig(i),s.setProxyError(a.message)}finally{s.setProxySaving(!1)}},[t.proxyConfig,s]),S=d.useCallback(async l=>{const{host:i,port:p,protocol:a,authToken:w}=l;if(!i){s.setProxyError("Host is required");return}try{s.setProxyTesting(!0),s.setProxyError(null),s.setProxyTestResult(null);const o=p?parseInt(p,10):void 0,I=await L.cliproxyServer.test({host:i,port:o||void 0,protocol:a,authToken:w||void 0});s.setProxyTestResult(I)}catch(o){s.setProxyError(o.message)}finally{s.setProxyTesting(!1)}},[s]);return{config:t.proxyConfig,loading:t.proxyLoading,saving:t.proxySaving,error:t.proxyError,success:t.proxySuccess,testResult:t.proxyTestResult,testing:t.proxyTesting,editedHost:n,setEditedHost:m,editedPort:h,setEditedPort:b,editedAuthToken:g,setEditedAuthToken:u,editedManagementKey:v,setEditedManagementKey:N,editedLocalPort:f,setEditedLocalPort:k,fetchConfig:C,saveConfig:P,testConnection:S}}function Me({config:t,saving:s,displayLocalPort:n,setEditedLocalPort:m,onSaveLocalPort:h,onSaveConfig:b}){const g=t.local;return e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Local Proxy"}),e.jsxs("div",{className:"space-y-3 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"Port"}),e.jsx(T,{type:"text",inputMode:"numeric",value:n,onChange:u=>m(u.target.value.replace(/\D/g,"")),onBlur:h,placeholder:`${D}`,className:"font-mono max-w-32",disabled:s})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:"Auto-start"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Start local proxy automatically when needed"})]}),e.jsx(_,{checked:g.auto_start??!0,onCheckedChange:u=>b({local:{...g,auto_start:u}}),disabled:s})]})]})]})}function Ke({config:t,saving:s,testing:n,testResult:m,displayHost:h,displayPort:b,displayAuthToken:g,displayManagementKey:u,setEditedHost:v,setEditedPort:N,setEditedAuthToken:f,setEditedManagementKey:k,onSaveHost:C,onSavePort:P,onSaveAuthToken:S,onSaveManagementKey:l,onSaveConfig:i,onTestConnection:p}){const a=t.remote,w=o=>o==="https"?443:D;return e.jsxs("div",{className:"space-y-4 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("h4",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(ee,{className:"w-4 h-4"}),"Remote Server Configuration"]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"Host"}),e.jsx(T,{value:h,onChange:o=>v(o.target.value),onBlur:C,placeholder:"192.168.1.100 or proxy.example.com",className:"font-mono",disabled:s})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("label",{className:"text-sm text-muted-foreground",children:["Port"," ",e.jsxs("span",{className:"text-xs opacity-70",children:["(default: ",w(t.remote.protocol||"http"),")"]})]}),e.jsx(T,{type:"text",inputMode:"numeric",value:b,onChange:o=>N(o.target.value.replace(/\D/g,"")),onBlur:P,placeholder:`Leave empty for ${w(t.remote.protocol||"http")}`,className:"font-mono",disabled:s})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"Protocol"}),e.jsxs(ve,{value:t.remote.protocol||"http",onValueChange:o=>i({remote:{...a,protocol:o}}),disabled:s,children:[e.jsx(Ne,{children:e.jsx(ke,{})}),e.jsxs(Ce,{children:[e.jsx(z,{value:"http",children:"HTTP"}),e.jsx(z,{value:"https",children:"HTTPS"})]})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"API Key (optional)"}),e.jsx(T,{type:"password",value:g,onChange:o=>f(o.target.value),onBlur:S,placeholder:"For /v1/* API endpoints",className:"font-mono",disabled:s}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Used for API requests to /v1/chat/completions"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"Management Key (optional)"}),e.jsx(T,{type:"password",value:u,onChange:o=>k(o.target.value),onBlur:l,placeholder:"For /v0/management/* endpoints",className:"font-mono",disabled:s}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Used for dashboard management APIs. Falls back to API Key if not set."})]}),e.jsxs("div",{className:"space-y-3 pt-2",children:[e.jsx(Q,{onClick:p,disabled:n||!h,variant:"outline",className:"w-full",children:n?e.jsxs(e.Fragment,{children:[e.jsx(U,{className:"w-4 h-4 mr-2 animate-spin"}),"Testing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ee,{className:"w-4 h-4 mr-2"}),"Test Connection"]})}),m&&e.jsx("div",{className:`p-3 rounded-md ${m.reachable?"bg-green-50 border border-green-200 dark:bg-green-900/20 dark:border-green-900/50":"bg-red-50 border border-red-200 dark:bg-red-900/20 dark:border-red-900/50"}`,children:e.jsx("div",{className:"flex items-center gap-2",children:m.reachable?e.jsxs(e.Fragment,{children:[e.jsx(te,{className:"w-4 h-4 text-green-600 dark:text-green-400"}),e.jsxs("span",{className:"text-sm font-medium text-green-700 dark:text-green-300",children:["Connected (",m.latencyMs,"ms)"]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Te,{className:"w-4 h-4 text-red-600 dark:text-red-400"}),e.jsx("span",{className:"text-sm font-medium text-red-700 dark:text-red-300",children:m.error||"Connection failed"})]})})})]})]})}const J="ccs_debug_mode",Fe=["kiro","ghcp"];function Qe(){const{config:t,loading:s,saving:n,error:m,success:h,testResult:b,testing:g,editedHost:u,setEditedHost:v,editedPort:N,setEditedPort:f,editedAuthToken:k,setEditedAuthToken:C,editedManagementKey:P,setEditedManagementKey:S,editedLocalPort:l,setEditedLocalPort:i,fetchConfig:p,saveConfig:a,testConnection:w}=Be(),{fetchRawConfig:o}=Pe(),[I,se]=d.useState(()=>{try{return localStorage.getItem(J)==="true"}catch{return!1}}),re=r=>{se(r);try{localStorage.setItem(J,String(r))}catch{}},[y,R]=d.useState("plus"),[ae,oe]=d.useState(!1),B=Se(),{data:ne}=we(),G=ne?.running??!1,M=d.useCallback(async()=>{try{const r=await L.cliproxyServer.getBackend();R(r.backend)}catch(r){console.error("[Proxy] Failed to fetch backend:",r)}},[]),K=d.useCallback(async()=>{try{const c=(await L.cliproxy.list()).variants.some(be=>Fe.includes(be.provider));oe(c)}catch(r){console.error("[Proxy] Failed to check variants:",r)}},[]),W=r=>{const c=y;R(r),B.mutate({backend:r},{onError:()=>{R(c)}})};if(d.useEffect(()=>{if(I&&t){const r={...t,remote:{...t.remote,auth_token:t.remote.auth_token?"[REDACTED]":void 0,management_key:t.remote.management_key?"[REDACTED]":void 0}};console.log("[CCS Debug] Debug mode enabled - proxy config:",r)}},[I,t]),d.useEffect(()=>{p(),o(),M(),K()},[p,o,M,K]),s||!t)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx(U,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:"Loading..."})]})});const x=t.remote.enabled??!1,A=!x&&G,j=t.remote,E=t.fallback,le=t.remote.host??"",ce=t.remote.port!==void 0?t.remote.port.toString():"",de=t.remote.auth_token??"",ie=t.remote.management_key??"",me=(t.local.port??D).toString(),F=u??le,$=N??ce,H=k??de,Y=P??ie,q=l??me,xe=()=>{const r=u??F;r!==t.remote.host&&a({remote:{...j,host:r}}),v(null)},ue=()=>{const r=(N??$).trim();if(r===""){t.remote.port!==void 0&&a({remote:{...j,port:void 0}}),f(null);return}const c=Number(r);if(!Number.isInteger(c)||c<1||c>65535){Z.error("Port must be an integer between 1 and 65535, or empty for default"),f(null);return}c!==t.remote.port&&a({remote:{...j,port:c}}),f(null)},pe=()=>{const r=k??H;r!==t.remote.auth_token&&a({remote:{...j,auth_token:r}}),C(null)},he=()=>{const r=P??Y;r!==t.remote.management_key&&a({remote:{...j,management_key:r||void 0}}),S(null)},ge=()=>{const r=(l??q).trim(),c=r===""?D:Number(r);if(!Number.isInteger(c)||c<1||c>65535){Z.error("Local port must be an integer between 1 and 65535"),i(null);return}c!==t.local.port&&a({local:{...t.local,port:c}}),i(null)},fe=()=>{w({host:F,port:$,protocol:t.remote.protocol||"http",authToken:H})};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${m||h?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[m&&e.jsxs(O,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(Le,{className:"h-4 w-4"}),e.jsx(V,{children:m})]}),h&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md border border-green-200 bg-green-50 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(te,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:"Saved"})]})]}),e.jsx(Ie,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Configure local or remote ",y==="plus"?"CLIProxy Plus":"CLIProxy"," connection for proxy-based profiles"]}),!x&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Instance Status"}),e.jsx(Re,{})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Connection Mode"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("button",{onClick:()=>a({remote:{...j,enabled:!1}}),disabled:n,className:`p-4 rounded-lg border-2 text-left transition-all ${x?"border-border hover:border-muted-foreground/50":"border-primary bg-primary/5"}`,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(Ae,{className:`w-5 h-5 ${x?"text-muted-foreground":"text-primary"}`}),e.jsx("span",{className:"font-medium",children:"Local"})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Run ",y==="plus"?"CLIProxy Plus":"CLIProxy"," binary on this machine"]})]}),e.jsxs("button",{onClick:()=>a({remote:{...j,enabled:!0}}),disabled:n,className:`p-4 rounded-lg border-2 text-left transition-all ${x?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/50"}`,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(ee,{className:`w-5 h-5 ${x?"text-primary":"text-muted-foreground"}`}),e.jsx("span",{className:"font-medium",children:"Remote"})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Connect to a remote ",y==="plus"?"CLIProxy Plus":"CLIProxy"," server"]})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-base font-medium flex items-center gap-2",children:[e.jsx(_e,{className:"w-4 h-4"}),"Backend Binary"]}),!x&&G&&e.jsxs(O,{className:"py-2 border-amber-200 bg-amber-50 dark:border-amber-900/50 dark:bg-amber-900/20 [&>svg]:top-2.5",children:[e.jsx(X,{className:"h-4 w-4 text-amber-600"}),e.jsx(V,{className:"text-amber-700 dark:text-amber-400",children:"Stop the running proxy in Instance Status to switch backend."})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("button",{onClick:()=>W("plus"),disabled:B.isPending||A,className:`p-4 rounded-lg border-2 text-left transition-all ${y==="plus"?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/50"} ${A?"opacity-60 cursor-not-allowed":""}`,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("span",{className:"font-medium",children:"CLIProxyAPIPlus"}),e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-green-100 text-green-700 dark:bg-green-900/50 dark:text-green-400",children:"Default"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Full provider support including Kiro and GitHub Copilot"})]}),e.jsxs("button",{onClick:()=>W("original"),disabled:B.isPending||A,className:`p-4 rounded-lg border-2 text-left transition-all ${y==="original"?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/50"} ${A?"opacity-60 cursor-not-allowed":""}`,children:[e.jsx("div",{className:"flex items-center gap-3 mb-2",children:e.jsx("span",{className:"font-medium",children:"CLIProxyAPI"})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Original binary (Gemini, Codex, Antigravity only)"})]})]}),y==="original"&&ae&&e.jsxs(O,{variant:"destructive",className:"py-2",children:[e.jsx(X,{className:"h-4 w-4"}),e.jsx(V,{children:"Existing Kiro/Copilot variants will not work with CLIProxyAPI. Switch to CLIProxyAPIPlus or remove those variants."})]})]}),x&&e.jsx(Ke,{config:t,saving:n,testing:g,testResult:b,displayHost:F,displayPort:$,displayAuthToken:H,displayManagementKey:Y,setEditedHost:v,setEditedPort:f,setEditedAuthToken:C,setEditedManagementKey:S,onSaveHost:xe,onSavePort:ue,onSaveAuthToken:pe,onSaveManagementKey:he,onSaveConfig:a,onTestConnection:fe}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Fallback Settings"}),e.jsxs("div",{className:"space-y-3 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:"Enable fallback to local"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Use local proxy if remote is unreachable"})]}),e.jsx(_,{checked:E.enabled??!0,onCheckedChange:r=>a({fallback:{...E,enabled:r}}),disabled:n||!x})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:"Auto-start local proxy"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Automatically start local proxy on fallback"})]}),e.jsx(_,{checked:E.auto_start??!1,onCheckedChange:r=>a({fallback:{...E,auto_start:r}}),disabled:n||!x||!E.enabled})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-base font-medium flex items-center gap-2",children:[e.jsx(De,{className:"w-4 h-4"}),"Advanced"]}),e.jsxs("div",{className:"space-y-3 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:"Debug Mode"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Enable developer diagnostics in browser console"})]}),e.jsx(_,{checked:I,onCheckedChange:re,disabled:n})]}),I&&e.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400 pl-0.5",children:"Debug mode enabled. Check browser console for detailed logs."})]})]}),!x&&e.jsx(Me,{config:t,saving:n,displayLocalPort:q,setEditedLocalPort:i,onSaveLocalPort:ge,onSaveConfig:a})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(Q,{variant:"outline",size:"sm",onClick:()=>{p(),o(),M(),K()},disabled:s||n,className:"w-full",children:[e.jsx(U,{className:`w-4 h-4 mr-2 ${s?"animate-spin":""}`}),"Refresh"]})})]})}export{Qe as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-qEZD5MMp.js";import{r as y}from"./react-vendor-CNOkPC89.js";import{b4 as J,aK as W,b5 as Z,b6 as _,b7 as ee,b8 as se,b9 as te,c as d,B as E,av as ae,E as ne,G as re,X as oe,Y as ie,Z as le,_ as ce,$ as de,b as T,T as xe,o as me,p as ue,ae as he}from"./index-Ce5AiHY_.js";import{A as ge,a as pe,b as fe,c as be,d as je,e as ye,f as Ne,g as ve}from"./alert-dialog-BoSPpkH2.js";import{u as q,a as we,b as Ce,e as Se}from"./tanstack-De4wvi8X.js";import{t as V}from"./notifications-B2HqRBj7.js";import{a2 as ke,A as Pe,R as f,aG as Ve,aH as Ae,aI as Te,X as De,S as Ie,aJ as Ue,aK as $e,U as Ee,p as Re,j as qe,a1 as Le,ao as Me,T as R,av as Fe}from"./icons-DGASzt3M.js";async function Ke(){const s=await fetch("/api/cliproxy/sync/status");if(!s.ok){let n="Failed to fetch sync status";try{const t=await s.json();n=t.error||t.message||n}catch{}throw new Error(n)}return s.json()}async function Be(){const s=new AbortController,n=setTimeout(()=>s.abort(),3e4);try{const t=await fetch("/api/cliproxy/sync",{method:"POST",headers:{"Content-Type":"application/json"},signal:s.signal});if(!t.ok){let a="Sync failed";try{const r=await t.json();a=r.error||r.message||a}catch{}throw new Error(a)}return t.json()}catch(t){throw t instanceof Error&&t.name==="AbortError"?new Error("Sync request timed out after 30 seconds"):t}finally{clearTimeout(n)}}function Qe(){return q({queryKey:["cliproxy-sync-status"],queryFn:Ke,refetchInterval:3e4,retry:1,staleTime:1e4})}function ze(){const s=we();return Ce({mutationFn:Be,onSuccess:n=>{s.invalidateQueries({queryKey:["cliproxy-sync-status"]}),s.invalidateQueries({queryKey:["cliproxy-sync-preview"]}),n.syncedCount===0?V.info("No profiles to sync"):V.success(`Synced ${n.syncedCount} profile${n.syncedCount===1?"":"s"} to CLIProxy`)},onError:n=>{V.error(`Sync failed: ${n.message}`)}})}function A(s,n){const t=s.replace(/-\d+$/,"").split(".").map(Number),a=n.replace(/-\d+$/,"").split(".").map(Number);for(let r=0;r<3;r++){if((t[r]||0)>(a[r]||0))return!0;if((t[r]||0)<(a[r]||0))return!1}return!1}function Ge(s){if(!s)return"";const n=new Date(s).getTime(),a=Date.now()-n,r=Math.floor(a/(1e3*60*60)),i=Math.floor(a%(1e3*60*60)/(1e3*60));return r>0?`${r}h ${i}m`:`${i}m`}function He(s){if(!s)return"";const n=Date.now()-s,t=Math.floor(n/(1e3*60)),a=Math.floor(n/(1e3*60*60));return t<1?"just now":t<60?`${t}m ago`:`${a}h ago`}function N({icon:s,tooltip:n,onClick:t,disabled:a,isPending:r,className:i,variant:l="ghost"}){return e.jsxs(xe,{children:[e.jsx(me,{asChild:!0,children:e.jsx(T,{variant:l==="destructive-ghost"?"ghost":l,size:"sm",className:d("h-7 w-7 p-0",l==="destructive-ghost"&&"hover:bg-destructive/10 hover:text-destructive hover:border-destructive/30",i),onClick:t,disabled:a,children:r?e.jsx(f,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(s,{className:"w-3.5 h-3.5"})})}),e.jsx(ue,{side:"bottom",className:"text-xs",children:n})]})}function es(){const{data:s,isLoading:n}=J(),{data:t}=W(),{data:a,isLoading:r}=Z(),i=_(),l=ee(),v=se(),u=te(),{data:L}=Qe(),{mutate:M,isPending:w}=ze(),[h,D]=y.useState(!1),[g,F]=y.useState(""),[K,b]=y.useState(!1),[C,S]=y.useState(null),{data:B}=q({queryKey:["cliproxy-server-config"],queryFn:()=>he.cliproxyServer.get(),staleTime:3e4}),Q=Se({mutationKey:["update-backend"]})>0,x=B?.remote,I=x?.enabled&&x?.host,p=s?.running??!1,k=i.isPending||l.isPending||v.isPending||u.isPending||Q||w,z=t?.hasUpdate??!1,m=t?.isStable===!1,U=t?.currentVersion,j=L?.configured??!1,G=j?"Sync Ready":"No Config",P=m?t?.maxStableVersion||a?.latestStable:t?.latestVersion,$=o=>{if(!o)return;const c=a?.maxStableVersion||"6.6.80";if(A(o,c)){S(o),b(!0);return}u.mutate({version:o})},H=()=>{C&&u.mutate({version:C,force:!0}),b(!1),S(null)},O=()=>{b(!1),S(null)},X=I?(()=>{const o=x.protocol||"http",c=x.port||(o==="https"?443:80);return o==="https"&&c===443||o==="http"&&c===80?x.host:`${x.host}:${c}`})():null;return I?e.jsxs("div",{className:d("rounded-lg border p-3 transition-colors","border-blue-500/30 bg-blue-500/5"),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ke,{className:"w-4 h-4 text-blue-500"}),e.jsx("span",{className:"text-sm font-medium",children:"Remote Proxy"}),e.jsx(E,{variant:"secondary",className:"text-[10px] h-4 px-1.5 bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400",children:"Active"})]}),e.jsx(Pe,{className:"w-3 h-3 text-blue-600"})]}),e.jsxs("div",{className:"mt-2 text-xs text-muted-foreground",children:[e.jsx("div",{className:"flex items-center gap-1 mb-1",children:e.jsx("span",{className:"font-mono",children:X})}),e.jsx("p",{className:"text-[10px] text-muted-foreground/70 leading-tight",children:"Traffic auto-routed to remote server"})]})]}):e.jsx(ae,{delayDuration:300,children:e.jsxs("div",{className:d("rounded-lg border p-3 transition-colors",p?"border-green-500/30 bg-green-500/5":"border-muted bg-muted/30"),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:d("w-2 h-2 rounded-full",p?"bg-green-500 animate-pulse":"bg-muted-foreground/30")}),e.jsx("span",{className:"text-sm font-medium",children:t?.backendLabel??"CLIProxy"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[n?e.jsx(f,{className:"w-3 h-3 animate-spin text-muted-foreground"}):p?e.jsxs(e.Fragment,{children:[e.jsx(N,{icon:w?f:Ve,tooltip:"Sync profiles to CLIProxy",onClick:()=>M(),disabled:!j||k,isPending:w}),e.jsx(N,{icon:Ae,tooltip:"Restart",onClick:()=>v.mutate(),disabled:k,isPending:v.isPending}),e.jsx(N,{icon:Te,tooltip:"Stop",onClick:()=>l.mutate(),disabled:k,isPending:l.isPending,variant:"destructive-ghost"})]}):null,e.jsx(N,{icon:h?De:Ie,tooltip:h?"Close":"Version settings",onClick:()=>D(!h),className:h?"bg-muted":void 0})]})]}),U&&e.jsxs("div",{className:"mt-1.5 flex items-center gap-2",children:[e.jsxs("span",{className:d("text-xs font-mono text-muted-foreground",m&&"text-amber-600 dark:text-amber-400"),children:["v",U]}),(z||m)&&P&&e.jsxs(E,{variant:"secondary",className:d("text-[10px] h-4 px-1.5 gap-0.5 cursor-pointer transition-colors",m?"bg-amber-100 text-amber-700 hover:bg-amber-200 dark:bg-amber-900/30 dark:text-amber-400 dark:hover:bg-amber-900/50":"bg-green-100 text-green-700 hover:bg-green-200 dark:bg-green-900/30 dark:text-green-400 dark:hover:bg-green-900/50"),onClick:()=>$(P),title:`Click to ${m?"downgrade":"update"}`,children:[m?e.jsx(Ue,{className:"w-2.5 h-2.5"}):e.jsx($e,{className:"w-2.5 h-2.5"}),P]})]}),p&&s&&e.jsxs("div",{className:"mt-2 flex items-center gap-4 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:["Port ",s.port]}),s.sessionCount!==void 0&&s.sessionCount>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ee,{className:"w-3 h-3"}),s.sessionCount," session",s.sessionCount!==1?"s":""]}),s.startedAt&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Re,{className:"w-3 h-3"}),Ge(s.startedAt)]})]}),e.jsxs("div",{className:"mt-2 flex items-center gap-1.5 text-xs",children:[j?e.jsx(qe,{className:"w-3 h-3 text-green-600 dark:text-green-400"}):e.jsx(Le,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:d("text-xs",j?"text-green-600 dark:text-green-400":"text-muted-foreground"),children:G})]}),e.jsx(ne,{open:h,onOpenChange:D,children:e.jsxs(re,{className:"mt-3 pt-3 border-t border-muted",children:[e.jsx("h4",{className:"text-xs font-medium text-muted-foreground mb-3",children:"Version Management"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(oe,{value:g,onValueChange:F,disabled:r,children:[e.jsx(ie,{className:"h-8 text-xs flex-1",children:e.jsx(le,{placeholder:"Select version to install..."})}),e.jsx(ce,{children:a?.versions.slice(0,20).map(o=>{const c=a?.maxStableVersion&&A(o,a.maxStableVersion);return e.jsx(de,{value:o,className:"text-xs",children:e.jsxs("span",{className:"flex items-center gap-2",children:["v",o,o===a.latestStable&&e.jsx("span",{className:"text-green-600 dark:text-green-400",children:"(stable)"}),c&&e.jsx("span",{className:"text-amber-600 dark:text-amber-400",children:"⚠"})]})},o)})})]}),e.jsxs(T,{variant:"outline",size:"sm",className:"h-8 text-xs gap-1.5 px-3",onClick:()=>$(g),disabled:u.isPending||!g,children:[u.isPending?e.jsx(f,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(Me,{className:"w-3.5 h-3.5"}),"Install"]})]}),g&&a?.maxStableVersion&&A(g,a.maxStableVersion)&&e.jsxs("div",{className:"mt-2 flex items-center gap-1.5 text-[11px] text-amber-600 dark:text-amber-400",children:[e.jsx(R,{className:"w-3.5 h-3.5 flex-shrink-0"}),e.jsxs("span",{children:["Versions above ",a.maxStableVersion," have known issues"]})]}),t?.checkedAt&&e.jsxs("div",{className:"mt-2 text-[10px] text-muted-foreground/60",children:["Last checked ",He(t.checkedAt)]})]})}),!p&&e.jsxs("div",{className:"mt-2 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Not running"}),e.jsxs(T,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1",onClick:()=>i.mutate(),disabled:i.isPending,children:[i.isPending?e.jsx(f,{className:"w-3 h-3 animate-spin"}):e.jsx(Fe,{className:"w-3 h-3"}),"Start"]})]}),e.jsx(ge,{open:K,onOpenChange:b,children:e.jsxs(pe,{children:[e.jsxs(fe,{children:[e.jsxs(be,{className:"flex items-center gap-2",children:[e.jsx(R,{className:"w-5 h-5 text-amber-500"}),"Install Unstable Version?"]}),e.jsxs(je,{className:"space-y-2",children:[e.jsxs("p",{children:["You are about to install ",e.jsxs("strong",{children:["v",C]}),", which is above the maximum stable version"," ",e.jsxs("strong",{children:["v",a?.maxStableVersion||"6.6.80"]}),"."]}),e.jsx("p",{className:"text-amber-600 dark:text-amber-400",children:"This version has known stability issues and may cause unexpected behavior."}),e.jsx("p",{children:"Are you sure you want to proceed?"})]})]}),e.jsxs(ye,{children:[e.jsx(Ne,{onClick:O,children:"Cancel"}),e.jsx(ve,{onClick:H,className:"bg-amber-500 hover:bg-amber-600 text-white",children:"Install Anyway"})]})]})})]})})}export{es as P};
|
|
1
|
+
import{j as e}from"./radix-ui-qEZD5MMp.js";import{r as y}from"./react-vendor-CNOkPC89.js";import{b4 as J,aK as W,b5 as Z,b6 as _,b7 as ee,b8 as se,b9 as te,c as d,B as E,av as ae,E as ne,G as re,X as oe,Y as ie,Z as le,_ as ce,$ as de,b as T,T as xe,o as me,p as ue,ae as he}from"./index-UX7yyQwV.js";import{A as ge,a as pe,b as fe,c as be,d as je,e as ye,f as Ne,g as ve}from"./alert-dialog-Cw-P0uZM.js";import{u as q,a as we,b as Ce,e as Se}from"./tanstack-De4wvi8X.js";import{t as V}from"./notifications-B2HqRBj7.js";import{a2 as ke,A as Pe,R as f,aG as Ve,aH as Ae,aI as Te,X as De,S as Ie,aJ as Ue,aK as $e,U as Ee,p as Re,j as qe,a1 as Le,ao as Me,T as R,av as Fe}from"./icons-DGASzt3M.js";async function Ke(){const s=await fetch("/api/cliproxy/sync/status");if(!s.ok){let n="Failed to fetch sync status";try{const t=await s.json();n=t.error||t.message||n}catch{}throw new Error(n)}return s.json()}async function Be(){const s=new AbortController,n=setTimeout(()=>s.abort(),3e4);try{const t=await fetch("/api/cliproxy/sync",{method:"POST",headers:{"Content-Type":"application/json"},signal:s.signal});if(!t.ok){let a="Sync failed";try{const r=await t.json();a=r.error||r.message||a}catch{}throw new Error(a)}return t.json()}catch(t){throw t instanceof Error&&t.name==="AbortError"?new Error("Sync request timed out after 30 seconds"):t}finally{clearTimeout(n)}}function Qe(){return q({queryKey:["cliproxy-sync-status"],queryFn:Ke,refetchInterval:3e4,retry:1,staleTime:1e4})}function ze(){const s=we();return Ce({mutationFn:Be,onSuccess:n=>{s.invalidateQueries({queryKey:["cliproxy-sync-status"]}),s.invalidateQueries({queryKey:["cliproxy-sync-preview"]}),n.syncedCount===0?V.info("No profiles to sync"):V.success(`Synced ${n.syncedCount} profile${n.syncedCount===1?"":"s"} to CLIProxy`)},onError:n=>{V.error(`Sync failed: ${n.message}`)}})}function A(s,n){const t=s.replace(/-\d+$/,"").split(".").map(Number),a=n.replace(/-\d+$/,"").split(".").map(Number);for(let r=0;r<3;r++){if((t[r]||0)>(a[r]||0))return!0;if((t[r]||0)<(a[r]||0))return!1}return!1}function Ge(s){if(!s)return"";const n=new Date(s).getTime(),a=Date.now()-n,r=Math.floor(a/(1e3*60*60)),i=Math.floor(a%(1e3*60*60)/(1e3*60));return r>0?`${r}h ${i}m`:`${i}m`}function He(s){if(!s)return"";const n=Date.now()-s,t=Math.floor(n/(1e3*60)),a=Math.floor(n/(1e3*60*60));return t<1?"just now":t<60?`${t}m ago`:`${a}h ago`}function N({icon:s,tooltip:n,onClick:t,disabled:a,isPending:r,className:i,variant:l="ghost"}){return e.jsxs(xe,{children:[e.jsx(me,{asChild:!0,children:e.jsx(T,{variant:l==="destructive-ghost"?"ghost":l,size:"sm",className:d("h-7 w-7 p-0",l==="destructive-ghost"&&"hover:bg-destructive/10 hover:text-destructive hover:border-destructive/30",i),onClick:t,disabled:a,children:r?e.jsx(f,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(s,{className:"w-3.5 h-3.5"})})}),e.jsx(ue,{side:"bottom",className:"text-xs",children:n})]})}function es(){const{data:s,isLoading:n}=J(),{data:t}=W(),{data:a,isLoading:r}=Z(),i=_(),l=ee(),v=se(),u=te(),{data:L}=Qe(),{mutate:M,isPending:w}=ze(),[h,D]=y.useState(!1),[g,F]=y.useState(""),[K,b]=y.useState(!1),[C,S]=y.useState(null),{data:B}=q({queryKey:["cliproxy-server-config"],queryFn:()=>he.cliproxyServer.get(),staleTime:3e4}),Q=Se({mutationKey:["update-backend"]})>0,x=B?.remote,I=x?.enabled&&x?.host,p=s?.running??!1,k=i.isPending||l.isPending||v.isPending||u.isPending||Q||w,z=t?.hasUpdate??!1,m=t?.isStable===!1,U=t?.currentVersion,j=L?.configured??!1,G=j?"Sync Ready":"No Config",P=m?t?.maxStableVersion||a?.latestStable:t?.latestVersion,$=o=>{if(!o)return;const c=a?.maxStableVersion||"6.6.80";if(A(o,c)){S(o),b(!0);return}u.mutate({version:o})},H=()=>{C&&u.mutate({version:C,force:!0}),b(!1),S(null)},O=()=>{b(!1),S(null)},X=I?(()=>{const o=x.protocol||"http",c=x.port||(o==="https"?443:80);return o==="https"&&c===443||o==="http"&&c===80?x.host:`${x.host}:${c}`})():null;return I?e.jsxs("div",{className:d("rounded-lg border p-3 transition-colors","border-blue-500/30 bg-blue-500/5"),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ke,{className:"w-4 h-4 text-blue-500"}),e.jsx("span",{className:"text-sm font-medium",children:"Remote Proxy"}),e.jsx(E,{variant:"secondary",className:"text-[10px] h-4 px-1.5 bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400",children:"Active"})]}),e.jsx(Pe,{className:"w-3 h-3 text-blue-600"})]}),e.jsxs("div",{className:"mt-2 text-xs text-muted-foreground",children:[e.jsx("div",{className:"flex items-center gap-1 mb-1",children:e.jsx("span",{className:"font-mono",children:X})}),e.jsx("p",{className:"text-[10px] text-muted-foreground/70 leading-tight",children:"Traffic auto-routed to remote server"})]})]}):e.jsx(ae,{delayDuration:300,children:e.jsxs("div",{className:d("rounded-lg border p-3 transition-colors",p?"border-green-500/30 bg-green-500/5":"border-muted bg-muted/30"),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:d("w-2 h-2 rounded-full",p?"bg-green-500 animate-pulse":"bg-muted-foreground/30")}),e.jsx("span",{className:"text-sm font-medium",children:t?.backendLabel??"CLIProxy"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[n?e.jsx(f,{className:"w-3 h-3 animate-spin text-muted-foreground"}):p?e.jsxs(e.Fragment,{children:[e.jsx(N,{icon:w?f:Ve,tooltip:"Sync profiles to CLIProxy",onClick:()=>M(),disabled:!j||k,isPending:w}),e.jsx(N,{icon:Ae,tooltip:"Restart",onClick:()=>v.mutate(),disabled:k,isPending:v.isPending}),e.jsx(N,{icon:Te,tooltip:"Stop",onClick:()=>l.mutate(),disabled:k,isPending:l.isPending,variant:"destructive-ghost"})]}):null,e.jsx(N,{icon:h?De:Ie,tooltip:h?"Close":"Version settings",onClick:()=>D(!h),className:h?"bg-muted":void 0})]})]}),U&&e.jsxs("div",{className:"mt-1.5 flex items-center gap-2",children:[e.jsxs("span",{className:d("text-xs font-mono text-muted-foreground",m&&"text-amber-600 dark:text-amber-400"),children:["v",U]}),(z||m)&&P&&e.jsxs(E,{variant:"secondary",className:d("text-[10px] h-4 px-1.5 gap-0.5 cursor-pointer transition-colors",m?"bg-amber-100 text-amber-700 hover:bg-amber-200 dark:bg-amber-900/30 dark:text-amber-400 dark:hover:bg-amber-900/50":"bg-green-100 text-green-700 hover:bg-green-200 dark:bg-green-900/30 dark:text-green-400 dark:hover:bg-green-900/50"),onClick:()=>$(P),title:`Click to ${m?"downgrade":"update"}`,children:[m?e.jsx(Ue,{className:"w-2.5 h-2.5"}):e.jsx($e,{className:"w-2.5 h-2.5"}),P]})]}),p&&s&&e.jsxs("div",{className:"mt-2 flex items-center gap-4 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:["Port ",s.port]}),s.sessionCount!==void 0&&s.sessionCount>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ee,{className:"w-3 h-3"}),s.sessionCount," session",s.sessionCount!==1?"s":""]}),s.startedAt&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Re,{className:"w-3 h-3"}),Ge(s.startedAt)]})]}),e.jsxs("div",{className:"mt-2 flex items-center gap-1.5 text-xs",children:[j?e.jsx(qe,{className:"w-3 h-3 text-green-600 dark:text-green-400"}):e.jsx(Le,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:d("text-xs",j?"text-green-600 dark:text-green-400":"text-muted-foreground"),children:G})]}),e.jsx(ne,{open:h,onOpenChange:D,children:e.jsxs(re,{className:"mt-3 pt-3 border-t border-muted",children:[e.jsx("h4",{className:"text-xs font-medium text-muted-foreground mb-3",children:"Version Management"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(oe,{value:g,onValueChange:F,disabled:r,children:[e.jsx(ie,{className:"h-8 text-xs flex-1",children:e.jsx(le,{placeholder:"Select version to install..."})}),e.jsx(ce,{children:a?.versions.slice(0,20).map(o=>{const c=a?.maxStableVersion&&A(o,a.maxStableVersion);return e.jsx(de,{value:o,className:"text-xs",children:e.jsxs("span",{className:"flex items-center gap-2",children:["v",o,o===a.latestStable&&e.jsx("span",{className:"text-green-600 dark:text-green-400",children:"(stable)"}),c&&e.jsx("span",{className:"text-amber-600 dark:text-amber-400",children:"⚠"})]})},o)})})]}),e.jsxs(T,{variant:"outline",size:"sm",className:"h-8 text-xs gap-1.5 px-3",onClick:()=>$(g),disabled:u.isPending||!g,children:[u.isPending?e.jsx(f,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(Me,{className:"w-3.5 h-3.5"}),"Install"]})]}),g&&a?.maxStableVersion&&A(g,a.maxStableVersion)&&e.jsxs("div",{className:"mt-2 flex items-center gap-1.5 text-[11px] text-amber-600 dark:text-amber-400",children:[e.jsx(R,{className:"w-3.5 h-3.5 flex-shrink-0"}),e.jsxs("span",{children:["Versions above ",a.maxStableVersion," have known issues"]})]}),t?.checkedAt&&e.jsxs("div",{className:"mt-2 text-[10px] text-muted-foreground/60",children:["Last checked ",He(t.checkedAt)]})]})}),!p&&e.jsxs("div",{className:"mt-2 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Not running"}),e.jsxs(T,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1",onClick:()=>i.mutate(),disabled:i.isPending,children:[i.isPending?e.jsx(f,{className:"w-3 h-3 animate-spin"}):e.jsx(Fe,{className:"w-3 h-3"}),"Start"]})]}),e.jsx(ge,{open:K,onOpenChange:b,children:e.jsxs(pe,{children:[e.jsxs(fe,{children:[e.jsxs(be,{className:"flex items-center gap-2",children:[e.jsx(R,{className:"w-5 h-5 text-amber-500"}),"Install Unstable Version?"]}),e.jsxs(je,{className:"space-y-2",children:[e.jsxs("p",{children:["You are about to install ",e.jsxs("strong",{children:["v",C]}),", which is above the maximum stable version"," ",e.jsxs("strong",{children:["v",a?.maxStableVersion||"6.6.80"]}),"."]}),e.jsx("p",{className:"text-amber-600 dark:text-amber-400",children:"This version has known stability issues and may cause unexpected behavior."}),e.jsx("p",{children:"Are you sure you want to proceed?"})]})]}),e.jsxs(ye,{children:[e.jsx(Ne,{onClick:O,children:"Cancel"}),e.jsx(ve,{onClick:H,className:"bg-amber-500 hover:bg-amber-600 text-white",children:"Install Anyway"})]})]})})]})})}export{es as P};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as i,a1 as n}from"./radix-ui-qEZD5MMp.js";import"./react-vendor-CNOkPC89.js";import{c as e}from"./index-
|
|
1
|
+
import{j as i,a1 as n}from"./radix-ui-qEZD5MMp.js";import"./react-vendor-CNOkPC89.js";import{c as e}from"./index-UX7yyQwV.js";function m({className:t,orientation:a="horizontal",decorative:o=!0,...r}){return i.jsx(n,{"data-slot":"separator",decorative:o,orientation:a,className:e("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",t),...r})}export{m as S};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as s}from"./radix-ui-qEZD5MMp.js";import{r as l}from"./react-vendor-CNOkPC89.js";import{a_ as o,a$ as m,aT as c,aU as x,aV as u,b as h,C as p,a as g}from"./index-
|
|
1
|
+
import{j as s}from"./radix-ui-qEZD5MMp.js";import{r as l}from"./react-vendor-CNOkPC89.js";import{a_ as o,a$ as m,aT as c,aU as x,aV as u,b as h,C as p,a as g}from"./index-UX7yyQwV.js";import{N as j,a0 as f,aA as N,T as b}from"./icons-DGASzt3M.js";import"./tanstack-De4wvi8X.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";function B(){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{B as SharedPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as a,a2 as s,a3 as n}from"./radix-ui-qEZD5MMp.js";import"./react-vendor-CNOkPC89.js";import{c as e}from"./index-
|
|
1
|
+
import{j as a,a2 as s,a3 as n}from"./radix-ui-qEZD5MMp.js";import"./react-vendor-CNOkPC89.js";import{c as e}from"./index-UX7yyQwV.js";function c({className:t,...r}){return a.jsx(s,{"data-slot":"switch",className:e("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",t),...r,children:a.jsx(n,{"data-slot":"switch-thumb",className:e("bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}export{c as S};
|
package/dist/ui/index.html
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&display=swap"
|
|
25
25
|
rel="stylesheet"
|
|
26
26
|
/>
|
|
27
|
-
<script type="module" crossorigin src="/assets/index-
|
|
27
|
+
<script type="module" crossorigin src="/assets/index-UX7yyQwV.js"></script>
|
|
28
28
|
<link rel="modulepreload" crossorigin href="/assets/react-vendor-CNOkPC89.js">
|
|
29
29
|
<link rel="modulepreload" crossorigin href="/assets/radix-ui-qEZD5MMp.js">
|
|
30
30
|
<link rel="modulepreload" crossorigin href="/assets/tanstack-De4wvi8X.js">
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve Claude config directory with test/dev overrides.
|
|
3
|
+
* Precedence:
|
|
4
|
+
* 1. CLAUDE_CONFIG_DIR (explicit override)
|
|
5
|
+
* 2. CCS_HOME compatibility path (<dirname(CCS_HOME)>/.claude)
|
|
6
|
+
* 3. ~/.claude (default)
|
|
7
|
+
*/
|
|
8
|
+
export declare function getClaudeConfigDir(): string;
|
|
9
|
+
/** Resolve Claude settings.json path. */
|
|
10
|
+
export declare function getClaudeSettingsPath(): string;
|
|
11
|
+
//# sourceMappingURL=claude-config-path.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-config-path.d.ts","sourceRoot":"","sources":["../../src/utils/claude-config-path.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAU3C;AAED,yCAAyC;AACzC,wBAAgB,qBAAqB,IAAI,MAAM,CAE9C"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.getClaudeSettingsPath = exports.getClaudeConfigDir = void 0;
|
|
27
|
+
const os = __importStar(require("os"));
|
|
28
|
+
const path = __importStar(require("path"));
|
|
29
|
+
/**
|
|
30
|
+
* Resolve Claude config directory with test/dev overrides.
|
|
31
|
+
* Precedence:
|
|
32
|
+
* 1. CLAUDE_CONFIG_DIR (explicit override)
|
|
33
|
+
* 2. CCS_HOME compatibility path (<dirname(CCS_HOME)>/.claude)
|
|
34
|
+
* 3. ~/.claude (default)
|
|
35
|
+
*/
|
|
36
|
+
function getClaudeConfigDir() {
|
|
37
|
+
if (process.env.CLAUDE_CONFIG_DIR) {
|
|
38
|
+
return path.resolve(process.env.CLAUDE_CONFIG_DIR);
|
|
39
|
+
}
|
|
40
|
+
if (process.env.CCS_HOME) {
|
|
41
|
+
return path.join(path.dirname(path.resolve(process.env.CCS_HOME)), '.claude');
|
|
42
|
+
}
|
|
43
|
+
return path.join(os.homedir(), '.claude');
|
|
44
|
+
}
|
|
45
|
+
exports.getClaudeConfigDir = getClaudeConfigDir;
|
|
46
|
+
/** Resolve Claude settings.json path. */
|
|
47
|
+
function getClaudeSettingsPath() {
|
|
48
|
+
return path.join(getClaudeConfigDir(), 'settings.json');
|
|
49
|
+
}
|
|
50
|
+
exports.getClaudeSettingsPath = getClaudeSettingsPath;
|
|
51
|
+
//# sourceMappingURL=claude-config-path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-config-path.js","sourceRoot":"","sources":["../../src/utils/claude-config-path.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAE7B;;;;;;GAMG;AACH,SAAgB,kBAAkB;IAChC,IAAI,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,CAAC;QAClC,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IACrD,CAAC;IAED,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;QACzB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;IAChF,CAAC;IAED,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,CAAC,CAAC;AAC5C,CAAC;AAVD,gDAUC;AAED,yCAAyC;AACzC,SAAgB,qBAAqB;IACnC,OAAO,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,EAAE,eAAe,CAAC,CAAC;AAC1D,CAAC;AAFD,sDAEC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hook-config.d.ts","sourceRoot":"","sources":["../../../src/utils/websearch/hook-config.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"hook-config.d.ts","sourceRoot":"","sources":["../../../src/utils/websearch/hook-config.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAmBH;;GAEG;AACH,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAkChE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,OAAO,CA6H1C;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,OAAO,CA4D1C"}
|
|
@@ -33,27 +33,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
33
33
|
exports.removeHookConfig = exports.ensureHookConfig = exports.getWebSearchHookConfig = exports.getHookPath = void 0;
|
|
34
34
|
const fs = __importStar(require("fs"));
|
|
35
35
|
const path = __importStar(require("path"));
|
|
36
|
-
const os = __importStar(require("os"));
|
|
37
36
|
const ui_1 = require("../ui");
|
|
38
37
|
const unified_config_loader_1 = require("../../config/unified-config-loader");
|
|
39
38
|
const config_manager_1 = require("../config-manager");
|
|
39
|
+
const claude_config_path_1 = require("../claude-config-path");
|
|
40
40
|
const hook_utils_1 = require("./hook-utils");
|
|
41
41
|
// Hook file name
|
|
42
42
|
const WEBSEARCH_HOOK = 'websearch-transformer.cjs';
|
|
43
|
-
/**
|
|
44
|
-
* Get Claude settings path (respects CCS_HOME for test isolation)
|
|
45
|
-
* In tests, returns path under CCS_HOME; in production, uses real ~/.claude/
|
|
46
|
-
*/
|
|
47
|
-
function getClaudeSettingsPath() {
|
|
48
|
-
const ccsHome = process.env.CCS_HOME;
|
|
49
|
-
if (ccsHome) {
|
|
50
|
-
// Test mode: use CCS_HOME parent for .claude directory
|
|
51
|
-
// This prevents tests from modifying user's real settings
|
|
52
|
-
return path.join(path.dirname(ccsHome), '.claude', 'settings.json');
|
|
53
|
-
}
|
|
54
|
-
// Production: use real home directory
|
|
55
|
-
return path.join(os.homedir(), '.claude', 'settings.json');
|
|
56
|
-
}
|
|
57
43
|
// Buffer time added to max provider timeout for hook timeout (seconds)
|
|
58
44
|
const HOOK_TIMEOUT_BUFFER = 30;
|
|
59
45
|
// Minimum hook timeout in seconds (fallback if no providers configured)
|
|
@@ -113,9 +99,9 @@ function ensureHookConfig() {
|
|
|
113
99
|
}
|
|
114
100
|
// Read existing settings or start fresh
|
|
115
101
|
let settings = {};
|
|
116
|
-
if (fs.existsSync(getClaudeSettingsPath())) {
|
|
102
|
+
if (fs.existsSync((0, claude_config_path_1.getClaudeSettingsPath)())) {
|
|
117
103
|
try {
|
|
118
|
-
const content = fs.readFileSync(getClaudeSettingsPath(), 'utf8');
|
|
104
|
+
const content = fs.readFileSync((0, claude_config_path_1.getClaudeSettingsPath)(), 'utf8');
|
|
119
105
|
settings = JSON.parse(content);
|
|
120
106
|
}
|
|
121
107
|
catch {
|
|
@@ -167,7 +153,7 @@ function ensureHookConfig() {
|
|
|
167
153
|
}
|
|
168
154
|
// Combine into single write if either changed
|
|
169
155
|
if (hadDuplicates || needsUpdate) {
|
|
170
|
-
fs.writeFileSync(getClaudeSettingsPath(), JSON.stringify(settings, null, 2), 'utf8');
|
|
156
|
+
fs.writeFileSync((0, claude_config_path_1.getClaudeSettingsPath)(), JSON.stringify(settings, null, 2), 'utf8');
|
|
171
157
|
if (process.env.CCS_DEBUG) {
|
|
172
158
|
if (hadDuplicates)
|
|
173
159
|
console.error((0, ui_1.info)('Removed duplicate WebSearch hooks from settings.json'));
|
|
@@ -197,12 +183,12 @@ function ensureHookConfig() {
|
|
|
197
183
|
const preToolUseHooks = hookConfig.PreToolUse;
|
|
198
184
|
settingsHooks.PreToolUse.push(...preToolUseHooks);
|
|
199
185
|
// Ensure ~/.claude directory exists
|
|
200
|
-
const claudeDir = path.dirname(getClaudeSettingsPath());
|
|
186
|
+
const claudeDir = path.dirname((0, claude_config_path_1.getClaudeSettingsPath)());
|
|
201
187
|
if (!fs.existsSync(claudeDir)) {
|
|
202
188
|
fs.mkdirSync(claudeDir, { recursive: true, mode: 0o700 });
|
|
203
189
|
}
|
|
204
190
|
// Write updated settings
|
|
205
|
-
fs.writeFileSync(getClaudeSettingsPath(), JSON.stringify(settings, null, 2), 'utf8');
|
|
191
|
+
fs.writeFileSync((0, claude_config_path_1.getClaudeSettingsPath)(), JSON.stringify(settings, null, 2), 'utf8');
|
|
206
192
|
if (process.env.CCS_DEBUG) {
|
|
207
193
|
console.error((0, ui_1.info)('Added WebSearch hook to settings.json'));
|
|
208
194
|
}
|
|
@@ -223,10 +209,10 @@ exports.ensureHookConfig = ensureHookConfig;
|
|
|
223
209
|
*/
|
|
224
210
|
function removeHookConfig() {
|
|
225
211
|
try {
|
|
226
|
-
if (!fs.existsSync(getClaudeSettingsPath())) {
|
|
212
|
+
if (!fs.existsSync((0, claude_config_path_1.getClaudeSettingsPath)())) {
|
|
227
213
|
return true; // Nothing to remove
|
|
228
214
|
}
|
|
229
|
-
const content = fs.readFileSync(getClaudeSettingsPath(), 'utf8');
|
|
215
|
+
const content = fs.readFileSync((0, claude_config_path_1.getClaudeSettingsPath)(), 'utf8');
|
|
230
216
|
let settings;
|
|
231
217
|
try {
|
|
232
218
|
settings = JSON.parse(content);
|
|
@@ -263,7 +249,7 @@ function removeHookConfig() {
|
|
|
263
249
|
if (Object.keys(hooks).length === 0) {
|
|
264
250
|
delete settings.hooks;
|
|
265
251
|
}
|
|
266
|
-
fs.writeFileSync(getClaudeSettingsPath(), JSON.stringify(settings, null, 2), 'utf8');
|
|
252
|
+
fs.writeFileSync((0, claude_config_path_1.getClaudeSettingsPath)(), JSON.stringify(settings, null, 2), 'utf8');
|
|
267
253
|
if (process.env.CCS_DEBUG) {
|
|
268
254
|
console.error((0, ui_1.info)('Removed WebSearch hook from settings.json'));
|
|
269
255
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hook-config.js","sourceRoot":"","sources":["../../../src/utils/websearch/hook-config.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AACzB,2CAA6B;AAC7B,
|
|
1
|
+
{"version":3,"file":"hook-config.js","sourceRoot":"","sources":["../../../src/utils/websearch/hook-config.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AACzB,2CAA6B;AAC7B,8BAAmC;AACnC,8EAAwE;AACxE,sDAAmD;AACnD,8DAA8D;AAC9D,6CAAuE;AAEvE,iBAAiB;AACjB,MAAM,cAAc,GAAG,2BAA2B,CAAC;AAEnD,uEAAuE;AACvE,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAE/B,wEAAwE;AACxE,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAE5B;;GAEG;AACH,SAAgB,WAAW;IACzB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAA,+BAAc,GAAE,EAAE,cAAc,CAAC,CAAC;AACrD,CAAC;AAFD,kCAEC;AAED;;;GAGG;AACH,SAAgB,sBAAsB;IACpC,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;IAC/B,MAAM,QAAQ,GAAG,IAAA,0CAAkB,GAAE,CAAC;IAEtC,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CAAC;YACpC,OAAO,QAAQ,CAAC,KAAK,CAAC;QACxB,CAAC;QAED,EAAE,CAAC,aAAa,CAAC,IAAA,0CAAqB,GAAE,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;QAErF,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC;YAC1B,OAAO,CAAC,KAAK,CAAC,IAAA,SAAI,EAAC,2CAA2C,CAAC,CAAC,CAAC;QACnE,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC;YAC1B,OAAO,CAAC,KAAK,CAAC,IAAA,SAAI,EAAC,iCAAkC,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QACnF,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AA5DD,4CA4DC"}
|
|
@@ -32,10 +32,6 @@ export interface ParserOptions {
|
|
|
32
32
|
/** Custom projects directory (default: ~/.claude/projects) */
|
|
33
33
|
projectsDir?: string;
|
|
34
34
|
}
|
|
35
|
-
/**
|
|
36
|
-
* Parse a single JSONL line into RawUsageEntry if valid
|
|
37
|
-
* Returns null for non-assistant entries or entries without usage data
|
|
38
|
-
*/
|
|
39
35
|
export declare function parseUsageEntry(line: string, projectPath: string): RawUsageEntry | null;
|
|
40
36
|
/**
|
|
41
37
|
* Stream-parse a single JSONL file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonl-parser.d.ts","sourceRoot":"","sources":["../../src/web-server/jsonl-parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAWH,sCAAsC;AACtC,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,mBAAmB,EAAE,MAAM,CAAC;IA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AAc,CAClC,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,aAAa,EAAE,CAAC,CA0B1B;AAWD;;GAEG;AACH,wBAAsB,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAqBxF;AAMD;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAE9C;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAWrE;AAED;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CAAC,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAqCjG;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAc5D"}
|
|
@@ -39,7 +39,9 @@ exports.countJsonlFiles = exports.scanProjectsDirectory = exports.findProjectDir
|
|
|
39
39
|
const fs = __importStar(require("fs"));
|
|
40
40
|
const path = __importStar(require("path"));
|
|
41
41
|
const readline = __importStar(require("readline"));
|
|
42
|
-
const
|
|
42
|
+
const claude_config_path_1 = require("../utils/claude-config-path");
|
|
43
|
+
const DEFAULT_SCAN_CONCURRENCY = 10;
|
|
44
|
+
const MAX_SCAN_CONCURRENCY = 64;
|
|
43
45
|
// ============================================================================
|
|
44
46
|
// CORE PARSING FUNCTIONS
|
|
45
47
|
// ============================================================================
|
|
@@ -47,6 +49,13 @@ const os = __importStar(require("os"));
|
|
|
47
49
|
* Parse a single JSONL line into RawUsageEntry if valid
|
|
48
50
|
* Returns null for non-assistant entries or entries without usage data
|
|
49
51
|
*/
|
|
52
|
+
function toNonNegativeNumber(value) {
|
|
53
|
+
const numeric = typeof value === 'number' ? value : Number(value);
|
|
54
|
+
if (!Number.isFinite(numeric) || numeric < 0) {
|
|
55
|
+
return 0;
|
|
56
|
+
}
|
|
57
|
+
return numeric;
|
|
58
|
+
}
|
|
50
59
|
function parseUsageEntry(line, projectPath) {
|
|
51
60
|
// Strip UTF-8 BOM if present (can occur on first line of some files)
|
|
52
61
|
const cleanLine = line.replace(/^\uFEFF/, '').trim();
|
|
@@ -64,10 +73,10 @@ function parseUsageEntry(line, projectPath) {
|
|
|
64
73
|
const usage = entry.message.usage;
|
|
65
74
|
const assistant = entry;
|
|
66
75
|
return {
|
|
67
|
-
inputTokens: usage.input_tokens
|
|
68
|
-
outputTokens: usage.output_tokens
|
|
69
|
-
cacheCreationTokens: usage.cache_creation_input_tokens
|
|
70
|
-
cacheReadTokens: usage.cache_read_input_tokens
|
|
76
|
+
inputTokens: toNonNegativeNumber(usage.input_tokens),
|
|
77
|
+
outputTokens: toNonNegativeNumber(usage.output_tokens),
|
|
78
|
+
cacheCreationTokens: toNonNegativeNumber(usage.cache_creation_input_tokens),
|
|
79
|
+
cacheReadTokens: toNonNegativeNumber(usage.cache_read_input_tokens),
|
|
71
80
|
model: assistant.message.model,
|
|
72
81
|
sessionId: assistant.sessionId || '',
|
|
73
82
|
timestamp: assistant.timestamp || new Date().toISOString(),
|
|
@@ -90,33 +99,45 @@ exports.parseUsageEntry = parseUsageEntry;
|
|
|
90
99
|
*/
|
|
91
100
|
async function parseJsonlFile(filePath, projectPath) {
|
|
92
101
|
const entries = [];
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
let fileStream = null;
|
|
103
|
+
let rl = null;
|
|
104
|
+
try {
|
|
105
|
+
fileStream = fs.createReadStream(filePath, { encoding: 'utf8' });
|
|
106
|
+
rl = readline.createInterface({
|
|
107
|
+
input: fileStream,
|
|
108
|
+
crlfDelay: Infinity,
|
|
109
|
+
});
|
|
110
|
+
for await (const line of rl) {
|
|
111
|
+
const entry = parseUsageEntry(line, projectPath);
|
|
112
|
+
if (entry) {
|
|
113
|
+
entries.push(entry);
|
|
114
|
+
}
|
|
105
115
|
}
|
|
106
116
|
}
|
|
117
|
+
catch {
|
|
118
|
+
// File read/stream error - return whatever was parsed so far
|
|
119
|
+
}
|
|
120
|
+
finally {
|
|
121
|
+
rl?.close();
|
|
122
|
+
fileStream?.destroy();
|
|
123
|
+
}
|
|
107
124
|
return entries;
|
|
108
125
|
}
|
|
109
126
|
exports.parseJsonlFile = parseJsonlFile;
|
|
127
|
+
function decodeProjectPath(projectDir) {
|
|
128
|
+
const raw = path.basename(projectDir).replace(/-/g, '/');
|
|
129
|
+
const safeSegments = raw
|
|
130
|
+
.split('/')
|
|
131
|
+
.filter((segment) => segment && segment !== '.' && segment !== '..');
|
|
132
|
+
return `/${safeSegments.join('/')}`;
|
|
133
|
+
}
|
|
110
134
|
/**
|
|
111
135
|
* Parse all JSONL files in a single project directory
|
|
112
136
|
*/
|
|
113
137
|
async function parseProjectDirectory(projectDir) {
|
|
114
138
|
const entries = [];
|
|
115
|
-
if (!fs.existsSync(projectDir)) {
|
|
116
|
-
return entries;
|
|
117
|
-
}
|
|
118
139
|
// Get project path from directory name (e.g., "-home-kai-project" -> "/home/kai/project")
|
|
119
|
-
const projectPath =
|
|
140
|
+
const projectPath = decodeProjectPath(projectDir);
|
|
120
141
|
try {
|
|
121
142
|
const files = await fs.promises.readdir(projectDir);
|
|
122
143
|
const jsonlFiles = files.filter((f) => f.endsWith('.jsonl'));
|
|
@@ -140,8 +161,7 @@ exports.parseProjectDirectory = parseProjectDirectory;
|
|
|
140
161
|
* Get default Claude projects directory
|
|
141
162
|
*/
|
|
142
163
|
function getDefaultProjectsDir() {
|
|
143
|
-
|
|
144
|
-
return path.join(configDir, 'projects');
|
|
164
|
+
return path.join((0, claude_config_path_1.getClaudeConfigDir)(), 'projects');
|
|
145
165
|
}
|
|
146
166
|
exports.getDefaultProjectsDir = getDefaultProjectsDir;
|
|
147
167
|
/**
|
|
@@ -149,9 +169,6 @@ exports.getDefaultProjectsDir = getDefaultProjectsDir;
|
|
|
149
169
|
*/
|
|
150
170
|
function findProjectDirectories(projectsDir) {
|
|
151
171
|
const dir = projectsDir || getDefaultProjectsDir();
|
|
152
|
-
if (!fs.existsSync(dir)) {
|
|
153
|
-
return [];
|
|
154
|
-
}
|
|
155
172
|
try {
|
|
156
173
|
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
157
174
|
return entries
|
|
@@ -171,7 +188,13 @@ exports.findProjectDirectories = findProjectDirectories;
|
|
|
171
188
|
* @returns All parsed usage entries from all projects
|
|
172
189
|
*/
|
|
173
190
|
async function scanProjectsDirectory(options = {}) {
|
|
174
|
-
const
|
|
191
|
+
const requestedConcurrency = options.concurrency;
|
|
192
|
+
const concurrency = typeof requestedConcurrency === 'number' &&
|
|
193
|
+
Number.isInteger(requestedConcurrency) &&
|
|
194
|
+
requestedConcurrency > 0
|
|
195
|
+
? Math.min(requestedConcurrency, MAX_SCAN_CONCURRENCY)
|
|
196
|
+
: DEFAULT_SCAN_CONCURRENCY;
|
|
197
|
+
const { projectsDir } = options;
|
|
175
198
|
const allEntries = [];
|
|
176
199
|
const projectDirs = findProjectDirectories(projectsDir);
|
|
177
200
|
if (projectDirs.length === 0) {
|
|
@@ -189,8 +212,8 @@ async function scanProjectsDirectory(options = {}) {
|
|
|
189
212
|
if (options.minDate) {
|
|
190
213
|
const minTime = options.minDate.getTime();
|
|
191
214
|
return allEntries.filter((entry) => {
|
|
192
|
-
const entryTime =
|
|
193
|
-
return entryTime >= minTime;
|
|
215
|
+
const entryTime = Date.parse(entry.timestamp);
|
|
216
|
+
return Number.isFinite(entryTime) && entryTime >= minTime;
|
|
194
217
|
});
|
|
195
218
|
}
|
|
196
219
|
return allEntries;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonl-parser.js","sourceRoot":"","sources":["../../src/web-server/jsonl-parser.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;;;;;;;;;;;;;;;;;;;;;;;;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,OAAO,CAAC;QAC5D,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC;AArCD,sDAqCC;AAED;;GAEG;AACH,SAAgB,eAAe,CAAC,WAAoB;IAClD,MAAM,WAAW,GAAG,sBAAsB,CAAC,WAAW,CAAC,CAAC;IACxD,IAAI,KAAK,GAAG,CAAC,CAAC;IAEd,KAAK,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;QAC9B,IAAI,CAAC;YACH,MAAM,KAAK,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;YAClC,KAAK,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC;QAC5D,CAAC;QAAC,MAAM,CAAC;YACP,gCAAgC;QAClC,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAdD,0CAcC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persist-routes.d.ts","sourceRoot":"","sources":["../../../src/web-server/routes/persist-routes.ts"],"names":[],"mappings":"AAAA;;GAEG;AAQH,QAAA,MAAM,MAAM,4CAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"persist-routes.d.ts","sourceRoot":"","sources":["../../../src/web-server/routes/persist-routes.ts"],"names":[],"mappings":"AAAA;;GAEG;AAQH,QAAA,MAAM,MAAM,4CAAW,CAAC;AA8QxB,eAAe,MAAM,CAAC"}
|