@kaitranntt/ccs 7.46.0-dev.5 → 7.46.0-dev.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cliproxy/codex-reasoning-proxy.d.ts +7 -0
- package/dist/cliproxy/codex-reasoning-proxy.d.ts.map +1 -1
- package/dist/cliproxy/codex-reasoning-proxy.js +34 -3
- package/dist/cliproxy/codex-reasoning-proxy.js.map +1 -1
- package/dist/cliproxy/config/thinking-config.js +5 -5
- package/dist/cliproxy/config/thinking-config.js.map +1 -1
- package/dist/cliproxy/executor/index.d.ts.map +1 -1
- package/dist/cliproxy/executor/index.js +10 -1
- package/dist/cliproxy/executor/index.js.map +1 -1
- package/dist/cliproxy/executor/thinking-override-resolver.d.ts +28 -0
- package/dist/cliproxy/executor/thinking-override-resolver.d.ts.map +1 -0
- package/dist/cliproxy/executor/thinking-override-resolver.js +109 -0
- package/dist/cliproxy/executor/thinking-override-resolver.js.map +1 -0
- package/dist/cliproxy/thinking-validator.d.ts +5 -0
- package/dist/cliproxy/thinking-validator.d.ts.map +1 -1
- package/dist/cliproxy/thinking-validator.js +18 -6
- package/dist/cliproxy/thinking-validator.js.map +1 -1
- package/dist/commands/config-command.d.ts.map +1 -1
- package/dist/commands/config-command.js +16 -0
- package/dist/commands/config-command.js.map +1 -1
- package/dist/commands/config-thinking-command.d.ts +9 -0
- package/dist/commands/config-thinking-command.d.ts.map +1 -0
- package/dist/commands/config-thinking-command.js +237 -0
- package/dist/commands/config-thinking-command.js.map +1 -0
- package/dist/commands/config-thinking-parser.d.ts +37 -0
- package/dist/commands/config-thinking-parser.d.ts.map +1 -0
- package/dist/commands/config-thinking-parser.js +135 -0
- package/dist/commands/config-thinking-parser.js.map +1 -0
- package/dist/commands/help-command.d.ts.map +1 -1
- package/dist/commands/help-command.js +4 -0
- package/dist/commands/help-command.js.map +1 -1
- package/dist/ui/assets/{accounts-CDMbYhoK.js → accounts-CBv2_m-e.js} +1 -1
- package/dist/ui/assets/{alert-dialog-BuoGLwhK.js → alert-dialog-DL7XlASm.js} +1 -1
- package/dist/ui/assets/{api-Ds2VDoWj.js → api-BX-4yUwK.js} +1 -1
- package/dist/ui/assets/{auth-section-yxhlBIeU.js → auth-section-DQHJwv63.js} +1 -1
- package/dist/ui/assets/{backups-section-DPkR6c2v.js → backups-section-DknkevFM.js} +1 -1
- package/dist/ui/assets/{cliproxy-DlRLzcMc.js → cliproxy-BDzKadA3.js} +1 -1
- package/dist/ui/assets/{cliproxy-control-panel-B-Kp16o4.js → cliproxy-control-panel-BU03-hoQ.js} +1 -1
- package/dist/ui/assets/{confirm-dialog-ApRA1nJe.js → confirm-dialog-Bcy9oejS.js} +1 -1
- package/dist/ui/assets/{copilot-CvvfxmsM.js → copilot-LD8I8jrG.js} +1 -1
- package/dist/ui/assets/{cursor-BJDbE6ri.js → cursor-D46fCdN2.js} +1 -1
- package/dist/ui/assets/{globalenv-section-Bj18vmmp.js → globalenv-section-Bm-xZiJC.js} +1 -1
- package/dist/ui/assets/{health-C-UMxtTO.js → health-BAi6Irfi.js} +1 -1
- package/dist/ui/assets/index-7VBsk1mJ.js +1 -0
- package/dist/ui/assets/{index-BzXQbaOm.js → index-BP8psFTO.js} +1 -1
- package/dist/ui/assets/{index-BSK5RM6B.js → index-BeJfBJlF.js} +1 -1
- package/dist/ui/assets/{index-C-4s51AH.js → index-usFFopdS.js} +2 -2
- package/dist/ui/assets/{index-CpuTaA7Q.js → index-yrr94eF3.js} +1 -1
- package/dist/ui/assets/{proxy-status-widget-B5Rk4t5g.js → proxy-status-widget-BoxaWU8G.js} +1 -1
- package/dist/ui/assets/{separator-Cmak08sq.js → separator-CD-XHdXM.js} +1 -1
- package/dist/ui/assets/{shared-Pb8lecSN.js → shared-2XMWbVNS.js} +1 -1
- package/dist/ui/assets/{switch-Dw_-BGlW.js → switch-BaBtJszd.js} +1 -1
- package/dist/ui/index.html +1 -1
- package/dist/web-server/routes/misc-routes.d.ts +2 -0
- package/dist/web-server/routes/misc-routes.d.ts.map +1 -1
- package/dist/web-server/routes/misc-routes.js +38 -7
- package/dist/web-server/routes/misc-routes.js.map +1 -1
- package/package.json +1 -1
- package/dist/ui/assets/index-DYpGbm8d.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-qEZD5MMp.js";import{r as p}from"./react-vendor-CNOkPC89.js";import{t as o}from"./notifications-B2HqRBj7.js";import{aS as v,aT as Ze,B as D,b as f,c as ie,m as E,H as $e,J as Ye,K as W,M as ee,L as P,I as se,aV as We,a4 as es,a5 as ss,a6 as ts,a7 as as,a8 as ns,am as rs,X as is,Y as os,Z as ls,_ as cs,ak as ds,al as us,$ as be,aU as ms}from"./index-C-4s51AH.js";import{a as hs,u as q,b as _}from"./tanstack-De4wvi8X.js";import{D as Ae}from"./default-ports-1QQSffYX.js";import{S as Ce}from"./switch-Dw_-BGlW.js";import{S as xs}from"./separator-Cmak08sq.js";import{R as Se,T as fs,ax as ps,K as G,a4 as gs,aw as ke,av as js,L as M,s as ws,ah as vs,a0 as ys,Z as te,ak as Ns,q as bs,r as Cs}from"./icons-DGASzt3M.js";import"./utils-CzKF5WmX.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";async function Ss(){const s=await fetch(v("/cursor/status"));if(!s.ok)throw new Error("Failed to fetch cursor status");return s.json()}async function ks(){const s=await fetch(v("/cursor/settings"));if(!s.ok)throw new Error("Failed to fetch cursor config");return s.json()}async function As(){const s=await fetch(v("/cursor/models"));if(!s.ok)throw new Error("Failed to fetch cursor models");return s.json()}async function Ds(){const s=await fetch(v("/cursor/settings/raw"));if(!s.ok)throw new Error("Failed to fetch cursor raw settings");return s.json()}async function _s(s){const a=await fetch(v("/cursor/settings"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!a.ok)throw new Error("Failed to update cursor config");return a.json()}async function Ms(s){const a=await fetch(v("/cursor/settings/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(a.status===409)throw new Ze("Cursor raw settings changed externally");if(!a.ok)throw new Error("Failed to save cursor raw settings");return a.json()}async function Ps(){const s=await fetch(v("/cursor/auth/auto-detect"),{method:"POST"});if(!s.ok){const a=await s.json().catch(()=>({error:"Auto-detect failed"}));throw new Error(a.error||"Auto-detect failed")}return s.json()}async function Ts(s){const a=await fetch(v("/cursor/auth/import"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!a.ok){const d=await a.json().catch(()=>({error:"Manual import failed"}));throw new Error(d.error||"Manual import failed")}return a.json()}async function Fs(){const s=await fetch(v("/cursor/daemon/start"),{method:"POST"});if(!s.ok)throw new Error("Failed to start cursor daemon");return s.json()}async function Rs(){const s=await fetch(v("/cursor/daemon/stop"),{method:"POST"});if(!s.ok)throw new Error("Failed to stop cursor daemon");return s.json()}function Os(){const s=hs(),a=q({queryKey:["cursor-status"],queryFn:Ss,refetchInterval:5e3}),d=q({queryKey:["cursor-config"],queryFn:ks}),u=q({queryKey:["cursor-models"],queryFn:As}),m=q({queryKey:["cursor-raw-settings"],queryFn:Ds}),l=()=>{s.invalidateQueries({queryKey:["cursor-status"]}),s.invalidateQueries({queryKey:["cursor-config"]}),s.invalidateQueries({queryKey:["cursor-models"]}),s.invalidateQueries({queryKey:["cursor-raw-settings"]})},n=_({mutationFn:_s,onSuccess:l}),c=_({mutationFn:Ms,onSuccess:l}),h=_({mutationFn:Ps,onSuccess:l}),i=_({mutationFn:Ts,onSuccess:l}),y=_({mutationFn:Fs,onSuccess:l}),C=_({mutationFn:Rs,onSuccess:l});return p.useMemo(()=>({status:a.data,statusLoading:a.isLoading,statusError:a.error,refetchStatus:a.refetch,config:d.data,configLoading:d.isLoading,models:u.data?.models??[],currentModel:u.data?.current??null,modelsLoading:u.isLoading,rawSettings:m.data,rawSettingsLoading:m.isLoading,refetchRawSettings:m.refetch,updateConfig:n.mutate,updateConfigAsync:n.mutateAsync,isUpdatingConfig:n.isPending,saveRawSettings:c.mutate,saveRawSettingsAsync:c.mutateAsync,isSavingRawSettings:c.isPending,autoDetectAuth:h.mutate,autoDetectAuthAsync:h.mutateAsync,isAutoDetectingAuth:h.isPending,autoDetectAuthResult:h.data,importManualAuth:i.mutate,importManualAuthAsync:i.mutateAsync,isImportingManualAuth:i.isPending,manualAuthResult:i.data,startDaemon:y.mutate,startDaemonAsync:y.mutateAsync,isStartingDaemon:y.isPending,stopDaemon:C.mutate,stopDaemonAsync:C.mutateAsync,isStoppingDaemon:C.isPending}),[a.data,a.isLoading,a.error,a.refetch,d.data,d.isLoading,u.data,u.isLoading,m.data,m.isLoading,m.refetch,n.mutate,n.mutateAsync,n.isPending,c.mutate,c.mutateAsync,c.isPending,h.mutate,h.mutateAsync,h.isPending,h.data,i.mutate,i.mutateAsync,i.isPending,i.data,y.mutate,y.mutateAsync,y.isPending,C.mutate,C.mutateAsync,C.isPending])}function ae(s){return{port:String(s?.port??Ae),auto_start:s?.auto_start??!1,ghost_mode:s?.ghost_mode??!0,model:s?.model?.trim()||"gpt-5.3-codex",opus_model:s?.opus_model?.trim()||"",sonnet_model:s?.sonnet_model?.trim()||"",haiku_model:s?.haiku_model?.trim()||""}}function N(s,a,d){return s.find(m=>a.some(l=>l.test(m.id)))?.id??d}function ne(s){return s.toLowerCase().replace(/[^a-z0-9]/g,"")}function b(s,a,d){const u=new Set(a.map(ne)),m=s.find(n=>u.has(ne(n.id)));if(m)return m.id;const l=s.find(n=>u.has(ne(n.name)));return l?l.id:d}function Is(s){try{const a=JSON.parse(s||"{}");return!a||typeof a!="object"||Array.isArray(a)?{isValid:!1,error:"Raw settings must be a JSON object"}:{isValid:!0,settings:a}}catch(a){return{isValid:!1,error:a.message||"Invalid JSON"}}}function U({label:s,description:a,value:d,models:u,disabled:m,allowDefaultFallback:l=!1,onChange:n}){const c=d||(l?"__default":""),h=u.find(i=>i.id===d);return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx(P,{className:"text-xs font-medium",children:s}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a})]}),e.jsxs(is,{value:c,onValueChange:i=>{if(l&&i==="__default"){n("");return}n(i)},disabled:m,children:[e.jsx(os,{className:"h-9",children:e.jsx(ls,{placeholder:"Select model",children:c&&e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:l&&c==="__default"?"Use Default Model":h?.name||c}),h?.provider&&e.jsx(D,{variant:"outline",className:"text-[9px] h-4 px-1 capitalize",children:h.provider})]})})}),e.jsx(cs,{className:"max-h-[300px]",children:e.jsxs(ds,{children:[e.jsxs(us,{className:"text-xs text-muted-foreground",children:["Available Models (",u.length,")"]}),l&&e.jsx(be,{value:"__default",children:"Use Default Model"}),u.map(i=>e.jsx(be,{value:i.id,children:e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"truncate text-xs font-mono",children:i.name||i.id}),e.jsx(D,{variant:"outline",className:"text-[9px] h-4 px-1 capitalize",children:i.provider})]})},i.id))]})})]})]})}function re({icon:s,label:a,ok:d,detail:u}){return e.jsxs("div",{className:"flex items-center gap-3 rounded-lg bg-muted/50 px-3 py-2",children:[e.jsx(s,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("p",{className:"text-sm",children:a})}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[d?e.jsx(bs,{className:"h-4 w-4 text-green-500"}):e.jsx(Cs,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:ie("text-xs",d?"text-green-500":"text-muted-foreground"),title:u,children:u})]})]})}function Xs(){const{status:s,statusLoading:a,refetchStatus:d,config:u,updateConfigAsync:m,isUpdatingConfig:l,models:n,modelsLoading:c,currentModel:h,rawSettings:i,rawSettingsLoading:y,refetchRawSettings:C,saveRawSettingsAsync:De,isSavingRawSettings:oe,autoDetectAuthAsync:_e,isAutoDetectingAuth:le,importManualAuthAsync:Me,isImportingManualAuth:ce,startDaemonAsync:Pe,isStartingDaemon:Te,stopDaemonAsync:Fe,isStoppingDaemon:de}=Os(),[A,ue]=p.useState(()=>ae()),[g,me]=p.useState(!1),[he,Re]=p.useState("{}"),[T,z]=p.useState(!1),[Oe,O]=p.useState(!1),[B,xe]=p.useState(""),[J,fe]=p.useState(""),S=ae(u),pe=g?A.port:S.port,K=g?A.auto_start:S.auto_start,H=g?A.ghost_mode:S.ghost_mode,j=g?A.model:S.model,Q=g?A.opus_model:S.opus_model,V=g?A.sonnet_model:S.sonnet_model,X=g?A.haiku_model:S.haiku_model,Z=T?he:JSON.stringify(i?.settings??{},null,2),ge=!!i,F=p.useMemo(()=>Is(Z),[Z]),je=F.isValid,we=g||T,Ie=!T||ge&&je,I=p.useMemo(()=>{const t=new Set,r=[...n].sort((k,Y)=>k.name.localeCompare(Y.name)),x=r.filter(k=>t.has(k.id)?!1:(t.add(k.id),!0));return j&&!r.some(k=>k.id===j)?[{id:j,name:j,provider:"custom"},...x]:x},[n,j]),w=t=>{ue(r=>t(g?r:S)),me(!0)},Le=!!(s?.enabled&&s?.authenticated&&!s?.token_expired),Ee=p.useMemo(()=>s?.enabled?e.jsx(D,{children:"Enabled"}):e.jsx(D,{variant:"secondary",children:"Disabled"}),[s?.enabled]),qe=async({suppressSuccessToast:t=!1}={})=>{const r=Number(pe);if(!Number.isInteger(r)||r<1||r>65535)return o.error("Port must be an integer between 1 and 65535"),!1;if(!j.trim())return o.error("Default model is required"),!1;try{return await m({port:r,auto_start:K,ghost_mode:H,model:j,opus_model:Q||void 0,sonnet_model:V||void 0,haiku_model:X||void 0}),me(!1),ue(ae({port:r,auto_start:K,ghost_mode:H,model:j,opus_model:Q||void 0,sonnet_model:V||void 0,haiku_model:X||void 0})),t||o.success("Cursor config and model mapping saved"),!0}catch(x){return o.error(x.message||"Failed to save config"),!1}},$=t=>{if(c){o.error("Models are still loading. Please wait before applying a preset.");return}if(n.length===0){o.error("No models available yet. Start the daemon and refresh first.");return}const r=j||h||n[0]?.id||"gpt-5.3-codex",x=b(n,["gpt-5.3-codex","gpt53codex","GPT-5.3 Codex"],N(n,[/gpt[-.]?5.*codex/i],r)),k=b(n,["gpt-5.1-codex-max","gpt51codexmax","GPT-5.1 Codex Max"],N(n,[/gpt[-.]?5.*codex.*max/i],x)),Y=b(n,["gpt-5-fast","gpt5fast","GPT-5 Fast"],N(n,[/gpt[-.]?5.*fast/i],x)),Qe=b(n,["gpt-5-mini","gpt5mini","GPT-5 Mini"],N(n,[/gpt[-.]?5.*mini/i],Y)),ye=b(n,["claude-4.6-opus","claude46opus","Claude 4.6 Opus"],N(n,[/claude[-.]?4\.?6.*opus/i,/claude.*opus/i],x)),Ne=b(n,["claude-4.5-sonnet","claude45sonnet","Claude 4.5 Sonnet"],N(n,[/claude[-.]?4\.?5.*sonnet/i,/claude.*sonnet/i],x)),Ve=b(n,["claude-4.5-haiku","claude45haiku","Claude 4.5 Haiku"],N(n,[/claude[-.]?4\.?5.*haiku/i,/haiku/i],Ne)),L=b(n,["gemini-3-pro","gemini3pro","Gemini 3 Pro"],N(n,[/gemini[-.]?3.*pro/i],x)),Xe=b(n,["gemini-3-flash","gemini3flash","Gemini 3 Flash"],N(n,[/gemini[-.]?3.*flash/i,/gemini[-.]?2\.?5.*flash/i],L));if(t==="codex53"){w(R=>({...R,model:x,opus_model:k,sonnet_model:x,haiku_model:Qe})),o.success("Applied GPT-5.3 Codex preset");return}if(t==="claude46"){w(R=>({...R,model:ye,opus_model:ye,sonnet_model:Ne,haiku_model:Ve})),o.success("Applied Claude 4.6 preset");return}w(R=>({...R,model:L,opus_model:L,sonnet_model:L,haiku_model:Xe})),o.success("Applied Gemini 3 preset")},ve=async t=>{try{await m({enabled:t}),o.success(t?"Cursor integration enabled":"Cursor integration disabled")}catch(r){o.error(r.message||"Failed to update integration state")}},Ge=async()=>{try{await _e(),o.success("Cursor credentials imported")}catch(t){o.error(t.message||"Auto-detect failed")}},Ue=async()=>{if(!B.trim()||!J.trim()){o.error("Token and machine ID are required");return}try{await Me({accessToken:B.trim(),machineId:J.trim()}),o.success("Cursor credentials imported"),O(!1),xe(""),fe("")}catch(t){o.error(t.message||"Manual import failed")}},ze=async()=>{try{const t=await Pe();if(!t.success){o.error(t.error||"Failed to start daemon");return}o.success(`Daemon started${t.pid?` (PID: ${t.pid})`:""}`)}catch(t){o.error(t.message||"Failed to start daemon")}},Be=async()=>{try{const t=await Fe();if(!t.success){o.error(t.error||"Failed to stop daemon");return}o.success("Daemon stopped")}catch(t){o.error(t.message||"Failed to stop daemon")}},Je=async({suppressSuccessToast:t=!1}={})=>{if(!ge)return o.error("Raw settings are still loading. Please wait and try again."),!1;if(!F.isValid||!F.settings)return o.error(F.error||"Invalid JSON"),!1;try{return await De({settings:F.settings,expectedMtime:i?.mtime}),z(!1),t||o.success("Raw settings saved"),!0}catch(r){return ms(r)?o.error("Raw settings changed externally. Refresh and retry."):o.error(r.message||"Failed to save raw settings"),!1}},Ke=async()=>{if(!we)return;const t=g,r=T;t&&!await qe({suppressSuccessToast:r})||r&&!await Je({suppressSuccessToast:t})||t&&r&&o.success("Cursor configuration saved")},He=()=>{z(!1),d(),C()};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"h-[calc(100vh-100px)] flex",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col bg-muted/30 shrink-0",children:[e.jsxs("div",{className:"p-4 border-b bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("img",{src:"/assets/sidebar/cursor.svg",alt:"",className:"w-5 h-5 object-contain shrink-0"}),e.jsx("h1",{className:"font-semibold",children:"Cursor"}),e.jsx(D,{variant:"outline",className:"h-5 border-amber-500/60 bg-amber-500/10 px-1.5 text-[10px] font-semibold uppercase tracking-wide text-amber-800 dark:text-amber-300",children:"Beta"}),Ee]}),e.jsx(f,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>d(),disabled:a,children:e.jsx(Se,{className:ie("w-4 h-4",a&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Dedicated Cursor integration controls"})]}),e.jsx(E,{className:"flex-1",children:e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsxs("div",{className:"rounded-md border border-yellow-500/50 bg-yellow-500/15 p-3 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(fs,{className:"h-4 w-4 text-yellow-600 dark:text-yellow-400 shrink-0"}),e.jsx("span",{className:"text-xs font-semibold text-yellow-800 dark:text-yellow-200",children:"Unofficial API - Use at Your Own Risk"})]}),e.jsxs("ul",{className:"text-[11px] text-yellow-700 dark:text-yellow-300 space-y-0.5 pl-6 list-disc",children:[e.jsx("li",{children:"Reverse-engineered integration may break anytime"}),e.jsx("li",{children:"Abuse or excessive usage may risk account restrictions"}),e.jsx("li",{children:"No warranty, no responsibility from CCS"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(re,{icon:ps,label:"Integration",ok:!!s?.enabled,detail:s?.enabled?"Enabled":"Disabled"}),e.jsx(re,{icon:G,label:"Authentication",ok:!!(s?.authenticated&&!s?.token_expired),detail:s?.authenticated?s?.token_expired?"Expired":s.auth_method??"Connected":"Not connected"}),e.jsx(re,{icon:gs,label:"Daemon",ok:!!s?.daemon_running,detail:s?.daemon_running?"Running":"Stopped"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Actions"}),s?.enabled?e.jsxs(f,{variant:"outline",size:"sm",className:"w-full",onClick:()=>ve(!1),disabled:l,children:[e.jsx(ke,{className:"w-3.5 h-3.5 mr-1.5"}),"Disable Integration"]}):e.jsxs(f,{size:"sm",className:"w-full",onClick:()=>ve(!0),disabled:l,children:[e.jsx(js,{className:"w-3.5 h-3.5 mr-1.5"}),"Enable Integration"]}),e.jsxs(f,{variant:"outline",size:"sm",className:"w-full",onClick:Ge,disabled:le,children:[le?e.jsx(M,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(G,{className:"w-3.5 h-3.5 mr-1.5"}),"Auto-detect Auth"]}),e.jsxs(f,{variant:"outline",size:"sm",className:"w-full",onClick:()=>O(!0),children:[e.jsx(G,{className:"w-3.5 h-3.5 mr-1.5"}),"Manual Auth Import"]}),s?.daemon_running?e.jsxs(f,{variant:"outline",size:"sm",className:"w-full",onClick:Be,disabled:de,children:[de?e.jsx(M,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(ke,{className:"w-3.5 h-3.5 mr-1.5"}),"Stop Daemon"]}):e.jsxs(f,{size:"sm",className:"w-full",onClick:ze,disabled:!Le,children:[Te?e.jsx(M,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(ws,{className:"w-3.5 h-3.5 mr-1.5"}),"Start Daemon"]})]})]})}),e.jsx("div",{className:"p-3 border-t bg-background text-xs text-muted-foreground",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Port"}),e.jsx("span",{children:s?.port??u?.port??Ae})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-background overflow-hidden",children:e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Cursor Configuration"}),i&&e.jsx(D,{variant:"outline",className:"text-xs",children:"cursor.settings.json"})]}),i&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified:"," ",i.exists?new Date(i.mtime).toLocaleString():"Never saved"]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(f,{variant:"ghost",size:"sm",onClick:He,disabled:a||y,children:e.jsx(Se,{className:ie("w-4 h-4",(a||y)&&"animate-spin")})}),e.jsx(f,{size:"sm",onClick:Ke,disabled:l||oe||!we||!Ie,children:l||oe?e.jsxs(e.Fragment,{children:[e.jsx(M,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(vs,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]}),e.jsxs("div",{className:"flex-1 min-h-0 flex divide-x overflow-hidden",children:[e.jsx("div",{className:"w-[540px] shrink-0 flex flex-col min-h-0 overflow-hidden bg-muted/5",children:e.jsxs($e,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(Ye,{className:"w-full",children:[e.jsx(W,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(W,{value:"settings",className:"flex-1",children:"Settings"}),e.jsx(W,{value:"info",className:"flex-1",children:"Info"})]})}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden flex flex-col",children:[e.jsx(ee,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(E,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(ys,{className:"w-4 h-4"}),"Presets"]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"Apply pre-configured model mappings"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(f,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>$("codex53"),disabled:c||n.length===0,title:"OpenAI-only mapping: GPT-5.3 Codex / Codex Max / GPT-5 Mini",children:[e.jsx(te,{className:"w-3 h-3"}),"GPT-5.3 Codex"]}),e.jsxs(f,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>$("claude46"),disabled:c||n.length===0,title:"Claude-first mapping: Opus 4.6 / Sonnet 4.5 / Haiku 4.5",children:[e.jsx(te,{className:"w-3 h-3"}),"Claude 4.6"]}),e.jsxs(f,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>$("gemini3"),disabled:c||n.length===0,title:"Gemini-first mapping: Gemini 3 Pro + Gemini 3 Flash",children:[e.jsx(te,{className:"w-3 h-3"}),"Gemini 3 Pro"]})]})]}),e.jsx(xs,{}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-2",children:"Model Mapping"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"Configure which models to use for each tier"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(U,{label:"Default Model",description:"Used when no specific tier is requested.",value:j,models:I,disabled:c,onChange:t=>{w(r=>({...r,model:t}))}}),e.jsx(U,{label:"Opus (Most capable)",description:"Complex reasoning and highest quality responses.",value:Q,models:I,disabled:c,allowDefaultFallback:!0,onChange:t=>{w(r=>({...r,opus_model:t}))}}),e.jsx(U,{label:"Sonnet (Balanced)",description:"General coding and day-to-day chat workloads.",value:V,models:I,disabled:c,allowDefaultFallback:!0,onChange:t=>{w(r=>({...r,sonnet_model:t}))}}),e.jsx(U,{label:"Haiku (Fast)",description:"Low-latency and lightweight request paths.",value:X,models:I,disabled:c,allowDefaultFallback:!0,onChange:t=>{w(r=>({...r,haiku_model:t}))}})]})]})]})})}),e.jsx(ee,{value:"settings",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(E,{className:"flex-1",children:e.jsx("div",{className:"p-4 space-y-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Runtime Settings"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{htmlFor:"cursor-port",className:"text-xs",children:"Port"}),e.jsx(se,{id:"cursor-port",type:"number",min:1,max:65535,className:"max-w-[150px] h-8",value:pe,onChange:t=>{w(r=>({...r,port:t.target.value}))}})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(P,{htmlFor:"cursor-auto-start",className:"text-xs",children:"Auto-start Daemon"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Start Cursor daemon automatically when integration is used."})]}),e.jsx(Ce,{id:"cursor-auto-start",checked:K,onCheckedChange:t=>{w(r=>({...r,auto_start:t}))}})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(P,{htmlFor:"cursor-ghost-mode",className:"text-xs",children:"Ghost Mode"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Request `x-ghost-mode` to reduce telemetry."})]}),e.jsx(Ce,{id:"cursor-ghost-mode",checked:H,onCheckedChange:t=>{w(r=>({...r,ghost_mode:t}))}})]})]})})})}),e.jsx(ee,{value:"info",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(E,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Provider"}),e.jsx("span",{className:"font-mono",children:"Cursor IDE"})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"File Path"}),e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:i?.path??"~/.ccs/cursor.settings.json"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Model mapping writes `ANTHROPIC_MODEL`, `ANTHROPIC_DEFAULT_OPUS_MODEL`, `ANTHROPIC_DEFAULT_SONNET_MODEL`, and `ANTHROPIC_DEFAULT_HAIKU_MODEL` in `cursor.settings.json`."})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:"Available Models"}),c?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(M,{className:"w-4 h-4 animate-spin"}),"Loading models..."]}):n.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No model metadata available yet. Start daemon and refresh."}):e.jsx("div",{className:"space-y-2",children:n.map(t=>e.jsxs("div",{className:"rounded-lg border px-3 py-2 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:t.id}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[t.name," • ",t.provider]})]}),t.id===h&&e.jsx(D,{children:"Default"})]},t.id))})]})]})})})]})]})}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-2 bg-muted/30 border-b flex items-center gap-2 shrink-0 h-[45px]",children:[e.jsx(Ns,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Raw Configuration (JSON)"})]}),e.jsx(We,{rawJsonContent:Z,isRawJsonValid:je,rawJsonEdits:T?he:null,rawSettingsEnv:i?.settings?.env,onChange:t=>{z(!0),Re(t)}})]})]})]})})]}),e.jsx(es,{open:Oe,onOpenChange:O,children:e.jsxs(ss,{children:[e.jsxs(ts,{children:[e.jsx(as,{children:"Manual Cursor Auth Import"}),e.jsx(ns,{children:"Provide Cursor access token and machine ID if auto-detect is unavailable."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(P,{htmlFor:"cursor-manual-token",children:"Access Token"}),e.jsx(se,{id:"cursor-manual-token",value:B,onChange:t=>xe(t.target.value),placeholder:"Paste Cursor access token"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(P,{htmlFor:"cursor-manual-machine-id",children:"Machine ID"}),e.jsx(se,{id:"cursor-manual-machine-id",value:J,onChange:t=>fe(t.target.value),placeholder:"32-char hex (UUID without hyphens)"})]})]}),e.jsxs(rs,{children:[e.jsx(f,{variant:"outline",onClick:()=>O(!1),children:"Cancel"}),e.jsxs(f,{onClick:Ue,disabled:ce,children:[ce?e.jsx(M,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(G,{className:"w-4 h-4 mr-2"}),"Import"]})]})]})})]})}export{Xs as CursorPage};
|
|
1
|
+
import{j as e}from"./radix-ui-qEZD5MMp.js";import{r as p}from"./react-vendor-CNOkPC89.js";import{t as o}from"./notifications-B2HqRBj7.js";import{aS as v,aT as Ze,B as D,b as f,c as ie,m as E,H as $e,J as Ye,K as W,M as ee,L as P,I as se,aV as We,a4 as es,a5 as ss,a6 as ts,a7 as as,a8 as ns,am as rs,X as is,Y as os,Z as ls,_ as cs,ak as ds,al as us,$ as be,aU as ms}from"./index-usFFopdS.js";import{a as hs,u as q,b as _}from"./tanstack-De4wvi8X.js";import{D as Ae}from"./default-ports-1QQSffYX.js";import{S as Ce}from"./switch-BaBtJszd.js";import{S as xs}from"./separator-CD-XHdXM.js";import{R as Se,T as fs,ax as ps,K as G,a4 as gs,aw as ke,av as js,L as M,s as ws,ah as vs,a0 as ys,Z as te,ak as Ns,q as bs,r as Cs}from"./icons-DGASzt3M.js";import"./utils-CzKF5WmX.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";async function Ss(){const s=await fetch(v("/cursor/status"));if(!s.ok)throw new Error("Failed to fetch cursor status");return s.json()}async function ks(){const s=await fetch(v("/cursor/settings"));if(!s.ok)throw new Error("Failed to fetch cursor config");return s.json()}async function As(){const s=await fetch(v("/cursor/models"));if(!s.ok)throw new Error("Failed to fetch cursor models");return s.json()}async function Ds(){const s=await fetch(v("/cursor/settings/raw"));if(!s.ok)throw new Error("Failed to fetch cursor raw settings");return s.json()}async function _s(s){const a=await fetch(v("/cursor/settings"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!a.ok)throw new Error("Failed to update cursor config");return a.json()}async function Ms(s){const a=await fetch(v("/cursor/settings/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(a.status===409)throw new Ze("Cursor raw settings changed externally");if(!a.ok)throw new Error("Failed to save cursor raw settings");return a.json()}async function Ps(){const s=await fetch(v("/cursor/auth/auto-detect"),{method:"POST"});if(!s.ok){const a=await s.json().catch(()=>({error:"Auto-detect failed"}));throw new Error(a.error||"Auto-detect failed")}return s.json()}async function Ts(s){const a=await fetch(v("/cursor/auth/import"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!a.ok){const d=await a.json().catch(()=>({error:"Manual import failed"}));throw new Error(d.error||"Manual import failed")}return a.json()}async function Fs(){const s=await fetch(v("/cursor/daemon/start"),{method:"POST"});if(!s.ok)throw new Error("Failed to start cursor daemon");return s.json()}async function Rs(){const s=await fetch(v("/cursor/daemon/stop"),{method:"POST"});if(!s.ok)throw new Error("Failed to stop cursor daemon");return s.json()}function Os(){const s=hs(),a=q({queryKey:["cursor-status"],queryFn:Ss,refetchInterval:5e3}),d=q({queryKey:["cursor-config"],queryFn:ks}),u=q({queryKey:["cursor-models"],queryFn:As}),m=q({queryKey:["cursor-raw-settings"],queryFn:Ds}),l=()=>{s.invalidateQueries({queryKey:["cursor-status"]}),s.invalidateQueries({queryKey:["cursor-config"]}),s.invalidateQueries({queryKey:["cursor-models"]}),s.invalidateQueries({queryKey:["cursor-raw-settings"]})},n=_({mutationFn:_s,onSuccess:l}),c=_({mutationFn:Ms,onSuccess:l}),h=_({mutationFn:Ps,onSuccess:l}),i=_({mutationFn:Ts,onSuccess:l}),y=_({mutationFn:Fs,onSuccess:l}),C=_({mutationFn:Rs,onSuccess:l});return p.useMemo(()=>({status:a.data,statusLoading:a.isLoading,statusError:a.error,refetchStatus:a.refetch,config:d.data,configLoading:d.isLoading,models:u.data?.models??[],currentModel:u.data?.current??null,modelsLoading:u.isLoading,rawSettings:m.data,rawSettingsLoading:m.isLoading,refetchRawSettings:m.refetch,updateConfig:n.mutate,updateConfigAsync:n.mutateAsync,isUpdatingConfig:n.isPending,saveRawSettings:c.mutate,saveRawSettingsAsync:c.mutateAsync,isSavingRawSettings:c.isPending,autoDetectAuth:h.mutate,autoDetectAuthAsync:h.mutateAsync,isAutoDetectingAuth:h.isPending,autoDetectAuthResult:h.data,importManualAuth:i.mutate,importManualAuthAsync:i.mutateAsync,isImportingManualAuth:i.isPending,manualAuthResult:i.data,startDaemon:y.mutate,startDaemonAsync:y.mutateAsync,isStartingDaemon:y.isPending,stopDaemon:C.mutate,stopDaemonAsync:C.mutateAsync,isStoppingDaemon:C.isPending}),[a.data,a.isLoading,a.error,a.refetch,d.data,d.isLoading,u.data,u.isLoading,m.data,m.isLoading,m.refetch,n.mutate,n.mutateAsync,n.isPending,c.mutate,c.mutateAsync,c.isPending,h.mutate,h.mutateAsync,h.isPending,h.data,i.mutate,i.mutateAsync,i.isPending,i.data,y.mutate,y.mutateAsync,y.isPending,C.mutate,C.mutateAsync,C.isPending])}function ae(s){return{port:String(s?.port??Ae),auto_start:s?.auto_start??!1,ghost_mode:s?.ghost_mode??!0,model:s?.model?.trim()||"gpt-5.3-codex",opus_model:s?.opus_model?.trim()||"",sonnet_model:s?.sonnet_model?.trim()||"",haiku_model:s?.haiku_model?.trim()||""}}function N(s,a,d){return s.find(m=>a.some(l=>l.test(m.id)))?.id??d}function ne(s){return s.toLowerCase().replace(/[^a-z0-9]/g,"")}function b(s,a,d){const u=new Set(a.map(ne)),m=s.find(n=>u.has(ne(n.id)));if(m)return m.id;const l=s.find(n=>u.has(ne(n.name)));return l?l.id:d}function Is(s){try{const a=JSON.parse(s||"{}");return!a||typeof a!="object"||Array.isArray(a)?{isValid:!1,error:"Raw settings must be a JSON object"}:{isValid:!0,settings:a}}catch(a){return{isValid:!1,error:a.message||"Invalid JSON"}}}function U({label:s,description:a,value:d,models:u,disabled:m,allowDefaultFallback:l=!1,onChange:n}){const c=d||(l?"__default":""),h=u.find(i=>i.id===d);return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx(P,{className:"text-xs font-medium",children:s}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a})]}),e.jsxs(is,{value:c,onValueChange:i=>{if(l&&i==="__default"){n("");return}n(i)},disabled:m,children:[e.jsx(os,{className:"h-9",children:e.jsx(ls,{placeholder:"Select model",children:c&&e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:l&&c==="__default"?"Use Default Model":h?.name||c}),h?.provider&&e.jsx(D,{variant:"outline",className:"text-[9px] h-4 px-1 capitalize",children:h.provider})]})})}),e.jsx(cs,{className:"max-h-[300px]",children:e.jsxs(ds,{children:[e.jsxs(us,{className:"text-xs text-muted-foreground",children:["Available Models (",u.length,")"]}),l&&e.jsx(be,{value:"__default",children:"Use Default Model"}),u.map(i=>e.jsx(be,{value:i.id,children:e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"truncate text-xs font-mono",children:i.name||i.id}),e.jsx(D,{variant:"outline",className:"text-[9px] h-4 px-1 capitalize",children:i.provider})]})},i.id))]})})]})]})}function re({icon:s,label:a,ok:d,detail:u}){return e.jsxs("div",{className:"flex items-center gap-3 rounded-lg bg-muted/50 px-3 py-2",children:[e.jsx(s,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("p",{className:"text-sm",children:a})}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[d?e.jsx(bs,{className:"h-4 w-4 text-green-500"}):e.jsx(Cs,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:ie("text-xs",d?"text-green-500":"text-muted-foreground"),title:u,children:u})]})]})}function Xs(){const{status:s,statusLoading:a,refetchStatus:d,config:u,updateConfigAsync:m,isUpdatingConfig:l,models:n,modelsLoading:c,currentModel:h,rawSettings:i,rawSettingsLoading:y,refetchRawSettings:C,saveRawSettingsAsync:De,isSavingRawSettings:oe,autoDetectAuthAsync:_e,isAutoDetectingAuth:le,importManualAuthAsync:Me,isImportingManualAuth:ce,startDaemonAsync:Pe,isStartingDaemon:Te,stopDaemonAsync:Fe,isStoppingDaemon:de}=Os(),[A,ue]=p.useState(()=>ae()),[g,me]=p.useState(!1),[he,Re]=p.useState("{}"),[T,z]=p.useState(!1),[Oe,O]=p.useState(!1),[B,xe]=p.useState(""),[J,fe]=p.useState(""),S=ae(u),pe=g?A.port:S.port,K=g?A.auto_start:S.auto_start,H=g?A.ghost_mode:S.ghost_mode,j=g?A.model:S.model,Q=g?A.opus_model:S.opus_model,V=g?A.sonnet_model:S.sonnet_model,X=g?A.haiku_model:S.haiku_model,Z=T?he:JSON.stringify(i?.settings??{},null,2),ge=!!i,F=p.useMemo(()=>Is(Z),[Z]),je=F.isValid,we=g||T,Ie=!T||ge&&je,I=p.useMemo(()=>{const t=new Set,r=[...n].sort((k,Y)=>k.name.localeCompare(Y.name)),x=r.filter(k=>t.has(k.id)?!1:(t.add(k.id),!0));return j&&!r.some(k=>k.id===j)?[{id:j,name:j,provider:"custom"},...x]:x},[n,j]),w=t=>{ue(r=>t(g?r:S)),me(!0)},Le=!!(s?.enabled&&s?.authenticated&&!s?.token_expired),Ee=p.useMemo(()=>s?.enabled?e.jsx(D,{children:"Enabled"}):e.jsx(D,{variant:"secondary",children:"Disabled"}),[s?.enabled]),qe=async({suppressSuccessToast:t=!1}={})=>{const r=Number(pe);if(!Number.isInteger(r)||r<1||r>65535)return o.error("Port must be an integer between 1 and 65535"),!1;if(!j.trim())return o.error("Default model is required"),!1;try{return await m({port:r,auto_start:K,ghost_mode:H,model:j,opus_model:Q||void 0,sonnet_model:V||void 0,haiku_model:X||void 0}),me(!1),ue(ae({port:r,auto_start:K,ghost_mode:H,model:j,opus_model:Q||void 0,sonnet_model:V||void 0,haiku_model:X||void 0})),t||o.success("Cursor config and model mapping saved"),!0}catch(x){return o.error(x.message||"Failed to save config"),!1}},$=t=>{if(c){o.error("Models are still loading. Please wait before applying a preset.");return}if(n.length===0){o.error("No models available yet. Start the daemon and refresh first.");return}const r=j||h||n[0]?.id||"gpt-5.3-codex",x=b(n,["gpt-5.3-codex","gpt53codex","GPT-5.3 Codex"],N(n,[/gpt[-.]?5.*codex/i],r)),k=b(n,["gpt-5.1-codex-max","gpt51codexmax","GPT-5.1 Codex Max"],N(n,[/gpt[-.]?5.*codex.*max/i],x)),Y=b(n,["gpt-5-fast","gpt5fast","GPT-5 Fast"],N(n,[/gpt[-.]?5.*fast/i],x)),Qe=b(n,["gpt-5-mini","gpt5mini","GPT-5 Mini"],N(n,[/gpt[-.]?5.*mini/i],Y)),ye=b(n,["claude-4.6-opus","claude46opus","Claude 4.6 Opus"],N(n,[/claude[-.]?4\.?6.*opus/i,/claude.*opus/i],x)),Ne=b(n,["claude-4.5-sonnet","claude45sonnet","Claude 4.5 Sonnet"],N(n,[/claude[-.]?4\.?5.*sonnet/i,/claude.*sonnet/i],x)),Ve=b(n,["claude-4.5-haiku","claude45haiku","Claude 4.5 Haiku"],N(n,[/claude[-.]?4\.?5.*haiku/i,/haiku/i],Ne)),L=b(n,["gemini-3-pro","gemini3pro","Gemini 3 Pro"],N(n,[/gemini[-.]?3.*pro/i],x)),Xe=b(n,["gemini-3-flash","gemini3flash","Gemini 3 Flash"],N(n,[/gemini[-.]?3.*flash/i,/gemini[-.]?2\.?5.*flash/i],L));if(t==="codex53"){w(R=>({...R,model:x,opus_model:k,sonnet_model:x,haiku_model:Qe})),o.success("Applied GPT-5.3 Codex preset");return}if(t==="claude46"){w(R=>({...R,model:ye,opus_model:ye,sonnet_model:Ne,haiku_model:Ve})),o.success("Applied Claude 4.6 preset");return}w(R=>({...R,model:L,opus_model:L,sonnet_model:L,haiku_model:Xe})),o.success("Applied Gemini 3 preset")},ve=async t=>{try{await m({enabled:t}),o.success(t?"Cursor integration enabled":"Cursor integration disabled")}catch(r){o.error(r.message||"Failed to update integration state")}},Ge=async()=>{try{await _e(),o.success("Cursor credentials imported")}catch(t){o.error(t.message||"Auto-detect failed")}},Ue=async()=>{if(!B.trim()||!J.trim()){o.error("Token and machine ID are required");return}try{await Me({accessToken:B.trim(),machineId:J.trim()}),o.success("Cursor credentials imported"),O(!1),xe(""),fe("")}catch(t){o.error(t.message||"Manual import failed")}},ze=async()=>{try{const t=await Pe();if(!t.success){o.error(t.error||"Failed to start daemon");return}o.success(`Daemon started${t.pid?` (PID: ${t.pid})`:""}`)}catch(t){o.error(t.message||"Failed to start daemon")}},Be=async()=>{try{const t=await Fe();if(!t.success){o.error(t.error||"Failed to stop daemon");return}o.success("Daemon stopped")}catch(t){o.error(t.message||"Failed to stop daemon")}},Je=async({suppressSuccessToast:t=!1}={})=>{if(!ge)return o.error("Raw settings are still loading. Please wait and try again."),!1;if(!F.isValid||!F.settings)return o.error(F.error||"Invalid JSON"),!1;try{return await De({settings:F.settings,expectedMtime:i?.mtime}),z(!1),t||o.success("Raw settings saved"),!0}catch(r){return ms(r)?o.error("Raw settings changed externally. Refresh and retry."):o.error(r.message||"Failed to save raw settings"),!1}},Ke=async()=>{if(!we)return;const t=g,r=T;t&&!await qe({suppressSuccessToast:r})||r&&!await Je({suppressSuccessToast:t})||t&&r&&o.success("Cursor configuration saved")},He=()=>{z(!1),d(),C()};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"h-[calc(100vh-100px)] flex",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col bg-muted/30 shrink-0",children:[e.jsxs("div",{className:"p-4 border-b bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("img",{src:"/assets/sidebar/cursor.svg",alt:"",className:"w-5 h-5 object-contain shrink-0"}),e.jsx("h1",{className:"font-semibold",children:"Cursor"}),e.jsx(D,{variant:"outline",className:"h-5 border-amber-500/60 bg-amber-500/10 px-1.5 text-[10px] font-semibold uppercase tracking-wide text-amber-800 dark:text-amber-300",children:"Beta"}),Ee]}),e.jsx(f,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>d(),disabled:a,children:e.jsx(Se,{className:ie("w-4 h-4",a&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Dedicated Cursor integration controls"})]}),e.jsx(E,{className:"flex-1",children:e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsxs("div",{className:"rounded-md border border-yellow-500/50 bg-yellow-500/15 p-3 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(fs,{className:"h-4 w-4 text-yellow-600 dark:text-yellow-400 shrink-0"}),e.jsx("span",{className:"text-xs font-semibold text-yellow-800 dark:text-yellow-200",children:"Unofficial API - Use at Your Own Risk"})]}),e.jsxs("ul",{className:"text-[11px] text-yellow-700 dark:text-yellow-300 space-y-0.5 pl-6 list-disc",children:[e.jsx("li",{children:"Reverse-engineered integration may break anytime"}),e.jsx("li",{children:"Abuse or excessive usage may risk account restrictions"}),e.jsx("li",{children:"No warranty, no responsibility from CCS"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(re,{icon:ps,label:"Integration",ok:!!s?.enabled,detail:s?.enabled?"Enabled":"Disabled"}),e.jsx(re,{icon:G,label:"Authentication",ok:!!(s?.authenticated&&!s?.token_expired),detail:s?.authenticated?s?.token_expired?"Expired":s.auth_method??"Connected":"Not connected"}),e.jsx(re,{icon:gs,label:"Daemon",ok:!!s?.daemon_running,detail:s?.daemon_running?"Running":"Stopped"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Actions"}),s?.enabled?e.jsxs(f,{variant:"outline",size:"sm",className:"w-full",onClick:()=>ve(!1),disabled:l,children:[e.jsx(ke,{className:"w-3.5 h-3.5 mr-1.5"}),"Disable Integration"]}):e.jsxs(f,{size:"sm",className:"w-full",onClick:()=>ve(!0),disabled:l,children:[e.jsx(js,{className:"w-3.5 h-3.5 mr-1.5"}),"Enable Integration"]}),e.jsxs(f,{variant:"outline",size:"sm",className:"w-full",onClick:Ge,disabled:le,children:[le?e.jsx(M,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(G,{className:"w-3.5 h-3.5 mr-1.5"}),"Auto-detect Auth"]}),e.jsxs(f,{variant:"outline",size:"sm",className:"w-full",onClick:()=>O(!0),children:[e.jsx(G,{className:"w-3.5 h-3.5 mr-1.5"}),"Manual Auth Import"]}),s?.daemon_running?e.jsxs(f,{variant:"outline",size:"sm",className:"w-full",onClick:Be,disabled:de,children:[de?e.jsx(M,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(ke,{className:"w-3.5 h-3.5 mr-1.5"}),"Stop Daemon"]}):e.jsxs(f,{size:"sm",className:"w-full",onClick:ze,disabled:!Le,children:[Te?e.jsx(M,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(ws,{className:"w-3.5 h-3.5 mr-1.5"}),"Start Daemon"]})]})]})}),e.jsx("div",{className:"p-3 border-t bg-background text-xs text-muted-foreground",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Port"}),e.jsx("span",{children:s?.port??u?.port??Ae})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-background overflow-hidden",children:e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Cursor Configuration"}),i&&e.jsx(D,{variant:"outline",className:"text-xs",children:"cursor.settings.json"})]}),i&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified:"," ",i.exists?new Date(i.mtime).toLocaleString():"Never saved"]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(f,{variant:"ghost",size:"sm",onClick:He,disabled:a||y,children:e.jsx(Se,{className:ie("w-4 h-4",(a||y)&&"animate-spin")})}),e.jsx(f,{size:"sm",onClick:Ke,disabled:l||oe||!we||!Ie,children:l||oe?e.jsxs(e.Fragment,{children:[e.jsx(M,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(vs,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]}),e.jsxs("div",{className:"flex-1 min-h-0 flex divide-x overflow-hidden",children:[e.jsx("div",{className:"w-[540px] shrink-0 flex flex-col min-h-0 overflow-hidden bg-muted/5",children:e.jsxs($e,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(Ye,{className:"w-full",children:[e.jsx(W,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(W,{value:"settings",className:"flex-1",children:"Settings"}),e.jsx(W,{value:"info",className:"flex-1",children:"Info"})]})}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden flex flex-col",children:[e.jsx(ee,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(E,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(ys,{className:"w-4 h-4"}),"Presets"]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"Apply pre-configured model mappings"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(f,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>$("codex53"),disabled:c||n.length===0,title:"OpenAI-only mapping: GPT-5.3 Codex / Codex Max / GPT-5 Mini",children:[e.jsx(te,{className:"w-3 h-3"}),"GPT-5.3 Codex"]}),e.jsxs(f,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>$("claude46"),disabled:c||n.length===0,title:"Claude-first mapping: Opus 4.6 / Sonnet 4.5 / Haiku 4.5",children:[e.jsx(te,{className:"w-3 h-3"}),"Claude 4.6"]}),e.jsxs(f,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>$("gemini3"),disabled:c||n.length===0,title:"Gemini-first mapping: Gemini 3 Pro + Gemini 3 Flash",children:[e.jsx(te,{className:"w-3 h-3"}),"Gemini 3 Pro"]})]})]}),e.jsx(xs,{}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-2",children:"Model Mapping"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"Configure which models to use for each tier"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(U,{label:"Default Model",description:"Used when no specific tier is requested.",value:j,models:I,disabled:c,onChange:t=>{w(r=>({...r,model:t}))}}),e.jsx(U,{label:"Opus (Most capable)",description:"Complex reasoning and highest quality responses.",value:Q,models:I,disabled:c,allowDefaultFallback:!0,onChange:t=>{w(r=>({...r,opus_model:t}))}}),e.jsx(U,{label:"Sonnet (Balanced)",description:"General coding and day-to-day chat workloads.",value:V,models:I,disabled:c,allowDefaultFallback:!0,onChange:t=>{w(r=>({...r,sonnet_model:t}))}}),e.jsx(U,{label:"Haiku (Fast)",description:"Low-latency and lightweight request paths.",value:X,models:I,disabled:c,allowDefaultFallback:!0,onChange:t=>{w(r=>({...r,haiku_model:t}))}})]})]})]})})}),e.jsx(ee,{value:"settings",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(E,{className:"flex-1",children:e.jsx("div",{className:"p-4 space-y-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Runtime Settings"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{htmlFor:"cursor-port",className:"text-xs",children:"Port"}),e.jsx(se,{id:"cursor-port",type:"number",min:1,max:65535,className:"max-w-[150px] h-8",value:pe,onChange:t=>{w(r=>({...r,port:t.target.value}))}})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(P,{htmlFor:"cursor-auto-start",className:"text-xs",children:"Auto-start Daemon"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Start Cursor daemon automatically when integration is used."})]}),e.jsx(Ce,{id:"cursor-auto-start",checked:K,onCheckedChange:t=>{w(r=>({...r,auto_start:t}))}})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(P,{htmlFor:"cursor-ghost-mode",className:"text-xs",children:"Ghost Mode"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Request `x-ghost-mode` to reduce telemetry."})]}),e.jsx(Ce,{id:"cursor-ghost-mode",checked:H,onCheckedChange:t=>{w(r=>({...r,ghost_mode:t}))}})]})]})})})}),e.jsx(ee,{value:"info",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(E,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Provider"}),e.jsx("span",{className:"font-mono",children:"Cursor IDE"})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"File Path"}),e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:i?.path??"~/.ccs/cursor.settings.json"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Model mapping writes `ANTHROPIC_MODEL`, `ANTHROPIC_DEFAULT_OPUS_MODEL`, `ANTHROPIC_DEFAULT_SONNET_MODEL`, and `ANTHROPIC_DEFAULT_HAIKU_MODEL` in `cursor.settings.json`."})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:"Available Models"}),c?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(M,{className:"w-4 h-4 animate-spin"}),"Loading models..."]}):n.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No model metadata available yet. Start daemon and refresh."}):e.jsx("div",{className:"space-y-2",children:n.map(t=>e.jsxs("div",{className:"rounded-lg border px-3 py-2 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:t.id}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[t.name," • ",t.provider]})]}),t.id===h&&e.jsx(D,{children:"Default"})]},t.id))})]})]})})})]})]})}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-2 bg-muted/30 border-b flex items-center gap-2 shrink-0 h-[45px]",children:[e.jsx(Ns,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Raw Configuration (JSON)"})]}),e.jsx(We,{rawJsonContent:Z,isRawJsonValid:je,rawJsonEdits:T?he:null,rawSettingsEnv:i?.settings?.env,onChange:t=>{z(!0),Re(t)}})]})]})]})})]}),e.jsx(es,{open:Oe,onOpenChange:O,children:e.jsxs(ss,{children:[e.jsxs(ts,{children:[e.jsx(as,{children:"Manual Cursor Auth Import"}),e.jsx(ns,{children:"Provide Cursor access token and machine ID if auto-detect is unavailable."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(P,{htmlFor:"cursor-manual-token",children:"Access Token"}),e.jsx(se,{id:"cursor-manual-token",value:B,onChange:t=>xe(t.target.value),placeholder:"Paste Cursor access token"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(P,{htmlFor:"cursor-manual-machine-id",children:"Machine ID"}),e.jsx(se,{id:"cursor-manual-machine-id",value:J,onChange:t=>fe(t.target.value),placeholder:"32-char hex (UUID without hyphens)"})]})]}),e.jsxs(rs,{children:[e.jsx(f,{variant:"outline",onClick:()=>O(!1),children:"Cancel"}),e.jsxs(f,{onClick:Ue,disabled:ce,children:[ce?e.jsx(M,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(G,{className:"w-4 h-4 mr-2"}),"Import"]})]})]})})]})}export{Xs as CursorPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-qEZD5MMp.js";import{r as c}from"./react-vendor-CNOkPC89.js";import{aY as N,aZ as C,a_ as w,aP as y,aR as G,m as S,b,I as p}from"./index-
|
|
1
|
+
import{j as e}from"./radix-ui-qEZD5MMp.js";import{r as c}from"./react-vendor-CNOkPC89.js";import{aY as N,aZ as C,a_ as w,aP as y,aR as G,m as S,b,I as p}from"./index-usFFopdS.js";import{S as k}from"./switch-BaBtJszd.js";import{R as j,a1 as R,q as A,ag as L,$ as _}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";function V(){const{state:s}=N(),a=C(),[l,d]=c.useState(""),[m,v]=c.useState(""),u=c.useCallback(async()=>{try{a.setGlobalEnvLoading(!0),a.setGlobalEnvError(null);const t=await fetch("/api/global-env");if(!t.ok)throw new Error("Failed to load Global Env config");const o=await t.json();a.setGlobalEnvConfig(o)}catch(t){a.setGlobalEnvError(t.message)}finally{a.setGlobalEnvLoading(!1)}},[a]),i=c.useCallback(async t=>{const o=s.globalEnvConfig;if(!o)return;const x={...o,...t};a.setGlobalEnvConfig(x);try{a.setGlobalEnvSaving(!0),a.setGlobalEnvError(null);const r=await fetch("/api/global-env",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(x)});if(!r.ok){const n=await r.json();throw new Error(n.error||"Failed to save")}const h=await r.json();a.setGlobalEnvConfig(h.config),a.setGlobalEnvSuccess(!0),setTimeout(()=>a.setGlobalEnvSuccess(!1),1500)}catch(r){a.setGlobalEnvConfig(o),a.setGlobalEnvError(r.message)}finally{a.setGlobalEnvSaving(!1)}},[s.globalEnvConfig,a]),f=c.useCallback(()=>{if(!l.trim()||!s.globalEnvConfig)return;const t={...s.globalEnvConfig.env,[l.trim()]:m};i({env:t}),d(""),v("")},[l,m,s.globalEnvConfig,i]),g=c.useCallback(t=>{if(!s.globalEnvConfig)return;const o={...s.globalEnvConfig.env};delete o[t],i({env:o})},[s.globalEnvConfig,i]);return{config:s.globalEnvConfig,loading:s.globalEnvLoading,saving:s.globalEnvSaving,error:s.globalEnvError,success:s.globalEnvSuccess,newEnvKey:l,setNewEnvKey:d,newEnvValue:m,setNewEnvValue:v,fetchConfig:u,saveConfig:i,addEnvVar:f,removeEnvVar:g}}function Y(){const{config:s,loading:a,saving:l,error:d,success:m,newEnvKey:v,setNewEnvKey:u,newEnvValue:i,setNewEnvValue:f,fetchConfig:g,saveConfig:t,addEnvVar:o,removeEnvVar:x}=V(),{fetchRawConfig:r}=w();c.useEffect(()=>{g(),r()},[g,r]);const h=()=>{t({enabled:!s?.enabled})};return a?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(j,{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 ${d||m?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[d&&e.jsxs(y,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(R,{className:"h-4 w-4"}),e.jsx(G,{children:d})]}),m&&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(A,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:"Saved"})]})]}),e.jsx(S,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Environment variables injected into all non-Claude subscription profiles (gemini, codex, agy, ghcp, 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:s?.enabled?"Global Env enabled":"Global Env disabled"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s?.enabled?"Env vars will be injected into third-party profiles":"Env vars will not be injected"})]}),e.jsx(k,{checked:s?.enabled??!0,onCheckedChange:h})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Environment Variables"}),s?.env&&Object.keys(s.env).length>0?e.jsx("div",{className:"space-y-2",children:Object.entries(s.env).map(([n,E])=>e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg border bg-background",children:[e.jsx("code",{className:"flex-1 font-mono text-sm truncate",children:n}),e.jsx("span",{className:"text-muted-foreground",children:"="}),e.jsx("code",{className:"font-mono text-sm px-2 py-1 bg-muted rounded",children:E}),e.jsx(b,{variant:"ghost",size:"sm",onClick:()=>x(n),disabled:l,className:"h-8 w-8 p-0 text-destructive hover:text-destructive hover:bg-destructive/10",children:e.jsx(L,{className:"w-4 h-4"})})]},n))}):e.jsx("div",{className:"p-4 rounded-lg border border-dashed text-center text-muted-foreground",children:e.jsx("p",{children:"No environment variables configured"})}),e.jsxs("div",{className:"p-4 rounded-lg border bg-muted/30",children:[e.jsx("h4",{className:"text-sm font-medium mb-3",children:"Add New Variable"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(p,{value:v,onChange:n=>u(n.target.value.toUpperCase()),placeholder:"KEY_NAME",className:"flex-1 font-mono text-sm h-9",disabled:l}),e.jsx("span",{className:"flex items-center text-muted-foreground",children:"="}),e.jsx(p,{value:i,onChange:n=>f(n.target.value),placeholder:"value",className:"flex-1 font-mono text-sm h-9",disabled:l}),e.jsxs(b,{size:"sm",onClick:o,disabled:l||!v.trim(),className:"h-9",children:[e.jsx(_,{className:"w-4 h-4 mr-1"}),"Add"]})]})]}),e.jsxs("div",{className:"p-4 rounded-lg border bg-muted/30",children:[e.jsx("h4",{className:"text-sm font-medium mb-3",children:"Quick Add Common Variables"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[[{key:"DISABLE_BUG_COMMAND",value:"1"},{key:"DISABLE_ERROR_REPORTING",value:"1"},{key:"DISABLE_TELEMETRY",value:"1"}].map(({key:n,value:E})=>!s?.env?.[n]&&e.jsxs(b,{variant:"outline",size:"sm",onClick:()=>{u(n),f(E)},className:"text-xs font-mono",children:["+ ",n]},n)),s?.env&&["DISABLE_BUG_COMMAND","DISABLE_ERROR_REPORTING","DISABLE_TELEMETRY"].every(n=>s.env[n])&&e.jsx("span",{className:"text-sm text-muted-foreground",children:"All common variables are configured"})]})]})]})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(b,{variant:"outline",size:"sm",onClick:()=>{g(),r()},disabled:a||l,className:"w-full",children:[e.jsx(j,{className:`w-4 h-4 mr-2 ${a?"animate-spin":""}`}),"Refresh"]})})]})}export{Y as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-qEZD5MMp.js";import{c as l,b as p,E as w,F as y,G as k,B as z,S as h}from"./index-C-4s51AH.js";import{u as R,a as E,b as M}from"./tanstack-De4wvi8X.js";import{t as g}from"./notifications-B2HqRBj7.js";import{r as j}from"./react-vendor-CNOkPC89.js";import{ay as v,b as W,y as C,l as S,Z as P,f as O,U as $,S as F,az as I,Y as H,x as T,R as A}from"./icons-DGASzt3M.js";import"./utils-CzKF5WmX.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";const B={sm:{dimension:80,strokeWidth:6,fontSize:"text-lg",labelSize:"text-[10px]"},md:{dimension:120,strokeWidth:8,fontSize:"text-3xl",labelSize:"text-xs"},lg:{dimension:160,strokeWidth:10,fontSize:"text-4xl",labelSize:"text-sm"}},D={ok:{stroke:"#22C55E",glow:"rgba(34, 197, 94, 0.4)"},warning:{stroke:"#EAB308",glow:"rgba(234, 179, 8, 0.4)"},error:{stroke:"#EF4444",glow:"rgba(239, 68, 68, 0.4)"}};function G({passed:s,total:t,status:r,size:o="md"}){const n=B[o],d=D[r],i=t>0?Math.round(s/t*100):0,a=(n.dimension-n.strokeWidth)/2,c=2*Math.PI*a,f=c-i/100*c,x=n.dimension/2;return e.jsxs("div",{className:"relative inline-flex items-center justify-center",children:[e.jsxs("svg",{width:n.dimension,height:n.dimension,className:"transform -rotate-90",style:{filter:`drop-shadow(0 0 8px ${d.glow})`},children:[e.jsx("circle",{cx:x,cy:x,r:a,fill:"none",stroke:"currentColor",strokeWidth:n.strokeWidth,className:"text-muted/30"}),e.jsx("circle",{cx:x,cy:x,r:a,fill:"none",stroke:d.stroke,strokeWidth:n.strokeWidth,strokeLinecap:"round",strokeDasharray:c,strokeDashoffset:f,className:"transition-all duration-1000 ease-out"}),i>0&&e.jsx("circle",{cx:x+a*Math.cos(i/100*2*Math.PI-Math.PI/2),cy:x+a*Math.sin(i/100*2*Math.PI-Math.PI/2),r:n.strokeWidth/2,fill:d.stroke,className:"animate-pulse",style:{filter:`drop-shadow(0 0 4px ${d.glow})`}})]}),e.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[e.jsx("span",{className:l("font-mono font-bold tracking-tight",n.fontSize),children:i}),e.jsx("span",{className:l("font-mono uppercase tracking-widest text-muted-foreground",n.labelSize),children:"health"})]})]})}function b({label:s,value:t,color:r,bgColor:o}){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:l("w-2 h-2 rounded-full animate-pulse",o)}),e.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:s}),e.jsx("span",{className:l("font-mono font-bold text-sm",r),children:t})]})}function L({total:s,passed:t,warnings:r,errors:o,info:n}){const d=t/s*100,i=r/s*100,a=o/s*100,c=n/s*100;return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"h-2 rounded-full overflow-hidden bg-muted/50 flex",children:[a>0&&e.jsx("div",{className:"h-full bg-red-500 transition-all duration-500",style:{width:`${a}%`}}),i>0&&e.jsx("div",{className:"h-full bg-yellow-500 transition-all duration-500",style:{width:`${i}%`}}),c>0&&e.jsx("div",{className:"h-full bg-blue-500 transition-all duration-500",style:{width:`${c}%`}}),d>0&&e.jsx("div",{className:"h-full bg-green-500 transition-all duration-500",style:{width:`${d}%`}})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Checks"}),e.jsx("span",{className:"font-mono font-bold text-lg",children:s})]}),e.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[e.jsx(b,{label:"OK",value:t,color:"text-green-500",bgColor:"bg-green-500"}),e.jsx(b,{label:"WARN",value:r,color:"text-yellow-500",bgColor:"bg-yellow-500"}),e.jsx(b,{label:"ERR",value:o,color:"text-red-500",bgColor:"bg-red-500"}),e.jsx(b,{label:"INFO",value:n,color:"text-blue-500",bgColor:"bg-blue-500"})]})]})]})}function q(){return R({queryKey:["health"],queryFn:async()=>(await fetch("/api/health")).json(),refetchInterval:3e4})}function K(){const s=E();return M({mutationFn:async t=>{const r=await fetch(`/api/health/fix/${t}`,{method:"POST"}),o=await r.json();if(!r.ok)throw new Error(o.message);return o},onSuccess:t=>{s.invalidateQueries({queryKey:["health"]}),g.success(t.message)},onError:t=>{g.error(t.message)}})}const Q={ok:{dot:"bg-green-500",label:"OK",labelColor:"text-green-500"},warning:{dot:"bg-yellow-500",label:"WARN",labelColor:"text-yellow-500"},error:{dot:"bg-red-500",label:"ERR",labelColor:"text-red-500"},info:{dot:"bg-blue-500",label:"INFO",labelColor:"text-blue-500"}};function U({check:s}){const t=K(),r=Q[s.status],[o,n]=j.useState(!1),d=s.details||s.fix,i=a=>{navigator.clipboard.writeText(a),g.success("Copied to clipboard")};return d?e.jsx(w,{open:o,onOpenChange:n,children:e.jsxs("div",{className:l("group rounded-lg border transition-all duration-150",o?"border-border bg-muted/30":"border-transparent hover:border-border/50 hover:bg-muted/50"),children:[e.jsx(y,{asChild:!0,children:e.jsxs("button",{className:"w-full flex items-center gap-3 px-3 py-2 text-left",children:[e.jsxs("div",{className:"relative flex items-center justify-center w-4 h-4",children:[e.jsx("div",{className:l("w-2 h-2 rounded-full",r.dot)}),s.status!=="ok"&&e.jsx("div",{className:l("absolute w-2 h-2 rounded-full animate-ping opacity-75",r.dot)})]}),e.jsx("span",{className:"flex-1 text-sm font-medium truncate",children:s.name}),e.jsxs("span",{className:l("font-mono text-xs font-semibold",r.labelColor),children:["[",r.label,"]"]}),e.jsx(W,{className:l("w-4 h-4 text-muted-foreground transition-transform duration-200",o&&"rotate-90")})]})}),e.jsx(k,{children:e.jsxs("div",{className:"px-3 pb-3 pt-1 space-y-2 ml-7",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:s.message}),s.details&&e.jsx("pre",{className:"text-xs font-mono text-muted-foreground bg-background/50 rounded p-2 overflow-x-auto border border-border/50",children:s.details}),s.fix&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex-1 flex items-center gap-2 bg-background/50 rounded px-2 py-1.5 border border-border/50",children:[e.jsx(C,{className:"w-3 h-3 text-muted-foreground shrink-0"}),e.jsx("code",{className:"text-xs font-mono flex-1 truncate",children:s.fix}),e.jsx(p,{variant:"ghost",size:"sm",onClick:()=>s.fix&&i(s.fix),className:"h-5 w-5 p-0",children:e.jsx(S,{className:"w-3 h-3"})})]}),s.fixable&&s.status!=="ok"&&e.jsxs(p,{size:"sm",onClick:()=>t.mutate(s.id),disabled:t.isPending,className:"h-7 px-3 text-xs",children:[e.jsx(v,{className:"w-3 h-3 mr-1"}),"Apply Fix"]})]})]})})]})}):e.jsxs("div",{className:l("group flex items-center gap-3 px-3 py-2 rounded-lg","hover:bg-muted/50 transition-colors duration-150","border border-transparent hover:border-border/50"),children:[e.jsxs("div",{className:"relative flex items-center justify-center w-4 h-4",children:[e.jsx("div",{className:l("w-2 h-2 rounded-full",r.dot)}),s.status!=="ok"&&e.jsx("div",{className:l("absolute w-2 h-2 rounded-full animate-ping opacity-75",r.dot)})]}),e.jsx("span",{className:"flex-1 text-sm font-medium truncate",children:s.name}),e.jsxs("span",{className:l("font-mono text-xs font-semibold",r.labelColor),children:["[",r.label,"]"]}),s.fixable&&s.status!=="ok"&&e.jsxs(p,{size:"sm",variant:"ghost",onClick:()=>t.mutate(s.id),disabled:t.isPending,className:"h-6 px-2 text-xs opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx(v,{className:"w-3 h-3 mr-1"}),"Fix"]})]})}const Z={Monitor:I,Settings:F,Users:$,Shield:O,Zap:P};function V({group:s,defaultOpen:t=!0}){const[r,o]=j.useState(t),n=Z[s.icon]||I,d=s.checks.filter(m=>m.status==="ok").length,i=s.checks.length,a=s.checks.some(m=>m.status==="error"),c=s.checks.some(m=>m.status==="warning"),f=Math.round(d/i*100),x=a?"text-red-500":c?"text-yellow-500":"text-green-500",u=a?"bg-red-500":c?"bg-yellow-500":"bg-green-500";return e.jsx(w,{open:r,onOpenChange:o,children:e.jsxs("div",{className:l("rounded-lg border transition-all duration-200",a?"border-red-500/30":c?"border-yellow-500/30":"border-border"),children:[e.jsx(y,{asChild:!0,children:e.jsxs("button",{className:l("w-full flex items-center gap-3 p-3 text-left rounded-lg","hover:bg-muted/50 transition-colors duration-150",r&&"rounded-b-none border-b border-border/50"),children:[e.jsx("div",{className:l("p-1.5 rounded-md",a?"bg-red-500/10 text-red-500":c?"bg-yellow-500/10 text-yellow-500":"bg-muted text-muted-foreground"),children:e.jsx(n,{className:"w-4 h-4"})}),e.jsx("span",{className:"flex-1 text-sm font-semibold",children:s.name}),!r&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("div",{className:"w-16 h-1.5 rounded-full bg-muted overflow-hidden",children:e.jsx("div",{className:l("h-full transition-all duration-500",u),style:{width:`${f}%`}})})}),e.jsxs("span",{className:l("font-mono text-xs font-semibold",x),children:[d,"/",i]}),e.jsx(H,{className:l("w-4 h-4 text-muted-foreground transition-transform duration-200",r&&"rotate-180")})]})}),e.jsx(k,{children:e.jsx("div",{className:"p-2 space-y-0.5",children:s.checks.map(m=>e.jsx(U,{check:m},m.id))})})]})})}function Y(s){return s.errors>0?"error":s.warnings>0?"warning":"ok"}function J(s){const t=Math.floor((Date.now()-s)/1e3);if(t<5)return"just now";if(t<60)return`${t}s ago`;const r=Math.floor(t/60);return r<60?`${r}m ago`:`${Math.floor(r/60)}h ago`}function X(s){return[...s].sort((t,r)=>{const o=t.checks.filter(a=>a.status==="error").length,n=r.checks.filter(a=>a.status==="error").length,d=t.checks.filter(a=>a.status==="warning").length,i=r.checks.filter(a=>a.status==="warning").length;return o!==n?n-o:i-d})}function _(){return e.jsxs("div",{className:"font-mono text-sm text-muted-foreground flex items-center gap-2",children:[e.jsx("span",{className:"text-green-500",children:"$"}),e.jsx("span",{children:"ccs doctor"})]})}function ee(){return e.jsxs("div",{className:"p-6 max-w-6xl mx-auto space-y-6",children:[e.jsx("div",{className:"rounded-xl border bg-gradient-to-br from-background to-muted/20 p-6",children:e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsx(h,{className:"w-[120px] h-[120px] rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx(h,{className:"h-5 w-48"}),e.jsx(h,{className:"h-8 w-64"}),e.jsx(h,{className:"h-4 w-32"})]})]})}),e.jsx(h,{className:"h-16 w-full rounded-lg"}),e.jsx("div",{className:"space-y-3",children:[1,2,3,4].map(s=>e.jsx(h,{className:"h-20 rounded-lg"},s))})]})}function ce(){const{data:s,isLoading:t,refetch:r,dataUpdatedAt:o}=q(),n=o,[d,i]=j.useState(0);j.useEffect(()=>{const u=setInterval(()=>i(m=>m+1),1e3);return()=>clearInterval(u)},[]);const a=()=>{navigator.clipboard.writeText("ccs doctor"),g.success("Copied to clipboard")},c=()=>{r(),g.info("Refreshing health checks...")};if(t&&!s)return e.jsx(ee,{});const f=s?Y(s.summary):"ok",x=s?.groups?X(s.groups):[];return e.jsxs("div",{className:"p-6 max-w-6xl mx-auto space-y-6",children:[e.jsxs("div",{className:l("relative overflow-hidden rounded-xl border p-6","bg-gradient-to-br from-background via-background to-muted/30"),children:[e.jsx("div",{className:"absolute inset-0 opacity-[0.02] pointer-events-none",style:{backgroundImage:"repeating-linear-gradient(0deg, transparent, transparent 2px, currentColor 2px, currentColor 3px)"}}),e.jsx("div",{className:"absolute inset-0 opacity-[0.03] pointer-events-none",children:e.jsx("div",{className:"absolute inset-0",style:{backgroundImage:"radial-gradient(circle at 1px 1px, currentColor 1px, transparent 0)",backgroundSize:"24px 24px"}})}),e.jsxs("div",{className:"relative flex flex-col md:flex-row items-start md:items-center gap-6",children:[s&&e.jsx("div",{className:"shrink-0",children:e.jsx(G,{passed:s.summary.passed,total:s.summary.total-s.summary.info,status:f,size:"md"})}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx(_,{}),e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx("h1",{className:"text-2xl font-bold font-mono tracking-tight",children:"System Health"}),s?.version&&e.jsxs(z,{variant:"outline",className:"font-mono text-xs bg-muted/50",children:["build ",s.version]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(T,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:"Last scan:"}),e.jsx("span",{className:"font-mono",children:n?J(n):"--"}),e.jsx("span",{className:"text-muted-foreground",children:"|"}),e.jsx("span",{className:"text-muted-foreground",children:"Auto-refresh:"}),e.jsx("span",{className:"font-mono text-green-500",children:"30s"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs(p,{variant:"outline",size:"sm",onClick:a,className:"gap-2 font-mono text-xs",children:[e.jsx(C,{className:"w-3 h-3"}),"ccs doctor",e.jsx(S,{className:"w-3 h-3 opacity-50"})]}),e.jsxs(p,{variant:"outline",size:"sm",onClick:c,disabled:t,className:"gap-2",children:[e.jsx(A,{className:l("w-4 h-4",t&&"animate-spin")}),e.jsx("span",{className:"hidden sm:inline",children:"Refresh"}),e.jsx("kbd",{className:"hidden md:inline-flex h-5 items-center gap-1 rounded border bg-muted px-1.5 font-mono text-[10px] font-medium text-muted-foreground",children:"R"})]})]})]})]}),s&&e.jsx("div",{className:"rounded-lg border bg-card p-4",children:e.jsx(L,{total:s.summary.total,passed:s.summary.passed,warnings:s.summary.warnings,errors:s.summary.errors,info:s.summary.info})}),x.length>0&&e.jsx("div",{className:"space-y-3",children:x.map((u,m)=>e.jsx(V,{group:u,defaultOpen:m<2||u.checks.some(N=>N.status==="error"||N.status==="warning")},u.id))}),e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground border-t pt-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("span",{children:["Version ",e.jsx("span",{className:"font-mono",children:s?.version??"--"})]}),e.jsxs("span",{children:["Platform"," ",e.jsx("span",{className:"font-mono",children:typeof navigator<"u"?navigator.platform:"linux"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-green-500 animate-pulse"}),e.jsx("span",{children:"Live monitoring active"})]})]})]})}export{ce as HealthPage};
|
|
1
|
+
import{j as e}from"./radix-ui-qEZD5MMp.js";import{c as l,b as p,E as w,F as y,G as k,B as z,S as h}from"./index-usFFopdS.js";import{u as R,a as E,b as M}from"./tanstack-De4wvi8X.js";import{t as g}from"./notifications-B2HqRBj7.js";import{r as j}from"./react-vendor-CNOkPC89.js";import{ay as v,b as W,y as C,l as S,Z as P,f as O,U as $,S as F,az as I,Y as H,x as T,R as A}from"./icons-DGASzt3M.js";import"./utils-CzKF5WmX.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";const B={sm:{dimension:80,strokeWidth:6,fontSize:"text-lg",labelSize:"text-[10px]"},md:{dimension:120,strokeWidth:8,fontSize:"text-3xl",labelSize:"text-xs"},lg:{dimension:160,strokeWidth:10,fontSize:"text-4xl",labelSize:"text-sm"}},D={ok:{stroke:"#22C55E",glow:"rgba(34, 197, 94, 0.4)"},warning:{stroke:"#EAB308",glow:"rgba(234, 179, 8, 0.4)"},error:{stroke:"#EF4444",glow:"rgba(239, 68, 68, 0.4)"}};function G({passed:s,total:t,status:r,size:o="md"}){const n=B[o],d=D[r],i=t>0?Math.round(s/t*100):0,a=(n.dimension-n.strokeWidth)/2,c=2*Math.PI*a,f=c-i/100*c,x=n.dimension/2;return e.jsxs("div",{className:"relative inline-flex items-center justify-center",children:[e.jsxs("svg",{width:n.dimension,height:n.dimension,className:"transform -rotate-90",style:{filter:`drop-shadow(0 0 8px ${d.glow})`},children:[e.jsx("circle",{cx:x,cy:x,r:a,fill:"none",stroke:"currentColor",strokeWidth:n.strokeWidth,className:"text-muted/30"}),e.jsx("circle",{cx:x,cy:x,r:a,fill:"none",stroke:d.stroke,strokeWidth:n.strokeWidth,strokeLinecap:"round",strokeDasharray:c,strokeDashoffset:f,className:"transition-all duration-1000 ease-out"}),i>0&&e.jsx("circle",{cx:x+a*Math.cos(i/100*2*Math.PI-Math.PI/2),cy:x+a*Math.sin(i/100*2*Math.PI-Math.PI/2),r:n.strokeWidth/2,fill:d.stroke,className:"animate-pulse",style:{filter:`drop-shadow(0 0 4px ${d.glow})`}})]}),e.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[e.jsx("span",{className:l("font-mono font-bold tracking-tight",n.fontSize),children:i}),e.jsx("span",{className:l("font-mono uppercase tracking-widest text-muted-foreground",n.labelSize),children:"health"})]})]})}function b({label:s,value:t,color:r,bgColor:o}){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:l("w-2 h-2 rounded-full animate-pulse",o)}),e.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:s}),e.jsx("span",{className:l("font-mono font-bold text-sm",r),children:t})]})}function L({total:s,passed:t,warnings:r,errors:o,info:n}){const d=t/s*100,i=r/s*100,a=o/s*100,c=n/s*100;return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"h-2 rounded-full overflow-hidden bg-muted/50 flex",children:[a>0&&e.jsx("div",{className:"h-full bg-red-500 transition-all duration-500",style:{width:`${a}%`}}),i>0&&e.jsx("div",{className:"h-full bg-yellow-500 transition-all duration-500",style:{width:`${i}%`}}),c>0&&e.jsx("div",{className:"h-full bg-blue-500 transition-all duration-500",style:{width:`${c}%`}}),d>0&&e.jsx("div",{className:"h-full bg-green-500 transition-all duration-500",style:{width:`${d}%`}})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Checks"}),e.jsx("span",{className:"font-mono font-bold text-lg",children:s})]}),e.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[e.jsx(b,{label:"OK",value:t,color:"text-green-500",bgColor:"bg-green-500"}),e.jsx(b,{label:"WARN",value:r,color:"text-yellow-500",bgColor:"bg-yellow-500"}),e.jsx(b,{label:"ERR",value:o,color:"text-red-500",bgColor:"bg-red-500"}),e.jsx(b,{label:"INFO",value:n,color:"text-blue-500",bgColor:"bg-blue-500"})]})]})]})}function q(){return R({queryKey:["health"],queryFn:async()=>(await fetch("/api/health")).json(),refetchInterval:3e4})}function K(){const s=E();return M({mutationFn:async t=>{const r=await fetch(`/api/health/fix/${t}`,{method:"POST"}),o=await r.json();if(!r.ok)throw new Error(o.message);return o},onSuccess:t=>{s.invalidateQueries({queryKey:["health"]}),g.success(t.message)},onError:t=>{g.error(t.message)}})}const Q={ok:{dot:"bg-green-500",label:"OK",labelColor:"text-green-500"},warning:{dot:"bg-yellow-500",label:"WARN",labelColor:"text-yellow-500"},error:{dot:"bg-red-500",label:"ERR",labelColor:"text-red-500"},info:{dot:"bg-blue-500",label:"INFO",labelColor:"text-blue-500"}};function U({check:s}){const t=K(),r=Q[s.status],[o,n]=j.useState(!1),d=s.details||s.fix,i=a=>{navigator.clipboard.writeText(a),g.success("Copied to clipboard")};return d?e.jsx(w,{open:o,onOpenChange:n,children:e.jsxs("div",{className:l("group rounded-lg border transition-all duration-150",o?"border-border bg-muted/30":"border-transparent hover:border-border/50 hover:bg-muted/50"),children:[e.jsx(y,{asChild:!0,children:e.jsxs("button",{className:"w-full flex items-center gap-3 px-3 py-2 text-left",children:[e.jsxs("div",{className:"relative flex items-center justify-center w-4 h-4",children:[e.jsx("div",{className:l("w-2 h-2 rounded-full",r.dot)}),s.status!=="ok"&&e.jsx("div",{className:l("absolute w-2 h-2 rounded-full animate-ping opacity-75",r.dot)})]}),e.jsx("span",{className:"flex-1 text-sm font-medium truncate",children:s.name}),e.jsxs("span",{className:l("font-mono text-xs font-semibold",r.labelColor),children:["[",r.label,"]"]}),e.jsx(W,{className:l("w-4 h-4 text-muted-foreground transition-transform duration-200",o&&"rotate-90")})]})}),e.jsx(k,{children:e.jsxs("div",{className:"px-3 pb-3 pt-1 space-y-2 ml-7",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:s.message}),s.details&&e.jsx("pre",{className:"text-xs font-mono text-muted-foreground bg-background/50 rounded p-2 overflow-x-auto border border-border/50",children:s.details}),s.fix&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex-1 flex items-center gap-2 bg-background/50 rounded px-2 py-1.5 border border-border/50",children:[e.jsx(C,{className:"w-3 h-3 text-muted-foreground shrink-0"}),e.jsx("code",{className:"text-xs font-mono flex-1 truncate",children:s.fix}),e.jsx(p,{variant:"ghost",size:"sm",onClick:()=>s.fix&&i(s.fix),className:"h-5 w-5 p-0",children:e.jsx(S,{className:"w-3 h-3"})})]}),s.fixable&&s.status!=="ok"&&e.jsxs(p,{size:"sm",onClick:()=>t.mutate(s.id),disabled:t.isPending,className:"h-7 px-3 text-xs",children:[e.jsx(v,{className:"w-3 h-3 mr-1"}),"Apply Fix"]})]})]})})]})}):e.jsxs("div",{className:l("group flex items-center gap-3 px-3 py-2 rounded-lg","hover:bg-muted/50 transition-colors duration-150","border border-transparent hover:border-border/50"),children:[e.jsxs("div",{className:"relative flex items-center justify-center w-4 h-4",children:[e.jsx("div",{className:l("w-2 h-2 rounded-full",r.dot)}),s.status!=="ok"&&e.jsx("div",{className:l("absolute w-2 h-2 rounded-full animate-ping opacity-75",r.dot)})]}),e.jsx("span",{className:"flex-1 text-sm font-medium truncate",children:s.name}),e.jsxs("span",{className:l("font-mono text-xs font-semibold",r.labelColor),children:["[",r.label,"]"]}),s.fixable&&s.status!=="ok"&&e.jsxs(p,{size:"sm",variant:"ghost",onClick:()=>t.mutate(s.id),disabled:t.isPending,className:"h-6 px-2 text-xs opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx(v,{className:"w-3 h-3 mr-1"}),"Fix"]})]})}const Z={Monitor:I,Settings:F,Users:$,Shield:O,Zap:P};function V({group:s,defaultOpen:t=!0}){const[r,o]=j.useState(t),n=Z[s.icon]||I,d=s.checks.filter(m=>m.status==="ok").length,i=s.checks.length,a=s.checks.some(m=>m.status==="error"),c=s.checks.some(m=>m.status==="warning"),f=Math.round(d/i*100),x=a?"text-red-500":c?"text-yellow-500":"text-green-500",u=a?"bg-red-500":c?"bg-yellow-500":"bg-green-500";return e.jsx(w,{open:r,onOpenChange:o,children:e.jsxs("div",{className:l("rounded-lg border transition-all duration-200",a?"border-red-500/30":c?"border-yellow-500/30":"border-border"),children:[e.jsx(y,{asChild:!0,children:e.jsxs("button",{className:l("w-full flex items-center gap-3 p-3 text-left rounded-lg","hover:bg-muted/50 transition-colors duration-150",r&&"rounded-b-none border-b border-border/50"),children:[e.jsx("div",{className:l("p-1.5 rounded-md",a?"bg-red-500/10 text-red-500":c?"bg-yellow-500/10 text-yellow-500":"bg-muted text-muted-foreground"),children:e.jsx(n,{className:"w-4 h-4"})}),e.jsx("span",{className:"flex-1 text-sm font-semibold",children:s.name}),!r&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("div",{className:"w-16 h-1.5 rounded-full bg-muted overflow-hidden",children:e.jsx("div",{className:l("h-full transition-all duration-500",u),style:{width:`${f}%`}})})}),e.jsxs("span",{className:l("font-mono text-xs font-semibold",x),children:[d,"/",i]}),e.jsx(H,{className:l("w-4 h-4 text-muted-foreground transition-transform duration-200",r&&"rotate-180")})]})}),e.jsx(k,{children:e.jsx("div",{className:"p-2 space-y-0.5",children:s.checks.map(m=>e.jsx(U,{check:m},m.id))})})]})})}function Y(s){return s.errors>0?"error":s.warnings>0?"warning":"ok"}function J(s){const t=Math.floor((Date.now()-s)/1e3);if(t<5)return"just now";if(t<60)return`${t}s ago`;const r=Math.floor(t/60);return r<60?`${r}m ago`:`${Math.floor(r/60)}h ago`}function X(s){return[...s].sort((t,r)=>{const o=t.checks.filter(a=>a.status==="error").length,n=r.checks.filter(a=>a.status==="error").length,d=t.checks.filter(a=>a.status==="warning").length,i=r.checks.filter(a=>a.status==="warning").length;return o!==n?n-o:i-d})}function _(){return e.jsxs("div",{className:"font-mono text-sm text-muted-foreground flex items-center gap-2",children:[e.jsx("span",{className:"text-green-500",children:"$"}),e.jsx("span",{children:"ccs doctor"})]})}function ee(){return e.jsxs("div",{className:"p-6 max-w-6xl mx-auto space-y-6",children:[e.jsx("div",{className:"rounded-xl border bg-gradient-to-br from-background to-muted/20 p-6",children:e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsx(h,{className:"w-[120px] h-[120px] rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx(h,{className:"h-5 w-48"}),e.jsx(h,{className:"h-8 w-64"}),e.jsx(h,{className:"h-4 w-32"})]})]})}),e.jsx(h,{className:"h-16 w-full rounded-lg"}),e.jsx("div",{className:"space-y-3",children:[1,2,3,4].map(s=>e.jsx(h,{className:"h-20 rounded-lg"},s))})]})}function ce(){const{data:s,isLoading:t,refetch:r,dataUpdatedAt:o}=q(),n=o,[d,i]=j.useState(0);j.useEffect(()=>{const u=setInterval(()=>i(m=>m+1),1e3);return()=>clearInterval(u)},[]);const a=()=>{navigator.clipboard.writeText("ccs doctor"),g.success("Copied to clipboard")},c=()=>{r(),g.info("Refreshing health checks...")};if(t&&!s)return e.jsx(ee,{});const f=s?Y(s.summary):"ok",x=s?.groups?X(s.groups):[];return e.jsxs("div",{className:"p-6 max-w-6xl mx-auto space-y-6",children:[e.jsxs("div",{className:l("relative overflow-hidden rounded-xl border p-6","bg-gradient-to-br from-background via-background to-muted/30"),children:[e.jsx("div",{className:"absolute inset-0 opacity-[0.02] pointer-events-none",style:{backgroundImage:"repeating-linear-gradient(0deg, transparent, transparent 2px, currentColor 2px, currentColor 3px)"}}),e.jsx("div",{className:"absolute inset-0 opacity-[0.03] pointer-events-none",children:e.jsx("div",{className:"absolute inset-0",style:{backgroundImage:"radial-gradient(circle at 1px 1px, currentColor 1px, transparent 0)",backgroundSize:"24px 24px"}})}),e.jsxs("div",{className:"relative flex flex-col md:flex-row items-start md:items-center gap-6",children:[s&&e.jsx("div",{className:"shrink-0",children:e.jsx(G,{passed:s.summary.passed,total:s.summary.total-s.summary.info,status:f,size:"md"})}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx(_,{}),e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx("h1",{className:"text-2xl font-bold font-mono tracking-tight",children:"System Health"}),s?.version&&e.jsxs(z,{variant:"outline",className:"font-mono text-xs bg-muted/50",children:["build ",s.version]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(T,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:"Last scan:"}),e.jsx("span",{className:"font-mono",children:n?J(n):"--"}),e.jsx("span",{className:"text-muted-foreground",children:"|"}),e.jsx("span",{className:"text-muted-foreground",children:"Auto-refresh:"}),e.jsx("span",{className:"font-mono text-green-500",children:"30s"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs(p,{variant:"outline",size:"sm",onClick:a,className:"gap-2 font-mono text-xs",children:[e.jsx(C,{className:"w-3 h-3"}),"ccs doctor",e.jsx(S,{className:"w-3 h-3 opacity-50"})]}),e.jsxs(p,{variant:"outline",size:"sm",onClick:c,disabled:t,className:"gap-2",children:[e.jsx(A,{className:l("w-4 h-4",t&&"animate-spin")}),e.jsx("span",{className:"hidden sm:inline",children:"Refresh"}),e.jsx("kbd",{className:"hidden md:inline-flex h-5 items-center gap-1 rounded border bg-muted px-1.5 font-mono text-[10px] font-medium text-muted-foreground",children:"R"})]})]})]})]}),s&&e.jsx("div",{className:"rounded-lg border bg-card p-4",children:e.jsx(L,{total:s.summary.total,passed:s.summary.passed,warnings:s.summary.warnings,errors:s.summary.errors,info:s.summary.info})}),x.length>0&&e.jsx("div",{className:"space-y-3",children:x.map((u,m)=>e.jsx(V,{group:u,defaultOpen:m<2||u.checks.some(N=>N.status==="error"||N.status==="warning")},u.id))}),e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground border-t pt-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("span",{children:["Version ",e.jsx("span",{className:"font-mono",children:s?.version??"--"})]}),e.jsxs("span",{children:["Platform"," ",e.jsx("span",{className:"font-mono",children:typeof navigator<"u"?navigator.platform:"linux"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-green-500 animate-pulse"}),e.jsx("span",{children:"Live monitoring active"})]})]})]})}export{ce as HealthPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./radix-ui-qEZD5MMp.js";import{r as a}from"./react-vendor-CNOkPC89.js";import{aP as q,aR as W,b as T,m as Y,L,X as D,Y as M,Z as K,_ as $,$ as I,I as F}from"./index-usFFopdS.js";import{S as X}from"./switch-BaBtJszd.js";import{R as z,a1 as J,q as Z,a3 as Q,I as ee,Y as se}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 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(J,{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(Z,{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(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(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(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(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-qEZD5MMp.js";import{r as d}from"./react-vendor-CNOkPC89.js";import{aY as ye,aZ as je,ae as L,I as T,X as ve,Y as Ne,Z as ke,_ as Ce,$ as z,b as Q,a_ as Pe,a$ as Se,b0 as we,aP as O,aR as U,m as Ie}from"./index-C-4s51AH.js";import{S as _}from"./switch-Dw_-BGlW.js";import{C as R}from"./default-ports-1QQSffYX.js";import{aC as ee,R as V,e as Ee,q as te,W as Te,a1 as Le,aD as Ae,aE as _e,T as X,aF as Re}from"./icons-DGASzt3M.js";import{P as De}from"./proxy-status-widget-B5Rk4t5g.js";import{t as Z}from"./notifications-B2HqRBj7.js";import"./tanstack-De4wvi8X.js";import"./utils-CzKF5WmX.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-BuoGLwhK.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 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(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: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(Q,{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 J="ccs_debug_mode",$e=["kiro","ghcp"];function Qe(){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(J)==="true"}catch{return!1}}),re=r=>{se(r);try{localStorage.setItem(J,String(r))}catch{}},[y,D]=d.useState("plus"),[ae,oe]=d.useState(!1),B=Se(),{data:ne}=we(),G=ne?.running??!1,M=d.useCallback(async()=>{try{const r=await L.cliproxyServer.getBackend();D(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=>$e.includes(be.provider));oe(c)}catch(r){console.error("[Proxy] Failed to check variants:",r)}},[]),Y=r=>{const c=y;D(r),B.mutate({backend:r},{onError:()=>{D(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(),$=u??le,F=N??ce,H=k??de,W=P??ie,q=l??me,xe=()=>{const r=u??$;r!==t.remote.host&&a({remote:{...j,host:r}}),v(null)},ue=()=>{const r=(N??F).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){Z.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??W;r!==t.remote.management_key&&a({remote:{...j,management_key:r||void 0}}),S(null)},ge=()=>{const r=(l??q).trim(),c=r===""?R:Number(r);if(!Number.isInteger(c)||c<1||c>65535){Z.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:$,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 ${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(De,{})]}),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:()=>Y("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:()=>Y("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(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:$,displayPort:F,displayAuthToken:H,displayManagementKey:W,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:q,setEditedLocalPort:i,onSaveLocalPort:ge,onSaveConfig:a})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(Q,{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{Qe as default};
|
|
1
|
+
import{j as e}from"./radix-ui-qEZD5MMp.js";import{r as d}from"./react-vendor-CNOkPC89.js";import{aY as ye,aZ as je,ae as L,I as T,X as ve,Y as Ne,Z as ke,_ as Ce,$ as z,b as Q,a_ as Pe,a$ as Se,b0 as we,aP as O,aR as U,m as Ie}from"./index-usFFopdS.js";import{S as _}from"./switch-BaBtJszd.js";import{C as R}from"./default-ports-1QQSffYX.js";import{aC as ee,R as V,e as Ee,q as te,W as Te,a1 as Le,aD as Ae,aE as _e,T as X,aF as Re}from"./icons-DGASzt3M.js";import{P as De}from"./proxy-status-widget-BoxaWU8G.js";import{t as Z}from"./notifications-B2HqRBj7.js";import"./tanstack-De4wvi8X.js";import"./utils-CzKF5WmX.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-DL7XlASm.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 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(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: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(Q,{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 J="ccs_debug_mode",$e=["kiro","ghcp"];function Qe(){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(J)==="true"}catch{return!1}}),re=r=>{se(r);try{localStorage.setItem(J,String(r))}catch{}},[y,D]=d.useState("plus"),[ae,oe]=d.useState(!1),B=Se(),{data:ne}=we(),G=ne?.running??!1,M=d.useCallback(async()=>{try{const r=await L.cliproxyServer.getBackend();D(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=>$e.includes(be.provider));oe(c)}catch(r){console.error("[Proxy] Failed to check variants:",r)}},[]),Y=r=>{const c=y;D(r),B.mutate({backend:r},{onError:()=>{D(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(),$=u??le,F=N??ce,H=k??de,W=P??ie,q=l??me,xe=()=>{const r=u??$;r!==t.remote.host&&a({remote:{...j,host:r}}),v(null)},ue=()=>{const r=(N??F).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){Z.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??W;r!==t.remote.management_key&&a({remote:{...j,management_key:r||void 0}}),S(null)},ge=()=>{const r=(l??q).trim(),c=r===""?R:Number(r);if(!Number.isInteger(c)||c<1||c>65535){Z.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:$,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 ${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(De,{})]}),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:()=>Y("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:()=>Y("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(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:$,displayPort:F,displayAuthToken:H,displayManagementKey:W,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:q,setEditedLocalPort:i,onSaveLocalPort:ge,onSaveConfig:a})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(Q,{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{Qe as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-qEZD5MMp.js";import{r as i}from"./react-vendor-CNOkPC89.js";import{aY as T,aZ as $,I as F,a_ as U,aP as _,aR as B,m as z,b as O}from"./index-C-4s51AH.js";import{S as K}from"./switch-Dw_-BGlW.js";import{y as Y,j as q,V as D,Y as V,m as Z,R as y,a1 as J,q as X,aB as Q}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";function ee(){const{state:s}=T(),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 R({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",E=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",I=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 ${I}`,children:[p?e.jsx(D,{className:"w-4 h-4"}):e.jsx(V,{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 ${E}`,children:r}),e.jsxs("a",{href:w,target:"_blank",rel:"noopener noreferrer",className:"hover:underline inline-flex items-center gap-1",children:[e.jsx(Z,{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),[E,I]=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,A=()=>{const c=s?.providers||{},b=c.gemini?.enabled??!1;t({enabled:!b||G||L,providers:{...c,gemini:{...c.gemini,enabled:!b}}})},H=()=>{const c=s?.providers||{},b=c.grok?.enabled??!1;t({enabled:N||!b||L,providers:{...c,grok:{...c.grok,enabled:!b}}})},P=()=>{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(J,{className:"h-4 w-4"}),e.jsx(B,{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(X,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:"Saved"})]})]}),e.jsx(z,{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(R,{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:A,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(R,{name:"opencode",label:"OpenCode (web search via Zen)",badge:"FREE",badgeColor:"green",enabled:L,installed:a?.opencodeCli?.installed??!1,statusLoading:l,saving:o,onToggle:P,modelInput:u,setModelInput:S,onModelBlur:w,modelSaved:g,modelPlaceholder:"opencode/grok-code",showHint:E,setShowHint:I,installCmd:"curl -fsSL https://opencode.ai/install | bash",docsUrl:"https://github.com/sst/opencode",hintColor:"purple"}),e.jsx(R,{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:H,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};
|
|
1
|
+
import{j as e}from"./radix-ui-qEZD5MMp.js";import{r as i}from"./react-vendor-CNOkPC89.js";import{aY as T,aZ as $,I as F,a_ as U,aP as _,aR as B,m as z,b as O}from"./index-usFFopdS.js";import{S as K}from"./switch-BaBtJszd.js";import{y as Y,j as q,V as D,Y as V,m as Z,R as y,a1 as J,q as X,aB as Q}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";function ee(){const{state:s}=T(),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 R({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",E=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",I=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 ${I}`,children:[p?e.jsx(D,{className:"w-4 h-4"}):e.jsx(V,{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 ${E}`,children:r}),e.jsxs("a",{href:w,target:"_blank",rel:"noopener noreferrer",className:"hover:underline inline-flex items-center gap-1",children:[e.jsx(Z,{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),[E,I]=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,A=()=>{const c=s?.providers||{},b=c.gemini?.enabled??!1;t({enabled:!b||G||L,providers:{...c,gemini:{...c.gemini,enabled:!b}}})},H=()=>{const c=s?.providers||{},b=c.grok?.enabled??!1;t({enabled:N||!b||L,providers:{...c,grok:{...c.grok,enabled:!b}}})},P=()=>{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(J,{className:"h-4 w-4"}),e.jsx(B,{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(X,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:"Saved"})]})]}),e.jsx(z,{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(R,{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:A,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(R,{name:"opencode",label:"OpenCode (web search via Zen)",badge:"FREE",badgeColor:"green",enabled:L,installed:a?.opencodeCli?.installed??!1,statusLoading:l,saving:o,onToggle:P,modelInput:u,setModelInput:S,onModelBlur:w,modelSaved:g,modelPlaceholder:"opencode/grok-code",showHint:E,setShowHint:I,installCmd:"curl -fsSL https://opencode.ai/install | bash",docsUrl:"https://github.com/sst/opencode",hintColor:"purple"}),e.jsx(R,{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:H,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};
|