@kaitranntt/ccs 6.6.1 → 6.6.2-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cliproxy/config-generator.d.ts +1 -1
- package/dist/cliproxy/config-generator.d.ts.map +1 -1
- package/dist/cliproxy/config-generator.js +5 -1
- package/dist/cliproxy/config-generator.js.map +1 -1
- package/dist/cliproxy/remote-proxy-client.d.ts +7 -2
- package/dist/cliproxy/remote-proxy-client.d.ts.map +1 -1
- package/dist/cliproxy/remote-proxy-client.js +36 -2
- package/dist/cliproxy/remote-proxy-client.js.map +1 -1
- package/dist/config/unified-config-loader.d.ts.map +1 -1
- package/dist/config/unified-config-loader.js +2 -1
- package/dist/config/unified-config-loader.js.map +1 -1
- package/dist/config/unified-config-types.d.ts +9 -2
- package/dist/config/unified-config-types.d.ts.map +1 -1
- package/dist/config/unified-config-types.js +2 -1
- package/dist/config/unified-config-types.js.map +1 -1
- package/dist/ui/assets/{accounts-DNYYJ7ul.js → accounts-BXfC8K1x.js} +1 -1
- package/dist/ui/assets/{analytics-Dhp2ikxe.js → analytics-CknzoRYp.js} +1 -1
- package/dist/ui/assets/{api-CZf-jQ-_.js → api-U2LP6WF0.js} +1 -1
- package/dist/ui/assets/{card--rU2tDlq.js → card-CpMqDjRa.js} +1 -1
- package/dist/ui/assets/{cliproxy-DZ_5oEVY.js → cliproxy-BEEaca31.js} +1 -1
- package/dist/ui/assets/{code-editor-CYOD5x0C.js → code-editor-DmM_bX-t.js} +1 -1
- package/dist/ui/assets/{copilot-Dd0yazW6.js → copilot-CQuiaJtb.js} +2 -2
- package/dist/ui/assets/{health-CyZQOQg7.js → health-BDkQz8vK.js} +1 -1
- package/dist/ui/assets/{index-Ced9Xuhx.js → index-eojxvUPJ.js} +3 -3
- package/dist/ui/assets/settings-C7wCYzo1.js +1 -0
- package/dist/ui/assets/{shared-BG9bijB0.js → shared-QDPeNpnv.js} +1 -1
- package/dist/ui/assets/{switch-fBCFt0Fe.js → switch-K-cpw7I2.js} +1 -1
- package/dist/ui/index.html +1 -1
- package/dist/web-server/routes/proxy-routes.d.ts.map +1 -1
- package/dist/web-server/routes/proxy-routes.js +7 -3
- package/dist/web-server/routes/proxy-routes.js.map +1 -1
- package/package.json +1 -1
- package/dist/ui/assets/settings-COL3veEu.js +0 -1
|
@@ -0,0 +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-eojxvUPJ.js";import{S as V}from"./switch-K-cpw7I2.js";import{CodeEditor as xs}from"./code-editor-DmM_bX-t.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 +1 @@
|
|
|
1
|
-
import{j as s}from"./radix-ui-DFHQr9A5.js";import{r as d}from"./react-vendor-FspHSO0w.js";import{C as l,a as m}from"./card
|
|
1
|
+
import{j as s}from"./radix-ui-DFHQr9A5.js";import{r as d}from"./react-vendor-FspHSO0w.js";import{C as l,a as m}from"./card-CpMqDjRa.js";import{aa as c,ab as x,a5 as u,ac as h,a6 as p,B as g}from"./index-eojxvUPJ.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]=d.useState("commands"),{data:e}=c(),{data:n,isLoading:i}=x(t),o=[{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:o.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-eojxvUPJ.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-eojxvUPJ.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">
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy-routes.d.ts","sourceRoot":"","sources":["../../../src/web-server/routes/proxy-routes.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAUH,QAAA,MAAM,MAAM,4CAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"proxy-routes.d.ts","sourceRoot":"","sources":["../../../src/web-server/routes/proxy-routes.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAUH,QAAA,MAAM,MAAM,4CAAW,CAAC;AAoFxB,eAAe,MAAM,CAAC"}
|
|
@@ -65,13 +65,17 @@ router.put('/', async (req, res) => {
|
|
|
65
65
|
router.post('/test', async (req, res) => {
|
|
66
66
|
try {
|
|
67
67
|
const { host, port, protocol, authToken, allowSelfSigned } = req.body;
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
// Host is required, port is optional (uses protocol defaults)
|
|
69
|
+
if (!host) {
|
|
70
|
+
res.status(400).json({ error: 'Host is required' });
|
|
70
71
|
return;
|
|
71
72
|
}
|
|
73
|
+
// Parse port - treat empty string, 0, null as "use default"
|
|
74
|
+
const parsedPort = port && port !== '' ? parseInt(String(port), 10) : undefined;
|
|
75
|
+
const effectivePort = parsedPort && !isNaN(parsedPort) && parsedPort > 0 ? parsedPort : undefined;
|
|
72
76
|
const status = await (0, remote_proxy_client_1.testConnection)({
|
|
73
77
|
host,
|
|
74
|
-
port:
|
|
78
|
+
port: effectivePort,
|
|
75
79
|
protocol: protocol || 'http',
|
|
76
80
|
authToken,
|
|
77
81
|
allowSelfSigned: allowSelfSigned || false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy-routes.js","sourceRoot":"","sources":["../../../src/web-server/routes/proxy-routes.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;AAEH,qCAAoD;AACpD,8EAAkG;AACl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";import{a1 as oe,a2 as rs,a3 as Ae,V as ls,W as ns,X as ce,a4 as os,B as w,a5 as ue,a6 as he,i as pe,I as G,z as cs,A as ds,E as is,F as ms,G as Re}from"./index-Ced9Xuhx.js";import{S as V}from"./switch-fBCFt0Fe.js";import{CodeEditor as xs}from"./code-editor-CYOD5x0C.js";import{J as k,am as us,z as hs,a6 as ps,k as bs,an as Ge,j as fs,o as gs,ac as be,l as se,t as de,x as ie,y as me,D as xe,N as js,V as Ns,ao as vs,ap as _e,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,N]=r.useState(o),[l,h]=r.useState(null),[c,C]=r.useState(!0),[_,v]=r.useState(!1),[S,f]=r.useState(null),[F,d]=r.useState(!1),[E,D]=r.useState(null),[W,z]=r.useState(!0),[y,g]=r.useState(null),[I,M]=r.useState(!1),[O,$]=r.useState(!1),[L,P]=r.useState(""),[j,U]=r.useState(""),[J,T]=r.useState(!1),[A,K]=r.useState(!1),[X,te]=r.useState(!1),[p,H]=r.useState(null),[ae,n]=r.useState(!0),[Fe,fe]=r.useState(!1),[ze,Q]=r.useState(null),[Me,ge]=r.useState(!1),[re,je]=r.useState(""),[Ne,ve]=r.useState(""),[R,Z]=r.useState(null),[$e,ye]=r.useState(!0),[Be,we]=r.useState(!1),[Ve,B]=r.useState(null),[Oe,ke]=r.useState(!1),[He,le]=r.useState(null),[De,Ce]=r.useState(!1);r.useEffect(()=>{Se(),Ee(),Y(),Pe(),Te()},[]),r.useEffect(()=>{l&&(P(l.providers?.gemini?.model??"gemini-2.5-flash"),U(l.providers?.opencode?.model??"opencode/grok-code"))},[l]);const Se=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)}},Ee=async()=>{try{z(!0);const s=await fetch("/api/websearch/status");if(!s.ok)throw new Error("Failed to load status");const a=await s.json();D(a)}catch(s){console.error("Failed to fetch WebSearch status:",s)}finally{z(!1)}},Y=async()=>{try{M(!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{M(!1)}},Pe=async()=>{try{n(!0),Q(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){Q(s.message)}finally{n(!1)}},Te=async()=>{try{ye(!0),B(null);const s=await oe.cliproxyServer.get();Z(s)}catch(s){B(s.message)}finally{ye(!1)}},We=async()=>{if(y)try{await navigator.clipboard.writeText(y),$(!0),setTimeout(()=>$(!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;q({enabled:!a||i||b,providers:{...s,gemini:{...s.gemini,enabled:!a}}})},q=async s=>{if(!l)return;const a={...l,...s};h(a);try{v(!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),d(!0),setTimeout(()=>d(!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{v(!1)}},ne=l?.providers?.gemini?.enabled??!1,Ie=l?.providers?.grok?.enabled??!1,Le=l?.providers?.opencode?.enabled??!1,Ye=()=>{const s=l?.providers||{},a=s.grok?.enabled??!1;q({enabled:ne||!a||Le,providers:{...s,grok:{...s.grok,enabled:!a}}})},qe=()=>{const s=l?.providers||{},a=s.opencode?.enabled??!1;q({enabled:ne||Ie||!a,providers:{...s,opencode:{...s.opencode,enabled:!a}}})},Je=()=>{const s=l?.providers?.gemini?.model??"gemini-2.5-flash";if(L!==s){const a=l?.providers||{};q({providers:{...a,gemini:{...a.gemini,model:L}}})}},Ke=()=>{const s=l?.providers?.opencode?.model??"opencode/grok-code";if(j!==s){const a=l?.providers||{};q({providers:{...a,opencode:{...a.opencode,model:j}}})}},ee=async s=>{if(!p)return;const a={...p,...s};H(a);try{fe(!0),Q(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),ge(!0),setTimeout(()=>ge(!1),1500),fetch("/api/config/raw").then(m=>m.ok?m.text():null).then(m=>m&&g(m)).catch(()=>{})}catch(i){H(p),Q(i.message)}finally{fe(!1)}},Xe=()=>{ee({enabled:!p?.enabled})},Qe=()=>{if(!re.trim()||!p)return;const s={...p.env,[re.trim()]:Ne};ee({env:s}),je(""),ve("")},Ze=s=>{if(!p)return;const a={...p.env};delete a[s],ee({env:a})},es=(s,a)=>{if(!p)return;const i={...p.env,[s]:a};ee({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}};Z(a),le(null);try{we(!0),B(null);const i=await oe.cliproxyServer.update(s);Z(i),ke(!0),setTimeout(()=>ke(!1),1500),fetch("/api/config/raw").then(b=>b.ok?b.text():null).then(b=>b&&g(b)).catch(()=>{})}catch(i){Z(R),B(i.message)}finally{we(!1)}},ts=async()=>{if(!R)return;const{host:s,port:a,protocol:i,auth_token:b}=R.remote;if(!s||!a){B("Host and port are required");return}try{Ce(!0),B(null),le(null);const m=await oe.cliproxyServer.test({host:s,port:a,protocol:i,authToken:b||void 0});le(m)}catch(m){B(m.message)}finally{Ce(!1)}};return c?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(Ae,{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=>N(s),children:e.jsxs(ns,{className:"w-full",children:[e.jsxs(ce,{value:"websearch",className:"flex-1 gap-2",children:[e.jsx(us,{className:"w-4 h-4"}),"WebSearch"]}),e.jsxs(ce,{value:"globalenv",className:"flex-1 gap-2",children:[e.jsx(hs,{className:"w-4 h-4"}),"Global Env"]}),e.jsxs(ce,{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:W,saving:_,error:S,success:F,isGeminiEnabled:ne,isGrokEnabled:Ie,isOpenCodeEnabled:Le,geminiModelInput:L,opencodeModelInput:j,showGeminiHint:J,showOpencodeHint:A,showGrokHint:X,setGeminiModelInput:P,setOpencodeModelInput:U,setShowGeminiHint:T,setShowOpencodeHint:K,setShowGrokHint:te,toggleGemini:Ue,toggleGrok:Ye,toggleOpenCode:qe,saveGeminiModel:Je,saveOpencodeModel:Ke,fetchStatus:Ee,fetchConfig:Se,fetchRawConfig:Y,loading:c}):u==="globalenv"?e.jsx(Cs,{config:p,loading:ae,saving:Fe,error:ze,success:Me,newEnvKey:re,newEnvValue:Ne,setNewEnvKey:je,setNewEnvValue:ve,toggleGlobalEnv:Xe,addEnvVar:Qe,removeEnvVar:Ze,updateEnvValue:es,fetchGlobalEnvConfig:Pe,fetchRawConfig:Y}):e.jsx(Ss,{config:R,loading:$e,saving:Be,error:Ve,success:Oe,testResult:He,testing:De,saveCliproxyServerConfig:ss,handleTestConnection:ts,fetchCliproxyServerConfig:Te,fetchRawConfig:Y})]})}),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(Ae,{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(Ge,{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:O?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:Y,disabled:I,children:e.jsx(k,{className:`w-4 h-4 ${I?"animate-spin":""}`})})]})]}),e.jsx("div",{className:"flex-1 overflow-auto",children:I?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(Ge,{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:N,isGeminiEnabled:l,isGrokEnabled:h,isOpenCodeEnabled:c,geminiModelInput:C,opencodeModelInput:_,showGeminiHint:v,showOpencodeHint:S,showGrokHint:f,setGeminiModelInput:F,setOpencodeModelInput:d,setShowGeminiHint:E,setShowOpencodeHint:D,setShowGrokHint:W,toggleGemini:z,toggleGrok:y,toggleOpenCode:g,saveGeminiModel:I,saveOpencodeModel:M,fetchStatus:O,fetchConfig:$,fetchRawConfig:L,loading:P}){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||N?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[u&&e.jsxs(ue,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(be,{className:"h-4 w-4"}),e.jsx(he,{children:u})]}),N&&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(se,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:"Saved"})]})]}),e.jsx(pe,{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:O,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(de,{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:z,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:I,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(!v),className:"flex items-center gap-2 text-sm text-amber-600 dark:text-amber-400 hover:underline w-full py-2",children:[v?e.jsx(ie,{className:"w-4 h-4"}):e.jsx(me,{className:"w-4 h-4"}),"How to install Gemini CLI"]}),v&&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(xe,{className:"w-3 h-3"}),"View documentation"]})]})]})]}),e.jsxs("div",{className:`rounded-lg border transition-colors ${c?"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(de,{className:`w-5 h-5 ${c?"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:c,onCheckedChange:g,disabled:o||!t?.opencodeCli?.installed})]}),c&&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=>d(j.target.value),onBlur:M,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:()=>D(!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(ie,{className:"w-4 h-4"}):e.jsx(me,{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(xe,{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(de,{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:()=>W(!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(ie,{className:"w-4 h-4"}):e.jsx(me,{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(xe,{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:()=>{$(),L()},disabled:P||o,className:"w-full",children:[e.jsx(k,{className:`w-4 h-4 mr-2 ${P?"animate-spin":""}`}),"Refresh"]})})]})}function Cs({config:t,loading:x,saving:o,error:u,success:N,newEnvKey:l,newEnvValue:h,setNewEnvKey:c,setNewEnvValue:C,toggleGlobalEnv:_,addEnvVar:v,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||N?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[u&&e.jsxs(ue,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(be,{className:"h-4 w-4"}),e.jsx(he,{children:u})]}),N&&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(se,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:"Saved"})]})]}),e.jsx(pe,{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(([d,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:d}),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(d),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"})})]},d))}):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:d=>c(d.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:d=>C(d.target.value),placeholder:"value",className:"flex-1 font-mono text-sm h-9",disabled:o}),e.jsxs(w,{size:"sm",onClick:v,disabled:o||!l.trim(),className:"h-9",children:[e.jsx(Ns,{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:d,value:E})=>!t?.env?.[d]&&e.jsxs(w,{variant:"outline",size:"sm",onClick:()=>{c(d),C(E)},className:"text-xs font-mono",children:["+ ",d]},d)),t?.env&&["DISABLE_BUG_COMMAND","DISABLE_ERROR_REPORTING","DISABLE_TELEMETRY"].every(d=>t.env[d])&&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:N,testResult:l,testing:h,saveCliproxyServerConfig:c,handleTestConnection:C,fetchCliproxyServerConfig:_,fetchRawConfig:v}){const S={enabled:!1,host:"",port:8317,protocol:"http",auth_token:""},f={enabled:!0,auto_start:!0},F={port:8317,auto_start:!0},d=t?.remote.host??"",E=(t?.remote.port??8317).toString(),D=t?.remote.auth_token??"",W=(t?.local.port??8317).toString(),[z,y]=r.useState(null),[g,I]=r.useState(null),[M,O]=r.useState(null),[$,L]=r.useState(null),P=z??d,j=g??E,U=M??D,J=$??W;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 T=t?.remote.enabled??!1,A=t?.remote??S,K=t?.fallback??f,X=t?.local??F,te=()=>{const n=z??P;n!==t?.remote.host&&c({remote:{...A,host:n}}),y(null)},p=()=>{const n=parseInt(g??j,10);!isNaN(n)&&n!==t?.remote.port&&c({remote:{...A,port:n}}),I(null)},H=()=>{const n=M??U;n!==t?.remote.auth_token&&c({remote:{...A,auth_token:n}}),O(null)},ae=()=>{const n=parseInt($??J,10);!isNaN(n)&&n!==t?.local.port&&c({local:{...X,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||N?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[u&&e.jsxs(ue,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(be,{className:"h-4 w-4"}),e.jsx(he,{children:u})]}),N&&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(se,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:"Saved"})]})]}),e.jsx(pe,{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:()=>c({remote:{...A,enabled:!1}}),disabled:o,className:`p-4 rounded-lg border-2 text-left transition-all ${T?"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(vs,{className:`w-5 h-5 ${T?"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:()=>c({remote:{...A,enabled:!0}}),disabled:o,className:`p-4 rounded-lg border-2 text-left transition-all ${T?"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(_e,{className:`w-5 h-5 ${T?"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"})]})]})]}),T&&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(_e,{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:P,onChange:n=>y(n.target.value),onBlur:te,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.jsx("label",{className:"text-sm text-muted-foreground",children:"Port"}),e.jsx(G,{type:"number",value:j,onChange:n=>I(n.target.value),onBlur:p,placeholder:"8317",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=>c({remote:{...A,protocol:n}}),disabled:o,children:[e.jsx(ds,{children:e.jsx(is,{})}),e.jsxs(ms,{children:[e.jsx(Re,{value:"http",children:"HTTP"}),e.jsx(Re,{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:U,onChange:n=>O(n.target.value),onBlur:H,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||!P||!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(se,{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=>c({fallback:{...K,enabled:n}}),disabled:o||!T})]}),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=>c({fallback:{...K,auto_start:n}}),disabled:o||!T||!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:J,onChange:n=>L(n.target.value),onBlur:ae,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=>c({local:{...X,auto_start:n}}),disabled:o})]})]})]})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(w,{variant:"outline",size:"sm",onClick:()=>{_(),v()},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};
|