@kaitranntt/ccs 7.37.1-dev.4 → 7.37.1-dev.6
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/config/extended-context-config.d.ts +39 -0
- package/dist/cliproxy/config/extended-context-config.d.ts.map +1 -0
- package/dist/cliproxy/config/extended-context-config.js +114 -0
- package/dist/cliproxy/config/extended-context-config.js.map +1 -0
- package/dist/cliproxy/config/generator.d.ts +3 -2
- package/dist/cliproxy/config/generator.d.ts.map +1 -1
- package/dist/cliproxy/config/generator.js +87 -5
- package/dist/cliproxy/config/generator.js.map +1 -1
- package/dist/cliproxy/config/index.d.ts +1 -0
- package/dist/cliproxy/config/index.d.ts.map +1 -1
- package/dist/cliproxy/config/index.js +1 -0
- package/dist/cliproxy/config/index.js.map +1 -1
- package/dist/cliproxy/executor/env-resolver.d.ts +2 -0
- package/dist/cliproxy/executor/env-resolver.d.ts.map +1 -1
- package/dist/cliproxy/executor/env-resolver.js +5 -1
- package/dist/cliproxy/executor/env-resolver.js.map +1 -1
- package/dist/cliproxy/executor/index.d.ts.map +1 -1
- package/dist/cliproxy/executor/index.js +22 -0
- package/dist/cliproxy/executor/index.js.map +1 -1
- package/dist/cliproxy/model-catalog.d.ts +12 -0
- package/dist/cliproxy/model-catalog.d.ts.map +1 -1
- package/dist/cliproxy/model-catalog.js +53 -3
- package/dist/cliproxy/model-catalog.js.map +1 -1
- package/dist/cliproxy/platform-detector.d.ts +4 -4
- package/dist/cliproxy/platform-detector.d.ts.map +1 -1
- package/dist/cliproxy/platform-detector.js +2 -2
- package/dist/cliproxy/platform-detector.js.map +1 -1
- package/dist/commands/help-command.d.ts.map +1 -1
- package/dist/commands/help-command.js +13 -0
- package/dist/commands/help-command.js.map +1 -1
- package/dist/ui/assets/{accounts-KKnpJgSm.js → accounts-ResKjvou.js} +1 -1
- package/dist/ui/assets/{alert-dialog--o3IMwNA.js → alert-dialog-BnSvEwhd.js} +1 -1
- package/dist/ui/assets/{api-DPXZuNLG.js → api-ClPWraVr.js} +1 -1
- package/dist/ui/assets/{auth-section-BvKiQ90u.js → auth-section-CZmgtezT.js} +1 -1
- package/dist/ui/assets/{backups-section-Oa5tPHhr.js → backups-section-CcQsXemH.js} +1 -1
- package/dist/ui/assets/cliproxy-C0JgtLfO.js +3 -0
- package/dist/ui/assets/{cliproxy-control-panel-dMdmQan0.js → cliproxy-control-panel-CBO7xTqe.js} +1 -1
- package/dist/ui/assets/{confirm-dialog-B3_kcO03.js → confirm-dialog-Cjs1FPCy.js} +1 -1
- package/dist/ui/assets/{copilot-CH4pWqh9.js → copilot-DCA0pQV3.js} +2 -2
- package/dist/ui/assets/{globalenv-section-p1HSDmYd.js → globalenv-section-D_GVHsDN.js} +1 -1
- package/dist/ui/assets/{health-Derb0pin.js → health-riN3OSz-.js} +1 -1
- package/dist/ui/assets/{index-kxaA8CDk.js → index-7gcYb5Oq.js} +2 -2
- package/dist/ui/assets/{index-gPRSR-UL.js → index-BXTtPkoG.js} +1 -1
- package/dist/ui/assets/{index-BjufZKGh.js → index-BjiZGSfI.js} +1 -1
- package/dist/ui/assets/{index-DaNar9ag.js → index-CK0URaBN.js} +1 -1
- package/dist/ui/assets/{index-iV1oqdC4.js → index-sdtPg8Gr.js} +1 -1
- package/dist/ui/assets/{proxy-status-widget-Dw9CXnhM.js → proxy-status-widget-B-LQxeOH.js} +1 -1
- package/dist/ui/assets/{shared-DZbSLiNl.js → shared-PuUIRrgy.js} +1 -1
- package/dist/ui/assets/{switch-DjrWWwTm.js → switch-CCYYFslZ.js} +1 -1
- package/dist/ui/index.html +1 -1
- package/package.json +1 -1
- package/dist/ui/assets/cliproxy-Bcil6EPw.js +0 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-qEZD5MMp.js";import{r as c}from"./react-vendor-CNOkPC89.js";import{aQ as fe,aR as ye,ae as A,I as T,X as be,Y as je,Z as ve,_ as Ne,$ as Y,b as Z,aS as ke,aT as Ce,aU as Pe,aN as U,aP as V,m as Se}from"./index-kxaA8CDk.js";import{S as B}from"./switch-DjrWWwTm.js";import{aB as J,R as O,e as we,q as ee,W as Ie,a1 as Ee,aC as Te,aD as Ae,T as Q,aE as Le}from"./icons-D5eAI-GR.js";import{P as _e}from"./proxy-status-widget-Dw9CXnhM.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";import"./alert-dialog--o3IMwNA.js";function Be(){const{state:t}=fe(),s=ye(),[n,d]=c.useState(null),[h,f]=c.useState(null),[p,x]=c.useState(null),[b,j]=c.useState(null),[v,N]=c.useState(null),k=c.useCallback(async()=>{try{s.setProxyLoading(!0),s.setProxyError(null);const l=await A.cliproxyServer.get();s.setProxyConfig(l)}catch(l){s.setProxyError(l.message)}finally{s.setProxyLoading(!1)}},[s]),C=c.useCallback(async l=>{const i=t.proxyConfig;if(!i)return;const u={remote:{...i.remote,...l.remote},fallback:{...i.fallback,...l.fallback},local:{...i.local,...l.local}};s.setProxyConfig(u),s.setProxyTestResult(null);try{s.setProxySaving(!0),s.setProxyError(null);const r=await A.cliproxyServer.update(l);s.setProxyConfig(r),s.setProxySuccess(!0),setTimeout(()=>s.setProxySuccess(!1),1500)}catch(r){s.setProxyConfig(i),s.setProxyError(r.message)}finally{s.setProxySaving(!1)}},[t.proxyConfig,s]),P=c.useCallback(async l=>{const{host:i,port:u,protocol:r,authToken:S}=l;if(!i){s.setProxyError("Host is required");return}try{s.setProxyTesting(!0),s.setProxyError(null),s.setProxyTestResult(null);const o=u?parseInt(u,10):void 0,w=await A.cliproxyServer.test({host:i,port:o||void 0,protocol:r,authToken:S||void 0});s.setProxyTestResult(w)}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:d,editedPort:h,setEditedPort:f,editedAuthToken:p,setEditedAuthToken:x,editedManagementKey:b,setEditedManagementKey:j,editedLocalPort:v,setEditedLocalPort:N,fetchConfig:k,saveConfig:C,testConnection:P}}function Re({config:t,saving:s,displayLocalPort:n,setEditedLocalPort:d,onSaveLocalPort:h,onSaveConfig:f}){const p=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:"number",value:n,onChange:x=>d(x.target.value),onBlur:h,placeholder:"8317",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(B,{checked:p.auto_start??!0,onCheckedChange:x=>f({local:{...p,auto_start:x}}),disabled:s})]})]})]})}function De({config:t,saving:s,testing:n,testResult:d,displayHost:h,displayPort:f,displayAuthToken:p,displayManagementKey:x,setEditedHost:b,setEditedPort:j,setEditedAuthToken:v,setEditedManagementKey:N,onSaveHost:k,onSavePort:C,onSaveAuthToken:P,onSaveManagementKey:l,onSaveConfig:i,onTestConnection:u}){const r=t.remote,S=o=>o==="https"?443:8317;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(J,{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=>b(o.target.value),onBlur:k,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: ",S(t.remote.protocol||"http"),")"]})]}),e.jsx(T,{type:"text",inputMode:"numeric",value:f,onChange:o=>j(o.target.value.replace(/\D/g,"")),onBlur:C,placeholder:`Leave empty for ${S(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(be,{value:t.remote.protocol||"http",onValueChange:o=>i({remote:{...r,protocol:o}}),disabled:s,children:[e.jsx(je,{children:e.jsx(ve,{})}),e.jsxs(Ne,{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:p,onChange:o=>v(o.target.value),onBlur:P,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:x,onChange:o=>N(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:u,disabled:n||!h,variant:"outline",className:"w-full",children:n?e.jsxs(e.Fragment,{children:[e.jsx(O,{className:"w-4 h-4 mr-2 animate-spin"}),"Testing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(we,{className:"w-4 h-4 mr-2"}),"Test Connection"]})}),d&&e.jsx("div",{className:`p-3 rounded-md ${d.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:d.reachable?e.jsxs(e.Fragment,{children:[e.jsx(ee,{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 (",d.latencyMs,"ms)"]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ie,{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:d.error||"Connection failed"})]})})})]})]})}const X="ccs_debug_mode",Me=["kiro","ghcp"];function Qe(){const{config:t,loading:s,saving:n,error:d,success:h,testResult:f,testing:p,editedHost:x,setEditedHost:b,editedPort:j,setEditedPort:v,editedAuthToken:N,setEditedAuthToken:k,editedManagementKey:C,setEditedManagementKey:P,editedLocalPort:l,setEditedLocalPort:i,fetchConfig:u,saveConfig:r,testConnection:S}=Be(),{fetchRawConfig:o}=ke(),[w,te]=c.useState(()=>{try{return localStorage.getItem(X)==="true"}catch{return!1}}),se=a=>{te(a);try{localStorage.setItem(X,String(a))}catch{}},[y,R]=c.useState("plus"),[ae,re]=c.useState(!1),D=Ce(),{data:oe}=Pe(),G=oe?.running??!1,M=c.useCallback(async()=>{try{const a=await A.cliproxyServer.getBackend();R(a.backend)}catch(a){console.error("[Proxy] Failed to fetch backend:",a)}},[]),K=c.useCallback(async()=>{try{const g=(await A.cliproxy.list()).variants.some(_=>Me.includes(_.provider));re(g)}catch(a){console.error("[Proxy] Failed to check variants:",a)}},[]),W=a=>{const g=y;R(a),D.mutate({backend:a},{onError:()=>{R(g)}})};if(c.useEffect(()=>{if(w&&t){const a={...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:",a)}},[w,t]),c.useEffect(()=>{u(),o(),M(),K()},[u,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(O,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:"Loading..."})]})});const m=t.remote.enabled??!1,L=!m&&G,I=t.remote,E=t.fallback,ne=t.remote.host??"",le=t.remote.port!==void 0?t.remote.port.toString():"",ce=t.remote.auth_token??"",de=t.remote.management_key??"",ie=(t.local.port??8317).toString(),$=x??ne,F=j??le,H=N??ce,q=C??de,z=l??ie,me=()=>{const a=x??$;a!==t.remote.host&&r({remote:{...I,host:a}}),b(null)},xe=()=>{const a=j??F,g=a===""?void 0:parseInt(a,10),_=g&&!isNaN(g)&&g>0?g:void 0;_!==t.remote.port&&r({remote:{...I,port:_}}),v(null)},ue=()=>{const a=N??H;a!==t.remote.auth_token&&r({remote:{...I,auth_token:a}}),k(null)},he=()=>{const a=C??q;a!==t.remote.management_key&&r({remote:{...I,management_key:a||void 0}}),P(null)},pe=()=>{const a=parseInt(l??z,10);!isNaN(a)&&a!==t.local.port&&r({local:{...t.local,port:a}}),i(null)},ge=()=>{S({host:$,port:F,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 ${d||h?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[d&&e.jsxs(U,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(Ee,{className:"h-4 w-4"}),e.jsx(V,{children:d})]}),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(ee,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:"Saved"})]})]}),e.jsx(Se,{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"]}),!m&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Instance Status"}),e.jsx(_e,{})]}),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:()=>r({remote:{...I,enabled:!1}}),disabled:n,className:`p-4 rounded-lg border-2 text-left transition-all ${m?"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(Te,{className:`w-5 h-5 ${m?"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:()=>r({remote:{...I,enabled:!0}}),disabled:n,className:`p-4 rounded-lg border-2 text-left transition-all ${m?"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(J,{className:`w-5 h-5 ${m?"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(Ae,{className:"w-4 h-4"}),"Backend Binary"]}),!m&&G&&e.jsxs(U,{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(Q,{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:D.isPending||L,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"} ${L?"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:D.isPending||L,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"} ${L?"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(U,{variant:"destructive",className:"py-2",children:[e.jsx(Q,{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."})]})]}),m&&e.jsx(De,{config:t,saving:n,testing:p,testResult:f,displayHost:$,displayPort:F,displayAuthToken:H,displayManagementKey:q,setEditedHost:b,setEditedPort:v,setEditedAuthToken:k,setEditedManagementKey:P,onSaveHost:me,onSavePort:xe,onSaveAuthToken:ue,onSaveManagementKey:he,onSaveConfig:r,onTestConnection:ge}),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(B,{checked:E.enabled??!0,onCheckedChange:a=>r({fallback:{...E,enabled:a}}),disabled:n||!m})]}),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(B,{checked:E.auto_start??!1,onCheckedChange:a=>r({fallback:{...E,auto_start:a}}),disabled:n||!m||!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(Le,{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(B,{checked:w,onCheckedChange:se,disabled:n})]}),w&&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."})]})]}),!m&&e.jsx(Re,{config:t,saving:n,displayLocalPort:z,setEditedLocalPort:i,onSaveLocalPort:pe,onSaveConfig:r})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(Z,{variant:"outline",size:"sm",onClick:()=>{u(),o(),M(),K()},disabled:s||n,className:"w-full",children:[e.jsx(O,{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 c}from"./react-vendor-CNOkPC89.js";import{aQ as fe,aR as ye,ae as A,I as T,X as be,Y as je,Z as ve,_ as Ne,$ as Y,b as Z,aS as ke,aT as Ce,aU as Pe,aN as U,aP as V,m as Se}from"./index-7gcYb5Oq.js";import{S as B}from"./switch-CCYYFslZ.js";import{aB as J,R as O,e as we,q as ee,W as Ie,a1 as Ee,aC as Te,aD as Ae,T as Q,aE as Le}from"./icons-D5eAI-GR.js";import{P as _e}from"./proxy-status-widget-B-LQxeOH.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";import"./alert-dialog-BnSvEwhd.js";function Be(){const{state:t}=fe(),s=ye(),[n,d]=c.useState(null),[h,f]=c.useState(null),[p,x]=c.useState(null),[b,j]=c.useState(null),[v,N]=c.useState(null),k=c.useCallback(async()=>{try{s.setProxyLoading(!0),s.setProxyError(null);const l=await A.cliproxyServer.get();s.setProxyConfig(l)}catch(l){s.setProxyError(l.message)}finally{s.setProxyLoading(!1)}},[s]),C=c.useCallback(async l=>{const i=t.proxyConfig;if(!i)return;const u={remote:{...i.remote,...l.remote},fallback:{...i.fallback,...l.fallback},local:{...i.local,...l.local}};s.setProxyConfig(u),s.setProxyTestResult(null);try{s.setProxySaving(!0),s.setProxyError(null);const r=await A.cliproxyServer.update(l);s.setProxyConfig(r),s.setProxySuccess(!0),setTimeout(()=>s.setProxySuccess(!1),1500)}catch(r){s.setProxyConfig(i),s.setProxyError(r.message)}finally{s.setProxySaving(!1)}},[t.proxyConfig,s]),P=c.useCallback(async l=>{const{host:i,port:u,protocol:r,authToken:S}=l;if(!i){s.setProxyError("Host is required");return}try{s.setProxyTesting(!0),s.setProxyError(null),s.setProxyTestResult(null);const o=u?parseInt(u,10):void 0,w=await A.cliproxyServer.test({host:i,port:o||void 0,protocol:r,authToken:S||void 0});s.setProxyTestResult(w)}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:d,editedPort:h,setEditedPort:f,editedAuthToken:p,setEditedAuthToken:x,editedManagementKey:b,setEditedManagementKey:j,editedLocalPort:v,setEditedLocalPort:N,fetchConfig:k,saveConfig:C,testConnection:P}}function Re({config:t,saving:s,displayLocalPort:n,setEditedLocalPort:d,onSaveLocalPort:h,onSaveConfig:f}){const p=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:"number",value:n,onChange:x=>d(x.target.value),onBlur:h,placeholder:"8317",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(B,{checked:p.auto_start??!0,onCheckedChange:x=>f({local:{...p,auto_start:x}}),disabled:s})]})]})]})}function De({config:t,saving:s,testing:n,testResult:d,displayHost:h,displayPort:f,displayAuthToken:p,displayManagementKey:x,setEditedHost:b,setEditedPort:j,setEditedAuthToken:v,setEditedManagementKey:N,onSaveHost:k,onSavePort:C,onSaveAuthToken:P,onSaveManagementKey:l,onSaveConfig:i,onTestConnection:u}){const r=t.remote,S=o=>o==="https"?443:8317;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(J,{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=>b(o.target.value),onBlur:k,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: ",S(t.remote.protocol||"http"),")"]})]}),e.jsx(T,{type:"text",inputMode:"numeric",value:f,onChange:o=>j(o.target.value.replace(/\D/g,"")),onBlur:C,placeholder:`Leave empty for ${S(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(be,{value:t.remote.protocol||"http",onValueChange:o=>i({remote:{...r,protocol:o}}),disabled:s,children:[e.jsx(je,{children:e.jsx(ve,{})}),e.jsxs(Ne,{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:p,onChange:o=>v(o.target.value),onBlur:P,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:x,onChange:o=>N(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:u,disabled:n||!h,variant:"outline",className:"w-full",children:n?e.jsxs(e.Fragment,{children:[e.jsx(O,{className:"w-4 h-4 mr-2 animate-spin"}),"Testing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(we,{className:"w-4 h-4 mr-2"}),"Test Connection"]})}),d&&e.jsx("div",{className:`p-3 rounded-md ${d.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:d.reachable?e.jsxs(e.Fragment,{children:[e.jsx(ee,{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 (",d.latencyMs,"ms)"]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ie,{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:d.error||"Connection failed"})]})})})]})]})}const X="ccs_debug_mode",Me=["kiro","ghcp"];function Qe(){const{config:t,loading:s,saving:n,error:d,success:h,testResult:f,testing:p,editedHost:x,setEditedHost:b,editedPort:j,setEditedPort:v,editedAuthToken:N,setEditedAuthToken:k,editedManagementKey:C,setEditedManagementKey:P,editedLocalPort:l,setEditedLocalPort:i,fetchConfig:u,saveConfig:r,testConnection:S}=Be(),{fetchRawConfig:o}=ke(),[w,te]=c.useState(()=>{try{return localStorage.getItem(X)==="true"}catch{return!1}}),se=a=>{te(a);try{localStorage.setItem(X,String(a))}catch{}},[y,R]=c.useState("plus"),[ae,re]=c.useState(!1),D=Ce(),{data:oe}=Pe(),G=oe?.running??!1,M=c.useCallback(async()=>{try{const a=await A.cliproxyServer.getBackend();R(a.backend)}catch(a){console.error("[Proxy] Failed to fetch backend:",a)}},[]),K=c.useCallback(async()=>{try{const g=(await A.cliproxy.list()).variants.some(_=>Me.includes(_.provider));re(g)}catch(a){console.error("[Proxy] Failed to check variants:",a)}},[]),W=a=>{const g=y;R(a),D.mutate({backend:a},{onError:()=>{R(g)}})};if(c.useEffect(()=>{if(w&&t){const a={...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:",a)}},[w,t]),c.useEffect(()=>{u(),o(),M(),K()},[u,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(O,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:"Loading..."})]})});const m=t.remote.enabled??!1,L=!m&&G,I=t.remote,E=t.fallback,ne=t.remote.host??"",le=t.remote.port!==void 0?t.remote.port.toString():"",ce=t.remote.auth_token??"",de=t.remote.management_key??"",ie=(t.local.port??8317).toString(),$=x??ne,F=j??le,H=N??ce,q=C??de,z=l??ie,me=()=>{const a=x??$;a!==t.remote.host&&r({remote:{...I,host:a}}),b(null)},xe=()=>{const a=j??F,g=a===""?void 0:parseInt(a,10),_=g&&!isNaN(g)&&g>0?g:void 0;_!==t.remote.port&&r({remote:{...I,port:_}}),v(null)},ue=()=>{const a=N??H;a!==t.remote.auth_token&&r({remote:{...I,auth_token:a}}),k(null)},he=()=>{const a=C??q;a!==t.remote.management_key&&r({remote:{...I,management_key:a||void 0}}),P(null)},pe=()=>{const a=parseInt(l??z,10);!isNaN(a)&&a!==t.local.port&&r({local:{...t.local,port:a}}),i(null)},ge=()=>{S({host:$,port:F,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 ${d||h?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[d&&e.jsxs(U,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(Ee,{className:"h-4 w-4"}),e.jsx(V,{children:d})]}),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(ee,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:"Saved"})]})]}),e.jsx(Se,{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"]}),!m&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Instance Status"}),e.jsx(_e,{})]}),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:()=>r({remote:{...I,enabled:!1}}),disabled:n,className:`p-4 rounded-lg border-2 text-left transition-all ${m?"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(Te,{className:`w-5 h-5 ${m?"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:()=>r({remote:{...I,enabled:!0}}),disabled:n,className:`p-4 rounded-lg border-2 text-left transition-all ${m?"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(J,{className:`w-5 h-5 ${m?"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(Ae,{className:"w-4 h-4"}),"Backend Binary"]}),!m&&G&&e.jsxs(U,{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(Q,{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:D.isPending||L,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"} ${L?"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:D.isPending||L,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"} ${L?"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(U,{variant:"destructive",className:"py-2",children:[e.jsx(Q,{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."})]})]}),m&&e.jsx(De,{config:t,saving:n,testing:p,testResult:f,displayHost:$,displayPort:F,displayAuthToken:H,displayManagementKey:q,setEditedHost:b,setEditedPort:v,setEditedAuthToken:k,setEditedManagementKey:P,onSaveHost:me,onSavePort:xe,onSaveAuthToken:ue,onSaveManagementKey:he,onSaveConfig:r,onTestConnection:ge}),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(B,{checked:E.enabled??!0,onCheckedChange:a=>r({fallback:{...E,enabled:a}}),disabled:n||!m})]}),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(B,{checked:E.auto_start??!1,onCheckedChange:a=>r({fallback:{...E,auto_start:a}}),disabled:n||!m||!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(Le,{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(B,{checked:w,onCheckedChange:se,disabled:n})]}),w&&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."})]})]}),!m&&e.jsx(Re,{config:t,saving:n,displayLocalPort:z,setEditedLocalPort:i,onSaveLocalPort:pe,onSaveConfig:r})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(Z,{variant:"outline",size:"sm",onClick:()=>{u(),o(),M(),K()},disabled:s||n,className:"w-full",children:[e.jsx(O,{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 i}from"./react-vendor-CNOkPC89.js";import{aQ as T,aR as $,I as F,aS as U,aN as _,aP as z,m as B,b as O}from"./index-kxaA8CDk.js";import{S as K}from"./switch-DjrWWwTm.js";import{y as q,j as Y,V as D,Y as V,m as J,R as y,a1 as Q,q as X,aA as Z}from"./icons-D5eAI-GR.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 ee(){const{state:s}=T(),a=$(),[d,l]=i.useState(""),[o,m]=i.useState(""),[f,h]=i.useState(!1),[j,u]=i.useState(!1),S=i.useCallback(async()=>{try{a.setWebSearchLoading(!0),a.setWebSearchError(null);const t=await fetch("/api/websearch");if(!t.ok)throw new Error("Failed to load WebSearch config");const r=await t.json();a.setWebSearchConfig(r)}catch(t){a.setWebSearchError(t.message)}finally{a.setWebSearchLoading(!1)}},[a]),v=i.useCallback(async()=>{try{a.setWebSearchStatusLoading(!0);const t=await fetch("/api/websearch/status");if(!t.ok)throw new Error("Failed to load status");const r=await t.json();a.setWebSearchStatus(r)}catch{}finally{a.setWebSearchStatusLoading(!1)}},[a]),g=i.useCallback(async t=>{const r=s.webSearchConfig;if(!r)return;const w={...r,...t};a.setWebSearchConfig(w);try{a.setWebSearchSaving(!0),a.setWebSearchError(null);const n=await fetch("/api/websearch",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(w)});if(!n.ok){const k=await n.json();throw new Error(k.error||"Failed to save")}const C=await n.json();a.setWebSearchConfig(C.websearch),a.setWebSearchSuccess(!0),setTimeout(()=>a.setWebSearchSuccess(!1),1500)}catch(n){a.setWebSearchConfig(r),a.setWebSearchError(n.message)}finally{a.setWebSearchSaving(!1)}},[s.webSearchConfig,a]);i.useEffect(()=>{s.webSearchConfig&&(l(s.webSearchConfig.providers?.gemini?.model??"gemini-2.5-flash"),m(s.webSearchConfig.providers?.opencode?.model??"opencode/grok-code"))},[s.webSearchConfig]);const x=i.useCallback(async()=>{const t=s.webSearchConfig?.providers?.gemini?.model??"gemini-2.5-flash";if(d!==t){const r=s.webSearchConfig?.providers||{};await g({providers:{...r,gemini:{...r.gemini,model:d}}}),h(!0),setTimeout(()=>h(!1),2e3)}},[d,s.webSearchConfig,g]),p=i.useCallback(async()=>{const t=s.webSearchConfig?.providers?.opencode?.model??"opencode/grok-code";if(o!==t){const r=s.webSearchConfig?.providers||{};await g({providers:{...r,opencode:{...r.opencode,model:o}}}),u(!0),setTimeout(()=>u(!1),2e3)}},[o,s.webSearchConfig,g]);return{config:s.webSearchConfig,status:s.webSearchStatus,loading:s.webSearchLoading,statusLoading:s.webSearchStatusLoading,saving:s.webSearchSaving,error:s.webSearchError,success:s.webSearchSuccess,geminiModelInput:d,setGeminiModelInput:l,opencodeModelInput:o,setOpencodeModelInput:m,geminiModelSaved:f,opencodeModelSaved:j,fetchConfig:S,fetchStatus:v,saveConfig:g,saveGeminiModel:x,saveOpencodeModel:p}}function A({name:s,label:a,badge:d,badgeColor:l,enabled:o,installed:m,statusLoading:f,saving:h,onToggle:j,modelInput:u,setModelInput:S,onModelBlur:v,modelSaved:g,modelPlaceholder:x,showHint:p,setShowHint:t,installCmd:r,docsUrl:w,hintColor:n}){const C=l==="green"?"bg-green-500/10 text-green-600":l==="blue"?"bg-blue-500/10 text-blue-600":"bg-purple-500/10 text-purple-600",k=n==="amber"?"bg-amber-50 dark:bg-amber-900/20 text-amber-700 dark:text-amber-300":n==="blue"?"bg-blue-50 dark:bg-blue-900/20 text-blue-700 dark:text-blue-300":"bg-purple-50 dark:bg-purple-900/20 text-purple-700 dark:text-purple-300",E=n==="amber"?"bg-amber-100 dark:bg-amber-900/40":n==="blue"?"bg-blue-100 dark:bg-blue-900/40":"bg-purple-100 dark:bg-purple-900/40",I=n==="amber"?"text-amber-600 dark:text-amber-400":n==="blue"?"text-blue-600 dark:text-blue-400":"text-purple-600 dark:text-purple-400",M=s==="opencode"?"OpenCode":s.charAt(0).toUpperCase()+s.slice(1);return e.jsxs("div",{className:`rounded-lg border transition-colors ${o?"border-primary border-l-4":"border-border"}`,children:[e.jsxs("div",{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(q,{className:`w-5 h-5 ${o?"text-primary":"text-muted-foreground"}`}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-mono font-medium",children:s}),e.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${C}`,children:d}),m?e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-green-500/10 text-green-600 font-medium",children:"installed"}):e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-amber-500/10 text-amber-600 font-medium",children:"not installed"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a})]})]}),e.jsx(K,{checked:o,onCheckedChange:j,disabled:h||!m})]}),o&&u!==void 0&&S&&v&&e.jsx("div",{className:"px-4 pb-4 pt-0",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-sm text-muted-foreground whitespace-nowrap",children:"Model:"}),e.jsx(F,{value:u,onChange:W=>S(W.target.value),onBlur:v,placeholder:x,className:"h-8 text-sm font-mono",disabled:h}),g&&e.jsxs("span",{className:"flex items-center gap-1 text-green-600 dark:text-green-400 text-xs animate-in fade-in duration-200",children:[e.jsx(Y,{className:"w-3.5 h-3.5"}),"Saved"]})]})}),!m&&!f&&e.jsxs("div",{className:"px-4 pb-4 pt-0 border-t border-border/50",children:[e.jsxs("button",{onClick:()=>t(!p),className:`flex items-center gap-2 text-sm hover:underline w-full py-2 ${I}`,children:[p?e.jsx(D,{className:"w-4 h-4"}):e.jsx(V,{className:"w-4 h-4"}),"How to install ",M," CLI"]}),p&&e.jsxs("div",{className:`mt-2 p-3 rounded-md text-sm ${k}`,children:[e.jsxs("p",{className:"mb-2",children:["Install globally"," ",d==="GROK_API_KEY"?"(requires xAI API key)":"(FREE tier available)",":"]}),e.jsx("code",{className:`text-sm px-2 py-1 rounded font-mono block mb-2 ${E}`,children:r}),e.jsxs("a",{href:w,target:"_blank",rel:"noopener noreferrer",className:"hover:underline inline-flex items-center gap-1",children:[e.jsx(J,{className:"w-3 h-3"}),"View documentation"]})]})]})]})}function me(){const{config:s,status:a,loading:d,statusLoading:l,saving:o,error:m,success:f,geminiModelInput:h,setGeminiModelInput:j,opencodeModelInput:u,setOpencodeModelInput:S,geminiModelSaved:v,opencodeModelSaved:g,fetchConfig:x,fetchStatus:p,saveConfig:t,saveGeminiModel:r,saveOpencodeModel:w}=ee(),{fetchRawConfig:n}=U(),[C,k]=i.useState(!1),[E,I]=i.useState(!1),[M,W]=i.useState(!1);i.useEffect(()=>{x(),p(),n()},[x,p,n]);const N=s?.providers?.gemini?.enabled??!1,G=s?.providers?.grok?.enabled??!1,L=s?.providers?.opencode?.enabled??!1,R=()=>{const c=s?.providers||{},b=c.gemini?.enabled??!1;t({enabled:!b||G||L,providers:{...c,gemini:{...c.gemini,enabled:!b}}})},H=()=>{const c=s?.providers||{},b=c.grok?.enabled??!1;t({enabled:N||!b||L,providers:{...c,grok:{...c.grok,enabled:!b}}})},P=()=>{const c=s?.providers||{},b=c.opencode?.enabled??!1;t({enabled:N||G||!b,providers:{...c,opencode:{...c.opencode,enabled:!b}}})};return d?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(y,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:"Loading..."})]})}):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||f?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[m&&e.jsxs(_,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(Q,{className:"h-4 w-4"}),e.jsx(z,{children:m})]}),f&&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(X,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:"Saved"})]})]}),e.jsx(B,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"CLI-based web search for third-party profiles (gemini, codex, agy, etc.)"}),e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:N?"WebSearch enabled":"WebSearch disabled"}),l?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Checking status..."}):a?.readiness?e.jsx("p",{className:"text-sm text-muted-foreground",children:a.readiness.message}):null]}),e.jsx(O,{variant:"ghost",size:"sm",onClick:p,disabled:l,children:e.jsx(y,{className:`w-4 h-4 ${l?"animate-spin":""}`})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Providers"}),!a?.geminiCli&&!a?.opencodeCli&&!a?.grokCli&&!l&&e.jsxs("div",{className:"flex flex-col items-center justify-center p-8 border-2 border-dashed rounded-lg text-center bg-muted/30",children:[e.jsx(Z,{className:"w-12 h-12 text-muted-foreground mb-3 opacity-30"}),e.jsx("p",{className:"font-medium text-foreground mb-1",children:"No providers configured"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Install CLI tools to enable web search providers"}),e.jsxs(O,{variant:"outline",size:"sm",onClick:p,children:[e.jsx(y,{className:"w-4 h-4 mr-2"}),"Check for providers"]})]}),e.jsx(A,{name:"gemini",label:"Google Gemini CLI (1000 req/day free)",badge:"FREE",badgeColor:"green",enabled:N,installed:a?.geminiCli?.installed??!1,statusLoading:l,saving:o,onToggle:R,modelInput:h,setModelInput:j,onModelBlur:r,modelSaved:v,modelPlaceholder:"gemini-2.5-flash",showHint:C,setShowHint:k,installCmd:"npm install -g @google/gemini-cli",docsUrl:"https://github.com/google-gemini/gemini-cli",hintColor:"amber"}),e.jsx(A,{name:"opencode",label:"OpenCode (web search via Zen)",badge:"FREE",badgeColor:"green",enabled:L,installed:a?.opencodeCli?.installed??!1,statusLoading:l,saving:o,onToggle:P,modelInput:u,setModelInput:S,onModelBlur:w,modelSaved:g,modelPlaceholder:"opencode/grok-code",showHint:E,setShowHint:I,installCmd:"curl -fsSL https://opencode.ai/install | bash",docsUrl:"https://github.com/sst/opencode",hintColor:"purple"}),e.jsx(A,{name:"grok",label:"xAI Grok CLI (web + X search)",badge:"GROK_API_KEY",badgeColor:"blue",enabled:G,installed:a?.grokCli?.installed??!1,statusLoading:l,saving:o,onToggle:H,showHint:M,setShowHint:W,installCmd:"npm install -g @vibe-kit/grok-cli",docsUrl:"https://github.com/superagent-ai/grok-cli",hintColor:"blue"})]})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(O,{variant:"outline",size:"sm",onClick:()=>{x(),n()},disabled:d||o,className:"w-full",children:[e.jsx(y,{className:`w-4 h-4 mr-2 ${d?"animate-spin":""}`}),"Refresh"]})})]})}export{me as default};
|
|
1
|
+
import{j as e}from"./radix-ui-qEZD5MMp.js";import{r as i}from"./react-vendor-CNOkPC89.js";import{aQ as T,aR as $,I as F,aS as U,aN as _,aP as z,m as B,b as O}from"./index-7gcYb5Oq.js";import{S as K}from"./switch-CCYYFslZ.js";import{y as q,j as Y,V as D,Y as V,m as J,R as y,a1 as Q,q as X,aA as Z}from"./icons-D5eAI-GR.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 ee(){const{state:s}=T(),a=$(),[d,l]=i.useState(""),[o,m]=i.useState(""),[f,h]=i.useState(!1),[j,u]=i.useState(!1),S=i.useCallback(async()=>{try{a.setWebSearchLoading(!0),a.setWebSearchError(null);const t=await fetch("/api/websearch");if(!t.ok)throw new Error("Failed to load WebSearch config");const r=await t.json();a.setWebSearchConfig(r)}catch(t){a.setWebSearchError(t.message)}finally{a.setWebSearchLoading(!1)}},[a]),v=i.useCallback(async()=>{try{a.setWebSearchStatusLoading(!0);const t=await fetch("/api/websearch/status");if(!t.ok)throw new Error("Failed to load status");const r=await t.json();a.setWebSearchStatus(r)}catch{}finally{a.setWebSearchStatusLoading(!1)}},[a]),g=i.useCallback(async t=>{const r=s.webSearchConfig;if(!r)return;const w={...r,...t};a.setWebSearchConfig(w);try{a.setWebSearchSaving(!0),a.setWebSearchError(null);const n=await fetch("/api/websearch",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(w)});if(!n.ok){const k=await n.json();throw new Error(k.error||"Failed to save")}const C=await n.json();a.setWebSearchConfig(C.websearch),a.setWebSearchSuccess(!0),setTimeout(()=>a.setWebSearchSuccess(!1),1500)}catch(n){a.setWebSearchConfig(r),a.setWebSearchError(n.message)}finally{a.setWebSearchSaving(!1)}},[s.webSearchConfig,a]);i.useEffect(()=>{s.webSearchConfig&&(l(s.webSearchConfig.providers?.gemini?.model??"gemini-2.5-flash"),m(s.webSearchConfig.providers?.opencode?.model??"opencode/grok-code"))},[s.webSearchConfig]);const x=i.useCallback(async()=>{const t=s.webSearchConfig?.providers?.gemini?.model??"gemini-2.5-flash";if(d!==t){const r=s.webSearchConfig?.providers||{};await g({providers:{...r,gemini:{...r.gemini,model:d}}}),h(!0),setTimeout(()=>h(!1),2e3)}},[d,s.webSearchConfig,g]),p=i.useCallback(async()=>{const t=s.webSearchConfig?.providers?.opencode?.model??"opencode/grok-code";if(o!==t){const r=s.webSearchConfig?.providers||{};await g({providers:{...r,opencode:{...r.opencode,model:o}}}),u(!0),setTimeout(()=>u(!1),2e3)}},[o,s.webSearchConfig,g]);return{config:s.webSearchConfig,status:s.webSearchStatus,loading:s.webSearchLoading,statusLoading:s.webSearchStatusLoading,saving:s.webSearchSaving,error:s.webSearchError,success:s.webSearchSuccess,geminiModelInput:d,setGeminiModelInput:l,opencodeModelInput:o,setOpencodeModelInput:m,geminiModelSaved:f,opencodeModelSaved:j,fetchConfig:S,fetchStatus:v,saveConfig:g,saveGeminiModel:x,saveOpencodeModel:p}}function A({name:s,label:a,badge:d,badgeColor:l,enabled:o,installed:m,statusLoading:f,saving:h,onToggle:j,modelInput:u,setModelInput:S,onModelBlur:v,modelSaved:g,modelPlaceholder:x,showHint:p,setShowHint:t,installCmd:r,docsUrl:w,hintColor:n}){const C=l==="green"?"bg-green-500/10 text-green-600":l==="blue"?"bg-blue-500/10 text-blue-600":"bg-purple-500/10 text-purple-600",k=n==="amber"?"bg-amber-50 dark:bg-amber-900/20 text-amber-700 dark:text-amber-300":n==="blue"?"bg-blue-50 dark:bg-blue-900/20 text-blue-700 dark:text-blue-300":"bg-purple-50 dark:bg-purple-900/20 text-purple-700 dark:text-purple-300",E=n==="amber"?"bg-amber-100 dark:bg-amber-900/40":n==="blue"?"bg-blue-100 dark:bg-blue-900/40":"bg-purple-100 dark:bg-purple-900/40",I=n==="amber"?"text-amber-600 dark:text-amber-400":n==="blue"?"text-blue-600 dark:text-blue-400":"text-purple-600 dark:text-purple-400",M=s==="opencode"?"OpenCode":s.charAt(0).toUpperCase()+s.slice(1);return e.jsxs("div",{className:`rounded-lg border transition-colors ${o?"border-primary border-l-4":"border-border"}`,children:[e.jsxs("div",{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(q,{className:`w-5 h-5 ${o?"text-primary":"text-muted-foreground"}`}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-mono font-medium",children:s}),e.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${C}`,children:d}),m?e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-green-500/10 text-green-600 font-medium",children:"installed"}):e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-amber-500/10 text-amber-600 font-medium",children:"not installed"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a})]})]}),e.jsx(K,{checked:o,onCheckedChange:j,disabled:h||!m})]}),o&&u!==void 0&&S&&v&&e.jsx("div",{className:"px-4 pb-4 pt-0",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-sm text-muted-foreground whitespace-nowrap",children:"Model:"}),e.jsx(F,{value:u,onChange:W=>S(W.target.value),onBlur:v,placeholder:x,className:"h-8 text-sm font-mono",disabled:h}),g&&e.jsxs("span",{className:"flex items-center gap-1 text-green-600 dark:text-green-400 text-xs animate-in fade-in duration-200",children:[e.jsx(Y,{className:"w-3.5 h-3.5"}),"Saved"]})]})}),!m&&!f&&e.jsxs("div",{className:"px-4 pb-4 pt-0 border-t border-border/50",children:[e.jsxs("button",{onClick:()=>t(!p),className:`flex items-center gap-2 text-sm hover:underline w-full py-2 ${I}`,children:[p?e.jsx(D,{className:"w-4 h-4"}):e.jsx(V,{className:"w-4 h-4"}),"How to install ",M," CLI"]}),p&&e.jsxs("div",{className:`mt-2 p-3 rounded-md text-sm ${k}`,children:[e.jsxs("p",{className:"mb-2",children:["Install globally"," ",d==="GROK_API_KEY"?"(requires xAI API key)":"(FREE tier available)",":"]}),e.jsx("code",{className:`text-sm px-2 py-1 rounded font-mono block mb-2 ${E}`,children:r}),e.jsxs("a",{href:w,target:"_blank",rel:"noopener noreferrer",className:"hover:underline inline-flex items-center gap-1",children:[e.jsx(J,{className:"w-3 h-3"}),"View documentation"]})]})]})]})}function me(){const{config:s,status:a,loading:d,statusLoading:l,saving:o,error:m,success:f,geminiModelInput:h,setGeminiModelInput:j,opencodeModelInput:u,setOpencodeModelInput:S,geminiModelSaved:v,opencodeModelSaved:g,fetchConfig:x,fetchStatus:p,saveConfig:t,saveGeminiModel:r,saveOpencodeModel:w}=ee(),{fetchRawConfig:n}=U(),[C,k]=i.useState(!1),[E,I]=i.useState(!1),[M,W]=i.useState(!1);i.useEffect(()=>{x(),p(),n()},[x,p,n]);const N=s?.providers?.gemini?.enabled??!1,G=s?.providers?.grok?.enabled??!1,L=s?.providers?.opencode?.enabled??!1,R=()=>{const c=s?.providers||{},b=c.gemini?.enabled??!1;t({enabled:!b||G||L,providers:{...c,gemini:{...c.gemini,enabled:!b}}})},H=()=>{const c=s?.providers||{},b=c.grok?.enabled??!1;t({enabled:N||!b||L,providers:{...c,grok:{...c.grok,enabled:!b}}})},P=()=>{const c=s?.providers||{},b=c.opencode?.enabled??!1;t({enabled:N||G||!b,providers:{...c,opencode:{...c.opencode,enabled:!b}}})};return d?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(y,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:"Loading..."})]})}):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||f?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[m&&e.jsxs(_,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(Q,{className:"h-4 w-4"}),e.jsx(z,{children:m})]}),f&&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(X,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:"Saved"})]})]}),e.jsx(B,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"CLI-based web search for third-party profiles (gemini, codex, agy, etc.)"}),e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:N?"WebSearch enabled":"WebSearch disabled"}),l?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Checking status..."}):a?.readiness?e.jsx("p",{className:"text-sm text-muted-foreground",children:a.readiness.message}):null]}),e.jsx(O,{variant:"ghost",size:"sm",onClick:p,disabled:l,children:e.jsx(y,{className:`w-4 h-4 ${l?"animate-spin":""}`})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Providers"}),!a?.geminiCli&&!a?.opencodeCli&&!a?.grokCli&&!l&&e.jsxs("div",{className:"flex flex-col items-center justify-center p-8 border-2 border-dashed rounded-lg text-center bg-muted/30",children:[e.jsx(Z,{className:"w-12 h-12 text-muted-foreground mb-3 opacity-30"}),e.jsx("p",{className:"font-medium text-foreground mb-1",children:"No providers configured"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Install CLI tools to enable web search providers"}),e.jsxs(O,{variant:"outline",size:"sm",onClick:p,children:[e.jsx(y,{className:"w-4 h-4 mr-2"}),"Check for providers"]})]}),e.jsx(A,{name:"gemini",label:"Google Gemini CLI (1000 req/day free)",badge:"FREE",badgeColor:"green",enabled:N,installed:a?.geminiCli?.installed??!1,statusLoading:l,saving:o,onToggle:R,modelInput:h,setModelInput:j,onModelBlur:r,modelSaved:v,modelPlaceholder:"gemini-2.5-flash",showHint:C,setShowHint:k,installCmd:"npm install -g @google/gemini-cli",docsUrl:"https://github.com/google-gemini/gemini-cli",hintColor:"amber"}),e.jsx(A,{name:"opencode",label:"OpenCode (web search via Zen)",badge:"FREE",badgeColor:"green",enabled:L,installed:a?.opencodeCli?.installed??!1,statusLoading:l,saving:o,onToggle:P,modelInput:u,setModelInput:S,onModelBlur:w,modelSaved:g,modelPlaceholder:"opencode/grok-code",showHint:E,setShowHint:I,installCmd:"curl -fsSL https://opencode.ai/install | bash",docsUrl:"https://github.com/sst/opencode",hintColor:"purple"}),e.jsx(A,{name:"grok",label:"xAI Grok CLI (web + X search)",badge:"GROK_API_KEY",badgeColor:"blue",enabled:G,installed:a?.grokCli?.installed??!1,statusLoading:l,saving:o,onToggle:H,showHint:M,setShowHint:W,installCmd:"npm install -g @vibe-kit/grok-cli",docsUrl:"https://github.com/superagent-ai/grok-cli",hintColor:"blue"})]})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(O,{variant:"outline",size:"sm",onClick:()=>{x(),n()},disabled:d||o,className:"w-full",children:[e.jsx(y,{className:`w-4 h-4 mr-2 ${d?"animate-spin":""}`}),"Refresh"]})})]})}export{me as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-qEZD5MMp.js";import{r as a}from"./react-vendor-CNOkPC89.js";import{aN as A,aP as R,b as C,m as M,L as D,X as L,Y as $,Z as F,_ as K,$ as z}from"./index-
|
|
1
|
+
import{j as e}from"./radix-ui-qEZD5MMp.js";import{r as a}from"./react-vendor-CNOkPC89.js";import{aN as A,aP as R,b as C,m as M,L as D,X as L,Y as $,Z as F,_ as K,$ as z}from"./index-7gcYb5Oq.js";import{S as H}from"./switch-CCYYFslZ.js";import{R as k,a1 as U,q as O,a3 as q,I as G}from"./icons-D5eAI-GR.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";const p={mode:"auto",tier_defaults:{opus:"high",sonnet:"medium",haiku:"low"},show_warnings:!0},T=1e4;function P(){const[n,i]=a.useState(null),[g,u]=a.useState(!0),[b,c]=a.useState(!1),[j,o]=a.useState(null),[v,s]=a.useState(!1),l=a.useRef(void 0),N=a.useCallback(async()=>{const r=new AbortController,m=setTimeout(()=>r.abort(),T);try{u(!0),o(null);const t=await fetch("/api/thinking",{signal:r.signal});if(clearTimeout(m),!t.ok)throw t.headers.get("content-type")?.includes("text/html")?new Error(`Server error (${t.status})`):new Error("Failed to load Thinking config");const x=await t.json();i(x.config||p),l.current=x.lastModified}catch(t){clearTimeout(m),t.name==="AbortError"?o("Request timeout - please try again"):o(t.message),i(p)}finally{u(!1)}return()=>r.abort()},[]),d=a.useCallback(async r=>{const m=n||p,t={...m,...r};i(t);const x=new AbortController,w=setTimeout(()=>x.abort(),T);try{c(!0),o(null);const f={...t,lastModified:l.current},h=await fetch("/api/thinking",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(f),signal:x.signal});if(clearTimeout(w),!h.ok){if(h.headers.get("content-type")?.includes("text/html"))throw new Error(`Server error (${h.status})`);const I=await h.json();throw h.status===409?new Error("Config changed by another session. Refreshing..."):new Error(I.error||"Failed to save")}const y=await h.json();i(y.config),l.current=y.lastModified,s(!0),setTimeout(()=>s(!1),1500)}catch(f){clearTimeout(w),i(m),f.name==="AbortError"?o("Request timeout - please try again"):(o(f.message),f.message.includes("another session")&&setTimeout(()=>N(),1e3))}finally{c(!1)}},[n,N]),S=a.useCallback(r=>{d({mode:r})},[d]),E=a.useCallback((r,m)=>{const t=n?.tier_defaults||p.tier_defaults;d({tier_defaults:{...t,[r]:m}})},[n,d]),_=a.useCallback(r=>{d({show_warnings:r})},[d]);return{config:n||p,loading:g,saving:b,error:j,success:v,fetchConfig:N,saveConfig:d,setMode:S,setTierDefault:E,setShowWarnings:_}}const V=[{value:"minimal",label:"Minimal (512 tokens)"},{value:"low",label:"Low (1K tokens)"},{value:"medium",label:"Medium (8K tokens)"},{value:"high",label:"High (24K tokens)"},{value:"xhigh",label:"Extra High (32K tokens)"},{value:"auto",label:"Auto (dynamic)"}];function ne(){const{config:n,loading:i,saving:g,error:u,success:b,fetchConfig:c,setMode:j,setTierDefault:o,setShowWarnings:v}=P();return a.useEffect(()=>{c()},[c]),i?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(k,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:"Loading..."})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${u||b?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[u&&e.jsx(A,{variant:"destructive",className:"py-2 shadow-lg",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(U,{className:"h-4 w-4"}),e.jsx(R,{children:u})]}),e.jsxs(C,{variant:"outline",size:"sm",onClick:c,className:"h-7 px-2 text-xs border-destructive/50 hover:bg-destructive/10",children:[e.jsx(k,{className:"w-3 h-3 mr-1"}),"Retry"]})]})}),b&&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(O,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:"Saved"})]})]}),e.jsx(M,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(q,{className:"w-5 h-5 text-primary"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure extended thinking/reasoning for supported models."})]}),e.jsxs("div",{className:"flex items-start gap-2 p-3 rounded-lg bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800",children:[e.jsx(G,{className:"w-4 h-4 text-blue-600 dark:text-blue-400 shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-blue-700 dark:text-blue-300",children:[e.jsx("p",{className:"font-medium",children:"Supported Providers"}),e.jsxs("ul",{className:"mt-1 space-y-0.5 text-blue-600 dark:text-blue-400",children:[e.jsxs("li",{children:["Thinking budget: ",e.jsx("strong",{children:"agy"}),", ",e.jsx("strong",{children:"gemini"})," (token-based)"]}),e.jsxs("li",{children:["Reasoning effort: ",e.jsx("strong",{children:"codex"})," (level-based: medium/high/xhigh)"]})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Thinking Mode"}),e.jsx("div",{className:"space-y-2",children:["auto","off","manual"].map(s=>e.jsxs("div",{className:`flex items-center justify-between p-4 rounded-lg cursor-pointer transition-colors ${n.mode===s?"bg-primary/10 border border-primary/30":"bg-muted/50 hover:bg-muted/80"}`,onClick:()=>j(s),children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium capitalize",children:s}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[s==="auto"&&"Automatically set thinking based on model tier",s==="off"&&"Disable extended thinking",s==="manual"&&"Use --thinking flag to control manually"]})]}),e.jsx("div",{className:`w-4 h-4 rounded-full border-2 ${n.mode===s?"bg-primary border-primary":"border-muted-foreground/50"}`})]},s))})]}),n.mode==="auto"&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Tier Defaults"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Default thinking level for each model tier when in auto mode."}),e.jsx("div",{className:"space-y-3",children:["opus","sonnet","haiku"].map(s=>e.jsxs("div",{className:"flex items-center gap-4 p-3 rounded-lg bg-muted/30",children:[e.jsx(D,{className:"w-20 capitalize font-medium",children:s}),e.jsxs(L,{value:n.tier_defaults[s],onValueChange:l=>o(s,l),disabled:g,children:[e.jsx($,{className:"flex-1",children:e.jsx(F,{})}),e.jsx(K,{children:V.map(l=>e.jsx(z,{value:l.value,children:l.label},l.value))})]})]},s))})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Show Warnings"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Display warnings when thinking values are clamped or adjusted"})]}),e.jsx(H,{checked:n.show_warnings??!0,onCheckedChange:v,disabled:g})]}),e.jsxs("div",{className:"p-4 rounded-lg border bg-muted/30",children:[e.jsx("h4",{className:"text-sm font-medium mb-2",children:"CLI Override"}),e.jsxs("p",{className:"text-sm text-muted-foreground mb-2",children:["Use ",e.jsx("code",{className:"px-1.5 py-0.5 rounded bg-muted",children:"--thinking"})," flag to override settings per session:"]}),e.jsxs("div",{className:"space-y-1 text-sm font-mono text-muted-foreground",children:[e.jsx("p",{children:"ccs gemini --thinking high"}),e.jsx("p",{children:"ccs agy --thinking 16384"}),e.jsx("p",{children:"ccs gemini --thinking off"})]})]})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(C,{variant:"outline",size:"sm",onClick:c,disabled:i||g,className:"w-full",children:[e.jsx(k,{className:`w-4 h-4 mr-2 ${i?"animate-spin":""}`}),"Refresh"]})})]})}export{ne as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-qEZD5MMp.js";import{r as y}from"./react-vendor-CNOkPC89.js";import{aU as W,aA as Z,aV as J,aW as _,aX as ee,aY as se,aZ as te,c as d,B as E,am 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-kxaA8CDk.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--o3IMwNA.js";import{u as q,a as ve,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,aF as Ve,aG as Ae,aH as Te,X as De,S as Ie,aI as Ue,aJ as $e,U as Ee,p as Re,j as qe,a1 as Fe,ao as Le,T as R,av as Me}from"./icons-D5eAI-GR.js";async function Be(){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 Ke(){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:Be,refetchInterval:3e4,retry:1,staleTime:1e4})}function ze(){const s=ve();return Ce({mutationFn:Ke,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}=W(),{data:t}=Z(),{data:a,isLoading:r}=J(),i=_(),l=ee(),w=se(),u=te(),{data:F}=Qe(),{mutate:L,isPending:v}=ze(),[h,D]=y.useState(!1),[g,M]=y.useState(""),[B,b]=y.useState(!1),[C,S]=y.useState(null),{data:K}=q({queryKey:["cliproxy-server-config"],queryFn:()=>he.cliproxyServer.get(),staleTime:3e4}),Q=Se({mutationKey:["update-backend"]})>0,x=K?.remote,I=x?.enabled&&x?.host,p=s?.running??!1,k=i.isPending||l.isPending||w.isPending||u.isPending||Q||v,z=t?.hasUpdate??!1,m=t?.isStable===!1,U=t?.currentVersion,j=F?.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:v?f:Ve,tooltip:"Sync profiles to CLIProxy",onClick:()=>L(),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]}),(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(Fe,{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:M,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(Le,{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(Me,{className:"w-3 h-3"}),"Start"]})]}),e.jsx(ge,{open:B,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(we,{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{aU as W,aA as Z,aV as J,aW as _,aX as ee,aY as se,aZ as te,c as d,B as E,am 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-7gcYb5Oq.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-BnSvEwhd.js";import{u as q,a as ve,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,aF as Ve,aG as Ae,aH as Te,X as De,S as Ie,aI as Ue,aJ as $e,U as Ee,p as Re,j as qe,a1 as Fe,ao as Le,T as R,av as Me}from"./icons-D5eAI-GR.js";async function Be(){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 Ke(){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:Be,refetchInterval:3e4,retry:1,staleTime:1e4})}function ze(){const s=ve();return Ce({mutationFn:Ke,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}=W(),{data:t}=Z(),{data:a,isLoading:r}=J(),i=_(),l=ee(),w=se(),u=te(),{data:F}=Qe(),{mutate:L,isPending:v}=ze(),[h,D]=y.useState(!1),[g,M]=y.useState(""),[B,b]=y.useState(!1),[C,S]=y.useState(null),{data:K}=q({queryKey:["cliproxy-server-config"],queryFn:()=>he.cliproxyServer.get(),staleTime:3e4}),Q=Se({mutationKey:["update-backend"]})>0,x=K?.remote,I=x?.enabled&&x?.host,p=s?.running??!1,k=i.isPending||l.isPending||w.isPending||u.isPending||Q||v,z=t?.hasUpdate??!1,m=t?.isStable===!1,U=t?.currentVersion,j=F?.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:v?f:Ve,tooltip:"Sync profiles to CLIProxy",onClick:()=>L(),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]}),(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(Fe,{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:M,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(Le,{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(Me,{className:"w-3 h-3"}),"Start"]})]}),e.jsx(ge,{open:B,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(we,{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 s}from"./radix-ui-qEZD5MMp.js";import{r as l}from"./react-vendor-CNOkPC89.js";import{aL as o,aM as m,aN as c,aO as x,aP 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{aL as o,aM as m,aN as c,aO as x,aP as u,b as h,C as p,a as g}from"./index-7gcYb5Oq.js";import{N as j,a0 as f,az as N,T as b}from"./icons-D5eAI-GR.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 R(){const[t,i]=l.useState("commands"),{data:e}=o(),{data:n,isLoading:r}=m(t),d=[{id:"commands",label:"Commands",icon:j,count:e?.commands??0},{id:"skills",label:"Skills",icon:f,count:e?.skills??0},{id:"agents",label:"Agents",icon:N,count:e?.agents??0}];return s.jsxs("div",{className:"p-6 max-w-6xl mx-auto space-y-8",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold",children:"Shared Data"}),s.jsx("p",{className:"text-muted-foreground",children:"Commands, skills, and agents shared across Claude instances"})]}),e&&!e.symlinkStatus.valid&&s.jsxs(c,{variant:"warning",children:[s.jsx(b,{className:"h-4 w-4"}),s.jsx(x,{children:"Configuration Required"}),s.jsxs(u,{children:[e.symlinkStatus.message,". Run `ccs sync` to configure."]})]}),s.jsx("div",{className:"flex gap-2 border-b pb-2",children:d.map(a=>s.jsxs(h,{variant:t===a.id?"default":"ghost",size:"sm",onClick:()=>i(a.id),className:"flex items-center gap-2",children:[s.jsx(a.icon,{className:"w-4 h-4"}),a.label," (",a.count,")"]},a.id))}),s.jsx("div",{className:"mt-4",children:r?s.jsx("div",{className:"text-muted-foreground",children:"Loading..."}):n?.items.length===0?s.jsxs("div",{className:"text-muted-foreground",children:["No ",t," found"]}):s.jsx("div",{className:"grid gap-3",children:n?.items.map(a=>s.jsx(p,{children:s.jsxs(g,{children:[s.jsx("div",{className:"font-medium",children:a.name}),s.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:a.description}),s.jsx("p",{className:"text-xs text-muted-foreground mt-2 font-mono truncate",children:a.path})]})},a.name))})})]})}export{R as SharedPage};
|
|
@@ -1 +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-7gcYb5Oq.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-7gcYb5Oq.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">
|
package/package.json
CHANGED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{j as e,$ as Ns,a0 as ws}from"./radix-ui-qEZD5MMp.js";import{r as m}from"./react-vendor-CNOkPC89.js";import{a as je,u as ze,b as bs}from"./tanstack-De4wvi8X.js";import{b as y,C as Be,a as Qe,c as q,P as ce,L as se,I as ne,X as Ve,Y as Je,Z as We,_ as Xe,$ as de,a0 as Ye,a1 as ys,a2 as Cs,a3 as ks,u as Ze,a4 as ve,a5 as Ne,a6 as we,a7 as be,a8 as es,a9 as Ie,aa as Ss,ab as As,ac as Ps,ad as ss,ae as le,af as Ms,ag as _e,ah as Le,B as G,ai as Ts,q as ts,m as ye,l as Os,aj as Ds,ak as Rs,al as Es,am as X,T as Y,o as Z,p as ee,an as Is,ao as _s,ap as Ls,aq as Fe,ar as Fs,as as Us,at as qs,au as Hs,av as Ks,aw as Gs,ax as $s,H as zs,J as Bs,K as Ue,M as qe,ay as Qs,az as Vs,aA as Js,aB as Ws,aC as Xs,aD as Ys,aE as Zs,aF as et,aG as st,aH as tt,aI as at,S as nt}from"./index-kxaA8CDk.js";import{t as _}from"./notifications-B2HqRBj7.js";import{b as as,L as $,m as ue,y as it,j as B,l as ns,an as Ce,R as ke,n as te,a0 as re,ao as rt,ap as me,Z as xe,I as ot,f as lt,a2 as is,aq as ct,ah as dt,X as Se,$ as rs,s as os,t as he,ar as ut,T as mt,p as He,as as xt,ag as ls,q as pt,at as ht,k as gt,a1 as ft,ak as jt,au as cs}from"./icons-D5eAI-GR.js";import{S as Ae,C as vt}from"./confirm-dialog-B3_kcO03.js";import{S as Nt}from"./switch-DjrWWwTm.js";import{P as wt}from"./proxy-status-widget-Dw9CXnhM.js";import"./utils-CzKF5WmX.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog--o3IMwNA.js";const ie={agy:{provider:"agy",displayName:"Antigravity",defaultModel:"gemini-claude-opus-4-5-thinking",models:[{id:"gemini-claude-opus-4-5-thinking",name:"Claude Opus 4.5 Thinking",description:"Most capable, extended thinking",presetMapping:{default:"gemini-claude-opus-4-5-thinking",opus:"gemini-claude-opus-4-5-thinking",sonnet:"gemini-claude-sonnet-4-5-thinking",haiku:"gemini-claude-sonnet-4-5"}},{id:"gemini-claude-sonnet-4-5-thinking",name:"Claude Sonnet 4.5 Thinking",description:"Balanced with extended thinking",presetMapping:{default:"gemini-claude-sonnet-4-5-thinking",opus:"gemini-claude-opus-4-5-thinking",sonnet:"gemini-claude-sonnet-4-5-thinking",haiku:"gemini-claude-sonnet-4-5"}},{id:"gemini-claude-sonnet-4-5",name:"Claude Sonnet 4.5",description:"Fast and capable",presetMapping:{default:"gemini-claude-sonnet-4-5",opus:"gemini-claude-opus-4-5-thinking",sonnet:"gemini-claude-sonnet-4-5",haiku:"gemini-claude-sonnet-4-5"}},{id:"gemini-3-pro-preview",name:"Gemini 3 Pro",description:"Google latest model via Antigravity",presetMapping:{default:"gemini-3-pro-preview",opus:"gemini-3-pro-preview",sonnet:"gemini-3-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-3-flash-preview",name:"Gemini 3 Flash",description:"Fast Gemini model via Antigravity",presetMapping:{default:"gemini-3-flash-preview",opus:"gemini-3-pro-preview",sonnet:"gemini-3-pro-preview",haiku:"gemini-3-flash-preview"}}]},gemini:{provider:"gemini",displayName:"Gemini",defaultModel:"gemini-2.5-pro",models:[{id:"gemini-3-pro-preview",name:"Gemini 3 Pro",tier:"paid",description:"Latest model, requires paid Google account",presetMapping:{default:"gemini-3-pro-preview",opus:"gemini-3-pro-preview",sonnet:"gemini-3-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-3-flash-preview",name:"Gemini 3 Flash",tier:"paid",description:"Fast Gemini 3 model, requires paid Google account",presetMapping:{default:"gemini-3-flash-preview",opus:"gemini-3-pro-preview",sonnet:"gemini-3-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-2.5-pro",name:"Gemini 2.5 Pro",description:"Stable, works with free Google account",presetMapping:{default:"gemini-2.5-pro",opus:"gemini-2.5-pro",sonnet:"gemini-2.5-pro",haiku:"gemini-2.5-flash"}}]},codex:{provider:"codex",displayName:"Codex",defaultModel:"gpt-5.2-codex",models:[{id:"gpt-5.2-codex",name:"GPT-5.2 Codex",description:"Full reasoning support (xhigh)",presetMapping:{default:"gpt-5.2-codex",opus:"gpt-5.2-codex",sonnet:"gpt-5.2-codex",haiku:"gpt-5-mini"}},{id:"gpt-5-mini",name:"GPT-5 Mini",description:"Fast, capped at high reasoning (no xhigh)",presetMapping:{default:"gpt-5-mini",opus:"gpt-5.2-codex",sonnet:"gpt-5-mini",haiku:"gpt-5-mini"}},{id:"gpt-5.1-codex-max",name:"Codex Max (5.1)",description:"Legacy most capable Codex model",presetMapping:{default:"gpt-5.1-codex-max",opus:"gpt-5.1-codex-max-high",sonnet:"gpt-5.1-codex-max",haiku:"gpt-5.1-codex-mini-high"}},{id:"gpt-5.2",name:"GPT 5.2",description:"Latest GPT model",presetMapping:{default:"gpt-5.2",opus:"gpt-5.2",sonnet:"gpt-5.2",haiku:"gpt-5.2"}},{id:"gpt-5.1-codex-mini",name:"Codex Mini",description:"Fast and efficient Codex model"}]},qwen:{provider:"qwen",displayName:"Qwen",defaultModel:"qwen3-coder-plus",models:[{id:"qwen3-coder-plus",name:"Qwen3 Coder Plus",description:"Code-focused model (1M context)",presetMapping:{default:"qwen3-coder-plus",opus:"qwen3-max",sonnet:"qwen3-coder-plus",haiku:"qwen3-coder-flash"}},{id:"qwen3-max",name:"Qwen3 Max",description:"Flagship model (256K context)",presetMapping:{default:"qwen3-max",opus:"qwen3-max",sonnet:"qwen3-coder-plus",haiku:"qwen3-coder-flash"}},{id:"qwen3-max-preview",name:"Qwen3 Max Preview",description:"Preview with thinking support (256K)",presetMapping:{default:"qwen3-max-preview",opus:"qwen3-max-preview",sonnet:"qwen3-max",haiku:"qwen3-coder-flash"}},{id:"qwen3-235b",name:"Qwen3 235B",description:"Large 235B A22B model",presetMapping:{default:"qwen3-235b",opus:"qwen3-max",sonnet:"qwen3-235b",haiku:"qwen3-coder-flash"}},{id:"qwen3-vl-plus",name:"Qwen3 VL Plus",description:"Vision-language multimodal"},{id:"qwen3-coder-flash",name:"Qwen3 Coder Flash",description:"Fast code generation"},{id:"qwen3-32b",name:"Qwen3 32B",description:"Qwen3 32B model"}]},iflow:{provider:"iflow",displayName:"iFlow",defaultModel:"iflow-default",models:[{id:"iflow-default",name:"iFlow Default",description:"Default iFlow model"}]},kiro:{provider:"kiro",displayName:"Kiro (AWS)",defaultModel:"kiro-claude-sonnet-4-5",models:[{id:"kiro-claude-opus-4-5",name:"Kiro Claude Opus 4.5",description:"Claude Opus 4.5 via Kiro (2.2x credit)",presetMapping:{default:"kiro-claude-opus-4-5",opus:"kiro-claude-opus-4-5",sonnet:"kiro-claude-sonnet-4-5",haiku:"kiro-claude-haiku-4-5"}},{id:"kiro-claude-sonnet-4-5",name:"Kiro Claude Sonnet 4.5",description:"Claude Sonnet 4.5 via Kiro (1.3x credit)",presetMapping:{default:"kiro-claude-sonnet-4-5",opus:"kiro-claude-opus-4-5",sonnet:"kiro-claude-sonnet-4-5",haiku:"kiro-claude-haiku-4-5"}},{id:"kiro-claude-sonnet-4",name:"Kiro Claude Sonnet 4",description:"Claude Sonnet 4 via Kiro (1.3x credit)",presetMapping:{default:"kiro-claude-sonnet-4",opus:"kiro-claude-opus-4-5",sonnet:"kiro-claude-sonnet-4",haiku:"kiro-claude-haiku-4-5"}},{id:"kiro-claude-haiku-4-5",name:"Kiro Claude Haiku 4.5",description:"Claude Haiku 4.5 via Kiro (0.4x credit)"}]},ghcp:{provider:"ghcp",displayName:"GitHub Copilot (OAuth)",defaultModel:"claude-sonnet-4.5",models:[{id:"claude-opus-4.5",name:"Claude Opus 4.5",description:"Anthropic Claude Opus 4.5 via GitHub Copilot",presetMapping:{default:"claude-opus-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"}},{id:"claude-sonnet-4.5",name:"Claude Sonnet 4.5",description:"Anthropic Claude Sonnet 4.5 via GitHub Copilot",presetMapping:{default:"claude-sonnet-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"}},{id:"claude-sonnet-4",name:"Claude Sonnet 4",description:"Anthropic Claude Sonnet 4 via GitHub Copilot"},{id:"claude-haiku-4.5",name:"Claude Haiku 4.5",description:"Anthropic Claude Haiku 4.5 via GitHub Copilot"},{id:"gpt-5.2",name:"GPT-5.2",description:"OpenAI GPT-5.2 via GitHub Copilot",presetMapping:{default:"gpt-5.2",opus:"gpt-5.2",sonnet:"gpt-5.1",haiku:"gpt-5-mini"}},{id:"gpt-5.1",name:"GPT-5.1",description:"OpenAI GPT-5.1 via GitHub Copilot"},{id:"gpt-5",name:"GPT-5",description:"OpenAI GPT-5 via GitHub Copilot"},{id:"gpt-5-mini",name:"GPT-5 Mini",description:"OpenAI GPT-5 Mini via GitHub Copilot"},{id:"gemini-3-pro",name:"Gemini 3 Pro",description:"Google Gemini 3 Pro via GitHub Copilot"}]},claude:{provider:"claude",displayName:"Claude (Anthropic)",defaultModel:"claude-sonnet-4-5-20250929",models:[{id:"claude-opus-4-5-20251101",name:"Claude Opus 4.5",description:"Most capable Claude model",presetMapping:{default:"claude-opus-4-5-20251101",opus:"claude-opus-4-5-20251101",sonnet:"claude-sonnet-4-5-20250929",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-sonnet-4-5-20250929",name:"Claude Sonnet 4.5",description:"Balanced performance and speed",presetMapping:{default:"claude-sonnet-4-5-20250929",opus:"claude-opus-4-5-20251101",sonnet:"claude-sonnet-4-5-20250929",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-sonnet-4-20250514",name:"Claude Sonnet 4",description:"Previous generation Sonnet",presetMapping:{default:"claude-sonnet-4-20250514",opus:"claude-opus-4-5-20251101",sonnet:"claude-sonnet-4-20250514",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-haiku-4-5-20251001",name:"Claude Haiku 4.5",description:"Fast and efficient"}]}},ge=8317,pe="ccs-internal-managed";async function bt(){try{const s=await fetch("/api/settings/auth/tokens/raw");return s.ok?(await s.json())?.apiKey?.value??pe:pe}catch{return pe}}async function fe(s,a){const t=ie[s];if(!t)return{success:!1};const i=t.models[0],r=i?.presetMapping||{default:t.defaultModel,opus:t.defaultModel,sonnet:t.defaultModel,haiku:t.defaultModel},u=await bt(),p={env:{ANTHROPIC_BASE_URL:`http://127.0.0.1:${ge}/api/provider/${s}`,ANTHROPIC_AUTH_TOKEN:u,ANTHROPIC_MODEL:r.default,ANTHROPIC_DEFAULT_OPUS_MODEL:r.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:r.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:r.haiku}};try{return{success:(await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:p})})).ok,presetName:i?.name||t.defaultModel}}catch{return{success:!1}}}function yt({currentProgress:s,allSteps:a}){return e.jsx("div",{className:"flex justify-center gap-1 pt-2",children:a.map((t,i)=>e.jsx("div",{className:`w-2 h-2 rounded-full transition-colors ${s>=i?"bg-primary":"bg-muted"}`},t))})}function Ct({providers:s,onSelect:a}){return e.jsx("div",{className:"grid gap-2",children:s.map(t=>e.jsxs("button",{onClick:()=>a(t.id),className:"flex items-center justify-between p-3 border rounded-lg hover:bg-muted/50 transition-colors text-left",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:t.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:t.description})]}),e.jsx(as,{className:"w-4 h-4 text-muted-foreground"})]},t.id))})}function kt({selectedProvider:s,providers:a,authCommand:t,isRefreshing:i,isPending:r,onBack:u,onStartAuth:c,onRefresh:p}){const[d,g]=m.useState(!1),j=async h=>{await navigator.clipboard.writeText(h),g(!0),setTimeout(()=>g(!1),2e3)};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-center space-y-3",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Authenticate with ",a.find(h=>h.id===s)?.name," to add an account"]}),e.jsx(y,{onClick:c,disabled:r,className:"w-full gap-2",size:"lg",children:r?e.jsxs(e.Fragment,{children:[e.jsx($,{className:"w-4 h-4 animate-spin"}),"Authenticating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"w-4 h-4"}),"Authenticate in Browser"]})}),r&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Complete the OAuth flow in your browser..."})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:"Or use terminal"})})]}),e.jsx(Be,{children:e.jsxs(Qe,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(it,{className:"w-4 h-4"}),"Run this command in your terminal:"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 px-3 py-2 bg-muted rounded-md font-mono text-sm",children:t}),e.jsx(y,{variant:"outline",size:"icon",onClick:()=>j(t),children:d?e.jsx(B,{className:"w-4 h-4 text-green-500"}):e.jsx(ns,{className:"w-4 h-4"})})]})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(y,{variant:"ghost",onClick:u,disabled:r,children:[e.jsx(Ce,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs(y,{variant:"outline",onClick:p,disabled:i||r,children:[e.jsx(ke,{className:`w-4 h-4 mr-2 ${i?"animate-spin":""}`}),i?"Checking...":"Refresh Status"]})]})]})}function St({accounts:s,privacyMode:a,onSelect:t,onAddNew:i,onBack:r}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:["Select an account (",s.length,")"]}),e.jsx("div",{className:"grid gap-2 max-h-[320px] overflow-y-auto pr-1",children:s.map(u=>e.jsxs("button",{type:"button",onClick:()=>t(u),className:"flex items-center justify-between p-3 border rounded-lg hover:bg-muted/50 transition-colors text-left",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-muted flex items-center justify-center",children:e.jsx(te,{className:"w-4 h-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:q("font-medium",a&&ce),children:u.email||u.id}),u.isDefault&&e.jsx("div",{className:"text-xs text-muted-foreground",children:"Default account"})]})]}),e.jsx(as,{className:"w-4 h-4 text-muted-foreground"})]},u.id))}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:"Or"})})]}),e.jsxs("button",{type:"button",className:"w-full flex items-center gap-3 p-3 border-2 border-dashed border-primary/50 rounded-lg hover:border-primary hover:bg-primary/5 transition-colors text-left",onClick:i,children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(ue,{className:"w-4 h-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-primary",children:"Add new account"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Authenticate with a different account"})]})]}),e.jsx("div",{className:"flex items-center justify-between pt-2",children:e.jsxs(y,{variant:"ghost",onClick:r,children:[e.jsx(Ce,{className:"w-4 h-4 mr-2"}),"Back"]})})]})}const Ke="__custom__";function At({selectedProvider:s,selectedAccount:a,variantName:t,modelName:i,isPending:r,privacyMode:u,onVariantNameChange:c,onModelChange:p,onBack:d,onSkip:g,onCreate:j}){const h=ie[s]?.models||[],n=i&&!h.some(x=>x.id===i),[l,f]=m.useState(n),w=x=>{x===Ke?(f(!0),p("")):(f(!1),p(x))};return e.jsxs("div",{className:"space-y-4",children:[a&&e.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/50 rounded-md text-sm",children:[e.jsx(te,{className:"w-4 h-4"}),e.jsxs("span",{children:["Using:"," ",e.jsx("span",{className:q(u&&ce),children:a.email||a.id})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"variant-name",children:"Variant Name *"}),e.jsx(ne,{id:"variant-name",value:t,onChange:x=>c(x.target.value),placeholder:"e.g., my-gemini, g3, flash"}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Use this name to invoke: ccs ",t||"<name>",' "prompt"']})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{children:"Model"}),l?e.jsxs("div",{className:"space-y-2",children:[e.jsx(ne,{value:i,onChange:x=>p(x.target.value),placeholder:"e.g., gemini-2.5-pro, claude-opus-4-5"}),e.jsx("button",{type:"button",className:"text-xs text-primary hover:underline",onClick:()=>f(!1),children:"Choose from presets instead"})]}):e.jsxs(Ve,{value:h.some(x=>x.id===i)?i:"",onValueChange:w,children:[e.jsx(Je,{children:e.jsx(We,{placeholder:"Select a model"})}),e.jsxs(Xe,{children:[h.map(x=>e.jsx(de,{value:x.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:x.name}),x.description&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",x.description]})]})},x.id)),e.jsx(de,{value:Ke,children:e.jsx("span",{className:"text-primary",children:"Custom model name..."})})]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:l?"Enter any model name supported by CLIProxy":`Default: ${ie[s]?.defaultModel||"provider default"}`})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs(y,{variant:"ghost",onClick:d,children:[e.jsx(Ce,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(y,{variant:"ghost",onClick:g,children:"Skip"}),e.jsx(y,{onClick:j,disabled:!t||r,children:r?"Creating...":"Create Variant"})]})]}),e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:"Skip if you just wanted to add an account without creating a variant"})]})}function Pt({variantName:s,onClose:a}){return e.jsxs("div",{className:"space-y-4 text-center",children:[e.jsx("div",{className:"flex justify-center",children:e.jsx("div",{className:"w-16 h-16 bg-green-100 dark:bg-green-900/30 rounded-full flex items-center justify-center",children:e.jsx(B,{className:"w-8 h-8 text-green-600 dark:text-green-400"})})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-lg",children:"Variant Created!"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Your custom variant is ready to use"})]}),e.jsx(Be,{children:e.jsxs(Qe,{className:"p-4 space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Usage:"}),e.jsxs("code",{className:"block px-3 py-2 bg-muted rounded-md font-mono text-sm",children:["ccs ",s,' "your prompt here"']})]})}),e.jsx(y,{onClick:a,className:"w-full",children:"Done"})]})}function Mt({open:s,onClose:a}){const[t,i]=m.useState("provider"),[r,u]=m.useState(""),[c,p]=m.useState(null),[d,g]=m.useState(""),[j,h]=m.useState(""),[n,l]=m.useState(!1),[f,w]=m.useState(!1),{data:x,refetch:A}=Ye(),I=ys(),E=Cs(),O=ks(),{privacyMode:D}=Ze(),v=x?.authStatus.find(S=>S.provider===r),T=m.useMemo(()=>v?.accounts||[],[v?.accounts]);m.useEffect(()=>{if(!s){const S=setTimeout(()=>{i("provider"),u(""),p(null),g(""),h(""),w(!1)},0);return()=>clearTimeout(S)}},[s]),m.useEffect(()=>{if(t==="auth"&&T.length>0&&!f){const S=setTimeout(()=>{i("account")},0);return()=>clearTimeout(S)}},[t,T,f]);const b=async()=>{l(!0),await A(),l(!1)},N=()=>{const S=(v?.accounts?.length||0)===0;E.mutate({provider:r},{onSuccess:async C=>{if(S){const L=await fe(r);L.success&&L.presetName?_.success(`Applied "${L.presetName}" preset`):L.success||_.warning("Account added, but failed to apply default preset")}C.account&&(p(C.account),i("variant")),A()}})},R=S=>{u(S),(x?.authStatus.find(K=>K.provider===S)?.accounts||[]).length===0?i("auth"):i("account")},P=S=>{p(S),i("variant")},k=async()=>{if(!(!d||!r))try{await I.mutateAsync({name:d,provider:r,model:j||void 0,account:c?.id}),i("success")}catch(S){console.error("Failed to create variant:",S)}},F=`ccs ${r} --auth --add`,H=As(t),z=S=>{if(!S&&(E.isPending&&r&&O.mutate(r),t==="success"||t==="provider")){a();return}};return e.jsx(ve,{open:s,onOpenChange:z,children:e.jsxs(Ne,{className:"sm:max-w-lg",onPointerDownOutside:S=>{t!=="success"&&t!=="provider"&&S.preventDefault()},onEscapeKeyDown:S=>{(E.isPending||I.isPending)&&S.preventDefault()},children:[e.jsxs(we,{children:[e.jsxs(be,{className:"flex items-center gap-2",children:[e.jsx(re,{className:"w-5 h-5 text-primary"}),"Quick Setup Wizard"]}),e.jsxs(es,{children:[t==="provider"&&"Select a provider to get started",t==="auth"&&"Authenticate with your provider",t==="account"&&"Select which account to use",t==="variant"&&"Create your custom variant",t==="success"&&"Setup complete!"]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[t==="provider"&&e.jsx(Ct,{providers:Ie,onSelect:R}),t==="auth"&&e.jsx(kt,{selectedProvider:r,providers:Ie,authCommand:F,isRefreshing:n,isPending:E.isPending,onBack:()=>i("provider"),onStartAuth:N,onRefresh:b}),t==="account"&&e.jsx(St,{accounts:T,privacyMode:D,onSelect:P,onAddNew:()=>{w(!0),i("auth")},onBack:()=>i("provider")}),t==="variant"&&e.jsx(At,{selectedProvider:r,selectedAccount:c,variantName:d,modelName:j,isPending:I.isPending,privacyMode:D,onVariantNameChange:g,onModelChange:h,onBack:()=>T.length>0?i("account"):i("provider"),onSkip:a,onCreate:k}),t==="success"&&e.jsx(Pt,{variantName:d,onClose:a})]}),e.jsx(yt,{currentProgress:H,allSteps:Ss})]})})}const Tt=3e3,Ot=300*1e3,J={provider:null,isAuthenticating:!1,error:null,authUrl:null,oauthState:null,isSubmittingCallback:!1,isDeviceCodeFlow:!1};function Dt(){const[s,a]=m.useState(J),t=m.useRef(null),i=m.useRef(null),r=m.useRef(0),u=je(),c=m.useCallback(()=>{i.current&&(clearInterval(i.current),i.current=null)},[]);m.useEffect(()=>()=>{t.current?.abort(),c()},[c]);const p=m.useCallback(async(h,n)=>{if(Date.now()-r.current>Ot){c(),a(l=>({...l,isAuthenticating:!1,error:"Authentication timed out. Please try again."}));return}try{const f=await(await fetch(`/api/cliproxy/auth/${h}/status?state=${encodeURIComponent(n)}`)).json();if(f.status==="ok")c(),u.invalidateQueries({queryKey:["cliproxy-auth"]}),u.invalidateQueries({queryKey:["account-quota"]}),_.success(`${h} authentication successful`),a(J);else if(f.status==="error"){c();const w=f.error||"Authentication failed";_.error(w),a(x=>({...x,isAuthenticating:!1,error:w}))}}catch{}},[u,c]),d=m.useCallback(async(h,n)=>{if(!Ps(h)){a({...J,error:`Unknown provider: ${h}`});return}t.current?.abort(),c();const l=new AbortController;t.current=l;const f=ss(h);a({provider:h,isAuthenticating:!0,error:null,authUrl:null,oauthState:null,isSubmittingCallback:!1,isDeviceCodeFlow:f});try{if(f)fetch(`/api/cliproxy/auth/${h}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({nickname:n?.nickname}),signal:l.signal}).then(async w=>{const x=await w.json();if(w.ok&&x.success)u.invalidateQueries({queryKey:["cliproxy-auth"]}),u.invalidateQueries({queryKey:["account-quota"]}),a(J);else{const A=x.error||"Authentication failed";_.error(A),a(I=>({...I,isAuthenticating:!1,error:A}))}}).catch(w=>{if(w instanceof Error&&w.name==="AbortError")return;const x=w instanceof Error?w.message:"Authentication failed";_.error(x),a(A=>({...A,isAuthenticating:!1,error:x}))});else{const w=await fetch(`/api/cliproxy/auth/${h}/start-url`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({nickname:n?.nickname}),signal:l.signal}),x=await w.json();if(!w.ok||!x.success)throw new Error(x.error||"Failed to start OAuth");a(A=>({...A,authUrl:x.authUrl,oauthState:x.state})),x.authUrl&&window.open(x.authUrl,"_blank"),x.state&&(r.current=Date.now(),i.current=setInterval(()=>{p(h,x.state)},Tt))}}catch(w){if(w instanceof Error&&w.name==="AbortError"){a(J);return}const x=w instanceof Error?w.message:"Authentication failed";_.error(x),a(A=>({...A,isAuthenticating:!1,error:x}))}},[p,c,u]),g=m.useCallback(()=>{const h=s.provider;t.current?.abort(),c(),a(J),h&&le.cliproxy.auth.cancel(h).catch(()=>{})},[s.provider,c]),j=m.useCallback(async h=>{if(s.provider){a(n=>({...n,isSubmittingCallback:!0,error:null}));try{const n=await fetch(`/api/cliproxy/auth/${s.provider}/submit-callback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({redirectUrl:h})}),l=await n.json();if(n.ok&&l.success)c(),u.invalidateQueries({queryKey:["cliproxy-auth"]}),u.invalidateQueries({queryKey:["account-quota"]}),_.success(`${s.provider} authentication successful`),a(J);else throw new Error(l.error||"Callback submission failed")}catch(n){const l=n instanceof Error?n.message:"Failed to submit callback";_.error(l),a(f=>({...f,isSubmittingCallback:!1,error:l}))}}},[s.provider,u,c]);return m.useMemo(()=>({...s,startAuth:d,cancelAuth:g,submitCallback:j}),[s,d,g,j])}function Rt({open:s,onClose:a,provider:t,displayName:i,isFirstAccount:r=!1}){const[u,c]=m.useState(""),[p,d]=m.useState(""),[g,j]=m.useState(!1),h=m.useRef(!1),n=Dt(),l=Ms(),f=t==="kiro",w=ss(t),x=n.isAuthenticating||l.isPending,A=()=>{c(""),d(""),j(!1),h.current=!1,a()};m.useEffect(()=>{!n.isAuthenticating&&!n.error&&n.provider===null&&s&&h.current&&(h.current=!1,(async()=>{try{const R=await fe(t);R.success&&R.presetName&&r&&_.success(`Applied "${R.presetName}" preset`)}catch{}A()})())},[n.isAuthenticating,n.error,n.provider]);const I=()=>{n.cancelAuth(),A()},E=async()=>{n.authUrl&&(await navigator.clipboard.writeText(n.authUrl),j(!0),setTimeout(()=>j(!1),2e3))},O=()=>{p.trim()&&n.submitCallback(p.trim())},D=()=>{h.current=!0,n.startAuth(t,{nickname:u.trim()||void 0})},v=()=>{h.current=!0,l.mutate(void 0,{onSuccess:async()=>{const N=await fe("kiro");N.success&&N.presetName&&r&&_.success(`Applied "${N.presetName}" preset`),A()}})},T=N=>{N||I()},b=n.isAuthenticating;return e.jsx(ve,{open:s,onOpenChange:T,children:e.jsxs(Ne,{className:"sm:max-w-md",onInteractOutside:N=>{b&&N.preventDefault()},children:[e.jsxs(we,{children:[e.jsxs(be,{children:["Add ",i," Account"]}),e.jsx(es,{children:f?"Authenticate via browser or import an existing token from Kiro IDE.":w?"Click Authenticate. A verification code will appear for you to enter on the provider website.":"Click Authenticate to get an OAuth URL. Open it in any browser to sign in."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[!b&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"nickname",children:"Nickname (optional)"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(te,{className:"w-4 h-4 text-muted-foreground"}),e.jsx(ne,{id:"nickname",value:u,onChange:N=>c(N.target.value),placeholder:"e.g., work, personal",disabled:x,className:"flex-1"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"A friendly name to identify this account. Auto-generated from email if left empty."})]}),b&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.jsx($,{className:"w-4 h-4 inline mr-2 animate-spin"}),"Waiting for authentication..."]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:n.isDeviceCodeFlow?"A verification code dialog will appear shortly. Enter the code on the provider website.":"Complete the authentication in your browser. This dialog closes automatically."})]}),n.error&&!n.authUrl&&e.jsx("p",{className:"text-xs text-center text-destructive",children:n.error}),n.authUrl&&!n.isDeviceCodeFlow&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{className:"text-xs",children:"Open this URL in any browser to sign in:"}),e.jsxs("div",{className:"p-3 bg-muted rounded-md",children:[e.jsx("p",{className:"text-xs text-muted-foreground break-all font-mono line-clamp-3",children:n.authUrl}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(y,{variant:"outline",size:"sm",onClick:E,children:g?e.jsxs(e.Fragment,{children:[e.jsx(B,{className:"w-3 h-3 mr-1"}),"Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(ns,{className:"w-3 h-3 mr-1"}),"Copy"]})}),e.jsxs(y,{variant:"outline",size:"sm",onClick:()=>{if(!n.authUrl)return;const N=window.open(n.authUrl,"_blank");(!N||N.closed||typeof N.closed>"u")&&_.warning("Popup blocked. Copy the URL above and open it manually in your browser.",{duration:5e3})},children:[e.jsx(ue,{className:"w-3 h-3 mr-1"}),"Open"]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"callback-url",className:"text-xs",children:"Redirect didn't work? Paste the callback URL:"}),e.jsx(ne,{id:"callback-url",value:p,onChange:N=>d(N.target.value),placeholder:"Paste the redirect URL here...",className:"font-mono text-xs"}),e.jsx(y,{variant:"secondary",size:"sm",onClick:O,disabled:!p.trim()||n.isSubmittingCallback,children:n.isSubmittingCallback?e.jsxs(e.Fragment,{children:[e.jsx($,{className:"w-3 h-3 mr-1 animate-spin"}),"Submitting..."]}):"Submit Callback"})]})]})]}),l.isPending&&e.jsxs("p",{className:"text-sm text-center text-muted-foreground",children:[e.jsx($,{className:"w-4 h-4 inline mr-2 animate-spin"}),"Importing token from Kiro IDE..."]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[e.jsx(y,{variant:"ghost",onClick:I,children:"Cancel"}),f&&!b&&e.jsx(y,{variant:"outline",onClick:v,disabled:x,children:l.isPending?e.jsxs(e.Fragment,{children:[e.jsx($,{className:"w-4 h-4 mr-2 animate-spin"}),"Importing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(rt,{className:"w-4 h-4 mr-2"}),"Import from IDE"]})}),!b&&e.jsxs(y,{onClick:D,disabled:x,children:[e.jsx(ue,{className:"w-4 h-4 mr-2"}),"Authenticate"]})]})]})]})})}const Et=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"];function It(s){const a=s?.env||{};return Et.filter(t=>!a[t]?.trim())}function _t(s){const[a,t]=m.useState(null),[i,r]=m.useState(!1),u=je(),{data:c,isLoading:p,refetch:d}=ze({queryKey:["settings",s],queryFn:async()=>{const b=await fetch(`/api/settings/${s}/raw`);return b.ok?b.json():{profile:s,settings:{env:{}},mtime:Date.now(),path:`~/.ccs/profiles/${s}/settings.json`}}}),g=c?.settings,j=m.useMemo(()=>a!==null?a:g?JSON.stringify(g,null,2):`{
|
|
2
|
-
"env": {}
|
|
3
|
-
}`,[a,g]),h=m.useCallback(b=>{t(b)},[]),n=m.useMemo(()=>{try{return JSON.parse(j)}catch{return g||{env:{}}}},[j,g]),l=n?.env?.ANTHROPIC_MODEL,f=n?.env?.ANTHROPIC_DEFAULT_OPUS_MODEL,w=n?.env?.ANTHROPIC_DEFAULT_SONNET_MODEL,x=n?.env?.ANTHROPIC_DEFAULT_HAIKU_MODEL,A=m.useCallback((b,N)=>{const R={...n?.env||{},[b]:N},P={...n,env:R};t(JSON.stringify(P,null,2))},[n]),I=m.useCallback(b=>{const N={...n?.env||{},...b},R={...n,env:N};t(JSON.stringify(R,null,2))},[n]),E=m.useMemo(()=>{try{return JSON.parse(j),!0}catch{return!1}},[j]),O=m.useMemo(()=>a===null?!1:a!==JSON.stringify(g,null,2),[a,g]),D=m.useMemo(()=>It(n),[n]),v=bs({mutationFn:async()=>{const b=JSON.parse(j),N=await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:b,expectedMtime:c?.mtime})});if(N.status===409)throw new Error("CONFLICT");if(!N.ok)throw new Error("Failed to save");return N.json()},onSuccess:b=>{u.invalidateQueries({queryKey:["settings",s]}),t(null),b?.warning?_.success("Settings saved",{description:b.warning}):_.success("Settings saved")},onError:b=>{b.message==="CONFLICT"?r(!0):_.error(b.message)}}),T=async b=>{r(!1),b?(await d(),v.mutate()):t(null)};return{data:c,isLoading:p,refetch:d,rawJsonContent:j,rawJsonEdits:a,isRawJsonValid:E,hasChanges:O,currentSettings:n,currentModel:l,opusModel:f,sonnetModel:w,haikuModel:x,handleRawJsonChange:h,updateEnvValue:A,updateEnvValues:I,saveMutation:{mutate:()=>v.mutate(),isPending:v.isPending},conflictDialog:i,setConflictDialog:r,handleConflictResolve:T,missingRequiredFields:D}}function V({label:s,description:a,value:t,onChange:i,catalog:r,allModels:u,disabled:c}){const p=new Set(r?.models.map(d=>d.id)||[]);return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",children:s}),a&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a})]}),e.jsxs(Ve,{value:t||"",onValueChange:i,disabled:c,children:[e.jsx(Je,{className:"h-9",children:e.jsx(We,{placeholder:"Select model",children:t&&e.jsx("span",{className:"truncate font-mono text-xs",children:t})})}),e.jsxs(Xe,{className:"max-h-[300px]",children:[r&&r.models.length>0&&e.jsxs(_e,{children:[e.jsx(Le,{className:"text-xs text-primary",children:"Recommended"}),r.models.map(d=>e.jsx(de,{value:d.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:d.id}),d.tier==="paid"&&e.jsx(G,{variant:"outline",className:"text-[9px] h-4 px-1",children:"PAID"}),t===d.id&&e.jsx(B,{className:"w-3 h-3 text-primary ml-auto"})]})},d.id))]}),u.length>0&&e.jsxs(_e,{children:[e.jsxs(Le,{className:"text-xs text-muted-foreground",children:["All Models (",u.length,")"]}),u.filter(d=>!p.has(d.id)).map(d=>e.jsx(de,{value:d.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:d.id}),t===d.id&&e.jsx(B,{className:"w-3 h-3 text-primary ml-auto"})]})},d.id))]}),(!r||r.models.length===0)&&u.length===0&&e.jsx("div",{className:"py-2 px-3 text-xs text-muted-foreground",children:"No models available"})]})]})]})}function Lt({open:s,onClose:a,currentValues:t,onApply:i,onSave:r,isSaving:u,catalog:c,allModels:p}){const[d,g]=m.useState(t),[j,h]=m.useState(""),n=l=>{l?(g(t),h("")):a()};return e.jsx(ve,{open:s,onOpenChange:n,children:e.jsxs(Ne,{className:"sm:max-w-md",children:[e.jsx(we,{children:e.jsxs(be,{className:"flex items-center gap-2",children:[e.jsx(re,{className:"w-4 h-4"}),"Custom Preset"]})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"preset-name",children:"Preset Name (optional)"}),e.jsx(ne,{id:"preset-name",value:j,onChange:l=>h(l.target.value),placeholder:"e.g., My Custom Config",className:"text-sm"})]}),e.jsx(Ae,{}),e.jsx(V,{label:"Default Model",description:"Used when no specific tier is requested",value:d.default,onChange:l=>g({...d,default:l}),catalog:c,allModels:p}),e.jsx(V,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:d.opus,onChange:l=>g({...d,opus:l}),catalog:c,allModels:p}),e.jsx(V,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:d.sonnet,onChange:l=>g({...d,sonnet:l}),catalog:c,allModels:p}),e.jsx(V,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:d.haiku,onChange:l=>g({...d,haiku:l}),catalog:c,allModels:p})]}),e.jsxs(Ts,{className:"gap-2 sm:gap-0",children:[e.jsx(y,{variant:"outline",onClick:a,children:"Cancel"}),r&&e.jsxs(y,{variant:"secondary",onClick:()=>r(d,j||void 0),disabled:u||!j.trim(),children:[u?e.jsx($,{className:"w-4 h-4 mr-1 animate-spin"}):e.jsx(me,{className:"w-4 h-4 mr-1"}),"Save Preset"]}),e.jsxs(y,{onClick:()=>i(d,j||void 0),children:[e.jsx(xe,{className:"w-4 h-4 mr-1"}),"Apply Preset"]})]})]})})}function oe({label:s,command:a}){return e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:s}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsx("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:a}),e.jsx(ts,{value:a,size:"icon",className:"h-6 w-6"})]})]})}function Ft({provider:s,displayName:a,data:t,authStatus:i}){return e.jsx(ye,{className:"h-full",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium flex items-center gap-2 mb-3",children:[e.jsx(ot,{className:"w-4 h-4"}),"Provider Information"]}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Provider"}),e.jsx("span",{className:"font-mono",children:a})]}),t&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"File Path"}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:t.path}),e.jsx(ts,{value:t.path,size:"icon",className:"h-5 w-5"})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Last Modified"}),e.jsx("span",{className:"text-xs",children:new Date(t.mtime).toLocaleString()})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Status"}),i.authenticated?e.jsxs(G,{variant:"outline",className:"w-fit text-green-600 border-green-200 bg-green-50",children:[e.jsx(lt,{className:"w-3 h-3 mr-1"}),"Authenticated"]}):e.jsx(G,{variant:"outline",className:"w-fit text-muted-foreground",children:"Not connected"})]})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:"Quick Usage"}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsx(oe,{label:"Run with prompt",command:`ccs ${s} "your prompt"`}),e.jsx(oe,{label:"Change model",command:`ccs ${s} --config`}),e.jsx(oe,{label:"Add account",command:`ccs ${s} --add`}),e.jsx(oe,{label:"List accounts",command:`ccs ${s} --accounts`})]})]})]})})}const Ut={gemini:"/assets/providers/gemini-color.svg",codex:"/assets/providers/openai.svg",agy:"/assets/providers/agy.png",qwen:"/assets/providers/qwen-color.svg",iflow:"/assets/providers/iflow.png",kiro:"/assets/providers/kiro.png",ghcp:"/assets/providers/copilot.svg",claude:"/assets/providers/claude.svg"},qt={gemini:{text:"text-blue-600",letter:"G"},claude:{text:"text-orange-600",letter:"C"},codex:{text:"text-emerald-600",letter:"X"},agy:{text:"text-violet-600",letter:"A"},qwen:{text:"text-cyan-600",letter:"Q"},iflow:{text:"text-indigo-600",letter:"i"},kiro:{text:"text-teal-600",letter:"K"},ghcp:{text:"text-green-600",letter:"C"}},Ht={sm:{container:"w-6 h-6",icon:"w-4 h-4",text:"text-xs"},md:{container:"w-8 h-8",icon:"w-5 h-5",text:"text-sm"},lg:{container:"w-12 h-12",icon:"w-8 h-8",text:"text-lg"}};function Pe({provider:s,className:a,size:t="md"}){const i=s.toLowerCase(),r=qt[i]||{text:"text-gray-600",letter:s[0]?.toUpperCase()||"?"},u=Ht[t],c=Ut[i];return e.jsx("div",{className:q("flex items-center justify-center rounded-md",c&&"bg-white p-1",u.container,a),children:c?e.jsx("img",{src:c,alt:`${s} logo`,className:q(u.icon,"object-contain")}):e.jsx("span",{className:q("font-semibold",r.text,u.text),children:r.letter})})}function Kt({displayName:s,logoProvider:a,provider:t,data:i,isLoading:r,hasChanges:u,isRawJsonValid:c,isSaving:p,isRemoteMode:d,port:g,onRefetch:j,onSave:h}){return e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Pe,{provider:a||t,size:"lg"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:s}),d&&e.jsxs(G,{variant:"secondary",className:"text-xs gap-1 bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400",children:[e.jsx(is,{className:"w-3 h-3"}),"Remote"]}),g&&e.jsxs(G,{variant:"outline",className:"text-xs gap-1 font-mono",children:[e.jsx(ct,{className:"w-3 h-3"}),":",g]}),!d&&i?.path&&e.jsx(G,{variant:"outline",className:"text-xs",children:i.path.replace(/^.*[\\/]/,"")})]}),d?e.jsx("p",{className:"text-xs text-blue-600 dark:text-blue-400 mt-0.5",children:"Traffic auto-routed to remote server"}):i&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified: ",new Date(i.mtime).toLocaleString()]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(y,{variant:"ghost",size:"sm",onClick:j,disabled:r,children:e.jsx(ke,{className:`w-4 h-4 ${r?"animate-spin":""}`})}),e.jsx(y,{size:"sm",onClick:h,disabled:p||!u||!c,children:p?e.jsxs(e.Fragment,{children:[e.jsx($,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(dt,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}function Gt({catalog:s,savedPresets:a,currentModel:t,opusModel:i,sonnetModel:r,haikuModel:u,providerModels:c,onApplyPreset:p,onUpdateEnvValue:d,onOpenCustomPreset:g,onDeletePreset:j,isDeletePending:h}){const n=s&&s.models.length>0||a.length>0;return e.jsxs(e.Fragment,{children:[n&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(re,{className:"w-4 h-4"}),"Presets"]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"Apply pre-configured model mappings"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[s?.models.slice(0,4).map(l=>e.jsxs(y,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>{const f=l.presetMapping||{default:l.id,opus:l.id,sonnet:l.id,haiku:l.id};p({ANTHROPIC_MODEL:f.default,ANTHROPIC_DEFAULT_OPUS_MODEL:f.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:f.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:f.haiku})},children:[e.jsx(xe,{className:"w-3 h-3"}),l.name]},l.id)),a.map(l=>e.jsxs("div",{className:"group relative",children:[e.jsxs(y,{variant:"secondary",size:"sm",className:"text-xs h-7 gap-1 pr-6",onClick:()=>{p({ANTHROPIC_MODEL:l.default,ANTHROPIC_DEFAULT_OPUS_MODEL:l.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:l.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:l.haiku})},children:[e.jsx(me,{className:"w-3 h-3 fill-current"}),l.name]}),e.jsx(y,{variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-7 w-5 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:f=>{f.stopPropagation(),j(l.name)},disabled:h,children:e.jsx(Se,{className:"w-3 h-3"})})]},l.name)),e.jsxs(y,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1 border-primary/50 text-primary hover:bg-primary/10 hover:border-primary",onClick:g,children:[e.jsx(rs,{className:"w-3 h-3"}),"Custom"]})]})]}),e.jsx(Ae,{}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-2",children:"Model Mapping"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"Configure which models to use for each tier"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(V,{label:"Default Model",description:"Used when no specific tier is requested",value:t,onChange:l=>d("ANTHROPIC_MODEL",l),catalog:s,allModels:c}),e.jsx(V,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:i,onChange:l=>d("ANTHROPIC_DEFAULT_OPUS_MODEL",l),catalog:s,allModels:c}),e.jsx(V,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:r,onChange:l=>d("ANTHROPIC_DEFAULT_SONNET_MODEL",l),catalog:s,allModels:c}),e.jsx(V,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:u,onChange:l=>d("ANTHROPIC_DEFAULT_HAIKU_MODEL",l),catalog:s,allModels:c})]})]})]})}function $t({className:s,...a}){return e.jsx(Ns,{"data-slot":"checkbox",className:q("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",s),...a,children:e.jsx(ws,{"data-slot":"checkbox-indicator",className:"grid place-content-center text-current transition-none",children:e.jsx(B,{className:"size-3.5"})})})}function zt(s){const a=Math.max(0,Math.min(100,s));return a<=20?"bg-destructive":a<=50?"bg-yellow-500":"bg-green-500"}function Ge(s){if(!s)return"";try{const a=new Date(s),i=new Date().getTime()-a.getTime();if(i<0)return"just now";const r=Math.floor(i/(1e3*60)),u=Math.floor(i/(1e3*60*60)),c=Math.floor(i/(1e3*60*60*24));return c>0?`${c}d ago`:u>0?`${u}h ago`:r>0?`${r}m ago`:"just now"}catch{return""}}function Bt(s){if(!s)return!1;try{const a=new Date(s);return new Date().getTime()-a.getTime()<3600*1e3}catch{return!1}}function Qt({account:s,onSetDefault:a,onRemove:t,onPauseToggle:i,isRemoving:r,isPausingAccount:u,privacyMode:c,showQuota:p,selectable:d,selected:g,onSelectChange:j}){const{data:h}=Os(p),{data:n,isLoading:l}=Ds(s.provider,s.id,p),f=h?.accountStats?.[s.email||s.id]?.lastUsedAt,w=Bt(f),x=Rs(s.provider,n),A=Es(s.provider,n);return e.jsxs("div",{className:q("flex flex-col gap-2 p-3 rounded-lg border transition-colors overflow-hidden",s.isDefault?"border-primary/30 bg-primary/5":"border-border hover:bg-muted/30",s.paused&&"opacity-75",g&&"ring-2 ring-primary/50 bg-primary/5"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[d&&e.jsx("button",{type:"button",onClick:()=>j?.(!g),className:q("flex items-center justify-center w-5 h-5 rounded border-2 transition-colors shrink-0",g?"bg-primary border-primary text-primary-foreground":"border-muted-foreground/30 hover:border-primary/50"),"aria-label":g?"Deselect account":"Select account",children:g&&e.jsx(B,{className:"w-3 h-3"})}),i&&e.jsx(X,{children:e.jsxs(Y,{children:[e.jsx(Z,{asChild:!0,children:e.jsx(y,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:()=>i(!s.paused),disabled:u,children:u?e.jsx($,{className:"w-4 h-4 animate-spin"}):s.paused?e.jsx(os,{className:"w-4 h-4 text-emerald-500"}):e.jsx(he,{className:"w-4 h-4 text-muted-foreground hover:text-foreground"})})}),e.jsx(ee,{side:"top",children:s.paused?"Resume account":"Pause account"})]})}),e.jsxs("div",{className:"relative shrink-0",children:[e.jsx("div",{className:q("flex items-center justify-center w-8 h-8 rounded-full",s.isDefault?"bg-primary/10":"bg-muted"),children:e.jsx(te,{className:"w-4 h-4"})}),s.tier&&s.tier!=="unknown"&&s.tier!=="free"&&e.jsx("span",{className:q("absolute -bottom-0.5 -right-0.5 text-[7px] font-bold uppercase px-1 py-px rounded","ring-1 ring-background",s.tier==="ultra"?"bg-violet-500/20 text-violet-600 dark:bg-violet-500/30 dark:text-violet-300":"bg-yellow-500/20 text-yellow-700 dark:bg-yellow-500/25 dark:text-yellow-400"),children:s.tier==="ultra"?"U":"P"})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:q("font-medium text-sm truncate",c&&ce),children:s.email||s.id}),s.isDefault&&e.jsxs(G,{variant:"secondary",className:"text-[10px] h-4 px-1.5 gap-0.5",children:[e.jsx(me,{className:"w-2.5 h-2.5 fill-current"}),"Default"]}),s.paused&&e.jsxs(G,{variant:"outline",className:"text-[10px] h-4 px-1.5 border-yellow-500 text-yellow-600",children:[e.jsx(he,{className:"w-2 h-2 mr-0.5"}),"Paused"]})]}),s.provider==="agy"&&e.jsx("div",{className:"flex items-center gap-1.5 mt-1",children:s.projectId?e.jsx(X,{children:e.jsxs(Y,{children:[e.jsx(Z,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(ut,{className:"w-3 h-3","aria-hidden":"true"}),e.jsx("span",{className:q("font-mono max-w-[180px] truncate",c&&ce),title:s.projectId,children:s.projectId})]})}),e.jsx(ee,{side:"bottom",children:e.jsx("p",{className:"text-xs",children:"GCP Project ID (read-only)"})})]})}):e.jsx(X,{children:e.jsxs(Y,{children:[e.jsx(Z,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-amber-600 dark:text-amber-500",children:[e.jsx(mt,{className:"w-3 h-3","aria-label":"Warning"}),e.jsx("span",{children:"Project ID: N/A"})]})}),e.jsx(ee,{side:"bottom",className:"max-w-[250px]",children:e.jsxs("div",{className:"text-xs space-y-1",children:[e.jsx("p",{className:"font-medium text-amber-600",children:"Missing Project ID"}),e.jsx("p",{children:"This may cause errors. Remove the account and re-add it to fetch the project ID."})]})})]})})}),s.lastUsedAt&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground mt-0.5",children:[e.jsx(He,{className:"w-3 h-3"}),"Last used: ",new Date(s.lastUsedAt).toLocaleDateString()]})]})]}),e.jsxs(Is,{children:[e.jsx(_s,{asChild:!0,children:e.jsx(y,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",children:e.jsx(xt,{className:"w-4 h-4"})})}),e.jsxs(Ls,{align:"end",children:[!s.isDefault&&e.jsxs(Fe,{onClick:a,children:[e.jsx(me,{className:"w-4 h-4 mr-2"}),"Set as default"]}),e.jsxs(Fe,{className:"text-destructive focus:text-destructive",onClick:t,disabled:r,children:[e.jsx(ls,{className:"w-4 h-4 mr-2"}),r?"Removing...":"Remove account"]})]})]})]}),p&&e.jsx("div",{className:"pl-11",children:l?e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx($,{className:"w-3 h-3 animate-spin"}),e.jsx("span",{children:"Loading quota..."})]}):x!==null?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"flex items-center gap-1.5 text-xs",children:w?e.jsxs(e.Fragment,{children:[e.jsx(pt,{className:"w-3 h-3 text-emerald-500"}),e.jsxs("span",{className:"text-emerald-600 dark:text-emerald-400",children:["Active · ",Ge(f)]})]}):f?e.jsxs(e.Fragment,{children:[e.jsx(He,{className:"w-3 h-3 text-muted-foreground"}),e.jsxs("span",{className:"text-muted-foreground",children:["Last used ",Ge(f)]})]}):e.jsxs(e.Fragment,{children:[e.jsx(ht,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:"Not used yet"})]})}),e.jsx(X,{children:e.jsxs(Y,{children:[e.jsx(Z,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Fs,{value:Math.max(0,Math.min(100,x)),className:"h-2 flex-1",indicatorClassName:zt(x)}),e.jsxs("span",{className:"text-xs font-medium w-10 text-right",children:[x,"%"]})]})}),e.jsx(ee,{side:"bottom",className:"max-w-xs",children:n&&e.jsx(Us,{quota:n,resetTime:A})})]})})]}):n?.needsReauth?e.jsx(X,{children:e.jsxs(Y,{children:[e.jsx(Z,{asChild:!0,children:e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs(G,{variant:"outline",className:"text-[10px] h-5 px-2 gap-1 border-amber-500/50 text-amber-600 dark:text-amber-400",children:[e.jsx(gt,{className:"w-3 h-3"}),"Reauth"]})})}),e.jsx(ee,{side:"bottom",className:"max-w-[220px]",children:e.jsx("p",{className:"text-xs",children:n.error?.includes("No refresh token")?"No refresh token available. Remove and re-add account to fix.":n.error?.includes("refresh")||n.error?.includes("Invalid")?`Auto-refresh failed: ${n.error}`:`Token issue: ${n.error||"Re-authenticate required"}`})})]})}):n?.error||n&&!n.success?e.jsx(X,{children:e.jsxs(Y,{children:[e.jsx(Z,{asChild:!0,children:e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs(G,{variant:"outline",className:"text-[10px] h-5 px-2 gap-1 border-muted-foreground/50 text-muted-foreground",children:[e.jsx(ft,{className:"w-3 h-3"}),"N/A"]})})}),e.jsx(ee,{side:"bottom",children:e.jsx("p",{className:"text-xs",children:n?.error||"Quota information unavailable"})})]})}):null})]})}function Vt({selectedCount:s,onPauseSelected:a,onResumeSelected:t,onClearSelection:i,isPausing:r,isResuming:u}){if(s<1)return null;const c=r||u;return e.jsxs("div",{className:"flex items-center gap-3 p-2 bg-muted/50 rounded-lg border mt-2",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[s," selected"]}),e.jsx(y,{variant:"ghost",size:"sm",className:"text-xs h-6 px-2",onClick:i,disabled:c,children:"Clear"}),e.jsxs("div",{className:"flex gap-2 ml-auto",children:[e.jsxs(y,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:a,disabled:c,children:[r?e.jsx($,{className:"w-3 h-3 animate-spin"}):e.jsx(he,{className:"w-3 h-3"}),"Pause Selected"]}),e.jsxs(y,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:t,disabled:c,children:[u?e.jsx($,{className:"w-3 h-3 animate-spin"}):e.jsx(os,{className:"w-3 h-3"}),"Resume Selected"]})]})]})}function Jt({accounts:s,onAddAccount:a,onSetDefault:t,onRemoveAccount:i,onPauseToggle:r,onSoloMode:u,onBulkPause:c,onBulkResume:p,isRemovingAccount:d,isPausingAccount:g,isSoloingAccount:j,isBulkPausing:h,isBulkResuming:n,privacyMode:l,showQuota:f,isKiro:w,kiroNoIncognito:x,onKiroNoIncognitoChange:A,kiroSettingsLoading:I}){const[E,O]=m.useState(new Set),D=m.useMemo(()=>new Set(s.map(C=>C.id)),[s]),v=m.useMemo(()=>new Set([...E].filter(C=>D.has(C))),[E,D]),T=!!(c&&p),b=v.size,N=s.length>0&&v.size===s.length,R=v.size>0&&v.size<s.length,P=m.useCallback(C=>{O(L=>{const K=new Set(L);return K.has(C)?K.delete(C):K.add(C),K})},[]),k=m.useCallback(()=>{O(new Set(s.map(C=>C.id)))},[s]),F=m.useCallback(()=>{O(new Set)},[]),H=m.useCallback(()=>{N?F():k()},[N,k,F]),z=m.useCallback(()=>{c&&v.size>0&&(c(Array.from(v)),O(new Set))},[c,v]),S=m.useCallback(()=>{p&&v.size>0&&(p(Array.from(v)),O(new Set))},[p,v]);return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("h3",{className:"text-sm font-medium flex items-center gap-2",children:[T&&s.length>0&&e.jsx($t,{checked:N,onCheckedChange:H,"aria-label":"Select all accounts",className:R?"data-[state=checked]:bg-primary/50":"",...R?{"data-state":"indeterminate"}:{}}),e.jsx(te,{className:"w-4 h-4"}),"Accounts",s.length>0&&e.jsx(G,{variant:"secondary",className:"text-xs",children:s.length})]}),e.jsxs(y,{variant:"default",size:"sm",className:"h-7 text-xs gap-1",onClick:a,children:[e.jsx(rs,{className:"w-3 h-3"}),"Add"]})]}),T&&b>0&&e.jsx(Vt,{selectedCount:b,onPauseSelected:z,onResumeSelected:S,onClearSelection:F,isPausing:!!h,isResuming:!!n}),s.length>0?e.jsx("div",{className:"space-y-2",children:s.map(C=>e.jsx(Qt,{account:C,onSetDefault:()=>t(C.id),onRemove:()=>i(C.id),onPauseToggle:r?L=>r(C.id,L):void 0,onSoloMode:u?()=>u(C.id):void 0,isRemoving:d,isPausingAccount:g,isSoloingAccount:j,privacyMode:l,showQuota:f,selectable:T,selected:v.has(C.id),onSelectChange:()=>P(C.id)},C.id))}):e.jsxs("div",{className:"py-6 text-center text-muted-foreground bg-muted/30 rounded-lg border border-dashed",children:[e.jsx(te,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No accounts connected"}),e.jsx("p",{className:"text-xs opacity-70",children:"Add an account to get started"})]}),w&&A&&e.jsx("div",{className:"mt-3 pt-3 border-t border-dashed",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(is,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Use incognito"})]}),e.jsx(Nt,{checked:!x,onCheckedChange:C=>A(!C),disabled:I,className:"scale-90"})]})})]})}function Wt({provider:s,catalog:a,savedPresets:t,currentModel:i,opusModel:r,sonnetModel:u,haikuModel:c,providerModels:p,onApplyPreset:d,onUpdateEnvValue:g,onOpenCustomPreset:j,onDeletePreset:h,isDeletePending:n,accounts:l,onAddAccount:f,onSetDefault:w,onRemoveAccount:x,onPauseToggle:A,onSoloMode:I,onBulkPause:E,onBulkResume:O,isRemovingAccount:D,isPausingAccount:v,isSoloingAccount:T,isBulkPausing:b,isBulkResuming:N,privacyMode:R,isRemoteMode:P}){const k=s==="kiro",[F,H]=m.useState(!0),[z,S]=m.useState(!0),[C,L]=m.useState(!1),K=m.useCallback(async()=>{if(k)try{S(!0);const M=(await le.config.get()).cliproxy;H(M?.kiro_no_incognito??!0)}catch{H(!0)}finally{S(!1)}},[k]),ae=m.useCallback(async o=>{H(o),L(!0);try{const M=await le.config.get(),W=M.cliproxy??{};await le.config.update({...M,cliproxy:{...W,kiro_no_incognito:o}})}catch{H(!o)}finally{L(!1)}},[]);return m.useEffect(()=>{K()},[K]),e.jsx(ye,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsx(Gt,{catalog:a,savedPresets:t,currentModel:i,opusModel:r,sonnetModel:u,haikuModel:c,providerModels:p,onApplyPreset:d,onUpdateEnvValue:g,onOpenCustomPreset:j,onDeletePreset:h,isDeletePending:n}),e.jsx(Ae,{}),e.jsx(Jt,{accounts:l,onAddAccount:f,onSetDefault:w,onRemoveAccount:x,onPauseToggle:A,onSoloMode:I,onBulkPause:E,onBulkResume:O,isRemovingAccount:D,isPausingAccount:v,isSoloingAccount:T,isBulkPausing:b,isBulkResuming:N,privacyMode:R,showQuota:qs.includes(s)&&!P,isKiro:k,kiroNoIncognito:F,onKiroNoIncognitoChange:ae,kiroSettingsLoading:z||C})]})})}function $e({provider:s,displayName:a,authStatus:t,catalog:i,logoProvider:r,baseProvider:u,isRemoteMode:c,port:p,onAddAccount:d,onSetDefault:g,onRemoveAccount:j,onPauseToggle:h,onSoloMode:n,onBulkPause:l,onBulkResume:f,isRemovingAccount:w,isPausingAccount:x,isSoloingAccount:A,isBulkPausing:I,isBulkResuming:E}){const[O,D]=m.useState(!1),{privacyMode:v}=Ze(),{data:T}=Hs(),{data:b}=Ks(s),N=Gs(),R=$s(),P=b?.presets||[],k=u||s,F=m.useMemo(()=>{if(!T?.models)return[];const Q={gemini:["google"],agy:["antigravity"],codex:["openai"],qwen:["alibaba","qwen"],iflow:["iflow"],kiro:["kiro","aws"],ghcp:["github","copilot"]}[k.toLowerCase()]||[k.toLowerCase()];return T.models.filter(Ee=>Q.some(vs=>Ee.owned_by.toLowerCase().includes(vs)))},[T,k]),{data:H,isLoading:z,refetch:S,rawJsonContent:C,rawJsonEdits:L,isRawJsonValid:K,hasChanges:ae,currentModel:o,opusModel:M,sonnetModel:W,haikuModel:Me,handleRawJsonChange:ds,updateEnvValue:us,updateEnvValues:Te,saveMutation:Oe,conflictDialog:ms,handleConflictResolve:De,missingRequiredFields:xs}=_t(s),ps=t.accounts||[],{data:hs}=ze({queryKey:["auth-tokens-raw"],queryFn:async()=>{const U=await fetch("/api/settings/auth/tokens/raw");return U.ok?U.json():{apiKey:{value:"ccs-internal-managed"}}},staleTime:6e4}),Re=hs?.apiKey?.value??"ccs-internal-managed",gs=U=>{Te({ANTHROPIC_BASE_URL:`http://127.0.0.1:${p??ge}/api/provider/${s}`,ANTHROPIC_AUTH_TOKEN:Re,...U}),_.success(`Applied "${U.ANTHROPIC_MODEL?.split("/").pop()||"preset"}" preset`)},fs=(U,Q)=>{Te({ANTHROPIC_BASE_URL:`http://127.0.0.1:${p??ge}/api/provider/${s}`,ANTHROPIC_AUTH_TOKEN:Re,ANTHROPIC_MODEL:U.default,ANTHROPIC_DEFAULT_OPUS_MODEL:U.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:U.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:U.haiku}),_.success(`Applied ${Q?`"${Q}"`:"custom"} preset`),D(!1)},js=(U,Q)=>{if(!Q){_.error("Please enter a preset name to save");return}N.mutate({profile:s,data:{name:Q,...U}}),D(!1)};return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(Kt,{provider:s,displayName:a,logoProvider:r,data:H,isLoading:z,hasChanges:ae,isRawJsonValid:K,isSaving:Oe.isPending,isRemoteMode:c,port:p,onRefetch:S,onSave:()=>Oe.mutate()}),z?e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsx($,{className:"w-8 h-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:"Loading settings..."})]}):e.jsxs("div",{className:"flex-1 grid grid-cols-[40%_60%] divide-x overflow-hidden",children:[e.jsx("div",{className:"flex flex-col overflow-hidden bg-muted/5",children:e.jsxs(zs,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(Bs,{className:"w-full",children:[e.jsx(Ue,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(Ue,{value:"info",className:"flex-1",children:"Info & Usage"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsx(qe,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(Wt,{provider:s,catalog:i,savedPresets:P,currentModel:o,opusModel:M,sonnetModel:W,haikuModel:Me,providerModels:F,onApplyPreset:gs,onUpdateEnvValue:us,onOpenCustomPreset:()=>D(!0),onDeletePreset:U=>R.mutate({profile:s,name:U}),isDeletePending:R.isPending,accounts:ps,onAddAccount:d,onSetDefault:g,onRemoveAccount:j,onPauseToggle:h,onSoloMode:n,onBulkPause:l,onBulkResume:f,isRemovingAccount:w,isPausingAccount:x,isSoloingAccount:A,isBulkPausing:I,isBulkResuming:E,privacyMode:v,isRemoteMode:c})}),e.jsx(qe,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(Ft,{provider:s,displayName:a,data:H,authStatus:t})})]})]})}),e.jsxs("div",{className:"flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-2 bg-muted/30 border-b flex items-center gap-2 shrink-0 h-[45px]",children:[e.jsx(jt,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Raw Configuration (JSON)"})]}),e.jsx(Qs,{rawJsonContent:C,isRawJsonValid:K,rawJsonEdits:L,onRawJsonChange:ds,profileEnv:H?.settings?.env,missingRequiredFields:xs})]})]}),e.jsx(vt,{open:ms,title:"File Modified Externally",description:"This settings file was modified by another process. Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>De(!0),onCancel:()=>De(!1)}),e.jsx(Lt,{open:O,onClose:()=>D(!1),currentValues:{default:o||"",opus:M||"",sonnet:W||"",haiku:Me||""},onApply:fs,onSave:js,isSaving:N.isPending,catalog:i,allModels:F})]})}function Xt({status:s,isSelected:a,onSelect:t}){const i=s.accounts?.length||0;return e.jsxs("button",{className:q("w-full flex items-center gap-3 px-3 py-2.5 rounded-lg transition-colors cursor-pointer text-left",a?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:t,children:[e.jsx(Pe,{provider:s.provider,size:"md"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm truncate",children:s.displayName}),i>0&&e.jsx(G,{variant:"secondary",className:"text-[10px] h-4 px-1",children:i})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:s.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(B,{className:"w-3 h-3 text-green-600"}),e.jsx("span",{className:"text-xs text-green-600",children:"Connected"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Se,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Not connected"})]})})]})]})}function Yt({variant:s,parentAuth:a,isSelected:t,onSelect:i,onDelete:r,isDeleting:u}){return e.jsxs("button",{className:q("group w-full flex items-center gap-3 px-3 py-2 rounded-lg transition-colors cursor-pointer text-left pl-6",t?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:i,children:[e.jsxs("div",{className:"relative",children:[e.jsx(Pe,{provider:s.provider,size:"sm"}),e.jsx(cs,{className:"w-2.5 h-2.5 absolute -bottom-0.5 -right-0.5 text-muted-foreground"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm truncate",children:s.name}),e.jsx(G,{variant:"outline",className:"text-[9px] h-4 px-1",children:"variant"})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:a?.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(B,{className:"w-3 h-3 text-green-600"}),e.jsxs("span",{className:"text-xs text-muted-foreground truncate",children:["via ",s.provider]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Se,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Parent not connected"})]})})]}),e.jsx(y,{variant:"ghost",size:"icon",className:"h-6 w-6 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:c=>{c.stopPropagation(),r()},disabled:u,children:e.jsx(ls,{className:"w-3 h-3"})})]})}function Zt({onSetup:s}){return e.jsx("div",{className:"flex-1 flex items-center justify-center bg-muted/20",children:e.jsxs("div",{className:"text-center max-w-md px-8",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-muted flex items-center justify-center mx-auto mb-6",children:e.jsx(xe,{className:"w-8 h-8 text-muted-foreground"})}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"CCS Profile Manager"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Manage OAuth authentication, account preferences, and model selection for CLIProxy providers. Configure how CCS routes requests to different AI backends."}),e.jsxs("p",{className:"text-xs text-muted-foreground mb-6",children:["For live usage stats and real-time monitoring, visit the"," ",e.jsx("a",{href:"/cliproxy/control-panel",className:"text-primary hover:underline",children:"Control Panel"}),"."]}),e.jsxs(y,{onClick:s,className:"gap-2",children:[e.jsx(re,{className:"w-4 h-4"}),"Quick Setup"]})]})})}function xa(){const s=je(),{data:a,isLoading:t}=Ye(),{data:i,isFetching:r}=Vs(),{data:u}=Js(),c=Ws(),p=Xs(),d=Ys(),g=Zs(),j=et(),h=st(),n=tt(),l=at(),[f,w]=m.useState(()=>typeof window<"u"?localStorage.getItem("cliproxy-selected-provider"):null),[x,A]=m.useState(null),[I,E]=m.useState(!1),[O,D]=m.useState(null),v=m.useMemo(()=>a?.authStatus||[],[a?.authStatus]),T=a?.source==="remote",b=m.useMemo(()=>i?.variants||[],[i?.variants]),N=o=>{w(o),o&&localStorage.setItem("cliproxy-selected-provider",o)},R=m.useMemo(()=>x?null:f&&v.some(o=>o.provider===f)?f:v.length>0&&(v.find(M=>(M.accounts?.length||0)>0)?.provider||v[0]?.provider)||null,[f,x,v]),P=v.find(o=>o.provider===R),k=b.find(o=>o.name===x),F=k?v.find(o=>o.provider===k.provider):void 0,H=()=>{s.invalidateQueries({queryKey:["cliproxy"]}),s.invalidateQueries({queryKey:["cliproxy-auth"]})},z=(o,M,W)=>{d.isPending||g.isPending||(W?d.mutate({provider:o,accountId:M}):g.mutate({provider:o,accountId:M}))},S=(o,M)=>{j.isPending||j.mutate({provider:o,accountId:M})},C=(o,M)=>{h.isPending||h.mutate({provider:o,accountIds:M})},L=(o,M)=>{n.isPending||n.mutate({provider:o,accountIds:M})},K=o=>{N(o),A(null)},ae=o=>{A(o),N(null)};return e.jsxs("div",{className:"h-[calc(100vh-100px)] flex",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col bg-muted/30",children:[e.jsxs("div",{className:"p-4 border-b bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xe,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:u?.backendLabel??"CLIProxy"})]}),e.jsx(y,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:H,disabled:r,children:e.jsx(ke,{className:q("w-4 h-4",r&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"CCS-level account management"}),e.jsxs(y,{variant:"default",size:"sm",className:"w-full gap-2",onClick:()=>E(!0),children:[e.jsx(re,{className:"w-4 h-4"}),"Quick Setup"]})]}),e.jsx(ye,{className:"flex-1",children:e.jsxs("div",{className:"p-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide px-3 py-2",children:"Providers"}),t?e.jsx("div",{className:"space-y-2 px-2",children:[1,2,3,4].map(o=>e.jsx(nt,{className:"h-14 w-full rounded-lg"},o))}):e.jsx("div",{className:"space-y-1",children:v.map(o=>e.jsx(Xt,{status:o,isSelected:R===o.provider,onSelect:()=>K(o.provider)},o.provider))}),b.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide px-3 py-2 mt-4 flex items-center gap-1.5",children:[e.jsx(cs,{className:"w-3 h-3"}),"Variants"]}),e.jsx("div",{className:"space-y-1",children:b.map(o=>e.jsx(Yt,{variant:o,parentAuth:v.find(M=>M.provider===o.provider),isSelected:x===o.name,onSelect:()=>ae(o.name),onDelete:()=>l.mutate(o.name),isDeleting:l.isPending},o.name))})]})]})}),e.jsx("div",{className:"p-3 border-t",children:e.jsx(wt,{})}),e.jsx("div",{className:"p-3 border-t bg-background text-xs text-muted-foreground",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{children:[v.length," provider",v.length!==1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(B,{className:"w-3 h-3 text-green-600"}),v.filter(o=>o.authenticated).length," connected"]})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-background",children:k&&F?e.jsx($e,{provider:k.name,displayName:`${k.name} (${k.provider} variant)`,authStatus:F,catalog:ie[k.provider],logoProvider:k.provider,baseProvider:k.provider,isRemoteMode:T,port:k.port,onAddAccount:()=>D({provider:k.provider,displayName:F.displayName,isFirstAccount:(F.accounts?.length||0)===0}),onSetDefault:o=>c.mutate({provider:k.provider,accountId:o}),onRemoveAccount:o=>p.mutate({provider:k.provider,accountId:o}),onPauseToggle:(o,M)=>z(k.provider,o,M),onSoloMode:o=>S(k.provider,o),onBulkPause:o=>C(k.provider,o),onBulkResume:o=>L(k.provider,o),isRemovingAccount:p.isPending,isPausingAccount:d.isPending||g.isPending,isSoloingAccount:j.isPending,isBulkPausing:h.isPending,isBulkResuming:n.isPending}):P?e.jsx($e,{provider:P.provider,displayName:P.displayName,authStatus:P,catalog:ie[P.provider],isRemoteMode:T,onAddAccount:()=>D({provider:P.provider,displayName:P.displayName,isFirstAccount:(P.accounts?.length||0)===0}),onSetDefault:o=>c.mutate({provider:P.provider,accountId:o}),onRemoveAccount:o=>p.mutate({provider:P.provider,accountId:o}),onPauseToggle:(o,M)=>z(P.provider,o,M),onSoloMode:o=>S(P.provider,o),onBulkPause:o=>C(P.provider,o),onBulkResume:o=>L(P.provider,o),isRemovingAccount:p.isPending,isPausingAccount:d.isPending||g.isPending,isSoloingAccount:j.isPending,isBulkPausing:h.isPending,isBulkResuming:n.isPending}):e.jsx(Zt,{onSetup:()=>E(!0)})}),e.jsx(Mt,{open:I,onClose:()=>E(!1)}),e.jsx(Rt,{open:O!==null,onClose:()=>D(null),provider:O?.provider||"",displayName:O?.displayName||"",isFirstAccount:O?.isFirstAccount||!1})]})}export{xa as CliproxyPage};
|