@kaitranntt/ccs 6.6.2-dev.3 → 6.7.0-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/ccs.js +5 -0
- package/dist/ccs.js.map +1 -1
- package/dist/cliproxy/cliproxy-executor.d.ts.map +1 -1
- package/dist/cliproxy/cliproxy-executor.js +4 -0
- package/dist/cliproxy/cliproxy-executor.js.map +1 -1
- package/dist/ui/assets/{accounts-BXfC8K1x.js → accounts-BMWLqlfE.js} +1 -1
- package/dist/ui/assets/{analytics-CknzoRYp.js → analytics-HpEEt606.js} +1 -1
- package/dist/ui/assets/{api-U2LP6WF0.js → api-BHNxPjjt.js} +1 -1
- package/dist/ui/assets/{card-CpMqDjRa.js → card-DQcAIoan.js} +1 -1
- package/dist/ui/assets/{cliproxy-BEEaca31.js → cliproxy-BXOWLqyH.js} +1 -1
- package/dist/ui/assets/{code-editor-DmM_bX-t.js → code-editor-DxImO7VE.js} +1 -1
- package/dist/ui/assets/{copilot-CQuiaJtb.js → copilot-CgYR2YcH.js} +2 -2
- package/dist/ui/assets/{health-BDkQz8vK.js → health-DJRHl0eA.js} +1 -1
- package/dist/ui/assets/{index-eojxvUPJ.js → index-DlEL4vYD.js} +4 -4
- package/dist/ui/assets/{settings-C7wCYzo1.js → settings-DAj4fuUJ.js} +1 -1
- package/dist/ui/assets/{shared-QDPeNpnv.js → shared-DJmTnvUs.js} +1 -1
- package/dist/ui/assets/{switch-K-cpw7I2.js → switch-D391CjDF.js} +1 -1
- package/dist/ui/index.html +1 -1
- package/dist/web-server/routes.d.ts.map +1 -1
- package/dist/web-server/routes.js +58 -22
- package/dist/web-server/routes.js.map +1 -1
- package/package.json +1 -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-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
|
+
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 +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-DQcAIoan.js";import{aa as c,ab as x,a5 as u,ac as h,a6 as p,B as g}from"./index-DlEL4vYD.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-DlEL4vYD.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-DlEL4vYD.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":"routes.d.ts","sourceRoot":"","sources":["../../src/web-server/routes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/web-server/routes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAwEH,eAAO,MAAM,SAAS,4CAAW,CAAC"}
|
|
@@ -52,6 +52,7 @@ const secrets_manager_1 = require("../config/secrets-manager");
|
|
|
52
52
|
const unified_config_loader_2 = require("../config/unified-config-loader");
|
|
53
53
|
const unified_config_types_1 = require("../config/unified-config-types");
|
|
54
54
|
const sensitive_keys_1 = require("../utils/sensitive-keys");
|
|
55
|
+
const reserved_names_1 = require("../config/reserved-names");
|
|
55
56
|
const websearch_manager_1 = require("../utils/websearch-manager");
|
|
56
57
|
exports.apiRoutes = (0, express_1.Router)();
|
|
57
58
|
/**
|
|
@@ -210,6 +211,14 @@ exports.apiRoutes.post('/profiles', (req, res) => {
|
|
|
210
211
|
res.status(400).json({ error: 'Missing required fields: name, baseUrl, apiKey' });
|
|
211
212
|
return;
|
|
212
213
|
}
|
|
214
|
+
// Validate reserved names
|
|
215
|
+
if ((0, reserved_names_1.isReservedName)(name)) {
|
|
216
|
+
res.status(400).json({
|
|
217
|
+
error: `Profile name '${name}' is reserved`,
|
|
218
|
+
reserved: reserved_names_1.RESERVED_PROFILE_NAMES,
|
|
219
|
+
});
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
213
222
|
const config = readConfigSafe();
|
|
214
223
|
if (config.profiles[name]) {
|
|
215
224
|
res.status(409).json({ error: 'Profile already exists' });
|
|
@@ -293,6 +302,14 @@ exports.apiRoutes.post('/cliproxy', (req, res) => {
|
|
|
293
302
|
res.status(400).json({ error: 'Missing required fields: name, provider' });
|
|
294
303
|
return;
|
|
295
304
|
}
|
|
305
|
+
// Reject reserved names as variant names (prevents collision with built-in providers)
|
|
306
|
+
if ((0, reserved_names_1.isReservedName)(name)) {
|
|
307
|
+
res.status(400).json({
|
|
308
|
+
error: `Cannot use reserved name '${name}' as variant name`,
|
|
309
|
+
reserved: reserved_names_1.RESERVED_PROFILE_NAMES,
|
|
310
|
+
});
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
296
313
|
const config = readConfigSafe();
|
|
297
314
|
config.cliproxy = config.cliproxy || {};
|
|
298
315
|
if (config.cliproxy[name]) {
|
|
@@ -372,10 +389,13 @@ exports.apiRoutes.delete('/cliproxy/:name', (req, res) => {
|
|
|
372
389
|
res.status(404).json({ error: 'Variant not found' });
|
|
373
390
|
return;
|
|
374
391
|
}
|
|
375
|
-
//
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
392
|
+
// Never delete settings files for reserved provider names (safety guard)
|
|
393
|
+
if (!(0, reserved_names_1.isReservedName)(name)) {
|
|
394
|
+
// Only delete settings file for non-reserved variant names
|
|
395
|
+
const settingsPath = path.join((0, config_manager_1.getCcsDir)(), `${name}.settings.json`);
|
|
396
|
+
if (fs.existsSync(settingsPath)) {
|
|
397
|
+
fs.unlinkSync(settingsPath);
|
|
398
|
+
}
|
|
379
399
|
}
|
|
380
400
|
delete config.cliproxy[name];
|
|
381
401
|
writeConfig(config);
|
|
@@ -631,33 +651,40 @@ exports.apiRoutes.get('/settings/:profile/raw', (req, res) => {
|
|
|
631
651
|
});
|
|
632
652
|
/**
|
|
633
653
|
* PUT /api/settings/:profile - Update settings with conflict detection and backup
|
|
654
|
+
* Creates the settings file if it doesn't exist (upsert behavior)
|
|
634
655
|
*/
|
|
635
656
|
exports.apiRoutes.put('/settings/:profile', (req, res) => {
|
|
636
657
|
const { profile } = req.params;
|
|
637
658
|
const { settings, expectedMtime } = req.body;
|
|
638
659
|
const ccsDir = (0, config_manager_1.getCcsDir)();
|
|
639
660
|
const settingsPath = path.join(ccsDir, `${profile}.settings.json`);
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
661
|
+
const fileExists = fs.existsSync(settingsPath);
|
|
662
|
+
// Only check conflict if file exists and expectedMtime was provided
|
|
663
|
+
if (fileExists && expectedMtime) {
|
|
664
|
+
const stat = fs.statSync(settingsPath);
|
|
665
|
+
if (stat.mtime.getTime() !== expectedMtime) {
|
|
666
|
+
res.status(409).json({
|
|
667
|
+
error: 'File modified externally',
|
|
668
|
+
currentMtime: stat.mtime.getTime(),
|
|
669
|
+
});
|
|
670
|
+
return;
|
|
671
|
+
}
|
|
643
672
|
}
|
|
644
|
-
//
|
|
645
|
-
|
|
646
|
-
if (
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
}
|
|
651
|
-
|
|
673
|
+
// Create backup only if file exists
|
|
674
|
+
let backupPath;
|
|
675
|
+
if (fileExists) {
|
|
676
|
+
const backupDir = path.join(ccsDir, 'backups');
|
|
677
|
+
if (!fs.existsSync(backupDir)) {
|
|
678
|
+
fs.mkdirSync(backupDir, { recursive: true });
|
|
679
|
+
}
|
|
680
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
681
|
+
backupPath = path.join(backupDir, `${profile}.${timestamp}.settings.json`);
|
|
682
|
+
fs.copyFileSync(settingsPath, backupPath);
|
|
652
683
|
}
|
|
653
|
-
//
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
fs.mkdirSync(backupDir, { recursive: true });
|
|
684
|
+
// Ensure directory exists for new files
|
|
685
|
+
if (!fileExists) {
|
|
686
|
+
fs.mkdirSync(path.dirname(settingsPath), { recursive: true });
|
|
657
687
|
}
|
|
658
|
-
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
659
|
-
const backupPath = path.join(backupDir, `${profile}.${timestamp}.settings.json`);
|
|
660
|
-
fs.copyFileSync(settingsPath, backupPath);
|
|
661
688
|
// Write new settings atomically
|
|
662
689
|
const tempPath = settingsPath + '.tmp';
|
|
663
690
|
fs.writeFileSync(tempPath, JSON.stringify(settings, null, 2) + '\n');
|
|
@@ -667,6 +694,7 @@ exports.apiRoutes.put('/settings/:profile', (req, res) => {
|
|
|
667
694
|
profile,
|
|
668
695
|
mtime: newStat.mtime.getTime(),
|
|
669
696
|
backupPath,
|
|
697
|
+
created: !fileExists,
|
|
670
698
|
});
|
|
671
699
|
});
|
|
672
700
|
// ==================== Presets ====================
|
|
@@ -1347,6 +1375,14 @@ exports.apiRoutes.post('/cliproxy/openai-compat', (req, res) => {
|
|
|
1347
1375
|
res.status(400).json({ error: 'name is required' });
|
|
1348
1376
|
return;
|
|
1349
1377
|
}
|
|
1378
|
+
// Validate reserved names
|
|
1379
|
+
if ((0, reserved_names_1.isReservedName)(name)) {
|
|
1380
|
+
res.status(400).json({
|
|
1381
|
+
error: `Provider name '${name}' is reserved`,
|
|
1382
|
+
reserved: reserved_names_1.RESERVED_PROFILE_NAMES,
|
|
1383
|
+
});
|
|
1384
|
+
return;
|
|
1385
|
+
}
|
|
1350
1386
|
if (!baseUrl || typeof baseUrl !== 'string') {
|
|
1351
1387
|
res.status(400).json({ error: 'baseUrl is required' });
|
|
1352
1388
|
return;
|