@kaitranntt/ccs 6.7.0-dev.3 → 6.7.0-dev.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cliproxy/cliproxy-executor.d.ts.map +1 -1
- package/dist/cliproxy/cliproxy-executor.js +59 -48
- package/dist/cliproxy/cliproxy-executor.js.map +1 -1
- package/dist/cliproxy/index.d.ts +4 -0
- package/dist/cliproxy/index.d.ts.map +1 -1
- package/dist/cliproxy/index.js +8 -1
- package/dist/cliproxy/index.js.map +1 -1
- package/dist/cliproxy/proxy-detector.d.ts +70 -0
- package/dist/cliproxy/proxy-detector.d.ts.map +1 -0
- package/dist/cliproxy/proxy-detector.js +177 -0
- package/dist/cliproxy/proxy-detector.js.map +1 -0
- package/dist/cliproxy/service-manager.d.ts.map +1 -1
- package/dist/cliproxy/service-manager.js +113 -86
- package/dist/cliproxy/service-manager.js.map +1 -1
- package/dist/cliproxy/startup-lock.d.ts +57 -0
- package/dist/cliproxy/startup-lock.d.ts.map +1 -0
- package/dist/cliproxy/startup-lock.js +216 -0
- package/dist/cliproxy/startup-lock.js.map +1 -0
- package/dist/ui/assets/{accounts-BMWLqlfE.js → accounts-p1_nf0Jy.js} +1 -1
- package/dist/ui/assets/{analytics-HpEEt606.js → analytics-D1k2nYcF.js} +1 -1
- package/dist/ui/assets/{api-BHNxPjjt.js → api-D9VVmZ1j.js} +1 -1
- package/dist/ui/assets/{card-DQcAIoan.js → card-CCDc-Mx9.js} +1 -1
- package/dist/ui/assets/cliproxy-CTt_Nsft.js +1 -0
- package/dist/ui/assets/{code-editor-DxImO7VE.js → code-editor-Br9x-r-E.js} +1 -1
- package/dist/ui/assets/{copilot-CgYR2YcH.js → copilot-C6F8PT_L.js} +3 -3
- package/dist/ui/assets/{health-DJRHl0eA.js → health-DiAvJaSn.js} +1 -1
- package/dist/ui/assets/{index-DlEL4vYD.js → index-ByU8ZhED.js} +15 -15
- package/dist/ui/assets/{settings-DAj4fuUJ.js → settings-CEomZLGl.js} +1 -1
- package/dist/ui/assets/{shared-DJmTnvUs.js → shared-BfYhSN4-.js} +1 -1
- package/dist/ui/assets/{switch-D391CjDF.js → switch-CMk95lwf.js} +1 -1
- package/dist/ui/index.html +1 -1
- package/package.json +1 -1
- package/dist/ui/assets/cliproxy-BXOWLqyH.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-DFHQr9A5.js";import{k as as,r}from"./react-vendor-FspHSO0w.js";import{a1 as ie,a2 as rs,a3 as Ge,V as ls,W as ns,X as me,a4 as os,B as w,a5 as be,a6 as fe,i as ge,I as G,z as cs,A as ds,E as is,F as ms,G as _e}from"./index-DlEL4vYD.js";import{S as V}from"./switch-D391CjDF.js";import{CodeEditor as xs}from"./code-editor-DxImO7VE.js";import{J as k,am as us,z as hs,a6 as ps,k as bs,an as Fe,j as fs,o as gs,ac as je,l as le,t as xe,x as ue,y as he,D as pe,N as js,V as vs,ao as Ns,ap as ze,e as ys,W as ws}from"./icons-BOsxPbiD.js";import"./tanstack-C4gT2P7V.js";import"./notifications-B2Pz7lik.js";import"./utils-CzKF5WmX.js";import"./form-utils-BuXDJb0w.js";import"./code-highlight-BoHWVYut.js";function Ms(){const[t]=as(),x=t.get("tab"),o=x==="globalenv"?"globalenv":x==="proxy"?"proxy":"websearch",[u,v]=r.useState(o),[l,h]=r.useState(null),[d,C]=r.useState(!0),[_,N]=r.useState(!1),[S,f]=r.useState(null),[F,c]=r.useState(!1),[E,W]=r.useState(null),[U,O]=r.useState(!0),[y,g]=r.useState(null),[T,z]=r.useState(!1),[D,M]=r.useState(!1),[I,L]=r.useState(""),[j,Y]=r.useState(""),[K,X]=r.useState(!1),[P,A]=r.useState(!1),[Q,Z]=r.useState(!1),[p,H]=r.useState(null),[ne,ee]=r.useState(!0),[n,$]=r.useState(!1),[se,te]=r.useState(null),[Me,ve]=r.useState(!1),[oe,Ne]=r.useState(""),[ye,we]=r.useState(""),[R,ae]=r.useState(null),[$e,ke]=r.useState(!0),[Be,Ce]=r.useState(!1),[Ve,B]=r.useState(null),[Oe,Se]=r.useState(!1),[De,ce]=r.useState(null),[He,Ee]=r.useState(!1);r.useEffect(()=>{Pe(),Te(),q(),Ie(),Le()},[]),r.useEffect(()=>{l&&(L(l.providers?.gemini?.model??"gemini-2.5-flash"),Y(l.providers?.opencode?.model??"opencode/grok-code"))},[l]);const Pe=async()=>{try{C(!0),f(null);const s=await fetch("/api/websearch");if(!s.ok)throw new Error("Failed to load WebSearch config");const a=await s.json();h(a)}catch(s){f(s.message)}finally{C(!1)}},Te=async()=>{try{O(!0);const s=await fetch("/api/websearch/status");if(!s.ok)throw new Error("Failed to load status");const a=await s.json();W(a)}catch(s){console.error("Failed to fetch WebSearch status:",s)}finally{O(!1)}},q=async()=>{try{z(!0);const s=await fetch("/api/config/raw");if(!s.ok){g(null);return}const a=await s.text();g(a)}catch(s){console.error("Failed to fetch raw config:",s),g(null)}finally{z(!1)}},Ie=async()=>{try{ee(!0),te(null);const s=await fetch("/api/global-env");if(!s.ok)throw new Error("Failed to load Global Env config");const a=await s.json();H(a)}catch(s){te(s.message)}finally{ee(!1)}},Le=async()=>{try{ke(!0),B(null);const s=await ie.cliproxyServer.get();ae(s)}catch(s){B(s.message)}finally{ke(!1)}},We=async()=>{if(y)try{await navigator.clipboard.writeText(y),M(!0),setTimeout(()=>M(!1),2e3)}catch(s){console.error("Failed to copy:",s)}},Ue=()=>{const s=l?.providers||{},a=s.gemini?.enabled??!1,i=s.grok?.enabled??!1,b=s.opencode?.enabled??!1;J({enabled:!a||i||b,providers:{...s,gemini:{...s.gemini,enabled:!a}}})},J=async s=>{if(!l)return;const a={...l,...s};h(a);try{N(!0),f(null);const i=await fetch("/api/websearch",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!i.ok){const m=await i.json();throw new Error(m.error||"Failed to save")}const b=await i.json();h(b.websearch),c(!0),setTimeout(()=>c(!1),1500),fetch("/api/config/raw").then(m=>m.ok?m.text():null).then(m=>m&&g(m)).catch(()=>{})}catch(i){h(l),f(i.message)}finally{N(!1)}},de=l?.providers?.gemini?.enabled??!1,Ae=l?.providers?.grok?.enabled??!1,Re=l?.providers?.opencode?.enabled??!1,Ye=()=>{const s=l?.providers||{},a=s.grok?.enabled??!1;J({enabled:de||!a||Re,providers:{...s,grok:{...s.grok,enabled:!a}}})},qe=()=>{const s=l?.providers||{},a=s.opencode?.enabled??!1;J({enabled:de||Ae||!a,providers:{...s,opencode:{...s.opencode,enabled:!a}}})},Je=()=>{const s=l?.providers?.gemini?.model??"gemini-2.5-flash";if(I!==s){const a=l?.providers||{};J({providers:{...a,gemini:{...a.gemini,model:I}}})}},Ke=()=>{const s=l?.providers?.opencode?.model??"opencode/grok-code";if(j!==s){const a=l?.providers||{};J({providers:{...a,opencode:{...a.opencode,model:j}}})}},re=async s=>{if(!p)return;const a={...p,...s};H(a);try{$(!0),te(null);const i=await fetch("/api/global-env",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!i.ok){const m=await i.json();throw new Error(m.error||"Failed to save")}const b=await i.json();H(b.config),ve(!0),setTimeout(()=>ve(!1),1500),fetch("/api/config/raw").then(m=>m.ok?m.text():null).then(m=>m&&g(m)).catch(()=>{})}catch(i){H(p),te(i.message)}finally{$(!1)}},Xe=()=>{re({enabled:!p?.enabled})},Qe=()=>{if(!oe.trim()||!p)return;const s={...p.env,[oe.trim()]:ye};re({env:s}),Ne(""),we("")},Ze=s=>{if(!p)return;const a={...p.env};delete a[s],re({env:a})},es=(s,a)=>{if(!p)return;const i={...p.env,[s]:a};re({env:i})},ss=async s=>{if(!R)return;const a={remote:{...R.remote,...s.remote},fallback:{...R.fallback,...s.fallback},local:{...R.local,...s.local}};ae(a),ce(null);try{Ce(!0),B(null);const i=await ie.cliproxyServer.update(s);ae(i),Se(!0),setTimeout(()=>Se(!1),1500),fetch("/api/config/raw").then(b=>b.ok?b.text():null).then(b=>b&&g(b)).catch(()=>{})}catch(i){ae(R),B(i.message)}finally{Ce(!1)}},ts=async()=>{if(!R)return;const{host:s,port:a,protocol:i,auth_token:b}=R.remote;if(!s){B("Host is required");return}try{Ee(!0),B(null),ce(null);const m=await ie.cliproxyServer.test({host:s,port:a||void 0,protocol:i,authToken:b||void 0});ce(m)}catch(m){B(m.message)}finally{Ee(!1)}};return d?e.jsx("div",{className:"h-[calc(100vh-100px)] 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",{className:"text-lg",children:"Loading configuration..."})]})}):e.jsx("div",{className:"h-[calc(100vh-100px)]",children:e.jsxs(rs,{direction:"horizontal",className:"h-full",children:[e.jsx(Ge,{defaultSize:40,minSize:30,maxSize:55,children:e.jsxs("div",{className:"h-full border-r flex flex-col bg-muted/30 relative",children:[e.jsx("div",{className:"p-5 border-b bg-background",children:e.jsx(ls,{value:u,onValueChange:s=>v(s),children:e.jsxs(ns,{className:"w-full",children:[e.jsxs(me,{value:"websearch",className:"flex-1 gap-2",children:[e.jsx(us,{className:"w-4 h-4"}),"WebSearch"]}),e.jsxs(me,{value:"globalenv",className:"flex-1 gap-2",children:[e.jsx(hs,{className:"w-4 h-4"}),"Global Env"]}),e.jsxs(me,{value:"proxy",className:"flex-1 gap-2",children:[e.jsx(ps,{className:"w-4 h-4"}),"Proxy"]})]})})}),u==="websearch"?e.jsx(ks,{config:l,status:E,statusLoading:U,saving:_,error:S,success:F,isGeminiEnabled:de,isGrokEnabled:Ae,isOpenCodeEnabled:Re,geminiModelInput:I,opencodeModelInput:j,showGeminiHint:K,showOpencodeHint:P,showGrokHint:Q,setGeminiModelInput:L,setOpencodeModelInput:Y,setShowGeminiHint:X,setShowOpencodeHint:A,setShowGrokHint:Z,toggleGemini:Ue,toggleGrok:Ye,toggleOpenCode:qe,saveGeminiModel:Je,saveOpencodeModel:Ke,fetchStatus:Te,fetchConfig:Pe,fetchRawConfig:q,loading:d}):u==="globalenv"?e.jsx(Cs,{config:p,loading:ne,saving:n,error:se,success:Me,newEnvKey:oe,newEnvValue:ye,setNewEnvKey:Ne,setNewEnvValue:we,toggleGlobalEnv:Xe,addEnvVar:Qe,removeEnvVar:Ze,updateEnvValue:es,fetchGlobalEnvConfig:Ie,fetchRawConfig:q}):e.jsx(Ss,{config:R,loading:$e,saving:Be,error:Ve,success:Oe,testResult:De,testing:He,saveCliproxyServerConfig:ss,handleTestConnection:ts,fetchCliproxyServerConfig:Le,fetchRawConfig:q})]})}),e.jsx(os,{className:"w-2 bg-border hover:bg-primary/20 transition-colors cursor-col-resize flex items-center justify-center group",children:e.jsx(bs,{className:"w-3 h-3 text-muted-foreground group-hover:text-primary"})}),e.jsx(Ge,{defaultSize:60,minSize:35,children:e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"p-4 border-b bg-background flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Fe,{className:"w-5 h-5 text-primary"}),e.jsxs("div",{children:[e.jsx("h2",{className:"font-semibold",children:"config.yaml"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"~/.ccs/config.yaml"})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(w,{variant:"outline",size:"sm",onClick:We,disabled:!y,children:D?e.jsxs(e.Fragment,{children:[e.jsx(fs,{className:"w-4 h-4 mr-1"}),"Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(gs,{className:"w-4 h-4 mr-1"}),"Copy"]})}),e.jsx(w,{variant:"outline",size:"sm",onClick:q,disabled:T,children:e.jsx(k,{className:`w-4 h-4 ${T?"animate-spin":""}`})})]})]}),e.jsx("div",{className:"flex-1 overflow-auto",children:T?e.jsxs("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:[e.jsx(k,{className:"w-5 h-5 animate-spin mr-2"}),"Loading..."]}):y?e.jsx(xs,{value:y,onChange:()=>{},language:"yaml",readonly:!0,minHeight:"auto",className:"min-h-full"}):e.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Fe,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),e.jsx("p",{children:"Config file not found"}),e.jsx("code",{className:"text-sm bg-muted px-2 py-1 rounded mt-2 inline-block",children:"ccs migrate"})]})})})]})})]})})}function ks({status:t,statusLoading:x,saving:o,error:u,success:v,isGeminiEnabled:l,isGrokEnabled:h,isOpenCodeEnabled:d,geminiModelInput:C,opencodeModelInput:_,showGeminiHint:N,showOpencodeHint:S,showGrokHint:f,setGeminiModelInput:F,setOpencodeModelInput:c,setShowGeminiHint:E,setShowOpencodeHint:W,setShowGrokHint:U,toggleGemini:O,toggleGrok:y,toggleOpenCode:g,saveGeminiModel:T,saveOpencodeModel:z,fetchStatus:D,fetchConfig:M,fetchRawConfig:I,loading:L}){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 ${u||v?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[u&&e.jsxs(be,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(je,{className:"h-4 w-4"}),e.jsx(fe,{children:u})]}),v&&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(le,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:"Saved"})]})]}),e.jsx(ge,{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:l?"WebSearch enabled":"WebSearch disabled"}),x?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Checking status..."}):t?.readiness?e.jsx("p",{className:"text-sm text-muted-foreground",children:t.readiness.message}):null]}),e.jsx(w,{variant:"ghost",size:"sm",onClick:D,disabled:x,children:e.jsx(k,{className:`w-4 h-4 ${x?"animate-spin":""}`})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Providers"}),e.jsxs("div",{className:`rounded-lg border transition-colors ${l?"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(xe,{className:`w-5 h-5 ${l?"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:"gemini"}),e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-green-500/10 text-green-600 font-medium",children:"FREE"}),t?.geminiCli?.installed?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:"Google Gemini CLI (1000 req/day free)"})]})]}),e.jsx(V,{checked:l,onCheckedChange:O,disabled:o||!t?.geminiCli?.installed})]}),l&&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(G,{value:C,onChange:j=>F(j.target.value),onBlur:T,placeholder:"gemini-2.5-flash",className:"h-8 text-sm font-mono",disabled:o})]})}),!t?.geminiCli?.installed&&!x&&e.jsxs("div",{className:"px-4 pb-4 pt-0 border-t border-border/50",children:[e.jsxs("button",{onClick:()=>E(!N),className:"flex items-center gap-2 text-sm text-amber-600 dark:text-amber-400 hover:underline w-full py-2",children:[N?e.jsx(ue,{className:"w-4 h-4"}):e.jsx(he,{className:"w-4 h-4"}),"How to install Gemini CLI"]}),N&&e.jsxs("div",{className:"mt-2 p-3 rounded-md bg-amber-50 dark:bg-amber-900/20 text-sm",children:[e.jsx("p",{className:"text-amber-700 dark:text-amber-300 mb-2",children:"Install globally (FREE tier available):"}),e.jsx("code",{className:"text-sm bg-amber-100 dark:bg-amber-900/40 px-2 py-1 rounded font-mono block mb-2",children:"npm install -g @google/gemini-cli"}),e.jsxs("a",{href:"https://github.com/google-gemini/gemini-cli",target:"_blank",rel:"noopener noreferrer",className:"text-amber-700 dark:text-amber-300 hover:underline inline-flex items-center gap-1",children:[e.jsx(pe,{className:"w-3 h-3"}),"View documentation"]})]})]})]}),e.jsxs("div",{className:`rounded-lg border transition-colors ${d?"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(xe,{className:`w-5 h-5 ${d?"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:"opencode"}),e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-green-500/10 text-green-600 font-medium",children:"FREE"}),t?.opencodeCli?.installed?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:"OpenCode (web search via Zen)"})]})]}),e.jsx(V,{checked:d,onCheckedChange:g,disabled:o||!t?.opencodeCli?.installed})]}),d&&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(G,{value:_,onChange:j=>c(j.target.value),onBlur:z,placeholder:"opencode/grok-code",className:"h-8 text-sm font-mono",disabled:o})]})}),!t?.opencodeCli?.installed&&!x&&e.jsxs("div",{className:"px-4 pb-4 pt-0 border-t border-border/50",children:[e.jsxs("button",{onClick:()=>W(!S),className:"flex items-center gap-2 text-sm text-purple-600 dark:text-purple-400 hover:underline w-full py-2",children:[S?e.jsx(ue,{className:"w-4 h-4"}):e.jsx(he,{className:"w-4 h-4"}),"How to install OpenCode"]}),S&&e.jsxs("div",{className:"mt-2 p-3 rounded-md bg-purple-50 dark:bg-purple-900/20 text-sm",children:[e.jsx("p",{className:"text-purple-700 dark:text-purple-300 mb-2",children:"Install globally (FREE tier available):"}),e.jsx("code",{className:"text-sm bg-purple-100 dark:bg-purple-900/40 px-2 py-1 rounded font-mono block mb-2",children:"curl -fsSL https://opencode.ai/install | bash"}),e.jsxs("a",{href:"https://github.com/sst/opencode",target:"_blank",rel:"noopener noreferrer",className:"text-purple-700 dark:text-purple-300 hover:underline inline-flex items-center gap-1",children:[e.jsx(pe,{className:"w-3 h-3"}),"View documentation"]})]})]})]}),e.jsxs("div",{className:`rounded-lg border transition-colors ${h?"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(xe,{className:`w-5 h-5 ${h?"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:"grok"}),e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-blue-500/10 text-blue-600 font-medium",children:"GROK_API_KEY"}),t?.grokCli?.installed?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:"xAI Grok CLI (web + X search)"})]})]}),e.jsx(V,{checked:h,onCheckedChange:y,disabled:o||!t?.grokCli?.installed})]}),!t?.grokCli?.installed&&!x&&e.jsxs("div",{className:"px-4 pb-4 pt-0 border-t border-border/50",children:[e.jsxs("button",{onClick:()=>U(!f),className:"flex items-center gap-2 text-sm text-blue-600 dark:text-blue-400 hover:underline w-full py-2",children:[f?e.jsx(ue,{className:"w-4 h-4"}):e.jsx(he,{className:"w-4 h-4"}),"How to install Grok CLI"]}),f&&e.jsxs("div",{className:"mt-2 p-3 rounded-md bg-blue-50 dark:bg-blue-900/20 text-sm",children:[e.jsx("p",{className:"text-blue-700 dark:text-blue-300 mb-2",children:"Install globally (requires xAI API key):"}),e.jsx("code",{className:"text-sm bg-blue-100 dark:bg-blue-900/40 px-2 py-1 rounded font-mono block mb-2",children:"npm install -g @vibe-kit/grok-cli"}),e.jsxs("a",{href:"https://github.com/superagent-ai/grok-cli",target:"_blank",rel:"noopener noreferrer",className:"text-blue-700 dark:text-blue-300 hover:underline inline-flex items-center gap-1",children:[e.jsx(pe,{className:"w-3 h-3"}),"View documentation"]})]})]})]})]})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(w,{variant:"outline",size:"sm",onClick:()=>{M(),I()},disabled:L||o,className:"w-full",children:[e.jsx(k,{className:`w-4 h-4 mr-2 ${L?"animate-spin":""}`}),"Refresh"]})})]})}function Cs({config:t,loading:x,saving:o,error:u,success:v,newEnvKey:l,newEnvValue:h,setNewEnvKey:d,setNewEnvValue:C,toggleGlobalEnv:_,addEnvVar:N,removeEnvVar:S,fetchGlobalEnvConfig:f,fetchRawConfig:F}){return x?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||v?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[u&&e.jsxs(be,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(je,{className:"h-4 w-4"}),e.jsx(fe,{children:u})]}),v&&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(le,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:"Saved"})]})]}),e.jsx(ge,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Environment variables injected into all non-Claude subscription profiles (gemini, codex, agy, copilot, 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:t?.enabled?"Global Env enabled":"Global Env disabled"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t?.enabled?"Env vars will be injected into third-party profiles":"Env vars will not be injected"})]}),e.jsx(V,{checked:t?.enabled??!0,onCheckedChange:_})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Environment Variables"}),t?.env&&Object.keys(t.env).length>0?e.jsx("div",{className:"space-y-2",children:Object.entries(t.env).map(([c,E])=>e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg border bg-background",children:[e.jsx("code",{className:"flex-1 font-mono text-sm truncate",children:c}),e.jsx("span",{className:"text-muted-foreground",children:"="}),e.jsx("code",{className:"font-mono text-sm px-2 py-1 bg-muted rounded",children:E}),e.jsx(w,{variant:"ghost",size:"sm",onClick:()=>S(c),disabled:o,className:"h-8 w-8 p-0 text-destructive hover:text-destructive hover:bg-destructive/10",children:e.jsx(js,{className:"w-4 h-4"})})]},c))}):e.jsx("div",{className:"p-4 rounded-lg border border-dashed text-center text-muted-foreground",children:e.jsx("p",{children:"No environment variables configured"})}),e.jsxs("div",{className:"p-4 rounded-lg border bg-muted/30",children:[e.jsx("h4",{className:"text-sm font-medium mb-3",children:"Add New Variable"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(G,{value:l,onChange:c=>d(c.target.value.toUpperCase()),placeholder:"KEY_NAME",className:"flex-1 font-mono text-sm h-9",disabled:o}),e.jsx("span",{className:"flex items-center text-muted-foreground",children:"="}),e.jsx(G,{value:h,onChange:c=>C(c.target.value),placeholder:"value",className:"flex-1 font-mono text-sm h-9",disabled:o}),e.jsxs(w,{size:"sm",onClick:N,disabled:o||!l.trim(),className:"h-9",children:[e.jsx(vs,{className:"w-4 h-4 mr-1"}),"Add"]})]})]}),e.jsxs("div",{className:"p-4 rounded-lg border bg-muted/30",children:[e.jsx("h4",{className:"text-sm font-medium mb-3",children:"Quick Add Common Variables"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[[{key:"DISABLE_BUG_COMMAND",value:"1"},{key:"DISABLE_ERROR_REPORTING",value:"1"},{key:"DISABLE_TELEMETRY",value:"1"}].map(({key:c,value:E})=>!t?.env?.[c]&&e.jsxs(w,{variant:"outline",size:"sm",onClick:()=>{d(c),C(E)},className:"text-xs font-mono",children:["+ ",c]},c)),t?.env&&["DISABLE_BUG_COMMAND","DISABLE_ERROR_REPORTING","DISABLE_TELEMETRY"].every(c=>t.env[c])&&e.jsx("span",{className:"text-sm text-muted-foreground",children:"All common variables are configured"})]})]})]})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(w,{variant:"outline",size:"sm",onClick:()=>{f(),F()},disabled:x||o,className:"w-full",children:[e.jsx(k,{className:`w-4 h-4 mr-2 ${x?"animate-spin":""}`}),"Refresh"]})})]})}function Ss({config:t,loading:x,saving:o,error:u,success:v,testResult:l,testing:h,saveCliproxyServerConfig:d,handleTestConnection:C,fetchCliproxyServerConfig:_,fetchRawConfig:N}){const S={enabled:!1,host:"",port:void 0,protocol:"http",auth_token:""},f={enabled:!0,auto_start:!0},F={port:8317,auto_start:!0},c=n=>n==="https"?443:80,E=t?.remote.host??"",W=t?.remote.port!==void 0?t.remote.port.toString():"",U=t?.remote.auth_token??"",O=(t?.local.port??8317).toString(),[y,g]=r.useState(null),[T,z]=r.useState(null),[D,M]=r.useState(null),[I,L]=r.useState(null),j=y??E,Y=T??W,K=D??U,X=I??O;if(x)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(k,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:"Loading..."})]})});const P=t?.remote.enabled??!1,A=t?.remote??S,Q=t?.fallback??f,Z=t?.local??F,p=()=>{const n=y??j;n!==t?.remote.host&&d({remote:{...A,host:n}}),g(null)},H=()=>{const n=T??Y,$=n===""?void 0:parseInt(n,10),se=$&&!isNaN($)&&$>0?$:void 0;se!==t?.remote.port&&d({remote:{...A,port:se}}),z(null)},ne=()=>{const n=D??K;n!==t?.remote.auth_token&&d({remote:{...A,auth_token:n}}),M(null)},ee=()=>{const n=parseInt(I??X,10);!isNaN(n)&&n!==t?.local.port&&d({local:{...Z,port:n}}),L(null)};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 ${u||v?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[u&&e.jsxs(be,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(je,{className:"h-4 w-4"}),e.jsx(fe,{children:u})]}),v&&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(le,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:"Saved"})]})]}),e.jsx(ge,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure local or remote CLIProxyAPI connection for proxy-based profiles"}),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:()=>d({remote:{...A,enabled:!1}}),disabled:o,className:`p-4 rounded-lg border-2 text-left transition-all ${P?"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(Ns,{className:`w-5 h-5 ${P?"text-muted-foreground":"text-primary"}`}),e.jsx("span",{className:"font-medium",children:"Local"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Run CLIProxyAPI binary on this machine"})]}),e.jsxs("button",{onClick:()=>d({remote:{...A,enabled:!0}}),disabled:o,className:`p-4 rounded-lg border-2 text-left transition-all ${P?"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(ze,{className:`w-5 h-5 ${P?"text-primary":"text-muted-foreground"}`}),e.jsx("span",{className:"font-medium",children:"Remote"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Connect to a remote CLIProxyAPI server"})]})]})]}),P&&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(ze,{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(G,{value:j,onChange:n=>g(n.target.value),onBlur:p,placeholder:"192.168.1.100 or proxy.example.com",className:"font-mono",disabled:o})]}),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: ",c(t?.remote.protocol||"http"),")"]})]}),e.jsx(G,{type:"text",inputMode:"numeric",value:Y,onChange:n=>z(n.target.value.replace(/\D/g,"")),onBlur:H,placeholder:`Leave empty for ${c(t?.remote.protocol||"http")}`,className:"font-mono",disabled:o})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"Protocol"}),e.jsxs(cs,{value:t?.remote.protocol||"http",onValueChange:n=>d({remote:{...A,protocol:n}}),disabled:o,children:[e.jsx(ds,{children:e.jsx(is,{})}),e.jsxs(ms,{children:[e.jsx(_e,{value:"http",children:"HTTP"}),e.jsx(_e,{value:"https",children:"HTTPS"})]})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"Auth Token (optional)"}),e.jsx(G,{type:"password",value:K,onChange:n=>M(n.target.value),onBlur:ne,placeholder:"Bearer token for authentication",className:"font-mono",disabled:o})]}),e.jsxs("div",{className:"space-y-3 pt-2",children:[e.jsx(w,{onClick:C,disabled:h||!j,variant:"outline",className:"w-full",children:h?e.jsxs(e.Fragment,{children:[e.jsx(k,{className:"w-4 h-4 mr-2 animate-spin"}),"Testing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ys,{className:"w-4 h-4 mr-2"}),"Test Connection"]})}),l&&e.jsx("div",{className:`p-3 rounded-md ${l.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:l.reachable?e.jsxs(e.Fragment,{children:[e.jsx(le,{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 (",l.latencyMs,"ms)"]})]}):e.jsxs(e.Fragment,{children:[e.jsx(ws,{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:l.error||"Connection failed"})]})})})]})]}),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(V,{checked:t?.fallback.enabled??!0,onCheckedChange:n=>d({fallback:{...Q,enabled:n}}),disabled:o||!P})]}),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(V,{checked:t?.fallback.auto_start??!1,onCheckedChange:n=>d({fallback:{...Q,auto_start:n}}),disabled:o||!P||!t?.fallback.enabled})]})]})]}),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:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"Port"}),e.jsx(G,{type:"number",value:X,onChange:n=>L(n.target.value),onBlur:ee,placeholder:"8317",className:"font-mono max-w-32",disabled:o})]}),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(V,{checked:t?.local.auto_start??!0,onCheckedChange:n=>d({local:{...Z,auto_start:n}}),disabled:o})]})]})]})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(w,{variant:"outline",size:"sm",onClick:()=>{_(),N()},disabled:x||o,className:"w-full",children:[e.jsx(k,{className:`w-4 h-4 mr-2 ${x?"animate-spin":""}`}),"Refresh"]})})]})}export{Ms as SettingsPage};
|
|
1
|
+
import{j as e}from"./radix-ui-DFHQr9A5.js";import{k as as,r}from"./react-vendor-FspHSO0w.js";import{a3 as ie,a4 as rs,a5 as Ge,X as ls,Y as ns,Z as me,a6 as os,B as w,a7 as be,a8 as fe,i as ge,I as G,z as cs,A as ds,E as is,F as ms,G as _e}from"./index-ByU8ZhED.js";import{S as O}from"./switch-CMk95lwf.js";import{CodeEditor as xs}from"./code-editor-Br9x-r-E.js";import{J as k,am as us,z as hs,a6 as ps,k as bs,an as Fe,j as fs,o as gs,ac as je,l as le,t as xe,x as ue,y as he,D as pe,N as js,V as vs,ao as Ns,ap as ze,e as ys,W as ws}from"./icons-BOsxPbiD.js";import"./tanstack-C4gT2P7V.js";import"./notifications-B2Pz7lik.js";import"./utils-CzKF5WmX.js";import"./form-utils-BuXDJb0w.js";import"./code-highlight-BoHWVYut.js";function Ms(){const[t]=as(),x=t.get("tab"),o=x==="globalenv"?"globalenv":x==="proxy"?"proxy":"websearch",[u,v]=r.useState(o),[l,h]=r.useState(null),[d,C]=r.useState(!0),[_,N]=r.useState(!1),[S,f]=r.useState(null),[F,c]=r.useState(!1),[E,W]=r.useState(null),[U,V]=r.useState(!0),[y,g]=r.useState(null),[T,z]=r.useState(!1),[D,M]=r.useState(!1),[I,L]=r.useState(""),[j,Y]=r.useState(""),[K,X]=r.useState(!1),[P,A]=r.useState(!1),[Z,Q]=r.useState(!1),[p,H]=r.useState(null),[ne,ee]=r.useState(!0),[n,$]=r.useState(!1),[se,te]=r.useState(null),[Me,ve]=r.useState(!1),[oe,Ne]=r.useState(""),[ye,we]=r.useState(""),[R,ae]=r.useState(null),[$e,ke]=r.useState(!0),[Be,Ce]=r.useState(!1),[Oe,B]=r.useState(null),[Ve,Se]=r.useState(!1),[De,ce]=r.useState(null),[He,Ee]=r.useState(!1);r.useEffect(()=>{Pe(),Te(),q(),Ie(),Le()},[]),r.useEffect(()=>{l&&(L(l.providers?.gemini?.model??"gemini-2.5-flash"),Y(l.providers?.opencode?.model??"opencode/grok-code"))},[l]);const Pe=async()=>{try{C(!0),f(null);const s=await fetch("/api/websearch");if(!s.ok)throw new Error("Failed to load WebSearch config");const a=await s.json();h(a)}catch(s){f(s.message)}finally{C(!1)}},Te=async()=>{try{V(!0);const s=await fetch("/api/websearch/status");if(!s.ok)throw new Error("Failed to load status");const a=await s.json();W(a)}catch(s){console.error("Failed to fetch WebSearch status:",s)}finally{V(!1)}},q=async()=>{try{z(!0);const s=await fetch("/api/config/raw");if(!s.ok){g(null);return}const a=await s.text();g(a)}catch(s){console.error("Failed to fetch raw config:",s),g(null)}finally{z(!1)}},Ie=async()=>{try{ee(!0),te(null);const s=await fetch("/api/global-env");if(!s.ok)throw new Error("Failed to load Global Env config");const a=await s.json();H(a)}catch(s){te(s.message)}finally{ee(!1)}},Le=async()=>{try{ke(!0),B(null);const s=await ie.cliproxyServer.get();ae(s)}catch(s){B(s.message)}finally{ke(!1)}},We=async()=>{if(y)try{await navigator.clipboard.writeText(y),M(!0),setTimeout(()=>M(!1),2e3)}catch(s){console.error("Failed to copy:",s)}},Ue=()=>{const s=l?.providers||{},a=s.gemini?.enabled??!1,i=s.grok?.enabled??!1,b=s.opencode?.enabled??!1;J({enabled:!a||i||b,providers:{...s,gemini:{...s.gemini,enabled:!a}}})},J=async s=>{if(!l)return;const a={...l,...s};h(a);try{N(!0),f(null);const i=await fetch("/api/websearch",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!i.ok){const m=await i.json();throw new Error(m.error||"Failed to save")}const b=await i.json();h(b.websearch),c(!0),setTimeout(()=>c(!1),1500),fetch("/api/config/raw").then(m=>m.ok?m.text():null).then(m=>m&&g(m)).catch(()=>{})}catch(i){h(l),f(i.message)}finally{N(!1)}},de=l?.providers?.gemini?.enabled??!1,Ae=l?.providers?.grok?.enabled??!1,Re=l?.providers?.opencode?.enabled??!1,Ye=()=>{const s=l?.providers||{},a=s.grok?.enabled??!1;J({enabled:de||!a||Re,providers:{...s,grok:{...s.grok,enabled:!a}}})},qe=()=>{const s=l?.providers||{},a=s.opencode?.enabled??!1;J({enabled:de||Ae||!a,providers:{...s,opencode:{...s.opencode,enabled:!a}}})},Je=()=>{const s=l?.providers?.gemini?.model??"gemini-2.5-flash";if(I!==s){const a=l?.providers||{};J({providers:{...a,gemini:{...a.gemini,model:I}}})}},Ke=()=>{const s=l?.providers?.opencode?.model??"opencode/grok-code";if(j!==s){const a=l?.providers||{};J({providers:{...a,opencode:{...a.opencode,model:j}}})}},re=async s=>{if(!p)return;const a={...p,...s};H(a);try{$(!0),te(null);const i=await fetch("/api/global-env",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!i.ok){const m=await i.json();throw new Error(m.error||"Failed to save")}const b=await i.json();H(b.config),ve(!0),setTimeout(()=>ve(!1),1500),fetch("/api/config/raw").then(m=>m.ok?m.text():null).then(m=>m&&g(m)).catch(()=>{})}catch(i){H(p),te(i.message)}finally{$(!1)}},Xe=()=>{re({enabled:!p?.enabled})},Ze=()=>{if(!oe.trim()||!p)return;const s={...p.env,[oe.trim()]:ye};re({env:s}),Ne(""),we("")},Qe=s=>{if(!p)return;const a={...p.env};delete a[s],re({env:a})},es=(s,a)=>{if(!p)return;const i={...p.env,[s]:a};re({env:i})},ss=async s=>{if(!R)return;const a={remote:{...R.remote,...s.remote},fallback:{...R.fallback,...s.fallback},local:{...R.local,...s.local}};ae(a),ce(null);try{Ce(!0),B(null);const i=await ie.cliproxyServer.update(s);ae(i),Se(!0),setTimeout(()=>Se(!1),1500),fetch("/api/config/raw").then(b=>b.ok?b.text():null).then(b=>b&&g(b)).catch(()=>{})}catch(i){ae(R),B(i.message)}finally{Ce(!1)}},ts=async()=>{if(!R)return;const{host:s,port:a,protocol:i,auth_token:b}=R.remote;if(!s){B("Host is required");return}try{Ee(!0),B(null),ce(null);const m=await ie.cliproxyServer.test({host:s,port:a||void 0,protocol:i,authToken:b||void 0});ce(m)}catch(m){B(m.message)}finally{Ee(!1)}};return d?e.jsx("div",{className:"h-[calc(100vh-100px)] 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",{className:"text-lg",children:"Loading configuration..."})]})}):e.jsx("div",{className:"h-[calc(100vh-100px)]",children:e.jsxs(rs,{direction:"horizontal",className:"h-full",children:[e.jsx(Ge,{defaultSize:40,minSize:30,maxSize:55,children:e.jsxs("div",{className:"h-full border-r flex flex-col bg-muted/30 relative",children:[e.jsx("div",{className:"p-5 border-b bg-background",children:e.jsx(ls,{value:u,onValueChange:s=>v(s),children:e.jsxs(ns,{className:"w-full",children:[e.jsxs(me,{value:"websearch",className:"flex-1 gap-2",children:[e.jsx(us,{className:"w-4 h-4"}),"WebSearch"]}),e.jsxs(me,{value:"globalenv",className:"flex-1 gap-2",children:[e.jsx(hs,{className:"w-4 h-4"}),"Global Env"]}),e.jsxs(me,{value:"proxy",className:"flex-1 gap-2",children:[e.jsx(ps,{className:"w-4 h-4"}),"Proxy"]})]})})}),u==="websearch"?e.jsx(ks,{config:l,status:E,statusLoading:U,saving:_,error:S,success:F,isGeminiEnabled:de,isGrokEnabled:Ae,isOpenCodeEnabled:Re,geminiModelInput:I,opencodeModelInput:j,showGeminiHint:K,showOpencodeHint:P,showGrokHint:Z,setGeminiModelInput:L,setOpencodeModelInput:Y,setShowGeminiHint:X,setShowOpencodeHint:A,setShowGrokHint:Q,toggleGemini:Ue,toggleGrok:Ye,toggleOpenCode:qe,saveGeminiModel:Je,saveOpencodeModel:Ke,fetchStatus:Te,fetchConfig:Pe,fetchRawConfig:q,loading:d}):u==="globalenv"?e.jsx(Cs,{config:p,loading:ne,saving:n,error:se,success:Me,newEnvKey:oe,newEnvValue:ye,setNewEnvKey:Ne,setNewEnvValue:we,toggleGlobalEnv:Xe,addEnvVar:Ze,removeEnvVar:Qe,updateEnvValue:es,fetchGlobalEnvConfig:Ie,fetchRawConfig:q}):e.jsx(Ss,{config:R,loading:$e,saving:Be,error:Oe,success:Ve,testResult:De,testing:He,saveCliproxyServerConfig:ss,handleTestConnection:ts,fetchCliproxyServerConfig:Le,fetchRawConfig:q})]})}),e.jsx(os,{className:"w-2 bg-border hover:bg-primary/20 transition-colors cursor-col-resize flex items-center justify-center group",children:e.jsx(bs,{className:"w-3 h-3 text-muted-foreground group-hover:text-primary"})}),e.jsx(Ge,{defaultSize:60,minSize:35,children:e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"p-4 border-b bg-background flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Fe,{className:"w-5 h-5 text-primary"}),e.jsxs("div",{children:[e.jsx("h2",{className:"font-semibold",children:"config.yaml"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"~/.ccs/config.yaml"})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(w,{variant:"outline",size:"sm",onClick:We,disabled:!y,children:D?e.jsxs(e.Fragment,{children:[e.jsx(fs,{className:"w-4 h-4 mr-1"}),"Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(gs,{className:"w-4 h-4 mr-1"}),"Copy"]})}),e.jsx(w,{variant:"outline",size:"sm",onClick:q,disabled:T,children:e.jsx(k,{className:`w-4 h-4 ${T?"animate-spin":""}`})})]})]}),e.jsx("div",{className:"flex-1 overflow-auto",children:T?e.jsxs("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:[e.jsx(k,{className:"w-5 h-5 animate-spin mr-2"}),"Loading..."]}):y?e.jsx(xs,{value:y,onChange:()=>{},language:"yaml",readonly:!0,minHeight:"auto",className:"min-h-full"}):e.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Fe,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),e.jsx("p",{children:"Config file not found"}),e.jsx("code",{className:"text-sm bg-muted px-2 py-1 rounded mt-2 inline-block",children:"ccs migrate"})]})})})]})})]})})}function ks({status:t,statusLoading:x,saving:o,error:u,success:v,isGeminiEnabled:l,isGrokEnabled:h,isOpenCodeEnabled:d,geminiModelInput:C,opencodeModelInput:_,showGeminiHint:N,showOpencodeHint:S,showGrokHint:f,setGeminiModelInput:F,setOpencodeModelInput:c,setShowGeminiHint:E,setShowOpencodeHint:W,setShowGrokHint:U,toggleGemini:V,toggleGrok:y,toggleOpenCode:g,saveGeminiModel:T,saveOpencodeModel:z,fetchStatus:D,fetchConfig:M,fetchRawConfig:I,loading:L}){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 ${u||v?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[u&&e.jsxs(be,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(je,{className:"h-4 w-4"}),e.jsx(fe,{children:u})]}),v&&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(le,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:"Saved"})]})]}),e.jsx(ge,{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:l?"WebSearch enabled":"WebSearch disabled"}),x?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Checking status..."}):t?.readiness?e.jsx("p",{className:"text-sm text-muted-foreground",children:t.readiness.message}):null]}),e.jsx(w,{variant:"ghost",size:"sm",onClick:D,disabled:x,children:e.jsx(k,{className:`w-4 h-4 ${x?"animate-spin":""}`})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Providers"}),e.jsxs("div",{className:`rounded-lg border transition-colors ${l?"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(xe,{className:`w-5 h-5 ${l?"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:"gemini"}),e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-green-500/10 text-green-600 font-medium",children:"FREE"}),t?.geminiCli?.installed?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:"Google Gemini CLI (1000 req/day free)"})]})]}),e.jsx(O,{checked:l,onCheckedChange:V,disabled:o||!t?.geminiCli?.installed})]}),l&&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(G,{value:C,onChange:j=>F(j.target.value),onBlur:T,placeholder:"gemini-2.5-flash",className:"h-8 text-sm font-mono",disabled:o})]})}),!t?.geminiCli?.installed&&!x&&e.jsxs("div",{className:"px-4 pb-4 pt-0 border-t border-border/50",children:[e.jsxs("button",{onClick:()=>E(!N),className:"flex items-center gap-2 text-sm text-amber-600 dark:text-amber-400 hover:underline w-full py-2",children:[N?e.jsx(ue,{className:"w-4 h-4"}):e.jsx(he,{className:"w-4 h-4"}),"How to install Gemini CLI"]}),N&&e.jsxs("div",{className:"mt-2 p-3 rounded-md bg-amber-50 dark:bg-amber-900/20 text-sm",children:[e.jsx("p",{className:"text-amber-700 dark:text-amber-300 mb-2",children:"Install globally (FREE tier available):"}),e.jsx("code",{className:"text-sm bg-amber-100 dark:bg-amber-900/40 px-2 py-1 rounded font-mono block mb-2",children:"npm install -g @google/gemini-cli"}),e.jsxs("a",{href:"https://github.com/google-gemini/gemini-cli",target:"_blank",rel:"noopener noreferrer",className:"text-amber-700 dark:text-amber-300 hover:underline inline-flex items-center gap-1",children:[e.jsx(pe,{className:"w-3 h-3"}),"View documentation"]})]})]})]}),e.jsxs("div",{className:`rounded-lg border transition-colors ${d?"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(xe,{className:`w-5 h-5 ${d?"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:"opencode"}),e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-green-500/10 text-green-600 font-medium",children:"FREE"}),t?.opencodeCli?.installed?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:"OpenCode (web search via Zen)"})]})]}),e.jsx(O,{checked:d,onCheckedChange:g,disabled:o||!t?.opencodeCli?.installed})]}),d&&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(G,{value:_,onChange:j=>c(j.target.value),onBlur:z,placeholder:"opencode/grok-code",className:"h-8 text-sm font-mono",disabled:o})]})}),!t?.opencodeCli?.installed&&!x&&e.jsxs("div",{className:"px-4 pb-4 pt-0 border-t border-border/50",children:[e.jsxs("button",{onClick:()=>W(!S),className:"flex items-center gap-2 text-sm text-purple-600 dark:text-purple-400 hover:underline w-full py-2",children:[S?e.jsx(ue,{className:"w-4 h-4"}):e.jsx(he,{className:"w-4 h-4"}),"How to install OpenCode"]}),S&&e.jsxs("div",{className:"mt-2 p-3 rounded-md bg-purple-50 dark:bg-purple-900/20 text-sm",children:[e.jsx("p",{className:"text-purple-700 dark:text-purple-300 mb-2",children:"Install globally (FREE tier available):"}),e.jsx("code",{className:"text-sm bg-purple-100 dark:bg-purple-900/40 px-2 py-1 rounded font-mono block mb-2",children:"curl -fsSL https://opencode.ai/install | bash"}),e.jsxs("a",{href:"https://github.com/sst/opencode",target:"_blank",rel:"noopener noreferrer",className:"text-purple-700 dark:text-purple-300 hover:underline inline-flex items-center gap-1",children:[e.jsx(pe,{className:"w-3 h-3"}),"View documentation"]})]})]})]}),e.jsxs("div",{className:`rounded-lg border transition-colors ${h?"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(xe,{className:`w-5 h-5 ${h?"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:"grok"}),e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-blue-500/10 text-blue-600 font-medium",children:"GROK_API_KEY"}),t?.grokCli?.installed?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:"xAI Grok CLI (web + X search)"})]})]}),e.jsx(O,{checked:h,onCheckedChange:y,disabled:o||!t?.grokCli?.installed})]}),!t?.grokCli?.installed&&!x&&e.jsxs("div",{className:"px-4 pb-4 pt-0 border-t border-border/50",children:[e.jsxs("button",{onClick:()=>U(!f),className:"flex items-center gap-2 text-sm text-blue-600 dark:text-blue-400 hover:underline w-full py-2",children:[f?e.jsx(ue,{className:"w-4 h-4"}):e.jsx(he,{className:"w-4 h-4"}),"How to install Grok CLI"]}),f&&e.jsxs("div",{className:"mt-2 p-3 rounded-md bg-blue-50 dark:bg-blue-900/20 text-sm",children:[e.jsx("p",{className:"text-blue-700 dark:text-blue-300 mb-2",children:"Install globally (requires xAI API key):"}),e.jsx("code",{className:"text-sm bg-blue-100 dark:bg-blue-900/40 px-2 py-1 rounded font-mono block mb-2",children:"npm install -g @vibe-kit/grok-cli"}),e.jsxs("a",{href:"https://github.com/superagent-ai/grok-cli",target:"_blank",rel:"noopener noreferrer",className:"text-blue-700 dark:text-blue-300 hover:underline inline-flex items-center gap-1",children:[e.jsx(pe,{className:"w-3 h-3"}),"View documentation"]})]})]})]})]})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(w,{variant:"outline",size:"sm",onClick:()=>{M(),I()},disabled:L||o,className:"w-full",children:[e.jsx(k,{className:`w-4 h-4 mr-2 ${L?"animate-spin":""}`}),"Refresh"]})})]})}function Cs({config:t,loading:x,saving:o,error:u,success:v,newEnvKey:l,newEnvValue:h,setNewEnvKey:d,setNewEnvValue:C,toggleGlobalEnv:_,addEnvVar:N,removeEnvVar:S,fetchGlobalEnvConfig:f,fetchRawConfig:F}){return x?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||v?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[u&&e.jsxs(be,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(je,{className:"h-4 w-4"}),e.jsx(fe,{children:u})]}),v&&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(le,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:"Saved"})]})]}),e.jsx(ge,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Environment variables injected into all non-Claude subscription profiles (gemini, codex, agy, copilot, 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:t?.enabled?"Global Env enabled":"Global Env disabled"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t?.enabled?"Env vars will be injected into third-party profiles":"Env vars will not be injected"})]}),e.jsx(O,{checked:t?.enabled??!0,onCheckedChange:_})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Environment Variables"}),t?.env&&Object.keys(t.env).length>0?e.jsx("div",{className:"space-y-2",children:Object.entries(t.env).map(([c,E])=>e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg border bg-background",children:[e.jsx("code",{className:"flex-1 font-mono text-sm truncate",children:c}),e.jsx("span",{className:"text-muted-foreground",children:"="}),e.jsx("code",{className:"font-mono text-sm px-2 py-1 bg-muted rounded",children:E}),e.jsx(w,{variant:"ghost",size:"sm",onClick:()=>S(c),disabled:o,className:"h-8 w-8 p-0 text-destructive hover:text-destructive hover:bg-destructive/10",children:e.jsx(js,{className:"w-4 h-4"})})]},c))}):e.jsx("div",{className:"p-4 rounded-lg border border-dashed text-center text-muted-foreground",children:e.jsx("p",{children:"No environment variables configured"})}),e.jsxs("div",{className:"p-4 rounded-lg border bg-muted/30",children:[e.jsx("h4",{className:"text-sm font-medium mb-3",children:"Add New Variable"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(G,{value:l,onChange:c=>d(c.target.value.toUpperCase()),placeholder:"KEY_NAME",className:"flex-1 font-mono text-sm h-9",disabled:o}),e.jsx("span",{className:"flex items-center text-muted-foreground",children:"="}),e.jsx(G,{value:h,onChange:c=>C(c.target.value),placeholder:"value",className:"flex-1 font-mono text-sm h-9",disabled:o}),e.jsxs(w,{size:"sm",onClick:N,disabled:o||!l.trim(),className:"h-9",children:[e.jsx(vs,{className:"w-4 h-4 mr-1"}),"Add"]})]})]}),e.jsxs("div",{className:"p-4 rounded-lg border bg-muted/30",children:[e.jsx("h4",{className:"text-sm font-medium mb-3",children:"Quick Add Common Variables"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[[{key:"DISABLE_BUG_COMMAND",value:"1"},{key:"DISABLE_ERROR_REPORTING",value:"1"},{key:"DISABLE_TELEMETRY",value:"1"}].map(({key:c,value:E})=>!t?.env?.[c]&&e.jsxs(w,{variant:"outline",size:"sm",onClick:()=>{d(c),C(E)},className:"text-xs font-mono",children:["+ ",c]},c)),t?.env&&["DISABLE_BUG_COMMAND","DISABLE_ERROR_REPORTING","DISABLE_TELEMETRY"].every(c=>t.env[c])&&e.jsx("span",{className:"text-sm text-muted-foreground",children:"All common variables are configured"})]})]})]})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(w,{variant:"outline",size:"sm",onClick:()=>{f(),F()},disabled:x||o,className:"w-full",children:[e.jsx(k,{className:`w-4 h-4 mr-2 ${x?"animate-spin":""}`}),"Refresh"]})})]})}function Ss({config:t,loading:x,saving:o,error:u,success:v,testResult:l,testing:h,saveCliproxyServerConfig:d,handleTestConnection:C,fetchCliproxyServerConfig:_,fetchRawConfig:N}){const S={enabled:!1,host:"",port:void 0,protocol:"http",auth_token:""},f={enabled:!0,auto_start:!0},F={port:8317,auto_start:!0},c=n=>n==="https"?443:80,E=t?.remote.host??"",W=t?.remote.port!==void 0?t.remote.port.toString():"",U=t?.remote.auth_token??"",V=(t?.local.port??8317).toString(),[y,g]=r.useState(null),[T,z]=r.useState(null),[D,M]=r.useState(null),[I,L]=r.useState(null),j=y??E,Y=T??W,K=D??U,X=I??V;if(x)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(k,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:"Loading..."})]})});const P=t?.remote.enabled??!1,A=t?.remote??S,Z=t?.fallback??f,Q=t?.local??F,p=()=>{const n=y??j;n!==t?.remote.host&&d({remote:{...A,host:n}}),g(null)},H=()=>{const n=T??Y,$=n===""?void 0:parseInt(n,10),se=$&&!isNaN($)&&$>0?$:void 0;se!==t?.remote.port&&d({remote:{...A,port:se}}),z(null)},ne=()=>{const n=D??K;n!==t?.remote.auth_token&&d({remote:{...A,auth_token:n}}),M(null)},ee=()=>{const n=parseInt(I??X,10);!isNaN(n)&&n!==t?.local.port&&d({local:{...Q,port:n}}),L(null)};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 ${u||v?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[u&&e.jsxs(be,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(je,{className:"h-4 w-4"}),e.jsx(fe,{children:u})]}),v&&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(le,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:"Saved"})]})]}),e.jsx(ge,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure local or remote CLIProxyAPI connection for proxy-based profiles"}),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:()=>d({remote:{...A,enabled:!1}}),disabled:o,className:`p-4 rounded-lg border-2 text-left transition-all ${P?"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(Ns,{className:`w-5 h-5 ${P?"text-muted-foreground":"text-primary"}`}),e.jsx("span",{className:"font-medium",children:"Local"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Run CLIProxyAPI binary on this machine"})]}),e.jsxs("button",{onClick:()=>d({remote:{...A,enabled:!0}}),disabled:o,className:`p-4 rounded-lg border-2 text-left transition-all ${P?"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(ze,{className:`w-5 h-5 ${P?"text-primary":"text-muted-foreground"}`}),e.jsx("span",{className:"font-medium",children:"Remote"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Connect to a remote CLIProxyAPI server"})]})]})]}),P&&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(ze,{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(G,{value:j,onChange:n=>g(n.target.value),onBlur:p,placeholder:"192.168.1.100 or proxy.example.com",className:"font-mono",disabled:o})]}),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: ",c(t?.remote.protocol||"http"),")"]})]}),e.jsx(G,{type:"text",inputMode:"numeric",value:Y,onChange:n=>z(n.target.value.replace(/\D/g,"")),onBlur:H,placeholder:`Leave empty for ${c(t?.remote.protocol||"http")}`,className:"font-mono",disabled:o})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"Protocol"}),e.jsxs(cs,{value:t?.remote.protocol||"http",onValueChange:n=>d({remote:{...A,protocol:n}}),disabled:o,children:[e.jsx(ds,{children:e.jsx(is,{})}),e.jsxs(ms,{children:[e.jsx(_e,{value:"http",children:"HTTP"}),e.jsx(_e,{value:"https",children:"HTTPS"})]})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"Auth Token (optional)"}),e.jsx(G,{type:"password",value:K,onChange:n=>M(n.target.value),onBlur:ne,placeholder:"Bearer token for authentication",className:"font-mono",disabled:o})]}),e.jsxs("div",{className:"space-y-3 pt-2",children:[e.jsx(w,{onClick:C,disabled:h||!j,variant:"outline",className:"w-full",children:h?e.jsxs(e.Fragment,{children:[e.jsx(k,{className:"w-4 h-4 mr-2 animate-spin"}),"Testing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ys,{className:"w-4 h-4 mr-2"}),"Test Connection"]})}),l&&e.jsx("div",{className:`p-3 rounded-md ${l.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:l.reachable?e.jsxs(e.Fragment,{children:[e.jsx(le,{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 (",l.latencyMs,"ms)"]})]}):e.jsxs(e.Fragment,{children:[e.jsx(ws,{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:l.error||"Connection failed"})]})})})]})]}),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(O,{checked:t?.fallback.enabled??!0,onCheckedChange:n=>d({fallback:{...Z,enabled:n}}),disabled:o||!P})]}),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(O,{checked:t?.fallback.auto_start??!1,onCheckedChange:n=>d({fallback:{...Z,auto_start:n}}),disabled:o||!P||!t?.fallback.enabled})]})]})]}),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:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"Port"}),e.jsx(G,{type:"number",value:X,onChange:n=>L(n.target.value),onBlur:ee,placeholder:"8317",className:"font-mono max-w-32",disabled:o})]}),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(O,{checked:t?.local.auto_start??!0,onCheckedChange:n=>d({local:{...Q,auto_start:n}}),disabled:o})]})]})]})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(w,{variant:"outline",size:"sm",onClick:()=>{_(),N()},disabled:x||o,className:"w-full",children:[e.jsx(k,{className:`w-4 h-4 mr-2 ${x?"animate-spin":""}`}),"Refresh"]})})]})}export{Ms as SettingsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as s}from"./radix-ui-DFHQr9A5.js";import{r as
|
|
1
|
+
import{j as s}from"./radix-ui-DFHQr9A5.js";import{r as o}from"./react-vendor-FspHSO0w.js";import{C as l,a as m}from"./card-CCDc-Mx9.js";import{ac as c,ad as x,a7 as u,ae as h,a8 as p,B as g}from"./index-ByU8ZhED.js";import{s as j,Y as f,as as N,T as b}from"./icons-BOsxPbiD.js";import"./tanstack-C4gT2P7V.js";import"./notifications-B2Pz7lik.js";import"./utils-CzKF5WmX.js";import"./form-utils-BuXDJb0w.js";import"./code-highlight-BoHWVYut.js";function D(){const[t,r]=o.useState("commands"),{data:e}=c(),{data:n,isLoading:i}=x(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(u,{variant:"warning",children:[s.jsx(b,{className:"h-4 w-4"}),s.jsx(h,{children:"Configuration Required"}),s.jsxs(p,{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(g,{variant:t===a.id?"default":"ghost",size:"sm",onClick:()=>r(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:i?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(l,{children:s.jsxs(m,{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{D as SharedPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as a,a8 as s,a9 as n}from"./radix-ui-DFHQr9A5.js";import"./react-vendor-FspHSO0w.js";import{c as e}from"./index-
|
|
1
|
+
import{j as a,a8 as s,a9 as n}from"./radix-ui-DFHQr9A5.js";import"./react-vendor-FspHSO0w.js";import{c as e}from"./index-ByU8ZhED.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-ByU8ZhED.js"></script>
|
|
28
28
|
<link rel="modulepreload" crossorigin href="/assets/react-vendor-FspHSO0w.js">
|
|
29
29
|
<link rel="modulepreload" crossorigin href="/assets/radix-ui-DFHQr9A5.js">
|
|
30
30
|
<link rel="modulepreload" crossorigin href="/assets/tanstack-C4gT2P7V.js">
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-DFHQr9A5.js";import{r as u}from"./react-vendor-FspHSO0w.js";import{u as je}from"./tanstack-C4gT2P7V.js";import{r as Z,s as ve,t as X,u as Ne,D as ee,v as se,w as te,x as ae,y as ne,B as l,c as v,d as B,L as T,I as ie,z as we,A as ye,E as be,F as Ce,G as Se,H as Ae,J as ke,K as Pe,M as De,e as I,N as Me,O as Fe,Q as Re,R as Ve,i as Le,S as Te,T as E,U as re}from"./index-DlEL4vYD.js";import{C as K,a as W}from"./card-DQcAIoan.js";import{Y as U,b as Y,L as ce,D as O,t as Oe,j as D,o as Ge,ae as L,J as A,$ as G,af as _,A as Ie,ag as H,U as Ue,r as ze,ah as $e,ai as Qe,Z as de,aj as oe,X as le,N as qe}from"./icons-BOsxPbiD.js";import"./notifications-B2Pz7lik.js";import"./utils-CzKF5WmX.js";import"./form-utils-BuXDJb0w.js";import"./code-highlight-BoHWVYut.js";const F={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"},{id:"gemini-claude-sonnet-4-5-thinking",name:"Claude Sonnet 4.5 Thinking",description:"Balanced with extended thinking"},{id:"gemini-claude-sonnet-4-5",name:"Claude Sonnet 4.5",description:"Fast and capable"},{id:"gemini-3-pro-preview",name:"Gemini 3 Pro",description:"Google latest model via Antigravity"}]},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"},{id:"gemini-2.5-pro",name:"Gemini 2.5 Pro",description:"Stable, works with free Google account"}]},codex:{provider:"codex",displayName:"Codex",defaultModel:"gpt-5.1-codex-max",models:[{id:"gpt-5.1-codex-max",name:"Codex Max (5.1)",description:"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:"qwen-coder-plus",models:[{id:"qwen-coder-plus",name:"Qwen Coder Plus",description:"Alibaba code-focused model"},{id:"qwen-max",name:"Qwen Max",description:"Most capable Qwen model"}]},iflow:{provider:"iflow",displayName:"iFlow",defaultModel:"iflow-default",models:[{id:"iflow-default",name:"iFlow Default",description:"Default iFlow model"}]}},J=[{id:"gemini",name:"Google Gemini",description:"Gemini Pro/Flash models"},{id:"codex",name:"OpenAI Codex",description:"GPT-4 and codex models"},{id:"agy",name:"Antigravity",description:"Antigravity AI models"},{id:"qwen",name:"Alibaba Qwen",description:"Qwen Code models"},{id:"iflow",name:"iFlow",description:"iFlow AI models"}];function Be({open:n,onClose:d}){const[t,i]=u.useState("provider"),[r,o]=u.useState(""),[c,x]=u.useState(null),[h,f]=u.useState(""),[N,k]=u.useState(""),[R,w]=u.useState(!1),[y,C]=u.useState(!1),[p,S]=u.useState(!1),{data:P,refetch:g}=Z(),m=ve(),j=X(),{privacyMode:M}=Ne(),b=P?.authStatus.find(s=>s.provider===r)?.accounts||[];u.useEffect(()=>{if(!n){const s=setTimeout(()=>{i("provider"),o(""),x(null),f(""),k(""),w(!1),S(!1)},0);return()=>clearTimeout(s)}},[n]),u.useEffect(()=>{if(t==="auth"&&b.length>0&&!p){const s=setTimeout(()=>{i("account")},0);return()=>clearTimeout(s)}},[t,b,p]);const a=async s=>{await navigator.clipboard.writeText(s),w(!0),setTimeout(()=>w(!1),2e3)},V=async()=>{C(!0),await g(),C(!1)},me=()=>{j.mutate({provider:r},{onSuccess:s=>{s.account&&(x(s.account),i("variant")),g()}})},ue=s=>{o(s),(P?.authStatus.find(fe=>fe.provider===s)?.accounts||[]).length===0?i("auth"):i("account")},xe=s=>{x(s),i("variant")},he=async()=>{if(!(!h||!r))try{await m.mutateAsync({name:h,provider:r,model:N||void 0,account:c?.id}),i("success")}catch(s){console.error("Failed to create variant:",s)}},$=`ccs ${r} --auth --add`,Q=["provider","auth","variant","success"],pe=(s=>s==="account"?1:Q.indexOf(s))(t),ge=s=>{if(!s&&(t==="success"||t==="provider")){d();return}};return e.jsx(ee,{open:n,onOpenChange:ge,children:e.jsxs(se,{className:"sm:max-w-lg",onPointerDownOutside:s=>{t!=="success"&&t!=="provider"&&s.preventDefault()},onEscapeKeyDown:s=>{(j.isPending||m.isPending)&&s.preventDefault()},children:[e.jsxs(te,{children:[e.jsxs(ae,{className:"flex items-center gap-2",children:[e.jsx(U,{className:"w-5 h-5 text-primary"}),"Quick Setup Wizard"]}),e.jsxs(ne,{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("div",{className:"grid gap-2",children:J.map(s=>e.jsxs("button",{onClick:()=>ue(s.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:s.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s.description})]}),e.jsx(Y,{className:"w-4 h-4 text-muted-foreground"})]},s.id))}),t==="auth"&&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 ",J.find(s=>s.id===r)?.name," to add an account"]}),e.jsx(l,{onClick:me,disabled:j.isPending,className:"w-full gap-2",size:"lg",children:j.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-4 h-4 animate-spin"}),"Authenticating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(O,{className:"w-4 h-4"}),"Authenticate in Browser"]})}),j.isPending&&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(K,{children:e.jsxs(W,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Oe,{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:$}),e.jsx(l,{variant:"outline",size:"icon",onClick:()=>a($),children:R?e.jsx(D,{className:"w-4 h-4 text-green-500"}):e.jsx(Ge,{className:"w-4 h-4"})})]})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(l,{variant:"ghost",onClick:()=>i("provider"),disabled:j.isPending,children:[e.jsx(L,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs(l,{variant:"outline",onClick:V,disabled:y||j.isPending,children:[e.jsx(A,{className:`w-4 h-4 mr-2 ${y?"animate-spin":""}`}),y?"Checking...":"Refresh Status"]})]})]}),t==="account"&&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 (",b.length,")"]}),e.jsx("div",{className:"grid gap-2",children:b.map(s=>e.jsxs("button",{type:"button",onClick:()=>xe(s),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(G,{className:"w-4 h-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:v("font-medium",M&&B),children:s.email||s.id}),s.isDefault&&e.jsx("div",{className:"text-xs text-muted-foreground",children:"Default account"})]})]}),e.jsx(Y,{className:"w-4 h-4 text-muted-foreground"})]},s.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:()=>{S(!0),i("auth")},children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(O,{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(l,{variant:"ghost",onClick:()=>i("provider"),children:[e.jsx(L,{className:"w-4 h-4 mr-2"}),"Back"]})})]}),t==="variant"&&e.jsxs("div",{className:"space-y-4",children:[c&&e.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/50 rounded-md text-sm",children:[e.jsx(G,{className:"w-4 h-4"}),e.jsxs("span",{children:["Using:"," ",e.jsx("span",{className:v(M&&B),children:c.email||c.id})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"variant-name",children:"Variant Name *"}),e.jsx(ie,{id:"variant-name",value:h,onChange:s=>f(s.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 ",h||"<name>",' "prompt"']})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{children:"Model"}),e.jsxs(we,{value:N,onValueChange:k,children:[e.jsx(ye,{children:e.jsx(be,{placeholder:"Select a model"})}),e.jsx(Ce,{children:F[r]?.models.map(s=>e.jsx(Se,{value:s.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:s.name}),s.description&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",s.description]})]})},s.id))})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Default: ",F[r]?.defaultModel||"provider default"]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs(l,{variant:"ghost",onClick:()=>b.length>0?i("account"):i("provider"),children:[e.jsx(L,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l,{variant:"ghost",onClick:d,children:"Skip"}),e.jsx(l,{onClick:he,disabled:!h||m.isPending,children:m.isPending?"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"})]}),t==="success"&&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(D,{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(K,{children:e.jsxs(W,{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 ",h,' "your prompt here"']})]})}),e.jsx(l,{onClick:d,className:"w-full",children:"Done"})]})]}),e.jsx("div",{className:"flex justify-center gap-1 pt-2",children:Q.map((s,q)=>e.jsx("div",{className:`w-2 h-2 rounded-full transition-colors ${pe>=q?"bg-primary":"bg-muted"}`},s))})]})})}function Ee({open:n,onClose:d,provider:t,displayName:i}){const[r,o]=u.useState(""),c=X(),x=()=>{c.mutate({provider:t,nickname:r.trim()||void 0},{onSuccess:()=>{o(""),d()}})},h=f=>{!f&&!c.isPending&&(o(""),d())};return e.jsx(ee,{open:n,onOpenChange:h,children:e.jsxs(se,{className:"sm:max-w-md",children:[e.jsxs(te,{children:[e.jsxs(ae,{children:["Add ",i," Account"]}),e.jsx(ne,{children:"Click the button below to authenticate a new account. A browser window will open for OAuth."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"nickname",children:"Nickname (optional)"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(G,{className:"w-4 h-4 text-muted-foreground"}),e.jsx(ie,{id:"nickname",value:r,onChange:f=>o(f.target.value),placeholder:"e.g., work, personal",disabled:c.isPending,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."})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[e.jsx(l,{variant:"ghost",onClick:d,disabled:c.isPending,children:"Cancel"}),e.jsx(l,{onClick:x,disabled:c.isPending,children:c.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-4 h-4 mr-2 animate-spin"}),"Authenticating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(O,{className:"w-4 h-4 mr-2"}),"Authenticate"]})})]}),c.isPending&&e.jsx("p",{className:"text-sm text-center text-muted-foreground",children:"Complete the OAuth flow in your browser..."})]})]})})}function Ke(n){if(!n)return"";const d=new Date(n).getTime(),i=Date.now()-d,r=Math.floor(i/(1e3*60*60)),o=Math.floor(i%(1e3*60*60)/(1e3*60));return r>0?`${r}h ${o}m`:`${o}m`}function We(n){if(!n)return"";const d=Date.now()-n,t=Math.floor(d/(1e3*60)),i=Math.floor(d/(1e3*60*60));return t<1?"just now":t<60?`${t}m ago`:`${i}h ago`}function Ye(){const{data:n,isLoading:d}=Ae(),{data:t}=ke(),i=Pe(),r=De(),o=n?.running??!1,c=i.isPending||r.isPending,x=t?.hasUpdate??!1,h=async()=>{await r.mutateAsync(),await new Promise(f=>setTimeout(f,500)),i.mutate()};return e.jsxs("div",{className:v("rounded-lg border p-3 transition-colors",o?"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:v("w-2 h-2 rounded-full",o?"bg-green-500 animate-pulse":"bg-muted-foreground/30")}),e.jsx("span",{className:"text-sm font-medium",children:"CLIProxy Service"}),x&&e.jsxs(I,{variant:"secondary",className:"text-[10px] h-4 px-1.5 gap-0.5 bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400",title:`Update: v${t?.currentVersion} -> v${t?.latestVersion}`,children:[e.jsx(_,{className:"w-2.5 h-2.5"}),"Update"]})]}),e.jsx("div",{className:"flex items-center gap-1",children:d?e.jsx(A,{className:"w-3 h-3 animate-spin text-muted-foreground"}):o?e.jsx(Ie,{className:"w-3 h-3 text-green-600"}):e.jsx(H,{className:"w-3 h-3 text-muted-foreground"})})]}),o&&n?e.jsxs(e.Fragment,{children:[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 ",n.port]}),n.sessionCount!==void 0&&n.sessionCount>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ue,{className:"w-3 h-3"}),n.sessionCount," session",n.sessionCount!==1?"s":""]}),n.startedAt&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ze,{className:"w-3 h-3"}),Ke(n.startedAt)]})]}),e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsxs(l,{variant:x?"default":"outline",size:"sm",className:v("h-7 text-xs gap-1 flex-1",x&&"bg-sidebar-accent hover:bg-sidebar-accent/90 text-sidebar-accent-foreground"),onClick:h,disabled:c,title:x?`Restart to update: v${t?.currentVersion} -> v${t?.latestVersion}`:"Restart CLIProxy service",children:[c?e.jsx(A,{className:"w-3 h-3 animate-spin"}):x?e.jsx(_,{className:"w-3 h-3"}):e.jsx($e,{className:"w-3 h-3"}),x?"Update":"Restart"]}),e.jsxs(l,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1 hover:bg-destructive/10 hover:text-destructive hover:border-destructive/30",onClick:()=>r.mutate(),disabled:c,title:"Stop CLIProxy service",children:[r.isPending?e.jsx(A,{className:"w-3 h-3 animate-spin"}):e.jsx(Qe,{className:"w-3 h-3"}),"Stop"]})]})]}):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(l,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1",onClick:()=>i.mutate(),disabled:i.isPending,children:[i.isPending?e.jsx(A,{className:"w-3 h-3 animate-spin"}):e.jsx(H,{className:"w-3 h-3"}),"Start"]})]}),t?.currentVersion&&e.jsxs("div",{className:"mt-2 pt-2 border-t border-muted flex items-center justify-between text-[10px] text-muted-foreground/70",children:[e.jsxs("span",{children:["v",t.currentVersion]}),t.checkedAt&&e.jsxs("span",{title:new Date(t.checkedAt).toLocaleString(),children:["Synced ",We(t.checkedAt)]})]})]})}function _e({status:n,isSelected:d,onSelect:t}){const i=n.accounts?.length||0;return e.jsxs("button",{className:v("w-full flex items-center gap-3 px-3 py-2.5 rounded-lg transition-colors cursor-pointer text-left",d?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:t,children:[e.jsx(re,{provider:n.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:n.displayName}),i>0&&e.jsx(I,{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:n.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(D,{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(le,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Not connected"})]})})]})]})}function He({variant:n,parentAuth:d,isSelected:t,onSelect:i,onDelete:r,isDeleting:o}){return e.jsxs("button",{className:v("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(re,{provider:n.provider,size:"sm"}),e.jsx(oe,{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:n.name}),e.jsx(I,{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:d?.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(D,{className:"w-3 h-3 text-green-600"}),e.jsxs("span",{className:"text-xs text-muted-foreground truncate",children:["via ",n.provider]})]}):e.jsxs(e.Fragment,{children:[e.jsx(le,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Parent not connected"})]})})]}),e.jsx(l,{variant:"ghost",size:"icon",className:"h-6 w-6 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:c=>{c.stopPropagation(),r()},disabled:o,children:e.jsx(qe,{className:"w-3 h-3"})})]})}function Je({onSetup:n}){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(de,{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(l,{onClick:n,className:"gap-2",children:[e.jsx(U,{className:"w-4 h-4"}),"Quick Setup"]})]})})}function ls(){const n=je(),{data:d,isLoading:t}=Z(),{data:i,isFetching:r}=Me(),o=Fe(),c=Re(),x=Ve(),[h,f]=u.useState(null),[N,k]=u.useState(null),[R,w]=u.useState(!1),[y,C]=u.useState(null),p=d?.authStatus||[],S=i?.variants||[],P=u.useMemo(()=>N?null:h&&p.some(a=>a.provider===h)?h:p.length>0?p[0].provider:null,[h,N,p]),g=p.find(a=>a.provider===P),m=S.find(a=>a.name===N),j=m?p.find(a=>a.provider===m.provider):void 0,M=()=>{n.invalidateQueries({queryKey:["cliproxy"]}),n.invalidateQueries({queryKey:["cliproxy-auth"]})},z=a=>{f(a),k(null)},b=a=>{k(a),f(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(de,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:"CLIProxy"})]}),e.jsx(l,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:M,disabled:r,children:e.jsx(A,{className:v("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(l,{variant:"default",size:"sm",className:"w-full gap-2",onClick:()=>w(!0),children:[e.jsx(U,{className:"w-4 h-4"}),"Quick Setup"]})]}),e.jsx(Le,{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(a=>e.jsx(Te,{className:"h-14 w-full rounded-lg"},a))}):e.jsx("div",{className:"space-y-1",children:p.map(a=>e.jsx(_e,{status:a,isSelected:P===a.provider,onSelect:()=>z(a.provider)},a.provider))}),S.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(oe,{className:"w-3 h-3"}),"Variants"]}),e.jsx("div",{className:"space-y-1",children:S.map(a=>e.jsx(He,{variant:a,parentAuth:p.find(V=>V.provider===a.provider),isSelected:N===a.name,onSelect:()=>b(a.name),onDelete:()=>x.mutate(a.name),isDeleting:x.isPending},a.name))})]})]})}),e.jsx("div",{className:"p-3 border-t",children:e.jsx(Ye,{})}),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:[p.length," provider",p.length!==1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(D,{className:"w-3 h-3 text-green-600"}),p.filter(a=>a.authenticated).length," connected"]})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-background",children:m&&j?e.jsx(E,{provider:m.name,displayName:`${m.name} (${m.provider} variant)`,authStatus:j,catalog:F[m.provider],logoProvider:m.provider,onAddAccount:()=>C({provider:m.provider,displayName:j.displayName}),onSetDefault:a=>o.mutate({provider:m.provider,accountId:a}),onRemoveAccount:a=>c.mutate({provider:m.provider,accountId:a}),isRemovingAccount:c.isPending}):g?e.jsx(E,{provider:g.provider,displayName:g.displayName,authStatus:g,catalog:F[g.provider],onAddAccount:()=>C({provider:g.provider,displayName:g.displayName}),onSetDefault:a=>o.mutate({provider:g.provider,accountId:a}),onRemoveAccount:a=>c.mutate({provider:g.provider,accountId:a}),isRemovingAccount:c.isPending}):e.jsx(Je,{onSetup:()=>w(!0)})}),e.jsx(Be,{open:R,onClose:()=>w(!1)}),e.jsx(Ee,{open:y!==null,onClose:()=>C(null),provider:y?.provider||"",displayName:y?.displayName||""})]})}export{ls as CliproxyPage};
|