@kaitranntt/ccs 7.44.0 → 7.45.0

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.
Files changed (51) hide show
  1. package/dist/config/unified-config-loader.d.ts.map +1 -1
  2. package/dist/config/unified-config-loader.js +6 -0
  3. package/dist/config/unified-config-loader.js.map +1 -1
  4. package/dist/config/unified-config-types.d.ts +8 -0
  5. package/dist/config/unified-config-types.d.ts.map +1 -1
  6. package/dist/config/unified-config-types.js +1 -0
  7. package/dist/config/unified-config-types.js.map +1 -1
  8. package/dist/cursor/cursor-models.d.ts +3 -3
  9. package/dist/cursor/cursor-models.d.ts.map +1 -1
  10. package/dist/cursor/cursor-models.js +105 -22
  11. package/dist/cursor/cursor-models.js.map +1 -1
  12. package/dist/ui/assets/accounts-B8J62kJ6.js +1 -0
  13. package/dist/ui/assets/{alert-dialog-z6HEaPqe.js → alert-dialog-B5t_5_UL.js} +1 -1
  14. package/dist/ui/assets/api-DuZyDFf7.js +1 -0
  15. package/dist/ui/assets/{auth-section-DXzTOTWo.js → auth-section-Dnaxf97q.js} +1 -1
  16. package/dist/ui/assets/{backups-section-BWlvR34E.js → backups-section-DUIq9Rxi.js} +1 -1
  17. package/dist/ui/assets/{cliproxy-BSyjTE6L.js → cliproxy-aK19VC4f.js} +2 -2
  18. package/dist/ui/assets/{cliproxy-control-panel-CKJHMGqD.js → cliproxy-control-panel-9OS_kdTh.js} +1 -1
  19. package/dist/ui/assets/confirm-dialog-D7hNt3ez.js +1 -0
  20. package/dist/ui/assets/copilot-B5dVoOMQ.js +3 -0
  21. package/dist/ui/assets/cursor-4zDGbBRA.js +1 -0
  22. package/dist/ui/assets/globalenv-section-DuUcheRN.js +1 -0
  23. package/dist/ui/assets/{health-Dqa61Bj1.js → health-Ddkl8zIJ.js} +1 -1
  24. package/dist/ui/assets/{icons-G0rMFC4M.js → icons-DGASzt3M.js} +1 -1
  25. package/dist/ui/assets/{index-DacpfVrt.js → index-BRCdKMse.js} +1 -1
  26. package/dist/ui/assets/{index-CiJndnpm.js → index-BRxqvMyp.js} +1 -1
  27. package/dist/ui/assets/index-C6u1zYVL.css +1 -0
  28. package/dist/ui/assets/{index-akX3q-m-.js → index-D0I8OsQ3.js} +1 -1
  29. package/dist/ui/assets/{index-qMp3rvH4.js → index-DOxNxHpI.js} +1 -1
  30. package/dist/ui/assets/{index-DGFnVfdv.js → index-Dv5jtphl.js} +17 -17
  31. package/dist/ui/assets/{proxy-status-widget-CSq7bxEv.js → proxy-status-widget-DKYj4dWI.js} +1 -1
  32. package/dist/ui/assets/separator-DrDw3JjB.js +1 -0
  33. package/dist/ui/assets/shared-psG1uSqB.js +1 -0
  34. package/dist/ui/assets/sidebar/cursor.svg +1 -0
  35. package/dist/ui/assets/{switch-Cr9fAsnM.js → switch-C0ri2ChT.js} +1 -1
  36. package/dist/ui/index.html +3 -3
  37. package/dist/web-server/routes/cursor-routes.d.ts.map +1 -1
  38. package/dist/web-server/routes/cursor-routes.js +1 -1
  39. package/dist/web-server/routes/cursor-routes.js.map +1 -1
  40. package/dist/web-server/routes/cursor-settings-routes.d.ts.map +1 -1
  41. package/dist/web-server/routes/cursor-settings-routes.js +114 -18
  42. package/dist/web-server/routes/cursor-settings-routes.js.map +1 -1
  43. package/package.json +1 -1
  44. package/dist/ui/assets/accounts-D7apG3NM.js +0 -1
  45. package/dist/ui/assets/api-C-aJLAbg.js +0 -1
  46. package/dist/ui/assets/confirm-dialog-D8vB20zr.js +0 -1
  47. package/dist/ui/assets/copilot-7sa7MFH_.js +0 -4
  48. package/dist/ui/assets/cursor-KwsbcPyA.js +0 -1
  49. package/dist/ui/assets/globalenv-section-BiyiJmIj.js +0 -1
  50. package/dist/ui/assets/index-Bqle3SG4.css +0 -1
  51. package/dist/ui/assets/shared-DvyiNZGg.js +0 -1
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-qEZD5MMp.js";import{r}from"./react-vendor-CNOkPC89.js";import{aU as R,aW as A,b as C,m as M,L as D,X as L,Y as $,Z as F,_ as K,$ as z}from"./index-DGFnVfdv.js";import{S as H}from"./switch-Cr9fAsnM.js";import{R as y,a2 as O,r as U,a4 as W,I as G}from"./icons-G0rMFC4M.js";import"./tanstack-De4wvi8X.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";const p={mode:"auto",tier_defaults:{opus:"high",sonnet:"medium",haiku:"low"},show_warnings:!0},T=1e4;function V(){const[a,i]=r.useState(null),[x,u]=r.useState(!0),[j,c]=r.useState(!1),[b,l]=r.useState(null),[N,s]=r.useState(!1),o=r.useRef(void 0),v=r.useCallback(async()=>{const n=new AbortController,m=setTimeout(()=>n.abort(),T);try{u(!0),l(null);const t=await fetch("/api/thinking",{signal:n.signal});if(clearTimeout(m),!t.ok)throw t.headers.get("content-type")?.includes("text/html")?new Error(`Server error (${t.status})`):new Error("Failed to load Thinking config");const g=await t.json();i(g.config||p),o.current=g.lastModified}catch(t){clearTimeout(m),t.name==="AbortError"?l("Request timeout - please try again"):l(t.message),i(p)}finally{u(!1)}return()=>n.abort()},[]),d=r.useCallback(async n=>{const m=a||p,t={...m,...n};i(t);const g=new AbortController,w=setTimeout(()=>g.abort(),T);try{c(!0),l(null);const f={...t,lastModified:o.current},h=await fetch("/api/thinking",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(f),signal:g.signal});if(clearTimeout(w),!h.ok){if(h.headers.get("content-type")?.includes("text/html"))throw new Error(`Server error (${h.status})`);const I=await h.json();throw h.status===409?new Error("Config changed by another session. Refreshing..."):new Error(I.error||"Failed to save")}const k=await h.json();i(k.config),o.current=k.lastModified,s(!0),setTimeout(()=>s(!1),1500)}catch(f){clearTimeout(w),i(m),f.name==="AbortError"?l("Request timeout - please try again"):(l(f.message),f.message.includes("another session")&&setTimeout(()=>v(),1e3))}finally{c(!1)}},[a,v]),S=r.useCallback(n=>{d({mode:n})},[d]),E=r.useCallback((n,m)=>{const t=a?.tier_defaults||p.tier_defaults;d({tier_defaults:{...t,[n]:m}})},[a,d]),_=r.useCallback(n=>{d({show_warnings:n})},[d]);return{config:a||p,loading:x,saving:j,error:b,success:N,fetchConfig:v,saveConfig:d,setMode:S,setTierDefault:E,setShowWarnings:_}}const q=[{value:"minimal",label:"Minimal (512 tokens)"},{value:"low",label:"Low (1K tokens)"},{value:"medium",label:"Medium (8K tokens)"},{value:"high",label:"High (24K tokens)"},{value:"xhigh",label:"Extra High (32K tokens)"},{value:"auto",label:"Auto (dynamic)"}];function ae(){const{config:a,loading:i,saving:x,error:u,success:j,fetchConfig:c,setMode:b,setTierDefault:l,setShowWarnings:N}=V();return r.useEffect(()=>{c()},[c]),i?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx(y,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:"Loading..."})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${u||j?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[u&&e.jsx(R,{variant:"destructive",className:"py-2 shadow-lg",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(O,{className:"h-4 w-4"}),e.jsx(A,{children:u})]}),e.jsxs(C,{variant:"outline",size:"sm",onClick:c,className:"h-7 px-2 text-xs border-destructive/50 hover:bg-destructive/10",children:[e.jsx(y,{className:"w-3 h-3 mr-1"}),"Retry"]})]})}),j&&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(U,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:"Saved"})]})]}),e.jsx(M,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(W,{className:"w-5 h-5 text-primary"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure extended thinking/reasoning for supported models."})]}),e.jsxs("div",{className:"flex items-start gap-2 p-3 rounded-lg bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800",children:[e.jsx(G,{className:"w-4 h-4 text-blue-600 dark:text-blue-400 shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-blue-700 dark:text-blue-300",children:[e.jsx("p",{className:"font-medium",children:"Supported Providers"}),e.jsxs("ul",{className:"mt-1 space-y-0.5 text-blue-600 dark:text-blue-400",children:[e.jsxs("li",{children:["Thinking budget: ",e.jsx("strong",{children:"agy"}),", ",e.jsx("strong",{children:"gemini"})," (token-based)"]}),e.jsxs("li",{children:["Reasoning effort: ",e.jsx("strong",{children:"codex"})," (suffix or ",e.jsx("code",{children:"--effort"}),": medium/high/xhigh)"]}),e.jsxs("li",{children:["Codex suffixes pin effort (for example ",e.jsx("code",{children:"-high"}),"); unsuffixed models use Thinking mode."]})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Thinking Mode"}),e.jsx("div",{className:"space-y-2",children:["auto","off","manual"].map(s=>e.jsxs("div",{className:`flex items-center justify-between p-4 rounded-lg cursor-pointer transition-colors ${a.mode===s?"bg-primary/10 border border-primary/30":"bg-muted/50 hover:bg-muted/80"}`,onClick:()=>b(s),children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium capitalize",children:s}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[s==="auto"&&"Automatically set thinking based on model tier",s==="off"&&"Disable extended thinking",s==="manual"&&"Use --thinking (agy/gemini) or --effort (codex) per run"]})]}),e.jsx("div",{className:`w-4 h-4 rounded-full border-2 ${a.mode===s?"bg-primary border-primary":"border-muted-foreground/50"}`})]},s))})]}),a.mode==="auto"&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Tier Defaults"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Default thinking level for each model tier when in auto mode."}),e.jsx("div",{className:"space-y-3",children:["opus","sonnet","haiku"].map(s=>e.jsxs("div",{className:"flex items-center gap-4 p-3 rounded-lg bg-muted/30",children:[e.jsx(D,{className:"w-20 capitalize font-medium",children:s}),e.jsxs(L,{value:a.tier_defaults[s],onValueChange:o=>l(s,o),disabled:x,children:[e.jsx($,{className:"flex-1",children:e.jsx(F,{})}),e.jsx(K,{children:q.map(o=>e.jsx(z,{value:o.value,children:o.label},o.value))})]})]},s))})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Show Warnings"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Display warnings when thinking values are clamped or adjusted"})]}),e.jsx(H,{checked:a.show_warnings??!0,onCheckedChange:N,disabled:x})]}),e.jsxs("div",{className:"p-4 rounded-lg border bg-muted/30",children:[e.jsx("h4",{className:"text-sm font-medium mb-2",children:"CLI Override"}),e.jsxs("p",{className:"text-sm text-muted-foreground mb-2",children:["Override per session with"," ",e.jsx("code",{className:"px-1.5 py-0.5 rounded bg-muted",children:"--thinking"})," (agy/gemini) or"," ",e.jsx("code",{className:"px-1.5 py-0.5 rounded bg-muted",children:"--effort"})," (codex):"]}),e.jsxs("div",{className:"space-y-1 text-sm font-mono text-muted-foreground",children:[e.jsx("p",{children:"ccs gemini --thinking high"}),e.jsx("p",{children:"ccs agy --thinking 16384"}),e.jsx("p",{children:"ccs codex --effort xhigh"}),e.jsx("p",{children:'ccs codex -p "Refactor this module" --effort xhigh'})]})]})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(C,{variant:"outline",size:"sm",onClick:c,disabled:i||x,className:"w-full",children:[e.jsx(y,{className:`w-4 h-4 mr-2 ${i?"animate-spin":""}`}),"Refresh"]})})]})}export{ae as default};
1
+ import{j as e}from"./radix-ui-qEZD5MMp.js";import{r}from"./react-vendor-CNOkPC89.js";import{aS as R,aU as A,b as C,m as M,L as D,X as L,Y as $,Z as F,_ as K,$ as z}from"./index-Dv5jtphl.js";import{S as H}from"./switch-C0ri2ChT.js";import{R as y,a1 as O,q as U,a3 as q,I as G}from"./icons-DGASzt3M.js";import"./tanstack-De4wvi8X.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";const p={mode:"auto",tier_defaults:{opus:"high",sonnet:"medium",haiku:"low"},show_warnings:!0},T=1e4;function V(){const[a,i]=r.useState(null),[x,u]=r.useState(!0),[j,c]=r.useState(!1),[b,l]=r.useState(null),[N,s]=r.useState(!1),o=r.useRef(void 0),v=r.useCallback(async()=>{const n=new AbortController,m=setTimeout(()=>n.abort(),T);try{u(!0),l(null);const t=await fetch("/api/thinking",{signal:n.signal});if(clearTimeout(m),!t.ok)throw t.headers.get("content-type")?.includes("text/html")?new Error(`Server error (${t.status})`):new Error("Failed to load Thinking config");const g=await t.json();i(g.config||p),o.current=g.lastModified}catch(t){clearTimeout(m),t.name==="AbortError"?l("Request timeout - please try again"):l(t.message),i(p)}finally{u(!1)}return()=>n.abort()},[]),d=r.useCallback(async n=>{const m=a||p,t={...m,...n};i(t);const g=new AbortController,w=setTimeout(()=>g.abort(),T);try{c(!0),l(null);const f={...t,lastModified:o.current},h=await fetch("/api/thinking",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(f),signal:g.signal});if(clearTimeout(w),!h.ok){if(h.headers.get("content-type")?.includes("text/html"))throw new Error(`Server error (${h.status})`);const I=await h.json();throw h.status===409?new Error("Config changed by another session. Refreshing..."):new Error(I.error||"Failed to save")}const k=await h.json();i(k.config),o.current=k.lastModified,s(!0),setTimeout(()=>s(!1),1500)}catch(f){clearTimeout(w),i(m),f.name==="AbortError"?l("Request timeout - please try again"):(l(f.message),f.message.includes("another session")&&setTimeout(()=>v(),1e3))}finally{c(!1)}},[a,v]),S=r.useCallback(n=>{d({mode:n})},[d]),E=r.useCallback((n,m)=>{const t=a?.tier_defaults||p.tier_defaults;d({tier_defaults:{...t,[n]:m}})},[a,d]),_=r.useCallback(n=>{d({show_warnings:n})},[d]);return{config:a||p,loading:x,saving:j,error:b,success:N,fetchConfig:v,saveConfig:d,setMode:S,setTierDefault:E,setShowWarnings:_}}const W=[{value:"minimal",label:"Minimal (512 tokens)"},{value:"low",label:"Low (1K tokens)"},{value:"medium",label:"Medium (8K tokens)"},{value:"high",label:"High (24K tokens)"},{value:"xhigh",label:"Extra High (32K tokens)"},{value:"auto",label:"Auto (dynamic)"}];function ae(){const{config:a,loading:i,saving:x,error:u,success:j,fetchConfig:c,setMode:b,setTierDefault:l,setShowWarnings:N}=V();return r.useEffect(()=>{c()},[c]),i?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx(y,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:"Loading..."})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${u||j?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[u&&e.jsx(R,{variant:"destructive",className:"py-2 shadow-lg",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(O,{className:"h-4 w-4"}),e.jsx(A,{children:u})]}),e.jsxs(C,{variant:"outline",size:"sm",onClick:c,className:"h-7 px-2 text-xs border-destructive/50 hover:bg-destructive/10",children:[e.jsx(y,{className:"w-3 h-3 mr-1"}),"Retry"]})]})}),j&&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(U,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:"Saved"})]})]}),e.jsx(M,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(q,{className:"w-5 h-5 text-primary"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure extended thinking/reasoning for supported models."})]}),e.jsxs("div",{className:"flex items-start gap-2 p-3 rounded-lg bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800",children:[e.jsx(G,{className:"w-4 h-4 text-blue-600 dark:text-blue-400 shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-blue-700 dark:text-blue-300",children:[e.jsx("p",{className:"font-medium",children:"Supported Providers"}),e.jsxs("ul",{className:"mt-1 space-y-0.5 text-blue-600 dark:text-blue-400",children:[e.jsxs("li",{children:["Thinking budget: ",e.jsx("strong",{children:"agy"}),", ",e.jsx("strong",{children:"gemini"})," (token-based)"]}),e.jsxs("li",{children:["Reasoning effort: ",e.jsx("strong",{children:"codex"})," (suffix or ",e.jsx("code",{children:"--effort"}),": medium/high/xhigh)"]}),e.jsxs("li",{children:["Codex suffixes pin effort (for example ",e.jsx("code",{children:"-high"}),"); unsuffixed models use Thinking mode."]})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Thinking Mode"}),e.jsx("div",{className:"space-y-2",children:["auto","off","manual"].map(s=>e.jsxs("div",{className:`flex items-center justify-between p-4 rounded-lg cursor-pointer transition-colors ${a.mode===s?"bg-primary/10 border border-primary/30":"bg-muted/50 hover:bg-muted/80"}`,onClick:()=>b(s),children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium capitalize",children:s}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[s==="auto"&&"Automatically set thinking based on model tier",s==="off"&&"Disable extended thinking",s==="manual"&&"Use --thinking (agy/gemini) or --effort (codex) per run"]})]}),e.jsx("div",{className:`w-4 h-4 rounded-full border-2 ${a.mode===s?"bg-primary border-primary":"border-muted-foreground/50"}`})]},s))})]}),a.mode==="auto"&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Tier Defaults"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Default thinking level for each model tier when in auto mode."}),e.jsx("div",{className:"space-y-3",children:["opus","sonnet","haiku"].map(s=>e.jsxs("div",{className:"flex items-center gap-4 p-3 rounded-lg bg-muted/30",children:[e.jsx(D,{className:"w-20 capitalize font-medium",children:s}),e.jsxs(L,{value:a.tier_defaults[s],onValueChange:o=>l(s,o),disabled:x,children:[e.jsx($,{className:"flex-1",children:e.jsx(F,{})}),e.jsx(K,{children:W.map(o=>e.jsx(z,{value:o.value,children:o.label},o.value))})]})]},s))})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Show Warnings"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Display warnings when thinking values are clamped or adjusted"})]}),e.jsx(H,{checked:a.show_warnings??!0,onCheckedChange:N,disabled:x})]}),e.jsxs("div",{className:"p-4 rounded-lg border bg-muted/30",children:[e.jsx("h4",{className:"text-sm font-medium mb-2",children:"CLI Override"}),e.jsxs("p",{className:"text-sm text-muted-foreground mb-2",children:["Override per session with"," ",e.jsx("code",{className:"px-1.5 py-0.5 rounded bg-muted",children:"--thinking"})," (agy/gemini) or"," ",e.jsx("code",{className:"px-1.5 py-0.5 rounded bg-muted",children:"--effort"})," (codex):"]}),e.jsxs("div",{className:"space-y-1 text-sm font-mono text-muted-foreground",children:[e.jsx("p",{children:"ccs gemini --thinking high"}),e.jsx("p",{children:"ccs agy --thinking 16384"}),e.jsx("p",{children:"ccs codex --effort xhigh"}),e.jsx("p",{children:'ccs codex -p "Refactor this module" --effort xhigh'})]})]})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(C,{variant:"outline",size:"sm",onClick:c,disabled:i||x,className:"w-full",children:[e.jsx(y,{className:`w-4 h-4 mr-2 ${i?"animate-spin":""}`}),"Refresh"]})})]})}export{ae as default};
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-qEZD5MMp.js";import{r as c}from"./react-vendor-CNOkPC89.js";import{aX as fe,aY as ye,ae as A,I as T,X as be,Y as je,Z as ve,_ as Ne,$ as q,b as J,aZ as ke,a_ as Ce,a$ as Pe,aU as U,aW as V,m as Se}from"./index-DGFnVfdv.js";import{S as B}from"./switch-Cr9fAsnM.js";import{aC as Q,R as O,f as we,r as ee,W as Ie,a2 as Ee,aD as Te,aE as Ae,T as X,aF as Le}from"./icons-G0rMFC4M.js";import{P as _e}from"./proxy-status-widget-CSq7bxEv.js";import"./tanstack-De4wvi8X.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-z6HEaPqe.js";function Be(){const{state:t}=fe(),s=ye(),[n,d]=c.useState(null),[h,f]=c.useState(null),[p,x]=c.useState(null),[b,j]=c.useState(null),[v,N]=c.useState(null),k=c.useCallback(async()=>{try{s.setProxyLoading(!0),s.setProxyError(null);const l=await A.cliproxyServer.get();s.setProxyConfig(l)}catch(l){s.setProxyError(l.message)}finally{s.setProxyLoading(!1)}},[s]),C=c.useCallback(async l=>{const i=t.proxyConfig;if(!i)return;const u={remote:{...i.remote,...l.remote},fallback:{...i.fallback,...l.fallback},local:{...i.local,...l.local}};s.setProxyConfig(u),s.setProxyTestResult(null);try{s.setProxySaving(!0),s.setProxyError(null);const r=await A.cliproxyServer.update(l);s.setProxyConfig(r),s.setProxySuccess(!0),setTimeout(()=>s.setProxySuccess(!1),1500)}catch(r){s.setProxyConfig(i),s.setProxyError(r.message)}finally{s.setProxySaving(!1)}},[t.proxyConfig,s]),P=c.useCallback(async l=>{const{host:i,port:u,protocol:r,authToken:S}=l;if(!i){s.setProxyError("Host is required");return}try{s.setProxyTesting(!0),s.setProxyError(null),s.setProxyTestResult(null);const o=u?parseInt(u,10):void 0,w=await A.cliproxyServer.test({host:i,port:o||void 0,protocol:r,authToken:S||void 0});s.setProxyTestResult(w)}catch(o){s.setProxyError(o.message)}finally{s.setProxyTesting(!1)}},[s]);return{config:t.proxyConfig,loading:t.proxyLoading,saving:t.proxySaving,error:t.proxyError,success:t.proxySuccess,testResult:t.proxyTestResult,testing:t.proxyTesting,editedHost:n,setEditedHost:d,editedPort:h,setEditedPort:f,editedAuthToken:p,setEditedAuthToken:x,editedManagementKey:b,setEditedManagementKey:j,editedLocalPort:v,setEditedLocalPort:N,fetchConfig:k,saveConfig:C,testConnection:P}}function De({config:t,saving:s,displayLocalPort:n,setEditedLocalPort:d,onSaveLocalPort:h,onSaveConfig:f}){const p=t.local;return e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Local Proxy"}),e.jsxs("div",{className:"space-y-3 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"Port"}),e.jsx(T,{type:"number",value:n,onChange:x=>d(x.target.value),onBlur:h,placeholder:"8317",className:"font-mono max-w-32",disabled:s})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:"Auto-start"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Start local proxy automatically when needed"})]}),e.jsx(B,{checked:p.auto_start??!0,onCheckedChange:x=>f({local:{...p,auto_start:x}}),disabled:s})]})]})]})}function Me({config:t,saving:s,testing:n,testResult:d,displayHost:h,displayPort:f,displayAuthToken:p,displayManagementKey:x,setEditedHost:b,setEditedPort:j,setEditedAuthToken:v,setEditedManagementKey:N,onSaveHost:k,onSavePort:C,onSaveAuthToken:P,onSaveManagementKey:l,onSaveConfig:i,onTestConnection:u}){const r=t.remote,S=o=>o==="https"?443:8317;return e.jsxs("div",{className:"space-y-4 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("h4",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(Q,{className:"w-4 h-4"}),"Remote Server Configuration"]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"Host"}),e.jsx(T,{value:h,onChange:o=>b(o.target.value),onBlur:k,placeholder:"192.168.1.100 or proxy.example.com",className:"font-mono",disabled:s})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("label",{className:"text-sm text-muted-foreground",children:["Port"," ",e.jsxs("span",{className:"text-xs opacity-70",children:["(default: ",S(t.remote.protocol||"http"),")"]})]}),e.jsx(T,{type:"text",inputMode:"numeric",value:f,onChange:o=>j(o.target.value.replace(/\D/g,"")),onBlur:C,placeholder:`Leave empty for ${S(t.remote.protocol||"http")}`,className:"font-mono",disabled:s})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"Protocol"}),e.jsxs(be,{value:t.remote.protocol||"http",onValueChange:o=>i({remote:{...r,protocol:o}}),disabled:s,children:[e.jsx(je,{children:e.jsx(ve,{})}),e.jsxs(Ne,{children:[e.jsx(q,{value:"http",children:"HTTP"}),e.jsx(q,{value:"https",children:"HTTPS"})]})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"API Key (optional)"}),e.jsx(T,{type:"password",value:p,onChange:o=>v(o.target.value),onBlur:P,placeholder:"For /v1/* API endpoints",className:"font-mono",disabled:s}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Used for API requests to /v1/chat/completions"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"Management Key (optional)"}),e.jsx(T,{type:"password",value:x,onChange:o=>N(o.target.value),onBlur:l,placeholder:"For /v0/management/* endpoints",className:"font-mono",disabled:s}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Used for dashboard management APIs. Falls back to API Key if not set."})]}),e.jsxs("div",{className:"space-y-3 pt-2",children:[e.jsx(J,{onClick:u,disabled:n||!h,variant:"outline",className:"w-full",children:n?e.jsxs(e.Fragment,{children:[e.jsx(O,{className:"w-4 h-4 mr-2 animate-spin"}),"Testing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(we,{className:"w-4 h-4 mr-2"}),"Test Connection"]})}),d&&e.jsx("div",{className:`p-3 rounded-md ${d.reachable?"bg-green-50 border border-green-200 dark:bg-green-900/20 dark:border-green-900/50":"bg-red-50 border border-red-200 dark:bg-red-900/20 dark:border-red-900/50"}`,children:e.jsx("div",{className:"flex items-center gap-2",children:d.reachable?e.jsxs(e.Fragment,{children:[e.jsx(ee,{className:"w-4 h-4 text-green-600 dark:text-green-400"}),e.jsxs("span",{className:"text-sm font-medium text-green-700 dark:text-green-300",children:["Connected (",d.latencyMs,"ms)"]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ie,{className:"w-4 h-4 text-red-600 dark:text-red-400"}),e.jsx("span",{className:"text-sm font-medium text-red-700 dark:text-red-300",children:d.error||"Connection failed"})]})})})]})]})}const Z="ccs_debug_mode",Re=["kiro","ghcp"];function Xe(){const{config:t,loading:s,saving:n,error:d,success:h,testResult:f,testing:p,editedHost:x,setEditedHost:b,editedPort:j,setEditedPort:v,editedAuthToken:N,setEditedAuthToken:k,editedManagementKey:C,setEditedManagementKey:P,editedLocalPort:l,setEditedLocalPort:i,fetchConfig:u,saveConfig:r,testConnection:S}=Be(),{fetchRawConfig:o}=ke(),[w,te]=c.useState(()=>{try{return localStorage.getItem(Z)==="true"}catch{return!1}}),se=a=>{te(a);try{localStorage.setItem(Z,String(a))}catch{}},[y,D]=c.useState("plus"),[ae,re]=c.useState(!1),M=Ce(),{data:oe}=Pe(),G=oe?.running??!1,R=c.useCallback(async()=>{try{const a=await A.cliproxyServer.getBackend();D(a.backend)}catch(a){console.error("[Proxy] Failed to fetch backend:",a)}},[]),K=c.useCallback(async()=>{try{const g=(await A.cliproxy.list()).variants.some(_=>Re.includes(_.provider));re(g)}catch(a){console.error("[Proxy] Failed to check variants:",a)}},[]),W=a=>{const g=y;D(a),M.mutate({backend:a},{onError:()=>{D(g)}})};if(c.useEffect(()=>{if(w&&t){const a={...t,remote:{...t.remote,auth_token:t.remote.auth_token?"[REDACTED]":void 0,management_key:t.remote.management_key?"[REDACTED]":void 0}};console.log("[CCS Debug] Debug mode enabled - proxy config:",a)}},[w,t]),c.useEffect(()=>{u(),o(),R(),K()},[u,o,R,K]),s||!t)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx(O,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:"Loading..."})]})});const m=t.remote.enabled??!1,L=!m&&G,I=t.remote,E=t.fallback,ne=t.remote.host??"",le=t.remote.port!==void 0?t.remote.port.toString():"",ce=t.remote.auth_token??"",de=t.remote.management_key??"",ie=(t.local.port??8317).toString(),$=x??ne,F=j??le,H=N??ce,Y=C??de,z=l??ie,me=()=>{const a=x??$;a!==t.remote.host&&r({remote:{...I,host:a}}),b(null)},xe=()=>{const a=j??F,g=a===""?void 0:parseInt(a,10),_=g&&!isNaN(g)&&g>0?g:void 0;_!==t.remote.port&&r({remote:{...I,port:_}}),v(null)},ue=()=>{const a=N??H;a!==t.remote.auth_token&&r({remote:{...I,auth_token:a}}),k(null)},he=()=>{const a=C??Y;a!==t.remote.management_key&&r({remote:{...I,management_key:a||void 0}}),P(null)},pe=()=>{const a=parseInt(l??z,10);!isNaN(a)&&a!==t.local.port&&r({local:{...t.local,port:a}}),i(null)},ge=()=>{S({host:$,port:F,protocol:t.remote.protocol||"http",authToken:H})};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${d||h?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[d&&e.jsxs(U,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(Ee,{className:"h-4 w-4"}),e.jsx(V,{children:d})]}),h&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md border border-green-200 bg-green-50 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(ee,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:"Saved"})]})]}),e.jsx(Se,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Configure local or remote ",y==="plus"?"CLIProxy Plus":"CLIProxy"," connection for proxy-based profiles"]}),!m&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Instance Status"}),e.jsx(_e,{})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Connection Mode"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("button",{onClick:()=>r({remote:{...I,enabled:!1}}),disabled:n,className:`p-4 rounded-lg border-2 text-left transition-all ${m?"border-border hover:border-muted-foreground/50":"border-primary bg-primary/5"}`,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(Te,{className:`w-5 h-5 ${m?"text-muted-foreground":"text-primary"}`}),e.jsx("span",{className:"font-medium",children:"Local"})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Run ",y==="plus"?"CLIProxy Plus":"CLIProxy"," binary on this machine"]})]}),e.jsxs("button",{onClick:()=>r({remote:{...I,enabled:!0}}),disabled:n,className:`p-4 rounded-lg border-2 text-left transition-all ${m?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/50"}`,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(Q,{className:`w-5 h-5 ${m?"text-primary":"text-muted-foreground"}`}),e.jsx("span",{className:"font-medium",children:"Remote"})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Connect to a remote ",y==="plus"?"CLIProxy Plus":"CLIProxy"," server"]})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-base font-medium flex items-center gap-2",children:[e.jsx(Ae,{className:"w-4 h-4"}),"Backend Binary"]}),!m&&G&&e.jsxs(U,{className:"py-2 border-amber-200 bg-amber-50 dark:border-amber-900/50 dark:bg-amber-900/20 [&>svg]:top-2.5",children:[e.jsx(X,{className:"h-4 w-4 text-amber-600"}),e.jsx(V,{className:"text-amber-700 dark:text-amber-400",children:"Stop the running proxy in Instance Status to switch backend."})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("button",{onClick:()=>W("plus"),disabled:M.isPending||L,className:`p-4 rounded-lg border-2 text-left transition-all ${y==="plus"?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/50"} ${L?"opacity-60 cursor-not-allowed":""}`,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("span",{className:"font-medium",children:"CLIProxyAPIPlus"}),e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-green-100 text-green-700 dark:bg-green-900/50 dark:text-green-400",children:"Default"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Full provider support including Kiro and GitHub Copilot"})]}),e.jsxs("button",{onClick:()=>W("original"),disabled:M.isPending||L,className:`p-4 rounded-lg border-2 text-left transition-all ${y==="original"?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/50"} ${L?"opacity-60 cursor-not-allowed":""}`,children:[e.jsx("div",{className:"flex items-center gap-3 mb-2",children:e.jsx("span",{className:"font-medium",children:"CLIProxyAPI"})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Original binary (Gemini, Codex, Antigravity only)"})]})]}),y==="original"&&ae&&e.jsxs(U,{variant:"destructive",className:"py-2",children:[e.jsx(X,{className:"h-4 w-4"}),e.jsx(V,{children:"Existing Kiro/Copilot variants will not work with CLIProxyAPI. Switch to CLIProxyAPIPlus or remove those variants."})]})]}),m&&e.jsx(Me,{config:t,saving:n,testing:p,testResult:f,displayHost:$,displayPort:F,displayAuthToken:H,displayManagementKey:Y,setEditedHost:b,setEditedPort:v,setEditedAuthToken:k,setEditedManagementKey:P,onSaveHost:me,onSavePort:xe,onSaveAuthToken:ue,onSaveManagementKey:he,onSaveConfig:r,onTestConnection:ge}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Fallback Settings"}),e.jsxs("div",{className:"space-y-3 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:"Enable fallback to local"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Use local proxy if remote is unreachable"})]}),e.jsx(B,{checked:E.enabled??!0,onCheckedChange:a=>r({fallback:{...E,enabled:a}}),disabled:n||!m})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:"Auto-start local proxy"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Automatically start local proxy on fallback"})]}),e.jsx(B,{checked:E.auto_start??!1,onCheckedChange:a=>r({fallback:{...E,auto_start:a}}),disabled:n||!m||!E.enabled})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-base font-medium flex items-center gap-2",children:[e.jsx(Le,{className:"w-4 h-4"}),"Advanced"]}),e.jsxs("div",{className:"space-y-3 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:"Debug Mode"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Enable developer diagnostics in browser console"})]}),e.jsx(B,{checked:w,onCheckedChange:se,disabled:n})]}),w&&e.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400 pl-0.5",children:"Debug mode enabled. Check browser console for detailed logs."})]})]}),!m&&e.jsx(De,{config:t,saving:n,displayLocalPort:z,setEditedLocalPort:i,onSaveLocalPort:pe,onSaveConfig:r})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(J,{variant:"outline",size:"sm",onClick:()=>{u(),o(),R(),K()},disabled:s||n,className:"w-full",children:[e.jsx(O,{className:`w-4 h-4 mr-2 ${s?"animate-spin":""}`}),"Refresh"]})})]})}export{Xe as default};
1
+ import{j as e}from"./radix-ui-qEZD5MMp.js";import{r as c}from"./react-vendor-CNOkPC89.js";import{aV as fe,aW as ye,ae as A,I as T,X as be,Y as je,Z as ve,_ as Ne,$ as z,b as J,aX as ke,aY as Ce,aZ as Pe,aS as V,aU as U,m as Se}from"./index-Dv5jtphl.js";import{S as B}from"./switch-C0ri2ChT.js";import{aC as Q,R as O,e as we,q as ee,W as Ie,a1 as Ee,aD as Te,aE as Ae,T as X,aF as Le}from"./icons-DGASzt3M.js";import{P as _e}from"./proxy-status-widget-DKYj4dWI.js";import"./tanstack-De4wvi8X.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-B5t_5_UL.js";function Be(){const{state:t}=fe(),s=ye(),[n,d]=c.useState(null),[h,f]=c.useState(null),[p,x]=c.useState(null),[b,j]=c.useState(null),[v,N]=c.useState(null),k=c.useCallback(async()=>{try{s.setProxyLoading(!0),s.setProxyError(null);const l=await A.cliproxyServer.get();s.setProxyConfig(l)}catch(l){s.setProxyError(l.message)}finally{s.setProxyLoading(!1)}},[s]),C=c.useCallback(async l=>{const i=t.proxyConfig;if(!i)return;const u={remote:{...i.remote,...l.remote},fallback:{...i.fallback,...l.fallback},local:{...i.local,...l.local}};s.setProxyConfig(u),s.setProxyTestResult(null);try{s.setProxySaving(!0),s.setProxyError(null);const r=await A.cliproxyServer.update(l);s.setProxyConfig(r),s.setProxySuccess(!0),setTimeout(()=>s.setProxySuccess(!1),1500)}catch(r){s.setProxyConfig(i),s.setProxyError(r.message)}finally{s.setProxySaving(!1)}},[t.proxyConfig,s]),P=c.useCallback(async l=>{const{host:i,port:u,protocol:r,authToken:S}=l;if(!i){s.setProxyError("Host is required");return}try{s.setProxyTesting(!0),s.setProxyError(null),s.setProxyTestResult(null);const o=u?parseInt(u,10):void 0,w=await A.cliproxyServer.test({host:i,port:o||void 0,protocol:r,authToken:S||void 0});s.setProxyTestResult(w)}catch(o){s.setProxyError(o.message)}finally{s.setProxyTesting(!1)}},[s]);return{config:t.proxyConfig,loading:t.proxyLoading,saving:t.proxySaving,error:t.proxyError,success:t.proxySuccess,testResult:t.proxyTestResult,testing:t.proxyTesting,editedHost:n,setEditedHost:d,editedPort:h,setEditedPort:f,editedAuthToken:p,setEditedAuthToken:x,editedManagementKey:b,setEditedManagementKey:j,editedLocalPort:v,setEditedLocalPort:N,fetchConfig:k,saveConfig:C,testConnection:P}}function De({config:t,saving:s,displayLocalPort:n,setEditedLocalPort:d,onSaveLocalPort:h,onSaveConfig:f}){const p=t.local;return e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Local Proxy"}),e.jsxs("div",{className:"space-y-3 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"Port"}),e.jsx(T,{type:"number",value:n,onChange:x=>d(x.target.value),onBlur:h,placeholder:"8317",className:"font-mono max-w-32",disabled:s})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:"Auto-start"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Start local proxy automatically when needed"})]}),e.jsx(B,{checked:p.auto_start??!0,onCheckedChange:x=>f({local:{...p,auto_start:x}}),disabled:s})]})]})]})}function Me({config:t,saving:s,testing:n,testResult:d,displayHost:h,displayPort:f,displayAuthToken:p,displayManagementKey:x,setEditedHost:b,setEditedPort:j,setEditedAuthToken:v,setEditedManagementKey:N,onSaveHost:k,onSavePort:C,onSaveAuthToken:P,onSaveManagementKey:l,onSaveConfig:i,onTestConnection:u}){const r=t.remote,S=o=>o==="https"?443:8317;return e.jsxs("div",{className:"space-y-4 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("h4",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(Q,{className:"w-4 h-4"}),"Remote Server Configuration"]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"Host"}),e.jsx(T,{value:h,onChange:o=>b(o.target.value),onBlur:k,placeholder:"192.168.1.100 or proxy.example.com",className:"font-mono",disabled:s})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("label",{className:"text-sm text-muted-foreground",children:["Port"," ",e.jsxs("span",{className:"text-xs opacity-70",children:["(default: ",S(t.remote.protocol||"http"),")"]})]}),e.jsx(T,{type:"text",inputMode:"numeric",value:f,onChange:o=>j(o.target.value.replace(/\D/g,"")),onBlur:C,placeholder:`Leave empty for ${S(t.remote.protocol||"http")}`,className:"font-mono",disabled:s})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"Protocol"}),e.jsxs(be,{value:t.remote.protocol||"http",onValueChange:o=>i({remote:{...r,protocol:o}}),disabled:s,children:[e.jsx(je,{children:e.jsx(ve,{})}),e.jsxs(Ne,{children:[e.jsx(z,{value:"http",children:"HTTP"}),e.jsx(z,{value:"https",children:"HTTPS"})]})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"API Key (optional)"}),e.jsx(T,{type:"password",value:p,onChange:o=>v(o.target.value),onBlur:P,placeholder:"For /v1/* API endpoints",className:"font-mono",disabled:s}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Used for API requests to /v1/chat/completions"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"Management Key (optional)"}),e.jsx(T,{type:"password",value:x,onChange:o=>N(o.target.value),onBlur:l,placeholder:"For /v0/management/* endpoints",className:"font-mono",disabled:s}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Used for dashboard management APIs. Falls back to API Key if not set."})]}),e.jsxs("div",{className:"space-y-3 pt-2",children:[e.jsx(J,{onClick:u,disabled:n||!h,variant:"outline",className:"w-full",children:n?e.jsxs(e.Fragment,{children:[e.jsx(O,{className:"w-4 h-4 mr-2 animate-spin"}),"Testing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(we,{className:"w-4 h-4 mr-2"}),"Test Connection"]})}),d&&e.jsx("div",{className:`p-3 rounded-md ${d.reachable?"bg-green-50 border border-green-200 dark:bg-green-900/20 dark:border-green-900/50":"bg-red-50 border border-red-200 dark:bg-red-900/20 dark:border-red-900/50"}`,children:e.jsx("div",{className:"flex items-center gap-2",children:d.reachable?e.jsxs(e.Fragment,{children:[e.jsx(ee,{className:"w-4 h-4 text-green-600 dark:text-green-400"}),e.jsxs("span",{className:"text-sm font-medium text-green-700 dark:text-green-300",children:["Connected (",d.latencyMs,"ms)"]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ie,{className:"w-4 h-4 text-red-600 dark:text-red-400"}),e.jsx("span",{className:"text-sm font-medium text-red-700 dark:text-red-300",children:d.error||"Connection failed"})]})})})]})]})}const Z="ccs_debug_mode",Re=["kiro","ghcp"];function Xe(){const{config:t,loading:s,saving:n,error:d,success:h,testResult:f,testing:p,editedHost:x,setEditedHost:b,editedPort:j,setEditedPort:v,editedAuthToken:N,setEditedAuthToken:k,editedManagementKey:C,setEditedManagementKey:P,editedLocalPort:l,setEditedLocalPort:i,fetchConfig:u,saveConfig:r,testConnection:S}=Be(),{fetchRawConfig:o}=ke(),[w,te]=c.useState(()=>{try{return localStorage.getItem(Z)==="true"}catch{return!1}}),se=a=>{te(a);try{localStorage.setItem(Z,String(a))}catch{}},[y,D]=c.useState("plus"),[ae,re]=c.useState(!1),M=Ce(),{data:oe}=Pe(),G=oe?.running??!1,R=c.useCallback(async()=>{try{const a=await A.cliproxyServer.getBackend();D(a.backend)}catch(a){console.error("[Proxy] Failed to fetch backend:",a)}},[]),K=c.useCallback(async()=>{try{const g=(await A.cliproxy.list()).variants.some(_=>Re.includes(_.provider));re(g)}catch(a){console.error("[Proxy] Failed to check variants:",a)}},[]),W=a=>{const g=y;D(a),M.mutate({backend:a},{onError:()=>{D(g)}})};if(c.useEffect(()=>{if(w&&t){const a={...t,remote:{...t.remote,auth_token:t.remote.auth_token?"[REDACTED]":void 0,management_key:t.remote.management_key?"[REDACTED]":void 0}};console.log("[CCS Debug] Debug mode enabled - proxy config:",a)}},[w,t]),c.useEffect(()=>{u(),o(),R(),K()},[u,o,R,K]),s||!t)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx(O,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:"Loading..."})]})});const m=t.remote.enabled??!1,L=!m&&G,I=t.remote,E=t.fallback,ne=t.remote.host??"",le=t.remote.port!==void 0?t.remote.port.toString():"",ce=t.remote.auth_token??"",de=t.remote.management_key??"",ie=(t.local.port??8317).toString(),F=x??ne,$=j??le,H=N??ce,Y=C??de,q=l??ie,me=()=>{const a=x??F;a!==t.remote.host&&r({remote:{...I,host:a}}),b(null)},xe=()=>{const a=j??$,g=a===""?void 0:parseInt(a,10),_=g&&!isNaN(g)&&g>0?g:void 0;_!==t.remote.port&&r({remote:{...I,port:_}}),v(null)},ue=()=>{const a=N??H;a!==t.remote.auth_token&&r({remote:{...I,auth_token:a}}),k(null)},he=()=>{const a=C??Y;a!==t.remote.management_key&&r({remote:{...I,management_key:a||void 0}}),P(null)},pe=()=>{const a=parseInt(l??q,10);!isNaN(a)&&a!==t.local.port&&r({local:{...t.local,port:a}}),i(null)},ge=()=>{S({host:F,port:$,protocol:t.remote.protocol||"http",authToken:H})};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${d||h?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[d&&e.jsxs(V,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(Ee,{className:"h-4 w-4"}),e.jsx(U,{children:d})]}),h&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md border border-green-200 bg-green-50 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(ee,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:"Saved"})]})]}),e.jsx(Se,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Configure local or remote ",y==="plus"?"CLIProxy Plus":"CLIProxy"," connection for proxy-based profiles"]}),!m&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Instance Status"}),e.jsx(_e,{})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Connection Mode"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("button",{onClick:()=>r({remote:{...I,enabled:!1}}),disabled:n,className:`p-4 rounded-lg border-2 text-left transition-all ${m?"border-border hover:border-muted-foreground/50":"border-primary bg-primary/5"}`,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(Te,{className:`w-5 h-5 ${m?"text-muted-foreground":"text-primary"}`}),e.jsx("span",{className:"font-medium",children:"Local"})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Run ",y==="plus"?"CLIProxy Plus":"CLIProxy"," binary on this machine"]})]}),e.jsxs("button",{onClick:()=>r({remote:{...I,enabled:!0}}),disabled:n,className:`p-4 rounded-lg border-2 text-left transition-all ${m?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/50"}`,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(Q,{className:`w-5 h-5 ${m?"text-primary":"text-muted-foreground"}`}),e.jsx("span",{className:"font-medium",children:"Remote"})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Connect to a remote ",y==="plus"?"CLIProxy Plus":"CLIProxy"," server"]})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-base font-medium flex items-center gap-2",children:[e.jsx(Ae,{className:"w-4 h-4"}),"Backend Binary"]}),!m&&G&&e.jsxs(V,{className:"py-2 border-amber-200 bg-amber-50 dark:border-amber-900/50 dark:bg-amber-900/20 [&>svg]:top-2.5",children:[e.jsx(X,{className:"h-4 w-4 text-amber-600"}),e.jsx(U,{className:"text-amber-700 dark:text-amber-400",children:"Stop the running proxy in Instance Status to switch backend."})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("button",{onClick:()=>W("plus"),disabled:M.isPending||L,className:`p-4 rounded-lg border-2 text-left transition-all ${y==="plus"?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/50"} ${L?"opacity-60 cursor-not-allowed":""}`,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("span",{className:"font-medium",children:"CLIProxyAPIPlus"}),e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-green-100 text-green-700 dark:bg-green-900/50 dark:text-green-400",children:"Default"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Full provider support including Kiro and GitHub Copilot"})]}),e.jsxs("button",{onClick:()=>W("original"),disabled:M.isPending||L,className:`p-4 rounded-lg border-2 text-left transition-all ${y==="original"?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/50"} ${L?"opacity-60 cursor-not-allowed":""}`,children:[e.jsx("div",{className:"flex items-center gap-3 mb-2",children:e.jsx("span",{className:"font-medium",children:"CLIProxyAPI"})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Original binary (Gemini, Codex, Antigravity only)"})]})]}),y==="original"&&ae&&e.jsxs(V,{variant:"destructive",className:"py-2",children:[e.jsx(X,{className:"h-4 w-4"}),e.jsx(U,{children:"Existing Kiro/Copilot variants will not work with CLIProxyAPI. Switch to CLIProxyAPIPlus or remove those variants."})]})]}),m&&e.jsx(Me,{config:t,saving:n,testing:p,testResult:f,displayHost:F,displayPort:$,displayAuthToken:H,displayManagementKey:Y,setEditedHost:b,setEditedPort:v,setEditedAuthToken:k,setEditedManagementKey:P,onSaveHost:me,onSavePort:xe,onSaveAuthToken:ue,onSaveManagementKey:he,onSaveConfig:r,onTestConnection:ge}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Fallback Settings"}),e.jsxs("div",{className:"space-y-3 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:"Enable fallback to local"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Use local proxy if remote is unreachable"})]}),e.jsx(B,{checked:E.enabled??!0,onCheckedChange:a=>r({fallback:{...E,enabled:a}}),disabled:n||!m})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:"Auto-start local proxy"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Automatically start local proxy on fallback"})]}),e.jsx(B,{checked:E.auto_start??!1,onCheckedChange:a=>r({fallback:{...E,auto_start:a}}),disabled:n||!m||!E.enabled})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-base font-medium flex items-center gap-2",children:[e.jsx(Le,{className:"w-4 h-4"}),"Advanced"]}),e.jsxs("div",{className:"space-y-3 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:"Debug Mode"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Enable developer diagnostics in browser console"})]}),e.jsx(B,{checked:w,onCheckedChange:se,disabled:n})]}),w&&e.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400 pl-0.5",children:"Debug mode enabled. Check browser console for detailed logs."})]})]}),!m&&e.jsx(De,{config:t,saving:n,displayLocalPort:q,setEditedLocalPort:i,onSaveLocalPort:pe,onSaveConfig:r})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(J,{variant:"outline",size:"sm",onClick:()=>{u(),o(),R(),K()},disabled:s||n,className:"w-full",children:[e.jsx(O,{className:`w-4 h-4 mr-2 ${s?"animate-spin":""}`}),"Refresh"]})})]})}export{Xe as default};