@kaitranntt/ccs 7.69.1-dev.3 → 7.69.1-dev.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cliproxy/binary/version-cache.d.ts +10 -0
- package/dist/cliproxy/binary/version-cache.d.ts.map +1 -1
- package/dist/cliproxy/binary/version-cache.js +29 -7
- package/dist/cliproxy/binary/version-cache.js.map +1 -1
- package/dist/cliproxy/binary/version-checker.d.ts +14 -3
- package/dist/cliproxy/binary/version-checker.d.ts.map +1 -1
- package/dist/cliproxy/binary/version-checker.js +65 -36
- package/dist/cliproxy/binary/version-checker.js.map +1 -1
- package/dist/ui/assets/{accounts-DN0lP-yj.js → accounts-D7sfwYrK.js} +1 -1
- package/dist/ui/assets/{alert-dialog-BA39vaYL.js → alert-dialog-CuN8HTEx.js} +1 -1
- package/dist/ui/assets/{api-D2cjf1H4.js → api-CI8RoZ-m.js} +1 -1
- package/dist/ui/assets/{auth-section-BNX8_9MJ.js → auth-section-C49fRTna.js} +1 -1
- package/dist/ui/assets/{backups-section-Bt0FA5zl.js → backups-section-DeJGo6Co.js} +1 -1
- package/dist/ui/assets/{channels-FaDUjf3Y.js → channels-CEHW5H6N.js} +1 -1
- package/dist/ui/assets/{checkbox-DHF-UBrH.js → checkbox-DVHcE1RO.js} +1 -1
- package/dist/ui/assets/{claude-extension-D-skBToQ.js → claude-extension-CLmICnx_.js} +1 -1
- package/dist/ui/assets/{cliproxy-CD7z-_q8.js → cliproxy-BQuYNZ_b.js} +1 -1
- package/dist/ui/assets/{cliproxy-ai-providers-QSOOqh8F.js → cliproxy-ai-providers-Bjx7XtY6.js} +1 -1
- package/dist/ui/assets/{cliproxy-control-panel-D9dLU28p.js → cliproxy-control-panel-DoLho1iE.js} +1 -1
- package/dist/ui/assets/{codex-CHO5_hku.js → codex-BDfvFO8E.js} +1 -1
- package/dist/ui/assets/{confirm-dialog-BICDz_zm.js → confirm-dialog-D_5v8muu.js} +1 -1
- package/dist/ui/assets/{copilot-BnQrRCuJ.js → copilot-B4waN1q6.js} +1 -1
- package/dist/ui/assets/{cursor-CXopLKfC.js → cursor-DHHZs05u.js} +1 -1
- package/dist/ui/assets/{droid-CLFg9ELE.js → droid-CZePX0Pf.js} +1 -1
- package/dist/ui/assets/{globalenv-section-NPjCcYBN.js → globalenv-section-nQDFHMda.js} +1 -1
- package/dist/ui/assets/{health-B_3JpCrY.js → health-BfS7V7RZ.js} +1 -1
- package/dist/ui/assets/{index-BcUkpsGj.js → index-B9VMppQ3.js} +1 -1
- package/dist/ui/assets/{index-DNmWbKbN.js → index-BDfXfBTa.js} +3 -3
- package/dist/ui/assets/{index-BgGHTjTd.js → index-C5CFzca_.js} +1 -1
- package/dist/ui/assets/{index-BY2j-o67.js → index-CRiWOwLR.js} +1 -1
- package/dist/ui/assets/{index-B5Egq7qY.js → index-EboJtDBz.js} +1 -1
- package/dist/ui/assets/{index-DZddoGfE.js → index-yt8jgaSK.js} +1 -1
- package/dist/ui/assets/{logs-Bb1OVYeK.js → logs-GW0Oy6XF.js} +1 -1
- package/dist/ui/assets/{masked-input-b4-lEKNq.js → masked-input-D1Ilmeh7.js} +1 -1
- package/dist/ui/assets/{proxy-status-widget-s89zaj3X.js → proxy-status-widget-Bdh67BxQ.js} +1 -1
- package/dist/ui/assets/{raw-json-settings-editor-panel-Dr_BNQwQ.js → raw-json-settings-editor-panel-DwzGE_kH.js} +1 -1
- package/dist/ui/assets/{searchable-select-FJPe_YWv.js → searchable-select-DbhlbNK0.js} +1 -1
- package/dist/ui/assets/{separator-DJ0ku_ak.js → separator-DziIoy6O.js} +1 -1
- package/dist/ui/assets/{shared-DyQlJnbj.js → shared-XJ2EhJPB.js} +1 -1
- package/dist/ui/assets/{table-6Yg65ZZH.js → table-D5bWyv-8.js} +1 -1
- package/dist/ui/assets/{updates-DSCXb6Au.js → updates-ClhhaqwU.js} +1 -1
- package/dist/ui/index.html +1 -1
- package/dist/web-server/routes/cliproxy-stats-routes.d.ts +37 -0
- package/dist/web-server/routes/cliproxy-stats-routes.d.ts.map +1 -1
- package/dist/web-server/routes/cliproxy-stats-routes.js +56 -10
- package/dist/web-server/routes/cliproxy-stats-routes.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as v}from"./react-vendor-CNOkPC89.js";import{t as q}from"./notifications-B2HqRBj7.js";import{C as I,j as F,k as W,B as k,b as U,a as _,d as N,aF as Q,r as P,s as O,t as L,v as D,w as g,I as y,n as pe,bb as ee,bc as Ee,c as Pe,bi as Ye,bj as ge,bk as He,Q as Qe,R as Je,U as ne,V as ae,bd as ve}from"./index-DNmWbKbN.js";import{aa as Ze,aR as es,as as se,L as z,n as ss,aS as rs,aT as ts,aB as ns,w as as,a7 as ls,aU as os,aV as is,aW as cs,ah as xe,p as be,$ as ds,m as us,o as xs,_ as ms,S as hs,aM as we,aX as ps,x as fs,I as js,T as gs,N as vs}from"./icons-KVCk4_U8.js";import{S as Z}from"./separator-DJ0ku_ak.js";import{a as bs,u as Ne,b as Ce}from"./tanstack-CrmUhA7Z.js";import"./code-highlight-BRUf_pqB.js";import{T as ws,a as Ns,b as ye,c as le,d as Cs,e as oe}from"./table-6Yg65ZZH.js";import{R as ys}from"./raw-json-settings-editor-panel-Dr_BNQwQ.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";function J({title:s,icon:r,badge:t,description:l,disabledReason:a,children:n}){return e.jsxs(I,{children:[e.jsxs(F,{className:"pb-2",children:[e.jsxs(W,{className:"flex items-center gap-2 text-base",children:[r,s,t?e.jsx(k,{variant:"outline",className:"text-[10px] font-normal",children:t}):null]}),l?e.jsx("p",{className:"text-xs text-muted-foreground",children:l}):null]}),e.jsxs(U,{className:"space-y-3",children:[a?e.jsx("p",{className:"text-xs text-amber-600",children:a}):null,n]})]})}function ks({catalog:s,state:r,disabled:t=!1,disabledReason:l,onToggle:a}){const{t:n}=_(),o=new Set(s.map(i=>i.name)),c=Object.entries(r).filter(([i])=>!o.has(i)).sort(([i],[d])=>i.localeCompare(d));return e.jsxs(J,{title:"Features",badge:"features",icon:e.jsx(Ze,{className:"h-4 w-4"}),description:"Toggle the supported Codex feature flags CCS can safely manage.",disabledReason:l,children:[e.jsx("div",{className:"space-y-2",children:s.map(i=>{const d=r[i.name]??null;return e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-sm font-medium",children:i.label}),e.jsx(k,{variant:"outline",className:"font-mono text-[10px]",children:i.name})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:i.description})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[d!==null?e.jsx(N,{variant:"outline",size:"sm",onClick:()=>a(i.name,null),disabled:t,children:n("codex.useDefault")}):null,e.jsx(Q,{checked:d===!0,onCheckedChange:u=>a(i.name,u),disabled:t})]})]},i.name)})}),c.length>0?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Existing config-only flags"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"These feature keys already exist in your `config.toml`, so CCS can surface them without claiming full catalog coverage."})]}),c.map(([i,d])=>e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border border-dashed px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-sm font-medium",children:i}),e.jsx(k,{variant:"secondary",className:"text-[10px]",children:"existing"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:d===null?"Stored in a non-boolean form. Use raw TOML if you need to edit it.":"Discovered from the current file instead of CCS's built-in catalog."})]}),d===null?e.jsx(k,{variant:"outline",children:n("codex.rawOnly")}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(N,{variant:"outline",size:"sm",onClick:()=>a(i,null),disabled:t,children:n("codex.useDefault")}),e.jsx(Q,{checked:d===!0,onCheckedChange:u=>a(i,u),disabled:t})]})]},i))]}):null]})}const Ss={name:"",transport:"stdio",command:null,args:[],url:null,enabled:!0,required:!1,startupTimeoutSec:null,toolTimeoutSec:null,enabledTools:[],disabledTools:[]};function ie(s){return s.join(", ")}function ce(s){return s.split(",").map(r=>r.trim()).filter(Boolean)}function Ts({initialDraft:s,isNew:r,disabled:t,saving:l,canDelete:a,onSave:n,onDelete:o}){const{t:c}=_(),[i,d]=v.useState(s);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(y,{value:i.name,onChange:u=>d(m=>({...m,name:u.target.value})),placeholder:"playwright",disabled:t||!r}),e.jsxs(P,{value:i.transport,onValueChange:u=>d(m=>({...m,transport:u})),disabled:t,children:[e.jsx(O,{children:e.jsx(L,{})}),e.jsxs(D,{children:[e.jsx(g,{value:"stdio",children:c("codex.stdio")}),e.jsx(g,{value:"streamable-http",children:c("codex.streamableHttp")})]})]}),i.transport==="stdio"?e.jsxs(e.Fragment,{children:[e.jsx(y,{value:i.command??"",onChange:u=>d(m=>({...m,command:u.target.value||null})),placeholder:"npx",disabled:t}),e.jsx(y,{value:ie(i.args),onChange:u=>d(m=>({...m,args:ce(u.target.value)})),placeholder:"@playwright/mcp@latest, --flag",disabled:t})]}):e.jsx(y,{className:"sm:col-span-2",value:i.url??"",onChange:u=>d(m=>({...m,url:u.target.value||null})),placeholder:"https://example.test/mcp",disabled:t}),e.jsx(y,{type:"number",min:1,value:i.startupTimeoutSec??"",onChange:u=>d(m=>({...m,startupTimeoutSec:u.target.value?Number(u.target.value):null})),placeholder:"Startup timeout (sec)",disabled:t}),e.jsx(y,{type:"number",min:1,value:i.toolTimeoutSec??"",onChange:u=>d(m=>({...m,toolTimeoutSec:u.target.value?Number(u.target.value):null})),placeholder:"Tool timeout (sec)",disabled:t}),e.jsx(y,{value:ie(i.enabledTools),onChange:u=>d(m=>({...m,enabledTools:ce(u.target.value)})),placeholder:"enabled_tools",disabled:t}),e.jsx(y,{value:ie(i.disabledTools),onChange:u=>d(m=>({...m,disabledTools:ce(u.target.value)})),placeholder:"disabled_tools",disabled:t})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("label",{className:"flex items-center justify-between rounded-md border px-3 py-2 text-sm",children:["Enabled",e.jsx(Q,{checked:i.enabled,onCheckedChange:u=>d(m=>({...m,enabled:u})),disabled:t})]}),e.jsxs("label",{className:"flex items-center justify-between rounded-md border px-3 py-2 text-sm",children:["Required",e.jsx(Q,{checked:i.required,onCheckedChange:u=>d(m=>({...m,required:u})),disabled:t})]})]}),e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsxs(N,{variant:"outline",onClick:o,disabled:t||l||!a,children:[e.jsx(se,{className:"mr-2 h-4 w-4"}),"Delete"]}),e.jsxs(N,{onClick:()=>n(i.name,{transport:i.transport,command:i.command,args:i.args,url:i.url,enabled:i.enabled,required:i.required,startupTimeoutSec:i.startupTimeoutSec,toolTimeoutSec:i.toolTimeoutSec,enabledTools:i.enabledTools,disabledTools:i.disabledTools}),disabled:t||l||i.name.trim().length===0,children:[l?e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save MCP server"]})]})]})}function _s({entries:s,disabled:r=!1,disabledReason:t,saving:l=!1,onSave:a,onDelete:n}){const{t:o}=_(),[c,i]=v.useState("new"),d=v.useMemo(()=>s.find(h=>h.name===c)??null,[s,c]),u=d??Ss,m=JSON.stringify(u);return e.jsxs(J,{title:"MCP servers",badge:"mcp_servers",icon:e.jsx(es,{className:"h-4 w-4"}),description:"Manage the safe MCP transport fields. Keep auth headers and bearer tokens in raw TOML.",disabledReason:t,children:[e.jsxs(P,{value:c,onValueChange:i,disabled:r,children:[e.jsx(O,{children:e.jsx(L,{placeholder:"Select MCP server"})}),e.jsxs(D,{children:[e.jsx(g,{value:"new",children:o("codex.createNewMcpServer")}),s.map(h=>e.jsx(g,{value:h.name,children:h.name},h.name))]})]}),e.jsx(Ts,{initialDraft:u,isNew:c==="new",disabled:r,saving:l,canDelete:d!==null,onDelete:async()=>{d&&(await n(d.name),i("new"))},onSave:async(h,b)=>{await a(h,b),i(h)}},m)]})}const Es={name:"",displayName:null,baseUrl:null,envKey:null,wireApi:"responses",requiresOpenaiAuth:!1,supportsWebsockets:!1},Ps={name:"cliproxy",displayName:"CLIProxy Codex",baseUrl:"http://127.0.0.1:8317/api/provider/codex",envKey:"CLIPROXY_API_KEY",wireApi:"responses",requiresOpenaiAuth:!1,supportsWebsockets:!1};function Os({initialDraft:s,isNew:r,disabled:t,saving:l,canDelete:a,onSave:n,onDelete:o}){const{t:c}=_(),[i,d]=v.useState(s);return e.jsxs(e.Fragment,{children:[r&&e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-md border border-dashed px-3 py-2 text-xs text-muted-foreground",children:[e.jsxs("p",{children:["Quick start: apply the CLIProxy Codex preset here, then set"," ",e.jsx("strong",{children:c("codex.defaultProvider")})," to ",e.jsx("code",{children:"cliproxy"})," in Top-level settings."]}),e.jsx(N,{variant:"outline",size:"sm",onClick:()=>d(Ps),disabled:t,children:"Use CLIProxy Codex preset"})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(y,{value:i.name,onChange:u=>d(m=>({...m,name:u.target.value})),placeholder:"Provider id",disabled:t||!r}),e.jsx(y,{value:i.displayName??"",onChange:u=>d(m=>({...m,displayName:u.target.value||null})),placeholder:"Display name",disabled:t}),e.jsx(y,{value:i.baseUrl??"",onChange:u=>d(m=>({...m,baseUrl:u.target.value||null})),placeholder:"http://127.0.0.1:8317/api/provider/codex",disabled:t}),e.jsx(y,{value:i.envKey??"",onChange:u=>d(m=>({...m,envKey:u.target.value||null})),placeholder:"CLIPROXY_API_KEY",disabled:t})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[e.jsxs(P,{value:i.wireApi??"responses",onValueChange:u=>d(m=>({...m,wireApi:u})),disabled:t,children:[e.jsx(O,{children:e.jsx(L,{})}),e.jsx(D,{children:e.jsx(g,{value:"responses",children:c("codex.responses")})})]}),e.jsxs("label",{className:"flex items-center justify-between rounded-md border px-3 py-2 text-sm",children:["Requires OpenAI auth",e.jsx(Q,{checked:i.requiresOpenaiAuth,onCheckedChange:u=>d(m=>({...m,requiresOpenaiAuth:u})),disabled:t})]}),e.jsxs("label",{className:"flex items-center justify-between rounded-md border px-3 py-2 text-sm",children:["Supports websockets",e.jsx(Q,{checked:i.supportsWebsockets,onCheckedChange:u=>d(m=>({...m,supportsWebsockets:u})),disabled:t})]})]}),e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsxs(N,{variant:"outline",onClick:o,disabled:t||l||!a,children:[e.jsx(se,{className:"mr-2 h-4 w-4"}),"Delete"]}),e.jsxs(N,{onClick:()=>n(i.name,{displayName:i.displayName,baseUrl:i.baseUrl,envKey:i.envKey,wireApi:i.wireApi,requiresOpenaiAuth:i.requiresOpenaiAuth,supportsWebsockets:i.supportsWebsockets}),disabled:t||l||i.name.trim().length===0,children:[l?e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save provider"]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["If you want plain native ",e.jsx("code",{children:"codex"})," to default to CLIProxy, save a provider named"," ",e.jsx("code",{children:"cliproxy"})," with ",e.jsx("code",{children:"CLIPROXY_API_KEY"})," here, then pick"," ",e.jsx("code",{children:"cliproxy"})," in the ",e.jsx("strong",{children:c("codex.defaultProvider")})," control above."]})]})}function Ls({entries:s,disabled:r=!1,disabledReason:t,saving:l=!1,onSave:a,onDelete:n}){const{t:o}=_(),[c,i]=v.useState("new"),d=v.useMemo(()=>s.find(h=>h.name===c)??null,[s,c]),u=d??Es,m=JSON.stringify(u);return e.jsxs(J,{title:"Model providers",badge:"model_providers",icon:e.jsx(ss,{className:"h-4 w-4"}),description:"Edit the common provider fields CCS can support safely. Keep secret migration and inline bearer tokens in raw TOML.",disabledReason:t,children:[e.jsxs(P,{value:c,onValueChange:i,disabled:r,children:[e.jsx(O,{children:e.jsx(L,{placeholder:"Select provider"})}),e.jsxs(D,{children:[e.jsx(g,{value:"new",children:o("codex.createNewProvider")}),s.map(h=>e.jsx(g,{value:h.name,children:h.name},h.name))]})]}),e.jsx(Os,{initialDraft:u,isNew:c==="new",disabled:r,saving:l,canDelete:d!==null,onDelete:async()=>{d&&(await n(d.name),i("new"))},onSave:async(h,b)=>{await a(h,b),i(h)}},m)]})}function Ds({initialName:s,initialModel:r,initialProvider:t,initialEffort:l,providerNames:a,activeProfile:n,selectedEntryName:o,disabled:c,saving:i,onSave:d,onDelete:u,onSetActive:m}){const{t:h}=_(),[b,p]=v.useState(s),[w,R]=v.useState(r),[K,x]=v.useState(t),[j,E]=v.useState(l);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(y,{value:b,onChange:C=>p(C.target.value),placeholder:"deep-review",disabled:c||o!==null}),e.jsx(y,{value:w??"",onChange:C=>R(C.target.value||null),placeholder:"gpt-5.4",disabled:c}),e.jsxs(P,{value:K??"__unset__",onValueChange:C=>x(C==="__unset__"?null:C),disabled:c,children:[e.jsx(O,{children:e.jsx(L,{placeholder:h("codex.useGlobalProvider")})}),e.jsxs(D,{children:[e.jsx(g,{value:"__unset__",children:h("codex.useGlobalProvider")}),a.map(C=>e.jsx(g,{value:C,children:C},C))]})]}),e.jsxs(P,{value:j??"__unset__",onValueChange:C=>E(C==="__unset__"?null:C),disabled:c,children:[e.jsx(O,{children:e.jsx(L,{placeholder:h("codex.useGlobalEffort")})}),e.jsxs(D,{children:[e.jsx(g,{value:"__unset__",children:h("codex.useGlobalEffort")}),["minimal","low","medium","high","xhigh"].map(C=>e.jsx(g,{value:C,children:C},C))]})]})]}),e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(N,{variant:"outline",onClick:u,disabled:c||i||!o,children:[e.jsx(se,{className:"mr-2 h-4 w-4"}),"Delete"]}),e.jsx(N,{variant:"outline",onClick:m,disabled:c||i||!o||o===n,children:"Set active"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(N,{variant:"outline",onClick:()=>d(b,{model:w,modelProvider:K,modelReasoningEffort:j},!1),disabled:c||i||b.trim().length===0,children:[i?e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save profile"]}),e.jsxs(N,{onClick:()=>d(b,{model:w,modelProvider:K,modelReasoningEffort:j},!0),disabled:c||i||b.trim().length===0,children:[i?e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save + activate"]})]})]})]})}function As({activeProfile:s,entries:r,providerNames:t,disabled:l=!1,disabledReason:a,saving:n=!1,onSave:o,onDelete:c,onSetActive:i}){const{t:d}=_(),[u,m]=v.useState("new"),h=v.useMemo(()=>r.find(p=>p.name===u)??null,[r,u]),b=JSON.stringify(h??{name:"",values:{}});return e.jsxs(J,{title:d("codex.profiles"),badge:"profiles",icon:e.jsx(rs,{className:"h-4 w-4"}),description:"Create reusable Codex overlays and set the active default profile.",disabledReason:a,children:[e.jsxs(P,{value:u,onValueChange:m,disabled:l,children:[e.jsx(O,{children:e.jsx(L,{placeholder:"Select profile"})}),e.jsxs(D,{children:[e.jsx(g,{value:"new",children:d("codex.createNewProfile")}),r.map(p=>e.jsxs(g,{value:p.name,children:[p.name,p.name===s?" (active)":""]},p.name))]})]}),e.jsx(Ds,{initialName:h?.name??"",initialModel:h?.values.model??null,initialProvider:h?.values.modelProvider??null,initialEffort:h?.values.modelReasoningEffort??null,providerNames:t,activeProfile:s,selectedEntryName:h?.name??null,disabled:l,saving:n,onDelete:async()=>{h&&(await c(h.name),m("new"))},onSetActive:async()=>{h&&await i(h.name)},onSave:async(p,w,R)=>{await o(p,w,R),m(p)}},b)]})}function Rs({workspacePath:s,disabled:r,saving:t,onSave:l}){const{t:a}=_(),[n,o]=v.useState(s),[c,i]=v.useState("trusted");return e.jsxs("div",{className:"grid gap-2 sm:grid-cols-[1fr_160px_auto]",children:[e.jsx(y,{value:n,onChange:d=>o(d.target.value),placeholder:"~/repo or /absolute/path",disabled:r}),e.jsxs(P,{value:c,onValueChange:i,disabled:r,children:[e.jsx(O,{children:e.jsx(L,{})}),e.jsxs(D,{children:[e.jsx(g,{value:"trusted",children:a("codex.trusted")}),e.jsx(g,{value:"untrusted",children:a("codex.untrusted")})]})]}),e.jsxs(N,{onClick:()=>l(n,c),disabled:r||t,children:[t?e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save trust"]})]})}function Ms({workspacePath:s,entries:r,disabled:t=!1,disabledReason:l,saving:a=!1,onSave:n}){const{t:o}=_();return e.jsxs(J,{title:"Project trust",badge:"projects",icon:e.jsx(ts,{className:"h-4 w-4"}),description:"Trust current workspaces or remove stale trust entries without opening raw TOML.",disabledReason:l,children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Paths must be absolute or start with ",e.jsx("code",{children:"~/"}),". Relative paths are rejected so CCS does not trust the wrong folder."]}),e.jsx(Rs,{workspacePath:s,disabled:t,saving:a,onSave:n},s),e.jsx(N,{variant:"outline",className:"w-full justify-start",onClick:()=>n(s,"trusted"),disabled:t||a,children:"Trust current workspace"}),e.jsx("div",{className:"space-y-2",children:r.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:o("codex.noProjectTrustEntries")}):r.map(c=>e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:c.path}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["trust_level = ",c.trustLevel]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(N,{variant:"ghost",size:"sm",onClick:()=>n(c.path,c.trustLevel==="trusted"?"untrusted":"trusted"),disabled:t||a,children:"Toggle"}),e.jsx(N,{variant:"ghost",size:"icon",onClick:()=>n(c.path,null),disabled:t||a,children:e.jsx(se,{className:"h-4 w-4"})})]})]},c.path))})]})}const A="__unset__",Is=105e4,Fs=272e3,ke=8e5,Se=7e5,Ws=new Intl.NumberFormat("en-US");function $(s){return s??A}function B(s,r){return r&&!s.includes(r)?[r,...s]:s}function de(s){return Ws.format(s)}function Us(s){return s?.trim().toLowerCase().startsWith("gpt-5.4")??!1}function Ks(s,r){const t={};return r.model!==s.model&&(t.model=r.model),r.modelReasoningEffort!==s.modelReasoningEffort&&(t.modelReasoningEffort=r.modelReasoningEffort),r.modelContextWindow!==s.modelContextWindow&&(t.modelContextWindow=r.modelContextWindow),r.modelAutoCompactTokenLimit!==s.modelAutoCompactTokenLimit&&(t.modelAutoCompactTokenLimit=r.modelAutoCompactTokenLimit),r.modelProvider!==s.modelProvider&&(t.modelProvider=r.modelProvider),r.approvalPolicy!==s.approvalPolicy&&(t.approvalPolicy=r.approvalPolicy),r.sandboxMode!==s.sandboxMode&&(t.sandboxMode=r.sandboxMode),r.webSearch!==s.webSearch&&(t.webSearch=r.webSearch),r.toolOutputTokenLimit!==s.toolOutputTokenLimit&&(t.toolOutputTokenLimit=r.toolOutputTokenLimit),r.personality!==s.personality&&(t.personality=r.personality),t}function qs({initialValues:s,providerNames:r,disabled:t,saving:l,onSave:a}){const{t:n}=_(),[o,c]=v.useState(s),i=B(["minimal","low","medium","high","xhigh"],o.modelReasoningEffort),d=B(r,o.modelProvider),u=B(["on-request","never","untrusted"],o.approvalPolicy),m=B(["read-only","workspace-write","danger-full-access"],o.sandboxMode),h=B(["cached","live","disabled"],o.webSearch),b=B(["none","friendly","pragmatic"],o.personality),p=Ks(s,o),w=Object.keys(p).length>0,R=Us(o.model),K=x=>{const j=x.trim();return j.length>0?Number(j):null};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.model")}),e.jsx(y,{value:o.model??"",onChange:x=>c(j=>({...j,model:x.target.value||null})),placeholder:"gpt-5.4",disabled:t})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.reasoningEffort")}),e.jsxs(P,{value:$(o.modelReasoningEffort),onValueChange:x=>c(j=>({...j,modelReasoningEffort:x===A?null:x})),disabled:t,children:[e.jsx(O,{children:e.jsx(L,{placeholder:n("codex.useDefault")})}),e.jsxs(D,{children:[e.jsx(g,{value:A,children:n("codex.useDefault")}),i.map(x=>e.jsx(g,{value:x,children:x},x))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.defaultProvider")}),e.jsxs(P,{value:$(o.modelProvider),onValueChange:x=>c(j=>({...j,modelProvider:x===A?null:x})),disabled:t,children:[e.jsx(O,{children:e.jsx(L,{placeholder:n("codex.useCodexDefault")})}),e.jsxs(D,{children:[e.jsx(g,{value:A,children:n("codex.useCodexDefault")}),d.map(x=>e.jsx(g,{value:x,children:x},x))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.approvalPolicy")}),e.jsxs(P,{value:$(o.approvalPolicy),onValueChange:x=>c(j=>({...j,approvalPolicy:x===A?null:x})),disabled:t,children:[e.jsx(O,{children:e.jsx(L,{placeholder:n("codex.useDefault")})}),e.jsxs(D,{children:[e.jsx(g,{value:A,children:n("codex.useDefault")}),u.map(x=>e.jsx(g,{value:x,children:x},x))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.sandboxMode")}),e.jsxs(P,{value:$(o.sandboxMode),onValueChange:x=>c(j=>({...j,sandboxMode:x===A?null:x})),disabled:t,children:[e.jsx(O,{children:e.jsx(L,{placeholder:n("codex.useDefault")})}),e.jsxs(D,{children:[e.jsx(g,{value:A,children:n("codex.useDefault")}),m.map(x=>e.jsx(g,{value:x,children:x},x))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.webSearch")}),e.jsxs(P,{value:$(o.webSearch),onValueChange:x=>c(j=>({...j,webSearch:x===A?null:x})),disabled:t,children:[e.jsx(O,{children:e.jsx(L,{placeholder:n("codex.useDefault")})}),e.jsxs(D,{children:[e.jsx(g,{value:A,children:n("codex.useDefault")}),h.map(x=>e.jsx(g,{value:x,children:x},x))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.toolOutputTokenLimit")}),e.jsx(y,{type:"number",min:1,value:o.toolOutputTokenLimit??"",onChange:x=>c(j=>({...j,toolOutputTokenLimit:x.target.value?Number(x.target.value):null})),placeholder:"25000",disabled:t})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.personality")}),e.jsxs(P,{value:$(o.personality),onValueChange:x=>c(j=>({...j,personality:x===A?null:x})),disabled:t,children:[e.jsx(O,{children:e.jsx(L,{placeholder:n("codex.useDefault")})}),e.jsxs(D,{children:[e.jsx(g,{value:A,children:n("codex.useDefault")}),b.map(x=>e.jsx(g,{value:x,children:x},x))]})]})]})]}),e.jsxs("div",{className:"space-y-4 rounded-xl border border-amber-500/30 bg-amber-500/5 p-4 shadow-sm dark:bg-amber-400/5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(as,{className:"h-4 w-4 text-amber-600 dark:text-amber-300"}),e.jsx("p",{className:"text-sm font-semibold",children:n("codex.longContextOverride")}),e.jsx(k,{variant:"outline",className:"border-amber-500/40 bg-background/80 text-[10px] uppercase tracking-[0.16em] text-amber-700 dark:text-amber-300",children:"Manual opt-in only"}),e.jsx(k,{variant:"secondary",className:"text-[10px] uppercase tracking-[0.16em] text-muted-foreground",children:R?"GPT-5.4 selected":"GPT-5.4 reference"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Draft values only. Nothing applies until Save."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(N,{type:"button",variant:"outline",size:"sm",disabled:t,onClick:()=>c(x=>({...x,modelContextWindow:ke,modelAutoCompactTokenLimit:Se})),children:"Fill cautious pair"}),e.jsx(N,{type:"button",variant:"outline",size:"sm",disabled:t,onClick:()=>c(x=>({...x,modelContextWindow:Is})),children:"Set official max window"}),e.jsx(N,{type:"button",variant:"ghost",size:"sm",disabled:t,onClick:()=>c(x=>({...x,modelContextWindow:null,modelAutoCompactTokenLimit:null})),children:"Clear"})]})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-3",children:[e.jsxs("div",{className:"rounded-lg border bg-background/85 px-3 py-3 shadow-sm shadow-black/5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"Official max"}),e.jsx("p",{className:"mt-1 font-mono text-base font-semibold text-foreground",children:"1.05M / 1M"}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:n("codex.gptContextCap")})]}),e.jsxs("div",{className:"rounded-lg border bg-background/85 px-3 py-3 shadow-sm shadow-black/5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"Standard window"}),e.jsx("p",{className:"mt-1 font-mono text-base font-semibold text-foreground",children:de(Fs)}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:n("codex.normalUsageWindow")})]}),e.jsxs("div",{className:"rounded-lg border bg-background/85 px-3 py-3 shadow-sm shadow-black/5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"Above 272K"}),e.jsx("p",{className:"mt-1 font-mono text-base font-semibold text-foreground",children:n("codex.counts2x")}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:n("codex.usageLimitCost")})]})]}),e.jsxs("div",{className:"space-y-3 rounded-lg border bg-background/75 px-3 py-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"One cautious pair"}),e.jsxs("div",{className:"rounded-full border bg-background px-2.5 py-1 font-mono text-[11px] font-medium",children:["Context ",de(ke)]}),e.jsxs("div",{className:"rounded-full border bg-background px-2.5 py-1 font-mono text-[11px] font-medium",children:["Auto-compact ",de(Se)]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx(k,{variant:"outline",className:"border-border/70 bg-background/80 text-[10px] uppercase tracking-[0.14em] text-muted-foreground",children:"Not official"}),e.jsx(k,{variant:"outline",className:"border-border/70 bg-background/80 text-[10px] uppercase tracking-[0.14em] text-muted-foreground",children:"Draft only"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px] text-muted-foreground",children:[e.jsx("span",{children:n("codex.quickFillWarning")}),!R&&o.model?e.jsxs("span",{children:[e.jsx("code",{children:o.model})," should be checked separately."]}):null]})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.modelContextWindow")}),e.jsx(y,{"aria-label":n("codex.modelContextWindow"),type:"number",min:1,value:o.modelContextWindow??"",onChange:x=>c(j=>({...j,modelContextWindow:K(x.target.value)})),placeholder:"Unset",disabled:t}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Writes ",e.jsx("code",{children:"model_context_window"}),". Leave unset to keep Codex defaults."]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.autoCompactTokenLimit")}),e.jsx(y,{"aria-label":n("codex.autoCompactTokenLimit"),type:"number",min:1,value:o.modelAutoCompactTokenLimit??"",onChange:x=>c(j=>({...j,modelAutoCompactTokenLimit:K(x.target.value)})),placeholder:"Unset",disabled:t}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Writes ",e.jsx("code",{children:"model_auto_compact_token_limit"}),". Leave unset to keep model defaults."]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px] text-muted-foreground",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-[0.14em]",children:"Docs"}),e.jsx("a",{href:"https://developers.openai.com/api/docs/models/gpt-5.4",target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:"GPT-5.4 model page"}),e.jsx("a",{href:"https://openai.com/index/introducing-gpt-5-4/",target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:"Release notes"}),e.jsx("a",{href:"https://developers.openai.com/codex/config-reference",target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:"Config reference"})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(N,{onClick:()=>a(p),disabled:t||l||!w,children:[l?e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save top-level settings"]})})]})}function Vs({values:s,providerNames:r,disabled:t=!1,disabledReason:l,saving:a=!1,onSave:n}){return e.jsx(J,{title:"Top-level controls",badge:"config.toml",icon:e.jsx(ns,{className:"h-4 w-4"}),description:"Structured controls for the stable top-level Codex settings users touch most often. Unsupported upstream shapes stay untouched and should be edited in raw TOML.",disabledReason:l,children:e.jsx(qs,{initialValues:s,providerNames:r,disabled:t,saving:a,onSave:n},JSON.stringify(s))})}function Gs({workspacePath:s,activeProfile:r,topLevelSettings:t,projectTrustEntries:l,profileEntries:a,modelProviderEntries:n,mcpServerEntries:o,featureCatalog:c,featureState:i,disabled:d,disabledReason:u,saving:m,onPatch:h}){const{t:b}=_();return e.jsx(pe,{className:"h-full",children:e.jsxs("div",{className:"space-y-6 pr-1 pb-6",children:[e.jsxs("div",{className:"group relative overflow-hidden rounded-xl border border-border/80 bg-background/50 p-5 shadow-sm transition-all hover:bg-background hover:shadow-md dark:border-border/60",children:[e.jsx("div",{className:"absolute inset-x-0 -top-px h-px bg-gradient-to-r from-transparent via-foreground/15 to-transparent transition-opacity group-hover:via-foreground/30"}),e.jsxs("div",{className:"flex flex-col gap-6 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{className:"flex-1 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary transition-colors group-hover:border-primary/30",children:e.jsx(ls,{className:"h-4 w-4"})}),e.jsx("div",{children:e.jsx("h2",{className:"text-base font-semibold tracking-tight text-foreground",children:b("codex.controlCenter")})})]}),e.jsxs("ul",{className:"grid gap-3 sm:grid-cols-2 text-sm text-muted-foreground",children:[e.jsxs("li",{className:"flex items-start gap-2.5",children:[e.jsx(os,{className:"h-4 w-4 shrink-0 text-muted-foreground/60 mt-0.5"}),e.jsxs("span",{className:"leading-relaxed",children:["Writes exclusively to user-layer"," ",e.jsx("code",{className:"text-[11px] bg-muted/70 px-1.5 py-0.5 rounded border border-border/50",children:"config.toml"})]})]}),e.jsxs("li",{className:"flex items-start gap-2.5",children:[e.jsx(is,{className:"h-4 w-4 shrink-0 text-muted-foreground/60 mt-0.5"}),e.jsx("span",{className:"leading-relaxed",children:"Does not reflect repo trust layers or CLI overrides"})]})]})]}),e.jsx("div",{className:"shrink-0 lg:w-[280px]",children:e.jsx("div",{className:"relative overflow-hidden rounded-lg border border-amber-500/20 bg-amber-500/5 p-4 transition-colors group-hover:border-amber-500/30 group-hover:bg-amber-500/10 dark:border-amber-400/10 dark:bg-amber-400/5",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(cs,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-bold text-amber-700 dark:text-amber-300 uppercase tracking-wider",children:"Formatting Note"}),e.jsx("p",{className:"text-[13px] leading-relaxed text-amber-800/80 dark:text-amber-200/70",children:"Saves normalize TOML formatting and strip comments. Switch to the raw editor if exact layout matters."})]})]})})})]})]}),e.jsx(Vs,{values:t,providerNames:n.map(p=>p.name),disabled:d,disabledReason:u,saving:m,onSave:p=>h({kind:"top-level",values:p},b("toasts.codexSaved"))}),e.jsx(Ms,{workspacePath:s,entries:l,disabled:d,disabledReason:u,saving:m,onSave:(p,w)=>h({kind:"project-trust",path:p,trustLevel:w},w?"Saved project trust entry.":"Removed project trust entry.")}),e.jsx(As,{activeProfile:r,entries:a,providerNames:n.map(p=>p.name),disabled:d,disabledReason:u,saving:m,onSave:(p,w,R)=>h({kind:"profile",action:"upsert",name:p,values:w,setAsActive:R},"Saved profile."),onDelete:p=>h({kind:"profile",action:"delete",name:p},"Deleted profile."),onSetActive:p=>h({kind:"profile",action:"set-active",name:p},"Set active profile.")}),e.jsx(Ls,{entries:n,disabled:d,disabledReason:u,saving:m,onSave:(p,w)=>h({kind:"model-provider",action:"upsert",name:p,values:w},"Saved model provider."),onDelete:p=>h({kind:"model-provider",action:"delete",name:p},"Deleted model provider.")}),e.jsx(_s,{entries:o,disabled:d,disabledReason:u,saving:m,onSave:(p,w)=>h({kind:"mcp-server",action:"upsert",name:p,values:w},"Saved MCP server."),onDelete:p=>h({kind:"mcp-server",action:"delete",name:p},"Deleted MCP server.")}),e.jsx(ks,{catalog:c,state:i,disabled:d,disabledReason:u,onToggle:(p,w)=>h({kind:"feature",feature:p,enabled:w},"Saved feature toggle.")})]})})}const Oe=`model_provider = "cliproxy"
|
|
1
|
+
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as v}from"./react-vendor-CNOkPC89.js";import{t as q}from"./notifications-B2HqRBj7.js";import{C as I,j as F,k as W,B as k,b as U,a as _,d as N,aF as Q,r as P,s as O,t as L,v as D,w as g,I as y,n as pe,bb as ee,bc as Ee,c as Pe,bi as Ye,bj as ge,bk as He,Q as Qe,R as Je,U as ne,V as ae,bd as ve}from"./index-BDfXfBTa.js";import{aa as Ze,aR as es,as as se,L as z,n as ss,aS as rs,aT as ts,aB as ns,w as as,a7 as ls,aU as os,aV as is,aW as cs,ah as xe,p as be,$ as ds,m as us,o as xs,_ as ms,S as hs,aM as we,aX as ps,x as fs,I as js,T as gs,N as vs}from"./icons-KVCk4_U8.js";import{S as Z}from"./separator-DziIoy6O.js";import{a as bs,u as Ne,b as Ce}from"./tanstack-CrmUhA7Z.js";import"./code-highlight-BRUf_pqB.js";import{T as ws,a as Ns,b as ye,c as le,d as Cs,e as oe}from"./table-D5bWyv-8.js";import{R as ys}from"./raw-json-settings-editor-panel-DwzGE_kH.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";function J({title:s,icon:r,badge:t,description:l,disabledReason:a,children:n}){return e.jsxs(I,{children:[e.jsxs(F,{className:"pb-2",children:[e.jsxs(W,{className:"flex items-center gap-2 text-base",children:[r,s,t?e.jsx(k,{variant:"outline",className:"text-[10px] font-normal",children:t}):null]}),l?e.jsx("p",{className:"text-xs text-muted-foreground",children:l}):null]}),e.jsxs(U,{className:"space-y-3",children:[a?e.jsx("p",{className:"text-xs text-amber-600",children:a}):null,n]})]})}function ks({catalog:s,state:r,disabled:t=!1,disabledReason:l,onToggle:a}){const{t:n}=_(),o=new Set(s.map(i=>i.name)),c=Object.entries(r).filter(([i])=>!o.has(i)).sort(([i],[d])=>i.localeCompare(d));return e.jsxs(J,{title:"Features",badge:"features",icon:e.jsx(Ze,{className:"h-4 w-4"}),description:"Toggle the supported Codex feature flags CCS can safely manage.",disabledReason:l,children:[e.jsx("div",{className:"space-y-2",children:s.map(i=>{const d=r[i.name]??null;return e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-sm font-medium",children:i.label}),e.jsx(k,{variant:"outline",className:"font-mono text-[10px]",children:i.name})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:i.description})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[d!==null?e.jsx(N,{variant:"outline",size:"sm",onClick:()=>a(i.name,null),disabled:t,children:n("codex.useDefault")}):null,e.jsx(Q,{checked:d===!0,onCheckedChange:u=>a(i.name,u),disabled:t})]})]},i.name)})}),c.length>0?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Existing config-only flags"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"These feature keys already exist in your `config.toml`, so CCS can surface them without claiming full catalog coverage."})]}),c.map(([i,d])=>e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border border-dashed px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-sm font-medium",children:i}),e.jsx(k,{variant:"secondary",className:"text-[10px]",children:"existing"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:d===null?"Stored in a non-boolean form. Use raw TOML if you need to edit it.":"Discovered from the current file instead of CCS's built-in catalog."})]}),d===null?e.jsx(k,{variant:"outline",children:n("codex.rawOnly")}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(N,{variant:"outline",size:"sm",onClick:()=>a(i,null),disabled:t,children:n("codex.useDefault")}),e.jsx(Q,{checked:d===!0,onCheckedChange:u=>a(i,u),disabled:t})]})]},i))]}):null]})}const Ss={name:"",transport:"stdio",command:null,args:[],url:null,enabled:!0,required:!1,startupTimeoutSec:null,toolTimeoutSec:null,enabledTools:[],disabledTools:[]};function ie(s){return s.join(", ")}function ce(s){return s.split(",").map(r=>r.trim()).filter(Boolean)}function Ts({initialDraft:s,isNew:r,disabled:t,saving:l,canDelete:a,onSave:n,onDelete:o}){const{t:c}=_(),[i,d]=v.useState(s);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(y,{value:i.name,onChange:u=>d(m=>({...m,name:u.target.value})),placeholder:"playwright",disabled:t||!r}),e.jsxs(P,{value:i.transport,onValueChange:u=>d(m=>({...m,transport:u})),disabled:t,children:[e.jsx(O,{children:e.jsx(L,{})}),e.jsxs(D,{children:[e.jsx(g,{value:"stdio",children:c("codex.stdio")}),e.jsx(g,{value:"streamable-http",children:c("codex.streamableHttp")})]})]}),i.transport==="stdio"?e.jsxs(e.Fragment,{children:[e.jsx(y,{value:i.command??"",onChange:u=>d(m=>({...m,command:u.target.value||null})),placeholder:"npx",disabled:t}),e.jsx(y,{value:ie(i.args),onChange:u=>d(m=>({...m,args:ce(u.target.value)})),placeholder:"@playwright/mcp@latest, --flag",disabled:t})]}):e.jsx(y,{className:"sm:col-span-2",value:i.url??"",onChange:u=>d(m=>({...m,url:u.target.value||null})),placeholder:"https://example.test/mcp",disabled:t}),e.jsx(y,{type:"number",min:1,value:i.startupTimeoutSec??"",onChange:u=>d(m=>({...m,startupTimeoutSec:u.target.value?Number(u.target.value):null})),placeholder:"Startup timeout (sec)",disabled:t}),e.jsx(y,{type:"number",min:1,value:i.toolTimeoutSec??"",onChange:u=>d(m=>({...m,toolTimeoutSec:u.target.value?Number(u.target.value):null})),placeholder:"Tool timeout (sec)",disabled:t}),e.jsx(y,{value:ie(i.enabledTools),onChange:u=>d(m=>({...m,enabledTools:ce(u.target.value)})),placeholder:"enabled_tools",disabled:t}),e.jsx(y,{value:ie(i.disabledTools),onChange:u=>d(m=>({...m,disabledTools:ce(u.target.value)})),placeholder:"disabled_tools",disabled:t})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("label",{className:"flex items-center justify-between rounded-md border px-3 py-2 text-sm",children:["Enabled",e.jsx(Q,{checked:i.enabled,onCheckedChange:u=>d(m=>({...m,enabled:u})),disabled:t})]}),e.jsxs("label",{className:"flex items-center justify-between rounded-md border px-3 py-2 text-sm",children:["Required",e.jsx(Q,{checked:i.required,onCheckedChange:u=>d(m=>({...m,required:u})),disabled:t})]})]}),e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsxs(N,{variant:"outline",onClick:o,disabled:t||l||!a,children:[e.jsx(se,{className:"mr-2 h-4 w-4"}),"Delete"]}),e.jsxs(N,{onClick:()=>n(i.name,{transport:i.transport,command:i.command,args:i.args,url:i.url,enabled:i.enabled,required:i.required,startupTimeoutSec:i.startupTimeoutSec,toolTimeoutSec:i.toolTimeoutSec,enabledTools:i.enabledTools,disabledTools:i.disabledTools}),disabled:t||l||i.name.trim().length===0,children:[l?e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save MCP server"]})]})]})}function _s({entries:s,disabled:r=!1,disabledReason:t,saving:l=!1,onSave:a,onDelete:n}){const{t:o}=_(),[c,i]=v.useState("new"),d=v.useMemo(()=>s.find(h=>h.name===c)??null,[s,c]),u=d??Ss,m=JSON.stringify(u);return e.jsxs(J,{title:"MCP servers",badge:"mcp_servers",icon:e.jsx(es,{className:"h-4 w-4"}),description:"Manage the safe MCP transport fields. Keep auth headers and bearer tokens in raw TOML.",disabledReason:t,children:[e.jsxs(P,{value:c,onValueChange:i,disabled:r,children:[e.jsx(O,{children:e.jsx(L,{placeholder:"Select MCP server"})}),e.jsxs(D,{children:[e.jsx(g,{value:"new",children:o("codex.createNewMcpServer")}),s.map(h=>e.jsx(g,{value:h.name,children:h.name},h.name))]})]}),e.jsx(Ts,{initialDraft:u,isNew:c==="new",disabled:r,saving:l,canDelete:d!==null,onDelete:async()=>{d&&(await n(d.name),i("new"))},onSave:async(h,b)=>{await a(h,b),i(h)}},m)]})}const Es={name:"",displayName:null,baseUrl:null,envKey:null,wireApi:"responses",requiresOpenaiAuth:!1,supportsWebsockets:!1},Ps={name:"cliproxy",displayName:"CLIProxy Codex",baseUrl:"http://127.0.0.1:8317/api/provider/codex",envKey:"CLIPROXY_API_KEY",wireApi:"responses",requiresOpenaiAuth:!1,supportsWebsockets:!1};function Os({initialDraft:s,isNew:r,disabled:t,saving:l,canDelete:a,onSave:n,onDelete:o}){const{t:c}=_(),[i,d]=v.useState(s);return e.jsxs(e.Fragment,{children:[r&&e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-md border border-dashed px-3 py-2 text-xs text-muted-foreground",children:[e.jsxs("p",{children:["Quick start: apply the CLIProxy Codex preset here, then set"," ",e.jsx("strong",{children:c("codex.defaultProvider")})," to ",e.jsx("code",{children:"cliproxy"})," in Top-level settings."]}),e.jsx(N,{variant:"outline",size:"sm",onClick:()=>d(Ps),disabled:t,children:"Use CLIProxy Codex preset"})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(y,{value:i.name,onChange:u=>d(m=>({...m,name:u.target.value})),placeholder:"Provider id",disabled:t||!r}),e.jsx(y,{value:i.displayName??"",onChange:u=>d(m=>({...m,displayName:u.target.value||null})),placeholder:"Display name",disabled:t}),e.jsx(y,{value:i.baseUrl??"",onChange:u=>d(m=>({...m,baseUrl:u.target.value||null})),placeholder:"http://127.0.0.1:8317/api/provider/codex",disabled:t}),e.jsx(y,{value:i.envKey??"",onChange:u=>d(m=>({...m,envKey:u.target.value||null})),placeholder:"CLIPROXY_API_KEY",disabled:t})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[e.jsxs(P,{value:i.wireApi??"responses",onValueChange:u=>d(m=>({...m,wireApi:u})),disabled:t,children:[e.jsx(O,{children:e.jsx(L,{})}),e.jsx(D,{children:e.jsx(g,{value:"responses",children:c("codex.responses")})})]}),e.jsxs("label",{className:"flex items-center justify-between rounded-md border px-3 py-2 text-sm",children:["Requires OpenAI auth",e.jsx(Q,{checked:i.requiresOpenaiAuth,onCheckedChange:u=>d(m=>({...m,requiresOpenaiAuth:u})),disabled:t})]}),e.jsxs("label",{className:"flex items-center justify-between rounded-md border px-3 py-2 text-sm",children:["Supports websockets",e.jsx(Q,{checked:i.supportsWebsockets,onCheckedChange:u=>d(m=>({...m,supportsWebsockets:u})),disabled:t})]})]}),e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsxs(N,{variant:"outline",onClick:o,disabled:t||l||!a,children:[e.jsx(se,{className:"mr-2 h-4 w-4"}),"Delete"]}),e.jsxs(N,{onClick:()=>n(i.name,{displayName:i.displayName,baseUrl:i.baseUrl,envKey:i.envKey,wireApi:i.wireApi,requiresOpenaiAuth:i.requiresOpenaiAuth,supportsWebsockets:i.supportsWebsockets}),disabled:t||l||i.name.trim().length===0,children:[l?e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save provider"]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["If you want plain native ",e.jsx("code",{children:"codex"})," to default to CLIProxy, save a provider named"," ",e.jsx("code",{children:"cliproxy"})," with ",e.jsx("code",{children:"CLIPROXY_API_KEY"})," here, then pick"," ",e.jsx("code",{children:"cliproxy"})," in the ",e.jsx("strong",{children:c("codex.defaultProvider")})," control above."]})]})}function Ls({entries:s,disabled:r=!1,disabledReason:t,saving:l=!1,onSave:a,onDelete:n}){const{t:o}=_(),[c,i]=v.useState("new"),d=v.useMemo(()=>s.find(h=>h.name===c)??null,[s,c]),u=d??Es,m=JSON.stringify(u);return e.jsxs(J,{title:"Model providers",badge:"model_providers",icon:e.jsx(ss,{className:"h-4 w-4"}),description:"Edit the common provider fields CCS can support safely. Keep secret migration and inline bearer tokens in raw TOML.",disabledReason:t,children:[e.jsxs(P,{value:c,onValueChange:i,disabled:r,children:[e.jsx(O,{children:e.jsx(L,{placeholder:"Select provider"})}),e.jsxs(D,{children:[e.jsx(g,{value:"new",children:o("codex.createNewProvider")}),s.map(h=>e.jsx(g,{value:h.name,children:h.name},h.name))]})]}),e.jsx(Os,{initialDraft:u,isNew:c==="new",disabled:r,saving:l,canDelete:d!==null,onDelete:async()=>{d&&(await n(d.name),i("new"))},onSave:async(h,b)=>{await a(h,b),i(h)}},m)]})}function Ds({initialName:s,initialModel:r,initialProvider:t,initialEffort:l,providerNames:a,activeProfile:n,selectedEntryName:o,disabled:c,saving:i,onSave:d,onDelete:u,onSetActive:m}){const{t:h}=_(),[b,p]=v.useState(s),[w,R]=v.useState(r),[K,x]=v.useState(t),[j,E]=v.useState(l);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(y,{value:b,onChange:C=>p(C.target.value),placeholder:"deep-review",disabled:c||o!==null}),e.jsx(y,{value:w??"",onChange:C=>R(C.target.value||null),placeholder:"gpt-5.4",disabled:c}),e.jsxs(P,{value:K??"__unset__",onValueChange:C=>x(C==="__unset__"?null:C),disabled:c,children:[e.jsx(O,{children:e.jsx(L,{placeholder:h("codex.useGlobalProvider")})}),e.jsxs(D,{children:[e.jsx(g,{value:"__unset__",children:h("codex.useGlobalProvider")}),a.map(C=>e.jsx(g,{value:C,children:C},C))]})]}),e.jsxs(P,{value:j??"__unset__",onValueChange:C=>E(C==="__unset__"?null:C),disabled:c,children:[e.jsx(O,{children:e.jsx(L,{placeholder:h("codex.useGlobalEffort")})}),e.jsxs(D,{children:[e.jsx(g,{value:"__unset__",children:h("codex.useGlobalEffort")}),["minimal","low","medium","high","xhigh"].map(C=>e.jsx(g,{value:C,children:C},C))]})]})]}),e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(N,{variant:"outline",onClick:u,disabled:c||i||!o,children:[e.jsx(se,{className:"mr-2 h-4 w-4"}),"Delete"]}),e.jsx(N,{variant:"outline",onClick:m,disabled:c||i||!o||o===n,children:"Set active"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(N,{variant:"outline",onClick:()=>d(b,{model:w,modelProvider:K,modelReasoningEffort:j},!1),disabled:c||i||b.trim().length===0,children:[i?e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save profile"]}),e.jsxs(N,{onClick:()=>d(b,{model:w,modelProvider:K,modelReasoningEffort:j},!0),disabled:c||i||b.trim().length===0,children:[i?e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save + activate"]})]})]})]})}function As({activeProfile:s,entries:r,providerNames:t,disabled:l=!1,disabledReason:a,saving:n=!1,onSave:o,onDelete:c,onSetActive:i}){const{t:d}=_(),[u,m]=v.useState("new"),h=v.useMemo(()=>r.find(p=>p.name===u)??null,[r,u]),b=JSON.stringify(h??{name:"",values:{}});return e.jsxs(J,{title:d("codex.profiles"),badge:"profiles",icon:e.jsx(rs,{className:"h-4 w-4"}),description:"Create reusable Codex overlays and set the active default profile.",disabledReason:a,children:[e.jsxs(P,{value:u,onValueChange:m,disabled:l,children:[e.jsx(O,{children:e.jsx(L,{placeholder:"Select profile"})}),e.jsxs(D,{children:[e.jsx(g,{value:"new",children:d("codex.createNewProfile")}),r.map(p=>e.jsxs(g,{value:p.name,children:[p.name,p.name===s?" (active)":""]},p.name))]})]}),e.jsx(Ds,{initialName:h?.name??"",initialModel:h?.values.model??null,initialProvider:h?.values.modelProvider??null,initialEffort:h?.values.modelReasoningEffort??null,providerNames:t,activeProfile:s,selectedEntryName:h?.name??null,disabled:l,saving:n,onDelete:async()=>{h&&(await c(h.name),m("new"))},onSetActive:async()=>{h&&await i(h.name)},onSave:async(p,w,R)=>{await o(p,w,R),m(p)}},b)]})}function Rs({workspacePath:s,disabled:r,saving:t,onSave:l}){const{t:a}=_(),[n,o]=v.useState(s),[c,i]=v.useState("trusted");return e.jsxs("div",{className:"grid gap-2 sm:grid-cols-[1fr_160px_auto]",children:[e.jsx(y,{value:n,onChange:d=>o(d.target.value),placeholder:"~/repo or /absolute/path",disabled:r}),e.jsxs(P,{value:c,onValueChange:i,disabled:r,children:[e.jsx(O,{children:e.jsx(L,{})}),e.jsxs(D,{children:[e.jsx(g,{value:"trusted",children:a("codex.trusted")}),e.jsx(g,{value:"untrusted",children:a("codex.untrusted")})]})]}),e.jsxs(N,{onClick:()=>l(n,c),disabled:r||t,children:[t?e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save trust"]})]})}function Ms({workspacePath:s,entries:r,disabled:t=!1,disabledReason:l,saving:a=!1,onSave:n}){const{t:o}=_();return e.jsxs(J,{title:"Project trust",badge:"projects",icon:e.jsx(ts,{className:"h-4 w-4"}),description:"Trust current workspaces or remove stale trust entries without opening raw TOML.",disabledReason:l,children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Paths must be absolute or start with ",e.jsx("code",{children:"~/"}),". Relative paths are rejected so CCS does not trust the wrong folder."]}),e.jsx(Rs,{workspacePath:s,disabled:t,saving:a,onSave:n},s),e.jsx(N,{variant:"outline",className:"w-full justify-start",onClick:()=>n(s,"trusted"),disabled:t||a,children:"Trust current workspace"}),e.jsx("div",{className:"space-y-2",children:r.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:o("codex.noProjectTrustEntries")}):r.map(c=>e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:c.path}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["trust_level = ",c.trustLevel]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(N,{variant:"ghost",size:"sm",onClick:()=>n(c.path,c.trustLevel==="trusted"?"untrusted":"trusted"),disabled:t||a,children:"Toggle"}),e.jsx(N,{variant:"ghost",size:"icon",onClick:()=>n(c.path,null),disabled:t||a,children:e.jsx(se,{className:"h-4 w-4"})})]})]},c.path))})]})}const A="__unset__",Is=105e4,Fs=272e3,ke=8e5,Se=7e5,Ws=new Intl.NumberFormat("en-US");function $(s){return s??A}function B(s,r){return r&&!s.includes(r)?[r,...s]:s}function de(s){return Ws.format(s)}function Us(s){return s?.trim().toLowerCase().startsWith("gpt-5.4")??!1}function Ks(s,r){const t={};return r.model!==s.model&&(t.model=r.model),r.modelReasoningEffort!==s.modelReasoningEffort&&(t.modelReasoningEffort=r.modelReasoningEffort),r.modelContextWindow!==s.modelContextWindow&&(t.modelContextWindow=r.modelContextWindow),r.modelAutoCompactTokenLimit!==s.modelAutoCompactTokenLimit&&(t.modelAutoCompactTokenLimit=r.modelAutoCompactTokenLimit),r.modelProvider!==s.modelProvider&&(t.modelProvider=r.modelProvider),r.approvalPolicy!==s.approvalPolicy&&(t.approvalPolicy=r.approvalPolicy),r.sandboxMode!==s.sandboxMode&&(t.sandboxMode=r.sandboxMode),r.webSearch!==s.webSearch&&(t.webSearch=r.webSearch),r.toolOutputTokenLimit!==s.toolOutputTokenLimit&&(t.toolOutputTokenLimit=r.toolOutputTokenLimit),r.personality!==s.personality&&(t.personality=r.personality),t}function qs({initialValues:s,providerNames:r,disabled:t,saving:l,onSave:a}){const{t:n}=_(),[o,c]=v.useState(s),i=B(["minimal","low","medium","high","xhigh"],o.modelReasoningEffort),d=B(r,o.modelProvider),u=B(["on-request","never","untrusted"],o.approvalPolicy),m=B(["read-only","workspace-write","danger-full-access"],o.sandboxMode),h=B(["cached","live","disabled"],o.webSearch),b=B(["none","friendly","pragmatic"],o.personality),p=Ks(s,o),w=Object.keys(p).length>0,R=Us(o.model),K=x=>{const j=x.trim();return j.length>0?Number(j):null};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.model")}),e.jsx(y,{value:o.model??"",onChange:x=>c(j=>({...j,model:x.target.value||null})),placeholder:"gpt-5.4",disabled:t})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.reasoningEffort")}),e.jsxs(P,{value:$(o.modelReasoningEffort),onValueChange:x=>c(j=>({...j,modelReasoningEffort:x===A?null:x})),disabled:t,children:[e.jsx(O,{children:e.jsx(L,{placeholder:n("codex.useDefault")})}),e.jsxs(D,{children:[e.jsx(g,{value:A,children:n("codex.useDefault")}),i.map(x=>e.jsx(g,{value:x,children:x},x))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.defaultProvider")}),e.jsxs(P,{value:$(o.modelProvider),onValueChange:x=>c(j=>({...j,modelProvider:x===A?null:x})),disabled:t,children:[e.jsx(O,{children:e.jsx(L,{placeholder:n("codex.useCodexDefault")})}),e.jsxs(D,{children:[e.jsx(g,{value:A,children:n("codex.useCodexDefault")}),d.map(x=>e.jsx(g,{value:x,children:x},x))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.approvalPolicy")}),e.jsxs(P,{value:$(o.approvalPolicy),onValueChange:x=>c(j=>({...j,approvalPolicy:x===A?null:x})),disabled:t,children:[e.jsx(O,{children:e.jsx(L,{placeholder:n("codex.useDefault")})}),e.jsxs(D,{children:[e.jsx(g,{value:A,children:n("codex.useDefault")}),u.map(x=>e.jsx(g,{value:x,children:x},x))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.sandboxMode")}),e.jsxs(P,{value:$(o.sandboxMode),onValueChange:x=>c(j=>({...j,sandboxMode:x===A?null:x})),disabled:t,children:[e.jsx(O,{children:e.jsx(L,{placeholder:n("codex.useDefault")})}),e.jsxs(D,{children:[e.jsx(g,{value:A,children:n("codex.useDefault")}),m.map(x=>e.jsx(g,{value:x,children:x},x))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.webSearch")}),e.jsxs(P,{value:$(o.webSearch),onValueChange:x=>c(j=>({...j,webSearch:x===A?null:x})),disabled:t,children:[e.jsx(O,{children:e.jsx(L,{placeholder:n("codex.useDefault")})}),e.jsxs(D,{children:[e.jsx(g,{value:A,children:n("codex.useDefault")}),h.map(x=>e.jsx(g,{value:x,children:x},x))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.toolOutputTokenLimit")}),e.jsx(y,{type:"number",min:1,value:o.toolOutputTokenLimit??"",onChange:x=>c(j=>({...j,toolOutputTokenLimit:x.target.value?Number(x.target.value):null})),placeholder:"25000",disabled:t})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.personality")}),e.jsxs(P,{value:$(o.personality),onValueChange:x=>c(j=>({...j,personality:x===A?null:x})),disabled:t,children:[e.jsx(O,{children:e.jsx(L,{placeholder:n("codex.useDefault")})}),e.jsxs(D,{children:[e.jsx(g,{value:A,children:n("codex.useDefault")}),b.map(x=>e.jsx(g,{value:x,children:x},x))]})]})]})]}),e.jsxs("div",{className:"space-y-4 rounded-xl border border-amber-500/30 bg-amber-500/5 p-4 shadow-sm dark:bg-amber-400/5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(as,{className:"h-4 w-4 text-amber-600 dark:text-amber-300"}),e.jsx("p",{className:"text-sm font-semibold",children:n("codex.longContextOverride")}),e.jsx(k,{variant:"outline",className:"border-amber-500/40 bg-background/80 text-[10px] uppercase tracking-[0.16em] text-amber-700 dark:text-amber-300",children:"Manual opt-in only"}),e.jsx(k,{variant:"secondary",className:"text-[10px] uppercase tracking-[0.16em] text-muted-foreground",children:R?"GPT-5.4 selected":"GPT-5.4 reference"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Draft values only. Nothing applies until Save."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(N,{type:"button",variant:"outline",size:"sm",disabled:t,onClick:()=>c(x=>({...x,modelContextWindow:ke,modelAutoCompactTokenLimit:Se})),children:"Fill cautious pair"}),e.jsx(N,{type:"button",variant:"outline",size:"sm",disabled:t,onClick:()=>c(x=>({...x,modelContextWindow:Is})),children:"Set official max window"}),e.jsx(N,{type:"button",variant:"ghost",size:"sm",disabled:t,onClick:()=>c(x=>({...x,modelContextWindow:null,modelAutoCompactTokenLimit:null})),children:"Clear"})]})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-3",children:[e.jsxs("div",{className:"rounded-lg border bg-background/85 px-3 py-3 shadow-sm shadow-black/5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"Official max"}),e.jsx("p",{className:"mt-1 font-mono text-base font-semibold text-foreground",children:"1.05M / 1M"}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:n("codex.gptContextCap")})]}),e.jsxs("div",{className:"rounded-lg border bg-background/85 px-3 py-3 shadow-sm shadow-black/5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"Standard window"}),e.jsx("p",{className:"mt-1 font-mono text-base font-semibold text-foreground",children:de(Fs)}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:n("codex.normalUsageWindow")})]}),e.jsxs("div",{className:"rounded-lg border bg-background/85 px-3 py-3 shadow-sm shadow-black/5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"Above 272K"}),e.jsx("p",{className:"mt-1 font-mono text-base font-semibold text-foreground",children:n("codex.counts2x")}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:n("codex.usageLimitCost")})]})]}),e.jsxs("div",{className:"space-y-3 rounded-lg border bg-background/75 px-3 py-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"One cautious pair"}),e.jsxs("div",{className:"rounded-full border bg-background px-2.5 py-1 font-mono text-[11px] font-medium",children:["Context ",de(ke)]}),e.jsxs("div",{className:"rounded-full border bg-background px-2.5 py-1 font-mono text-[11px] font-medium",children:["Auto-compact ",de(Se)]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx(k,{variant:"outline",className:"border-border/70 bg-background/80 text-[10px] uppercase tracking-[0.14em] text-muted-foreground",children:"Not official"}),e.jsx(k,{variant:"outline",className:"border-border/70 bg-background/80 text-[10px] uppercase tracking-[0.14em] text-muted-foreground",children:"Draft only"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px] text-muted-foreground",children:[e.jsx("span",{children:n("codex.quickFillWarning")}),!R&&o.model?e.jsxs("span",{children:[e.jsx("code",{children:o.model})," should be checked separately."]}):null]})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.modelContextWindow")}),e.jsx(y,{"aria-label":n("codex.modelContextWindow"),type:"number",min:1,value:o.modelContextWindow??"",onChange:x=>c(j=>({...j,modelContextWindow:K(x.target.value)})),placeholder:"Unset",disabled:t}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Writes ",e.jsx("code",{children:"model_context_window"}),". Leave unset to keep Codex defaults."]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.autoCompactTokenLimit")}),e.jsx(y,{"aria-label":n("codex.autoCompactTokenLimit"),type:"number",min:1,value:o.modelAutoCompactTokenLimit??"",onChange:x=>c(j=>({...j,modelAutoCompactTokenLimit:K(x.target.value)})),placeholder:"Unset",disabled:t}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Writes ",e.jsx("code",{children:"model_auto_compact_token_limit"}),". Leave unset to keep model defaults."]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px] text-muted-foreground",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-[0.14em]",children:"Docs"}),e.jsx("a",{href:"https://developers.openai.com/api/docs/models/gpt-5.4",target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:"GPT-5.4 model page"}),e.jsx("a",{href:"https://openai.com/index/introducing-gpt-5-4/",target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:"Release notes"}),e.jsx("a",{href:"https://developers.openai.com/codex/config-reference",target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:"Config reference"})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(N,{onClick:()=>a(p),disabled:t||l||!w,children:[l?e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save top-level settings"]})})]})}function Vs({values:s,providerNames:r,disabled:t=!1,disabledReason:l,saving:a=!1,onSave:n}){return e.jsx(J,{title:"Top-level controls",badge:"config.toml",icon:e.jsx(ns,{className:"h-4 w-4"}),description:"Structured controls for the stable top-level Codex settings users touch most often. Unsupported upstream shapes stay untouched and should be edited in raw TOML.",disabledReason:l,children:e.jsx(qs,{initialValues:s,providerNames:r,disabled:t,saving:a,onSave:n},JSON.stringify(s))})}function Gs({workspacePath:s,activeProfile:r,topLevelSettings:t,projectTrustEntries:l,profileEntries:a,modelProviderEntries:n,mcpServerEntries:o,featureCatalog:c,featureState:i,disabled:d,disabledReason:u,saving:m,onPatch:h}){const{t:b}=_();return e.jsx(pe,{className:"h-full",children:e.jsxs("div",{className:"space-y-6 pr-1 pb-6",children:[e.jsxs("div",{className:"group relative overflow-hidden rounded-xl border border-border/80 bg-background/50 p-5 shadow-sm transition-all hover:bg-background hover:shadow-md dark:border-border/60",children:[e.jsx("div",{className:"absolute inset-x-0 -top-px h-px bg-gradient-to-r from-transparent via-foreground/15 to-transparent transition-opacity group-hover:via-foreground/30"}),e.jsxs("div",{className:"flex flex-col gap-6 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{className:"flex-1 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary transition-colors group-hover:border-primary/30",children:e.jsx(ls,{className:"h-4 w-4"})}),e.jsx("div",{children:e.jsx("h2",{className:"text-base font-semibold tracking-tight text-foreground",children:b("codex.controlCenter")})})]}),e.jsxs("ul",{className:"grid gap-3 sm:grid-cols-2 text-sm text-muted-foreground",children:[e.jsxs("li",{className:"flex items-start gap-2.5",children:[e.jsx(os,{className:"h-4 w-4 shrink-0 text-muted-foreground/60 mt-0.5"}),e.jsxs("span",{className:"leading-relaxed",children:["Writes exclusively to user-layer"," ",e.jsx("code",{className:"text-[11px] bg-muted/70 px-1.5 py-0.5 rounded border border-border/50",children:"config.toml"})]})]}),e.jsxs("li",{className:"flex items-start gap-2.5",children:[e.jsx(is,{className:"h-4 w-4 shrink-0 text-muted-foreground/60 mt-0.5"}),e.jsx("span",{className:"leading-relaxed",children:"Does not reflect repo trust layers or CLI overrides"})]})]})]}),e.jsx("div",{className:"shrink-0 lg:w-[280px]",children:e.jsx("div",{className:"relative overflow-hidden rounded-lg border border-amber-500/20 bg-amber-500/5 p-4 transition-colors group-hover:border-amber-500/30 group-hover:bg-amber-500/10 dark:border-amber-400/10 dark:bg-amber-400/5",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(cs,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-bold text-amber-700 dark:text-amber-300 uppercase tracking-wider",children:"Formatting Note"}),e.jsx("p",{className:"text-[13px] leading-relaxed text-amber-800/80 dark:text-amber-200/70",children:"Saves normalize TOML formatting and strip comments. Switch to the raw editor if exact layout matters."})]})]})})})]})]}),e.jsx(Vs,{values:t,providerNames:n.map(p=>p.name),disabled:d,disabledReason:u,saving:m,onSave:p=>h({kind:"top-level",values:p},b("toasts.codexSaved"))}),e.jsx(Ms,{workspacePath:s,entries:l,disabled:d,disabledReason:u,saving:m,onSave:(p,w)=>h({kind:"project-trust",path:p,trustLevel:w},w?"Saved project trust entry.":"Removed project trust entry.")}),e.jsx(As,{activeProfile:r,entries:a,providerNames:n.map(p=>p.name),disabled:d,disabledReason:u,saving:m,onSave:(p,w,R)=>h({kind:"profile",action:"upsert",name:p,values:w,setAsActive:R},"Saved profile."),onDelete:p=>h({kind:"profile",action:"delete",name:p},"Deleted profile."),onSetActive:p=>h({kind:"profile",action:"set-active",name:p},"Set active profile.")}),e.jsx(Ls,{entries:n,disabled:d,disabledReason:u,saving:m,onSave:(p,w)=>h({kind:"model-provider",action:"upsert",name:p,values:w},"Saved model provider."),onDelete:p=>h({kind:"model-provider",action:"delete",name:p},"Deleted model provider.")}),e.jsx(_s,{entries:o,disabled:d,disabledReason:u,saving:m,onSave:(p,w)=>h({kind:"mcp-server",action:"upsert",name:p,values:w},"Saved MCP server."),onDelete:p=>h({kind:"mcp-server",action:"delete",name:p},"Deleted MCP server.")}),e.jsx(ks,{catalog:c,state:i,disabled:d,disabledReason:u,onToggle:(p,w)=>h({kind:"feature",feature:p,enabled:w},"Saved feature toggle.")})]})})}const Oe=`model_provider = "cliproxy"
|
|
2
2
|
|
|
3
3
|
[model_providers.cliproxy]
|
|
4
4
|
base_url = "http://127.0.0.1:8317/api/provider/codex"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{A as g,a as d,b as m,c as x,d as D,e as h,f,g as j}from"./alert-dialog-
|
|
1
|
+
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{A as g,a as d,b as m,c as x,d as D,e as h,f,g as j}from"./alert-dialog-CuN8HTEx.js";import{a as A}from"./index-BDfXfBTa.js";function b({open:l,onConfirm:o,onCancel:r,title:a,description:s,confirmText:t,variant:n="default"}){const{t:i}=A();return e.jsx(g,{open:l,onOpenChange:c=>!c&&r(),children:e.jsxs(d,{children:[e.jsxs(m,{children:[e.jsx(x,{children:a}),e.jsx(D,{children:s})]}),e.jsxs(h,{children:[e.jsx(f,{onClick:r,children:i("confirmDialog.cancel")}),e.jsx(j,{onClick:o,className:n==="destructive"?"bg-red-600 hover:bg-red-700 text-white":"",children:t??i("confirmDialog.confirm")})]})]})})}export{b as C};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{bb as N,bc as ke,a as S,B as P,d as b,V as oe,n as V,L,aF as Z,I as de,r as Fe,s as Te,t as Me,v as Le,w as ee,x as ge,bd as Re,S as y,be as Ae,bf as Ee,bg as Oe,Q as _e,R as qe,U as te,bh as De,c as ie}from"./index-DNmWbKbN.js";import{r as w}from"./react-vendor-CNOkPC89.js";import{a as Ie,u as D,b as R}from"./tanstack-CrmUhA7Z.js";import{C as Ue}from"./confirm-dialog-BICDz_zm.js";import{R as fe,L as je,at as Ke,aa as Qe,Z as me,_ as Je,T as ve,aw as $e,b as ze,ad as Be,aE as Ge,aO as ue,K as He,Y as We,aP as Ve,x as we,I as Ne}from"./icons-KVCk4_U8.js";import{S as ne}from"./separator-DJ0ku_ak.js";import{S as Ye}from"./searchable-select-FJPe_YWv.js";import{t as I}from"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-BA39vaYL.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-Zb8sVEtn.js";import{bb as N,bc as ke,a as S,B as P,d as b,V as oe,n as V,L,aF as Z,I as de,r as Fe,s as Te,t as Me,v as Le,w as ee,x as ge,bd as Re,S as y,be as Ae,bf as Ee,bg as Oe,Q as _e,R as qe,U as te,bh as De,c as ie}from"./index-BDfXfBTa.js";import{r as w}from"./react-vendor-CNOkPC89.js";import{a as Ie,u as D,b as R}from"./tanstack-CrmUhA7Z.js";import{C as Ue}from"./confirm-dialog-D_5v8muu.js";import{R as fe,L as je,at as Ke,aa as Qe,Z as me,_ as Je,T as ve,aw as $e,b as ze,ad as Be,aE as Ge,aO as ue,K as He,Y as We,aP as Ve,x as we,I as Ne}from"./icons-KVCk4_U8.js";import{S as ne}from"./separator-DziIoy6O.js";import{S as Ye}from"./searchable-select-DbhlbNK0.js";import{t as I}from"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-CuN8HTEx.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):`{
|
|
2
2
|
"env": {}
|
|
3
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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as b}from"./react-vendor-CNOkPC89.js";import{t as o}from"./notifications-B2HqRBj7.js";import{bb as w,bc as us,a as Le,B as A,d as p,c as H,n as G,Q as ms,R as gs,U as le,V as de,L as F,I as ue,aF as Te,bh as hs,ag as xs,ah as fs,ai as ps,aj as js,ak as Ps,aC as bs,bd as ws}from"./index-DNmWbKbN.js";import{a as ys,u as Q,b as T}from"./tanstack-CrmUhA7Z.js";import{D as Ie}from"./default-ports-1QQSffYX.js";import{S as vs}from"./separator-DJ0ku_ak.js";import{S as Ns}from"./searchable-select-FJPe_YWv.js";import{R as Re,T as Cs,ah as Ss,K as J,ad as ks,aw as me,aP as Fe,aO as _s,L as R,J as Ms,at as As,aa as Ds,Z as ge,x as Ts,I as Rs}from"./icons-KVCk4_U8.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";function Fs(s){if(!s||typeof s!="object")return!1;const a=s;return typeof a.message=="string"&&typeof a.stage=="string"&&typeof a.status=="number"&&typeof a.duration_ms=="number"&&typeof a.ok=="boolean"}function Ls(s){if(!s||typeof s!="object"||!("error"in s))return null;const a=s;return typeof a.error=="string"?a.error:null}async function Is(){const s=await fetch(w("/cursor/status"));if(!s.ok)throw new Error("Failed to fetch cursor status");return s.json()}async function Os(){const s=await fetch(w("/cursor/settings"));if(!s.ok)throw new Error("Failed to fetch cursor config");return s.json()}async function Es(){const s=await fetch(w("/cursor/models"));if(!s.ok)throw new Error("Failed to fetch cursor models");return s.json()}async function Ks(){const s=await fetch(w("/cursor/settings/raw"));if(!s.ok)throw new Error("Failed to fetch cursor raw settings");return s.json()}async function zs(s){const a=await fetch(w("/cursor/settings"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!a.ok)throw new Error("Failed to update cursor config");return a.json()}async function qs(s){const a=await fetch(w("/cursor/settings/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(a.status===409)throw new us("Cursor raw settings changed externally");if(!a.ok)throw new Error("Failed to save cursor raw settings");return a.json()}async function Gs(){const s=await fetch(w("/cursor/auth/auto-detect"),{method:"POST"});if(!s.ok){const a=await s.json().catch(()=>({error:"Auto-detect failed"}));throw new Error(a.error||"Auto-detect failed")}return s.json()}async function Qs(s){const a=await fetch(w("/cursor/auth/import"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!a.ok){const c=await a.json().catch(()=>({error:"Manual import failed"}));throw new Error(c.error||"Manual import failed")}return a.json()}async function Js(){const s=await fetch(w("/cursor/daemon/start"),{method:"POST"});if(!s.ok)throw new Error("Failed to start cursor daemon");return s.json()}async function Us(){const s=await fetch(w("/cursor/daemon/stop"),{method:"POST"});if(!s.ok)throw new Error("Failed to stop cursor daemon");return s.json()}async function Bs(){const s=await fetch(w("/cursor/probe"),{method:"POST"}),a=await s.json().catch(()=>null);return Fs(a)?a:{ok:!1,stage:"runtime",status:s.status,duration_ms:0,error_type:"runtime_error",message:Ls(a)??"Failed to run live probe"}}function Hs(){const s=ys(),a=Q({queryKey:["cursor-status"],queryFn:Is,refetchInterval:5e3}),c=Q({queryKey:["cursor-config"],queryFn:Os}),d=Q({queryKey:["cursor-models"],queryFn:Es}),l=Q({queryKey:["cursor-raw-settings"],queryFn:Ks}),g=()=>{s.invalidateQueries({queryKey:["cursor-status"]}),s.invalidateQueries({queryKey:["cursor-config"]}),s.invalidateQueries({queryKey:["cursor-models"]}),s.invalidateQueries({queryKey:["cursor-raw-settings"]})},h=T({mutationFn:zs,onSuccess:g}),u=T({mutationFn:qs,onSuccess:g}),r=T({mutationFn:Gs,onSuccess:g}),m=T({mutationFn:Qs,onSuccess:g}),x=T({mutationFn:Js,onSuccess:g}),i=T({mutationFn:Us,onSuccess:g}),P=T({mutationFn:Bs,onSettled:()=>{s.invalidateQueries({queryKey:["cursor-status"]}),s.invalidateQueries({queryKey:["cursor-models"]})}});return b.useMemo(()=>({status:a.data,statusLoading:a.isLoading,statusError:a.error,refetchStatus:a.refetch,config:c.data,configLoading:c.isLoading,refetchConfig:c.refetch,models:d.data?.models??[],currentModel:d.data?.current??null,modelsLoading:d.isLoading,rawSettings:l.data,rawSettingsLoading:l.isLoading,refetchRawSettings:l.refetch,updateConfig:h.mutate,updateConfigAsync:h.mutateAsync,isUpdatingConfig:h.isPending,saveRawSettings:u.mutate,saveRawSettingsAsync:u.mutateAsync,isSavingRawSettings:u.isPending,autoDetectAuth:r.mutate,autoDetectAuthAsync:r.mutateAsync,isAutoDetectingAuth:r.isPending,autoDetectAuthResult:r.data,importManualAuth:m.mutate,importManualAuthAsync:m.mutateAsync,isImportingManualAuth:m.isPending,manualAuthResult:m.data,startDaemon:x.mutate,startDaemonAsync:x.mutateAsync,isStartingDaemon:x.isPending,stopDaemon:i.mutate,stopDaemonAsync:i.mutateAsync,isStoppingDaemon:i.isPending,runProbe:P.mutate,runProbeAsync:P.mutateAsync,isRunningProbe:P.isPending,probeResult:P.data,resetProbe:P.reset}),[a.data,a.isLoading,a.error,a.refetch,c.data,c.isLoading,c.refetch,d.data,d.isLoading,l.data,l.isLoading,l.refetch,h.mutate,h.mutateAsync,h.isPending,u.mutate,u.mutateAsync,u.isPending,r.mutate,r.mutateAsync,r.isPending,r.data,m.mutate,m.mutateAsync,m.isPending,m.data,x.mutate,x.mutateAsync,x.isPending,i.mutate,i.mutateAsync,i.isPending,P.mutate,P.mutateAsync,P.isPending,P.data,P.reset])}function he(s,a){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:a?.auto_start??null,model:a?.model??null})}function U(s){return{port:String(s?.port??Ie),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 C(s,a,c){return s.find(l=>a.some(g=>g.test(l.id)))?.id??c}function xe(s){return s.toLowerCase().replace(/[^a-z0-9]/g,"")}function S(s,a,c){const d=new Set(a.map(xe)),l=s.find(h=>d.has(xe(h.id)));if(l)return l.id;const g=s.find(h=>d.has(xe(h.name)));return g?g.id:c}function Vs(s){try{const a=JSON.parse(s||"{}");return!a||typeof a!="object"||Array.isArray(a)?{isValid:!1,error:"Raw settings must be a JSON object"}:{isValid:!0,settings:a}}catch(a){return{isValid:!1,error:a.message||"Invalid JSON"}}}function B({label:s,description:a,value:c,models:d,disabled:l,allowDefaultFallback:g=!1,onChange:h}){const{t:u}=Le(),r=c||(g?"__default":""),m=b.useMemo(()=>{const x=d.map(i=>({value:i.id,groupKey:"models",searchText:`${i.name||i.id} ${i.id}`,keywords:[i.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:i.name||i.id}),i.provider&&e.jsx(A,{variant:"outline",className:"text-[9px] h-4 px-1 capitalize",children:i.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:i.name||i.id}),e.jsx(A,{variant:"outline",className:"text-[9px] h-4 px-1 capitalize",children:i.provider})]})}));return g?[{value:"__default",groupKey:"models",searchText:u("cursorPage.useDefaultModel"),triggerContent:e.jsx("span",{className:"truncate font-mono text-xs",children:u("cursorPage.useDefaultModel")}),itemContent:e.jsx("span",{children:u("cursorPage.useDefaultModel")})},...x]:x},[g,d,u]);return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx(F,{className:"text-xs font-medium",children:s}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a})]}),e.jsx(Ns,{value:r||void 0,onChange:x=>{if(g&&x==="__default"){h("");return}h(x)},disabled:l,placeholder:u("cursorPage.selectModel"),searchPlaceholder:u("searchableSelect.searchModels"),emptyText:u("searchableSelect.noResults"),triggerClassName:"h-9",groups:[{key:"models",label:u("cursorPage.availableModelCount",{count:d.length})}],options:m})]})}function fe({icon:s,label:a,ok:c,detail:d}){return e.jsxs("div",{className:"flex items-center gap-3 rounded-lg bg-muted/50 px-3 py-2",children:[e.jsx(s,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("p",{className:"text-sm",children:a})}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[c?e.jsx(Ts,{className:"h-4 w-4 text-green-500"}):e.jsx(Rs,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:H("text-xs",c?"text-green-500":"text-muted-foreground"),title:d,children:d})]})]})}function ia(){const{t:s}=Le(),{status:a,statusLoading:c,refetchStatus:d,config:l,refetchConfig:g,updateConfigAsync:h,isUpdatingConfig:u,models:r,modelsLoading:m,currentModel:x,rawSettings:i,rawSettingsLoading:P,refetchRawSettings:Oe,saveRawSettingsAsync:Ee,isSavingRawSettings:pe,autoDetectAuthAsync:Ke,isAutoDetectingAuth:je,importManualAuthAsync:ze,isImportingManualAuth:Pe,startDaemonAsync:qe,isStartingDaemon:Ge,stopDaemonAsync:Qe,isStoppingDaemon:be,runProbeAsync:Je,isRunningProbe:V,probeResult:W,resetProbe:Ue}=Hs(),[D,X]=b.useState(()=>U()),[y,Z]=b.useState(!1),[we,Be]=b.useState("{}"),[L,$]=b.useState(!1),[He,E]=b.useState(!1),[Y,ye]=b.useState(""),[ee,ve]=b.useState(""),[Ne,Ce]=b.useState(()=>W?he(a,l):null),k=U(l),Se=y?D.port:k.port,se=y?D.auto_start:k.auto_start,ae=y?D.ghost_mode:k.ghost_mode,v=y?D.model:k.model,te=y?D.opus_model:k.opus_model,re=y?D.sonnet_model:k.sonnet_model,ne=y?D.haiku_model:k.haiku_model,oe=L?we:JSON.stringify(i?.settings??{},null,2),ke=!!i,I=b.useMemo(()=>Vs(oe),[oe]),_e=I.isValid,K=y||L,Ve=!L||ke&&_e,We=he(a,l),j=W&&!K&&Ne!==null&&Ne===We?W:null,z=b.useMemo(()=>{const t=new Set,n=[...r].sort((M,ce)=>M.name.localeCompare(ce.name)),f=n.filter(M=>t.has(M.id)?!1:(t.add(M.id),!0));return v&&!n.some(M=>M.id===v)?[{id:v,name:v,provider:"custom"},...f]:f},[r,v]),N=t=>{X(n=>t(y?n:k)),Z(!0)},_=()=>{Ue(),Ce(null)},Xe=(t=l)=>{X(U(t)),Z(!1)},Ze=!!(a?.enabled&&a?.authenticated&&!a?.token_expired),$e=b.useMemo(()=>a?.enabled?e.jsx(A,{children:s("cursorPage.enabled")}):e.jsx(A,{variant:"secondary",children:s("cursorPage.disabled")}),[a?.enabled,s]),Ye=async({suppressSuccessToast:t=!1}={})=>{const n=Number(Se);if(!Number.isInteger(n)||n<1||n>65535)return o.error(s("cursorPage.invalidPort")),!1;if(!v.trim())return o.error(s("cursorPage.defaultModelRequired")),!1;try{return await h({port:n,auto_start:se,ghost_mode:ae,model:v,opus_model:te||void 0,sonnet_model:re||void 0,haiku_model:ne||void 0}),Z(!1),X(U({port:n,auto_start:se,ghost_mode:ae,model:v,opus_model:te||void 0,sonnet_model:re||void 0,haiku_model:ne||void 0})),_(),t||o.success(s("cursorPage.savedConfig")),!0}catch(f){return o.error(f.message||s("cursorPage.failedSaveConfig")),!1}},ie=t=>{if(m){o.error(s("cursorPage.modelsLoadingWait"));return}if(r.length===0){o.error(s("cursorPage.noModelsAvailable"));return}const n=v||x||r[0]?.id||"gpt-5.3-codex",f=S(r,["gpt-5.3-codex","gpt53codex","GPT-5.3 Codex"],C(r,[/gpt[-.]?5.*codex/i],n)),M=S(r,["gpt-5.1-codex-max","gpt51codexmax","GPT-5.1 Codex Max"],C(r,[/gpt[-.]?5.*codex.*max/i],f)),ce=S(r,["gpt-5-fast","gpt5fast","GPT-5 Fast"],C(r,[/gpt[-.]?5.*fast/i],f)),cs=S(r,["gpt-5-mini","gpt5mini","GPT-5 Mini"],C(r,[/gpt[-.]?5.*mini/i],ce)),Ae=S(r,["claude-4.6-opus","claude46opus","Claude 4.6 Opus"],C(r,[/claude[-.]?4\.?6.*opus/i,/claude.*opus/i],f)),De=S(r,["claude-4.5-sonnet","claude45sonnet","Claude 4.5 Sonnet"],C(r,[/claude[-.]?4\.?5.*sonnet/i,/claude.*sonnet/i],f)),ls=S(r,["claude-4.5-haiku","claude45haiku","Claude 4.5 Haiku"],C(r,[/claude[-.]?4\.?5.*haiku/i,/haiku/i],De)),q=S(r,["gemini-3-pro","gemini3pro","Gemini 3 Pro"],C(r,[/gemini[-.]?3.*pro/i],f)),ds=S(r,["gemini-3-flash","gemini3flash","Gemini 3 Flash"],C(r,[/gemini[-.]?3.*flash/i,/gemini[-.]?2\.?5.*flash/i],q));if(t==="codex53"){N(O=>({...O,model:f,opus_model:M,sonnet_model:f,haiku_model:cs})),o.success(s("cursorPage.appliedCodexPreset"));return}if(t==="claude46"){N(O=>({...O,model:Ae,opus_model:Ae,sonnet_model:De,haiku_model:ls})),o.success(s("cursorPage.appliedClaudePreset"));return}N(O=>({...O,model:q,opus_model:q,sonnet_model:q,haiku_model:ds})),o.success(s("cursorPage.appliedGeminiPreset"))},Me=async t=>{try{await h({enabled:t}),_(),o.success(s(t?"cursorPage.integrationEnabled":"cursorPage.integrationDisabled"))}catch(n){o.error(n.message||s("cursorPage.failedUpdateIntegration"))}},es=async()=>{try{await Ke(),_(),o.success(s("cursorPage.credentialsImported"))}catch(t){o.error(t.message||s("cursorPage.autoDetectFailed"))}},ss=async()=>{if(!Y.trim()||!ee.trim()){o.error(s("cursorPage.manualRequired"));return}try{await ze({accessToken:Y.trim(),machineId:ee.trim()}),_(),o.success(s("cursorPage.credentialsImported")),E(!1),ye(""),ve("")}catch(t){o.error(t.message||s("cursorPage.manualImportFailed"))}},as=async()=>{try{const t=await qe();if(!t.success){o.error(t.error||s("cursorPage.failedStartDaemon"));return}_(),o.success(t.pid?s("cursorPage.daemonStartedWithPid",{pid:t.pid}):s("cursorPage.daemonStarted"))}catch(t){o.error(t.message||s("cursorPage.failedStartDaemon"))}},ts=async()=>{try{const t=await Qe();if(!t.success){o.error(t.error||s("cursorPage.failedStopDaemon"));return}_(),o.success(s("cursorPage.daemonStopped"))}catch(t){o.error(t.message||s("cursorPage.failedStopDaemon"))}},rs=async()=>{if(K){o.error(s("cursorPage.probeSaveFirst"));return}try{const t=await Je(),n=await d();if(Ce(he(n.data??a,l)),t.ok){o.success(s("cursorPage.probeSucceeded"));return}o.error(t.message||s("cursorPage.probeFailed"))}catch(t){o.error(t.message||s("cursorPage.probeFailed"))}},ns=async({suppressSuccessToast:t=!1}={})=>{if(!ke)return o.error(s("cursorPage.rawLoading")),!1;if(!I.isValid||!I.settings)return o.error(I.error||s("cursorPage.invalidJson")),!1;try{return await Ee({settings:I.settings,expectedMtime:i?.mtime}),$(!1),_(),t||o.success(s("cursorPage.rawSaved")),!0}catch(n){return ws(n)?o.error(s("cursorPage.rawChanged")):o.error(n.message||s("cursorPage.failedSaveRaw")),!1}},os=async()=>{if(!K)return;const t=y,n=L;t&&!await Ye({suppressSuccessToast:n})||n&&!await ns({suppressSuccessToast:t})||t&&n&&o.success(s("cursorPage.savedAll"))},is=async()=>{$(!1),_();const[,t]=await Promise.all([d(),g(),Oe()]);Xe(t.data??l)};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(A,{variant:"outline",className:"h-5 border-amber-500/60 bg-amber-500/10 px-1.5 text-[10px] font-semibold uppercase tracking-wide text-amber-800 dark:text-amber-300",children:s("cursorPage.beta")}),$e]}),e.jsx(p,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>d(),disabled:c,"aria-label":s("cursorPage.refreshStatus"),title:s("cursorPage.refreshStatus"),children:e.jsx(Re,{className:H("w-4 h-4",c&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("cursorPage.subtitle")})]}),e.jsx(G,{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(Cs,{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:"space-y-2",children:[e.jsx(fe,{icon:Ss,label:s("cursorPage.integration"),ok:!!a?.enabled,detail:a?.enabled?s("cursorPage.enabled"):s("cursorPage.disabled")}),e.jsx(fe,{icon:J,label:s("cursorPage.authentication"),ok:!!(a?.authenticated&&!a?.token_expired),detail:a?.authenticated?a?.token_expired?s("cursorPage.expired"):a.auth_method??s("cursorPage.connected"):s("cursorPage.notConnected")}),e.jsx(fe,{icon:ks,label:s("cursorPage.daemon"),ok:!!a?.daemon_running,detail:a?.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(me,{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(A,{variant:j?"outline":"secondary",className:H(j?.ok&&"border-green-500/40 text-green-600 dark:text-green-300",j&&!j.ok&&"border-red-500/40 text-red-600 dark:text-red-300"),children:j?j.ok?s("cursorPage.probeSucceeded"):s("cursorPage.probeFailed"):s("cursorPage.probeNotRun")})]}),j?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:j.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:j.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:[j.duration_ms," ms"]})]}),j.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:j.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:j.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")}),a?.enabled?e.jsxs(p,{variant:"outline",size:"sm",className:"w-full",onClick:()=>Me(!1),disabled:u,children:[e.jsx(Fe,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.disableIntegration")]}):e.jsxs(p,{size:"sm",className:"w-full",onClick:()=>Me(!0),disabled:u,children:[e.jsx(_s,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.enableIntegration")]}),e.jsxs(p,{variant:"outline",size:"sm",className:"w-full",onClick:es,disabled:je,children:[je?e.jsx(R,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(J,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.autoDetectAuth")]}),e.jsxs(p,{variant:"outline",size:"sm",className:"w-full",onClick:()=>E(!0),children:[e.jsx(J,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.manualAuthImport")]}),e.jsxs(p,{variant:"outline",size:"sm",className:"w-full",onClick:rs,disabled:V,children:[V?e.jsx(R,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(me,{className:"w-3.5 h-3.5 mr-1.5"}),s(V?"cursorPage.probing":j?"cursorPage.rerunLiveProbe":"cursorPage.runLiveProbe")]}),a?.daemon_running?e.jsxs(p,{variant:"outline",size:"sm",className:"w-full",onClick:ts,disabled:be,children:[be?e.jsx(R,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(Fe,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.stopDaemon")]}):e.jsxs(p,{size:"sm",className:"w-full",onClick:as,disabled:!Ze,children:[Ge?e.jsx(R,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(Ms,{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:a?.port??l?.port??Ie})]})})]}),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")}),i&&e.jsx(A,{variant:"outline",className:"text-xs",children:"cursor.settings.json"})]}),i&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[s("cursorPage.lastModified")," ",i.exists?new Date(i.mtime).toLocaleString():s("cursorPage.neverSaved")]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p,{variant:"ghost",size:"sm",onClick:is,disabled:c||P,"aria-label":s("cursorPage.refreshConfiguration"),title:s("cursorPage.refreshConfiguration"),children:e.jsx(Re,{className:H("w-4 h-4",(c||P)&&"animate-spin")})}),e.jsx(p,{size:"sm",onClick:os,disabled:u||pe||!K||!Ve,children:u||pe?e.jsxs(e.Fragment,{children:[e.jsx(R,{className:"w-4 h-4 mr-1 animate-spin"}),s("cursorPage.saving")]}):e.jsxs(e.Fragment,{children:[e.jsx(As,{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(ms,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(gs,{className:"w-full",children:[e.jsx(le,{value:"config",className:"flex-1",children:s("cursorPage.modelConfig")}),e.jsx(le,{value:"settings",className:"flex-1",children:s("cursorPage.settings")}),e.jsx(le,{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(de,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(G,{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(Ds,{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(p,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>ie("codex53"),disabled:m||r.length===0,title:"OpenAI-only mapping: GPT-5.3 Codex / Codex Max / GPT-5 Mini",children:[e.jsx(ge,{className:"w-3 h-3"}),"GPT-5.3 Codex"]}),e.jsxs(p,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>ie("claude46"),disabled:m||r.length===0,title:"Claude-first mapping: Opus 4.6 / Sonnet 4.5 / Haiku 4.5",children:[e.jsx(ge,{className:"w-3 h-3"}),"Claude 4.6"]}),e.jsxs(p,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>ie("gemini3"),disabled:m||r.length===0,title:"Gemini-first mapping: Gemini 3 Pro + Gemini 3 Flash",children:[e.jsx(ge,{className:"w-3 h-3"}),"Gemini 3 Pro"]})]})]}),e.jsx(vs,{}),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(B,{label:s("cursorPage.defaultModel"),description:s("cursorPage.defaultModelDesc"),value:v,models:z,disabled:m,onChange:t=>{N(n=>({...n,model:t}))}}),e.jsx(B,{label:s("cursorPage.opusModel"),description:s("cursorPage.opusModelDesc"),value:te,models:z,disabled:m,allowDefaultFallback:!0,onChange:t=>{N(n=>({...n,opus_model:t}))}}),e.jsx(B,{label:s("cursorPage.sonnetModel"),description:s("cursorPage.sonnetModelDesc"),value:re,models:z,disabled:m,allowDefaultFallback:!0,onChange:t=>{N(n=>({...n,sonnet_model:t}))}}),e.jsx(B,{label:s("cursorPage.haikuModel"),description:s("cursorPage.haikuModelDesc"),value:ne,models:z,disabled:m,allowDefaultFallback:!0,onChange:t=>{N(n=>({...n,haiku_model:t}))}})]})]})]})})}),e.jsx(de,{value:"settings",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(G,{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(F,{htmlFor:"cursor-port",className:"text-xs",children:s("cursorPage.port")}),e.jsx(ue,{id:"cursor-port",type:"number",min:1,max:65535,className:"max-w-[150px] h-8",value:Se,onChange:t=>{N(n=>({...n,port:t.target.value}))}})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(F,{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(Te,{id:"cursor-auto-start",checked:se,onCheckedChange:t=>{N(n=>({...n,auto_start:t}))}})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(F,{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(Te,{id:"cursor-ghost-mode",checked:ae,onCheckedChange:t=>{N(n=>({...n,ghost_mode:t}))}})]})]})})})}),e.jsx(de,{value:"info",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(G,{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"})]}),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:i?.path??"~/.ccs/cursor.settings.json"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Model mapping writes `ANTHROPIC_MODEL`, `ANTHROPIC_DEFAULT_OPUS_MODEL`, `ANTHROPIC_DEFAULT_SONNET_MODEL`, and `ANTHROPIC_DEFAULT_HAIKU_MODEL` in `cursor.settings.json`."})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:s("cursorPage.availableModels")}),m?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(R,{className:"w-4 h-4 animate-spin"}),s("cursorPage.loadingModels")]}):r.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:s("cursorPage.noModels")}):e.jsx("div",{className:"space-y-2",children:r.map(t=>e.jsxs("div",{className:"rounded-lg border px-3 py-2 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:t.id}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[t.name," • ",t.provider]})]}),t.id===x&&e.jsx(A,{children:s("cursorPage.default")})]},t.id))})]})]})})})]})]})}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-2 bg-muted/30 border-b flex items-center gap-2 shrink-0 h-[45px]",children:[e.jsx(me,{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(hs,{rawJsonContent:oe,isRawJsonValid:_e,rawJsonEdits:L?we:null,rawSettingsEnv:i?.settings?.env,onChange:t=>{$(!0),Be(t)}})]})]})]})})]}),e.jsx(xs,{open:He,onOpenChange:E,children:e.jsxs(fs,{children:[e.jsxs(ps,{children:[e.jsx(js,{children:s("cursorPage.manualImportTitle")}),e.jsx(Ps,{children:s("cursorPage.manualImportDesc")})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(F,{htmlFor:"cursor-manual-token",children:s("cursorPage.accessToken")}),e.jsx(ue,{id:"cursor-manual-token",value:Y,onChange:t=>ye(t.target.value),placeholder:s("cursorPage.accessTokenPlaceholder")})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(F,{htmlFor:"cursor-manual-machine-id",children:s("cursorPage.machineId")}),e.jsx(ue,{id:"cursor-manual-machine-id",value:ee,onChange:t=>ve(t.target.value),placeholder:s("cursorPage.machineIdPlaceholder")})]})]}),e.jsxs(bs,{children:[e.jsx(p,{variant:"outline",onClick:()=>E(!1),children:s("cursorPage.cancel")}),e.jsxs(p,{onClick:ss,disabled:Pe,children:[Pe?e.jsx(R,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(J,{className:"w-4 h-4 mr-2"}),s("cursorPage.import")]})]})]})})]})}export{ia as CursorPage};
|
|
1
|
+
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as b}from"./react-vendor-CNOkPC89.js";import{t as o}from"./notifications-B2HqRBj7.js";import{bb as w,bc as us,a as Le,B as A,d as p,c as H,n as G,Q as ms,R as gs,U as le,V as de,L as F,I as ue,aF as Te,bh as hs,ag as xs,ah as fs,ai as ps,aj as js,ak as Ps,aC as bs,bd as ws}from"./index-BDfXfBTa.js";import{a as ys,u as Q,b as T}from"./tanstack-CrmUhA7Z.js";import{D as Ie}from"./default-ports-1QQSffYX.js";import{S as vs}from"./separator-DziIoy6O.js";import{S as Ns}from"./searchable-select-DbhlbNK0.js";import{R as Re,T as Cs,ah as Ss,K as J,ad as ks,aw as me,aP as Fe,aO as _s,L as R,J as Ms,at as As,aa as Ds,Z as ge,x as Ts,I as Rs}from"./icons-KVCk4_U8.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";function Fs(s){if(!s||typeof s!="object")return!1;const a=s;return typeof a.message=="string"&&typeof a.stage=="string"&&typeof a.status=="number"&&typeof a.duration_ms=="number"&&typeof a.ok=="boolean"}function Ls(s){if(!s||typeof s!="object"||!("error"in s))return null;const a=s;return typeof a.error=="string"?a.error:null}async function Is(){const s=await fetch(w("/cursor/status"));if(!s.ok)throw new Error("Failed to fetch cursor status");return s.json()}async function Os(){const s=await fetch(w("/cursor/settings"));if(!s.ok)throw new Error("Failed to fetch cursor config");return s.json()}async function Es(){const s=await fetch(w("/cursor/models"));if(!s.ok)throw new Error("Failed to fetch cursor models");return s.json()}async function Ks(){const s=await fetch(w("/cursor/settings/raw"));if(!s.ok)throw new Error("Failed to fetch cursor raw settings");return s.json()}async function zs(s){const a=await fetch(w("/cursor/settings"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!a.ok)throw new Error("Failed to update cursor config");return a.json()}async function qs(s){const a=await fetch(w("/cursor/settings/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(a.status===409)throw new us("Cursor raw settings changed externally");if(!a.ok)throw new Error("Failed to save cursor raw settings");return a.json()}async function Gs(){const s=await fetch(w("/cursor/auth/auto-detect"),{method:"POST"});if(!s.ok){const a=await s.json().catch(()=>({error:"Auto-detect failed"}));throw new Error(a.error||"Auto-detect failed")}return s.json()}async function Qs(s){const a=await fetch(w("/cursor/auth/import"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!a.ok){const c=await a.json().catch(()=>({error:"Manual import failed"}));throw new Error(c.error||"Manual import failed")}return a.json()}async function Js(){const s=await fetch(w("/cursor/daemon/start"),{method:"POST"});if(!s.ok)throw new Error("Failed to start cursor daemon");return s.json()}async function Us(){const s=await fetch(w("/cursor/daemon/stop"),{method:"POST"});if(!s.ok)throw new Error("Failed to stop cursor daemon");return s.json()}async function Bs(){const s=await fetch(w("/cursor/probe"),{method:"POST"}),a=await s.json().catch(()=>null);return Fs(a)?a:{ok:!1,stage:"runtime",status:s.status,duration_ms:0,error_type:"runtime_error",message:Ls(a)??"Failed to run live probe"}}function Hs(){const s=ys(),a=Q({queryKey:["cursor-status"],queryFn:Is,refetchInterval:5e3}),c=Q({queryKey:["cursor-config"],queryFn:Os}),d=Q({queryKey:["cursor-models"],queryFn:Es}),l=Q({queryKey:["cursor-raw-settings"],queryFn:Ks}),g=()=>{s.invalidateQueries({queryKey:["cursor-status"]}),s.invalidateQueries({queryKey:["cursor-config"]}),s.invalidateQueries({queryKey:["cursor-models"]}),s.invalidateQueries({queryKey:["cursor-raw-settings"]})},h=T({mutationFn:zs,onSuccess:g}),u=T({mutationFn:qs,onSuccess:g}),r=T({mutationFn:Gs,onSuccess:g}),m=T({mutationFn:Qs,onSuccess:g}),x=T({mutationFn:Js,onSuccess:g}),i=T({mutationFn:Us,onSuccess:g}),P=T({mutationFn:Bs,onSettled:()=>{s.invalidateQueries({queryKey:["cursor-status"]}),s.invalidateQueries({queryKey:["cursor-models"]})}});return b.useMemo(()=>({status:a.data,statusLoading:a.isLoading,statusError:a.error,refetchStatus:a.refetch,config:c.data,configLoading:c.isLoading,refetchConfig:c.refetch,models:d.data?.models??[],currentModel:d.data?.current??null,modelsLoading:d.isLoading,rawSettings:l.data,rawSettingsLoading:l.isLoading,refetchRawSettings:l.refetch,updateConfig:h.mutate,updateConfigAsync:h.mutateAsync,isUpdatingConfig:h.isPending,saveRawSettings:u.mutate,saveRawSettingsAsync:u.mutateAsync,isSavingRawSettings:u.isPending,autoDetectAuth:r.mutate,autoDetectAuthAsync:r.mutateAsync,isAutoDetectingAuth:r.isPending,autoDetectAuthResult:r.data,importManualAuth:m.mutate,importManualAuthAsync:m.mutateAsync,isImportingManualAuth:m.isPending,manualAuthResult:m.data,startDaemon:x.mutate,startDaemonAsync:x.mutateAsync,isStartingDaemon:x.isPending,stopDaemon:i.mutate,stopDaemonAsync:i.mutateAsync,isStoppingDaemon:i.isPending,runProbe:P.mutate,runProbeAsync:P.mutateAsync,isRunningProbe:P.isPending,probeResult:P.data,resetProbe:P.reset}),[a.data,a.isLoading,a.error,a.refetch,c.data,c.isLoading,c.refetch,d.data,d.isLoading,l.data,l.isLoading,l.refetch,h.mutate,h.mutateAsync,h.isPending,u.mutate,u.mutateAsync,u.isPending,r.mutate,r.mutateAsync,r.isPending,r.data,m.mutate,m.mutateAsync,m.isPending,m.data,x.mutate,x.mutateAsync,x.isPending,i.mutate,i.mutateAsync,i.isPending,P.mutate,P.mutateAsync,P.isPending,P.data,P.reset])}function he(s,a){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:a?.auto_start??null,model:a?.model??null})}function U(s){return{port:String(s?.port??Ie),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 C(s,a,c){return s.find(l=>a.some(g=>g.test(l.id)))?.id??c}function xe(s){return s.toLowerCase().replace(/[^a-z0-9]/g,"")}function S(s,a,c){const d=new Set(a.map(xe)),l=s.find(h=>d.has(xe(h.id)));if(l)return l.id;const g=s.find(h=>d.has(xe(h.name)));return g?g.id:c}function Vs(s){try{const a=JSON.parse(s||"{}");return!a||typeof a!="object"||Array.isArray(a)?{isValid:!1,error:"Raw settings must be a JSON object"}:{isValid:!0,settings:a}}catch(a){return{isValid:!1,error:a.message||"Invalid JSON"}}}function B({label:s,description:a,value:c,models:d,disabled:l,allowDefaultFallback:g=!1,onChange:h}){const{t:u}=Le(),r=c||(g?"__default":""),m=b.useMemo(()=>{const x=d.map(i=>({value:i.id,groupKey:"models",searchText:`${i.name||i.id} ${i.id}`,keywords:[i.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:i.name||i.id}),i.provider&&e.jsx(A,{variant:"outline",className:"text-[9px] h-4 px-1 capitalize",children:i.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:i.name||i.id}),e.jsx(A,{variant:"outline",className:"text-[9px] h-4 px-1 capitalize",children:i.provider})]})}));return g?[{value:"__default",groupKey:"models",searchText:u("cursorPage.useDefaultModel"),triggerContent:e.jsx("span",{className:"truncate font-mono text-xs",children:u("cursorPage.useDefaultModel")}),itemContent:e.jsx("span",{children:u("cursorPage.useDefaultModel")})},...x]:x},[g,d,u]);return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx(F,{className:"text-xs font-medium",children:s}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a})]}),e.jsx(Ns,{value:r||void 0,onChange:x=>{if(g&&x==="__default"){h("");return}h(x)},disabled:l,placeholder:u("cursorPage.selectModel"),searchPlaceholder:u("searchableSelect.searchModels"),emptyText:u("searchableSelect.noResults"),triggerClassName:"h-9",groups:[{key:"models",label:u("cursorPage.availableModelCount",{count:d.length})}],options:m})]})}function fe({icon:s,label:a,ok:c,detail:d}){return e.jsxs("div",{className:"flex items-center gap-3 rounded-lg bg-muted/50 px-3 py-2",children:[e.jsx(s,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("p",{className:"text-sm",children:a})}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[c?e.jsx(Ts,{className:"h-4 w-4 text-green-500"}):e.jsx(Rs,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:H("text-xs",c?"text-green-500":"text-muted-foreground"),title:d,children:d})]})]})}function ia(){const{t:s}=Le(),{status:a,statusLoading:c,refetchStatus:d,config:l,refetchConfig:g,updateConfigAsync:h,isUpdatingConfig:u,models:r,modelsLoading:m,currentModel:x,rawSettings:i,rawSettingsLoading:P,refetchRawSettings:Oe,saveRawSettingsAsync:Ee,isSavingRawSettings:pe,autoDetectAuthAsync:Ke,isAutoDetectingAuth:je,importManualAuthAsync:ze,isImportingManualAuth:Pe,startDaemonAsync:qe,isStartingDaemon:Ge,stopDaemonAsync:Qe,isStoppingDaemon:be,runProbeAsync:Je,isRunningProbe:V,probeResult:W,resetProbe:Ue}=Hs(),[D,X]=b.useState(()=>U()),[y,Z]=b.useState(!1),[we,Be]=b.useState("{}"),[L,$]=b.useState(!1),[He,E]=b.useState(!1),[Y,ye]=b.useState(""),[ee,ve]=b.useState(""),[Ne,Ce]=b.useState(()=>W?he(a,l):null),k=U(l),Se=y?D.port:k.port,se=y?D.auto_start:k.auto_start,ae=y?D.ghost_mode:k.ghost_mode,v=y?D.model:k.model,te=y?D.opus_model:k.opus_model,re=y?D.sonnet_model:k.sonnet_model,ne=y?D.haiku_model:k.haiku_model,oe=L?we:JSON.stringify(i?.settings??{},null,2),ke=!!i,I=b.useMemo(()=>Vs(oe),[oe]),_e=I.isValid,K=y||L,Ve=!L||ke&&_e,We=he(a,l),j=W&&!K&&Ne!==null&&Ne===We?W:null,z=b.useMemo(()=>{const t=new Set,n=[...r].sort((M,ce)=>M.name.localeCompare(ce.name)),f=n.filter(M=>t.has(M.id)?!1:(t.add(M.id),!0));return v&&!n.some(M=>M.id===v)?[{id:v,name:v,provider:"custom"},...f]:f},[r,v]),N=t=>{X(n=>t(y?n:k)),Z(!0)},_=()=>{Ue(),Ce(null)},Xe=(t=l)=>{X(U(t)),Z(!1)},Ze=!!(a?.enabled&&a?.authenticated&&!a?.token_expired),$e=b.useMemo(()=>a?.enabled?e.jsx(A,{children:s("cursorPage.enabled")}):e.jsx(A,{variant:"secondary",children:s("cursorPage.disabled")}),[a?.enabled,s]),Ye=async({suppressSuccessToast:t=!1}={})=>{const n=Number(Se);if(!Number.isInteger(n)||n<1||n>65535)return o.error(s("cursorPage.invalidPort")),!1;if(!v.trim())return o.error(s("cursorPage.defaultModelRequired")),!1;try{return await h({port:n,auto_start:se,ghost_mode:ae,model:v,opus_model:te||void 0,sonnet_model:re||void 0,haiku_model:ne||void 0}),Z(!1),X(U({port:n,auto_start:se,ghost_mode:ae,model:v,opus_model:te||void 0,sonnet_model:re||void 0,haiku_model:ne||void 0})),_(),t||o.success(s("cursorPage.savedConfig")),!0}catch(f){return o.error(f.message||s("cursorPage.failedSaveConfig")),!1}},ie=t=>{if(m){o.error(s("cursorPage.modelsLoadingWait"));return}if(r.length===0){o.error(s("cursorPage.noModelsAvailable"));return}const n=v||x||r[0]?.id||"gpt-5.3-codex",f=S(r,["gpt-5.3-codex","gpt53codex","GPT-5.3 Codex"],C(r,[/gpt[-.]?5.*codex/i],n)),M=S(r,["gpt-5.1-codex-max","gpt51codexmax","GPT-5.1 Codex Max"],C(r,[/gpt[-.]?5.*codex.*max/i],f)),ce=S(r,["gpt-5-fast","gpt5fast","GPT-5 Fast"],C(r,[/gpt[-.]?5.*fast/i],f)),cs=S(r,["gpt-5-mini","gpt5mini","GPT-5 Mini"],C(r,[/gpt[-.]?5.*mini/i],ce)),Ae=S(r,["claude-4.6-opus","claude46opus","Claude 4.6 Opus"],C(r,[/claude[-.]?4\.?6.*opus/i,/claude.*opus/i],f)),De=S(r,["claude-4.5-sonnet","claude45sonnet","Claude 4.5 Sonnet"],C(r,[/claude[-.]?4\.?5.*sonnet/i,/claude.*sonnet/i],f)),ls=S(r,["claude-4.5-haiku","claude45haiku","Claude 4.5 Haiku"],C(r,[/claude[-.]?4\.?5.*haiku/i,/haiku/i],De)),q=S(r,["gemini-3-pro","gemini3pro","Gemini 3 Pro"],C(r,[/gemini[-.]?3.*pro/i],f)),ds=S(r,["gemini-3-flash","gemini3flash","Gemini 3 Flash"],C(r,[/gemini[-.]?3.*flash/i,/gemini[-.]?2\.?5.*flash/i],q));if(t==="codex53"){N(O=>({...O,model:f,opus_model:M,sonnet_model:f,haiku_model:cs})),o.success(s("cursorPage.appliedCodexPreset"));return}if(t==="claude46"){N(O=>({...O,model:Ae,opus_model:Ae,sonnet_model:De,haiku_model:ls})),o.success(s("cursorPage.appliedClaudePreset"));return}N(O=>({...O,model:q,opus_model:q,sonnet_model:q,haiku_model:ds})),o.success(s("cursorPage.appliedGeminiPreset"))},Me=async t=>{try{await h({enabled:t}),_(),o.success(s(t?"cursorPage.integrationEnabled":"cursorPage.integrationDisabled"))}catch(n){o.error(n.message||s("cursorPage.failedUpdateIntegration"))}},es=async()=>{try{await Ke(),_(),o.success(s("cursorPage.credentialsImported"))}catch(t){o.error(t.message||s("cursorPage.autoDetectFailed"))}},ss=async()=>{if(!Y.trim()||!ee.trim()){o.error(s("cursorPage.manualRequired"));return}try{await ze({accessToken:Y.trim(),machineId:ee.trim()}),_(),o.success(s("cursorPage.credentialsImported")),E(!1),ye(""),ve("")}catch(t){o.error(t.message||s("cursorPage.manualImportFailed"))}},as=async()=>{try{const t=await qe();if(!t.success){o.error(t.error||s("cursorPage.failedStartDaemon"));return}_(),o.success(t.pid?s("cursorPage.daemonStartedWithPid",{pid:t.pid}):s("cursorPage.daemonStarted"))}catch(t){o.error(t.message||s("cursorPage.failedStartDaemon"))}},ts=async()=>{try{const t=await Qe();if(!t.success){o.error(t.error||s("cursorPage.failedStopDaemon"));return}_(),o.success(s("cursorPage.daemonStopped"))}catch(t){o.error(t.message||s("cursorPage.failedStopDaemon"))}},rs=async()=>{if(K){o.error(s("cursorPage.probeSaveFirst"));return}try{const t=await Je(),n=await d();if(Ce(he(n.data??a,l)),t.ok){o.success(s("cursorPage.probeSucceeded"));return}o.error(t.message||s("cursorPage.probeFailed"))}catch(t){o.error(t.message||s("cursorPage.probeFailed"))}},ns=async({suppressSuccessToast:t=!1}={})=>{if(!ke)return o.error(s("cursorPage.rawLoading")),!1;if(!I.isValid||!I.settings)return o.error(I.error||s("cursorPage.invalidJson")),!1;try{return await Ee({settings:I.settings,expectedMtime:i?.mtime}),$(!1),_(),t||o.success(s("cursorPage.rawSaved")),!0}catch(n){return ws(n)?o.error(s("cursorPage.rawChanged")):o.error(n.message||s("cursorPage.failedSaveRaw")),!1}},os=async()=>{if(!K)return;const t=y,n=L;t&&!await Ye({suppressSuccessToast:n})||n&&!await ns({suppressSuccessToast:t})||t&&n&&o.success(s("cursorPage.savedAll"))},is=async()=>{$(!1),_();const[,t]=await Promise.all([d(),g(),Oe()]);Xe(t.data??l)};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(A,{variant:"outline",className:"h-5 border-amber-500/60 bg-amber-500/10 px-1.5 text-[10px] font-semibold uppercase tracking-wide text-amber-800 dark:text-amber-300",children:s("cursorPage.beta")}),$e]}),e.jsx(p,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>d(),disabled:c,"aria-label":s("cursorPage.refreshStatus"),title:s("cursorPage.refreshStatus"),children:e.jsx(Re,{className:H("w-4 h-4",c&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("cursorPage.subtitle")})]}),e.jsx(G,{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(Cs,{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:"space-y-2",children:[e.jsx(fe,{icon:Ss,label:s("cursorPage.integration"),ok:!!a?.enabled,detail:a?.enabled?s("cursorPage.enabled"):s("cursorPage.disabled")}),e.jsx(fe,{icon:J,label:s("cursorPage.authentication"),ok:!!(a?.authenticated&&!a?.token_expired),detail:a?.authenticated?a?.token_expired?s("cursorPage.expired"):a.auth_method??s("cursorPage.connected"):s("cursorPage.notConnected")}),e.jsx(fe,{icon:ks,label:s("cursorPage.daemon"),ok:!!a?.daemon_running,detail:a?.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(me,{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(A,{variant:j?"outline":"secondary",className:H(j?.ok&&"border-green-500/40 text-green-600 dark:text-green-300",j&&!j.ok&&"border-red-500/40 text-red-600 dark:text-red-300"),children:j?j.ok?s("cursorPage.probeSucceeded"):s("cursorPage.probeFailed"):s("cursorPage.probeNotRun")})]}),j?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:j.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:j.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:[j.duration_ms," ms"]})]}),j.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:j.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:j.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")}),a?.enabled?e.jsxs(p,{variant:"outline",size:"sm",className:"w-full",onClick:()=>Me(!1),disabled:u,children:[e.jsx(Fe,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.disableIntegration")]}):e.jsxs(p,{size:"sm",className:"w-full",onClick:()=>Me(!0),disabled:u,children:[e.jsx(_s,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.enableIntegration")]}),e.jsxs(p,{variant:"outline",size:"sm",className:"w-full",onClick:es,disabled:je,children:[je?e.jsx(R,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(J,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.autoDetectAuth")]}),e.jsxs(p,{variant:"outline",size:"sm",className:"w-full",onClick:()=>E(!0),children:[e.jsx(J,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.manualAuthImport")]}),e.jsxs(p,{variant:"outline",size:"sm",className:"w-full",onClick:rs,disabled:V,children:[V?e.jsx(R,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(me,{className:"w-3.5 h-3.5 mr-1.5"}),s(V?"cursorPage.probing":j?"cursorPage.rerunLiveProbe":"cursorPage.runLiveProbe")]}),a?.daemon_running?e.jsxs(p,{variant:"outline",size:"sm",className:"w-full",onClick:ts,disabled:be,children:[be?e.jsx(R,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(Fe,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.stopDaemon")]}):e.jsxs(p,{size:"sm",className:"w-full",onClick:as,disabled:!Ze,children:[Ge?e.jsx(R,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(Ms,{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:a?.port??l?.port??Ie})]})})]}),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")}),i&&e.jsx(A,{variant:"outline",className:"text-xs",children:"cursor.settings.json"})]}),i&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[s("cursorPage.lastModified")," ",i.exists?new Date(i.mtime).toLocaleString():s("cursorPage.neverSaved")]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p,{variant:"ghost",size:"sm",onClick:is,disabled:c||P,"aria-label":s("cursorPage.refreshConfiguration"),title:s("cursorPage.refreshConfiguration"),children:e.jsx(Re,{className:H("w-4 h-4",(c||P)&&"animate-spin")})}),e.jsx(p,{size:"sm",onClick:os,disabled:u||pe||!K||!Ve,children:u||pe?e.jsxs(e.Fragment,{children:[e.jsx(R,{className:"w-4 h-4 mr-1 animate-spin"}),s("cursorPage.saving")]}):e.jsxs(e.Fragment,{children:[e.jsx(As,{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(ms,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(gs,{className:"w-full",children:[e.jsx(le,{value:"config",className:"flex-1",children:s("cursorPage.modelConfig")}),e.jsx(le,{value:"settings",className:"flex-1",children:s("cursorPage.settings")}),e.jsx(le,{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(de,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(G,{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(Ds,{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(p,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>ie("codex53"),disabled:m||r.length===0,title:"OpenAI-only mapping: GPT-5.3 Codex / Codex Max / GPT-5 Mini",children:[e.jsx(ge,{className:"w-3 h-3"}),"GPT-5.3 Codex"]}),e.jsxs(p,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>ie("claude46"),disabled:m||r.length===0,title:"Claude-first mapping: Opus 4.6 / Sonnet 4.5 / Haiku 4.5",children:[e.jsx(ge,{className:"w-3 h-3"}),"Claude 4.6"]}),e.jsxs(p,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>ie("gemini3"),disabled:m||r.length===0,title:"Gemini-first mapping: Gemini 3 Pro + Gemini 3 Flash",children:[e.jsx(ge,{className:"w-3 h-3"}),"Gemini 3 Pro"]})]})]}),e.jsx(vs,{}),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(B,{label:s("cursorPage.defaultModel"),description:s("cursorPage.defaultModelDesc"),value:v,models:z,disabled:m,onChange:t=>{N(n=>({...n,model:t}))}}),e.jsx(B,{label:s("cursorPage.opusModel"),description:s("cursorPage.opusModelDesc"),value:te,models:z,disabled:m,allowDefaultFallback:!0,onChange:t=>{N(n=>({...n,opus_model:t}))}}),e.jsx(B,{label:s("cursorPage.sonnetModel"),description:s("cursorPage.sonnetModelDesc"),value:re,models:z,disabled:m,allowDefaultFallback:!0,onChange:t=>{N(n=>({...n,sonnet_model:t}))}}),e.jsx(B,{label:s("cursorPage.haikuModel"),description:s("cursorPage.haikuModelDesc"),value:ne,models:z,disabled:m,allowDefaultFallback:!0,onChange:t=>{N(n=>({...n,haiku_model:t}))}})]})]})]})})}),e.jsx(de,{value:"settings",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(G,{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(F,{htmlFor:"cursor-port",className:"text-xs",children:s("cursorPage.port")}),e.jsx(ue,{id:"cursor-port",type:"number",min:1,max:65535,className:"max-w-[150px] h-8",value:Se,onChange:t=>{N(n=>({...n,port:t.target.value}))}})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(F,{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(Te,{id:"cursor-auto-start",checked:se,onCheckedChange:t=>{N(n=>({...n,auto_start:t}))}})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(F,{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(Te,{id:"cursor-ghost-mode",checked:ae,onCheckedChange:t=>{N(n=>({...n,ghost_mode:t}))}})]})]})})})}),e.jsx(de,{value:"info",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(G,{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"})]}),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:i?.path??"~/.ccs/cursor.settings.json"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Model mapping writes `ANTHROPIC_MODEL`, `ANTHROPIC_DEFAULT_OPUS_MODEL`, `ANTHROPIC_DEFAULT_SONNET_MODEL`, and `ANTHROPIC_DEFAULT_HAIKU_MODEL` in `cursor.settings.json`."})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:s("cursorPage.availableModels")}),m?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(R,{className:"w-4 h-4 animate-spin"}),s("cursorPage.loadingModels")]}):r.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:s("cursorPage.noModels")}):e.jsx("div",{className:"space-y-2",children:r.map(t=>e.jsxs("div",{className:"rounded-lg border px-3 py-2 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:t.id}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[t.name," • ",t.provider]})]}),t.id===x&&e.jsx(A,{children:s("cursorPage.default")})]},t.id))})]})]})})})]})]})}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-2 bg-muted/30 border-b flex items-center gap-2 shrink-0 h-[45px]",children:[e.jsx(me,{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(hs,{rawJsonContent:oe,isRawJsonValid:_e,rawJsonEdits:L?we:null,rawSettingsEnv:i?.settings?.env,onChange:t=>{$(!0),Be(t)}})]})]})]})})]}),e.jsx(xs,{open:He,onOpenChange:E,children:e.jsxs(fs,{children:[e.jsxs(ps,{children:[e.jsx(js,{children:s("cursorPage.manualImportTitle")}),e.jsx(Ps,{children:s("cursorPage.manualImportDesc")})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(F,{htmlFor:"cursor-manual-token",children:s("cursorPage.accessToken")}),e.jsx(ue,{id:"cursor-manual-token",value:Y,onChange:t=>ye(t.target.value),placeholder:s("cursorPage.accessTokenPlaceholder")})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(F,{htmlFor:"cursor-manual-machine-id",children:s("cursorPage.machineId")}),e.jsx(ue,{id:"cursor-manual-machine-id",value:ee,onChange:t=>ve(t.target.value),placeholder:s("cursorPage.machineIdPlaceholder")})]})]}),e.jsxs(bs,{children:[e.jsx(p,{variant:"outline",onClick:()=>E(!1),children:s("cursorPage.cancel")}),e.jsxs(p,{onClick:ss,disabled:Pe,children:[Pe?e.jsx(R,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(J,{className:"w-4 h-4 mr-2"}),s("cursorPage.import")]})]})]})})]})}export{ia as CursorPage};
|