@kaitranntt/ccs 7.50.0-dev.1 → 7.50.0-dev.4

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 (93) hide show
  1. package/README.md +12 -0
  2. package/dist/api/services/profile-writer.d.ts +1 -1
  3. package/dist/api/services/profile-writer.d.ts.map +1 -1
  4. package/dist/api/services/profile-writer.js +18 -5
  5. package/dist/api/services/profile-writer.js.map +1 -1
  6. package/dist/ccs.js +46 -8
  7. package/dist/ccs.js.map +1 -1
  8. package/dist/targets/droid-adapter.d.ts +1 -1
  9. package/dist/targets/droid-adapter.d.ts.map +1 -1
  10. package/dist/targets/droid-adapter.js +16 -4
  11. package/dist/targets/droid-adapter.js.map +1 -1
  12. package/dist/targets/droid-config-manager.d.ts +9 -1
  13. package/dist/targets/droid-config-manager.d.ts.map +1 -1
  14. package/dist/targets/droid-config-manager.js +131 -3
  15. package/dist/targets/droid-config-manager.js.map +1 -1
  16. package/dist/targets/droid-provider.d.ts +40 -0
  17. package/dist/targets/droid-provider.d.ts.map +1 -0
  18. package/dist/targets/droid-provider.js +140 -0
  19. package/dist/targets/droid-provider.js.map +1 -0
  20. package/dist/targets/droid-reasoning-runtime.d.ts +14 -0
  21. package/dist/targets/droid-reasoning-runtime.d.ts.map +1 -0
  22. package/dist/targets/droid-reasoning-runtime.js +42 -0
  23. package/dist/targets/droid-reasoning-runtime.js.map +1 -0
  24. package/dist/targets/index.d.ts +2 -0
  25. package/dist/targets/index.d.ts.map +1 -1
  26. package/dist/targets/index.js +4 -1
  27. package/dist/targets/index.js.map +1 -1
  28. package/dist/targets/target-adapter.d.ts +6 -0
  29. package/dist/targets/target-adapter.d.ts.map +1 -1
  30. package/dist/ui/assets/accounts-B3RlymZc.js +1 -0
  31. package/dist/ui/assets/{alert-dialog-DmrIcJav.js → alert-dialog-CuEMPUz1.js} +1 -1
  32. package/dist/ui/assets/api-B2ICvWzi.js +1 -0
  33. package/dist/ui/assets/{auth-section-CP_2r8oJ.js → auth-section-47vsG_g9.js} +1 -1
  34. package/dist/ui/assets/{backups-section-jwtuA5Ay.js → backups-section-D-sat7Ti.js} +1 -1
  35. package/dist/ui/assets/{checkbox-CNqHZx7Z.js → checkbox-C-12mTDT.js} +1 -1
  36. package/dist/ui/assets/{cliproxy-CtO9BwgG.js → cliproxy-CAR-zTil.js} +1 -1
  37. package/dist/ui/assets/{cliproxy-control-panel--WUVyBIk.js → cliproxy-control-panel-3uthxEI-.js} +1 -1
  38. package/dist/ui/assets/{confirm-dialog-CQNxkz9X.js → confirm-dialog-BfiBvMqW.js} +1 -1
  39. package/dist/ui/assets/{copilot-DLxxmnsW.js → copilot-Dz0B1ZUz.js} +1 -1
  40. package/dist/ui/assets/{cursor-YRIza7sP.js → cursor-DdPXjHsr.js} +1 -1
  41. package/dist/ui/assets/droid-DE-zbt4u.js +2 -0
  42. package/dist/ui/assets/globalenv-section-BKbOddIv.js +1 -0
  43. package/dist/ui/assets/{health-BWPd6F4h.js → health-Bu6uaf__.js} +1 -1
  44. package/dist/ui/assets/icons-ErRLeJ3U.js +1 -0
  45. package/dist/ui/assets/index-CjJDhkhP.css +1 -0
  46. package/dist/ui/assets/{index-D244tv89.js → index-Cl-418Sf.js} +1 -1
  47. package/dist/ui/assets/{index-BlldLmNl.js → index-D1DFI7Lj.js} +1 -1
  48. package/dist/ui/assets/{index-BZdHAol5.js → index-DNyQOJ27.js} +1 -1
  49. package/dist/ui/assets/index-Dzby9K4O.js +1 -0
  50. package/dist/ui/assets/{index-PWMOllOf.js → index-zgEA-GkK.js} +11 -11
  51. package/dist/ui/assets/{proxy-status-widget-MlyNgoPh.js → proxy-status-widget-BtL-jVdm.js} +1 -1
  52. package/dist/ui/assets/{separator-OcJLDgYQ.js → separator-sNDYgSUT.js} +1 -1
  53. package/dist/ui/assets/{shared-LxAdbm4g.js → shared-qWuCxx8B.js} +1 -1
  54. package/dist/ui/assets/{switch-s8pp-m8L.js → switch-BdRPtxoo.js} +1 -1
  55. package/dist/ui/assets/{updates-BQRhDVbP.js → updates-BIpeiM6l.js} +1 -1
  56. package/dist/ui/index.html +3 -3
  57. package/dist/web-server/routes/droid-routes.d.ts +3 -0
  58. package/dist/web-server/routes/droid-routes.d.ts.map +1 -0
  59. package/dist/web-server/routes/droid-routes.js +61 -0
  60. package/dist/web-server/routes/droid-routes.js.map +1 -0
  61. package/dist/web-server/routes/index.d.ts.map +1 -1
  62. package/dist/web-server/routes/index.js +3 -0
  63. package/dist/web-server/routes/index.js.map +1 -1
  64. package/dist/web-server/routes/profile-routes.d.ts.map +1 -1
  65. package/dist/web-server/routes/profile-routes.js +29 -3
  66. package/dist/web-server/routes/profile-routes.js.map +1 -1
  67. package/dist/web-server/routes/route-helpers.d.ts +2 -1
  68. package/dist/web-server/routes/route-helpers.d.ts.map +1 -1
  69. package/dist/web-server/routes/route-helpers.js +20 -1
  70. package/dist/web-server/routes/route-helpers.js.map +1 -1
  71. package/dist/web-server/services/compatible-cli-docs-registry.d.ts +23 -0
  72. package/dist/web-server/services/compatible-cli-docs-registry.d.ts.map +1 -0
  73. package/dist/web-server/services/compatible-cli-docs-registry.js +81 -0
  74. package/dist/web-server/services/compatible-cli-docs-registry.js.map +1 -0
  75. package/dist/web-server/services/compatible-cli-json-file-service.d.ts +41 -0
  76. package/dist/web-server/services/compatible-cli-json-file-service.d.ts.map +1 -0
  77. package/dist/web-server/services/compatible-cli-json-file-service.js +205 -0
  78. package/dist/web-server/services/compatible-cli-json-file-service.js.map +1 -0
  79. package/dist/web-server/services/compatible-cli-types.d.ts +82 -0
  80. package/dist/web-server/services/compatible-cli-types.d.ts.map +1 -0
  81. package/dist/web-server/services/compatible-cli-types.js +3 -0
  82. package/dist/web-server/services/compatible-cli-types.js.map +1 -0
  83. package/dist/web-server/services/droid-dashboard-service.d.ts +29 -0
  84. package/dist/web-server/services/droid-dashboard-service.d.ts.map +1 -0
  85. package/dist/web-server/services/droid-dashboard-service.js +238 -0
  86. package/dist/web-server/services/droid-dashboard-service.js.map +1 -0
  87. package/package.json +1 -1
  88. package/dist/ui/assets/accounts-BKK-Lc16.js +0 -1
  89. package/dist/ui/assets/api-DzTwRtww.js +0 -1
  90. package/dist/ui/assets/globalenv-section-vUSIK5rf.js +0 -1
  91. package/dist/ui/assets/icons-Dk2sL3Mr.js +0 -1
  92. package/dist/ui/assets/index-B9dJZNls.js +0 -1
  93. package/dist/ui/assets/index-DEDy1J8t.css +0 -1
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-DIWAxjEp.js";import{r as a}from"./react-vendor-CNOkPC89.js";import{a_ as q,b0 as W,b as T,m as J,L,q as D,r as M,s as K,t as V,v as I,I as F}from"./index-PWMOllOf.js";import{S as X}from"./switch-s8pp-m8L.js";import{R as $,a1 as Y,q as Q,a3 as Z,I as ee,V as se}from"./icons-Dk2sL3Mr.js";import"./tanstack-Hn82hibe.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Cn_Uld6y.js";import"./code-highlight-BRUf_pqB.js";const z={mode:"auto",tier_defaults:{opus:"high",sonnet:"medium",haiku:"low"},show_warnings:!0},U=1e4;function re(){const[t,f]=a.useState(null),[l,j]=a.useState(!0),[w,v]=a.useState(!1),[E,m]=a.useState(null),[A,p]=a.useState(!1),N=a.useRef(void 0),C=a.useRef(!1),b=a.useCallback(async()=>{const r=new AbortController,d=setTimeout(()=>r.abort(),U);try{j(!0),m(null);const n=await fetch("/api/thinking",{signal:r.signal});if(clearTimeout(d),!n.ok)throw n.headers.get("content-type")?.includes("text/html")?new Error(`Server error (${n.status})`):new Error("Failed to load Thinking config");const c=await n.json();f(c.config||z),N.current=c.lastModified,C.current=!0}catch(n){clearTimeout(d),n.name==="AbortError"?m("Request timeout - please try again"):m(n.message)}finally{j(!1)}return()=>r.abort()},[]),o=a.useCallback(async r=>{if(!C.current||t===null){m("Cannot save settings before they load. Click Refresh and try again.");return}const d=t,n={...d,...r.mode!==void 0?{mode:r.mode}:{},...r.tier_defaults!==void 0?{tier_defaults:r.tier_defaults}:{},...r.show_warnings!==void 0?{show_warnings:r.show_warnings}:{}};r.clear_override||r.override===null?delete n.override:r.override!==void 0&&(n.override=r.override),r.clear_provider_overrides||r.provider_overrides===null?delete n.provider_overrides:r.provider_overrides!==void 0&&(n.provider_overrides=r.provider_overrides),f(n);const c=new AbortController,h=setTimeout(()=>c.abort(),U);try{v(!0),m(null);const x={...n,lastModified:N.current},u=await fetch("/api/thinking",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(x),signal:c.signal});if(clearTimeout(h),!u.ok){if(u.headers.get("content-type")?.includes("text/html"))throw new Error(`Server error (${u.status})`);const i=await u.json();throw u.status===409?new Error("Config changed by another session. Refreshing..."):new Error(i.error||"Failed to save")}const g=await u.json();f(g.config),N.current=g.lastModified,p(!0),setTimeout(()=>p(!1),1500)}catch(x){clearTimeout(h),f(d),x.name==="AbortError"?m("Request timeout - please try again"):(m(x.message),x.message.includes("another session")&&setTimeout(()=>b(),1e3))}finally{v(!1)}},[t,b]),S=a.useCallback(r=>{o({mode:r})},[o]),O=a.useCallback((r,d)=>{const n=t?.tier_defaults||z.tier_defaults;o({tier_defaults:{...n,[r]:d}})},[t,o]),R=a.useCallback(r=>{o({show_warnings:r})},[o]),P=a.useCallback(r=>{if(r===void 0){o({override:null,clear_override:!0});return}o({override:r,clear_override:!1})},[o]),y=a.useCallback((r,d,n)=>{const c=t?.provider_overrides||{},h=c[r]||{};if(n===void 0){const{[d]:x,...u}=h,g=Object.keys(u).length>0?u:void 0,{[r]:s,...i}=c,k=g?{...i,[r]:g}:i;o({provider_overrides:Object.keys(k).length>0?k:null,clear_provider_overrides:Object.keys(k).length===0})}else o({provider_overrides:{...c,[r]:{...h,[d]:n}},clear_provider_overrides:!1})},[t,o]);return{config:t||z,loading:l,saving:w,error:E,success:A,fetchConfig:b,saveConfig:o,setMode:S,setTierDefault:O,setShowWarnings:R,setOverride:P,setProviderOverride:y}}const H=[{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)"}],te=[{value:"__none__",label:"None (use CLI flags only)"},...H,{value:"__custom__",label:"Custom budget (number)"},{value:"off",label:"Off (disable thinking)"}],ie=["agy","gemini","codex"],B=0,G=1e5;function fe(){const{config:t,loading:f,saving:l,error:j,success:w,fetchConfig:v,setMode:E,setTierDefault:m,setShowWarnings:A,setOverride:p,setProviderOverride:N}=re(),[C,b]=a.useState(null),[o,S]=a.useState(""),[O,R]=a.useState([]),[P,y]=a.useState(null),r=a.useMemo(()=>Array.from(new Set([...ie,...Object.keys(t.provider_overrides??{}),...O])),[O,t.provider_overrides]),d=t.override===void 0?"__none__":typeof t.override=="number"||/^\d+$/.test(String(t.override))?"__custom__":String(t.override),n=typeof t.override=="number"||/^\d+$/.test(String(t.override??""))?String(t.override):"",c=P??n,h=Object.keys(t.provider_overrides??{}).length>0,x=C??h;a.useEffect(()=>{v()},[v]);const u=()=>{const s=o.trim().toLowerCase();s&&(r.includes(s)||R(i=>[...i,s]),S(""),b(!0))},g=()=>{const s=c.trim();if(!s){p(void 0);return}const i=Number.parseInt(s,10);Number.isNaN(i)||i<B||i>G||!/^\d+$/.test(s)||p(i)};return f?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($,{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 ${j||w?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[j&&e.jsx(q,{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(Y,{className:"h-4 w-4"}),e.jsx(W,{children:j})]}),e.jsxs(T,{variant:"outline",size:"sm",onClick:v,className:"h-7 px-2 text-xs border-destructive/50 hover:bg-destructive/10",children:[e.jsx($,{className:"w-3 h-3 mr-1"}),"Retry"]})]})}),w&&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(Q,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:"Saved"})]})]}),e.jsx(J,{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(Z,{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(ee,{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 ${t.mode===s?"bg-primary/10 border border-primary/30":"bg-muted/50 hover:bg-muted/80"} ${l?"opacity-70 pointer-events-none":""}`,onClick:()=>{l||E(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"&&"Set a persistent override level or use CLI flags per run"]})]}),e.jsx("div",{className:`w-4 h-4 rounded-full border-2 ${t.mode===s?"bg-primary border-primary":"border-muted-foreground/50"}`})]},s))})]}),t.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(L,{className:"w-20 capitalize font-medium",children:s}),e.jsxs(D,{value:t.tier_defaults[s],onValueChange:i=>m(s,i),disabled:l,children:[e.jsx(M,{className:"flex-1",children:e.jsx(K,{})}),e.jsx(V,{children:H.map(i=>e.jsx(I,{value:i.value,children:i.label},i.value))})]})]},s))})]}),t.mode==="manual"&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Persistent Override"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Applied to all sessions. CLI flags still take priority."}),e.jsxs(D,{value:d,onValueChange:s=>{if(s==="__none__"){p(void 0);return}if(s==="__custom__"){c||y("8192");return}y(null),p(s)},disabled:l,children:[e.jsx(M,{children:e.jsx(K,{})}),e.jsx(V,{children:te.map(s=>e.jsx(I,{value:s.value,children:s.label},s.value))})]}),d==="__custom__"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(F,{type:"number",min:B,max:G,value:c,onChange:s=>y(s.target.value),onBlur:g,disabled:l,placeholder:"Enter custom budget"}),e.jsx(T,{type:"button",size:"sm",variant:"outline",onClick:g,disabled:l,children:"Apply"})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Range: ",B," to ",G]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("button",{type:"button",className:"flex items-center gap-2 text-base font-medium w-full text-left",onClick:()=>b(s=>!(s??h)),disabled:l,children:[e.jsx(se,{className:`w-4 h-4 transition-transform ${x?"rotate-0":"-rotate-90"}`}),"Provider Overrides (",Object.keys(t.provider_overrides??{}).length,")"]}),x&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Override tier defaults for specific providers. Add custom provider keys as needed."}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(F,{value:o,onChange:s=>S(s.target.value),disabled:l,placeholder:"Add provider key (e.g. qwen)"}),e.jsx(T,{type:"button",size:"sm",variant:"outline",onClick:u,disabled:l,children:"Add"})]}),r.map(s=>e.jsxs("div",{className:"space-y-2 p-3 rounded-lg bg-muted/30",children:[e.jsx(L,{className:"capitalize font-medium text-sm",children:s}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:["opus","sonnet","haiku"].map(i=>{const k=t.provider_overrides?.[s]?.[i]||"__default__";return e.jsxs("div",{className:"space-y-1",children:[e.jsx(L,{className:"text-xs text-muted-foreground capitalize",children:i}),e.jsxs(D,{value:k,onValueChange:_=>N(s,i,_==="__default__"?void 0:_),disabled:l,children:[e.jsx(M,{className:"h-8 text-xs",children:e.jsx(K,{})}),e.jsxs(V,{children:[e.jsx(I,{value:"__default__",children:"Default"}),H.map(_=>e.jsx(I,{value:_.value,children:_.label},_.value))]})]})]},i)})})]},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(X,{checked:t.show_warnings??!0,onCheckedChange:A,disabled:l})]}),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 & Env Override"}),e.jsxs("p",{className:"text-sm text-muted-foreground mb-2",children:["Override per session with flags or"," ",e.jsx("code",{className:"px-1.5 py-0.5 rounded bg-muted",children:"CCS_THINKING"})," env var. Priority: flag > env > config."]}),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 codex --effort xhigh"}),e.jsx("p",{children:'CCS_THINKING=high ccs codex "debug this"'}),e.jsx("p",{children:"ccs config thinking --mode auto"})]})]})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(T,{variant:"outline",size:"sm",onClick:v,disabled:f||l,className:"w-full",children:[e.jsx($,{className:`w-4 h-4 mr-2 ${f?"animate-spin":""}`}),"Refresh"]})})]})}export{fe as default};
1
+ import{j as e}from"./radix-ui-DIWAxjEp.js";import{r as a}from"./react-vendor-CNOkPC89.js";import{b2 as q,b4 as W,b as T,m as Y,L,q as D,r as M,s as K,t as $,v as I,I as F}from"./index-zgEA-GkK.js";import{S as J}from"./switch-BdRPtxoo.js";import{R as z,a2 as X,r as Q,a4 as Z,I as ee,Y as se}from"./icons-ErRLeJ3U.js";import"./tanstack-Hn82hibe.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Cn_Uld6y.js";import"./code-highlight-BRUf_pqB.js";const B={mode:"auto",tier_defaults:{opus:"high",sonnet:"medium",haiku:"low"},show_warnings:!0},U=1e4;function re(){const[t,f]=a.useState(null),[l,j]=a.useState(!0),[w,v]=a.useState(!1),[E,m]=a.useState(null),[A,p]=a.useState(!1),N=a.useRef(void 0),C=a.useRef(!1),b=a.useCallback(async()=>{const r=new AbortController,d=setTimeout(()=>r.abort(),U);try{j(!0),m(null);const n=await fetch("/api/thinking",{signal:r.signal});if(clearTimeout(d),!n.ok)throw n.headers.get("content-type")?.includes("text/html")?new Error(`Server error (${n.status})`):new Error("Failed to load Thinking config");const c=await n.json();f(c.config||B),N.current=c.lastModified,C.current=!0}catch(n){clearTimeout(d),n.name==="AbortError"?m("Request timeout - please try again"):m(n.message)}finally{j(!1)}return()=>r.abort()},[]),o=a.useCallback(async r=>{if(!C.current||t===null){m("Cannot save settings before they load. Click Refresh and try again.");return}const d=t,n={...d,...r.mode!==void 0?{mode:r.mode}:{},...r.tier_defaults!==void 0?{tier_defaults:r.tier_defaults}:{},...r.show_warnings!==void 0?{show_warnings:r.show_warnings}:{}};r.clear_override||r.override===null?delete n.override:r.override!==void 0&&(n.override=r.override),r.clear_provider_overrides||r.provider_overrides===null?delete n.provider_overrides:r.provider_overrides!==void 0&&(n.provider_overrides=r.provider_overrides),f(n);const c=new AbortController,h=setTimeout(()=>c.abort(),U);try{v(!0),m(null);const x={...n,lastModified:N.current},u=await fetch("/api/thinking",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(x),signal:c.signal});if(clearTimeout(h),!u.ok){if(u.headers.get("content-type")?.includes("text/html"))throw new Error(`Server error (${u.status})`);const i=await u.json();throw u.status===409?new Error("Config changed by another session. Refreshing..."):new Error(i.error||"Failed to save")}const g=await u.json();f(g.config),N.current=g.lastModified,p(!0),setTimeout(()=>p(!1),1500)}catch(x){clearTimeout(h),f(d),x.name==="AbortError"?m("Request timeout - please try again"):(m(x.message),x.message.includes("another session")&&setTimeout(()=>b(),1e3))}finally{v(!1)}},[t,b]),S=a.useCallback(r=>{o({mode:r})},[o]),O=a.useCallback((r,d)=>{const n=t?.tier_defaults||B.tier_defaults;o({tier_defaults:{...n,[r]:d}})},[t,o]),R=a.useCallback(r=>{o({show_warnings:r})},[o]),P=a.useCallback(r=>{if(r===void 0){o({override:null,clear_override:!0});return}o({override:r,clear_override:!1})},[o]),y=a.useCallback((r,d,n)=>{const c=t?.provider_overrides||{},h=c[r]||{};if(n===void 0){const{[d]:x,...u}=h,g=Object.keys(u).length>0?u:void 0,{[r]:s,...i}=c,k=g?{...i,[r]:g}:i;o({provider_overrides:Object.keys(k).length>0?k:null,clear_provider_overrides:Object.keys(k).length===0})}else o({provider_overrides:{...c,[r]:{...h,[d]:n}},clear_provider_overrides:!1})},[t,o]);return{config:t||B,loading:l,saving:w,error:E,success:A,fetchConfig:b,saveConfig:o,setMode:S,setTierDefault:O,setShowWarnings:R,setOverride:P,setProviderOverride:y}}const H=[{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)"}],te=[{value:"__none__",label:"None (use CLI flags only)"},...H,{value:"__custom__",label:"Custom budget (number)"},{value:"off",label:"Off (disable thinking)"}],ie=["agy","gemini","codex"],V=0,G=1e5;function fe(){const{config:t,loading:f,saving:l,error:j,success:w,fetchConfig:v,setMode:E,setTierDefault:m,setShowWarnings:A,setOverride:p,setProviderOverride:N}=re(),[C,b]=a.useState(null),[o,S]=a.useState(""),[O,R]=a.useState([]),[P,y]=a.useState(null),r=a.useMemo(()=>Array.from(new Set([...ie,...Object.keys(t.provider_overrides??{}),...O])),[O,t.provider_overrides]),d=t.override===void 0?"__none__":typeof t.override=="number"||/^\d+$/.test(String(t.override))?"__custom__":String(t.override),n=typeof t.override=="number"||/^\d+$/.test(String(t.override??""))?String(t.override):"",c=P??n,h=Object.keys(t.provider_overrides??{}).length>0,x=C??h;a.useEffect(()=>{v()},[v]);const u=()=>{const s=o.trim().toLowerCase();s&&(r.includes(s)||R(i=>[...i,s]),S(""),b(!0))},g=()=>{const s=c.trim();if(!s){p(void 0);return}const i=Number.parseInt(s,10);Number.isNaN(i)||i<V||i>G||!/^\d+$/.test(s)||p(i)};return f?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(z,{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 ${j||w?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[j&&e.jsx(q,{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(X,{className:"h-4 w-4"}),e.jsx(W,{children:j})]}),e.jsxs(T,{variant:"outline",size:"sm",onClick:v,className:"h-7 px-2 text-xs border-destructive/50 hover:bg-destructive/10",children:[e.jsx(z,{className:"w-3 h-3 mr-1"}),"Retry"]})]})}),w&&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(Q,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:"Saved"})]})]}),e.jsx(Y,{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(Z,{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(ee,{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 ${t.mode===s?"bg-primary/10 border border-primary/30":"bg-muted/50 hover:bg-muted/80"} ${l?"opacity-70 pointer-events-none":""}`,onClick:()=>{l||E(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"&&"Set a persistent override level or use CLI flags per run"]})]}),e.jsx("div",{className:`w-4 h-4 rounded-full border-2 ${t.mode===s?"bg-primary border-primary":"border-muted-foreground/50"}`})]},s))})]}),t.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(L,{className:"w-20 capitalize font-medium",children:s}),e.jsxs(D,{value:t.tier_defaults[s],onValueChange:i=>m(s,i),disabled:l,children:[e.jsx(M,{className:"flex-1",children:e.jsx(K,{})}),e.jsx($,{children:H.map(i=>e.jsx(I,{value:i.value,children:i.label},i.value))})]})]},s))})]}),t.mode==="manual"&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Persistent Override"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Applied to all sessions. CLI flags still take priority."}),e.jsxs(D,{value:d,onValueChange:s=>{if(s==="__none__"){p(void 0);return}if(s==="__custom__"){c||y("8192");return}y(null),p(s)},disabled:l,children:[e.jsx(M,{children:e.jsx(K,{})}),e.jsx($,{children:te.map(s=>e.jsx(I,{value:s.value,children:s.label},s.value))})]}),d==="__custom__"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(F,{type:"number",min:V,max:G,value:c,onChange:s=>y(s.target.value),onBlur:g,disabled:l,placeholder:"Enter custom budget"}),e.jsx(T,{type:"button",size:"sm",variant:"outline",onClick:g,disabled:l,children:"Apply"})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Range: ",V," to ",G]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("button",{type:"button",className:"flex items-center gap-2 text-base font-medium w-full text-left",onClick:()=>b(s=>!(s??h)),disabled:l,children:[e.jsx(se,{className:`w-4 h-4 transition-transform ${x?"rotate-0":"-rotate-90"}`}),"Provider Overrides (",Object.keys(t.provider_overrides??{}).length,")"]}),x&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Override tier defaults for specific providers. Add custom provider keys as needed."}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(F,{value:o,onChange:s=>S(s.target.value),disabled:l,placeholder:"Add provider key (e.g. qwen)"}),e.jsx(T,{type:"button",size:"sm",variant:"outline",onClick:u,disabled:l,children:"Add"})]}),r.map(s=>e.jsxs("div",{className:"space-y-2 p-3 rounded-lg bg-muted/30",children:[e.jsx(L,{className:"capitalize font-medium text-sm",children:s}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:["opus","sonnet","haiku"].map(i=>{const k=t.provider_overrides?.[s]?.[i]||"__default__";return e.jsxs("div",{className:"space-y-1",children:[e.jsx(L,{className:"text-xs text-muted-foreground capitalize",children:i}),e.jsxs(D,{value:k,onValueChange:_=>N(s,i,_==="__default__"?void 0:_),disabled:l,children:[e.jsx(M,{className:"h-8 text-xs",children:e.jsx(K,{})}),e.jsxs($,{children:[e.jsx(I,{value:"__default__",children:"Default"}),H.map(_=>e.jsx(I,{value:_.value,children:_.label},_.value))]})]})]},i)})})]},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(J,{checked:t.show_warnings??!0,onCheckedChange:A,disabled:l})]}),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 & Env Override"}),e.jsxs("p",{className:"text-sm text-muted-foreground mb-2",children:["Override per session with flags or"," ",e.jsx("code",{className:"px-1.5 py-0.5 rounded bg-muted",children:"CCS_THINKING"})," env var. Priority: flag > env > config."]}),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 codex --effort xhigh"}),e.jsx("p",{children:'CCS_THINKING=high ccs codex "debug this"'}),e.jsx("p",{children:"ccs config thinking --mode auto"})]})]})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(T,{variant:"outline",size:"sm",onClick:v,disabled:f||l,className:"w-full",children:[e.jsx(z,{className:`w-4 h-4 mr-2 ${f?"animate-spin":""}`}),"Refresh"]})})]})}export{fe as default};
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-DIWAxjEp.js";import{r as d}from"./react-vendor-CNOkPC89.js";import{b5 as ye,b6 as je,W as L,I as T,q as ve,r as Ne,s as ke,t as Ce,v as Y,b as Z,b7 as Pe,b8 as Se,b9 as we,a_ as O,b0 as U,m as Ie}from"./index-PWMOllOf.js";import{S as _}from"./switch-s8pp-m8L.js";import{C as R}from"./default-ports-1QQSffYX.js";import{aE as ee,R as V,e as Ee,q as te,W as Te,a1 as Le,aF as Ae,aG as _e,T as X,aH as Re}from"./icons-Dk2sL3Mr.js";import{P as Be}from"./proxy-status-widget-MlyNgoPh.js";import{t as J}from"./notifications-B2HqRBj7.js";import"./tanstack-Hn82hibe.js";import"./utils-CzKF5WmX.js";import"./form-utils-Cn_Uld6y.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-DmrIcJav.js";function De(){const{state:t}=ye(),s=je(),[n,m]=d.useState(null),[h,b]=d.useState(null),[g,u]=d.useState(null),[v,N]=d.useState(null),[f,k]=d.useState(null),C=d.useCallback(async()=>{try{s.setProxyLoading(!0),s.setProxyError(null);const l=await L.cliproxyServer.get();s.setProxyConfig(l)}catch(l){s.setProxyError(l.message)}finally{s.setProxyLoading(!1)}},[s]),P=d.useCallback(async l=>{const i=t.proxyConfig;if(!i)return;const p={remote:{...i.remote,...l.remote},fallback:{...i.fallback,...l.fallback},local:{...i.local,...l.local}};s.setProxyConfig(p),s.setProxyTestResult(null);try{s.setProxySaving(!0),s.setProxyError(null);const a=await L.cliproxyServer.update(l);s.setProxyConfig(a),s.setProxySuccess(!0),setTimeout(()=>s.setProxySuccess(!1),1500)}catch(a){s.setProxyConfig(i),s.setProxyError(a.message)}finally{s.setProxySaving(!1)}},[t.proxyConfig,s]),S=d.useCallback(async l=>{const{host:i,port:p,protocol:a,authToken:w}=l;if(!i){s.setProxyError("Host is required");return}try{s.setProxyTesting(!0),s.setProxyError(null),s.setProxyTestResult(null);const o=p?parseInt(p,10):void 0,I=await L.cliproxyServer.test({host:i,port:o||void 0,protocol:a,authToken:w||void 0});s.setProxyTestResult(I)}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:m,editedPort:h,setEditedPort:b,editedAuthToken:g,setEditedAuthToken:u,editedManagementKey:v,setEditedManagementKey:N,editedLocalPort:f,setEditedLocalPort:k,fetchConfig:C,saveConfig:P,testConnection:S}}function Me({config:t,saving:s,displayLocalPort:n,setEditedLocalPort:m,onSaveLocalPort:h,onSaveConfig:b}){const g=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:"text",inputMode:"numeric",value:n,onChange:u=>m(u.target.value.replace(/\D/g,"")),onBlur:h,placeholder:`${R}`,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(_,{checked:g.auto_start??!0,onCheckedChange:u=>b({local:{...g,auto_start:u}}),disabled:s})]})]})]})}function Ke({config:t,saving:s,testing:n,testResult:m,displayHost:h,displayPort:b,displayAuthToken:g,displayManagementKey:u,setEditedHost:v,setEditedPort:N,setEditedAuthToken:f,setEditedManagementKey:k,onSaveHost:C,onSavePort:P,onSaveAuthToken:S,onSaveManagementKey:l,onSaveConfig:i,onTestConnection:p}){const a=t.remote,w=o=>o==="https"?443:R;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(ee,{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=>v(o.target.value),onBlur:C,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: ",w(t.remote.protocol||"http"),")"]})]}),e.jsx(T,{type:"text",inputMode:"numeric",value:b,onChange:o=>N(o.target.value.replace(/\D/g,"")),onBlur:P,placeholder:`Leave empty for ${w(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(ve,{value:t.remote.protocol||"http",onValueChange:o=>i({remote:{...a,protocol:o}}),disabled:s,children:[e.jsx(Ne,{children:e.jsx(ke,{})}),e.jsxs(Ce,{children:[e.jsx(Y,{value:"http",children:"HTTP"}),e.jsx(Y,{value:"https",children:"HTTPS"})]})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"API Key (optional)"}),e.jsx(T,{type:"password",value:g,onChange:o=>f(o.target.value),onBlur:S,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:u,onChange:o=>k(o.target.value),onBlur:l,placeholder:"For /v0/management/* endpoints",className:"font-mono",disabled:s}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Used for dashboard management APIs. Falls back to API Key if not set."})]}),e.jsxs("div",{className:"space-y-3 pt-2",children:[e.jsx(Z,{onClick:p,disabled:n||!h,variant:"outline",className:"w-full",children:n?e.jsxs(e.Fragment,{children:[e.jsx(V,{className:"w-4 h-4 mr-2 animate-spin"}),"Testing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ee,{className:"w-4 h-4 mr-2"}),"Test Connection"]})}),m&&e.jsx("div",{className:`p-3 rounded-md ${m.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:m.reachable?e.jsxs(e.Fragment,{children:[e.jsx(te,{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 (",m.latencyMs,"ms)"]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Te,{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:m.error||"Connection failed"})]})})})]})]})}const Q="ccs_debug_mode",Fe=["kiro","ghcp"];function Ze(){const{config:t,loading:s,saving:n,error:m,success:h,testResult:b,testing:g,editedHost:u,setEditedHost:v,editedPort:N,setEditedPort:f,editedAuthToken:k,setEditedAuthToken:C,editedManagementKey:P,setEditedManagementKey:S,editedLocalPort:l,setEditedLocalPort:i,fetchConfig:p,saveConfig:a,testConnection:w}=De(),{fetchRawConfig:o}=Pe(),[I,se]=d.useState(()=>{try{return localStorage.getItem(Q)==="true"}catch{return!1}}),re=r=>{se(r);try{localStorage.setItem(Q,String(r))}catch{}},[y,B]=d.useState("plus"),[ae,oe]=d.useState(!1),D=Se(),{data:ne}=we(),G=ne?.running??!1,M=d.useCallback(async()=>{try{const r=await L.cliproxyServer.getBackend();B(r.backend)}catch(r){console.error("[Proxy] Failed to fetch backend:",r)}},[]),K=d.useCallback(async()=>{try{const c=(await L.cliproxy.list()).variants.some(be=>Fe.includes(be.provider));oe(c)}catch(r){console.error("[Proxy] Failed to check variants:",r)}},[]),W=r=>{const c=y;B(r),D.mutate({backend:r},{onError:()=>{B(c)}})};if(d.useEffect(()=>{if(I&&t){const r={...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:",r)}},[I,t]),d.useEffect(()=>{p(),o(),M(),K()},[p,o,M,K]),s||!t)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx(V,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:"Loading..."})]})});const x=t.remote.enabled??!1,A=!x&&G,j=t.remote,E=t.fallback,le=t.remote.host??"",ce=t.remote.port!==void 0?t.remote.port.toString():"",de=t.remote.auth_token??"",ie=t.remote.management_key??"",me=(t.local.port??R).toString(),F=u??le,H=N??ce,$=k??de,q=P??ie,z=l??me,xe=()=>{const r=u??F;r!==t.remote.host&&a({remote:{...j,host:r}}),v(null)},ue=()=>{const r=(N??H).trim();if(r===""){t.remote.port!==void 0&&a({remote:{...j,port:void 0}}),f(null);return}const c=Number(r);if(!Number.isInteger(c)||c<1||c>65535){J.error("Port must be an integer between 1 and 65535, or empty for default"),f(null);return}c!==t.remote.port&&a({remote:{...j,port:c}}),f(null)},pe=()=>{const r=k??$;r!==t.remote.auth_token&&a({remote:{...j,auth_token:r}}),C(null)},he=()=>{const r=P??q;r!==t.remote.management_key&&a({remote:{...j,management_key:r||void 0}}),S(null)},ge=()=>{const r=(l??z).trim(),c=r===""?R:Number(r);if(!Number.isInteger(c)||c<1||c>65535){J.error("Local port must be an integer between 1 and 65535"),i(null);return}c!==t.local.port&&a({local:{...t.local,port:c}}),i(null)},fe=()=>{w({host:F,port:H,protocol:t.remote.protocol||"http",authToken:$})};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 ${m||h?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[m&&e.jsxs(O,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(Le,{className:"h-4 w-4"}),e.jsx(U,{children:m})]}),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(te,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:"Saved"})]})]}),e.jsx(Ie,{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"]}),!x&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Instance Status"}),e.jsx(Be,{})]}),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:()=>a({remote:{...j,enabled:!1}}),disabled:n,className:`p-4 rounded-lg border-2 text-left transition-all ${x?"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(Ae,{className:`w-5 h-5 ${x?"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:()=>a({remote:{...j,enabled:!0}}),disabled:n,className:`p-4 rounded-lg border-2 text-left transition-all ${x?"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(ee,{className:`w-5 h-5 ${x?"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(_e,{className:"w-4 h-4"}),"Backend Binary"]}),!x&&G&&e.jsxs(O,{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:D.isPending||A,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"} ${A?"opacity-60 cursor-not-allowed":""}`,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("span",{className:"font-medium",children:"CLIProxyAPIPlus"}),e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-green-100 text-green-700 dark:bg-green-900/50 dark:text-green-400",children:"Default"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Full provider support including Kiro and GitHub Copilot"})]}),e.jsxs("button",{onClick:()=>W("original"),disabled:D.isPending||A,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"} ${A?"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(O,{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."})]})]}),x&&e.jsx(Ke,{config:t,saving:n,testing:g,testResult:b,displayHost:F,displayPort:H,displayAuthToken:$,displayManagementKey:q,setEditedHost:v,setEditedPort:f,setEditedAuthToken:C,setEditedManagementKey:S,onSaveHost:xe,onSavePort:ue,onSaveAuthToken:pe,onSaveManagementKey:he,onSaveConfig:a,onTestConnection:fe}),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(_,{checked:E.enabled??!0,onCheckedChange:r=>a({fallback:{...E,enabled:r}}),disabled:n||!x})]}),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(_,{checked:E.auto_start??!1,onCheckedChange:r=>a({fallback:{...E,auto_start:r}}),disabled:n||!x||!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(Re,{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(_,{checked:I,onCheckedChange:re,disabled:n})]}),I&&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."})]})]}),!x&&e.jsx(Me,{config:t,saving:n,displayLocalPort:z,setEditedLocalPort:i,onSaveLocalPort:ge,onSaveConfig:a})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(Z,{variant:"outline",size:"sm",onClick:()=>{p(),o(),M(),K()},disabled:s||n,className:"w-full",children:[e.jsx(V,{className:`w-4 h-4 mr-2 ${s?"animate-spin":""}`}),"Refresh"]})})]})}export{Ze as default};
1
+ import{j as e}from"./radix-ui-DIWAxjEp.js";import{r as d}from"./react-vendor-CNOkPC89.js";import{b9 as ye,ba as je,W as L,I as T,q as ve,r as Ne,s as ke,t as Ce,v as Y,b as Z,bb as Pe,bc as Se,bd as we,b2 as O,b4 as U,m as Ie}from"./index-zgEA-GkK.js";import{S as _}from"./switch-BdRPtxoo.js";import{C as M}from"./default-ports-1QQSffYX.js";import{aJ as ee,R as V,f as Ee,r as te,W as Te,a2 as Le,aK as Ae,aL as _e,T as J,aM as Me}from"./icons-ErRLeJ3U.js";import{P as Re}from"./proxy-status-widget-BtL-jVdm.js";import{t as X}from"./notifications-B2HqRBj7.js";import"./tanstack-Hn82hibe.js";import"./utils-CzKF5WmX.js";import"./form-utils-Cn_Uld6y.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-CuEMPUz1.js";function Be(){const{state:t}=ye(),s=je(),[n,m]=d.useState(null),[h,b]=d.useState(null),[g,u]=d.useState(null),[v,N]=d.useState(null),[f,k]=d.useState(null),C=d.useCallback(async()=>{try{s.setProxyLoading(!0),s.setProxyError(null);const l=await L.cliproxyServer.get();s.setProxyConfig(l)}catch(l){s.setProxyError(l.message)}finally{s.setProxyLoading(!1)}},[s]),P=d.useCallback(async l=>{const i=t.proxyConfig;if(!i)return;const p={remote:{...i.remote,...l.remote},fallback:{...i.fallback,...l.fallback},local:{...i.local,...l.local}};s.setProxyConfig(p),s.setProxyTestResult(null);try{s.setProxySaving(!0),s.setProxyError(null);const a=await L.cliproxyServer.update(l);s.setProxyConfig(a),s.setProxySuccess(!0),setTimeout(()=>s.setProxySuccess(!1),1500)}catch(a){s.setProxyConfig(i),s.setProxyError(a.message)}finally{s.setProxySaving(!1)}},[t.proxyConfig,s]),S=d.useCallback(async l=>{const{host:i,port:p,protocol:a,authToken:w}=l;if(!i){s.setProxyError("Host is required");return}try{s.setProxyTesting(!0),s.setProxyError(null),s.setProxyTestResult(null);const o=p?parseInt(p,10):void 0,I=await L.cliproxyServer.test({host:i,port:o||void 0,protocol:a,authToken:w||void 0});s.setProxyTestResult(I)}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:m,editedPort:h,setEditedPort:b,editedAuthToken:g,setEditedAuthToken:u,editedManagementKey:v,setEditedManagementKey:N,editedLocalPort:f,setEditedLocalPort:k,fetchConfig:C,saveConfig:P,testConnection:S}}function De({config:t,saving:s,displayLocalPort:n,setEditedLocalPort:m,onSaveLocalPort:h,onSaveConfig:b}){const g=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:"text",inputMode:"numeric",value:n,onChange:u=>m(u.target.value.replace(/\D/g,"")),onBlur:h,placeholder:`${M}`,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(_,{checked:g.auto_start??!0,onCheckedChange:u=>b({local:{...g,auto_start:u}}),disabled:s})]})]})]})}function Ke({config:t,saving:s,testing:n,testResult:m,displayHost:h,displayPort:b,displayAuthToken:g,displayManagementKey:u,setEditedHost:v,setEditedPort:N,setEditedAuthToken:f,setEditedManagementKey:k,onSaveHost:C,onSavePort:P,onSaveAuthToken:S,onSaveManagementKey:l,onSaveConfig:i,onTestConnection:p}){const a=t.remote,w=o=>o==="https"?443:M;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(ee,{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=>v(o.target.value),onBlur:C,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: ",w(t.remote.protocol||"http"),")"]})]}),e.jsx(T,{type:"text",inputMode:"numeric",value:b,onChange:o=>N(o.target.value.replace(/\D/g,"")),onBlur:P,placeholder:`Leave empty for ${w(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(ve,{value:t.remote.protocol||"http",onValueChange:o=>i({remote:{...a,protocol:o}}),disabled:s,children:[e.jsx(Ne,{children:e.jsx(ke,{})}),e.jsxs(Ce,{children:[e.jsx(Y,{value:"http",children:"HTTP"}),e.jsx(Y,{value:"https",children:"HTTPS"})]})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"API Key (optional)"}),e.jsx(T,{type:"password",value:g,onChange:o=>f(o.target.value),onBlur:S,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:u,onChange:o=>k(o.target.value),onBlur:l,placeholder:"For /v0/management/* endpoints",className:"font-mono",disabled:s}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Used for dashboard management APIs. Falls back to API Key if not set."})]}),e.jsxs("div",{className:"space-y-3 pt-2",children:[e.jsx(Z,{onClick:p,disabled:n||!h,variant:"outline",className:"w-full",children:n?e.jsxs(e.Fragment,{children:[e.jsx(V,{className:"w-4 h-4 mr-2 animate-spin"}),"Testing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ee,{className:"w-4 h-4 mr-2"}),"Test Connection"]})}),m&&e.jsx("div",{className:`p-3 rounded-md ${m.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:m.reachable?e.jsxs(e.Fragment,{children:[e.jsx(te,{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 (",m.latencyMs,"ms)"]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Te,{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:m.error||"Connection failed"})]})})})]})]})}const Q="ccs_debug_mode",Fe=["kiro","ghcp"];function Ze(){const{config:t,loading:s,saving:n,error:m,success:h,testResult:b,testing:g,editedHost:u,setEditedHost:v,editedPort:N,setEditedPort:f,editedAuthToken:k,setEditedAuthToken:C,editedManagementKey:P,setEditedManagementKey:S,editedLocalPort:l,setEditedLocalPort:i,fetchConfig:p,saveConfig:a,testConnection:w}=Be(),{fetchRawConfig:o}=Pe(),[I,se]=d.useState(()=>{try{return localStorage.getItem(Q)==="true"}catch{return!1}}),re=r=>{se(r);try{localStorage.setItem(Q,String(r))}catch{}},[y,R]=d.useState("plus"),[ae,oe]=d.useState(!1),B=Se(),{data:ne}=we(),G=ne?.running??!1,D=d.useCallback(async()=>{try{const r=await L.cliproxyServer.getBackend();R(r.backend)}catch(r){console.error("[Proxy] Failed to fetch backend:",r)}},[]),K=d.useCallback(async()=>{try{const c=(await L.cliproxy.list()).variants.some(be=>Fe.includes(be.provider));oe(c)}catch(r){console.error("[Proxy] Failed to check variants:",r)}},[]),W=r=>{const c=y;R(r),B.mutate({backend:r},{onError:()=>{R(c)}})};if(d.useEffect(()=>{if(I&&t){const r={...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:",r)}},[I,t]),d.useEffect(()=>{p(),o(),D(),K()},[p,o,D,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(V,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:"Loading..."})]})});const x=t.remote.enabled??!1,A=!x&&G,j=t.remote,E=t.fallback,le=t.remote.host??"",ce=t.remote.port!==void 0?t.remote.port.toString():"",de=t.remote.auth_token??"",ie=t.remote.management_key??"",me=(t.local.port??M).toString(),F=u??le,$=N??ce,H=k??de,q=P??ie,z=l??me,xe=()=>{const r=u??F;r!==t.remote.host&&a({remote:{...j,host:r}}),v(null)},ue=()=>{const r=(N??$).trim();if(r===""){t.remote.port!==void 0&&a({remote:{...j,port:void 0}}),f(null);return}const c=Number(r);if(!Number.isInteger(c)||c<1||c>65535){X.error("Port must be an integer between 1 and 65535, or empty for default"),f(null);return}c!==t.remote.port&&a({remote:{...j,port:c}}),f(null)},pe=()=>{const r=k??H;r!==t.remote.auth_token&&a({remote:{...j,auth_token:r}}),C(null)},he=()=>{const r=P??q;r!==t.remote.management_key&&a({remote:{...j,management_key:r||void 0}}),S(null)},ge=()=>{const r=(l??z).trim(),c=r===""?M:Number(r);if(!Number.isInteger(c)||c<1||c>65535){X.error("Local port must be an integer between 1 and 65535"),i(null);return}c!==t.local.port&&a({local:{...t.local,port:c}}),i(null)},fe=()=>{w({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 ${m||h?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[m&&e.jsxs(O,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(Le,{className:"h-4 w-4"}),e.jsx(U,{children:m})]}),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(te,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:"Saved"})]})]}),e.jsx(Ie,{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"]}),!x&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Instance Status"}),e.jsx(Re,{})]}),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:()=>a({remote:{...j,enabled:!1}}),disabled:n,className:`p-4 rounded-lg border-2 text-left transition-all ${x?"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(Ae,{className:`w-5 h-5 ${x?"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:()=>a({remote:{...j,enabled:!0}}),disabled:n,className:`p-4 rounded-lg border-2 text-left transition-all ${x?"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(ee,{className:`w-5 h-5 ${x?"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(_e,{className:"w-4 h-4"}),"Backend Binary"]}),!x&&G&&e.jsxs(O,{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(J,{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:B.isPending||A,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"} ${A?"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:B.isPending||A,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"} ${A?"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(O,{variant:"destructive",className:"py-2",children:[e.jsx(J,{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."})]})]}),x&&e.jsx(Ke,{config:t,saving:n,testing:g,testResult:b,displayHost:F,displayPort:$,displayAuthToken:H,displayManagementKey:q,setEditedHost:v,setEditedPort:f,setEditedAuthToken:C,setEditedManagementKey:S,onSaveHost:xe,onSavePort:ue,onSaveAuthToken:pe,onSaveManagementKey:he,onSaveConfig:a,onTestConnection:fe}),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(_,{checked:E.enabled??!0,onCheckedChange:r=>a({fallback:{...E,enabled:r}}),disabled:n||!x})]}),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(_,{checked:E.auto_start??!1,onCheckedChange:r=>a({fallback:{...E,auto_start:r}}),disabled:n||!x||!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(Me,{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(_,{checked:I,onCheckedChange:re,disabled:n})]}),I&&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."})]})]}),!x&&e.jsx(De,{config:t,saving:n,displayLocalPort:z,setEditedLocalPort:i,onSaveLocalPort:ge,onSaveConfig:a})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(Z,{variant:"outline",size:"sm",onClick:()=>{p(),o(),D(),K()},disabled:s||n,className:"w-full",children:[e.jsx(V,{className:`w-4 h-4 mr-2 ${s?"animate-spin":""}`}),"Refresh"]})})]})}export{Ze as default};
@@ -0,0 +1 @@
1
+ import{j as e}from"./radix-ui-DIWAxjEp.js";import{r as i}from"./react-vendor-CNOkPC89.js";import{b9 as P,ba as $,I as F,bb as U,b2 as _,b4 as z,m as B,b as O}from"./index-zgEA-GkK.js";import{S as K}from"./switch-BdRPtxoo.js";import{z as Y,k as q,_ as D,Y as J,n as V,R as y,a2 as X,r as Z,aI as Q}from"./icons-ErRLeJ3U.js";import"./tanstack-Hn82hibe.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Cn_Uld6y.js";import"./code-highlight-BRUf_pqB.js";function ee(){const{state:s}=P(),a=$(),[d,l]=i.useState(""),[o,m]=i.useState(""),[f,h]=i.useState(!1),[j,u]=i.useState(!1),S=i.useCallback(async()=>{try{a.setWebSearchLoading(!0),a.setWebSearchError(null);const t=await fetch("/api/websearch");if(!t.ok)throw new Error("Failed to load WebSearch config");const r=await t.json();a.setWebSearchConfig(r)}catch(t){a.setWebSearchError(t.message)}finally{a.setWebSearchLoading(!1)}},[a]),v=i.useCallback(async()=>{try{a.setWebSearchStatusLoading(!0);const t=await fetch("/api/websearch/status");if(!t.ok)throw new Error("Failed to load status");const r=await t.json();a.setWebSearchStatus(r)}catch{}finally{a.setWebSearchStatusLoading(!1)}},[a]),g=i.useCallback(async t=>{const r=s.webSearchConfig;if(!r)return;const w={...r,...t};a.setWebSearchConfig(w);try{a.setWebSearchSaving(!0),a.setWebSearchError(null);const n=await fetch("/api/websearch",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(w)});if(!n.ok){const k=await n.json();throw new Error(k.error||"Failed to save")}const C=await n.json();a.setWebSearchConfig(C.websearch),a.setWebSearchSuccess(!0),setTimeout(()=>a.setWebSearchSuccess(!1),1500)}catch(n){a.setWebSearchConfig(r),a.setWebSearchError(n.message)}finally{a.setWebSearchSaving(!1)}},[s.webSearchConfig,a]);i.useEffect(()=>{s.webSearchConfig&&(l(s.webSearchConfig.providers?.gemini?.model??"gemini-2.5-flash"),m(s.webSearchConfig.providers?.opencode?.model??"opencode/grok-code"))},[s.webSearchConfig]);const x=i.useCallback(async()=>{const t=s.webSearchConfig?.providers?.gemini?.model??"gemini-2.5-flash";if(d!==t){const r=s.webSearchConfig?.providers||{};await g({providers:{...r,gemini:{...r.gemini,model:d}}}),h(!0),setTimeout(()=>h(!1),2e3)}},[d,s.webSearchConfig,g]),p=i.useCallback(async()=>{const t=s.webSearchConfig?.providers?.opencode?.model??"opencode/grok-code";if(o!==t){const r=s.webSearchConfig?.providers||{};await g({providers:{...r,opencode:{...r.opencode,model:o}}}),u(!0),setTimeout(()=>u(!1),2e3)}},[o,s.webSearchConfig,g]);return{config:s.webSearchConfig,status:s.webSearchStatus,loading:s.webSearchLoading,statusLoading:s.webSearchStatusLoading,saving:s.webSearchSaving,error:s.webSearchError,success:s.webSearchSuccess,geminiModelInput:d,setGeminiModelInput:l,opencodeModelInput:o,setOpencodeModelInput:m,geminiModelSaved:f,opencodeModelSaved:j,fetchConfig:S,fetchStatus:v,saveConfig:g,saveGeminiModel:x,saveOpencodeModel:p}}function A({name:s,label:a,badge:d,badgeColor:l,enabled:o,installed:m,statusLoading:f,saving:h,onToggle:j,modelInput:u,setModelInput:S,onModelBlur:v,modelSaved:g,modelPlaceholder:x,showHint:p,setShowHint:t,installCmd:r,docsUrl:w,hintColor:n}){const C=l==="green"?"bg-green-500/10 text-green-600":l==="blue"?"bg-blue-500/10 text-blue-600":"bg-purple-500/10 text-purple-600",k=n==="amber"?"bg-amber-50 dark:bg-amber-900/20 text-amber-700 dark:text-amber-300":n==="blue"?"bg-blue-50 dark:bg-blue-900/20 text-blue-700 dark:text-blue-300":"bg-purple-50 dark:bg-purple-900/20 text-purple-700 dark:text-purple-300",I=n==="amber"?"bg-amber-100 dark:bg-amber-900/40":n==="blue"?"bg-blue-100 dark:bg-blue-900/40":"bg-purple-100 dark:bg-purple-900/40",E=n==="amber"?"text-amber-600 dark:text-amber-400":n==="blue"?"text-blue-600 dark:text-blue-400":"text-purple-600 dark:text-purple-400",M=s==="opencode"?"OpenCode":s.charAt(0).toUpperCase()+s.slice(1);return e.jsxs("div",{className:`rounded-lg border transition-colors ${o?"border-primary border-l-4":"border-border"}`,children:[e.jsxs("div",{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Y,{className:`w-5 h-5 ${o?"text-primary":"text-muted-foreground"}`}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-mono font-medium",children:s}),e.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${C}`,children:d}),m?e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-green-500/10 text-green-600 font-medium",children:"installed"}):e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-amber-500/10 text-amber-600 font-medium",children:"not installed"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a})]})]}),e.jsx(K,{checked:o,onCheckedChange:j,disabled:h||!m})]}),o&&u!==void 0&&S&&v&&e.jsx("div",{className:"px-4 pb-4 pt-0",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-sm text-muted-foreground whitespace-nowrap",children:"Model:"}),e.jsx(F,{value:u,onChange:W=>S(W.target.value),onBlur:v,placeholder:x,className:"h-8 text-sm font-mono",disabled:h}),g&&e.jsxs("span",{className:"flex items-center gap-1 text-green-600 dark:text-green-400 text-xs animate-in fade-in duration-200",children:[e.jsx(q,{className:"w-3.5 h-3.5"}),"Saved"]})]})}),!m&&!f&&e.jsxs("div",{className:"px-4 pb-4 pt-0 border-t border-border/50",children:[e.jsxs("button",{onClick:()=>t(!p),className:`flex items-center gap-2 text-sm hover:underline w-full py-2 ${E}`,children:[p?e.jsx(D,{className:"w-4 h-4"}):e.jsx(J,{className:"w-4 h-4"}),"How to install ",M," CLI"]}),p&&e.jsxs("div",{className:`mt-2 p-3 rounded-md text-sm ${k}`,children:[e.jsxs("p",{className:"mb-2",children:["Install globally"," ",d==="GROK_API_KEY"?"(requires xAI API key)":"(FREE tier available)",":"]}),e.jsx("code",{className:`text-sm px-2 py-1 rounded font-mono block mb-2 ${I}`,children:r}),e.jsxs("a",{href:w,target:"_blank",rel:"noopener noreferrer",className:"hover:underline inline-flex items-center gap-1",children:[e.jsx(V,{className:"w-3 h-3"}),"View documentation"]})]})]})]})}function me(){const{config:s,status:a,loading:d,statusLoading:l,saving:o,error:m,success:f,geminiModelInput:h,setGeminiModelInput:j,opencodeModelInput:u,setOpencodeModelInput:S,geminiModelSaved:v,opencodeModelSaved:g,fetchConfig:x,fetchStatus:p,saveConfig:t,saveGeminiModel:r,saveOpencodeModel:w}=ee(),{fetchRawConfig:n}=U(),[C,k]=i.useState(!1),[I,E]=i.useState(!1),[M,W]=i.useState(!1);i.useEffect(()=>{x(),p(),n()},[x,p,n]);const N=s?.providers?.gemini?.enabled??!1,G=s?.providers?.grok?.enabled??!1,L=s?.providers?.opencode?.enabled??!1,H=()=>{const c=s?.providers||{},b=c.gemini?.enabled??!1;t({enabled:!b||G||L,providers:{...c,gemini:{...c.gemini,enabled:!b}}})},R=()=>{const c=s?.providers||{},b=c.grok?.enabled??!1;t({enabled:N||!b||L,providers:{...c,grok:{...c.grok,enabled:!b}}})},T=()=>{const c=s?.providers||{},b=c.opencode?.enabled??!1;t({enabled:N||G||!b,providers:{...c,opencode:{...c.opencode,enabled:!b}}})};return d?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx(y,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:"Loading..."})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${m||f?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[m&&e.jsxs(_,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(X,{className:"h-4 w-4"}),e.jsx(z,{children:m})]}),f&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md border border-green-200 bg-green-50 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(Z,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:"Saved"})]})]}),e.jsx(B,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"CLI-based web search for third-party profiles (gemini, codex, agy, etc.)"}),e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:N?"WebSearch enabled":"WebSearch disabled"}),l?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Checking status..."}):a?.readiness?e.jsx("p",{className:"text-sm text-muted-foreground",children:a.readiness.message}):null]}),e.jsx(O,{variant:"ghost",size:"sm",onClick:p,disabled:l,children:e.jsx(y,{className:`w-4 h-4 ${l?"animate-spin":""}`})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Providers"}),!a?.geminiCli&&!a?.opencodeCli&&!a?.grokCli&&!l&&e.jsxs("div",{className:"flex flex-col items-center justify-center p-8 border-2 border-dashed rounded-lg text-center bg-muted/30",children:[e.jsx(Q,{className:"w-12 h-12 text-muted-foreground mb-3 opacity-30"}),e.jsx("p",{className:"font-medium text-foreground mb-1",children:"No providers configured"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Install CLI tools to enable web search providers"}),e.jsxs(O,{variant:"outline",size:"sm",onClick:p,children:[e.jsx(y,{className:"w-4 h-4 mr-2"}),"Check for providers"]})]}),e.jsx(A,{name:"gemini",label:"Google Gemini CLI (1000 req/day free)",badge:"FREE",badgeColor:"green",enabled:N,installed:a?.geminiCli?.installed??!1,statusLoading:l,saving:o,onToggle:H,modelInput:h,setModelInput:j,onModelBlur:r,modelSaved:v,modelPlaceholder:"gemini-2.5-flash",showHint:C,setShowHint:k,installCmd:"npm install -g @google/gemini-cli",docsUrl:"https://github.com/google-gemini/gemini-cli",hintColor:"amber"}),e.jsx(A,{name:"opencode",label:"OpenCode (web search via Zen)",badge:"FREE",badgeColor:"green",enabled:L,installed:a?.opencodeCli?.installed??!1,statusLoading:l,saving:o,onToggle:T,modelInput:u,setModelInput:S,onModelBlur:w,modelSaved:g,modelPlaceholder:"opencode/grok-code",showHint:I,setShowHint:E,installCmd:"curl -fsSL https://opencode.ai/install | bash",docsUrl:"https://github.com/sst/opencode",hintColor:"purple"}),e.jsx(A,{name:"grok",label:"xAI Grok CLI (web + X search)",badge:"GROK_API_KEY",badgeColor:"blue",enabled:G,installed:a?.grokCli?.installed??!1,statusLoading:l,saving:o,onToggle:R,showHint:M,setShowHint:W,installCmd:"npm install -g @vibe-kit/grok-cli",docsUrl:"https://github.com/superagent-ai/grok-cli",hintColor:"blue"})]})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(O,{variant:"outline",size:"sm",onClick:()=>{x(),n()},disabled:d||o,className:"w-full",children:[e.jsx(y,{className:`w-4 h-4 mr-2 ${d?"animate-spin":""}`}),"Refresh"]})})]})}export{me as default};