@kaitranntt/ccs 7.50.0-dev.4 → 7.50.0-dev.5
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/cliproxy/account-safety.d.ts.map +1 -1
- package/dist/cliproxy/account-safety.js +4 -0
- package/dist/cliproxy/account-safety.js.map +1 -1
- package/dist/cliproxy/antigravity-responsibility.d.ts +36 -0
- package/dist/cliproxy/antigravity-responsibility.d.ts.map +1 -0
- package/dist/cliproxy/antigravity-responsibility.js +171 -0
- package/dist/cliproxy/antigravity-responsibility.js.map +1 -0
- package/dist/cliproxy/auth/auth-types.d.ts +2 -0
- package/dist/cliproxy/auth/auth-types.d.ts.map +1 -1
- package/dist/cliproxy/auth/oauth-handler.d.ts.map +1 -1
- package/dist/cliproxy/auth/oauth-handler.js +18 -0
- package/dist/cliproxy/auth/oauth-handler.js.map +1 -1
- package/dist/cliproxy/executor/index.d.ts.map +1 -1
- package/dist/cliproxy/executor/index.js +30 -0
- package/dist/cliproxy/executor/index.js.map +1 -1
- package/dist/commands/help-command.d.ts.map +1 -1
- package/dist/commands/help-command.js +5 -0
- package/dist/commands/help-command.js.map +1 -1
- package/dist/config/unified-config-loader.d.ts +11 -1
- package/dist/config/unified-config-loader.d.ts.map +1 -1
- package/dist/config/unified-config-loader.js +127 -59
- package/dist/config/unified-config-loader.js.map +1 -1
- package/dist/config/unified-config-types.d.ts +14 -0
- package/dist/config/unified-config-types.d.ts.map +1 -1
- package/dist/config/unified-config-types.js +8 -1
- package/dist/config/unified-config-types.js.map +1 -1
- package/dist/ui/assets/{accounts-B3RlymZc.js → accounts-Cv9gdSl_.js} +1 -1
- package/dist/ui/assets/{alert-dialog-CuEMPUz1.js → alert-dialog-Cbz7hjbH.js} +1 -1
- package/dist/ui/assets/{api-B2ICvWzi.js → api-CtPIBYPJ.js} +1 -1
- package/dist/ui/assets/auth-section-DDB-gXA-.js +1 -0
- package/dist/ui/assets/{backups-section-D-sat7Ti.js → backups-section-f3TrZYc_.js} +1 -1
- package/dist/ui/assets/{checkbox-C-12mTDT.js → checkbox-DyM_OviW.js} +1 -1
- package/dist/ui/assets/{cliproxy-control-panel-3uthxEI-.js → cliproxy-control-panel-D-0qYG1v.js} +1 -1
- package/dist/ui/assets/cliproxy-nwnHc6Ex.js +3 -0
- package/dist/ui/assets/{confirm-dialog-BfiBvMqW.js → confirm-dialog-B1DNTIER.js} +1 -1
- package/dist/ui/assets/{copilot-Dz0B1ZUz.js → copilot-CsbHY1RT.js} +1 -1
- package/dist/ui/assets/{cursor-DdPXjHsr.js → cursor-Dae1NLqC.js} +1 -1
- package/dist/ui/assets/{droid-DE-zbt4u.js → droid-BQLHOVuB.js} +1 -1
- package/dist/ui/assets/{globalenv-section-BKbOddIv.js → globalenv-section-DryB5ety.js} +1 -1
- package/dist/ui/assets/{health-Bu6uaf__.js → health-DXE1K5e_.js} +1 -1
- package/dist/ui/assets/{icons-ErRLeJ3U.js → icons-D7XDTBCN.js} +1 -1
- package/dist/ui/assets/index-BDygjMjY.js +1 -0
- package/dist/ui/assets/{index-Dzby9K4O.js → index-BGM7ArZ-.js} +1 -1
- package/dist/ui/assets/{index-zgEA-GkK.js → index-BOyrh__4.js} +4 -4
- package/dist/ui/assets/index-C5CDmWs5.css +1 -0
- package/dist/ui/assets/{index-D1DFI7Lj.js → index-Dt0OpGYK.js} +1 -1
- package/dist/ui/assets/{index-Cl-418Sf.js → index-n1iv9ylt.js} +1 -1
- package/dist/ui/assets/proxy-status-widget-Bvi7eWkI.js +1 -0
- package/dist/ui/assets/{separator-sNDYgSUT.js → separator-DrB7U5vm.js} +1 -1
- package/dist/ui/assets/{shared-qWuCxx8B.js → shared-ByrShSly.js} +1 -1
- package/dist/ui/assets/{switch-BdRPtxoo.js → switch-JJlvFHut.js} +1 -1
- package/dist/ui/assets/{updates-BIpeiM6l.js → updates-BUBIr73T.js} +1 -1
- package/dist/ui/index.html +3 -3
- package/dist/web-server/routes/cliproxy-auth-routes.d.ts.map +1 -1
- package/dist/web-server/routes/cliproxy-auth-routes.js +58 -24
- package/dist/web-server/routes/cliproxy-auth-routes.js.map +1 -1
- package/dist/web-server/routes/settings-routes.d.ts.map +1 -1
- package/dist/web-server/routes/settings-routes.js +110 -12
- package/dist/web-server/routes/settings-routes.js.map +1 -1
- package/package.json +1 -1
- package/dist/ui/assets/auth-section-47vsG_g9.js +0 -1
- package/dist/ui/assets/cliproxy-CAR-zTil.js +0 -3
- package/dist/ui/assets/index-CjJDhkhP.css +0 -1
- package/dist/ui/assets/index-DNyQOJ27.js +0 -1
- package/dist/ui/assets/proxy-status-widget-BtL-jVdm.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-DIWAxjEp.js";import{r as d}from"./react-vendor-CNOkPC89.js";import{b9 as ye,ba as je,W as L,I as T,q as ve,r as Ne,s as ke,t as Ce,v as Y,b as Z,bb as Pe,bc as Se,bd as we,b2 as O,b4 as U,m as Ie}from"./index-zgEA-GkK.js";import{S as _}from"./switch-BdRPtxoo.js";import{C as M}from"./default-ports-1QQSffYX.js";import{aJ as ee,R as V,f as Ee,r as te,W as Te,a2 as Le,aK as Ae,aL as _e,T as J,aM as Me}from"./icons-ErRLeJ3U.js";import{P as Re}from"./proxy-status-widget-BtL-jVdm.js";import{t as X}from"./notifications-B2HqRBj7.js";import"./tanstack-Hn82hibe.js";import"./utils-CzKF5WmX.js";import"./form-utils-Cn_Uld6y.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-CuEMPUz1.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 De({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:`${M}`,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:M;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(Y,{value:"http",children:"HTTP"}),e.jsx(Y,{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(Z,{onClick:p,disabled:n||!h,variant:"outline",className:"w-full",children:n?e.jsxs(e.Fragment,{children:[e.jsx(V,{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 Q="ccs_debug_mode",Fe=["kiro","ghcp"];function Ze(){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(Q)==="true"}catch{return!1}}),re=r=>{se(r);try{localStorage.setItem(Q,String(r))}catch{}},[y,R]=d.useState("plus"),[ae,oe]=d.useState(!1),B=Se(),{data:ne}=we(),G=ne?.running??!1,D=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(),D(),K()},[p,o,D,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(V,{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??M).toString(),F=u??le,$=N??ce,H=k??de,q=P??ie,z=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){X.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??q;r!==t.remote.management_key&&a({remote:{...j,management_key:r||void 0}}),S(null)},ge=()=>{const r=(l??z).trim(),c=r===""?M:Number(r);if(!Number.isInteger(c)||c<1||c>65535){X.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(U,{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(J,{className:"h-4 w-4 text-amber-600"}),e.jsx(U,{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(J,{className:"h-4 w-4"}),e.jsx(U,{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:q,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(Me,{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(De,{config:t,saving:n,displayLocalPort:z,setEditedLocalPort:i,onSaveLocalPort:ge,onSaveConfig:a})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(Z,{variant:"outline",size:"sm",onClick:()=>{p(),o(),D(),K()},disabled:s||n,className:"w-full",children:[e.jsx(V,{className:`w-4 h-4 mr-2 ${s?"animate-spin":""}`}),"Refresh"]})})]})}export{Ze as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-DIWAxjEp.js";import{r as y}from"./react-vendor-CNOkPC89.js";import{bd as Y,aL as J,be as Z,bf as _,bg as ee,bh as se,bi as te,c as d,B as q,aw as ae,K as ne,N as re,q as oe,r as ie,s as le,t as ce,v as de,b as T,T as xe,o as me,p as ue,W as he}from"./index-zgEA-GkK.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 we}from"./alert-dialog-CuEMPUz1.js";import{u as R,a as ve,b as Ce,e as Se}from"./tanstack-Hn82hibe.js";import{t as V}from"./notifications-B2HqRBj7.js";import{a3 as ke,A as Pe,R as f,aN as Ve,aO as Ae,aP as Te,X as De,b as Ie,aQ as Ue,aR as $e,U as qe,q as Ee,k as Re,a2 as Le,ap as Me,T as E,aw as Fe}from"./icons-ErRLeJ3U.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 R({queryKey:["cliproxy-sync-status"],queryFn:Ke,refetchInterval:3e4,retry:1,staleTime:1e4})}function Oe(){const s=ve();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 ze(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}=Y(),{data:t}=J(),{data:a,isLoading:r}=Z(),i=_(),l=ee(),w=se(),u=te(),{data:L}=Qe(),{mutate:M,isPending:v}=Oe(),[h,D]=y.useState(!1),[g,F]=y.useState(""),[K,b]=y.useState(!1),[C,S]=y.useState(null),{data:B}=R({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||w.isPending||u.isPending||Q||v,O=t?.hasUpdate??!1,m=t?.isStable===!1,U=t?.currentVersion,j=L?.configured??!1,z=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)},W=()=>{b(!1),S(null)},G=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(q,{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:G})}),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:v?f:Ve,tooltip:"Sync profiles to CLIProxy",onClick:()=>M(),disabled:!j||k,isPending:v}),e.jsx(N,{icon:Ae,tooltip:"Restart",onClick:()=>w.mutate(),disabled:k,isPending:w.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]}),(O||m)&&P&&e.jsxs(q,{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(qe,{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(Ee,{className:"w-3 h-3"}),ze(s.startedAt)]})]}),e.jsxs("div",{className:"mt-2 flex items-center gap-1.5 text-xs",children:[j?e.jsx(Re,{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:z})]}),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(E,{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(E,{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:W,children:"Cancel"}),e.jsx(we,{onClick:H,className:"bg-amber-500 hover:bg-amber-600 text-white",children:"Install Anyway"})]})]})})]})})}export{es as P};
|