@kaitranntt/ccs 7.77.1-dev.7 → 7.77.1-dev.9
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/README.md +2 -1
- package/dist/cliproxy/ai-providers/codex-plan-compatibility.d.ts.map +1 -1
- package/dist/cliproxy/ai-providers/codex-plan-compatibility.js +2 -2
- package/dist/cliproxy/ai-providers/codex-plan-compatibility.js.map +1 -1
- package/dist/cliproxy/ai-providers/codex-reasoning-proxy.d.ts +8 -2
- package/dist/cliproxy/ai-providers/codex-reasoning-proxy.d.ts.map +1 -1
- package/dist/cliproxy/ai-providers/codex-reasoning-proxy.js +82 -33
- package/dist/cliproxy/ai-providers/codex-reasoning-proxy.js.map +1 -1
- package/dist/cliproxy/ai-providers/model-id-normalizer.d.ts +1 -1
- package/dist/cliproxy/ai-providers/model-id-normalizer.d.ts.map +1 -1
- package/dist/cliproxy/ai-providers/model-id-normalizer.js +28 -11
- package/dist/cliproxy/ai-providers/model-id-normalizer.js.map +1 -1
- package/dist/cliproxy/config/thinking-config.d.ts.map +1 -1
- package/dist/cliproxy/config/thinking-config.js +9 -8
- package/dist/cliproxy/config/thinking-config.js.map +1 -1
- package/dist/cliproxy/model-catalog.d.ts +2 -0
- package/dist/cliproxy/model-catalog.d.ts.map +1 -1
- package/dist/cliproxy/model-catalog.js +2 -0
- package/dist/cliproxy/model-catalog.js.map +1 -1
- package/dist/cliproxy/provider-capabilities.js +1 -1
- package/dist/cliproxy/provider-capabilities.js.map +1 -1
- package/dist/commands/cliproxy/variant-subcommand.d.ts.map +1 -1
- package/dist/commands/cliproxy/variant-subcommand.js +44 -12
- package/dist/commands/cliproxy/variant-subcommand.js.map +1 -1
- package/dist/commands/command-catalog.js +2 -2
- package/dist/commands/command-catalog.js.map +1 -1
- package/dist/commands/copilot-command.js +3 -1
- package/dist/commands/copilot-command.js.map +1 -1
- package/dist/commands/help-command.js +1 -1
- package/dist/commands/help-command.js.map +1 -1
- package/dist/config/loader/yaml-serializer.d.ts.map +1 -1
- package/dist/config/loader/yaml-serializer.js +4 -3
- package/dist/config/loader/yaml-serializer.js.map +1 -1
- package/dist/config/schemas/copilot-cursor.d.ts +2 -2
- package/dist/config/schemas/copilot-cursor.js +1 -1
- package/dist/config/schemas/unified-config.d.ts +1 -1
- package/dist/config/schemas/unified-config.d.ts.map +1 -1
- package/dist/ui/assets/{accounts-BWciW_nb.js → accounts-DkID6f81.js} +1 -1
- package/dist/ui/assets/{alert-dialog-C-oyVuIB.js → alert-dialog-BM9gIsRp.js} +1 -1
- package/dist/ui/assets/{api-CE6KShct.js → api-0YJdilQb.js} +1 -1
- package/dist/ui/assets/{auth-section-Batq2rqI.js → auth-section-C1ljCo7W.js} +1 -1
- package/dist/ui/assets/{backups-section-C0dn7Ket.js → backups-section-C-iLf1kg.js} +1 -1
- package/dist/ui/assets/{channels-CVJfKJyT.js → channels-DDSqllsQ.js} +1 -1
- package/dist/ui/assets/{checkbox-BWXzxH0e.js → checkbox-5R1YTubE.js} +1 -1
- package/dist/ui/assets/{claude-extension-DH0ltdyv.js → claude-extension-CEGefl3-.js} +1 -1
- package/dist/ui/assets/cliproxy-R4kPUeL-.js +3 -0
- package/dist/ui/assets/{cliproxy-ai-providers-QZCa2DN7.js → cliproxy-ai-providers-DVF3FnXM.js} +1 -1
- package/dist/ui/assets/{cliproxy-control-panel-BT1a2KtK.js → cliproxy-control-panel-CIsKyGK6.js} +1 -1
- package/dist/ui/assets/{codex-DVC-dMzi.js → codex-BiEEUC4Y.js} +1 -1
- package/dist/ui/assets/{confirm-dialog-7py4oJEQ.js → confirm-dialog-BhJV4F_d.js} +1 -1
- package/dist/ui/assets/{copilot-DOe7yu8W.js → copilot-DgRLuQfV.js} +2 -2
- package/dist/ui/assets/{cursor-TaT3xM-m.js → cursor-BuOjfajj.js} +1 -1
- package/dist/ui/assets/{droid-ClF_i2qJ.js → droid-BPiviAW2.js} +1 -1
- package/dist/ui/assets/{globalenv-section-CLjnaW56.js → globalenv-section-DAqbiNI1.js} +1 -1
- package/dist/ui/assets/{health-BUHx35_z.js → health-B_CfF7J0.js} +1 -1
- package/dist/ui/assets/{icons-Ce9So20E.js → icons-DIVjDO-z.js} +1 -1
- package/dist/ui/assets/{index-DCdHT0L4.js → index-BEGD-4HR.js} +1 -1
- package/dist/ui/assets/{index-BIF0Wvld.js → index-BJl0cazY.js} +20 -20
- package/dist/ui/assets/{index-D8l3dEVy.js → index-Bc-AbZRU.js} +1 -1
- package/dist/ui/assets/{index-Cv_ifcCd.js → index-BqR6NZDE.js} +1 -1
- package/dist/ui/assets/{index-BIgntzT5.js → index-Cj4mWFVK.js} +1 -1
- package/dist/ui/assets/{index-DZ9DNmxz.js → index-CzKdWNe5.js} +1 -1
- package/dist/ui/assets/{index-Czt4jG_U.js → index-LJitUhfE.js} +1 -1
- package/dist/ui/assets/{logs-4FBxeZlN.js → logs-Lqv-I3_T.js} +1 -1
- package/dist/ui/assets/{masked-input-BUPGfXYs.js → masked-input-CgCDYXYf.js} +1 -1
- package/dist/ui/assets/{proxy-status-widget-CEVsYzZc.js → proxy-status-widget-Df-4cfdm.js} +1 -1
- package/dist/ui/assets/{raw-json-settings-editor-panel-Bx9NZXKo.js → raw-json-settings-editor-panel-BpXdUisD.js} +1 -1
- package/dist/ui/assets/{searchable-select-CRBVpRX9.js → searchable-select-DCOfw3f0.js} +1 -1
- package/dist/ui/assets/{separator-oLpQ8QTJ.js → separator-Ct6a34bG.js} +1 -1
- package/dist/ui/assets/{shared-CDOZvFvu.js → shared-D-JFc_Cw.js} +1 -1
- package/dist/ui/assets/{table-CvB4g1aV.js → table-DsU2UX-e.js} +1 -1
- package/dist/ui/assets/{updates-FB-3z9nq.js → updates-D-0gOqSU.js} +1 -1
- package/dist/ui/index.html +2 -2
- package/package.json +1 -1
- package/dist/ui/assets/cliproxy-5ZQ4DdWj.js +0 -3
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-nu4wz29m.js";import{bf as N,bg as ke,a as S,B as P,d as b,V as oe,n as V,L,aI as Z,I as de,r as Fe,s as Te,t as Me,v as Le,w as ee,x as ge,bh as Re,S as y,bi as Ae,bj as Ee,bk as Oe,Q as _e,R as qe,U as te,bl as De,c as ie}from"./index-BIF0Wvld.js";import{r as w}from"./react-vendor-Bjx91N7w.js";import{a as Ie,u as D,b as R}from"./tanstack-bhJxV1h8.js";import{C as Ue}from"./confirm-dialog-7py4oJEQ.js";import{R as fe,L as je,au as Ke,aa as Qe,Z as me,_ as Je,T as ve,ax as $e,b as ze,ae as Be,aF as Ge,aP as ue,K as He,Y as We,aQ as Ve,x as we,I as Ne}from"./icons-Ce9So20E.js";import{S as ne}from"./separator-oLpQ8QTJ.js";import{S as Ye}from"./searchable-select-CRBVpRX9.js";import{t as I}from"./notifications-B4_o8bcr.js";import"./utils-CzKF5WmX.js";import"./form-utils-CuHzLhJZ.js";import"./code-highlight-D4E79GKQ.js";import"./alert-dialog-C-oyVuIB.js";async function Xe(){const t=await fetch(N("/copilot/status"));if(!t.ok)throw new Error("Failed to fetch copilot status");return t.json()}async function Ze(){const t=await fetch(N("/copilot/config"));if(!t.ok)throw new Error("Failed to fetch copilot config");return t.json()}async function et(){const t=await fetch(N("/copilot/models"));if(!t.ok)throw new Error("Failed to fetch copilot models");return t.json()}async function tt(){const t=await fetch(N("/copilot/settings/raw"));if(!t.ok)throw new Error("Failed to fetch copilot raw settings");return t.json()}async function st(t){const s=await fetch(N("/copilot/config"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!s.ok)throw new Error("Failed to update copilot config");return s.json()}async function at(t){const s=await fetch(N("/copilot/settings/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(s.status===409)throw new ke("Copilot raw settings changed externally");if(!s.ok)throw new Error("Failed to save copilot raw settings");return s.json()}async function it(){const t=await fetch(N("/copilot/auth/start"),{method:"POST"});if(!t.ok)throw new Error("Failed to start auth");return t.json()}async function nt(){const t=await fetch(N("/copilot/daemon/start"),{method:"POST"});if(!t.ok)throw new Error("Failed to start daemon");return t.json()}async function ot(){const t=await fetch(N("/copilot/daemon/stop"),{method:"POST"});if(!t.ok)throw new Error("Failed to stop daemon");return t.json()}async function lt(){const t=await fetch(N("/copilot/info"));if(!t.ok)throw new Error("Failed to fetch copilot info");return t.json()}async function rt(t){const s=await fetch(N("/copilot/install"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t?{version:t}:{})});if(!s.ok)throw new Error("Failed to install copilot-api");return s.json()}function be(){const t=Ie(),s=D({queryKey:["copilot-status"],queryFn:Xe,refetchInterval:5e3}),o=D({queryKey:["copilot-config"],queryFn:Ze}),d=D({queryKey:["copilot-models"],queryFn:et}),r=D({queryKey:["copilot-raw-settings"],queryFn:tt}),i=D({queryKey:["copilot-info"],queryFn:lt}),c=R({mutationFn:st,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]}),t.invalidateQueries({queryKey:["copilot-config"]}),t.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),a=R({mutationFn:at,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]}),t.invalidateQueries({queryKey:["copilot-config"]}),t.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),x=R({mutationFn:it,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]})}}),h=R({mutationFn:nt,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]})}}),f=R({mutationFn:ot,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]})}}),u=R({mutationFn:rt,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]}),t.invalidateQueries({queryKey:["copilot-info"]})}});return w.useMemo(()=>({status:s.data,statusLoading:s.isLoading,statusError:s.error,refetchStatus:s.refetch,config:o.data,configLoading:o.isLoading,models:d.data?.models??[],currentModel:d.data?.current,modelsLoading:d.isLoading,rawSettings:r.data,rawSettingsLoading:r.isLoading,refetchRawSettings:r.refetch,updateConfig:c.mutate,updateConfigAsync:c.mutateAsync,isUpdating:c.isPending,saveRawSettings:a.mutate,saveRawSettingsAsync:a.mutateAsync,isSavingRawSettings:a.isPending,startAuth:x.mutate,startAuthAsync:x.mutateAsync,isAuthenticating:x.isPending,authResult:x.data,startDaemon:h.mutate,isStartingDaemon:h.isPending,stopDaemon:f.mutate,isStoppingDaemon:f.isPending,info:i.data,infoLoading:i.isLoading,refetchInfo:i.refetch,install:u.mutate,installAsync:u.mutateAsync,isInstalling:u.isPending}),[s.data,s.isLoading,s.error,s.refetch,o.data,o.isLoading,d.data,d.isLoading,r.data,r.isLoading,r.refetch,c.mutate,c.mutateAsync,c.isPending,a.mutate,a.mutateAsync,a.isPending,x.mutate,x.mutateAsync,x.isPending,x.data,h.mutate,h.isPending,f.mutate,f.isPending,i.data,i.isLoading,i.refetch,u.mutate,u.mutateAsync,u.isPending])}function ct({rawSettings:t,rawSettingsLoading:s,isUpdating:o,isSavingRawSettings:d,hasChanges:r,isRawJsonValid:i,onRefresh:c,onSave:a}){const{t:x}=S();return 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:x("copilotConfigForm.copilotConfiguration")}),t&&e.jsx(P,{variant:"outline",className:"text-xs",children:"copilot.settings.json"})]}),t&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified: ",t.exists?new Date(t.mtime).toLocaleString():"Never saved"]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(b,{variant:"ghost",size:"sm",onClick:c,disabled:s,children:e.jsx(fe,{className:`w-4 h-4 ${s?"animate-spin":""}`})}),e.jsx(b,{size:"sm",onClick:a,disabled:o||d||!r||!i,children:o||d?e.jsxs(e.Fragment,{children:[e.jsx(je,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ke,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}const dt=[{name:"GPT-4.1 (Free)",description:"Free tier - no premium usage",default:"gpt-4.1",opus:"gpt-4.1",sonnet:"gpt-4.1",haiku:"gpt-4.1"},{name:"GPT-5 Mini (Free)",description:"Free tier - lightweight model",default:"gpt-5-mini",opus:"gpt-5-mini",sonnet:"gpt-5-mini",haiku:"gpt-5-mini"}],mt=[{name:"Claude Opus 4.5",description:"Pro+ (3x) - Most capable reasoning",default:"claude-opus-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"},{name:"Claude Sonnet 4.5",description:"Pro+ (1x) - Balanced performance",default:"claude-sonnet-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"},{name:"GPT-5.2",description:"Pro+ (1x) - Latest OpenAI (Preview)",default:"gpt-5.2",opus:"gpt-5.2",sonnet:"gpt-5.1",haiku:"gpt-5-mini"},{name:"GPT-5.1 Codex Max",description:"Pro+ (1x) - Best for coding",default:"gpt-5.1-codex-max",opus:"gpt-5.1-codex-max",sonnet:"gpt-5.1-codex",haiku:"gpt-5.1-codex-mini"},{name:"Gemini 2.5 Pro",description:"Pro+ (1x) - Google latest",default:"gemini-2.5-pro",opus:"gemini-2.5-pro",sonnet:"gemini-2.5-pro",haiku:"gemini-3-flash"}];function xe(t){switch(t){case"free":return"bg-green-100 text-green-700 border-green-200";case"pro":return"bg-blue-100 text-blue-700 border-blue-200";case"pro+":return"bg-purple-100 text-purple-700 border-purple-200";case"business":return"bg-orange-100 text-orange-700 border-orange-200";case"enterprise":return"bg-red-100 text-red-700 border-red-200";default:return"bg-muted text-muted-foreground"}}function ut(t){return t==null?null:t===0?"Free":t<1?`${t}x`:t===1?"1x":`${t}x`}function G({label:t,description:s,value:o,onChange:d,models:r,disabled:i}){const{t:c}=S();return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",children:t}),s&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:s})]}),e.jsx(Ye,{value:o||void 0,onChange:d,disabled:i,placeholder:c("componentModelSelector.selectModel"),searchPlaceholder:c("searchableSelect.searchModels"),emptyText:c("searchableSelect.noResults"),triggerClassName:"h-9",groups:[{key:"models",label:c("componentModelSelector.availableModelsCount",{count:r.length})}],options:r.map(a=>({value:a.id,groupKey:"models",searchText:`${a.name||a.id} ${a.id}`,keywords:[a.minPlan??"",a.preview?"preview":""],triggerContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:a.id}),a.minPlan&&e.jsx(P,{variant:"outline",className:`text-[9px] px-1 py-0 h-4 ${xe(a.minPlan)}`,children:a.minPlan})]}),itemContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:a.name||a.id}),a.minPlan&&e.jsx(P,{variant:"outline",className:`text-[9px] px-1 py-0 h-4 ${xe(a.minPlan)}`,children:a.minPlan}),a.multiplier!==void 0&&e.jsx("span",{className:"text-[9px] text-muted-foreground",children:ut(a.multiplier)}),a.preview&&e.jsx(P,{variant:"secondary",className:"text-[9px] px-1 py-0 h-4",children:c("componentModelSelector.preview")})]})}))})]})}function se(t){if(t>=1e6){const s=t/1e6;return s%1===0?`${s}M`:`${s.toFixed(1)}M`}if(t>=1e3){const s=t/1e3;return s%1===0?`${s}K`:`${s.toFixed(1)}K`}return`${t}`}function xt(t){if(!t?.limits)return null;const s=[];return t.limits.maxPromptTokens&&s.push(`prompt ${se(t.limits.maxPromptTokens)}`),t.limits.maxContextWindowTokens&&s.push(`context ${se(t.limits.maxContextWindowTokens)}`),t.limits.maxOutputTokens&&s.push(`output ${se(t.limits.maxOutputTokens)}`),s.length>0?s.join(" | "):null}function pt({currentModel:t,opusModel:s,sonnetModel:o,haikuModel:d,models:r,modelsLoading:i,onApplyPreset:c,onUpdateModel:a,onUpdateOpusModel:x,onUpdateSonnetModel:h,onUpdateHaikuModel:f}){const{t:u}=S(),n=[{label:"Default",id:t},{label:"Opus",id:s||t},{label:"Sonnet",id:o||t},{label:"Haiku",id:d||t}].map(({label:l,id:p})=>{const C=r.find(F=>F.id===p),k=xt(C);return k?{label:l,id:p,limits:k}:null}).filter(l=>l!==null);return e.jsx(oe,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(V,{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(Qe,{className:"w-4 h-4"}),u("providerEditor.presets")]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:u("copilotConfigForm.modelMapping")}),e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(P,{variant:"outline",className:"text-[10px] bg-green-100 text-green-700 border-green-200",children:"Free Tier"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:u("copilotConfigForm.noPremiumUsage")})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:dt.map(l=>e.jsxs(b,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>c(l),title:l.description,children:[e.jsx(me,{className:"w-3 h-3 text-green-600"}),l.name]},l.name))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(P,{variant:"outline",className:"text-[10px] bg-blue-100 text-blue-700 border-blue-200",children:"Pro+ Required"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Uses premium request quota"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:mt.map(l=>e.jsxs(b,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>c(l),title:l.description,children:[e.jsx(me,{className:"w-3 h-3"}),l.name]},l.name))})]})]}),e.jsx(ne,{}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-2",children:u("copilotConfigForm.modelMapping")}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"Configure which models to use for each tier"}),e.jsxs("div",{className:"mb-4 rounded-lg border border-amber-500/30 bg-amber-500/10 p-3 text-xs text-amber-900 dark:text-amber-200",children:[e.jsx("p",{className:"font-medium",children:u("copilotConfigForm.githubCopilotControls")}),e.jsx("p",{className:"mt-1",children:"CCS can switch Copilot models, but it cannot increase the provider's max prompt or context window."}),n.length>0?e.jsx("div",{className:"mt-2 space-y-1 text-[11px] font-mono",children:n.map(l=>e.jsxs("p",{children:[l.label,": ",l.id," (",l.limits,")"]},`${l.label}-${l.id}`))}):e.jsx("p",{className:"mt-2 text-[11px] font-mono",children:"Start the daemon to inspect live model limits from GitHub Copilot metadata."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(G,{label:"Default Model",description:"Used when no specific tier is requested",value:t,onChange:a,models:r,disabled:i}),e.jsx(G,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:s||t,onChange:x,models:r,disabled:i}),e.jsx(G,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:o||t,onChange:h,models:r,disabled:i}),e.jsx(G,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:d||t,onChange:f,models:r,disabled:i})]})]})]})})})}function ht({enabled:t,autoStart:s,port:o,accountType:d,rateLimit:r,waitOnLimit:i,onUpdateEnabled:c,onUpdateAutoStart:a,onUpdatePort:x,onUpdateAccountType:h,onUpdateRateLimit:f,onUpdateWaitOnLimit:u}){const{t:n}=S();return e.jsx(oe,{value:"settings",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(V,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(L,{htmlFor:"enabled",className:"text-sm font-medium",children:n("copilotSettings.enableCopilot")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n("copilotSettings.enableCopilotDesc")})]}),e.jsx(Z,{id:"enabled",checked:t,onCheckedChange:c})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:n("copilotSettings.basicSettings")}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(L,{htmlFor:"port",className:"text-xs",children:n("copilotPage.port")}),e.jsx(de,{id:"port",type:"number",value:o,onChange:l=>x(parseInt(l.target.value,10)),min:1024,max:65535,className:"max-w-[150px] h-8"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(L,{htmlFor:"account-type",className:"text-xs",children:n("copilotSettings.accountType")}),e.jsxs(Fe,{value:d,onValueChange:h,children:[e.jsx(Te,{id:"account-type",className:"max-w-[150px] h-8",children:e.jsx(Me,{})}),e.jsxs(Le,{children:[e.jsx(ee,{value:"individual",children:n("copilotSettings.accountTypeIndividual")}),e.jsx(ee,{value:"business",children:n("copilotSettings.accountTypeBusiness")}),e.jsx(ee,{value:"enterprise",children:n("copilotSettings.accountTypeEnterprise")})]})]})]})]}),e.jsx(ne,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:n("copilotSettings.rateLimiting")}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(L,{htmlFor:"rate-limit",className:"text-xs",children:n("copilotSettings.rateLimitSeconds")}),e.jsx(de,{id:"rate-limit",type:"number",value:r,onChange:l=>f(l.target.value),placeholder:n("copilotSettings.noLimit"),min:0,className:"max-w-[150px] h-8"})]}),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(L,{htmlFor:"wait-on-limit",className:"text-xs",children:n("copilotSettings.waitOnRateLimit")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:n("copilotSettings.waitOnRateLimitDesc")})]}),e.jsx(Z,{id:"wait-on-limit",checked:i,onCheckedChange:u})]})]}),e.jsx(ne,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:n("copilotSettings.daemonSettings")}),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(L,{htmlFor:"auto-start",className:"text-xs",children:n("copilotSettings.autoStartDaemon")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:n("copilotSettings.autoStartDaemonDesc")})]}),e.jsx(Z,{id:"auto-start",checked:s,onCheckedChange:a})]})]})]})})})}function H({label:t,command:s}){return e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:t}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsx("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:s}),e.jsx(ge,{value:s,size:"icon",className:"h-6 w-6"})]})]})}function gt({rawSettings:t}){const{t:s}=S();return e.jsx(oe,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(V,{className:"h-full",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium flex items-center gap-2 mb-3",children:[e.jsx(Je,{className:"w-4 h-4"}),"Configuration Info"]}),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:s("copilotConfigForm.provider")}),e.jsx("span",{className:"font-mono",children:"GitHub Copilot"})]}),t&&e.jsxs(e.Fragment,{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:s("copilotConfigForm.filePath")}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:t.path}),e.jsx(ge,{value:t.path,size:"icon",className:"h-5 w-5"})]})]}),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:s("copilotConfigForm.status")}),e.jsx(P,{variant:"outline",className:t.exists?"w-fit text-green-600 border-green-200 bg-green-50":"w-fit text-muted-foreground",children:t.exists?"File exists":"Using defaults"})]})]})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:s("copilotConfigForm.quickUsage")}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsx(H,{label:"Run with Copilot",command:"ccs copilot"}),e.jsx(H,{label:"Authenticate",command:"ccs copilot auth"}),e.jsx(H,{label:"Start daemon",command:"ccs copilot --start"}),e.jsx(H,{label:"Stop daemon",command:"ccs copilot --stop"})]})]})]})})})}const ft=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"];function pe(t){const s=t?.env||{};return ft.filter(o=>!s[o]?.trim())}function he(t){if(!t||t.length===0)return[];const s=new Map;return t.forEach(o=>{s.set(o.message,o)}),[...s.values()]}function jt(){const{t}=S(),{config:s,configLoading:o,models:d,modelsLoading:r,rawSettings:i,rawSettingsLoading:c,updateConfigAsync:a,isUpdating:x,saveRawSettingsAsync:h,isSavingRawSettings:f,refetchRawSettings:u}=be(),[n,l]=w.useState({}),[p,C]=w.useState(null),[k,F]=w.useState(!1),U=n.enabled??s?.enabled??!1,K=n.autoStart??s?.auto_start??!1,A=n.port??s?.port??4141,Q=n.accountType??s?.account_type??"individual",E=n.model??s?.model??"claude-sonnet-4-6",O=n.rateLimit??s?.rate_limit?.toString()??"",j=n.waitOnLimit??s?.wait_on_limit??!0,J=n.opusModel??s?.opus_model??"",$=n.sonnetModel??s?.sonnet_model??"",z=n.haikuModel??s?.haiku_model??"",B=(g,v)=>{l(_=>({..._,[g]:v}))},Y=g=>{l(v=>({...v,model:g.default,opusModel:g.opus,sonnetModel:g.sonnet,haikuModel:g.haiku})),I.success(t("toasts.presetApplied",{name:g.name}))},T=w.useMemo(()=>p!==null?p:i?.settings?JSON.stringify(i.settings,null,2):`{
|
|
1
|
+
import{j as e}from"./radix-ui-nu4wz29m.js";import{bf as w,bg as ke,a as S,B as P,d as N,V as le,n as V,L,aI as Z,I as me,r as Fe,s as Te,t as Me,v as Le,w as ee,x as fe,bh as Re,S as y,bi as Ae,bj as Ee,bk as Oe,Q as _e,R as qe,U as te,bl as De,c as ie}from"./index-BJl0cazY.js";import{r as b}from"./react-vendor-Bjx91N7w.js";import{a as Ie,u as D,b as R}from"./tanstack-bhJxV1h8.js";import{C as Ue}from"./confirm-dialog-BhJV4F_d.js";import{R as je,L as ve,au as Ke,aa as Qe,Z as ue,_ as Je,T as ne,ax as $e,c as ze,ae as Be,aF as Ge,aP as xe,K as He,Y as We,aQ as Ve,x as be,I as we}from"./icons-DIVjDO-z.js";import{S as oe}from"./separator-Ct6a34bG.js";import{S as Ye}from"./searchable-select-DCOfw3f0.js";import{t as I}from"./notifications-B4_o8bcr.js";import"./utils-CzKF5WmX.js";import"./form-utils-CuHzLhJZ.js";import"./code-highlight-D4E79GKQ.js";import"./alert-dialog-BM9gIsRp.js";async function Xe(){const t=await fetch(w("/copilot/status"));if(!t.ok)throw new Error("Failed to fetch copilot status");return t.json()}async function Ze(){const t=await fetch(w("/copilot/config"));if(!t.ok)throw new Error("Failed to fetch copilot config");return t.json()}async function et(){const t=await fetch(w("/copilot/models"));if(!t.ok)throw new Error("Failed to fetch copilot models");return t.json()}async function tt(){const t=await fetch(w("/copilot/settings/raw"));if(!t.ok)throw new Error("Failed to fetch copilot raw settings");return t.json()}async function st(t){const s=await fetch(w("/copilot/config"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!s.ok)throw new Error("Failed to update copilot config");return s.json()}async function at(t){const s=await fetch(w("/copilot/settings/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(s.status===409)throw new ke("Copilot raw settings changed externally");if(!s.ok)throw new Error("Failed to save copilot raw settings");return s.json()}async function it(){const t=await fetch(w("/copilot/auth/start"),{method:"POST"});if(!t.ok)throw new Error("Failed to start auth");return t.json()}async function nt(){const t=await fetch(w("/copilot/daemon/start"),{method:"POST"});if(!t.ok)throw new Error("Failed to start daemon");return t.json()}async function ot(){const t=await fetch(w("/copilot/daemon/stop"),{method:"POST"});if(!t.ok)throw new Error("Failed to stop daemon");return t.json()}async function lt(){const t=await fetch(w("/copilot/info"));if(!t.ok)throw new Error("Failed to fetch copilot info");return t.json()}async function rt(t){const s=await fetch(w("/copilot/install"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t?{version:t}:{})});if(!s.ok)throw new Error("Failed to install copilot-api");return s.json()}function Ne(){const t=Ie(),s=D({queryKey:["copilot-status"],queryFn:Xe,refetchInterval:5e3}),o=D({queryKey:["copilot-config"],queryFn:Ze}),d=D({queryKey:["copilot-models"],queryFn:et}),r=D({queryKey:["copilot-raw-settings"],queryFn:tt}),i=D({queryKey:["copilot-info"],queryFn:lt}),c=R({mutationFn:st,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]}),t.invalidateQueries({queryKey:["copilot-config"]}),t.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),a=R({mutationFn:at,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]}),t.invalidateQueries({queryKey:["copilot-config"]}),t.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),x=R({mutationFn:it,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]})}}),h=R({mutationFn:nt,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]})}}),f=R({mutationFn:ot,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]})}}),u=R({mutationFn:rt,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]}),t.invalidateQueries({queryKey:["copilot-info"]})}});return b.useMemo(()=>({status:s.data,statusLoading:s.isLoading,statusError:s.error,refetchStatus:s.refetch,config:o.data,configLoading:o.isLoading,models:d.data?.models??[],currentModel:d.data?.current,modelsLoading:d.isLoading,rawSettings:r.data,rawSettingsLoading:r.isLoading,refetchRawSettings:r.refetch,updateConfig:c.mutate,updateConfigAsync:c.mutateAsync,isUpdating:c.isPending,saveRawSettings:a.mutate,saveRawSettingsAsync:a.mutateAsync,isSavingRawSettings:a.isPending,startAuth:x.mutate,startAuthAsync:x.mutateAsync,isAuthenticating:x.isPending,authResult:x.data,startDaemon:h.mutate,isStartingDaemon:h.isPending,stopDaemon:f.mutate,isStoppingDaemon:f.isPending,info:i.data,infoLoading:i.isLoading,refetchInfo:i.refetch,install:u.mutate,installAsync:u.mutateAsync,isInstalling:u.isPending}),[s.data,s.isLoading,s.error,s.refetch,o.data,o.isLoading,d.data,d.isLoading,r.data,r.isLoading,r.refetch,c.mutate,c.mutateAsync,c.isPending,a.mutate,a.mutateAsync,a.isPending,x.mutate,x.mutateAsync,x.isPending,x.data,h.mutate,h.isPending,f.mutate,f.isPending,i.data,i.isLoading,i.refetch,u.mutate,u.mutateAsync,u.isPending])}function ct({rawSettings:t,rawSettingsLoading:s,isUpdating:o,isSavingRawSettings:d,hasChanges:r,isRawJsonValid:i,onRefresh:c,onSave:a}){const{t:x}=S();return 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:x("copilotConfigForm.copilotConfiguration")}),t&&e.jsx(P,{variant:"outline",className:"text-xs",children:"copilot.settings.json"})]}),t&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified: ",t.exists?new Date(t.mtime).toLocaleString():"Never saved"]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(N,{variant:"ghost",size:"sm",onClick:c,disabled:s,children:e.jsx(je,{className:`w-4 h-4 ${s?"animate-spin":""}`})}),e.jsx(N,{size:"sm",onClick:a,disabled:o||d||!r||!i,children:o||d?e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ke,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}const dt=[{name:"GPT-4.1 (Free)",description:"Free tier - no premium usage",default:"gpt-4.1",opus:"gpt-4.1",sonnet:"gpt-4.1",haiku:"gpt-4.1"},{name:"GPT-5 Mini (Free)",description:"Free tier - lightweight model",default:"gpt-5-mini",opus:"gpt-5-mini",sonnet:"gpt-5-mini",haiku:"gpt-5-mini"}],mt=[{name:"Claude Opus 4.5",description:"Pro+ (3x) - Most capable reasoning",default:"claude-opus-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"},{name:"Claude Sonnet 4.5",description:"Pro+ (1x) - Balanced performance",default:"claude-sonnet-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"},{name:"GPT-5.2",description:"Pro+ (1x) - Latest OpenAI (Preview)",default:"gpt-5.2",opus:"gpt-5.2",sonnet:"gpt-5.1",haiku:"gpt-5-mini"},{name:"GPT-5.1 Codex Max",description:"Pro+ (1x) - Best for coding",default:"gpt-5.1-codex-max",opus:"gpt-5.1-codex-max",sonnet:"gpt-5.1-codex",haiku:"gpt-5.1-codex-mini"},{name:"Gemini 2.5 Pro",description:"Pro+ (1x) - Google latest",default:"gemini-2.5-pro",opus:"gemini-2.5-pro",sonnet:"gemini-2.5-pro",haiku:"gemini-3-flash"}];function pe(t){switch(t){case"free":return"bg-green-100 text-green-700 border-green-200";case"pro":return"bg-blue-100 text-blue-700 border-blue-200";case"pro+":return"bg-purple-100 text-purple-700 border-purple-200";case"business":return"bg-orange-100 text-orange-700 border-orange-200";case"enterprise":return"bg-red-100 text-red-700 border-red-200";default:return"bg-muted text-muted-foreground"}}function ut(t){return t==null?null:t===0?"Free":t<1?`${t}x`:t===1?"1x":`${t}x`}function G({label:t,description:s,value:o,onChange:d,models:r,disabled:i}){const{t:c}=S();return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",children:t}),s&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:s})]}),e.jsx(Ye,{value:o||void 0,onChange:d,disabled:i,placeholder:c("componentModelSelector.selectModel"),searchPlaceholder:c("searchableSelect.searchModels"),emptyText:c("searchableSelect.noResults"),triggerClassName:"h-9",groups:[{key:"models",label:c("componentModelSelector.availableModelsCount",{count:r.length})}],options:r.map(a=>({value:a.id,groupKey:"models",searchText:`${a.name||a.id} ${a.id}`,keywords:[a.minPlan??"",a.preview?"preview":""],triggerContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:a.id}),a.minPlan&&e.jsx(P,{variant:"outline",className:`text-[9px] px-1 py-0 h-4 ${pe(a.minPlan)}`,children:a.minPlan})]}),itemContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:a.name||a.id}),a.minPlan&&e.jsx(P,{variant:"outline",className:`text-[9px] px-1 py-0 h-4 ${pe(a.minPlan)}`,children:a.minPlan}),a.multiplier!==void 0&&e.jsx("span",{className:"text-[9px] text-muted-foreground",children:ut(a.multiplier)}),a.preview&&e.jsx(P,{variant:"secondary",className:"text-[9px] px-1 py-0 h-4",children:c("componentModelSelector.preview")})]})}))})]})}function se(t){if(t>=1e6){const s=t/1e6;return s%1===0?`${s}M`:`${s.toFixed(1)}M`}if(t>=1e3){const s=t/1e3;return s%1===0?`${s}K`:`${s.toFixed(1)}K`}return`${t}`}function xt(t){if(!t?.limits)return null;const s=[];return t.limits.maxPromptTokens&&s.push(`prompt ${se(t.limits.maxPromptTokens)}`),t.limits.maxContextWindowTokens&&s.push(`context ${se(t.limits.maxContextWindowTokens)}`),t.limits.maxOutputTokens&&s.push(`output ${se(t.limits.maxOutputTokens)}`),s.length>0?s.join(" | "):null}function pt({currentModel:t,opusModel:s,sonnetModel:o,haikuModel:d,models:r,modelsLoading:i,onApplyPreset:c,onUpdateModel:a,onUpdateOpusModel:x,onUpdateSonnetModel:h,onUpdateHaikuModel:f}){const{t:u}=S(),n=[{label:"Default",id:t},{label:"Opus",id:s||t},{label:"Sonnet",id:o||t},{label:"Haiku",id:d||t}].map(({label:l,id:p})=>{const C=r.find(F=>F.id===p),k=xt(C);return k?{label:l,id:p,limits:k}:null}).filter(l=>l!==null);return e.jsx(le,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(V,{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(Qe,{className:"w-4 h-4"}),u("providerEditor.presets")]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:u("copilotConfigForm.modelMapping")}),e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(P,{variant:"outline",className:"text-[10px] bg-green-100 text-green-700 border-green-200",children:"Free Tier"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:u("copilotConfigForm.noPremiumUsage")})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:dt.map(l=>e.jsxs(N,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>c(l),title:l.description,children:[e.jsx(ue,{className:"w-3 h-3 text-green-600"}),l.name]},l.name))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(P,{variant:"outline",className:"text-[10px] bg-blue-100 text-blue-700 border-blue-200",children:"Pro+ Required"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Uses premium request quota"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:mt.map(l=>e.jsxs(N,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>c(l),title:l.description,children:[e.jsx(ue,{className:"w-3 h-3"}),l.name]},l.name))})]})]}),e.jsx(oe,{}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-2",children:u("copilotConfigForm.modelMapping")}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"Configure which models to use for each tier"}),e.jsxs("div",{className:"mb-4 rounded-lg border border-amber-500/30 bg-amber-500/10 p-3 text-xs text-amber-900 dark:text-amber-200",children:[e.jsx("p",{className:"font-medium",children:u("copilotConfigForm.githubCopilotControls")}),e.jsx("p",{className:"mt-1",children:"CCS can switch Copilot models, but it cannot increase the provider's max prompt or context window."}),n.length>0?e.jsx("div",{className:"mt-2 space-y-1 text-[11px] font-mono",children:n.map(l=>e.jsxs("p",{children:[l.label,": ",l.id," (",l.limits,")"]},`${l.label}-${l.id}`))}):e.jsx("p",{className:"mt-2 text-[11px] font-mono",children:"Start the daemon to inspect live model limits from GitHub Copilot metadata."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(G,{label:"Default Model",description:"Used when no specific tier is requested",value:t,onChange:a,models:r,disabled:i}),e.jsx(G,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:s||t,onChange:x,models:r,disabled:i}),e.jsx(G,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:o||t,onChange:h,models:r,disabled:i}),e.jsx(G,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:d||t,onChange:f,models:r,disabled:i})]})]})]})})})}function ht({enabled:t,autoStart:s,port:o,accountType:d,rateLimit:r,waitOnLimit:i,onUpdateEnabled:c,onUpdateAutoStart:a,onUpdatePort:x,onUpdateAccountType:h,onUpdateRateLimit:f,onUpdateWaitOnLimit:u}){const{t:n}=S();return e.jsx(le,{value:"settings",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(V,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(L,{htmlFor:"enabled",className:"text-sm font-medium",children:n("copilotSettings.enableCopilot")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n("copilotSettings.enableCopilotDesc")})]}),e.jsx(Z,{id:"enabled",checked:t,onCheckedChange:c})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:n("copilotSettings.basicSettings")}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(L,{htmlFor:"port",className:"text-xs",children:n("copilotPage.port")}),e.jsx(me,{id:"port",type:"number",value:o,onChange:l=>x(parseInt(l.target.value,10)),min:1024,max:65535,className:"max-w-[150px] h-8"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(L,{htmlFor:"account-type",className:"text-xs",children:n("copilotSettings.accountType")}),e.jsxs(Fe,{value:d,onValueChange:h,children:[e.jsx(Te,{id:"account-type",className:"max-w-[150px] h-8",children:e.jsx(Me,{})}),e.jsxs(Le,{children:[e.jsx(ee,{value:"individual",children:n("copilotSettings.accountTypeIndividual")}),e.jsx(ee,{value:"business",children:n("copilotSettings.accountTypeBusiness")}),e.jsx(ee,{value:"enterprise",children:n("copilotSettings.accountTypeEnterprise")})]})]})]})]}),e.jsx(oe,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:n("copilotSettings.rateLimiting")}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(L,{htmlFor:"rate-limit",className:"text-xs",children:n("copilotSettings.rateLimitSeconds")}),e.jsx(me,{id:"rate-limit",type:"number",value:r,onChange:l=>f(l.target.value),placeholder:n("copilotSettings.noLimit"),min:0,className:"max-w-[150px] h-8"})]}),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(L,{htmlFor:"wait-on-limit",className:"text-xs",children:n("copilotSettings.waitOnRateLimit")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:n("copilotSettings.waitOnRateLimitDesc")})]}),e.jsx(Z,{id:"wait-on-limit",checked:i,onCheckedChange:u})]})]}),e.jsx(oe,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:n("copilotSettings.daemonSettings")}),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(L,{htmlFor:"auto-start",className:"text-xs",children:n("copilotSettings.autoStartDaemon")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:n("copilotSettings.autoStartDaemonDesc")})]}),e.jsx(Z,{id:"auto-start",checked:s,onCheckedChange:a})]})]})]})})})}function H({label:t,command:s}){return e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:t}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsx("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:s}),e.jsx(fe,{value:s,size:"icon",className:"h-6 w-6"})]})]})}function gt({rawSettings:t}){const{t:s}=S();return e.jsx(le,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(V,{className:"h-full",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium flex items-center gap-2 mb-3",children:[e.jsx(Je,{className:"w-4 h-4"}),"Configuration Info"]}),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:s("copilotConfigForm.provider")}),e.jsx("span",{className:"font-mono",children:"GitHub Copilot"})]}),t&&e.jsxs(e.Fragment,{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:s("copilotConfigForm.filePath")}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:t.path}),e.jsx(fe,{value:t.path,size:"icon",className:"h-5 w-5"})]})]}),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:s("copilotConfigForm.status")}),e.jsx(P,{variant:"outline",className:t.exists?"w-fit text-green-600 border-green-200 bg-green-50":"w-fit text-muted-foreground",children:t.exists?"File exists":"Using defaults"})]})]})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:s("copilotConfigForm.quickUsage")}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsx(H,{label:"Run with Copilot",command:"ccs copilot"}),e.jsx(H,{label:"Authenticate",command:"ccs copilot auth"}),e.jsx(H,{label:"Start daemon",command:"ccs copilot --start"}),e.jsx(H,{label:"Stop daemon",command:"ccs copilot --stop"})]})]})]})})})}const ft=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"];function he(t){const s=t?.env||{};return ft.filter(o=>!s[o]?.trim())}function ge(t){if(!t||t.length===0)return[];const s=new Map;return t.forEach(o=>{s.set(o.message,o)}),[...s.values()]}function jt(){const{t}=S(),{config:s,configLoading:o,models:d,modelsLoading:r,rawSettings:i,rawSettingsLoading:c,updateConfigAsync:a,isUpdating:x,saveRawSettingsAsync:h,isSavingRawSettings:f,refetchRawSettings:u}=Ne(),[n,l]=b.useState({}),[p,C]=b.useState(null),[k,F]=b.useState(!1),U=n.enabled??s?.enabled??!1,K=n.autoStart??s?.auto_start??!1,A=n.port??s?.port??4141,Q=n.accountType??s?.account_type??"individual",E=n.model??s?.model??"claude-sonnet-4-6",O=n.rateLimit??s?.rate_limit?.toString()??"",j=n.waitOnLimit??s?.wait_on_limit??!0,J=n.opusModel??s?.opus_model??"",$=n.sonnetModel??s?.sonnet_model??"",z=n.haikuModel??s?.haiku_model??"",B=(g,v)=>{l(_=>({..._,[g]:v}))},Y=g=>{l(v=>({...v,model:g.default,opusModel:g.opus,sonnetModel:g.sonnet,haikuModel:g.haiku})),I.success(t("toasts.presetApplied",{name:g.name}))},T=b.useMemo(()=>p!==null?p:i?.settings?JSON.stringify(i.settings,null,2):`{
|
|
2
2
|
"env": {}
|
|
3
|
-
}`,[p,i]),m=w.useCallback(g=>{C(g)},[]),le=w.useMemo(()=>{try{return JSON.parse(T),!0}catch{return!1}},[T]),ye=w.useMemo(()=>{const g=Object.keys(n).length>0,v=p!==null&&p!==JSON.stringify(i?.settings,null,2);return g||v},[n,p,i]),re=w.useMemo(()=>{if(p!==null)try{return JSON.parse(p)}catch{return i?.settings}return i?.settings},[p,i?.settings]),Se=w.useMemo(()=>pe(re),[re]),Ce=w.useMemo(()=>he([...s?.warnings??[],...i?.warnings??[]]),[s?.warnings,i?.warnings]),ce=async({overwriteRawSettings:g=!1}={})=>{try{const v=[];if(Object.keys(n).length>0){const M=await a({enabled:U,auto_start:K,port:A,account_type:Q,model:E,rate_limit:O?parseInt(O,10):null,wait_on_limit:j,opus_model:J||void 0,sonnet_model:$||void 0,haiku_model:z||void 0});v.push(...M.warnings??[])}let _=[];if(p!==null&&le){const M=JSON.parse(T);_=pe(M);const Pe=await h({settings:M,expectedMtime:g?void 0:i?.mtime});v.push(...Pe.warnings??[])}const X=he(v),q=[];X.length>0&&q.push(X.map(M=>M.message).join(" ")),_.length>0&&q.push(`Missing fields will use defaults: ${_.join(", ")}`),X.length>0?I.warning(t("toasts.settingsSavedWithAdjustments"),{description:q.join(" ")}):q.length>0?I.success(t("toasts.settingsSaved"),{description:q.join(" ")}):I.success(t("toasts.settingsSaved")),l({}),C(null)}catch(v){Re(v)?F(!0):I.error(t("toasts.failedSaveSettings"))}};return{configLoading:o,rawSettingsLoading:c,modelsLoading:r,isUpdating:x,isSavingRawSettings:f,models:d,rawSettings:i,rawJsonContent:T,rawJsonEdits:p,enabled:U,autoStart:K,port:A,accountType:Q,currentModel:E,rateLimit:O,waitOnLimit:j,opusModel:J,sonnetModel:$,haikuModel:z,isRawJsonValid:le,hasChanges:ye,normalizationWarnings:Ce,conflictDialog:k,updateField:B,applyPreset:Y,handleRawJsonChange:m,handleSave:ce,handleConflictResolve:async g=>{F(!1),g?await ce({overwriteRawSettings:!0}):C(null)},refetchRawSettings:u,missingRequiredFields:Se}}function vt(){const{t}=S(),{configLoading:s,rawSettingsLoading:o,modelsLoading:d,isUpdating:r,isSavingRawSettings:i,models:c,rawSettings:a,rawJsonContent:x,rawJsonEdits:h,enabled:f,autoStart:u,port:n,accountType:l,currentModel:p,rateLimit:C,waitOnLimit:k,opusModel:F,sonnetModel:U,haikuModel:K,isRawJsonValid:A,hasChanges:Q,normalizationWarnings:E,conflictDialog:O,updateField:j,applyPreset:J,handleRawJsonChange:$,handleSave:z,handleConflictResolve:B,refetchRawSettings:Y,missingRequiredFields:T}=jt();return s||o?e.jsxs("div",{className:"space-y-6",children:[e.jsx(y,{className:"h-10 w-full"}),e.jsx(y,{className:"h-10 w-full"}),e.jsx(y,{className:"h-10 w-full"}),e.jsx(y,{className:"h-10 w-full"})]}):e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(ct,{rawSettings:a,rawSettingsLoading:o,isUpdating:r,isSavingRawSettings:i,hasChanges:Q,isRawJsonValid:A,onRefresh:()=>Y(),onSave:z}),E.length>0&&e.jsx("div",{className:"px-6 pt-4 shrink-0",children:e.jsxs(Ae,{variant:"warning",children:[e.jsx(ve,{className:"h-4 w-4"}),e.jsx(Ee,{children:t("copilotConfigForm.deprecatedModels")}),e.jsxs(Oe,{className:"space-y-2",children:[e.jsx("p",{children:"Loading this page did not rewrite your files. Save the Copilot configuration to persist these replacements."}),e.jsx("div",{className:"space-y-1",children:E.map(m=>e.jsx("p",{children:m.message},m.message))})]})]})}),e.jsxs("div",{className:"flex-1 flex divide-x overflow-hidden",children:[e.jsx("div",{className:"w-[540px] shrink-0 flex flex-col overflow-hidden bg-muted/5",children:e.jsx("div",{className:"h-full flex flex-col",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(qe,{className:"w-full",children:[e.jsx(te,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(te,{value:"settings",className:"flex-1",children:"Settings"}),e.jsx(te,{value:"info",className:"flex-1",children:"Info"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsx(pt,{currentModel:p,opusModel:F,sonnetModel:U,haikuModel:K,models:c,modelsLoading:d,onApplyPreset:J,onUpdateModel:m=>j("model",m),onUpdateOpusModel:m=>j("opusModel",m),onUpdateSonnetModel:m=>j("sonnetModel",m),onUpdateHaikuModel:m=>j("haikuModel",m)}),e.jsx(ht,{enabled:f,autoStart:u,port:n,accountType:l,rateLimit:C,waitOnLimit:k,onUpdateEnabled:m=>j("enabled",m),onUpdateAutoStart:m=>j("autoStart",m),onUpdatePort:m=>j("port",m),onUpdateAccountType:m=>j("accountType",m),onUpdateRateLimit:m=>j("rateLimit",m),onUpdateWaitOnLimit:m=>j("waitOnLimit",m)}),e.jsx(gt,{rawSettings:a})]})]})})}),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($e,{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(De,{rawJsonContent:x,isRawJsonValid:A,rawJsonEdits:h,rawSettingsEnv:a?.settings?.env,onChange:$,missingRequiredFields:T})]})]}),e.jsx(Ue,{open:O,title:"File Modified Externally",description:"This settings file was modified by another process. Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>B(!0),onCancel:()=>B(!1)})]})}function ae({title:t,children:s}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide px-3",children:t}),e.jsx("div",{className:"space-y-1",children:s})]})}function W({icon:t,label:s,status:o,statusText:d,variant:r="default"}){return e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 rounded-lg bg-muted/50",children:[e.jsx(t,{className:"w-4 h-4 text-muted-foreground shrink-0"}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("span",{className:"text-sm",children:s})}),e.jsx("div",{className:"flex items-center gap-1.5",children:o?e.jsxs(e.Fragment,{children:[e.jsx(we,{className:ie("w-4 h-4",r==="warning"?"text-yellow-500":"text-green-500")}),e.jsx("span",{className:ie("text-xs",r==="warning"?"text-yellow-500":"text-green-500"),children:d||"Yes"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ne,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:d||"No"})]})})]})}function wt(){return e.jsxs("div",{className:"space-y-4 p-4",children:[e.jsx(y,{className:"h-8 w-full"}),e.jsx(y,{className:"h-12 w-full"}),e.jsx(y,{className:"h-12 w-full"}),e.jsx(y,{className:"h-12 w-full"})]})}function Ot(){const{t}=S(),{status:s,statusLoading:o,refetchStatus:d,startAuth:r,isAuthenticating:i,startDaemon:c,isStartingDaemon:a,stopDaemon:x,isStoppingDaemon:h,install:f,isInstalling:u}=be();return e.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden",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(ze,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:t("copilotPage.title")})]}),e.jsx(b,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>d(),disabled:o,children:e.jsx(fe,{className:ie("w-4 h-4",o&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("copilotPage.subtitle")})]}),e.jsx(V,{className:"flex-1",children:o?e.jsx(wt,{}):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(ve,{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:t("copilotPage.unofficialTitle")})]}),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:t("copilotPage.unofficialItem1")}),e.jsx("li",{children:t("copilotPage.unofficialItem2")}),e.jsx("li",{children:t("copilotPage.unofficialItem3")})]})]}),e.jsxs(ae,{title:t("copilotPage.setup"),children:[e.jsx(W,{icon:Be,label:"copilot-api",status:s?.installed??!1,statusText:s?.installed?s.version?`v${s.version}`:t("copilotPage.installed"):t("copilotPage.missing")}),!s?.installed&&e.jsx(b,{size:"sm",className:"w-full mt-2",onClick:()=>f(void 0),disabled:u,children:u?e.jsxs(e.Fragment,{children:[e.jsx(je,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}),t("copilotPage.installing")]}):e.jsxs(e.Fragment,{children:[e.jsx(Ge,{className:"w-3.5 h-3.5 mr-1.5"}),t("copilotPage.installCopilotApi")]})}),s?.installed&&e.jsx(W,{icon:ue,label:t("copilotPage.integration"),status:s?.enabled??!1,statusText:s?.enabled?t("copilotPage.enabled"):t("copilotPage.disabled")})]}),s?.installed&&e.jsxs(ae,{title:t("copilotPage.auth"),children:[e.jsx(W,{icon:He,label:t("copilotPage.github"),status:s?.authenticated??!1,statusText:s?.authenticated?t("copilotPage.connected"):t("copilotPage.notConnected")}),!s?.authenticated&&e.jsx(b,{size:"sm",className:"w-full mt-2",onClick:()=>r(),disabled:i,children:t(i?"copilotPage.authenticating":"copilotPage.authenticate")})]}),s?.authenticated&&e.jsxs(ae,{title:t("copilotPage.daemon"),children:[e.jsx(W,{icon:We,label:t("copilotPage.status"),status:s?.daemon_running??!1,statusText:s?.daemon_running?t("copilotPage.running"):t("copilotPage.stopped")}),e.jsxs("div",{className:"px-3 py-1 text-xs text-muted-foreground",children:[t("copilotPage.port"),": ",s?.port??4141]}),e.jsx("div",{className:"px-1",children:s?.daemon_running?e.jsxs(b,{size:"sm",variant:"outline",className:"w-full",onClick:()=>x(),disabled:h,children:[e.jsx(Ve,{className:"w-3.5 h-3.5 mr-1.5"}),t(h?"copilotPage.stopping":"copilotPage.stop")]}):e.jsxs(b,{size:"sm",variant:"outline",className:"w-full",onClick:()=>c(),disabled:a,children:[e.jsx(ue,{className:"w-3.5 h-3.5 mr-1.5"}),t(a?"copilotPage.starting":"copilotPage.start")]})})]})]})}),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:t("copilotPage.proxy")}),s?.daemon_running?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(we,{className:"w-3 h-3 text-green-500"}),t("copilotPage.active")]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ne,{className:"w-3 h-3 text-muted-foreground"}),t("copilotPage.inactive")]})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-background overflow-hidden",children:e.jsx(vt,{})})]})}export{Ot as CopilotPage};
|
|
3
|
+
}`,[p,i]),m=b.useCallback(g=>{C(g)},[]),re=b.useMemo(()=>{try{return JSON.parse(T),!0}catch{return!1}},[T]),ye=b.useMemo(()=>{const g=Object.keys(n).length>0,v=p!==null&&p!==JSON.stringify(i?.settings,null,2);return g||v},[n,p,i]),ce=b.useMemo(()=>{if(p!==null)try{return JSON.parse(p)}catch{return i?.settings}return i?.settings},[p,i?.settings]),Se=b.useMemo(()=>he(ce),[ce]),Ce=b.useMemo(()=>ge([...s?.warnings??[],...i?.warnings??[]]),[s?.warnings,i?.warnings]),de=async({overwriteRawSettings:g=!1}={})=>{try{const v=[];if(Object.keys(n).length>0){const M=await a({enabled:U,auto_start:K,port:A,account_type:Q,model:E,rate_limit:O?parseInt(O,10):null,wait_on_limit:j,opus_model:J||void 0,sonnet_model:$||void 0,haiku_model:z||void 0});v.push(...M.warnings??[])}let _=[];if(p!==null&&re){const M=JSON.parse(T);_=he(M);const Pe=await h({settings:M,expectedMtime:g?void 0:i?.mtime});v.push(...Pe.warnings??[])}const X=ge(v),q=[];X.length>0&&q.push(X.map(M=>M.message).join(" ")),_.length>0&&q.push(`Missing fields will use defaults: ${_.join(", ")}`),X.length>0?I.warning(t("toasts.settingsSavedWithAdjustments"),{description:q.join(" ")}):q.length>0?I.success(t("toasts.settingsSaved"),{description:q.join(" ")}):I.success(t("toasts.settingsSaved")),l({}),C(null)}catch(v){Re(v)?F(!0):I.error(t("toasts.failedSaveSettings"))}};return{configLoading:o,rawSettingsLoading:c,modelsLoading:r,isUpdating:x,isSavingRawSettings:f,models:d,rawSettings:i,rawJsonContent:T,rawJsonEdits:p,enabled:U,autoStart:K,port:A,accountType:Q,currentModel:E,rateLimit:O,waitOnLimit:j,opusModel:J,sonnetModel:$,haikuModel:z,isRawJsonValid:re,hasChanges:ye,normalizationWarnings:Ce,conflictDialog:k,updateField:B,applyPreset:Y,handleRawJsonChange:m,handleSave:de,handleConflictResolve:async g=>{F(!1),g?await de({overwriteRawSettings:!0}):C(null)},refetchRawSettings:u,missingRequiredFields:Se}}function vt(){const{t}=S(),{configLoading:s,rawSettingsLoading:o,modelsLoading:d,isUpdating:r,isSavingRawSettings:i,models:c,rawSettings:a,rawJsonContent:x,rawJsonEdits:h,enabled:f,autoStart:u,port:n,accountType:l,currentModel:p,rateLimit:C,waitOnLimit:k,opusModel:F,sonnetModel:U,haikuModel:K,isRawJsonValid:A,hasChanges:Q,normalizationWarnings:E,conflictDialog:O,updateField:j,applyPreset:J,handleRawJsonChange:$,handleSave:z,handleConflictResolve:B,refetchRawSettings:Y,missingRequiredFields:T}=jt();return s||o?e.jsxs("div",{className:"space-y-6",children:[e.jsx(y,{className:"h-10 w-full"}),e.jsx(y,{className:"h-10 w-full"}),e.jsx(y,{className:"h-10 w-full"}),e.jsx(y,{className:"h-10 w-full"})]}):e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(ct,{rawSettings:a,rawSettingsLoading:o,isUpdating:r,isSavingRawSettings:i,hasChanges:Q,isRawJsonValid:A,onRefresh:()=>Y(),onSave:z}),E.length>0&&e.jsx("div",{className:"px-6 pt-4 shrink-0",children:e.jsxs(Ae,{variant:"warning",children:[e.jsx(ne,{className:"h-4 w-4"}),e.jsx(Ee,{children:t("copilotConfigForm.deprecatedModels")}),e.jsxs(Oe,{className:"space-y-2",children:[e.jsx("p",{children:"Loading this page did not rewrite your files. Save the Copilot configuration to persist these replacements."}),e.jsx("div",{className:"space-y-1",children:E.map(m=>e.jsx("p",{children:m.message},m.message))})]})]})}),e.jsxs("div",{className:"flex-1 flex divide-x overflow-hidden",children:[e.jsx("div",{className:"w-[540px] shrink-0 flex flex-col overflow-hidden bg-muted/5",children:e.jsx("div",{className:"h-full flex flex-col",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(qe,{className:"w-full",children:[e.jsx(te,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(te,{value:"settings",className:"flex-1",children:"Settings"}),e.jsx(te,{value:"info",className:"flex-1",children:"Info"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsx(pt,{currentModel:p,opusModel:F,sonnetModel:U,haikuModel:K,models:c,modelsLoading:d,onApplyPreset:J,onUpdateModel:m=>j("model",m),onUpdateOpusModel:m=>j("opusModel",m),onUpdateSonnetModel:m=>j("sonnetModel",m),onUpdateHaikuModel:m=>j("haikuModel",m)}),e.jsx(ht,{enabled:f,autoStart:u,port:n,accountType:l,rateLimit:C,waitOnLimit:k,onUpdateEnabled:m=>j("enabled",m),onUpdateAutoStart:m=>j("autoStart",m),onUpdatePort:m=>j("port",m),onUpdateAccountType:m=>j("accountType",m),onUpdateRateLimit:m=>j("rateLimit",m),onUpdateWaitOnLimit:m=>j("waitOnLimit",m)}),e.jsx(gt,{rawSettings:a})]})]})})}),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($e,{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(De,{rawJsonContent:x,isRawJsonValid:A,rawJsonEdits:h,rawSettingsEnv:a?.settings?.env,onChange:$,missingRequiredFields:T})]})]}),e.jsx(Ue,{open:O,title:"File Modified Externally",description:"This settings file was modified by another process. Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>B(!0),onCancel:()=>B(!1)})]})}function ae({title:t,children:s}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide px-3",children:t}),e.jsx("div",{className:"space-y-1",children:s})]})}function W({icon:t,label:s,status:o,statusText:d,variant:r="default"}){return e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 rounded-lg bg-muted/50",children:[e.jsx(t,{className:"w-4 h-4 text-muted-foreground shrink-0"}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("span",{className:"text-sm",children:s})}),e.jsx("div",{className:"flex items-center gap-1.5",children:o?e.jsxs(e.Fragment,{children:[e.jsx(be,{className:ie("w-4 h-4",r==="warning"?"text-yellow-500":"text-green-500")}),e.jsx("span",{className:ie("text-xs",r==="warning"?"text-yellow-500":"text-green-500"),children:d||"Yes"})]}):e.jsxs(e.Fragment,{children:[e.jsx(we,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:d||"No"})]})})]})}function bt(){return e.jsxs("div",{className:"space-y-4 p-4",children:[e.jsx(y,{className:"h-8 w-full"}),e.jsx(y,{className:"h-12 w-full"}),e.jsx(y,{className:"h-12 w-full"}),e.jsx(y,{className:"h-12 w-full"})]})}function Ot(){const{t}=S(),{status:s,statusLoading:o,refetchStatus:d,startAuth:r,isAuthenticating:i,startDaemon:c,isStartingDaemon:a,stopDaemon:x,isStoppingDaemon:h,install:f,isInstalling:u}=Ne();return e.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden",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(ze,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:t("copilotPage.title")}),e.jsx("span",{className:"rounded border border-amber-300 bg-amber-100 px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-amber-800 dark:border-amber-900/60 dark:bg-amber-950/40 dark:text-amber-200",children:t("copilotPage.deprecatedBadge")})]}),e.jsx(N,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>d(),disabled:o,children:e.jsx(je,{className:ie("w-4 h-4",o&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("copilotPage.subtitle")})]}),e.jsx(V,{className:"flex-1",children:o?e.jsx(bt,{}):e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsxs("div",{className:"rounded-md border border-amber-500/50 bg-amber-500/15 p-3 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ne,{className:"h-4 w-4 text-amber-600 dark:text-amber-400 shrink-0"}),e.jsx("span",{className:"text-xs font-semibold text-amber-800 dark:text-amber-200",children:t("copilotPage.deprecationTitle")})]}),e.jsxs("ul",{className:"text-[11px] text-amber-700 dark:text-amber-300 space-y-0.5 pl-6 list-disc",children:[e.jsx("li",{children:t("copilotPage.deprecationItem1")}),e.jsx("li",{children:t("copilotPage.deprecationItem2")}),e.jsx("li",{children:t("copilotPage.deprecationItem3")})]})]}),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(ne,{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:t("copilotPage.unofficialTitle")})]}),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:t("copilotPage.unofficialItem1")}),e.jsx("li",{children:t("copilotPage.unofficialItem2")}),e.jsx("li",{children:t("copilotPage.unofficialItem3")})]})]}),e.jsxs(ae,{title:t("copilotPage.setup"),children:[e.jsx(W,{icon:Be,label:"copilot-api",status:s?.installed??!1,statusText:s?.installed?s.version?`v${s.version}`:t("copilotPage.installed"):t("copilotPage.missing")}),!s?.installed&&e.jsx(N,{size:"sm",className:"w-full mt-2",onClick:()=>f(void 0),disabled:u,children:u?e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}),t("copilotPage.installing")]}):e.jsxs(e.Fragment,{children:[e.jsx(Ge,{className:"w-3.5 h-3.5 mr-1.5"}),t("copilotPage.installCopilotApi")]})}),s?.installed&&e.jsx(W,{icon:xe,label:t("copilotPage.integration"),status:s?.enabled??!1,statusText:s?.enabled?t("copilotPage.enabled"):t("copilotPage.disabled")})]}),s?.installed&&e.jsxs(ae,{title:t("copilotPage.auth"),children:[e.jsx(W,{icon:He,label:t("copilotPage.github"),status:s?.authenticated??!1,statusText:s?.authenticated?t("copilotPage.connected"):t("copilotPage.notConnected")}),!s?.authenticated&&e.jsx(N,{size:"sm",className:"w-full mt-2",onClick:()=>r(),disabled:i,children:t(i?"copilotPage.authenticating":"copilotPage.authenticate")})]}),s?.authenticated&&e.jsxs(ae,{title:t("copilotPage.daemon"),children:[e.jsx(W,{icon:We,label:t("copilotPage.status"),status:s?.daemon_running??!1,statusText:s?.daemon_running?t("copilotPage.running"):t("copilotPage.stopped")}),e.jsxs("div",{className:"px-3 py-1 text-xs text-muted-foreground",children:[t("copilotPage.port"),": ",s?.port??4141]}),e.jsx("div",{className:"px-1",children:s?.daemon_running?e.jsxs(N,{size:"sm",variant:"outline",className:"w-full",onClick:()=>x(),disabled:h,children:[e.jsx(Ve,{className:"w-3.5 h-3.5 mr-1.5"}),t(h?"copilotPage.stopping":"copilotPage.stop")]}):e.jsxs(N,{size:"sm",variant:"outline",className:"w-full",onClick:()=>c(),disabled:a,children:[e.jsx(xe,{className:"w-3.5 h-3.5 mr-1.5"}),t(a?"copilotPage.starting":"copilotPage.start")]})})]})]})}),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:t("copilotPage.proxy")}),s?.daemon_running?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(be,{className:"w-3 h-3 text-green-500"}),t("copilotPage.active")]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(we,{className:"w-3 h-3 text-muted-foreground"}),t("copilotPage.inactive")]})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-background overflow-hidden",children:e.jsx(vt,{})})]})}export{Ot as CopilotPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-nu4wz29m.js";import{r as b,e as gs}from"./react-vendor-Bjx91N7w.js";import{t as i}from"./notifications-B4_o8bcr.js";import{bf as y,bg as xs,a as Oe,B as M,d as h,c as V,n as U,Q as hs,R as fs,U as ue,V as me,L,I as ge,aI as Fe,bl as ps,ah as js,ai as Ps,aj as bs,ak as ys,al as Ns,aD as vs,bh as ws}from"./index-BIF0Wvld.js";import{a as Cs,u as B,b as R}from"./tanstack-bhJxV1h8.js";import{D as Ee}from"./default-ports-1QQSffYX.js";import{S as Ss}from"./separator-oLpQ8QTJ.js";import{S as ks}from"./searchable-select-CRBVpRX9.js";import{R as Le,T as _s,K as z,Z as J,ai as As,ae as Ds,ax as xe,aQ as Ie,aP as Ms,L as F,J as Ts,au as Rs,aa as Fs,x as Ls,I as Is}from"./icons-Ce9So20E.js";import"./utils-CzKF5WmX.js";import"./form-utils-CuHzLhJZ.js";import"./code-highlight-D4E79GKQ.js";const N="/legacy/cursor";function Os(s){if(!s||typeof s!="object")return!1;const t=s;return typeof t.message=="string"&&typeof t.stage=="string"&&typeof t.status=="number"&&typeof t.duration_ms=="number"&&typeof t.ok=="boolean"}function Es(s){if(!s||typeof s!="object"||!("error"in s))return null;const t=s;return typeof t.error=="string"?t.error:null}async function zs(){const s=await fetch(y(`${N}/status`));if(!s.ok)throw new Error("Failed to fetch cursor status");return s.json()}async function Ks(){const s=await fetch(y(`${N}/settings`));if(!s.ok)throw new Error("Failed to fetch cursor config");return s.json()}async function qs(){const s=await fetch(y(`${N}/models`));if(!s.ok)throw new Error("Failed to fetch cursor models");return s.json()}async function Gs(){const s=await fetch(y(`${N}/settings/raw`));if(!s.ok)throw new Error("Failed to fetch cursor raw settings");return s.json()}async function Qs(s){const t=await fetch(y(`${N}/settings`),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!t.ok)throw new Error("Failed to update cursor config");return t.json()}async function Us(s){const t=await fetch(y(`${N}/settings/raw`),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(t.status===409)throw new xs("Cursor raw settings changed externally");if(!t.ok)throw new Error("Failed to save cursor raw settings");return t.json()}async function Bs(){const s=await fetch(y(`${N}/auth/auto-detect`),{method:"POST"});if(!s.ok){const t=await s.json().catch(()=>({error:"Auto-detect failed"}));throw new Error(t.error||"Auto-detect failed")}return s.json()}async function Js(s){const t=await fetch(y(`${N}/auth/import`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!t.ok){const r=await t.json().catch(()=>({error:"Manual import failed"}));throw new Error(r.error||"Manual import failed")}return t.json()}async function $s(){const s=await fetch(y(`${N}/daemon/start`),{method:"POST"});if(!s.ok)throw new Error("Failed to start cursor daemon");return s.json()}async function Hs(){const s=await fetch(y(`${N}/daemon/stop`),{method:"POST"});if(!s.ok)throw new Error("Failed to stop cursor daemon");return s.json()}async function Vs(){const s=await fetch(y(`${N}/probe`),{method:"POST"}),t=await s.json().catch(()=>null);return Os(t)?t:{ok:!1,stage:"runtime",status:s.status,duration_ms:0,error_type:"runtime_error",message:Es(t)??"Failed to run live probe"}}function Ws(){const s=Cs(),t=B({queryKey:["cursor-status"],queryFn:zs,refetchInterval:5e3}),r=B({queryKey:["cursor-config"],queryFn:Ks}),u=B({queryKey:["cursor-models"],queryFn:qs}),x=B({queryKey:["cursor-raw-settings"],queryFn:Gs}),c=()=>{s.invalidateQueries({queryKey:["cursor-status"]}),s.invalidateQueries({queryKey:["cursor-config"]}),s.invalidateQueries({queryKey:["cursor-models"]}),s.invalidateQueries({queryKey:["cursor-raw-settings"]})},f=R({mutationFn:Qs,onSuccess:c}),g=R({mutationFn:Us,onSuccess:c}),p=R({mutationFn:Bs,onSuccess:c}),n=R({mutationFn:Js,onSuccess:c}),l=R({mutationFn:$s,onSuccess:c}),d=R({mutationFn:Hs,onSuccess:c}),m=R({mutationFn:Vs,onSettled:()=>{s.invalidateQueries({queryKey:["cursor-status"]}),s.invalidateQueries({queryKey:["cursor-models"]})}});return b.useMemo(()=>({status:t.data,statusLoading:t.isLoading,statusError:t.error,refetchStatus:t.refetch,config:r.data,configLoading:r.isLoading,refetchConfig:r.refetch,models:u.data?.models??[],currentModel:u.data?.current??null,modelsLoading:u.isLoading,rawSettings:x.data,rawSettingsLoading:x.isLoading,refetchRawSettings:x.refetch,updateConfig:f.mutate,updateConfigAsync:f.mutateAsync,isUpdatingConfig:f.isPending,saveRawSettings:g.mutate,saveRawSettingsAsync:g.mutateAsync,isSavingRawSettings:g.isPending,autoDetectAuth:p.mutate,autoDetectAuthAsync:p.mutateAsync,isAutoDetectingAuth:p.isPending,autoDetectAuthResult:p.data,importManualAuth:n.mutate,importManualAuthAsync:n.mutateAsync,isImportingManualAuth:n.isPending,manualAuthResult:n.data,startDaemon:l.mutate,startDaemonAsync:l.mutateAsync,isStartingDaemon:l.isPending,stopDaemon:d.mutate,stopDaemonAsync:d.mutateAsync,isStoppingDaemon:d.isPending,runProbe:m.mutate,runProbeAsync:m.mutateAsync,isRunningProbe:m.isPending,probeResult:m.data,resetProbe:m.reset}),[t.data,t.isLoading,t.error,t.refetch,r.data,r.isLoading,r.refetch,u.data,u.isLoading,x.data,x.isLoading,x.refetch,f.mutate,f.mutateAsync,f.isPending,g.mutate,g.mutateAsync,g.isPending,p.mutate,p.mutateAsync,p.isPending,p.data,n.mutate,n.mutateAsync,n.isPending,n.data,l.mutate,l.mutateAsync,l.isPending,d.mutate,d.mutateAsync,d.isPending,m.mutate,m.mutateAsync,m.isPending,m.data,m.reset])}function he(s,t){return JSON.stringify({enabled:s?.enabled??null,authenticated:s?.authenticated??null,token_expired:s?.token_expired??null,daemon_running:s?.daemon_running??null,port:s?.port??null,ghost_mode:s?.ghost_mode??null,auto_start:t?.auto_start??null,model:t?.model??null})}function $(s){return{port:String(s?.port??Ee),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 S(s,t,r){return s.find(x=>t.some(c=>c.test(x.id)))?.id??r}function fe(s){return s.toLowerCase().replace(/[^a-z0-9]/g,"")}function k(s,t,r){const u=new Set(t.map(fe)),x=s.find(f=>u.has(fe(f.id)));if(x)return x.id;const c=s.find(f=>u.has(fe(f.name)));return c?c.id:r}function Xs(s){try{const t=JSON.parse(s||"{}");return!t||typeof t!="object"||Array.isArray(t)?{isValid:!1,error:"Raw settings must be a JSON object"}:{isValid:!0,settings:t}}catch(t){return{isValid:!1,error:t.message||"Invalid JSON"}}}function H({label:s,description:t,value:r,models:u,disabled:x,allowDefaultFallback:c=!1,onChange:f}){const{t:g}=Oe(),p=r||(c?"__default":""),n=b.useMemo(()=>{const l=u.map(d=>({value:d.id,groupKey:"models",searchText:`${d.name||d.id} ${d.id}`,keywords:[d.provider],triggerContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:d.name||d.id}),d.provider&&e.jsx(M,{variant:"outline",className:"text-[9px] h-4 px-1 capitalize",children:d.provider})]}),itemContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate text-xs font-mono",children:d.name||d.id}),e.jsx(M,{variant:"outline",className:"text-[9px] h-4 px-1 capitalize",children:d.provider})]})}));return c?[{value:"__default",groupKey:"models",searchText:g("cursorPage.useDefaultModel"),triggerContent:e.jsx("span",{className:"truncate font-mono text-xs",children:g("cursorPage.useDefaultModel")}),itemContent:e.jsx("span",{children:g("cursorPage.useDefaultModel")})},...l]:l},[c,u,g]);return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx(L,{className:"text-xs font-medium",children:s}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:t})]}),e.jsx(ks,{value:p||void 0,onChange:l=>{if(c&&l==="__default"){f("");return}f(l)},disabled:x,placeholder:g("cursorPage.selectModel"),searchPlaceholder:g("searchableSelect.searchModels"),emptyText:g("searchableSelect.noResults"),triggerClassName:"h-9",groups:[{key:"models",label:g("cursorPage.availableModelCount",{count:u.length})}],options:n})]})}function pe({icon:s,label:t,ok:r,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:t})}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[r?e.jsx(Ls,{className:"h-4 w-4 text-green-500"}):e.jsx(Is,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:V("text-xs",r?"text-green-500":"text-muted-foreground"),title:u,children:u})]})]})}function da(){const{t:s}=Oe(),t=gs(),{status:r,statusLoading:u,refetchStatus:x,config:c,refetchConfig:f,updateConfigAsync:g,isUpdatingConfig:p,models:n,modelsLoading:l,currentModel:d,rawSettings:m,rawSettingsLoading:je,refetchRawSettings:ze,saveRawSettingsAsync:Ke,isSavingRawSettings:Pe,autoDetectAuthAsync:qe,isAutoDetectingAuth:be,importManualAuthAsync:Ge,isImportingManualAuth:ye,startDaemonAsync:Qe,isStartingDaemon:Ue,stopDaemonAsync:Be,isStoppingDaemon:Ne,runProbeAsync:Je,isRunningProbe:W,probeResult:X,resetProbe:$e}=Ws(),[T,Z]=b.useState(()=>$()),[v,Y]=b.useState(!1),[ve,He]=b.useState("{}"),[I,ee]=b.useState(!1),[Ve,K]=b.useState(!1),[se,we]=b.useState(""),[ae,Ce]=b.useState(""),[Se,ke]=b.useState(()=>X?he(r,c):null),_=$(c),_e=v?T.port:_.port,te=v?T.auto_start:_.auto_start,re=v?T.ghost_mode:_.ghost_mode,w=v?T.model:_.model,ne=v?T.opus_model:_.opus_model,oe=v?T.sonnet_model:_.sonnet_model,ie=v?T.haiku_model:_.haiku_model,ce=I?ve:JSON.stringify(m?.settings??{},null,2),Ae=!!m,O=b.useMemo(()=>Xs(ce),[ce]),De=O.isValid,q=v||I,We=!I||Ae&&De,Xe=he(r,c),P=X&&!q&&Se!==null&&Se===Xe?X:null,G=b.useMemo(()=>{const a=new Set,o=[...n].sort((D,de)=>D.name.localeCompare(de.name)),j=o.filter(D=>a.has(D.id)?!1:(a.add(D.id),!0));return w&&!o.some(D=>D.id===w)?[{id:w,name:w,provider:"custom"},...j]:j},[n,w]),C=a=>{Z(o=>a(v?o:_)),Y(!0)},A=()=>{$e(),ke(null)},Ze=(a=c)=>{Z($(a)),Y(!1)},Ye=!!(r?.enabled&&r?.authenticated&&!r?.token_expired),es=b.useMemo(()=>r?.enabled?e.jsx(M,{children:s("cursorPage.enabled")}):e.jsx(M,{variant:"secondary",children:s("cursorPage.disabled")}),[r?.enabled,s]),ss=async({suppressSuccessToast:a=!1}={})=>{const o=Number(_e);if(!Number.isInteger(o)||o<1||o>65535)return i.error(s("cursorPage.invalidPort")),!1;if(!w.trim())return i.error(s("cursorPage.defaultModelRequired")),!1;try{return await g({port:o,auto_start:te,ghost_mode:re,model:w,opus_model:ne||void 0,sonnet_model:oe||void 0,haiku_model:ie||void 0}),Y(!1),Z($({port:o,auto_start:te,ghost_mode:re,model:w,opus_model:ne||void 0,sonnet_model:oe||void 0,haiku_model:ie||void 0})),A(),a||i.success(s("cursorPage.savedConfig")),!0}catch(j){return i.error(j.message||s("cursorPage.failedSaveConfig")),!1}},le=a=>{if(l){i.error(s("cursorPage.modelsLoadingWait"));return}if(n.length===0){i.error(s("cursorPage.noModelsAvailable"));return}const o=w||d||n[0]?.id||"gpt-5.3-codex",j=k(n,["gpt-5.3-codex","gpt53codex","GPT-5.3 Codex"],S(n,[/gpt[-.]?5.*codex/i],o)),D=k(n,["gpt-5.1-codex-max","gpt51codexmax","GPT-5.1 Codex Max"],S(n,[/gpt[-.]?5.*codex.*max/i],j)),de=k(n,["gpt-5-fast","gpt5fast","GPT-5 Fast"],S(n,[/gpt[-.]?5.*fast/i],j)),ds=k(n,["gpt-5-mini","gpt5mini","GPT-5 Mini"],S(n,[/gpt[-.]?5.*mini/i],de)),Te=k(n,["claude-4.6-opus","claude46opus","Claude 4.6 Opus"],S(n,[/claude[-.]?4\.?6.*opus/i,/claude.*opus/i],j)),Re=k(n,["claude-4.5-sonnet","claude45sonnet","Claude 4.5 Sonnet"],S(n,[/claude[-.]?4\.?5.*sonnet/i,/claude.*sonnet/i],j)),us=k(n,["claude-4.5-haiku","claude45haiku","Claude 4.5 Haiku"],S(n,[/claude[-.]?4\.?5.*haiku/i,/haiku/i],Re)),Q=k(n,["gemini-3-pro","gemini3pro","Gemini 3 Pro"],S(n,[/gemini[-.]?3.*pro/i],j)),ms=k(n,["gemini-3-flash","gemini3flash","Gemini 3 Flash"],S(n,[/gemini[-.]?3.*flash/i,/gemini[-.]?2\.?5.*flash/i],Q));if(a==="codex53"){C(E=>({...E,model:j,opus_model:D,sonnet_model:j,haiku_model:ds})),i.success(s("cursorPage.appliedCodexPreset"));return}if(a==="claude46"){C(E=>({...E,model:Te,opus_model:Te,sonnet_model:Re,haiku_model:us})),i.success(s("cursorPage.appliedClaudePreset"));return}C(E=>({...E,model:Q,opus_model:Q,sonnet_model:Q,haiku_model:ms})),i.success(s("cursorPage.appliedGeminiPreset"))},Me=async a=>{try{await g({enabled:a}),A(),i.success(s(a?"cursorPage.integrationEnabled":"cursorPage.integrationDisabled"))}catch(o){i.error(o.message||s("cursorPage.failedUpdateIntegration"))}},as=async()=>{try{await qe(),A(),i.success(s("cursorPage.credentialsImported"))}catch(a){i.error(a.message||s("cursorPage.autoDetectFailed"))}},ts=async()=>{if(!se.trim()||!ae.trim()){i.error(s("cursorPage.manualRequired"));return}try{await Ge({accessToken:se.trim(),machineId:ae.trim()}),A(),i.success(s("cursorPage.credentialsImported")),K(!1),we(""),Ce("")}catch(a){i.error(a.message||s("cursorPage.manualImportFailed"))}},rs=async()=>{try{const a=await Qe();if(!a.success){i.error(a.error||s("cursorPage.failedStartDaemon"));return}A(),i.success(a.pid?s("cursorPage.daemonStartedWithPid",{pid:a.pid}):s("cursorPage.daemonStarted"))}catch(a){i.error(a.message||s("cursorPage.failedStartDaemon"))}},ns=async()=>{try{const a=await Be();if(!a.success){i.error(a.error||s("cursorPage.failedStopDaemon"));return}A(),i.success(s("cursorPage.daemonStopped"))}catch(a){i.error(a.message||s("cursorPage.failedStopDaemon"))}},os=async()=>{if(q){i.error(s("cursorPage.probeSaveFirst"));return}try{const a=await Je(),o=await x();if(ke(he(o.data??r,c)),a.ok){i.success(s("cursorPage.probeSucceeded"));return}i.error(a.message||s("cursorPage.probeFailed"))}catch(a){i.error(a.message||s("cursorPage.probeFailed"))}},is=async({suppressSuccessToast:a=!1}={})=>{if(!Ae)return i.error(s("cursorPage.rawLoading")),!1;if(!O.isValid||!O.settings)return i.error(O.error||s("cursorPage.invalidJson")),!1;try{return await Ke({settings:O.settings,expectedMtime:m?.mtime}),ee(!1),A(),a||i.success(s("cursorPage.rawSaved")),!0}catch(o){return ws(o)?i.error(s("cursorPage.rawChanged")):i.error(o.message||s("cursorPage.failedSaveRaw")),!1}},cs=async()=>{if(!q)return;const a=v,o=I;a&&!await ss({suppressSuccessToast:o})||o&&!await is({suppressSuccessToast:a})||a&&o&&i.success(s("cursorPage.savedAll"))},ls=async()=>{ee(!1),A();const[,a]=await Promise.all([x(),f(),ze()]);Ze(a.data??c)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden",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:s("cursorPage.title")}),e.jsx(M,{variant:"outline",className:"h-5 border-red-500/50 bg-red-500/10 px-1.5 text-[10px] font-semibold uppercase tracking-wide text-red-700 dark:text-red-300",children:s("cursorPage.deprecated")}),es]}),e.jsx(h,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>x(),disabled:u,"aria-label":s("cursorPage.refreshStatus"),title:s("cursorPage.refreshStatus"),children:e.jsx(Le,{className:V("w-4 h-4",u&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("cursorPage.subtitle")})]}),e.jsx(U,{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(_s,{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:s("cursorPage.unofficialTitle")})]}),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:s("cursorPage.unofficialItem1")}),e.jsx("li",{children:s("cursorPage.unofficialItem2")}),e.jsx("li",{children:s("cursorPage.unofficialItem3")})]})]}),e.jsxs("div",{className:"rounded-md border border-border/70 bg-background/90 p-3 space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:s("cursorPage.supportedPathTitle")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("cursorPage.supportedPathDesc")})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(h,{size:"sm",className:"w-full",onClick:()=>t("/cliproxy?provider=cursor&action=auth"),children:[e.jsx(z,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.startCliproxyAuth")]}),e.jsxs(h,{variant:"outline",size:"sm",className:"w-full",onClick:()=>t("/cliproxy?provider=cursor"),children:[e.jsx(J,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.openCliproxyCursor")]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(pe,{icon:As,label:s("cursorPage.integration"),ok:!!r?.enabled,detail:r?.enabled?s("cursorPage.enabled"):s("cursorPage.disabled")}),e.jsx(pe,{icon:z,label:s("cursorPage.authentication"),ok:!!(r?.authenticated&&!r?.token_expired),detail:r?.authenticated?r?.token_expired?s("cursorPage.expired"):r.auth_method??s("cursorPage.connected"):s("cursorPage.notConnected")}),e.jsx(pe,{icon:Ds,label:s("cursorPage.daemon"),ok:!!r?.daemon_running,detail:r?.daemon_running?s("cursorPage.running"):s("cursorPage.stopped")})]}),e.jsxs("div",{className:"rounded-md border bg-background/80 p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(xe,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:s("cursorPage.liveProbe")})]}),e.jsx(M,{variant:P?"outline":"secondary",className:V(P?.ok&&"border-green-500/40 text-green-600 dark:text-green-300",P&&!P.ok&&"border-red-500/40 text-red-600 dark:text-red-300"),children:P?P.ok?s("cursorPage.probeSucceeded"):s("cursorPage.probeFailed"):s("cursorPage.probeNotRun")})]}),P?e.jsxs("div",{className:"space-y-1 text-xs",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-muted-foreground",children:s("cursorPage.probeStage")}),e.jsx("span",{className:"font-mono uppercase",children:P.stage})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-muted-foreground",children:s("cursorPage.probeHttpStatus")}),e.jsx("span",{className:"font-mono",children:P.status})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-muted-foreground",children:s("cursorPage.probeDuration")}),e.jsxs("span",{className:"font-mono",children:[P.duration_ms," ms"]})]}),P.model?e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-muted-foreground",children:s("cursorPage.probeModel")}),e.jsx("span",{className:"font-mono text-[11px] text-right break-all",children:P.model})]}):null,e.jsxs("div",{className:"space-y-1 pt-1",children:[e.jsx("span",{className:"text-muted-foreground",children:s("cursorPage.probeMessage")}),e.jsx("p",{className:"text-[11px] leading-relaxed break-words",children:P.message})]})]}):e.jsx("p",{className:"text-xs text-muted-foreground",children:s("cursorPage.probeNotRun")}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:s("cursorPage.probeLocalReadinessHint")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:s("cursorPage.actions")}),r?.enabled?e.jsxs(h,{variant:"outline",size:"sm",className:"w-full",onClick:()=>Me(!1),disabled:p,children:[e.jsx(Ie,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.disableIntegration")]}):e.jsxs(h,{size:"sm",className:"w-full",onClick:()=>Me(!0),disabled:p,children:[e.jsx(Ms,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.enableIntegration")]}),e.jsxs(h,{variant:"outline",size:"sm",className:"w-full",onClick:as,disabled:be,children:[be?e.jsx(F,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(z,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.autoDetectAuth")]}),e.jsxs(h,{variant:"outline",size:"sm",className:"w-full",onClick:()=>K(!0),children:[e.jsx(z,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.manualAuthImport")]}),e.jsxs(h,{variant:"outline",size:"sm",className:"w-full",onClick:os,disabled:W,children:[W?e.jsx(F,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(xe,{className:"w-3.5 h-3.5 mr-1.5"}),s(W?"cursorPage.probing":P?"cursorPage.rerunLiveProbe":"cursorPage.runLiveProbe")]}),r?.daemon_running?e.jsxs(h,{variant:"outline",size:"sm",className:"w-full",onClick:ns,disabled:Ne,children:[Ne?e.jsx(F,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(Ie,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.stopDaemon")]}):e.jsxs(h,{size:"sm",className:"w-full",onClick:rs,disabled:!Ye,children:[Ue?e.jsx(F,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(Ts,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.startDaemon")]})]})]})}),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:s("cursorPage.port")}),e.jsx("span",{children:r?.port??c?.port??Ee})]})})]}),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:s("cursorPage.configuration")}),m&&e.jsx(M,{variant:"outline",className:"text-xs",children:"cursor.settings.json"})]}),m&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[s("cursorPage.lastModified")," ",m.exists?new Date(m.mtime).toLocaleString():s("cursorPage.neverSaved")]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(h,{variant:"ghost",size:"sm",onClick:ls,disabled:u||je,"aria-label":s("cursorPage.refreshConfiguration"),title:s("cursorPage.refreshConfiguration"),children:e.jsx(Le,{className:V("w-4 h-4",(u||je)&&"animate-spin")})}),e.jsx(h,{size:"sm",onClick:cs,disabled:p||Pe||!q||!We,children:p||Pe?e.jsxs(e.Fragment,{children:[e.jsx(F,{className:"w-4 h-4 mr-1 animate-spin"}),s("cursorPage.saving")]}):e.jsxs(e.Fragment,{children:[e.jsx(Rs,{className:"w-4 h-4 mr-1"}),s("cursorPage.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(hs,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(fs,{className:"w-full",children:[e.jsx(ue,{value:"config",className:"flex-1",children:s("cursorPage.modelConfig")}),e.jsx(ue,{value:"settings",className:"flex-1",children:s("cursorPage.settings")}),e.jsx(ue,{value:"info",className:"flex-1",children:s("cursorPage.info")})]})}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden flex flex-col",children:[e.jsx(me,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(U,{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(Fs,{className:"w-4 h-4"}),s("cursorPage.presets")]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:s("cursorPage.presetsDesc")}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(h,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>le("codex53"),disabled:l||n.length===0,title:"OpenAI-only mapping: GPT-5.3 Codex / Codex Max / GPT-5 Mini",children:[e.jsx(J,{className:"w-3 h-3"}),"GPT-5.3 Codex"]}),e.jsxs(h,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>le("claude46"),disabled:l||n.length===0,title:"Claude-first mapping: Opus 4.6 / Sonnet 4.5 / Haiku 4.5",children:[e.jsx(J,{className:"w-3 h-3"}),"Claude 4.6"]}),e.jsxs(h,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>le("gemini3"),disabled:l||n.length===0,title:"Gemini-first mapping: Gemini 3 Pro + Gemini 3 Flash",children:[e.jsx(J,{className:"w-3 h-3"}),"Gemini 3 Pro"]})]})]}),e.jsx(Ss,{}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-2",children:s("cursorPage.modelMapping")}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:s("cursorPage.modelMappingDesc")}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(H,{label:s("cursorPage.defaultModel"),description:s("cursorPage.defaultModelDesc"),value:w,models:G,disabled:l,onChange:a=>{C(o=>({...o,model:a}))}}),e.jsx(H,{label:s("cursorPage.opusModel"),description:s("cursorPage.opusModelDesc"),value:ne,models:G,disabled:l,allowDefaultFallback:!0,onChange:a=>{C(o=>({...o,opus_model:a}))}}),e.jsx(H,{label:s("cursorPage.sonnetModel"),description:s("cursorPage.sonnetModelDesc"),value:oe,models:G,disabled:l,allowDefaultFallback:!0,onChange:a=>{C(o=>({...o,sonnet_model:a}))}}),e.jsx(H,{label:s("cursorPage.haikuModel"),description:s("cursorPage.haikuModelDesc"),value:ie,models:G,disabled:l,allowDefaultFallback:!0,onChange:a=>{C(o=>({...o,haiku_model:a}))}})]})]})]})})}),e.jsx(me,{value:"settings",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(U,{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:s("cursorPage.runtimeSettings")}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(L,{htmlFor:"cursor-port",className:"text-xs",children:s("cursorPage.port")}),e.jsx(ge,{id:"cursor-port",type:"number",min:1,max:65535,className:"max-w-[150px] h-8",value:_e,onChange:a=>{C(o=>({...o,port:a.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(L,{htmlFor:"cursor-auto-start",className:"text-xs",children:s("cursorPage.autoStartDaemon")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:s("cursorPage.autoStartDesc")})]}),e.jsx(Fe,{id:"cursor-auto-start",checked:te,onCheckedChange:a=>{C(o=>({...o,auto_start:a}))}})]}),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(L,{htmlFor:"cursor-ghost-mode",className:"text-xs",children:s("cursorPage.ghostMode")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:s("cursorPage.ghostModeDesc")})]}),e.jsx(Fe,{id:"cursor-ghost-mode",checked:re,onCheckedChange:a=>{C(o=>({...o,ghost_mode:a}))}})]})]})})})}),e.jsx(me,{value:"info",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(U,{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:s("cursorPage.provider")}),e.jsx("span",{className:"font-mono",children:"Cursor IDE (Legacy)"})]}),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:s("cursorPage.filePath")}),e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:m?.path??"~/.ccs/cursor.settings.json"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Legacy bridge 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:s("cursorPage.availableModels")}),l?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(F,{className:"w-4 h-4 animate-spin"}),s("cursorPage.loadingModels")]}):n.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:s("cursorPage.noModels")}):e.jsx("div",{className:"space-y-2",children:n.map(a=>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:a.id}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[a.name," • ",a.provider]})]}),a.id===d&&e.jsx(M,{children:s("cursorPage.default")})]},a.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(xe,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:s("cursorPage.rawConfiguration")})]}),e.jsx(ps,{rawJsonContent:ce,isRawJsonValid:De,rawJsonEdits:I?ve:null,rawSettingsEnv:m?.settings?.env,onChange:a=>{ee(!0),He(a)}})]})]})]})})]}),e.jsx(js,{open:Ve,onOpenChange:K,children:e.jsxs(Ps,{children:[e.jsxs(bs,{children:[e.jsx(ys,{children:s("cursorPage.manualImportTitle")}),e.jsx(Ns,{children:s("cursorPage.manualImportDesc")})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(L,{htmlFor:"cursor-manual-token",children:s("cursorPage.accessToken")}),e.jsx(ge,{id:"cursor-manual-token",value:se,onChange:a=>we(a.target.value),placeholder:s("cursorPage.accessTokenPlaceholder")})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(L,{htmlFor:"cursor-manual-machine-id",children:s("cursorPage.machineId")}),e.jsx(ge,{id:"cursor-manual-machine-id",value:ae,onChange:a=>Ce(a.target.value),placeholder:s("cursorPage.machineIdPlaceholder")})]})]}),e.jsxs(vs,{children:[e.jsx(h,{variant:"outline",onClick:()=>K(!1),children:s("cursorPage.cancel")}),e.jsxs(h,{onClick:ts,disabled:ye,children:[ye?e.jsx(F,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(z,{className:"w-4 h-4 mr-2"}),s("cursorPage.import")]})]})]})})]})}export{da as CursorPage};
|
|
1
|
+
import{j as e}from"./radix-ui-nu4wz29m.js";import{r as b,e as gs}from"./react-vendor-Bjx91N7w.js";import{t as i}from"./notifications-B4_o8bcr.js";import{bf as y,bg as xs,a as Oe,B as M,d as h,c as V,n as U,Q as hs,R as fs,U as ue,V as me,L,I as ge,aI as Fe,bl as ps,ah as js,ai as Ps,aj as bs,ak as ys,al as Ns,aD as vs,bh as ws}from"./index-BJl0cazY.js";import{a as Cs,u as B,b as R}from"./tanstack-bhJxV1h8.js";import{D as Ee}from"./default-ports-1QQSffYX.js";import{S as Ss}from"./separator-Ct6a34bG.js";import{S as ks}from"./searchable-select-DCOfw3f0.js";import{R as Le,T as _s,K as z,Z as J,ai as As,ae as Ds,ax as xe,aQ as Ie,aP as Ms,L as F,J as Ts,au as Rs,aa as Fs,x as Ls,I as Is}from"./icons-DIVjDO-z.js";import"./utils-CzKF5WmX.js";import"./form-utils-CuHzLhJZ.js";import"./code-highlight-D4E79GKQ.js";const N="/legacy/cursor";function Os(s){if(!s||typeof s!="object")return!1;const t=s;return typeof t.message=="string"&&typeof t.stage=="string"&&typeof t.status=="number"&&typeof t.duration_ms=="number"&&typeof t.ok=="boolean"}function Es(s){if(!s||typeof s!="object"||!("error"in s))return null;const t=s;return typeof t.error=="string"?t.error:null}async function zs(){const s=await fetch(y(`${N}/status`));if(!s.ok)throw new Error("Failed to fetch cursor status");return s.json()}async function Ks(){const s=await fetch(y(`${N}/settings`));if(!s.ok)throw new Error("Failed to fetch cursor config");return s.json()}async function qs(){const s=await fetch(y(`${N}/models`));if(!s.ok)throw new Error("Failed to fetch cursor models");return s.json()}async function Gs(){const s=await fetch(y(`${N}/settings/raw`));if(!s.ok)throw new Error("Failed to fetch cursor raw settings");return s.json()}async function Qs(s){const t=await fetch(y(`${N}/settings`),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!t.ok)throw new Error("Failed to update cursor config");return t.json()}async function Us(s){const t=await fetch(y(`${N}/settings/raw`),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(t.status===409)throw new xs("Cursor raw settings changed externally");if(!t.ok)throw new Error("Failed to save cursor raw settings");return t.json()}async function Bs(){const s=await fetch(y(`${N}/auth/auto-detect`),{method:"POST"});if(!s.ok){const t=await s.json().catch(()=>({error:"Auto-detect failed"}));throw new Error(t.error||"Auto-detect failed")}return s.json()}async function Js(s){const t=await fetch(y(`${N}/auth/import`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!t.ok){const r=await t.json().catch(()=>({error:"Manual import failed"}));throw new Error(r.error||"Manual import failed")}return t.json()}async function $s(){const s=await fetch(y(`${N}/daemon/start`),{method:"POST"});if(!s.ok)throw new Error("Failed to start cursor daemon");return s.json()}async function Hs(){const s=await fetch(y(`${N}/daemon/stop`),{method:"POST"});if(!s.ok)throw new Error("Failed to stop cursor daemon");return s.json()}async function Vs(){const s=await fetch(y(`${N}/probe`),{method:"POST"}),t=await s.json().catch(()=>null);return Os(t)?t:{ok:!1,stage:"runtime",status:s.status,duration_ms:0,error_type:"runtime_error",message:Es(t)??"Failed to run live probe"}}function Ws(){const s=Cs(),t=B({queryKey:["cursor-status"],queryFn:zs,refetchInterval:5e3}),r=B({queryKey:["cursor-config"],queryFn:Ks}),u=B({queryKey:["cursor-models"],queryFn:qs}),x=B({queryKey:["cursor-raw-settings"],queryFn:Gs}),c=()=>{s.invalidateQueries({queryKey:["cursor-status"]}),s.invalidateQueries({queryKey:["cursor-config"]}),s.invalidateQueries({queryKey:["cursor-models"]}),s.invalidateQueries({queryKey:["cursor-raw-settings"]})},f=R({mutationFn:Qs,onSuccess:c}),g=R({mutationFn:Us,onSuccess:c}),p=R({mutationFn:Bs,onSuccess:c}),n=R({mutationFn:Js,onSuccess:c}),l=R({mutationFn:$s,onSuccess:c}),d=R({mutationFn:Hs,onSuccess:c}),m=R({mutationFn:Vs,onSettled:()=>{s.invalidateQueries({queryKey:["cursor-status"]}),s.invalidateQueries({queryKey:["cursor-models"]})}});return b.useMemo(()=>({status:t.data,statusLoading:t.isLoading,statusError:t.error,refetchStatus:t.refetch,config:r.data,configLoading:r.isLoading,refetchConfig:r.refetch,models:u.data?.models??[],currentModel:u.data?.current??null,modelsLoading:u.isLoading,rawSettings:x.data,rawSettingsLoading:x.isLoading,refetchRawSettings:x.refetch,updateConfig:f.mutate,updateConfigAsync:f.mutateAsync,isUpdatingConfig:f.isPending,saveRawSettings:g.mutate,saveRawSettingsAsync:g.mutateAsync,isSavingRawSettings:g.isPending,autoDetectAuth:p.mutate,autoDetectAuthAsync:p.mutateAsync,isAutoDetectingAuth:p.isPending,autoDetectAuthResult:p.data,importManualAuth:n.mutate,importManualAuthAsync:n.mutateAsync,isImportingManualAuth:n.isPending,manualAuthResult:n.data,startDaemon:l.mutate,startDaemonAsync:l.mutateAsync,isStartingDaemon:l.isPending,stopDaemon:d.mutate,stopDaemonAsync:d.mutateAsync,isStoppingDaemon:d.isPending,runProbe:m.mutate,runProbeAsync:m.mutateAsync,isRunningProbe:m.isPending,probeResult:m.data,resetProbe:m.reset}),[t.data,t.isLoading,t.error,t.refetch,r.data,r.isLoading,r.refetch,u.data,u.isLoading,x.data,x.isLoading,x.refetch,f.mutate,f.mutateAsync,f.isPending,g.mutate,g.mutateAsync,g.isPending,p.mutate,p.mutateAsync,p.isPending,p.data,n.mutate,n.mutateAsync,n.isPending,n.data,l.mutate,l.mutateAsync,l.isPending,d.mutate,d.mutateAsync,d.isPending,m.mutate,m.mutateAsync,m.isPending,m.data,m.reset])}function he(s,t){return JSON.stringify({enabled:s?.enabled??null,authenticated:s?.authenticated??null,token_expired:s?.token_expired??null,daemon_running:s?.daemon_running??null,port:s?.port??null,ghost_mode:s?.ghost_mode??null,auto_start:t?.auto_start??null,model:t?.model??null})}function $(s){return{port:String(s?.port??Ee),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 S(s,t,r){return s.find(x=>t.some(c=>c.test(x.id)))?.id??r}function fe(s){return s.toLowerCase().replace(/[^a-z0-9]/g,"")}function k(s,t,r){const u=new Set(t.map(fe)),x=s.find(f=>u.has(fe(f.id)));if(x)return x.id;const c=s.find(f=>u.has(fe(f.name)));return c?c.id:r}function Xs(s){try{const t=JSON.parse(s||"{}");return!t||typeof t!="object"||Array.isArray(t)?{isValid:!1,error:"Raw settings must be a JSON object"}:{isValid:!0,settings:t}}catch(t){return{isValid:!1,error:t.message||"Invalid JSON"}}}function H({label:s,description:t,value:r,models:u,disabled:x,allowDefaultFallback:c=!1,onChange:f}){const{t:g}=Oe(),p=r||(c?"__default":""),n=b.useMemo(()=>{const l=u.map(d=>({value:d.id,groupKey:"models",searchText:`${d.name||d.id} ${d.id}`,keywords:[d.provider],triggerContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:d.name||d.id}),d.provider&&e.jsx(M,{variant:"outline",className:"text-[9px] h-4 px-1 capitalize",children:d.provider})]}),itemContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate text-xs font-mono",children:d.name||d.id}),e.jsx(M,{variant:"outline",className:"text-[9px] h-4 px-1 capitalize",children:d.provider})]})}));return c?[{value:"__default",groupKey:"models",searchText:g("cursorPage.useDefaultModel"),triggerContent:e.jsx("span",{className:"truncate font-mono text-xs",children:g("cursorPage.useDefaultModel")}),itemContent:e.jsx("span",{children:g("cursorPage.useDefaultModel")})},...l]:l},[c,u,g]);return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx(L,{className:"text-xs font-medium",children:s}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:t})]}),e.jsx(ks,{value:p||void 0,onChange:l=>{if(c&&l==="__default"){f("");return}f(l)},disabled:x,placeholder:g("cursorPage.selectModel"),searchPlaceholder:g("searchableSelect.searchModels"),emptyText:g("searchableSelect.noResults"),triggerClassName:"h-9",groups:[{key:"models",label:g("cursorPage.availableModelCount",{count:u.length})}],options:n})]})}function pe({icon:s,label:t,ok:r,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:t})}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[r?e.jsx(Ls,{className:"h-4 w-4 text-green-500"}):e.jsx(Is,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:V("text-xs",r?"text-green-500":"text-muted-foreground"),title:u,children:u})]})]})}function da(){const{t:s}=Oe(),t=gs(),{status:r,statusLoading:u,refetchStatus:x,config:c,refetchConfig:f,updateConfigAsync:g,isUpdatingConfig:p,models:n,modelsLoading:l,currentModel:d,rawSettings:m,rawSettingsLoading:je,refetchRawSettings:ze,saveRawSettingsAsync:Ke,isSavingRawSettings:Pe,autoDetectAuthAsync:qe,isAutoDetectingAuth:be,importManualAuthAsync:Ge,isImportingManualAuth:ye,startDaemonAsync:Qe,isStartingDaemon:Ue,stopDaemonAsync:Be,isStoppingDaemon:Ne,runProbeAsync:Je,isRunningProbe:W,probeResult:X,resetProbe:$e}=Ws(),[T,Z]=b.useState(()=>$()),[v,Y]=b.useState(!1),[ve,He]=b.useState("{}"),[I,ee]=b.useState(!1),[Ve,K]=b.useState(!1),[se,we]=b.useState(""),[ae,Ce]=b.useState(""),[Se,ke]=b.useState(()=>X?he(r,c):null),_=$(c),_e=v?T.port:_.port,te=v?T.auto_start:_.auto_start,re=v?T.ghost_mode:_.ghost_mode,w=v?T.model:_.model,ne=v?T.opus_model:_.opus_model,oe=v?T.sonnet_model:_.sonnet_model,ie=v?T.haiku_model:_.haiku_model,ce=I?ve:JSON.stringify(m?.settings??{},null,2),Ae=!!m,O=b.useMemo(()=>Xs(ce),[ce]),De=O.isValid,q=v||I,We=!I||Ae&&De,Xe=he(r,c),P=X&&!q&&Se!==null&&Se===Xe?X:null,G=b.useMemo(()=>{const a=new Set,o=[...n].sort((D,de)=>D.name.localeCompare(de.name)),j=o.filter(D=>a.has(D.id)?!1:(a.add(D.id),!0));return w&&!o.some(D=>D.id===w)?[{id:w,name:w,provider:"custom"},...j]:j},[n,w]),C=a=>{Z(o=>a(v?o:_)),Y(!0)},A=()=>{$e(),ke(null)},Ze=(a=c)=>{Z($(a)),Y(!1)},Ye=!!(r?.enabled&&r?.authenticated&&!r?.token_expired),es=b.useMemo(()=>r?.enabled?e.jsx(M,{children:s("cursorPage.enabled")}):e.jsx(M,{variant:"secondary",children:s("cursorPage.disabled")}),[r?.enabled,s]),ss=async({suppressSuccessToast:a=!1}={})=>{const o=Number(_e);if(!Number.isInteger(o)||o<1||o>65535)return i.error(s("cursorPage.invalidPort")),!1;if(!w.trim())return i.error(s("cursorPage.defaultModelRequired")),!1;try{return await g({port:o,auto_start:te,ghost_mode:re,model:w,opus_model:ne||void 0,sonnet_model:oe||void 0,haiku_model:ie||void 0}),Y(!1),Z($({port:o,auto_start:te,ghost_mode:re,model:w,opus_model:ne||void 0,sonnet_model:oe||void 0,haiku_model:ie||void 0})),A(),a||i.success(s("cursorPage.savedConfig")),!0}catch(j){return i.error(j.message||s("cursorPage.failedSaveConfig")),!1}},le=a=>{if(l){i.error(s("cursorPage.modelsLoadingWait"));return}if(n.length===0){i.error(s("cursorPage.noModelsAvailable"));return}const o=w||d||n[0]?.id||"gpt-5.3-codex",j=k(n,["gpt-5.3-codex","gpt53codex","GPT-5.3 Codex"],S(n,[/gpt[-.]?5.*codex/i],o)),D=k(n,["gpt-5.1-codex-max","gpt51codexmax","GPT-5.1 Codex Max"],S(n,[/gpt[-.]?5.*codex.*max/i],j)),de=k(n,["gpt-5-fast","gpt5fast","GPT-5 Fast"],S(n,[/gpt[-.]?5.*fast/i],j)),ds=k(n,["gpt-5-mini","gpt5mini","GPT-5 Mini"],S(n,[/gpt[-.]?5.*mini/i],de)),Te=k(n,["claude-4.6-opus","claude46opus","Claude 4.6 Opus"],S(n,[/claude[-.]?4\.?6.*opus/i,/claude.*opus/i],j)),Re=k(n,["claude-4.5-sonnet","claude45sonnet","Claude 4.5 Sonnet"],S(n,[/claude[-.]?4\.?5.*sonnet/i,/claude.*sonnet/i],j)),us=k(n,["claude-4.5-haiku","claude45haiku","Claude 4.5 Haiku"],S(n,[/claude[-.]?4\.?5.*haiku/i,/haiku/i],Re)),Q=k(n,["gemini-3-pro","gemini3pro","Gemini 3 Pro"],S(n,[/gemini[-.]?3.*pro/i],j)),ms=k(n,["gemini-3-flash","gemini3flash","Gemini 3 Flash"],S(n,[/gemini[-.]?3.*flash/i,/gemini[-.]?2\.?5.*flash/i],Q));if(a==="codex53"){C(E=>({...E,model:j,opus_model:D,sonnet_model:j,haiku_model:ds})),i.success(s("cursorPage.appliedCodexPreset"));return}if(a==="claude46"){C(E=>({...E,model:Te,opus_model:Te,sonnet_model:Re,haiku_model:us})),i.success(s("cursorPage.appliedClaudePreset"));return}C(E=>({...E,model:Q,opus_model:Q,sonnet_model:Q,haiku_model:ms})),i.success(s("cursorPage.appliedGeminiPreset"))},Me=async a=>{try{await g({enabled:a}),A(),i.success(s(a?"cursorPage.integrationEnabled":"cursorPage.integrationDisabled"))}catch(o){i.error(o.message||s("cursorPage.failedUpdateIntegration"))}},as=async()=>{try{await qe(),A(),i.success(s("cursorPage.credentialsImported"))}catch(a){i.error(a.message||s("cursorPage.autoDetectFailed"))}},ts=async()=>{if(!se.trim()||!ae.trim()){i.error(s("cursorPage.manualRequired"));return}try{await Ge({accessToken:se.trim(),machineId:ae.trim()}),A(),i.success(s("cursorPage.credentialsImported")),K(!1),we(""),Ce("")}catch(a){i.error(a.message||s("cursorPage.manualImportFailed"))}},rs=async()=>{try{const a=await Qe();if(!a.success){i.error(a.error||s("cursorPage.failedStartDaemon"));return}A(),i.success(a.pid?s("cursorPage.daemonStartedWithPid",{pid:a.pid}):s("cursorPage.daemonStarted"))}catch(a){i.error(a.message||s("cursorPage.failedStartDaemon"))}},ns=async()=>{try{const a=await Be();if(!a.success){i.error(a.error||s("cursorPage.failedStopDaemon"));return}A(),i.success(s("cursorPage.daemonStopped"))}catch(a){i.error(a.message||s("cursorPage.failedStopDaemon"))}},os=async()=>{if(q){i.error(s("cursorPage.probeSaveFirst"));return}try{const a=await Je(),o=await x();if(ke(he(o.data??r,c)),a.ok){i.success(s("cursorPage.probeSucceeded"));return}i.error(a.message||s("cursorPage.probeFailed"))}catch(a){i.error(a.message||s("cursorPage.probeFailed"))}},is=async({suppressSuccessToast:a=!1}={})=>{if(!Ae)return i.error(s("cursorPage.rawLoading")),!1;if(!O.isValid||!O.settings)return i.error(O.error||s("cursorPage.invalidJson")),!1;try{return await Ke({settings:O.settings,expectedMtime:m?.mtime}),ee(!1),A(),a||i.success(s("cursorPage.rawSaved")),!0}catch(o){return ws(o)?i.error(s("cursorPage.rawChanged")):i.error(o.message||s("cursorPage.failedSaveRaw")),!1}},cs=async()=>{if(!q)return;const a=v,o=I;a&&!await ss({suppressSuccessToast:o})||o&&!await is({suppressSuccessToast:a})||a&&o&&i.success(s("cursorPage.savedAll"))},ls=async()=>{ee(!1),A();const[,a]=await Promise.all([x(),f(),ze()]);Ze(a.data??c)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden",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:s("cursorPage.title")}),e.jsx(M,{variant:"outline",className:"h-5 border-red-500/50 bg-red-500/10 px-1.5 text-[10px] font-semibold uppercase tracking-wide text-red-700 dark:text-red-300",children:s("cursorPage.deprecated")}),es]}),e.jsx(h,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>x(),disabled:u,"aria-label":s("cursorPage.refreshStatus"),title:s("cursorPage.refreshStatus"),children:e.jsx(Le,{className:V("w-4 h-4",u&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("cursorPage.subtitle")})]}),e.jsx(U,{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(_s,{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:s("cursorPage.unofficialTitle")})]}),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:s("cursorPage.unofficialItem1")}),e.jsx("li",{children:s("cursorPage.unofficialItem2")}),e.jsx("li",{children:s("cursorPage.unofficialItem3")})]})]}),e.jsxs("div",{className:"rounded-md border border-border/70 bg-background/90 p-3 space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:s("cursorPage.supportedPathTitle")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("cursorPage.supportedPathDesc")})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(h,{size:"sm",className:"w-full",onClick:()=>t("/cliproxy?provider=cursor&action=auth"),children:[e.jsx(z,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.startCliproxyAuth")]}),e.jsxs(h,{variant:"outline",size:"sm",className:"w-full",onClick:()=>t("/cliproxy?provider=cursor"),children:[e.jsx(J,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.openCliproxyCursor")]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(pe,{icon:As,label:s("cursorPage.integration"),ok:!!r?.enabled,detail:r?.enabled?s("cursorPage.enabled"):s("cursorPage.disabled")}),e.jsx(pe,{icon:z,label:s("cursorPage.authentication"),ok:!!(r?.authenticated&&!r?.token_expired),detail:r?.authenticated?r?.token_expired?s("cursorPage.expired"):r.auth_method??s("cursorPage.connected"):s("cursorPage.notConnected")}),e.jsx(pe,{icon:Ds,label:s("cursorPage.daemon"),ok:!!r?.daemon_running,detail:r?.daemon_running?s("cursorPage.running"):s("cursorPage.stopped")})]}),e.jsxs("div",{className:"rounded-md border bg-background/80 p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(xe,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:s("cursorPage.liveProbe")})]}),e.jsx(M,{variant:P?"outline":"secondary",className:V(P?.ok&&"border-green-500/40 text-green-600 dark:text-green-300",P&&!P.ok&&"border-red-500/40 text-red-600 dark:text-red-300"),children:P?P.ok?s("cursorPage.probeSucceeded"):s("cursorPage.probeFailed"):s("cursorPage.probeNotRun")})]}),P?e.jsxs("div",{className:"space-y-1 text-xs",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-muted-foreground",children:s("cursorPage.probeStage")}),e.jsx("span",{className:"font-mono uppercase",children:P.stage})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-muted-foreground",children:s("cursorPage.probeHttpStatus")}),e.jsx("span",{className:"font-mono",children:P.status})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-muted-foreground",children:s("cursorPage.probeDuration")}),e.jsxs("span",{className:"font-mono",children:[P.duration_ms," ms"]})]}),P.model?e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-muted-foreground",children:s("cursorPage.probeModel")}),e.jsx("span",{className:"font-mono text-[11px] text-right break-all",children:P.model})]}):null,e.jsxs("div",{className:"space-y-1 pt-1",children:[e.jsx("span",{className:"text-muted-foreground",children:s("cursorPage.probeMessage")}),e.jsx("p",{className:"text-[11px] leading-relaxed break-words",children:P.message})]})]}):e.jsx("p",{className:"text-xs text-muted-foreground",children:s("cursorPage.probeNotRun")}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:s("cursorPage.probeLocalReadinessHint")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:s("cursorPage.actions")}),r?.enabled?e.jsxs(h,{variant:"outline",size:"sm",className:"w-full",onClick:()=>Me(!1),disabled:p,children:[e.jsx(Ie,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.disableIntegration")]}):e.jsxs(h,{size:"sm",className:"w-full",onClick:()=>Me(!0),disabled:p,children:[e.jsx(Ms,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.enableIntegration")]}),e.jsxs(h,{variant:"outline",size:"sm",className:"w-full",onClick:as,disabled:be,children:[be?e.jsx(F,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(z,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.autoDetectAuth")]}),e.jsxs(h,{variant:"outline",size:"sm",className:"w-full",onClick:()=>K(!0),children:[e.jsx(z,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.manualAuthImport")]}),e.jsxs(h,{variant:"outline",size:"sm",className:"w-full",onClick:os,disabled:W,children:[W?e.jsx(F,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(xe,{className:"w-3.5 h-3.5 mr-1.5"}),s(W?"cursorPage.probing":P?"cursorPage.rerunLiveProbe":"cursorPage.runLiveProbe")]}),r?.daemon_running?e.jsxs(h,{variant:"outline",size:"sm",className:"w-full",onClick:ns,disabled:Ne,children:[Ne?e.jsx(F,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(Ie,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.stopDaemon")]}):e.jsxs(h,{size:"sm",className:"w-full",onClick:rs,disabled:!Ye,children:[Ue?e.jsx(F,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(Ts,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.startDaemon")]})]})]})}),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:s("cursorPage.port")}),e.jsx("span",{children:r?.port??c?.port??Ee})]})})]}),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:s("cursorPage.configuration")}),m&&e.jsx(M,{variant:"outline",className:"text-xs",children:"cursor.settings.json"})]}),m&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[s("cursorPage.lastModified")," ",m.exists?new Date(m.mtime).toLocaleString():s("cursorPage.neverSaved")]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(h,{variant:"ghost",size:"sm",onClick:ls,disabled:u||je,"aria-label":s("cursorPage.refreshConfiguration"),title:s("cursorPage.refreshConfiguration"),children:e.jsx(Le,{className:V("w-4 h-4",(u||je)&&"animate-spin")})}),e.jsx(h,{size:"sm",onClick:cs,disabled:p||Pe||!q||!We,children:p||Pe?e.jsxs(e.Fragment,{children:[e.jsx(F,{className:"w-4 h-4 mr-1 animate-spin"}),s("cursorPage.saving")]}):e.jsxs(e.Fragment,{children:[e.jsx(Rs,{className:"w-4 h-4 mr-1"}),s("cursorPage.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(hs,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(fs,{className:"w-full",children:[e.jsx(ue,{value:"config",className:"flex-1",children:s("cursorPage.modelConfig")}),e.jsx(ue,{value:"settings",className:"flex-1",children:s("cursorPage.settings")}),e.jsx(ue,{value:"info",className:"flex-1",children:s("cursorPage.info")})]})}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden flex flex-col",children:[e.jsx(me,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(U,{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(Fs,{className:"w-4 h-4"}),s("cursorPage.presets")]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:s("cursorPage.presetsDesc")}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(h,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>le("codex53"),disabled:l||n.length===0,title:"OpenAI-only mapping: GPT-5.3 Codex / Codex Max / GPT-5 Mini",children:[e.jsx(J,{className:"w-3 h-3"}),"GPT-5.3 Codex"]}),e.jsxs(h,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>le("claude46"),disabled:l||n.length===0,title:"Claude-first mapping: Opus 4.6 / Sonnet 4.5 / Haiku 4.5",children:[e.jsx(J,{className:"w-3 h-3"}),"Claude 4.6"]}),e.jsxs(h,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>le("gemini3"),disabled:l||n.length===0,title:"Gemini-first mapping: Gemini 3 Pro + Gemini 3 Flash",children:[e.jsx(J,{className:"w-3 h-3"}),"Gemini 3 Pro"]})]})]}),e.jsx(Ss,{}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-2",children:s("cursorPage.modelMapping")}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:s("cursorPage.modelMappingDesc")}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(H,{label:s("cursorPage.defaultModel"),description:s("cursorPage.defaultModelDesc"),value:w,models:G,disabled:l,onChange:a=>{C(o=>({...o,model:a}))}}),e.jsx(H,{label:s("cursorPage.opusModel"),description:s("cursorPage.opusModelDesc"),value:ne,models:G,disabled:l,allowDefaultFallback:!0,onChange:a=>{C(o=>({...o,opus_model:a}))}}),e.jsx(H,{label:s("cursorPage.sonnetModel"),description:s("cursorPage.sonnetModelDesc"),value:oe,models:G,disabled:l,allowDefaultFallback:!0,onChange:a=>{C(o=>({...o,sonnet_model:a}))}}),e.jsx(H,{label:s("cursorPage.haikuModel"),description:s("cursorPage.haikuModelDesc"),value:ie,models:G,disabled:l,allowDefaultFallback:!0,onChange:a=>{C(o=>({...o,haiku_model:a}))}})]})]})]})})}),e.jsx(me,{value:"settings",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(U,{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:s("cursorPage.runtimeSettings")}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(L,{htmlFor:"cursor-port",className:"text-xs",children:s("cursorPage.port")}),e.jsx(ge,{id:"cursor-port",type:"number",min:1,max:65535,className:"max-w-[150px] h-8",value:_e,onChange:a=>{C(o=>({...o,port:a.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(L,{htmlFor:"cursor-auto-start",className:"text-xs",children:s("cursorPage.autoStartDaemon")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:s("cursorPage.autoStartDesc")})]}),e.jsx(Fe,{id:"cursor-auto-start",checked:te,onCheckedChange:a=>{C(o=>({...o,auto_start:a}))}})]}),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(L,{htmlFor:"cursor-ghost-mode",className:"text-xs",children:s("cursorPage.ghostMode")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:s("cursorPage.ghostModeDesc")})]}),e.jsx(Fe,{id:"cursor-ghost-mode",checked:re,onCheckedChange:a=>{C(o=>({...o,ghost_mode:a}))}})]})]})})})}),e.jsx(me,{value:"info",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(U,{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:s("cursorPage.provider")}),e.jsx("span",{className:"font-mono",children:"Cursor IDE (Legacy)"})]}),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:s("cursorPage.filePath")}),e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:m?.path??"~/.ccs/cursor.settings.json"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Legacy bridge 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:s("cursorPage.availableModels")}),l?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(F,{className:"w-4 h-4 animate-spin"}),s("cursorPage.loadingModels")]}):n.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:s("cursorPage.noModels")}):e.jsx("div",{className:"space-y-2",children:n.map(a=>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:a.id}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[a.name," • ",a.provider]})]}),a.id===d&&e.jsx(M,{children:s("cursorPage.default")})]},a.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(xe,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:s("cursorPage.rawConfiguration")})]}),e.jsx(ps,{rawJsonContent:ce,isRawJsonValid:De,rawJsonEdits:I?ve:null,rawSettingsEnv:m?.settings?.env,onChange:a=>{ee(!0),He(a)}})]})]})]})})]}),e.jsx(js,{open:Ve,onOpenChange:K,children:e.jsxs(Ps,{children:[e.jsxs(bs,{children:[e.jsx(ys,{children:s("cursorPage.manualImportTitle")}),e.jsx(Ns,{children:s("cursorPage.manualImportDesc")})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(L,{htmlFor:"cursor-manual-token",children:s("cursorPage.accessToken")}),e.jsx(ge,{id:"cursor-manual-token",value:se,onChange:a=>we(a.target.value),placeholder:s("cursorPage.accessTokenPlaceholder")})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(L,{htmlFor:"cursor-manual-machine-id",children:s("cursorPage.machineId")}),e.jsx(ge,{id:"cursor-manual-machine-id",value:ae,onChange:a=>Ce(a.target.value),placeholder:s("cursorPage.machineIdPlaceholder")})]})]}),e.jsxs(vs,{children:[e.jsx(h,{variant:"outline",onClick:()=>K(!1),children:s("cursorPage.cancel")}),e.jsxs(h,{onClick:ts,disabled:ye,children:[ye?e.jsx(F,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(z,{className:"w-4 h-4 mr-2"}),s("cursorPage.import")]})]})]})})]})}export{da as CursorPage};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-nu4wz29m.js";import{r as Q}from"./react-vendor-Bjx91N7w.js";import{t as j}from"./notifications-B4_o8bcr.js";import{bf as X,bg as Ne,a as Z,C as y,j as v,k as b,B as C,b as N,r as q,s as H,t as W,v as Y,w as k,I as le,bm as we,bn as ae,bo as ke,Q as Se,R as Pe,U,V,n as A,bh as Ce,c as Ee}from"./index-BIF0Wvld.js";import{a as Te,u as ie,b as Ae}from"./tanstack-bhJxV1h8.js";import{a as Re}from"./raw-json-settings-editor-panel-Bx9NZXKo.js";import{ay as _e,aC as De,N as Oe,L as Me,S as Be,aY as Fe,x as Le,I as Ie,T as Ke,ae as Ue,ai as Ve,p as oe}from"./icons-Ce9So20E.js";import{S as R}from"./separator-oLpQ8QTJ.js";import"./utils-CzKF5WmX.js";import"./form-utils-CuHzLhJZ.js";import"./code-highlight-D4E79GKQ.js";function $e(s){try{const r=JSON.parse(s);return!r||typeof r!="object"||Array.isArray(r)?{settings:null,parseError:"JSON root must be an object."}:{settings:r,parseError:null}}catch(r){return{settings:null,parseError:r.message}}}async function ze(){const s=await fetch(X("/droid/diagnostics"));if(!s.ok)throw new Error("Failed to fetch Droid diagnostics");return s.json()}async function Je(){const s=await fetch(X("/droid/settings/raw"));if(!s.ok)throw new Error("Failed to fetch Droid raw settings");return s.json()}async function Qe(s){const r=await fetch(X("/droid/settings/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(r.status===409)throw new Ne("Droid raw settings changed externally");if(!r.ok){const n=await r.json().catch(()=>null);throw new Error(n?.error||"Failed to save Droid raw settings")}return r.json()}function qe(){const s=Te(),r=ie({queryKey:["droid-diagnostics"],queryFn:ze,refetchInterval:1e4}),n=ie({queryKey:["droid-raw-settings"],queryFn:Je}),i=Ae({mutationFn:Qe,onSuccess:(l,d)=>{s.setQueryData(["droid-raw-settings"],o=>{const t=o?.path??"~/.factory/settings.json",c=o?.resolvedPath??t,m=$e(d.rawText);return{path:t,resolvedPath:c,exists:!0,mtime:l.mtime,rawText:d.rawText,settings:m.settings,parseError:m.parseError}}),s.invalidateQueries({queryKey:["droid-diagnostics"]})}});return Q.useMemo(()=>({diagnostics:r.data,diagnosticsLoading:r.isLoading,diagnosticsError:r.error,refetchDiagnostics:r.refetch,rawSettings:n.data,rawSettingsLoading:n.isLoading,rawSettingsError:n.error,refetchRawSettings:n.refetch,saveRawSettings:i.mutate,saveRawSettingsAsync:i.mutateAsync,isSavingRawSettings:i.isPending}),[r.data,r.isLoading,r.error,r.refetch,n.data,n.isLoading,n.error,n.refetch,i.mutate,i.mutateAsync,i.isPending])}const He=["customModels","custom_models"],We={low:4e3,medium:12e3,high:3e4,max:5e4,xhigh:64e3},Ye=["low","medium","high","max","xhigh"];function p(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)}function h(s){return typeof s=="string"&&s.trim()?s.trim():null}function D(s){return typeof s=="number"&&Number.isFinite(s)?s:null}function G(s){if(!s)return"unknown";const r=s.toLowerCase();return r==="anthropic"?"anthropic":r==="openai"?"openai":r==="generic-chat-completion-api"?"generic-chat-completion-api":"unknown"}function Ge(s,r,n){return`${s}:${r}:${encodeURIComponent(String(n))}`}function Xe(s){const r=s.indexOf(":"),n=s.indexOf(":",r+1);if(r<=0||n<=r+1)return null;const i=s.slice(0,r),l=s.slice(r+1,n),d=s.slice(n+1);if(i!=="customModels"&&i!=="custom_models"||l!=="array"&&l!=="object")return null;const o=decodeURIComponent(d);if(l==="array"){const t=Number.parseInt(o,10);return!Number.isInteger(t)||t<0?null:{rootKey:i,locationType:l,locationKey:t}}return{rootKey:i,locationType:l,locationKey:o}}function Ze(s){return!s||s<=0?null:s<=4e3?"low":s<=12e3?"medium":s<=3e4?"high":s<=5e4?"max":"xhigh"}function es(s){return Object.prototype.hasOwnProperty.call(s,"extraArgs")?"extraArgs":Object.prototype.hasOwnProperty.call(s,"extra_args")?"extra_args":"extraArgs"}function de(s){return JSON.parse(JSON.stringify(s))}function ss(s){const r=[];for(const n of He){const i=s[n];if(Array.isArray(i)){i.forEach((l,d)=>{p(l)&&r.push({rootKey:n,locationType:"array",locationKey:d,entry:l})});continue}if(p(i))for(const[l,d]of Object.entries(i))p(d)&&r.push({rootKey:n,locationType:"object",locationKey:l,entry:d})}return r}function ce(s,r){const n=Xe(r);if(!n)return null;const i=s[n.rootKey];if(n.locationType==="array"){if(!Array.isArray(i))return null;const o=i[n.locationKey];if(!p(o))return null;const t=h(o.provider);return{entry:o,providerKind:G(t)}}if(!p(i))return null;const l=i[n.locationKey];if(!p(l))return null;const d=h(l.provider);return{entry:l,providerKind:G(d)}}function rs(s,r){const n=r.extraArgs??r.extra_args,i=p(n)?n:null;if(!i)return{effort:null,anthropicBudgetTokens:null};const l=h(i.reasoning_effort)??h(i.reasoningEffort),d=p(i.reasoning)?i.reasoning:null,o=d?h(d.effort):null,t=p(i.thinking)?i.thinking:null,c=t?h(t.type):null,m=t?D(t.budget_tokens)??D(t.budgetTokens):null;return s==="openai"?{effort:o??l,anthropicBudgetTokens:null}:s==="anthropic"?c==="enabled"?{effort:Ze(m)??"high",anthropicBudgetTokens:m}:{effort:o??l,anthropicBudgetTokens:m}:{effort:l??o,anthropicBudgetTokens:null}}function ts(s){if(!s)return null;const r=s.trim().toLowerCase();return!r||r==="default"||r==="unset"||r==="off"||r==="none"||r==="disabled"?null:r}function ue(s){const r=es(s),n=s[r],i=p(n)?{...n}:{};return{extraArgsKey:r,extraArgs:i}}function me(s,r,n){if(Object.keys(n).length===0){delete s[r];return}s[r]=n}function ns(s){return ss(s).map(({rootKey:r,locationType:n,locationKey:i,entry:l})=>{const d=h(l.displayName)??h(l.model_display_name)??"Unnamed model",o=h(l.model)??"",t=h(l.provider)??"unknown",c=G(t),m=rs(c,l);return{id:Ge(r,n,i),rootKey:r,locationType:n,locationKey:i,displayName:d,model:o,provider:t,providerKind:c,effort:m.effort,anthropicBudgetTokens:m.anthropicBudgetTokens}})}function as(s,r,n){const i=de(s),l=ce(i,r);if(!l)return null;const d=ts(n),{extraArgsKey:o,extraArgs:t}=ue(l.entry);if(l.providerKind==="openai")if(delete t.reasoning_effort,delete t.reasoningEffort,!d)delete t.reasoning;else{const c=p(t.reasoning)?t.reasoning:{};t.reasoning={...c,effort:d}}else if(l.providerKind==="anthropic")if(delete t.reasoning_effort,delete t.reasoningEffort,delete t.reasoning,!d)delete t.thinking;else{const c=p(t.thinking)?{...t.thinking}:{},m=D(c.budget_tokens)??D(c.budgetTokens);delete c.budgetTokens,t.thinking={...c,type:"enabled",budget_tokens:m??We[d]??3e4}}else delete t.reasoning,delete t.reasoningEffort,d?t.reasoning_effort=d:delete t.reasoning_effort;return me(l.entry,o,t),i}function is(s,r,n){const i=de(s),l=ce(i,r);if(!l||l.providerKind!=="anthropic")return null;const{extraArgsKey:d,extraArgs:o}=ue(l.entry),t=p(o.thinking)?{...o.thinking}:{};if(t.type="enabled",n===null)delete t.budget_tokens,delete t.budgetTokens;else{const c=Math.max(1024,Math.floor(n));t.budget_tokens=c,delete t.budgetTokens}return o.thinking=t,me(l.entry,d,o),i}const $="__unset__";function os(s){return s.providerKind==="openai"?"Writes: extraArgs.reasoning.effort":s.providerKind==="anthropic"?"Writes: extraArgs.thinking.{type,budget_tokens}":"Writes: extraArgs.reasoning_effort"}function ls({models:s,disabled:r,disabledReason:n,onEffortChange:i,onAnthropicBudgetChange:l}){const{t:d}=Z();return e.jsxs(y,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(b,{className:"text-base flex items-center gap-2",children:[e.jsx(_e,{className:"h-4 w-4"}),d("droidSettings.reasoningControls"),e.jsx(C,{variant:"outline",className:"text-[10px] font-normal",children:"customModels"})]})}),e.jsxs(N,{className:"space-y-3",children:[n&&e.jsx("p",{className:"text-xs text-amber-600",children:n}),s.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No BYOK custom models found in settings.json (`customModels` or `custom_models`)."}):e.jsx("div",{className:"space-y-2",children:s.map(o=>e.jsxs("div",{className:"rounded-md border p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:o.displayName}),e.jsx("p",{className:"text-[11px] font-mono text-muted-foreground truncate",children:o.model||"(missing model id)"})]}),e.jsx(C,{variant:"outline",className:"font-mono text-[10px] shrink-0",children:o.provider})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-medium",children:d("codex.reasoningEffortCapitalized")}),e.jsxs(q,{value:o.effort??$,onValueChange:t=>i(o.id,t===$?null:t),disabled:r,children:[e.jsx(H,{className:"h-8 text-xs",children:e.jsx(W,{placeholder:"Use provider default"})}),e.jsxs(Y,{children:[e.jsx(k,{value:$,children:"Use provider default"}),Ye.map(t=>e.jsx(k,{value:t,children:t},t))]})]})]}),o.providerKind==="anthropic"&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-medium",children:d("codex.thinkingBudgetTokens")}),e.jsx(le,{type:"number",min:1024,step:1024,value:o.anthropicBudgetTokens??"",placeholder:"auto",className:"h-8 text-xs",disabled:r,onChange:t=>{const c=t.target.value.trim();if(!c){l(o.id,null);return}const m=Number.parseInt(c,10);Number.isFinite(m)&&l(o.id,Math.max(1024,m))}})]})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:os(o)})]},o.id))})]})]})}const T="__unset__",ds=[{key:"reasoningEffort",label:"Reasoning Effort",description:"none | medium | high | max",options:[{value:"none",label:"none"},{value:"medium",label:"medium"},{value:"high",label:"high"},{value:"max",label:"max"}]},{key:"autonomyLevel",label:"Autonomy Level",description:"suggest | aggressive | full",options:[{value:"suggest",label:"suggest"},{value:"aggressive",label:"aggressive"},{value:"full",label:"full"}]},{key:"diffMode",label:"Diff Mode",description:"auto | none | inline | split",options:[{value:"auto",label:"auto"},{value:"none",label:"none"},{value:"inline",label:"inline"},{value:"split",label:"split"}]}],cs=[{key:"todoEnabled",label:"Todo Enabled"},{key:"todoAutoRefresh",label:"Todo Auto Refresh"},{key:"autoCompactEnabled",label:"Auto Compact Enabled"},{key:"soundEnabled",label:"Sound Enabled"}],us=[{key:"maxTurns",label:"Max Turns",min:1,step:1},{key:"maxToolCalls",label:"Max Tool Calls",min:1,step:1},{key:"autoCompactThreshold",label:"Auto Compact Threshold",min:1e3,step:1e3}];function ms(s){return s===!0?"true":s===!1?"false":T}function xs(s){return s==="true"?!0:s==="false"?!1:null}function gs({values:s,disabled:r,disabledReason:n,onEnumSettingChange:i,onBooleanSettingChange:l,onNumberSettingChange:d}){const{t:o}=Z();return e.jsxs(y,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(b,{className:"text-base flex items-center gap-2",children:[e.jsx(De,{className:"h-4 w-4"}),o("droidSettings.quickControls"),e.jsx(C,{variant:"outline",className:"text-[10px] font-normal",children:"settings.json"})]})}),e.jsxs(N,{className:"space-y-4",children:[n&&e.jsx("p",{className:"text-xs text-amber-600",children:n}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[ds.map(t=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:t.label}),e.jsxs(q,{value:s[t.key]??T,onValueChange:c=>i(t.key,c===T?null:c),disabled:r,children:[e.jsx(H,{className:"h-8 text-xs",children:e.jsx(W,{placeholder:o("codex.useDefault")})}),e.jsxs(Y,{children:[e.jsx(k,{value:T,children:o("codex.useDefault")}),t.options.map(c=>e.jsx(k,{value:c.value,children:c.label},c.value))]})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:t.description})]},t.key)),us.map(t=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:t.label}),e.jsx(le,{type:"number",min:t.min,step:t.step,value:s[t.key]??"",onChange:c=>{const m=c.target.value.trim();if(!m){d(t.key,null);return}const S=Number.parseInt(m,10);Number.isFinite(S)&&d(t.key,Math.max(t.min,S))},className:"h-8 text-xs",disabled:r})]},t.key)),cs.map(t=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:t.label}),e.jsxs(q,{value:ms(s[t.key]),onValueChange:c=>l(t.key,xs(c)),disabled:r,children:[e.jsx(H,{className:"h-8 text-xs",children:e.jsx(W,{placeholder:o("codex.useDefault")})}),e.jsxs(Y,{children:[e.jsx(k,{value:T,children:o("codex.useDefault")}),e.jsx(k,{value:"true",children:"true"}),e.jsx(k,{value:"false",children:"false"})]})]})]},t.key))]})]})]})}const fs=[{id:"droid-cli-overview",label:"Droid CLI Overview",url:"https://docs.factory.ai/cli/",description:"Primary entry docs for setup, auth, and core CLI usage."},{id:"droid-byok-overview",label:"BYOK Overview",url:"https://docs.factory.ai/cli/byok/overview/",description:"BYOK model/provider shape, provider values, and migration notes."},{id:"droid-settings-reference",label:"settings.json Reference",url:"https://docs.factory.ai/cli/configuration/settings/",description:"Supported settings keys, defaults, and allowed values."}],ps=[{provider:"anthropic",label:"Anthropic Messages API",apiFormat:"Messages API",url:"https://docs.anthropic.com/en/api/messages"},{provider:"openai",label:"OpenAI Responses API",apiFormat:"Responses API",url:"https://platform.openai.com/docs/api-reference/responses"},{provider:"generic-chat-completion-api",label:"OpenAI Chat Completions Spec",apiFormat:"Chat Completions API",url:"https://platform.openai.com/docs/api-reference/chat"}];function hs(s){const r=/https?:\/\/[^\s)]+/g,n=[];let i=0,l;for(;(l=r.exec(s))!==null;){const[d]=l,o=l.index;o>i&&n.push(s.slice(i,o)),n.push(e.jsx("a",{href:d,target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:d},`${d}-${o}`)),i=o+d.length}return i<s.length&&n.push(s.slice(i)),n.length>0?n:[s]}function js(s){return!s||!Number.isFinite(s)?"N/A":new Date(s).toLocaleString()}function ys(s){return!s||s<=0?"0 B":s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(2)} MB`}function vs(s){try{const r=JSON.parse(s);return!r||typeof r!="object"||Array.isArray(r)?{valid:!1,error:"JSON root must be an object."}:{valid:!0,value:r}}catch(r){return{valid:!1,error:r.message}}}function z(s){return typeof s=="string"?s:null}function J(s){return typeof s=="number"&&Number.isFinite(s)?s:null}function _(s){return typeof s=="boolean"?s:null}function g({label:s,value:r,mono:n=!1}){return e.jsxs("div",{className:"flex items-start justify-between gap-3 text-sm",children:[e.jsx("span",{className:"text-muted-foreground shrink-0",children:s}),e.jsx("span",{className:Ee("text-right break-all",n&&"font-mono text-xs"),children:r})]})}function _s(){const{t:s}=Z(),{diagnostics:r,diagnosticsLoading:n,diagnosticsError:i,refetchDiagnostics:l,rawSettings:d,rawSettingsLoading:o,refetchRawSettings:t,saveRawSettingsAsync:c,isSavingRawSettings:m}=qe(),[S,O]=Q.useState(null),M=d?.rawText??"{}",B=S??M,ee=S!==null&&S!==M,u=vs(B),F=u.valid?{valid:!0}:{valid:!1,error:u.error},se=x=>{if(x===M){O(null);return}O(x)},L=x=>{se(JSON.stringify(x,null,2)+`
|
|
1
|
+
import{j as e}from"./radix-ui-nu4wz29m.js";import{r as Q}from"./react-vendor-Bjx91N7w.js";import{t as j}from"./notifications-B4_o8bcr.js";import{bf as X,bg as Ne,a as Z,C as y,j as v,k as b,B as C,b as N,r as q,s as H,t as W,v as Y,w as k,I as le,bm as we,bn as ae,bo as ke,Q as Se,R as Pe,U,V,n as A,bh as Ce,c as Ee}from"./index-BJl0cazY.js";import{a as Te,u as ie,b as Ae}from"./tanstack-bhJxV1h8.js";import{a as Re}from"./raw-json-settings-editor-panel-BpXdUisD.js";import{ay as _e,aC as De,N as Oe,L as Me,S as Be,aY as Fe,x as Le,I as Ie,T as Ke,ae as Ue,ai as Ve,p as oe}from"./icons-DIVjDO-z.js";import{S as R}from"./separator-Ct6a34bG.js";import"./utils-CzKF5WmX.js";import"./form-utils-CuHzLhJZ.js";import"./code-highlight-D4E79GKQ.js";function $e(s){try{const r=JSON.parse(s);return!r||typeof r!="object"||Array.isArray(r)?{settings:null,parseError:"JSON root must be an object."}:{settings:r,parseError:null}}catch(r){return{settings:null,parseError:r.message}}}async function ze(){const s=await fetch(X("/droid/diagnostics"));if(!s.ok)throw new Error("Failed to fetch Droid diagnostics");return s.json()}async function Je(){const s=await fetch(X("/droid/settings/raw"));if(!s.ok)throw new Error("Failed to fetch Droid raw settings");return s.json()}async function Qe(s){const r=await fetch(X("/droid/settings/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(r.status===409)throw new Ne("Droid raw settings changed externally");if(!r.ok){const n=await r.json().catch(()=>null);throw new Error(n?.error||"Failed to save Droid raw settings")}return r.json()}function qe(){const s=Te(),r=ie({queryKey:["droid-diagnostics"],queryFn:ze,refetchInterval:1e4}),n=ie({queryKey:["droid-raw-settings"],queryFn:Je}),i=Ae({mutationFn:Qe,onSuccess:(l,d)=>{s.setQueryData(["droid-raw-settings"],o=>{const t=o?.path??"~/.factory/settings.json",c=o?.resolvedPath??t,m=$e(d.rawText);return{path:t,resolvedPath:c,exists:!0,mtime:l.mtime,rawText:d.rawText,settings:m.settings,parseError:m.parseError}}),s.invalidateQueries({queryKey:["droid-diagnostics"]})}});return Q.useMemo(()=>({diagnostics:r.data,diagnosticsLoading:r.isLoading,diagnosticsError:r.error,refetchDiagnostics:r.refetch,rawSettings:n.data,rawSettingsLoading:n.isLoading,rawSettingsError:n.error,refetchRawSettings:n.refetch,saveRawSettings:i.mutate,saveRawSettingsAsync:i.mutateAsync,isSavingRawSettings:i.isPending}),[r.data,r.isLoading,r.error,r.refetch,n.data,n.isLoading,n.error,n.refetch,i.mutate,i.mutateAsync,i.isPending])}const He=["customModels","custom_models"],We={low:4e3,medium:12e3,high:3e4,max:5e4,xhigh:64e3},Ye=["low","medium","high","max","xhigh"];function p(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)}function h(s){return typeof s=="string"&&s.trim()?s.trim():null}function D(s){return typeof s=="number"&&Number.isFinite(s)?s:null}function G(s){if(!s)return"unknown";const r=s.toLowerCase();return r==="anthropic"?"anthropic":r==="openai"?"openai":r==="generic-chat-completion-api"?"generic-chat-completion-api":"unknown"}function Ge(s,r,n){return`${s}:${r}:${encodeURIComponent(String(n))}`}function Xe(s){const r=s.indexOf(":"),n=s.indexOf(":",r+1);if(r<=0||n<=r+1)return null;const i=s.slice(0,r),l=s.slice(r+1,n),d=s.slice(n+1);if(i!=="customModels"&&i!=="custom_models"||l!=="array"&&l!=="object")return null;const o=decodeURIComponent(d);if(l==="array"){const t=Number.parseInt(o,10);return!Number.isInteger(t)||t<0?null:{rootKey:i,locationType:l,locationKey:t}}return{rootKey:i,locationType:l,locationKey:o}}function Ze(s){return!s||s<=0?null:s<=4e3?"low":s<=12e3?"medium":s<=3e4?"high":s<=5e4?"max":"xhigh"}function es(s){return Object.prototype.hasOwnProperty.call(s,"extraArgs")?"extraArgs":Object.prototype.hasOwnProperty.call(s,"extra_args")?"extra_args":"extraArgs"}function de(s){return JSON.parse(JSON.stringify(s))}function ss(s){const r=[];for(const n of He){const i=s[n];if(Array.isArray(i)){i.forEach((l,d)=>{p(l)&&r.push({rootKey:n,locationType:"array",locationKey:d,entry:l})});continue}if(p(i))for(const[l,d]of Object.entries(i))p(d)&&r.push({rootKey:n,locationType:"object",locationKey:l,entry:d})}return r}function ce(s,r){const n=Xe(r);if(!n)return null;const i=s[n.rootKey];if(n.locationType==="array"){if(!Array.isArray(i))return null;const o=i[n.locationKey];if(!p(o))return null;const t=h(o.provider);return{entry:o,providerKind:G(t)}}if(!p(i))return null;const l=i[n.locationKey];if(!p(l))return null;const d=h(l.provider);return{entry:l,providerKind:G(d)}}function rs(s,r){const n=r.extraArgs??r.extra_args,i=p(n)?n:null;if(!i)return{effort:null,anthropicBudgetTokens:null};const l=h(i.reasoning_effort)??h(i.reasoningEffort),d=p(i.reasoning)?i.reasoning:null,o=d?h(d.effort):null,t=p(i.thinking)?i.thinking:null,c=t?h(t.type):null,m=t?D(t.budget_tokens)??D(t.budgetTokens):null;return s==="openai"?{effort:o??l,anthropicBudgetTokens:null}:s==="anthropic"?c==="enabled"?{effort:Ze(m)??"high",anthropicBudgetTokens:m}:{effort:o??l,anthropicBudgetTokens:m}:{effort:l??o,anthropicBudgetTokens:null}}function ts(s){if(!s)return null;const r=s.trim().toLowerCase();return!r||r==="default"||r==="unset"||r==="off"||r==="none"||r==="disabled"?null:r}function ue(s){const r=es(s),n=s[r],i=p(n)?{...n}:{};return{extraArgsKey:r,extraArgs:i}}function me(s,r,n){if(Object.keys(n).length===0){delete s[r];return}s[r]=n}function ns(s){return ss(s).map(({rootKey:r,locationType:n,locationKey:i,entry:l})=>{const d=h(l.displayName)??h(l.model_display_name)??"Unnamed model",o=h(l.model)??"",t=h(l.provider)??"unknown",c=G(t),m=rs(c,l);return{id:Ge(r,n,i),rootKey:r,locationType:n,locationKey:i,displayName:d,model:o,provider:t,providerKind:c,effort:m.effort,anthropicBudgetTokens:m.anthropicBudgetTokens}})}function as(s,r,n){const i=de(s),l=ce(i,r);if(!l)return null;const d=ts(n),{extraArgsKey:o,extraArgs:t}=ue(l.entry);if(l.providerKind==="openai")if(delete t.reasoning_effort,delete t.reasoningEffort,!d)delete t.reasoning;else{const c=p(t.reasoning)?t.reasoning:{};t.reasoning={...c,effort:d}}else if(l.providerKind==="anthropic")if(delete t.reasoning_effort,delete t.reasoningEffort,delete t.reasoning,!d)delete t.thinking;else{const c=p(t.thinking)?{...t.thinking}:{},m=D(c.budget_tokens)??D(c.budgetTokens);delete c.budgetTokens,t.thinking={...c,type:"enabled",budget_tokens:m??We[d]??3e4}}else delete t.reasoning,delete t.reasoningEffort,d?t.reasoning_effort=d:delete t.reasoning_effort;return me(l.entry,o,t),i}function is(s,r,n){const i=de(s),l=ce(i,r);if(!l||l.providerKind!=="anthropic")return null;const{extraArgsKey:d,extraArgs:o}=ue(l.entry),t=p(o.thinking)?{...o.thinking}:{};if(t.type="enabled",n===null)delete t.budget_tokens,delete t.budgetTokens;else{const c=Math.max(1024,Math.floor(n));t.budget_tokens=c,delete t.budgetTokens}return o.thinking=t,me(l.entry,d,o),i}const $="__unset__";function os(s){return s.providerKind==="openai"?"Writes: extraArgs.reasoning.effort":s.providerKind==="anthropic"?"Writes: extraArgs.thinking.{type,budget_tokens}":"Writes: extraArgs.reasoning_effort"}function ls({models:s,disabled:r,disabledReason:n,onEffortChange:i,onAnthropicBudgetChange:l}){const{t:d}=Z();return e.jsxs(y,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(b,{className:"text-base flex items-center gap-2",children:[e.jsx(_e,{className:"h-4 w-4"}),d("droidSettings.reasoningControls"),e.jsx(C,{variant:"outline",className:"text-[10px] font-normal",children:"customModels"})]})}),e.jsxs(N,{className:"space-y-3",children:[n&&e.jsx("p",{className:"text-xs text-amber-600",children:n}),s.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No BYOK custom models found in settings.json (`customModels` or `custom_models`)."}):e.jsx("div",{className:"space-y-2",children:s.map(o=>e.jsxs("div",{className:"rounded-md border p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:o.displayName}),e.jsx("p",{className:"text-[11px] font-mono text-muted-foreground truncate",children:o.model||"(missing model id)"})]}),e.jsx(C,{variant:"outline",className:"font-mono text-[10px] shrink-0",children:o.provider})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-medium",children:d("codex.reasoningEffortCapitalized")}),e.jsxs(q,{value:o.effort??$,onValueChange:t=>i(o.id,t===$?null:t),disabled:r,children:[e.jsx(H,{className:"h-8 text-xs",children:e.jsx(W,{placeholder:"Use provider default"})}),e.jsxs(Y,{children:[e.jsx(k,{value:$,children:"Use provider default"}),Ye.map(t=>e.jsx(k,{value:t,children:t},t))]})]})]}),o.providerKind==="anthropic"&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-medium",children:d("codex.thinkingBudgetTokens")}),e.jsx(le,{type:"number",min:1024,step:1024,value:o.anthropicBudgetTokens??"",placeholder:"auto",className:"h-8 text-xs",disabled:r,onChange:t=>{const c=t.target.value.trim();if(!c){l(o.id,null);return}const m=Number.parseInt(c,10);Number.isFinite(m)&&l(o.id,Math.max(1024,m))}})]})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:os(o)})]},o.id))})]})]})}const T="__unset__",ds=[{key:"reasoningEffort",label:"Reasoning Effort",description:"none | medium | high | max",options:[{value:"none",label:"none"},{value:"medium",label:"medium"},{value:"high",label:"high"},{value:"max",label:"max"}]},{key:"autonomyLevel",label:"Autonomy Level",description:"suggest | aggressive | full",options:[{value:"suggest",label:"suggest"},{value:"aggressive",label:"aggressive"},{value:"full",label:"full"}]},{key:"diffMode",label:"Diff Mode",description:"auto | none | inline | split",options:[{value:"auto",label:"auto"},{value:"none",label:"none"},{value:"inline",label:"inline"},{value:"split",label:"split"}]}],cs=[{key:"todoEnabled",label:"Todo Enabled"},{key:"todoAutoRefresh",label:"Todo Auto Refresh"},{key:"autoCompactEnabled",label:"Auto Compact Enabled"},{key:"soundEnabled",label:"Sound Enabled"}],us=[{key:"maxTurns",label:"Max Turns",min:1,step:1},{key:"maxToolCalls",label:"Max Tool Calls",min:1,step:1},{key:"autoCompactThreshold",label:"Auto Compact Threshold",min:1e3,step:1e3}];function ms(s){return s===!0?"true":s===!1?"false":T}function xs(s){return s==="true"?!0:s==="false"?!1:null}function gs({values:s,disabled:r,disabledReason:n,onEnumSettingChange:i,onBooleanSettingChange:l,onNumberSettingChange:d}){const{t:o}=Z();return e.jsxs(y,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(b,{className:"text-base flex items-center gap-2",children:[e.jsx(De,{className:"h-4 w-4"}),o("droidSettings.quickControls"),e.jsx(C,{variant:"outline",className:"text-[10px] font-normal",children:"settings.json"})]})}),e.jsxs(N,{className:"space-y-4",children:[n&&e.jsx("p",{className:"text-xs text-amber-600",children:n}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[ds.map(t=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:t.label}),e.jsxs(q,{value:s[t.key]??T,onValueChange:c=>i(t.key,c===T?null:c),disabled:r,children:[e.jsx(H,{className:"h-8 text-xs",children:e.jsx(W,{placeholder:o("codex.useDefault")})}),e.jsxs(Y,{children:[e.jsx(k,{value:T,children:o("codex.useDefault")}),t.options.map(c=>e.jsx(k,{value:c.value,children:c.label},c.value))]})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:t.description})]},t.key)),us.map(t=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:t.label}),e.jsx(le,{type:"number",min:t.min,step:t.step,value:s[t.key]??"",onChange:c=>{const m=c.target.value.trim();if(!m){d(t.key,null);return}const S=Number.parseInt(m,10);Number.isFinite(S)&&d(t.key,Math.max(t.min,S))},className:"h-8 text-xs",disabled:r})]},t.key)),cs.map(t=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:t.label}),e.jsxs(q,{value:ms(s[t.key]),onValueChange:c=>l(t.key,xs(c)),disabled:r,children:[e.jsx(H,{className:"h-8 text-xs",children:e.jsx(W,{placeholder:o("codex.useDefault")})}),e.jsxs(Y,{children:[e.jsx(k,{value:T,children:o("codex.useDefault")}),e.jsx(k,{value:"true",children:"true"}),e.jsx(k,{value:"false",children:"false"})]})]})]},t.key))]})]})]})}const fs=[{id:"droid-cli-overview",label:"Droid CLI Overview",url:"https://docs.factory.ai/cli/",description:"Primary entry docs for setup, auth, and core CLI usage."},{id:"droid-byok-overview",label:"BYOK Overview",url:"https://docs.factory.ai/cli/byok/overview/",description:"BYOK model/provider shape, provider values, and migration notes."},{id:"droid-settings-reference",label:"settings.json Reference",url:"https://docs.factory.ai/cli/configuration/settings/",description:"Supported settings keys, defaults, and allowed values."}],ps=[{provider:"anthropic",label:"Anthropic Messages API",apiFormat:"Messages API",url:"https://docs.anthropic.com/en/api/messages"},{provider:"openai",label:"OpenAI Responses API",apiFormat:"Responses API",url:"https://platform.openai.com/docs/api-reference/responses"},{provider:"generic-chat-completion-api",label:"OpenAI Chat Completions Spec",apiFormat:"Chat Completions API",url:"https://platform.openai.com/docs/api-reference/chat"}];function hs(s){const r=/https?:\/\/[^\s)]+/g,n=[];let i=0,l;for(;(l=r.exec(s))!==null;){const[d]=l,o=l.index;o>i&&n.push(s.slice(i,o)),n.push(e.jsx("a",{href:d,target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:d},`${d}-${o}`)),i=o+d.length}return i<s.length&&n.push(s.slice(i)),n.length>0?n:[s]}function js(s){return!s||!Number.isFinite(s)?"N/A":new Date(s).toLocaleString()}function ys(s){return!s||s<=0?"0 B":s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(2)} MB`}function vs(s){try{const r=JSON.parse(s);return!r||typeof r!="object"||Array.isArray(r)?{valid:!1,error:"JSON root must be an object."}:{valid:!0,value:r}}catch(r){return{valid:!1,error:r.message}}}function z(s){return typeof s=="string"?s:null}function J(s){return typeof s=="number"&&Number.isFinite(s)?s:null}function _(s){return typeof s=="boolean"?s:null}function g({label:s,value:r,mono:n=!1}){return e.jsxs("div",{className:"flex items-start justify-between gap-3 text-sm",children:[e.jsx("span",{className:"text-muted-foreground shrink-0",children:s}),e.jsx("span",{className:Ee("text-right break-all",n&&"font-mono text-xs"),children:r})]})}function _s(){const{t:s}=Z(),{diagnostics:r,diagnosticsLoading:n,diagnosticsError:i,refetchDiagnostics:l,rawSettings:d,rawSettingsLoading:o,refetchRawSettings:t,saveRawSettingsAsync:c,isSavingRawSettings:m}=qe(),[S,O]=Q.useState(null),M=d?.rawText??"{}",B=S??M,ee=S!==null&&S!==M,u=vs(B),F=u.valid?{valid:!0}:{valid:!1,error:u.error},se=x=>{if(x===M){O(null);return}O(x)},L=x=>{se(JSON.stringify(x,null,2)+`
|
|
2
2
|
`)},I=(x,w)=>{if(!u.valid){j.error(s("droidPage.fixJsonBeforeQuickSettings"));return}const P={...u.value};w==null?delete P[x]:P[x]=w,L(P)},xe=u.valid?{reasoningEffort:z(u.value.reasoningEffort),autonomyLevel:z(u.value.autonomyLevel),diffMode:z(u.value.diffMode),maxTurns:J(u.value.maxTurns),maxToolCalls:J(u.value.maxToolCalls),autoCompactThreshold:J(u.value.autoCompactThreshold),todoEnabled:_(u.value.todoEnabled),todoAutoRefresh:_(u.value.todoAutoRefresh),autoCompactEnabled:_(u.value.autoCompactEnabled),soundEnabled:_(u.value.soundEnabled)}:{reasoningEffort:null,autonomyLevel:null,diffMode:null,maxTurns:null,maxToolCalls:null,autoCompactThreshold:null,todoEnabled:null,todoAutoRefresh:null,autoCompactEnabled:null,soundEnabled:null},ge=u.valid?ns(u.value):[],fe=async()=>{await Promise.all([l(),t()])},pe=async()=>{if(!F.valid){j.error(s("droidPage.invalidJson",{value:F.error}));return}try{await c({rawText:B,expectedMtime:d?.exists?d.mtime:void 0}),O(null),j.success(s("droidPage.saved"))}catch(x){Ce(x)?j.error(s("droidPage.changedExternally")):j.error(x.message||s("droidPage.failedSave"))}},re=r?.byok.customModels??[],te=Q.useMemo(()=>Object.entries(r?.byok.providerBreakdown??{}).sort((x,w)=>w[1]-x[1]),[r?.byok.providerBreakdown]),he=()=>{if(n)return e.jsxs("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:[e.jsx(Me,{className:"h-5 w-5 animate-spin mr-2"}),s("droidPage.loadingDiagnostics")]});if(i||!r)return e.jsx("div",{className:"flex h-full items-center justify-center text-destructive px-6 text-center",children:s("droidPage.failedDiagnostics")});const x=r.docsReference??{notes:[],links:[],providerDocs:[],providerValues:[],settingsHierarchy:[]},w=x.notes??[],P=x.links??[],ne=x.providerDocs??[],je=P.length>0?P:fs,ye=ne.length>0?ne:ps,ve=x.providerValues??[],be=x.settingsHierarchy??[],K="mt-0 h-full border-0 p-0 data-[state=inactive]:hidden";return e.jsxs(Se,{defaultValue:"byok",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(Pe,{className:"grid w-full grid-cols-3",children:[e.jsx(U,{value:"overview",children:s("droidPage.overview")}),e.jsx(U,{value:"byok",children:s("droidPage.byok")}),e.jsx(U,{value:"docs",children:s("droidPage.docs")})]})}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden px-4 pb-4 pt-3",children:[e.jsx(V,{value:"overview",className:K,children:e.jsx(A,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 pr-1",children:[e.jsxs(y,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(b,{className:"text-base flex items-center gap-2",children:[e.jsx(Be,{className:"h-4 w-4"}),s("droidPage.runtimeInstall")]})}),e.jsxs(N,{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:s("droidPage.status")}),e.jsx(C,{variant:r.binary.installed?"default":"secondary",children:r.binary.installed?s("droidPage.detected"):s("droidPage.notFound")})]}),e.jsx(g,{label:s("droidPage.detectionSource"),value:r.binary.source,mono:!0}),e.jsx(g,{label:s("droidPage.binaryPath"),value:r.binary.path||s("droidPage.notFound"),mono:!0}),e.jsx(g,{label:s("droidPage.installDirectory"),value:r.binary.installDir||"N/A",mono:!0}),e.jsx(g,{label:s("droidPage.version"),value:r.binary.version||"Unknown",mono:!0}),e.jsx(g,{label:s("droidPage.overridePath"),value:r.binary.overridePath||"Not set",mono:!0})]})]}),e.jsxs(y,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(b,{className:"text-base flex items-center gap-2",children:[e.jsx(Fe,{className:"h-4 w-4"}),s("droidPage.configFiles")]})}),e.jsx(N,{className:"space-y-3",children:[r.files.settings,r.files.legacyConfig].map(a=>e.jsxs("div",{className:"rounded-md border p-3 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"font-medium text-sm",children:a.label}),a.exists?e.jsx(Le,{className:"h-4 w-4 text-green-600"}):e.jsx(Ie,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(g,{label:s("droidPage.path"),value:a.path,mono:!0}),e.jsx(g,{label:s("droidPage.resolved"),value:a.resolvedPath,mono:!0}),e.jsx(g,{label:s("droidPage.size"),value:ys(a.sizeBytes)}),e.jsx(g,{label:s("droidPage.lastModified"),value:js(a.mtimeMs)}),a.parseError&&e.jsx("p",{className:"text-xs text-amber-600",children:s("droidPage.parseWarning",{value:a.parseError})}),a.readError&&e.jsx("p",{className:"text-xs text-destructive",children:s("droidPage.readWarning",{value:a.readError})})]},a.label))})]}),r.warnings.length>0&&e.jsxs(y,{className:"border-amber-200 bg-amber-50/50 dark:bg-amber-950/20",children:[e.jsx(v,{className:"pb-2",children:e.jsxs(b,{className:"text-base flex items-center gap-2",children:[e.jsx(Ke,{className:"h-4 w-4 text-amber-600"}),s("droidPage.warnings")]})}),e.jsx(N,{className:"space-y-1.5",children:r.warnings.map(a=>e.jsxs("p",{className:"text-sm text-amber-800 dark:text-amber-300",children:["- ",a]},a))})]})]})})}),e.jsx(V,{value:"byok",className:K,children:e.jsx(A,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 pr-1",children:[e.jsx(gs,{values:xe,disabled:o||!u.valid,disabledReason:u.valid?null:`Quick settings disabled: ${u.error}`,onEnumSettingChange:(a,f)=>{I(a,f)},onBooleanSettingChange:(a,f)=>{I(a,f)},onNumberSettingChange:(a,f)=>{I(a,f)}}),e.jsx(ls,{models:ge,disabled:o||!u.valid,disabledReason:u.valid?null:`${s("droidPage.byok")}: ${u.error}`,onEffortChange:(a,f)=>{if(!u.valid){j.error(s("droidPage.fixJsonBeforeReasoning"));return}const E=as(u.value,a,f);if(!E){j.error(s("droidPage.unableUpdateReasoning"));return}L(E)},onAnthropicBudgetChange:(a,f)=>{if(!u.valid){j.error(s("droidPage.fixJsonBeforeBudget"));return}const E=is(u.value,a,f);if(!E){j.error(s("droidPage.anthropicOnlyBudget"));return}L(E)}}),e.jsxs(y,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(b,{className:"text-base flex items-center gap-2",children:[e.jsx(Ue,{className:"h-4 w-4"}),s("droidPage.byokSummary")]})}),e.jsxs(N,{className:"space-y-2",children:[e.jsx(g,{label:s("droidPage.activeModelSelector"),value:r.byok.activeModelSelector||"Not set",mono:!0}),e.jsx(g,{label:s("droidPage.customModels"),value:String(r.byok.customModelCount)}),e.jsx(g,{label:s("droidPage.ccsManaged"),value:String(r.byok.ccsManagedCount)}),e.jsx(g,{label:s("droidPage.userManaged"),value:String(r.byok.userManagedCount)}),e.jsx(g,{label:s("droidPage.malformedEntries"),value:String(r.byok.invalidModelEntryCount)}),e.jsx(R,{}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:s("droidPage.providers")}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[te.length===0&&e.jsx(C,{variant:"secondary",className:"font-mono",children:s("droidPage.none")}),te.map(([a,f])=>e.jsxs(C,{variant:"outline",className:"font-mono text-xs",children:[a,": ",f]},a))]})]})]})]}),e.jsxs(y,{children:[e.jsx(v,{className:"pb-2",children:e.jsx(b,{className:"text-base",children:s("droidPage.customModelsTitle")})}),e.jsx(N,{children:e.jsxs("div",{className:"rounded-md border overflow-hidden",children:[e.jsxs("div",{className:"grid grid-cols-[2fr_1fr_2fr] bg-muted/40 px-3 py-2 text-xs font-medium",children:[e.jsx("span",{children:s("droidPage.modelName")}),e.jsx("span",{children:s("droidPage.provider")}),e.jsx("span",{children:s("droidPage.baseUrl")})]}),e.jsx(A,{className:"h-52",children:e.jsxs("div",{className:"divide-y",children:[re.length===0&&e.jsx("div",{className:"px-3 py-4 text-xs text-muted-foreground",children:s("droidPage.noCustomModels")}),re.map(a=>e.jsxs("div",{className:"grid grid-cols-[2fr_1fr_2fr] gap-2 px-3 py-2 text-xs",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:a.displayName}),e.jsx("p",{className:"text-muted-foreground font-mono truncate",children:a.model})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate",children:a.provider}),e.jsx("p",{className:"text-muted-foreground",children:a.apiKeyPreview||"no-key"})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate",title:a.baseUrl,children:a.host||a.baseUrl}),e.jsx("p",{className:"text-muted-foreground font-mono truncate",children:a.baseUrl})]})]},`${a.displayName}-${a.model}-${a.baseUrl}`))]})})]})})]})]})})}),e.jsx(V,{value:"docs",className:K,children:e.jsx(A,{className:"h-full",children:e.jsx("div",{className:"space-y-4 pr-1",children:e.jsxs(y,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(b,{className:"text-base flex items-center gap-2",children:[e.jsx(Ve,{className:"h-4 w-4"}),s("droidPage.docsAlignedNotes")]})}),e.jsxs(N,{className:"space-y-2 text-sm",children:[w.map((a,f)=>e.jsxs("p",{className:"text-muted-foreground",children:["- ",hs(a)]},`${f}-${a}`)),e.jsx(R,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:s("droidPage.factoryDocs")}),e.jsx("div",{className:"space-y-1.5",children:je.map(a=>e.jsxs("a",{href:a.url,target:"_blank",rel:"noreferrer",className:"block rounded-md border px-2.5 py-2 transition-colors hover:bg-muted/50",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-xs font-medium",children:a.label}),e.jsx(oe,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),e.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:a.description}),e.jsx("p",{className:"mt-1 break-all font-mono text-[11px] text-muted-foreground/90 underline underline-offset-2",children:a.url})]},a.id))})]}),e.jsx(R,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:s("droidPage.providerFactCheckDocs")}),e.jsx("div",{className:"space-y-1.5",children:ye.map(a=>e.jsxs("a",{href:a.url,target:"_blank",rel:"noreferrer",className:"block rounded-md border px-2.5 py-2 transition-colors hover:bg-muted/50",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-xs font-medium",children:a.label}),e.jsx(oe,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),e.jsxs("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:["provider: ",a.provider," | format: ",a.apiFormat]}),e.jsx("p",{className:"mt-1 break-all font-mono text-[11px] text-muted-foreground/90 underline underline-offset-2",children:a.url})]},`${a.provider}-${a.url}`))})]}),e.jsx(R,{}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("droidPage.providerValues",{value:ve.join(", ")})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("droidPage.settingsHierarchy",{value:be.join(" -> ")})})]})]})})})})]})]})};return e.jsx("div",{className:"h-full min-h-0 overflow-hidden",children:e.jsxs(we,{direction:"horizontal",className:"h-full",children:[e.jsx(ae,{defaultSize:45,minSize:35,children:e.jsx("div",{className:"h-full border-r bg-muted/20",children:he()})}),e.jsx(ke,{className:"w-2 bg-border hover:bg-primary/20 transition-colors cursor-col-resize flex items-center justify-center group",children:e.jsx(Oe,{className:"w-3 h-3 text-muted-foreground group-hover:text-primary"})}),e.jsx(ae,{defaultSize:55,minSize:35,children:e.jsx(Re,{title:s("droidPage.settingsTitle"),pathLabel:d?.path||"~/.factory/settings.json",loading:o,parseWarning:d?.parseError,value:B,dirty:ee,saving:m,saveDisabled:!ee||m||o||!F.valid,onChange:x=>{se(x)},onSave:pe,onRefresh:fe})})]})})}export{_s as DroidPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-nu4wz29m.js";import{r as g}from"./react-vendor-Bjx91N7w.js";import{by as C,bz as w,a as G,bA as y,bi as k,bk as S,n as R,aI as A,d as f,I as j}from"./index-
|
|
1
|
+
import{j as e}from"./radix-ui-nu4wz29m.js";import{r as g}from"./react-vendor-Bjx91N7w.js";import{by as C,bz as w,a as G,bA as y,bi as k,bk as S,n as R,aI as A,d as f,I as j}from"./index-BJl0cazY.js";import{R as N,w as D,x as I,at as L,a9 as T}from"./icons-DIVjDO-z.js";import"./tanstack-bhJxV1h8.js";import"./notifications-B4_o8bcr.js";import"./utils-CzKF5WmX.js";import"./form-utils-CuHzLhJZ.js";import"./code-highlight-D4E79GKQ.js";function _(){const{state:s}=C(),n=w(),[o,r]=g.useState(""),[c,m]=g.useState(""),b=g.useCallback(async()=>{try{n.setGlobalEnvLoading(!0),n.setGlobalEnvError(null);const a=await fetch("/api/global-env");if(!a.ok)throw new Error("Failed to load Global Env config");const l=await a.json();n.setGlobalEnvConfig(l)}catch(a){n.setGlobalEnvError(a.message)}finally{n.setGlobalEnvLoading(!1)}},[n]),i=g.useCallback(async a=>{const l=s.globalEnvConfig;if(!l)return;const x={...l,...a};n.setGlobalEnvConfig(x);try{n.setGlobalEnvSaving(!0),n.setGlobalEnvError(null);const d=await fetch("/api/global-env",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(x)});if(!d.ok){const h=await d.json();throw new Error(h.error||"Failed to save")}const v=await d.json();n.setGlobalEnvConfig(v.config),n.setGlobalEnvSuccess(!0),setTimeout(()=>n.setGlobalEnvSuccess(!1),1500)}catch(d){n.setGlobalEnvConfig(l),n.setGlobalEnvError(d.message)}finally{n.setGlobalEnvSaving(!1)}},[s.globalEnvConfig,n]),E=g.useCallback(()=>{if(!o.trim()||!s.globalEnvConfig)return;const a={...s.globalEnvConfig.env,[o.trim()]:c};i({env:a}),r(""),m("")},[o,c,s.globalEnvConfig,i]),u=g.useCallback(a=>{if(!s.globalEnvConfig)return;const l={...s.globalEnvConfig.env};delete l[a],i({env:l})},[s.globalEnvConfig,i]);return{config:s.globalEnvConfig,loading:s.globalEnvLoading,saving:s.globalEnvSaving,error:s.globalEnvError,success:s.globalEnvSuccess,newEnvKey:o,setNewEnvKey:r,newEnvValue:c,setNewEnvValue:m,fetchConfig:b,saveConfig:i,addEnvVar:E,removeEnvVar:u}}function Y(){const{t:s}=G(),{config:n,loading:o,saving:r,error:c,success:m,newEnvKey:b,setNewEnvKey:i,newEnvValue:E,setNewEnvValue:u,fetchConfig:a,saveConfig:l,addEnvVar:x,removeEnvVar:d}=_(),{fetchRawConfig:v}=y();g.useEffect(()=>{a(),v()},[a,v]);const h=()=>{l({enabled:!n?.enabled})};return o?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(N,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:s("settings.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 ${c||m?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[c&&e.jsxs(k,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(D,{className:"h-4 w-4"}),e.jsx(S,{children:c})]}),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(I,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:s("settings.saved")})]})]}),e.jsx(R,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("settingsGlobalEnv.description")}),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?.enabled?s("settingsGlobalEnv.enabled"):s("settingsGlobalEnv.disabled")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n?.enabled?s("settingsGlobalEnv.enabledDesc"):s("settingsGlobalEnv.disabledDesc")})]}),e.jsx(A,{checked:n?.enabled??!0,onCheckedChange:h})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:s("settingsGlobalEnv.envVars")}),n?.env&&Object.keys(n.env).length>0?e.jsx("div",{className:"space-y-2",children:Object.entries(n.env).map(([t,p])=>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:t}),e.jsx("span",{className:"text-muted-foreground",children:"="}),e.jsx("code",{className:"font-mono text-sm px-2 py-1 bg-muted rounded",children:p}),e.jsx(f,{variant:"ghost",size:"sm",onClick:()=>d(t),disabled:r,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"})})]},t))}):e.jsx("div",{className:"p-4 rounded-lg border border-dashed text-center text-muted-foreground",children:e.jsx("p",{children:s("settingsGlobalEnv.noneConfigured")})}),e.jsxs("div",{className:"p-4 rounded-lg border bg-muted/30",children:[e.jsx("h4",{className:"text-sm font-medium mb-3",children:s("settingsGlobalEnv.addNew")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{value:b,onChange:t=>i(t.target.value.toUpperCase()),placeholder:s("settingsGlobalEnv.keyName"),className:"flex-1 font-mono text-sm h-9",disabled:r}),e.jsx("span",{className:"flex items-center text-muted-foreground",children:"="}),e.jsx(j,{value:E,onChange:t=>u(t.target.value),placeholder:s("settingsGlobalEnv.value"),className:"flex-1 font-mono text-sm h-9",disabled:r}),e.jsxs(f,{size:"sm",onClick:x,disabled:r||!b.trim(),className:"h-9",children:[e.jsx(T,{className:"w-4 h-4 mr-1"}),s("settingsGlobalEnv.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:s("settingsGlobalEnv.quickAdd")}),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:t,value:p})=>!n?.env?.[t]&&e.jsxs(f,{variant:"outline",size:"sm",onClick:()=>{i(t),u(p)},className:"text-xs font-mono",children:["+ ",t]},t)),n?.env&&["DISABLE_BUG_COMMAND","DISABLE_ERROR_REPORTING","DISABLE_TELEMETRY"].every(t=>n.env[t])&&e.jsx("span",{className:"text-sm text-muted-foreground",children:s("settingsGlobalEnv.allConfigured")})]})]})]})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(f,{variant:"outline",size:"sm",onClick:()=>{a(),v()},disabled:o||r,className:"w-full",children:[e.jsx(N,{className:`w-4 h-4 mr-2 ${o?"animate-spin":""}`}),s("settings.refresh")]})})]})}export{Y as default};
|