@kaitranntt/ccs 7.69.1-dev.2 → 7.69.1-dev.3
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/ui/assets/accounts-DN0lP-yj.js +1 -0
- package/dist/ui/assets/{alert-dialog-QyEXocpn.js → alert-dialog-BA39vaYL.js} +1 -1
- package/dist/ui/assets/api-D2cjf1H4.js +4 -0
- package/dist/ui/assets/{auth-section-BszF77uT.js → auth-section-BNX8_9MJ.js} +1 -1
- package/dist/ui/assets/{backups-section-D6RgaOx1.js → backups-section-Bt0FA5zl.js} +1 -1
- package/dist/ui/assets/channels-FaDUjf3Y.js +1 -0
- package/dist/ui/assets/{checkbox-Dzwkj_Pg.js → checkbox-DHF-UBrH.js} +1 -1
- package/dist/ui/assets/claude-extension-D-skBToQ.js +1 -0
- package/dist/ui/assets/cliproxy-CD7z-_q8.js +3 -0
- package/dist/ui/assets/cliproxy-ai-providers-QSOOqh8F.js +15 -0
- package/dist/ui/assets/cliproxy-control-panel-D9dLU28p.js +1 -0
- package/dist/ui/assets/codex-CHO5_hku.js +27 -0
- package/dist/ui/assets/confirm-dialog-BICDz_zm.js +1 -0
- package/dist/ui/assets/copilot-BnQrRCuJ.js +3 -0
- package/dist/ui/assets/{cursor-BrcDgu6X.js → cursor-CXopLKfC.js} +1 -1
- package/dist/ui/assets/droid-CLFg9ELE.js +2 -0
- package/dist/ui/assets/{globalenv-section-DoX37DqB.js → globalenv-section-NPjCcYBN.js} +1 -1
- package/dist/ui/assets/{health-D_gdcxnc.js → health-B_3JpCrY.js} +1 -1
- package/dist/ui/assets/index-B5Egq7qY.js +1 -0
- package/dist/ui/assets/index-BY2j-o67.js +1 -0
- package/dist/ui/assets/{index-CTGpqIx6.js → index-BcUkpsGj.js} +1 -1
- package/dist/ui/assets/{index-DoVPk3vW.js → index-BgGHTjTd.js} +1 -1
- package/dist/ui/assets/index-DNmWbKbN.js +72 -0
- package/dist/ui/assets/index-DZddoGfE.js +1 -0
- package/dist/ui/assets/logs-Bb1OVYeK.js +1 -0
- package/dist/ui/assets/{masked-input-C2H-Ax0Z.js → masked-input-b4-lEKNq.js} +1 -1
- package/dist/ui/assets/proxy-status-widget-s89zaj3X.js +1 -0
- package/dist/ui/assets/{raw-json-settings-editor-panel-WxTn7-hS.js → raw-json-settings-editor-panel-Dr_BNQwQ.js} +1 -1
- package/dist/ui/assets/{searchable-select-1zOULoec.js → searchable-select-FJPe_YWv.js} +1 -1
- package/dist/ui/assets/{separator-BCfZ54mZ.js → separator-DJ0ku_ak.js} +1 -1
- package/dist/ui/assets/{shared-DlTbnc9n.js → shared-DyQlJnbj.js} +1 -1
- package/dist/ui/assets/{table-Bx2cnkWN.js → table-6Yg65ZZH.js} +1 -1
- package/dist/ui/assets/{updates-SiZKOnUD.js → updates-DSCXb6Au.js} +1 -1
- package/dist/ui/index.html +1 -1
- package/package.json +1 -1
- package/dist/ui/assets/accounts-D9eEaNx9.js +0 -1
- package/dist/ui/assets/api-7vQe0xOg.js +0 -4
- package/dist/ui/assets/channels-B1vgnNJX.js +0 -1
- package/dist/ui/assets/claude-extension-CKO4bJ22.js +0 -1
- package/dist/ui/assets/cliproxy-ai-providers-CmbFYVoR.js +0 -15
- package/dist/ui/assets/cliproxy-control-panel-M8ZfUq3C.js +0 -1
- package/dist/ui/assets/cliproxy-kHd-oC5W.js +0 -3
- package/dist/ui/assets/codex-BJ0RdMuh.js +0 -27
- package/dist/ui/assets/confirm-dialog-BlSaX2gK.js +0 -1
- package/dist/ui/assets/copilot-NJKZQXQ_.js +0 -3
- package/dist/ui/assets/droid-B9u9ZB-a.js +0 -2
- package/dist/ui/assets/index-BNU4Hhe_.js +0 -1
- package/dist/ui/assets/index-DFEMq3KP.js +0 -1
- package/dist/ui/assets/index-DOn6k1jF.js +0 -72
- package/dist/ui/assets/index-h08p9xL5.js +0 -1
- package/dist/ui/assets/logs-DtH4YMt4.js +0 -1
- package/dist/ui/assets/proxy-status-widget-BOrsn86w.js +0 -1
|
@@ -0,0 +1,27 @@
|
|
|
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"
|
|
2
|
+
|
|
3
|
+
[model_providers.cliproxy]
|
|
4
|
+
base_url = "http://127.0.0.1:8317/api/provider/codex"
|
|
5
|
+
env_key = "CLIPROXY_API_KEY"
|
|
6
|
+
wire_api = "responses"`,Le=[{name:"multi_agent",label:"Multi-agent",description:"Enable subagent collaboration tools."},{name:"unified_exec",label:"Unified exec",description:"Use the PTY-backed unified exec tool."},{name:"shell_snapshot",label:"Shell snapshot",description:"Reuse shell environment snapshots."},{name:"apply_patch_freeform",label:"Apply patch",description:"Enable freeform apply_patch edits."},{name:"js_repl",label:"JS REPL",description:"Enable the Node-backed JavaScript REPL."},{name:"runtime_metrics",label:"Runtime metrics",description:"Collect Codex runtime metrics."},{name:"prevent_idle_sleep",label:"Prevent idle sleep",description:"Keep the machine awake while active."},{name:"fast_mode",label:"Fast mode",description:"Allow the fast service tier path."},{name:"apps",label:"Apps",description:"Enable ChatGPT Apps and connectors support."},{name:"smart_approvals",label:"Smart approvals",description:"Route eligible approvals through the guardian flow."}];function G(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)?s:null}function T(s){return typeof s=="string"&&s.trim().length>0?s.trim():null}function H(s){return typeof s=="number"&&Number.isFinite(s)?s:null}function ue(s){return Array.isArray(s)?s.filter(r=>typeof r=="string").map(r=>r.trim()):[]}function De(s){return{model:T(s?.model),modelReasoningEffort:T(s?.model_reasoning_effort),modelContextWindow:H(s?.model_context_window),modelAutoCompactTokenLimit:H(s?.model_auto_compact_token_limit),modelProvider:T(s?.model_provider),approvalPolicy:T(s?.approval_policy),sandboxMode:T(s?.sandbox_mode),webSearch:T(s?.web_search),toolOutputTokenLimit:H(s?.tool_output_token_limit),personality:T(s?.personality)}}function Xs(s){const r=G(s?.projects);return r?Object.entries(r).map(([t,l])=>{const a=T(G(l)?.trust_level);return a?{path:t,trustLevel:a}:null}).filter(t=>t!==null).sort((t,l)=>t.path.localeCompare(l.path)):[]}function zs(s){const r=G(s?.profiles);return r?Object.entries(r).map(([t,l])=>({name:t,values:De(G(l))})).sort((t,l)=>t.name.localeCompare(l.name)):[]}function $s(s){const r=G(s?.model_providers);return r?Object.entries(r).map(([t,l])=>{const a=G(l);return a?{name:t,displayName:T(a.name),baseUrl:T(a.base_url),envKey:T(a.env_key),wireApi:T(a.wire_api),requiresOpenaiAuth:a.requires_openai_auth===!0,supportsWebsockets:a.supports_websockets===!0}:null}).filter(t=>t!==null).sort((t,l)=>t.name.localeCompare(l.name)):[]}function Bs(s){const r=G(s?.mcp_servers);return r?Object.entries(r).map(([t,l])=>{const a=G(l);if(!a)return null;const n=T(a.command)?"stdio":"streamable-http",o=H(a.startup_timeout_ms);return{name:t,transport:n,command:T(a.command),args:ue(a.args),url:T(a.url),enabled:a.enabled!==!1,required:a.required===!0,startupTimeoutSec:H(a.startup_timeout_sec)??(o!==null?o/1e3:null),toolTimeoutSec:H(a.tool_timeout_sec),enabledTools:ue(a.enabled_tools),disabledTools:ue(a.disabled_tools)}}).filter(t=>t!==null).sort((t,l)=>t.name.localeCompare(l.name)):[]}function Ys(s){const r=G(s?.features),t={};for(const l of Le){const a=r?.[l.name];t[l.name]=typeof a=="boolean"?a:null}if(r)for(const[l,a]of Object.entries(r))l in t||(t[l]=typeof a=="boolean"?a:null);return t}const Hs=[{id:"codex-config-basic",label:"Codex Config Basics",url:"https://developers.openai.com/codex/config-basic",description:"Official user-layer setup, config location, and baseline configuration behavior."},{id:"codex-config-advanced",label:"Codex Config Advanced",url:"https://developers.openai.com/codex/config-advanced",description:"Layering, trust, profiles, and advanced config behavior."},{id:"codex-config-reference",label:"Codex Config Reference",url:"https://developers.openai.com/codex/config-reference",description:"Canonical upstream config surface for providers, MCP, features, and trust."},{id:"codex-releases",label:"Codex GitHub Releases",url:"https://github.com/openai/codex/releases",description:"Track upstream release notes and fast-moving CLI changes."}],Qs=[{provider:"openai",label:"OpenAI Responses API",apiFormat:"Responses API",url:"https://platform.openai.com/docs/api-reference/responses"}];function Js(s){const r=/https?:\/\/[^\s)]+/g,t=[];let l=0,a;for(;(a=r.exec(s))!==null;){const[n]=a,o=a.index;o>l&&t.push(s.slice(l,o)),t.push(e.jsx("a",{href:n,target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:n},`${n}-${o}`)),l=o+n.length}return l<s.length&&t.push(s.slice(l)),t.length>0?t:[s]}function Zs({diagnostics:s}){const{t:r}=_(),t=s.docsReference??{notes:[],links:[],providerDocs:[],providerValues:[],settingsHierarchy:[]},l=t.links.length>0?t.links:Hs,a=t.providerDocs.length>0?t.providerDocs:Qs;return e.jsx(pe,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 pr-1",children:[e.jsxs(I,{children:[e.jsx(F,{className:"pb-2",children:e.jsxs(W,{className:"flex items-center gap-2 text-base",children:[e.jsx(xe,{className:"h-4 w-4"}),"CCS bridge recipe"]})}),e.jsxs(U,{className:"space-y-3 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("p",{children:[e.jsx("strong",{children:"Built-in:"})," Use ",e.jsx("code",{children:"ccsxp"})," for the CCS provider shortcut."]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Native:"})," Configure the recipe below to use CLIProxy directly with"," ",e.jsx("code",{children:"codex"}),"."]})]}),e.jsx("pre",{className:"overflow-x-auto rounded-md border bg-muted/20 p-3 text-xs text-foreground",children:Oe}),e.jsxs("ol",{className:"ml-4 list-decimal space-y-1.5 [&>li]:pl-1",children:[e.jsxs("li",{children:["Save the ",e.jsx("code",{children:"cliproxy"})," provider in your user config."]}),e.jsxs("li",{children:["Set top-level ",e.jsx("code",{children:"model_provider"})," to ",e.jsx("code",{children:"cliproxy"}),"."]}),e.jsxs("li",{children:["Export ",e.jsx("code",{children:"CLIPROXY_API_KEY"})," before launching native Codex."]})]})]})]}),e.jsxs(I,{children:[e.jsx(F,{className:"pb-2",children:e.jsxs(W,{className:"flex items-center gap-2 text-base",children:[e.jsx(xe,{className:"h-4 w-4"}),"Upstream notes"]})}),e.jsxs(U,{className:"space-y-2 text-sm",children:[t.notes.length>0&&e.jsx("ul",{className:"ml-4 list-disc space-y-1.5 text-muted-foreground [&>li]:pl-1",children:t.notes.map((n,o)=>e.jsx("li",{children:Js(n)},`${o}-${n}`))}),e.jsx(Z,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:r("codex.codexDocs")}),e.jsx("div",{className:"space-y-1.5",children:l.map(n=>e.jsxs("a",{href:n.url,target:"_blank",rel:"noreferrer",className:"block rounded-md border px-2.5 py-2 transition-colors hover:bg-muted/50",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-xs font-medium",children:n.label}),e.jsx(be,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),e.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:n.description}),e.jsx("p",{className:"mt-1 break-all font-mono text-[11px] text-muted-foreground/90 underline underline-offset-2",children:n.url})]},n.id))})]}),e.jsx(Z,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:"Provider / bridge reference"}),e.jsx("div",{className:"space-y-1.5",children:a.map(n=>e.jsxs("a",{href:n.url,target:"_blank",rel:"noreferrer",className:"block rounded-md border px-2.5 py-2 transition-colors hover:bg-muted/50",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-xs font-medium",children:n.label}),e.jsx(be,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),e.jsxs("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:["provider: ",n.provider," | format: ",n.apiFormat]}),e.jsx("p",{className:"mt-1 break-all font-mono text-[11px] text-muted-foreground/90 underline underline-offset-2",children:n.url})]},`${n.provider}-${n.url}`))})]}),t.providerValues.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(Z,{}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Provider values: ",t.providerValues.join(", ")]})]}),t.settingsHierarchy.length>0&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Settings hierarchy: ",t.settingsHierarchy.join(" -> ")]})]})]})]})})}function er(s,r){let t=s.slice(0,r).split(/\r\n|\n|\r/g);return[t.length,t.pop().length+1]}function sr(s,r,t){let l=s.split(/\r\n|\n|\r/g),a="",n=(Math.log10(r+1)|0)+1;for(let o=r-1;o<=r+1;o++){let c=l[o-1];c&&(a+=o.toString().padEnd(n," "),a+=": ",a+=c,a+=`
|
|
7
|
+
`,o===r&&(a+=" ".repeat(n+t+2),a+=`^
|
|
8
|
+
`))}return a}class f extends Error{line;column;codeblock;constructor(r,t){const[l,a]=er(t.toml,t.ptr),n=sr(t.toml,l,a);super(`Invalid TOML document: ${r}
|
|
9
|
+
|
|
10
|
+
${n}`,t),this.line=l,this.column=a,this.codeblock=n}}function rr(s,r){let t=0;for(;s[r-++t]==="\\";);return--t&&t%2}function me(s,r=0,t=s.length){let l=s.indexOf(`
|
|
11
|
+
`,r);return s[l-1]==="\r"&&l--,l<=t?l:-1}function re(s,r){for(let t=r;t<s.length;t++){let l=s[t];if(l===`
|
|
12
|
+
`)return t;if(l==="\r"&&s[t+1]===`
|
|
13
|
+
`)return t+1;if(l<" "&&l!==" "||l==="")throw new f("control characters are not allowed in comments",{toml:s,ptr:r})}return s.length}function V(s,r,t,l){let a;for(;;){for(;(a=s[r])===" "||a===" "||!t&&(a===`
|
|
14
|
+
`||a==="\r"&&s[r+1]===`
|
|
15
|
+
`);)r++;if(l||a!=="#")break;r=re(s,r)}return r}function tr(s,r,t,l,a=!1){if(!l)return r=me(s,r),r<0?s.length:r;for(let n=r;n<s.length;n++){let o=s[n];if(o==="#")n=me(s,n);else{if(o===t)return n+1;if(o===l||a&&(o===`
|
|
16
|
+
`||o==="\r"&&s[n+1]===`
|
|
17
|
+
`))return n}}throw new f("cannot find end of structure",{toml:s,ptr:r})}function Ae(s,r){let t=s[r],l=t===s[r+1]&&s[r+1]===s[r+2]?s.slice(r,r+3):t;r+=l.length-1;do r=s.indexOf(l,++r);while(r>-1&&t!=="'"&&rr(s,r));return r>-1&&(r+=l.length,l.length>1&&(s[r]===t&&r++,s[r]===t&&r++)),r}let nr=/^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;class Y extends Date{#s=!1;#r=!1;#e=null;constructor(r){let t=!0,l=!0,a="Z";if(typeof r=="string"){let n=r.match(nr);n?(n[1]||(t=!1,r=`0000-01-01T${r}`),l=!!n[2],l&&r[10]===" "&&(r=r.replace(" ","T")),n[2]&&+n[2]>23?r="":(a=n[3]||null,r=r.toUpperCase(),!a&&l&&(r+="Z"))):r=""}super(r),isNaN(this.getTime())||(this.#s=t,this.#r=l,this.#e=a)}isDateTime(){return this.#s&&this.#r}isLocal(){return!this.#s||!this.#r||!this.#e}isDate(){return this.#s&&!this.#r}isTime(){return this.#r&&!this.#s}isValid(){return this.#s||this.#r}toISOString(){let r=super.toISOString();if(this.isDate())return r.slice(0,10);if(this.isTime())return r.slice(11,23);if(this.#e===null)return r.slice(0,-1);if(this.#e==="Z")return r;let t=+this.#e.slice(1,3)*60+ +this.#e.slice(4,6);return t=this.#e[0]==="-"?t:-t,new Date(this.getTime()-t*6e4).toISOString().slice(0,-1)+this.#e}static wrapAsOffsetDateTime(r,t="Z"){let l=new Y(r);return l.#e=t,l}static wrapAsLocalDateTime(r){let t=new Y(r);return t.#e=null,t}static wrapAsLocalDate(r){let t=new Y(r);return t.#r=!1,t.#e=null,t}static wrapAsLocalTime(r){let t=new Y(r);return t.#s=!1,t.#e=null,t}}let ar=/^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/,lr=/^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/,or=/^[+-]?0[0-9_]/,ir=/^[0-9a-f]{2,8}$/i,Te={b:"\b",t:" ",n:`
|
|
18
|
+
`,f:"\f",r:"\r",e:"\x1B",'"':'"',"\\":"\\"};function Re(s,r=0,t=s.length){let l=s[r]==="'",a=s[r++]===s[r]&&s[r]===s[r+1];a&&(t-=2,s[r+=2]==="\r"&&r++,s[r]===`
|
|
19
|
+
`&&r++);let n=0,o,c="",i=r;for(;r<t-1;){let d=s[r++];if(d===`
|
|
20
|
+
`||d==="\r"&&s[r]===`
|
|
21
|
+
`){if(!a)throw new f("newlines are not allowed in strings",{toml:s,ptr:r-1})}else if(d<" "&&d!==" "||d==="")throw new f("control characters are not allowed in strings",{toml:s,ptr:r-1});if(o){if(o=!1,d==="x"||d==="u"||d==="U"){let u=s.slice(r,r+=d==="x"?2:d==="u"?4:8);if(!ir.test(u))throw new f("invalid unicode escape",{toml:s,ptr:n});try{c+=String.fromCodePoint(parseInt(u,16))}catch{throw new f("invalid unicode escape",{toml:s,ptr:n})}}else if(a&&(d===`
|
|
22
|
+
`||d===" "||d===" "||d==="\r")){if(r=V(s,r-1,!0),s[r]!==`
|
|
23
|
+
`&&s[r]!=="\r")throw new f("invalid escape: only line-ending whitespace may be escaped",{toml:s,ptr:n});r=V(s,r)}else if(d in Te)c+=Te[d];else throw new f("unrecognized escape sequence",{toml:s,ptr:n});i=r}else!l&&d==="\\"&&(n=r-1,o=!0,c+=s.slice(i,n))}return c+s.slice(i,t-1)}function cr(s,r,t,l){if(s==="true")return!0;if(s==="false")return!1;if(s==="-inf")return-1/0;if(s==="inf"||s==="+inf")return 1/0;if(s==="nan"||s==="+nan"||s==="-nan")return NaN;if(s==="-0")return l?0n:0;let a=ar.test(s);if(a||lr.test(s)){if(or.test(s))throw new f("leading zeroes are not allowed",{toml:r,ptr:t});s=s.replace(/_/g,"");let o=+s;if(isNaN(o))throw new f("invalid number",{toml:r,ptr:t});if(a){if((a=!Number.isSafeInteger(o))&&!l)throw new f("integer value cannot be represented losslessly",{toml:r,ptr:t});(a||l===!0)&&(o=BigInt(s))}return o}const n=new Y(s);if(!n.isValid())throw new f("invalid value",{toml:r,ptr:t});return n}function dr(s,r,t){let l=s.slice(r,t),a=l.indexOf("#");return a>-1&&(re(s,a),l=l.slice(0,a)),[l.trimEnd(),a]}function fe(s,r,t,l,a){if(l===0)throw new f("document contains excessively nested structures. aborting.",{toml:s,ptr:r});let n=s[r];if(n==="["||n==="{"){let[i,d]=n==="["?mr(s,r,l,a):xr(s,r,l,a);if(t){if(d=V(s,d),s[d]===",")d++;else if(s[d]!==t)throw new f("expected comma or end of structure",{toml:s,ptr:d})}return[i,d]}let o;if(n==='"'||n==="'"){o=Ae(s,r);let i=Re(s,r,o);if(t){if(o=V(s,o),s[o]&&s[o]!==","&&s[o]!==t&&s[o]!==`
|
|
24
|
+
`&&s[o]!=="\r")throw new f("unexpected character encountered",{toml:s,ptr:o});o+=+(s[o]===",")}return[i,o]}o=tr(s,r,",",t);let c=dr(s,r,o-+(s[o-1]===","));if(!c[0])throw new f("incomplete key-value declaration: no value specified",{toml:s,ptr:r});return t&&c[1]>-1&&(o=V(s,r+c[1]),o+=+(s[o]===",")),[cr(c[0],s,r,a),o]}let ur=/^[a-zA-Z0-9-_]+[ \t]*$/;function he(s,r,t="="){let l=r-1,a=[],n=s.indexOf(t,r);if(n<0)throw new f("incomplete key-value: cannot find end of key",{toml:s,ptr:r});do{let o=s[r=++l];if(o!==" "&&o!==" ")if(o==='"'||o==="'"){if(o===s[r+1]&&o===s[r+2])throw new f("multiline strings are not allowed in keys",{toml:s,ptr:r});let c=Ae(s,r);if(c<0)throw new f("unfinished string encountered",{toml:s,ptr:r});l=s.indexOf(".",c);let i=s.slice(c,l<0||l>n?n:l),d=me(i);if(d>-1)throw new f("newlines are not allowed in keys",{toml:s,ptr:r+l+d});if(i.trimStart())throw new f("found extra tokens after the string part",{toml:s,ptr:c});if(n<c&&(n=s.indexOf(t,c),n<0))throw new f("incomplete key-value: cannot find end of key",{toml:s,ptr:r});a.push(Re(s,r,c))}else{l=s.indexOf(".",r);let c=s.slice(r,l<0||l>n?n:l);if(!ur.test(c))throw new f("only letter, numbers, dashes and underscores are allowed in keys",{toml:s,ptr:r});a.push(c.trimEnd())}}while(l+1&&l<n);return[a,V(s,n+1,!0,!0)]}function xr(s,r,t,l){let a={},n=new Set,o;for(r++;(o=s[r++])!=="}"&&o;){if(o===",")throw new f("expected value, found comma",{toml:s,ptr:r-1});if(o==="#")r=re(s,r);else if(o!==" "&&o!==" "&&o!==`
|
|
25
|
+
`&&o!=="\r"){let c,i=a,d=!1,[u,m]=he(s,r-1);for(let p=0;p<u.length;p++){if(p&&(i=d?i[c]:i[c]={}),c=u[p],(d=Object.hasOwn(i,c))&&(typeof i[c]!="object"||n.has(i[c])))throw new f("trying to redefine an already defined value",{toml:s,ptr:r});!d&&c==="__proto__"&&Object.defineProperty(i,c,{enumerable:!0,configurable:!0,writable:!0})}if(d)throw new f("trying to redefine an already defined value",{toml:s,ptr:r});let[h,b]=fe(s,m,"}",t-1,l);n.add(h),i[c]=h,r=b}}if(!o)throw new f("unfinished table encountered",{toml:s,ptr:r});return[a,r]}function mr(s,r,t,l){let a=[],n;for(r++;(n=s[r++])!=="]"&&n;){if(n===",")throw new f("expected value, found comma",{toml:s,ptr:r-1});if(n==="#")r=re(s,r);else if(n!==" "&&n!==" "&&n!==`
|
|
26
|
+
`&&n!=="\r"){let o=fe(s,r-1,"]",t-1,l);a.push(o[0]),r=o[1]}}if(!n)throw new f("unfinished array encountered",{toml:s,ptr:r});return[a,r]}function _e(s,r,t,l){let a=r,n=t,o,c=!1,i;for(let d=0;d<s.length;d++){if(d){if(a=c?a[o]:a[o]={},n=(i=n[o]).c,l===0&&(i.t===1||i.t===2))return null;if(i.t===2){let u=a.length-1;a=a[u],n=n[u].c}}if(o=s[d],(c=Object.hasOwn(a,o))&&n[o]?.t===0&&n[o]?.d)return null;c||(o==="__proto__"&&(Object.defineProperty(a,o,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(n,o,{enumerable:!0,configurable:!0,writable:!0})),n[o]={t:d<s.length-1&&l===2?3:l,d:!1,i:0,c:{}})}if(i=n[o],i.t!==l&&!(l===1&&i.t===3)||(l===2&&(i.d||(i.d=!0,a[o]=[]),a[o].push(a={}),i.c[i.i++]=i={t:1,d:!1,i:0,c:{}}),i.d))return null;if(i.d=!0,l===1)a=c?a[o]:a[o]={};else if(l===0&&c)return null;return[o,a,i.c]}function hr(s,{maxDepth:r=1e3,integersAsBigInt:t}={}){let l={},a={},n=l,o=a;for(let c=V(s,0);c<s.length;){if(s[c]==="["){let i=s[++c]==="[",d=he(s,c+=+i,"]");if(i){if(s[d[1]-1]!=="]")throw new f("expected end of table declaration",{toml:s,ptr:d[1]-1});d[1]++}let u=_e(d[0],l,a,i?2:1);if(!u)throw new f("trying to redefine an already defined table or value",{toml:s,ptr:c});o=u[2],n=u[1],c=d[1]}else{let i=he(s,c),d=_e(i[0],n,o,0);if(!d)throw new f("trying to redefine an already defined table or value",{toml:s,ptr:c});let u=fe(s,i[1],void 0,r,t);d[1][d[0]]=u[0],c=u[1]}if(c=V(s,c,!0),s[c]&&s[c]!==`
|
|
27
|
+
`&&s[c]!=="\r")throw new f("each key-value declaration must be followed by an end-of-line",{toml:s,ptr:c});c=V(s,c)}return l}function pr(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)}function fr(s){if(!s.trim())return{};const t=hr(s);if(!pr(t))throw new Error("TOML root must be a table.");return t}function Me(s){try{return{config:fr(s),parseError:null}}catch(r){return{config:null,parseError:r.message}}}async function jr(){const s=await fetch(ee("/codex/diagnostics"));if(!s.ok)throw new Error("Failed to fetch Codex diagnostics");return s.json()}async function gr(){const s=await fetch(ee("/codex/config/raw"));if(!s.ok)throw new Error("Failed to fetch Codex raw config");return s.json()}async function vr(s){const r=await fetch(ee("/codex/config/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(r.status===409)throw new Ee("Codex raw config changed externally");if(!r.ok){const t=await r.json().catch(()=>null);throw new Error(t?.error||"Failed to save Codex raw config")}return r.json()}async function br(s){const r=await fetch(ee("/codex/config/patch"),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(r.status===409)throw new Ee("Codex config changed externally");if(!r.ok){const t=await r.json().catch(()=>null);throw new Error(t?.error||"Failed to patch Codex config")}return r.json()}function wr(){const s=bs(),r=Ne({queryKey:["codex-diagnostics"],queryFn:jr,refetchInterval:1e4}),t=Ne({queryKey:["codex-raw-config"],queryFn:gr}),l=Ce({mutationFn:vr,onSuccess:(n,o)=>{s.setQueryData(["codex-raw-config"],c=>{const i=c?.path??"$CODEX_HOME/config.toml",d=c?.resolvedPath??i,u=Me(o.rawText);return{path:i,resolvedPath:d,exists:!0,mtime:n.mtime,rawText:o.rawText,config:u.config,parseError:u.parseError,readError:null}}),s.invalidateQueries({queryKey:["codex-diagnostics"]})}}),a=Ce({mutationFn:br,onSuccess:n=>{s.setQueryData(["codex-raw-config"],n),s.invalidateQueries({queryKey:["codex-diagnostics"]})}});return v.useMemo(()=>({diagnostics:r.data,diagnosticsLoading:r.isLoading,diagnosticsError:r.error,refetchDiagnostics:r.refetch,rawConfig:t.data,rawConfigLoading:t.isLoading,rawConfigError:t.error,refetchRawConfig:t.refetch,saveRawConfig:l.mutate,saveRawConfigAsync:l.mutateAsync,isSavingRawConfig:l.isPending,patchConfig:a.mutate,patchConfigAsync:a.mutateAsync,isPatchingConfig:a.isPending}),[r.data,r.isLoading,r.error,r.refetch,t.data,t.isLoading,t.error,t.refetch,l.mutate,l.mutateAsync,l.isPending,a.mutate,a.mutateAsync,a.isPending])}const Nr=[{label:"Start Default",command:"ccs",description:"Launch Claude with default profile"},{label:"GLM Profile",command:"ccs glm",description:"Switch to GLM model"},{label:"Health Check",command:"ccs doctor",description:"Run system diagnostics"},{label:"Delegate Task",command:'ccs glm -p "your task"',description:"Delegate to GLM profile"}];function Cr({snippets:s=Nr}){const[r,t]=v.useState(null),{t:l}=_(),a=async(n,o)=>{await navigator.clipboard.writeText(n),t(o),setTimeout(()=>t(null),2e3)};return e.jsxs(I,{children:[e.jsx(F,{className:"pb-3",children:e.jsxs(W,{className:"text-lg flex items-center gap-2",children:[e.jsx(ds,{className:"w-5 h-5 text-muted-foreground"}),l("quickCommands.title")]})}),e.jsx(U,{children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:s.map((n,o)=>e.jsxs("div",{className:Pe("group flex items-center justify-between gap-2 px-3 py-2","rounded-lg border bg-muted/30 hover:bg-muted/50 transition-colors"),children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:n.label}),e.jsx("code",{className:"text-sm font-mono font-medium truncate block",children:n.command})]}),e.jsx(N,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>a(n.command,o),title:n.description,children:r===o?e.jsx(us,{className:"h-4 w-4 text-green-600"}):e.jsx(xs,{className:"h-4 w-4"})})]},o))})})]})}function yr(s){return!s||!Number.isFinite(s)?"N/A":new Date(s).toLocaleString()}function kr(s){return!s||s<=0?"0 B":s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(2)} MB`}function S({label:s,value:r,mono:t=!1}){return e.jsxs("div",{className:"flex items-start justify-between gap-3 text-sm",children:[e.jsx("span",{className:"text-muted-foreground shrink-0",children:s}),e.jsx("span",{className:Pe("text-right break-all",t&&"font-mono text-xs"),children:r})]})}function Sr({diagnostics:s}){const{t:r}=_(),t=s.config.activeProfile?`codex --profile ${s.config.activeProfile}`:"codex",l=s.binary.supportsConfigOverrides;return e.jsx(pe,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 pr-1",children:[e.jsxs(I,{children:[e.jsx(F,{className:"pb-2",children:e.jsxs(W,{className:"flex items-center gap-2 text-base",children:[e.jsx(ms,{className:"h-4 w-4"}),"How Codex works in CCS"]})}),e.jsx(U,{className:"text-sm text-muted-foreground",children:e.jsxs("ul",{className:"ml-4 list-disc space-y-1.5 [&>li]:pl-1",children:[e.jsx("li",{children:r("codex.nativeDesc")}),e.jsxs("li",{children:[e.jsx("strong",{children:"Native config:"})," ",e.jsx("code",{children:"ccs-codex"})," and ",e.jsx("code",{children:"ccsx"})," launch native Codex using your saved defaults."]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Transient overrides:"})," ",e.jsx("code",{children:"ccsxp"})," (or"," ",e.jsx("code",{children:"ccs codex --target codex"}),") uses the CCS provider shortcut."]}),e.jsxs("li",{children:[e.jsx("strong",{children:"CLIProxy default:"})," To make plain ",e.jsx("code",{children:"codex"})," use CLIProxy, set ",e.jsx("code",{children:'model_provider = "cliproxy"'})," and add the recipe below."]}),e.jsx("li",{children:r("codex.apiProfilesDefault")})]})})]}),e.jsxs(I,{children:[e.jsx(F,{className:"pb-2",children:e.jsxs(W,{className:"flex items-center gap-2 text-base",children:[e.jsx(hs,{className:"h-4 w-4"}),"Runtime install"]})}),e.jsxs(U,{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:r("codex.status")}),e.jsx(k,{variant:s.binary.installed?"default":"secondary",children:s.binary.installed?"Detected":"Not found"})]}),e.jsx(S,{label:"Detection source",value:s.binary.source,mono:!0}),e.jsx(S,{label:"Binary path",value:s.binary.path||"Not found",mono:!0}),e.jsx(S,{label:"Install directory",value:s.binary.installDir||"N/A",mono:!0}),e.jsx(S,{label:"Version",value:s.binary.version||"Unknown",mono:!0}),e.jsx(S,{label:"Native aliases",value:"ccs-codex, ccsx",mono:!0}),e.jsx(S,{label:"CCS provider shortcut",value:"ccsxp",mono:!0}),e.jsxs("div",{className:"flex items-center justify-between rounded-md border px-3 py-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"--config override support"}),e.jsx(k,{variant:s.binary.supportsConfigOverrides?"default":"secondary",children:s.binary.supportsConfigOverrides?"Available":"Missing"})]})]})]}),e.jsxs(I,{children:[e.jsx(F,{className:"pb-2",children:e.jsxs(W,{className:"flex items-center gap-2 text-base",children:[e.jsx(we,{className:"h-4 w-4"}),"CLIProxy-backed native Codex"]})}),e.jsx(U,{className:"space-y-3 text-sm text-muted-foreground",children:l?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{children:e.jsx("strong",{children:r("codex.twoSupportedPaths")})}),e.jsxs("ul",{className:"ml-4 list-disc space-y-1 [&>li]:pl-1",children:[e.jsxs("li",{children:[e.jsx("strong",{children:"Built-in:"})," Use ",e.jsx("code",{children:"ccsxp"})," for the CCS provider shortcut."]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Native:"})," Configure the recipe below to use CLIProxy directly with ",e.jsx("code",{children:"codex"}),"."]})]})]}),e.jsxs("div",{className:"rounded-md border bg-muted/20 p-3",children:[e.jsx("p",{className:"font-medium text-foreground",children:r("codex.codexNativeRecipe")}),e.jsx("pre",{className:"mt-2 overflow-x-auto rounded-md bg-background p-3 text-xs text-foreground",children:Oe})]}),e.jsxs("ol",{className:"ml-4 list-decimal space-y-1.5 [&>li]:pl-1",children:[e.jsxs("li",{children:["Save a provider named ",e.jsx("code",{children:"cliproxy"})," with the base URL and env key above."]}),e.jsxs("li",{children:["In ",e.jsx("strong",{children:"Top-level settings"}),", set ",e.jsx("strong",{children:"Default provider"})," to"," ",e.jsx("code",{children:"cliproxy"}),"."]}),e.jsxs("li",{children:["Export ",e.jsx("code",{children:"CLIPROXY_API_KEY"})," in your shell before launching native Codex."]})]})]}):e.jsxs("p",{children:["This Codex build can still use the native path, but CCS-backed Codex routing via"," ",e.jsx("code",{children:"ccsxp"})," or ",e.jsx("code",{children:"ccs codex --target codex"})," stays unavailable until the detected Codex binary exposes ",e.jsx("code",{children:"--config"})," overrides."]})})]}),e.jsxs(I,{children:[e.jsx(F,{className:"pb-2",children:e.jsxs(W,{className:"flex items-center gap-2 text-base",children:[e.jsx(ps,{className:"h-4 w-4"}),"Config file"]})}),e.jsx(U,{className:"space-y-3",children:e.jsxs("div",{className:"rounded-md border p-3 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"font-medium text-sm",children:r("codex.userConfig")}),s.file.exists?e.jsx(fs,{className:"h-4 w-4 text-green-600"}):e.jsx(js,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(S,{label:"Path",value:s.file.path,mono:!0}),e.jsx(S,{label:"Resolved",value:s.file.resolvedPath,mono:!0}),e.jsx(S,{label:"Size",value:kr(s.file.sizeBytes)}),e.jsx(S,{label:"Last modified",value:yr(s.file.mtimeMs)}),s.file.parseError&&e.jsxs("p",{className:"text-xs text-amber-600",children:["TOML warning: ",s.file.parseError]}),s.file.readError&&e.jsxs("p",{className:"text-xs text-destructive",children:["Read warning: ",s.file.readError]})]})})]}),e.jsxs(I,{children:[e.jsx(F,{className:"pb-2",children:e.jsxs(W,{className:"flex items-center gap-2 text-base",children:[e.jsx(xe,{className:"h-4 w-4"}),"Current user-layer summary"]})}),e.jsxs(U,{className:"space-y-3",children:[e.jsx(S,{label:r("codex.model"),value:s.config.model||"Not set",mono:!0}),e.jsx(S,{label:r("codex.defaultProvider"),value:s.config.modelProvider||"Not set",mono:!0}),e.jsx(S,{label:"Active profile",value:s.config.activeProfile||"Not set",mono:!0}),e.jsx(S,{label:r("codex.approvalPolicy"),value:s.config.approvalPolicy||"Not set",mono:!0}),e.jsx(S,{label:r("codex.sandboxMode"),value:s.config.sandboxMode||"Not set",mono:!0}),e.jsx(S,{label:r("codex.webSearch"),value:s.config.webSearch||"Not set",mono:!0}),e.jsx(Z,{}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[e.jsxs(k,{variant:"outline",className:"justify-center",children:["providers: ",s.config.modelProviderCount]}),e.jsxs(k,{variant:"outline",className:"justify-center",children:["profiles: ",s.config.profileCount]}),e.jsxs(k,{variant:"outline",className:"justify-center",children:["enabled features: ",s.config.enabledFeatures.length]}),e.jsxs(k,{variant:"outline",className:"justify-center",children:["MCP servers: ",s.config.mcpServerCount]})]}),s.config.topLevelKeys.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:"User-layer keys present"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.config.topLevelKeys.map(a=>e.jsx(k,{variant:"secondary",className:"font-mono text-[10px]",children:a},a))})]})]})]}),e.jsx(Cr,{snippets:[{label:"Native short alias",command:"ccsx",description:"Launch the short native Codex runtime alias."},{label:"CCS Codex shortcut",command:'ccsxp "your prompt"',description:l?r("codex.runBuiltInCodex"):"Requires a Codex build that exposes --config overrides."},{label:"Explicit provider route",command:'ccs codex --target codex "your prompt"',description:l?r("codex.runBuiltInCodexExplicit"):"Requires a Codex build that exposes --config overrides."},{label:s.config.activeProfile?"Inspect active profile":r("codex.openNativeCodex"),command:t,description:s.config.activeProfile?"Inspect the active named profile directly in native Codex.":"Open native Codex without forcing a named profile overlay."}]}),e.jsxs(I,{children:[e.jsx(F,{className:"pb-2",children:e.jsxs(W,{className:"flex items-center gap-2 text-base",children:[e.jsx(we,{className:"h-4 w-4"}),"Runtime vs provider"]})}),e.jsxs(U,{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("div",{className:"flex flex-col rounded-md border p-3 text-sm",children:[e.jsx("p",{className:"font-medium text-foreground",children:r("codex.nativeCodexRuntime")}),e.jsxs("ul",{className:"mt-2 flex-grow list-disc space-y-1.5 pl-4 text-muted-foreground [&>li]:pl-1",children:[e.jsx("li",{children:e.jsx("code",{children:"ccs-codex"})}),e.jsx("li",{children:e.jsx("code",{children:"ccsx"})}),e.jsx("li",{children:e.jsx("code",{children:"--target codex"})})]}),e.jsx(k,{variant:"secondary",className:"mt-4 w-fit justify-center font-normal",children:"Honors saved native user config"})]}),e.jsxs("div",{className:"flex flex-col rounded-md border p-3 text-sm",children:[e.jsx("p",{className:"font-medium text-foreground",children:r("codex.ccsCodexProvider")}),l?e.jsxs(e.Fragment,{children:[e.jsxs("ul",{className:"mt-2 flex-grow list-disc space-y-1.5 pl-4 text-muted-foreground [&>li]:pl-1",children:[e.jsx("li",{children:e.jsx("code",{children:"ccsxp"})}),e.jsx("li",{children:e.jsx("code",{children:"ccs codex --target codex"})})]}),e.jsx(k,{variant:"secondary",className:"mt-4 w-fit justify-center font-normal",children:"Uses transient overrides"})]}):e.jsxs("p",{className:"mt-2 text-muted-foreground",children:["Unavailable (Codex build lacks ",e.jsx("code",{children:"--config"})," support)."]})]})]})]}),e.jsxs(I,{children:[e.jsx(F,{className:"pb-2",children:e.jsx(W,{className:"text-base",children:r("codex.supportedFlows")})}),e.jsx(U,{children:e.jsxs(ws,{children:[e.jsx(Ns,{children:e.jsxs(ye,{children:[e.jsx(le,{children:r("codex.flow")}),e.jsx(le,{children:r("codex.status")}),e.jsx(le,{children:r("codex.notes")})]})}),e.jsx(Cs,{children:s.supportMatrix.map(a=>e.jsxs(ye,{children:[e.jsx(oe,{className:"font-mono text-xs",children:a.label}),e.jsx(oe,{children:e.jsx(k,{variant:a.supported?"default":"secondary",children:a.supported?"Yes":"No"})}),e.jsx(oe,{className:"text-xs text-muted-foreground",children:a.notes})]},a.id))})]})})]}),s.warnings.length>0&&e.jsxs(I,{className:"border-amber-200 bg-amber-50/50 dark:bg-amber-950/20",children:[e.jsx(F,{className:"pb-2",children:e.jsxs(W,{className:"flex items-center gap-2 text-base",children:[e.jsx(gs,{className:"h-4 w-4 text-amber-600"}),"Warnings"]})}),e.jsx(U,{className:"space-y-1.5",children:s.warnings.map(a=>e.jsxs("p",{className:"text-sm text-amber-800 dark:text-amber-300",children:["- ",a]},a))})]})]})})}function Wr(){const{t:s}=_(),{diagnostics:r,diagnosticsLoading:t,diagnosticsError:l,refetchDiagnostics:a,rawConfig:n,rawConfigLoading:o,rawConfigError:c,refetchRawConfig:i,saveRawConfigAsync:d,isSavingRawConfig:u,patchConfigAsync:m,isPatchingConfig:h}=wr(),[b,p]=v.useState(null),w=n?.rawText??"",R=b??w,K=b!==null&&b!==w,x=Me(R),j=x.parseError?{valid:!1,error:x.parseError}:{valid:!0},E=n?.config??null,C=o||!n||K||n?.parseError!==null||n?.readError!==null,Ie=c?"Structured controls unavailable: failed to load the current config.toml.":n?.readError?`Structured controls unavailable: ${n.readError}`:K?j.valid?"Save or discard raw TOML edits before using structured controls.":"Fix or discard raw TOML edits before using structured controls.":n?.parseError?`Structured controls disabled: ${n.parseError}`:null,Fe=v.useMemo(()=>De(E),[E]),We=v.useMemo(()=>Xs(E),[E]),Ue=v.useMemo(()=>zs(E),[E]),Ke=v.useMemo(()=>$s(E),[E]),qe=v.useMemo(()=>Bs(E),[E]),Ve=v.useMemo(()=>Ys(E),[E]),Ge=M=>{if(M===w){p(null);return}p(M)},Xe=async()=>{try{if((await Promise.all([a(),i()])).some(X=>!X||X.status==="error"||X.isError||X.error)){q.error(s("toasts.codexRefreshFailed"));return}p(null)}catch(M){q.error(M.message||s("toasts.codexRefreshError"))}},ze=async()=>{if(!j.valid){q.error(s("toasts.codexFixToml"));return}try{await d({rawText:R,expectedMtime:n?.exists?n.mtime:void 0}),p(null),q.success(s("toasts.codexSaved")),await a()}catch(M){ve(M)?q.error(s("toasts.codexChangedExternally")):q.error(M.message||s("toasts.codexSaveFailed"))}},$e=async(M,je)=>{try{await m({...M,expectedMtime:n?.exists?n.mtime:void 0}),p(null),q.success(je)}catch(X){ve(X)?q.error(s("toasts.codexChangedExternally")):q.error(X.message||s("toasts.codexUpdateFailed"))}},te="mt-0 h-full border-0 p-0 data-[state=inactive]:hidden",Be=()=>t?e.jsxs("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:[e.jsx(z,{className:"mr-2 h-5 w-5 animate-spin"}),"Loading Codex diagnostics..."]}):l||!r?e.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center text-destructive",children:"Failed to load Codex diagnostics."}):e.jsxs(Qe,{defaultValue:"overview",className:"flex h-full flex-col",children:[e.jsx("div",{className:"shrink-0 px-4 pt-4",children:e.jsxs(Je,{className:"grid w-full grid-cols-3",children:[e.jsx(ne,{value:"overview",children:s("codexPage.overview")}),e.jsx(ne,{value:"controls",children:s("codexPage.controlCenter")}),e.jsx(ne,{value:"docs",children:s("codexPage.docs")})]})}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden px-4 pb-4 pt-3",children:[e.jsx(ae,{value:"overview",className:te,children:e.jsx(Sr,{diagnostics:r})}),e.jsx(ae,{value:"controls",className:te,children:e.jsx(Gs,{workspacePath:r.workspacePath,activeProfile:r.config.activeProfile,topLevelSettings:Fe,projectTrustEntries:We,profileEntries:Ue,modelProviderEntries:Ke,mcpServerEntries:qe,featureCatalog:Le,featureState:Ve,disabled:C,disabledReason:Ie,saving:h,onPatch:$e})}),e.jsx(ae,{value:"docs",className:te,children:e.jsx(Zs,{diagnostics:r})})]})]});return e.jsx("div",{className:"h-full min-h-0 overflow-hidden",children:e.jsxs(Ye,{direction:"horizontal",className:"h-full",children:[e.jsx(ge,{defaultSize:45,minSize:35,children:e.jsx("div",{className:"h-full border-r bg-muted/20",children:Be()})}),e.jsx(He,{className:"group flex w-2 cursor-col-resize items-center justify-center bg-border transition-colors hover:bg-primary/20",children:e.jsx(vs,{className:"h-3 w-3 text-muted-foreground group-hover:text-primary"})}),e.jsx(ge,{defaultSize:55,minSize:35,children:e.jsx(ys,{title:"Codex config.toml",pathLabel:n?.path||r?.file.path||"$CODEX_HOME/config.toml",loading:o,parseWarning:j.valid?n?.parseError:j.error,readWarning:n?.readError,value:R,dirty:K,readOnly:!!n?.readError,saving:u,saveDisabled:!K||u||o||!j.valid||!!n?.readError,onChange:M=>{Ge(M)},onSave:ze,onRefresh:Xe,onDiscard:()=>p(null),language:"toml",loadingLabel:"Loading config.toml...",parseWarningLabel:"TOML warning",ownershipNotice:e.jsxs("div",{className:"rounded-md border border-amber-200 bg-amber-50/60 px-3 py-2 text-sm text-amber-900 dark:bg-amber-950/20 dark:text-amber-300",children:[e.jsx("p",{className:"font-medium",children:"This file is upstream-owned by Codex CLI."}),e.jsxs("p",{children:["CCS does not keep ",e.jsx("code",{children:"~/.codex/config.toml"})," in sync for you."]}),e.jsxs("p",{children:["CCS-backed Codex launches may apply transient ",e.jsx("code",{children:"-c"})," overrides and",e.jsx("code",{children:" CCS_CODEX_API_KEY"}),"; those effective values may not appear here."]})]})})})]})})}export{Wr as CodexPage};
|
|
@@ -0,0 +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-BA39vaYL.js";import{a as A}from"./index-DNmWbKbN.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};
|
|
@@ -0,0 +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):`{
|
|
2
|
+
"env": {}
|
|
3
|
+
}`,[p,i]),m=w.useCallback(g=>{C(g)},[]),le=w.useMemo(()=>{try{return JSON.parse(T),!0}catch{return!1}},[T]),ye=w.useMemo(()=>{const g=Object.keys(n).length>0,v=p!==null&&p!==JSON.stringify(i?.settings,null,2);return g||v},[n,p,i]),re=w.useMemo(()=>{if(p!==null)try{return JSON.parse(p)}catch{return i?.settings}return i?.settings},[p,i?.settings]),Se=w.useMemo(()=>pe(re),[re]),Ce=w.useMemo(()=>he([...s?.warnings??[],...i?.warnings??[]]),[s?.warnings,i?.warnings]),ce=async({overwriteRawSettings:g=!1}={})=>{try{const v=[];if(Object.keys(n).length>0){const M=await a({enabled:U,auto_start:K,port:A,account_type:Q,model:E,rate_limit:O?parseInt(O,10):null,wait_on_limit:j,opus_model:J||void 0,sonnet_model:$||void 0,haiku_model:z||void 0});v.push(...M.warnings??[])}let _=[];if(p!==null&&le){const M=JSON.parse(T);_=pe(M);const Pe=await h({settings:M,expectedMtime:g?void 0:i?.mtime});v.push(...Pe.warnings??[])}const X=he(v),q=[];X.length>0&&q.push(X.map(M=>M.message).join(" ")),_.length>0&&q.push(`Missing fields will use defaults: ${_.join(", ")}`),X.length>0?I.warning(t("toasts.settingsSavedWithAdjustments"),{description:q.join(" ")}):q.length>0?I.success(t("toasts.settingsSaved"),{description:q.join(" ")}):I.success(t("toasts.settingsSaved")),l({}),C(null)}catch(v){Re(v)?F(!0):I.error(t("toasts.failedSaveSettings"))}};return{configLoading:o,rawSettingsLoading:c,modelsLoading:r,isUpdating:x,isSavingRawSettings:f,models:d,rawSettings:i,rawJsonContent:T,rawJsonEdits:p,enabled:U,autoStart:K,port:A,accountType:Q,currentModel:E,rateLimit:O,waitOnLimit:j,opusModel:J,sonnetModel:$,haikuModel:z,isRawJsonValid:le,hasChanges:ye,normalizationWarnings:Ce,conflictDialog:k,updateField:B,applyPreset:Y,handleRawJsonChange:m,handleSave:ce,handleConflictResolve:async g=>{F(!1),g?await ce({overwriteRawSettings:!0}):C(null)},refetchRawSettings:u,missingRequiredFields:Se}}function vt(){const{t}=S(),{configLoading:s,rawSettingsLoading:o,modelsLoading:d,isUpdating:r,isSavingRawSettings:i,models:c,rawSettings:a,rawJsonContent:x,rawJsonEdits:h,enabled:f,autoStart:u,port:n,accountType:l,currentModel:p,rateLimit:C,waitOnLimit:k,opusModel:F,sonnetModel:U,haikuModel:K,isRawJsonValid:A,hasChanges:Q,normalizationWarnings:E,conflictDialog:O,updateField:j,applyPreset:J,handleRawJsonChange:$,handleSave:z,handleConflictResolve:B,refetchRawSettings:Y,missingRequiredFields:T}=jt();return s||o?e.jsxs("div",{className:"space-y-6",children:[e.jsx(y,{className:"h-10 w-full"}),e.jsx(y,{className:"h-10 w-full"}),e.jsx(y,{className:"h-10 w-full"}),e.jsx(y,{className:"h-10 w-full"})]}):e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(ct,{rawSettings:a,rawSettingsLoading:o,isUpdating:r,isSavingRawSettings:i,hasChanges:Q,isRawJsonValid:A,onRefresh:()=>Y(),onSave:z}),E.length>0&&e.jsx("div",{className:"px-6 pt-4 shrink-0",children:e.jsxs(Ae,{variant:"warning",children:[e.jsx(ve,{className:"h-4 w-4"}),e.jsx(Ee,{children:t("copilotConfigForm.deprecatedModels")}),e.jsxs(Oe,{className:"space-y-2",children:[e.jsx("p",{children:"Loading this page did not rewrite your files. Save the Copilot configuration to persist these replacements."}),e.jsx("div",{className:"space-y-1",children:E.map(m=>e.jsx("p",{children:m.message},m.message))})]})]})}),e.jsxs("div",{className:"flex-1 flex divide-x overflow-hidden",children:[e.jsx("div",{className:"w-[540px] shrink-0 flex flex-col overflow-hidden bg-muted/5",children:e.jsx("div",{className:"h-full flex flex-col",children:e.jsxs(_e,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(qe,{className:"w-full",children:[e.jsx(te,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(te,{value:"settings",className:"flex-1",children:"Settings"}),e.jsx(te,{value:"info",className:"flex-1",children:"Info"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsx(pt,{currentModel:p,opusModel:F,sonnetModel:U,haikuModel:K,models:c,modelsLoading:d,onApplyPreset:J,onUpdateModel:m=>j("model",m),onUpdateOpusModel:m=>j("opusModel",m),onUpdateSonnetModel:m=>j("sonnetModel",m),onUpdateHaikuModel:m=>j("haikuModel",m)}),e.jsx(ht,{enabled:f,autoStart:u,port:n,accountType:l,rateLimit:C,waitOnLimit:k,onUpdateEnabled:m=>j("enabled",m),onUpdateAutoStart:m=>j("autoStart",m),onUpdatePort:m=>j("port",m),onUpdateAccountType:m=>j("accountType",m),onUpdateRateLimit:m=>j("rateLimit",m),onUpdateWaitOnLimit:m=>j("waitOnLimit",m)}),e.jsx(gt,{rawSettings:a})]})]})})}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-2 bg-muted/30 border-b flex items-center gap-2 shrink-0 h-[45px]",children:[e.jsx($e,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Raw Configuration (JSON)"})]}),e.jsx(De,{rawJsonContent:x,isRawJsonValid:A,rawJsonEdits:h,rawSettingsEnv:a?.settings?.env,onChange:$,missingRequiredFields:T})]})]}),e.jsx(Ue,{open:O,title:"File Modified Externally",description:"This settings file was modified by another process. Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>B(!0),onCancel:()=>B(!1)})]})}function ae({title:t,children:s}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide px-3",children:t}),e.jsx("div",{className:"space-y-1",children:s})]})}function W({icon:t,label:s,status:o,statusText:d,variant:r="default"}){return e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 rounded-lg bg-muted/50",children:[e.jsx(t,{className:"w-4 h-4 text-muted-foreground shrink-0"}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("span",{className:"text-sm",children:s})}),e.jsx("div",{className:"flex items-center gap-1.5",children:o?e.jsxs(e.Fragment,{children:[e.jsx(we,{className:ie("w-4 h-4",r==="warning"?"text-yellow-500":"text-green-500")}),e.jsx("span",{className:ie("text-xs",r==="warning"?"text-yellow-500":"text-green-500"),children:d||"Yes"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ne,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:d||"No"})]})})]})}function wt(){return e.jsxs("div",{className:"space-y-4 p-4",children:[e.jsx(y,{className:"h-8 w-full"}),e.jsx(y,{className:"h-12 w-full"}),e.jsx(y,{className:"h-12 w-full"}),e.jsx(y,{className:"h-12 w-full"})]})}function Ot(){const{t}=S(),{status:s,statusLoading:o,refetchStatus:d,startAuth:r,isAuthenticating:i,startDaemon:c,isStartingDaemon:a,stopDaemon:x,isStoppingDaemon:h,install:f,isInstalling:u}=be();return e.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col bg-muted/30 shrink-0",children:[e.jsxs("div",{className:"p-4 border-b bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ze,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:t("copilotPage.title")})]}),e.jsx(b,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>d(),disabled:o,children:e.jsx(fe,{className:ie("w-4 h-4",o&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("copilotPage.subtitle")})]}),e.jsx(V,{className:"flex-1",children:o?e.jsx(wt,{}):e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsxs("div",{className:"rounded-md border border-yellow-500/50 bg-yellow-500/15 p-3 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{className:"h-4 w-4 text-yellow-600 dark:text-yellow-400 shrink-0"}),e.jsx("span",{className:"text-xs font-semibold text-yellow-800 dark:text-yellow-200",children:t("copilotPage.unofficialTitle")})]}),e.jsxs("ul",{className:"text-[11px] text-yellow-700 dark:text-yellow-300 space-y-0.5 pl-6 list-disc",children:[e.jsx("li",{children:t("copilotPage.unofficialItem1")}),e.jsx("li",{children:t("copilotPage.unofficialItem2")}),e.jsx("li",{children:t("copilotPage.unofficialItem3")})]})]}),e.jsxs(ae,{title:t("copilotPage.setup"),children:[e.jsx(W,{icon:Be,label:"copilot-api",status:s?.installed??!1,statusText:s?.installed?s.version?`v${s.version}`:t("copilotPage.installed"):t("copilotPage.missing")}),!s?.installed&&e.jsx(b,{size:"sm",className:"w-full mt-2",onClick:()=>f(void 0),disabled:u,children:u?e.jsxs(e.Fragment,{children:[e.jsx(je,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}),t("copilotPage.installing")]}):e.jsxs(e.Fragment,{children:[e.jsx(Ge,{className:"w-3.5 h-3.5 mr-1.5"}),t("copilotPage.installCopilotApi")]})}),s?.installed&&e.jsx(W,{icon:ue,label:t("copilotPage.integration"),status:s?.enabled??!1,statusText:s?.enabled?t("copilotPage.enabled"):t("copilotPage.disabled")})]}),s?.installed&&e.jsxs(ae,{title:t("copilotPage.auth"),children:[e.jsx(W,{icon:He,label:t("copilotPage.github"),status:s?.authenticated??!1,statusText:s?.authenticated?t("copilotPage.connected"):t("copilotPage.notConnected")}),!s?.authenticated&&e.jsx(b,{size:"sm",className:"w-full mt-2",onClick:()=>r(),disabled:i,children:t(i?"copilotPage.authenticating":"copilotPage.authenticate")})]}),s?.authenticated&&e.jsxs(ae,{title:t("copilotPage.daemon"),children:[e.jsx(W,{icon:We,label:t("copilotPage.status"),status:s?.daemon_running??!1,statusText:s?.daemon_running?t("copilotPage.running"):t("copilotPage.stopped")}),e.jsxs("div",{className:"px-3 py-1 text-xs text-muted-foreground",children:[t("copilotPage.port"),": ",s?.port??4141]}),e.jsx("div",{className:"px-1",children:s?.daemon_running?e.jsxs(b,{size:"sm",variant:"outline",className:"w-full",onClick:()=>x(),disabled:h,children:[e.jsx(Ve,{className:"w-3.5 h-3.5 mr-1.5"}),t(h?"copilotPage.stopping":"copilotPage.stop")]}):e.jsxs(b,{size:"sm",variant:"outline",className:"w-full",onClick:()=>c(),disabled:a,children:[e.jsx(ue,{className:"w-3.5 h-3.5 mr-1.5"}),t(a?"copilotPage.starting":"copilotPage.start")]})})]})]})}),e.jsx("div",{className:"p-3 border-t bg-background text-xs text-muted-foreground",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{children:t("copilotPage.proxy")}),s?.daemon_running?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(we,{className:"w-3 h-3 text-green-500"}),t("copilotPage.active")]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ne,{className:"w-3 h-3 text-muted-foreground"}),t("copilotPage.inactive")]})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-background overflow-hidden",children:e.jsx(vt,{})})]})}export{Ot as CopilotPage};
|
|
@@ -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-DOn6k1jF.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-BCfZ54mZ.js";import{S as Ns}from"./searchable-select-1zOULoec.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:"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-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};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as Q}from"./react-vendor-CNOkPC89.js";import{t as j}from"./notifications-B2HqRBj7.js";import{bb as X,bc as Ne,a as Z,C as b,j as v,k as y,B as E,b as N,r as q,s as H,t as W,v as Y,w as k,I as le,bi as we,bj as ae,bk as ke,Q as Se,R as Pe,U,V,n as A,bd as Ee,c as Ce}from"./index-DNmWbKbN.js";import{a as Te,u as ie,b as Ae}from"./tanstack-CrmUhA7Z.js";import{a as Re}from"./raw-json-settings-editor-panel-Dr_BNQwQ.js";import{ax as _e,aB as De,N as Oe,L as Me,S as Be,aX as Fe,x as Le,I as Ie,T as Ke,ad as Ue,ah as Ve,p as oe}from"./icons-KVCk4_U8.js";import{S as R}from"./separator-DJ0ku_ak.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";function $e(s){try{const r=JSON.parse(s);return!r||typeof r!="object"||Array.isArray(r)?{settings:null,parseError:"JSON root must be an object."}:{settings:r,parseError:null}}catch(r){return{settings:null,parseError:r.message}}}async function ze(){const s=await fetch(X("/droid/diagnostics"));if(!s.ok)throw new Error("Failed to fetch Droid diagnostics");return s.json()}async function Je(){const s=await fetch(X("/droid/settings/raw"));if(!s.ok)throw new Error("Failed to fetch Droid raw settings");return s.json()}async function Qe(s){const r=await fetch(X("/droid/settings/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(r.status===409)throw new Ne("Droid raw settings changed externally");if(!r.ok){const n=await r.json().catch(()=>null);throw new Error(n?.error||"Failed to save Droid raw settings")}return r.json()}function qe(){const s=Te(),r=ie({queryKey:["droid-diagnostics"],queryFn:ze,refetchInterval:1e4}),n=ie({queryKey:["droid-raw-settings"],queryFn:Je}),i=Ae({mutationFn:Qe,onSuccess:(l,d)=>{s.setQueryData(["droid-raw-settings"],o=>{const t=o?.path??"~/.factory/settings.json",c=o?.resolvedPath??t,m=$e(d.rawText);return{path:t,resolvedPath:c,exists:!0,mtime:l.mtime,rawText:d.rawText,settings:m.settings,parseError:m.parseError}}),s.invalidateQueries({queryKey:["droid-diagnostics"]})}});return Q.useMemo(()=>({diagnostics:r.data,diagnosticsLoading:r.isLoading,diagnosticsError:r.error,refetchDiagnostics:r.refetch,rawSettings:n.data,rawSettingsLoading:n.isLoading,rawSettingsError:n.error,refetchRawSettings:n.refetch,saveRawSettings:i.mutate,saveRawSettingsAsync:i.mutateAsync,isSavingRawSettings:i.isPending}),[r.data,r.isLoading,r.error,r.refetch,n.data,n.isLoading,n.error,n.refetch,i.mutate,i.mutateAsync,i.isPending])}const He=["customModels","custom_models"],We={low:4e3,medium:12e3,high:3e4,max:5e4,xhigh:64e3},Ye=["low","medium","high","max","xhigh"];function p(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)}function h(s){return typeof s=="string"&&s.trim()?s.trim():null}function D(s){return typeof s=="number"&&Number.isFinite(s)?s:null}function G(s){if(!s)return"unknown";const r=s.toLowerCase();return r==="anthropic"?"anthropic":r==="openai"?"openai":r==="generic-chat-completion-api"?"generic-chat-completion-api":"unknown"}function Ge(s,r,n){return`${s}:${r}:${encodeURIComponent(String(n))}`}function Xe(s){const r=s.indexOf(":"),n=s.indexOf(":",r+1);if(r<=0||n<=r+1)return null;const i=s.slice(0,r),l=s.slice(r+1,n),d=s.slice(n+1);if(i!=="customModels"&&i!=="custom_models"||l!=="array"&&l!=="object")return null;const o=decodeURIComponent(d);if(l==="array"){const t=Number.parseInt(o,10);return!Number.isInteger(t)||t<0?null:{rootKey:i,locationType:l,locationKey:t}}return{rootKey:i,locationType:l,locationKey:o}}function Ze(s){return!s||s<=0?null:s<=4e3?"low":s<=12e3?"medium":s<=3e4?"high":s<=5e4?"max":"xhigh"}function es(s){return Object.prototype.hasOwnProperty.call(s,"extraArgs")?"extraArgs":Object.prototype.hasOwnProperty.call(s,"extra_args")?"extra_args":"extraArgs"}function de(s){return JSON.parse(JSON.stringify(s))}function ss(s){const r=[];for(const n of He){const i=s[n];if(Array.isArray(i)){i.forEach((l,d)=>{p(l)&&r.push({rootKey:n,locationType:"array",locationKey:d,entry:l})});continue}if(p(i))for(const[l,d]of Object.entries(i))p(d)&&r.push({rootKey:n,locationType:"object",locationKey:l,entry:d})}return r}function ce(s,r){const n=Xe(r);if(!n)return null;const i=s[n.rootKey];if(n.locationType==="array"){if(!Array.isArray(i))return null;const o=i[n.locationKey];if(!p(o))return null;const t=h(o.provider);return{entry:o,providerKind:G(t)}}if(!p(i))return null;const l=i[n.locationKey];if(!p(l))return null;const d=h(l.provider);return{entry:l,providerKind:G(d)}}function rs(s,r){const n=r.extraArgs??r.extra_args,i=p(n)?n:null;if(!i)return{effort:null,anthropicBudgetTokens:null};const l=h(i.reasoning_effort)??h(i.reasoningEffort),d=p(i.reasoning)?i.reasoning:null,o=d?h(d.effort):null,t=p(i.thinking)?i.thinking:null,c=t?h(t.type):null,m=t?D(t.budget_tokens)??D(t.budgetTokens):null;return s==="openai"?{effort:o??l,anthropicBudgetTokens:null}:s==="anthropic"?c==="enabled"?{effort:Ze(m)??"high",anthropicBudgetTokens:m}:{effort:o??l,anthropicBudgetTokens:m}:{effort:l??o,anthropicBudgetTokens:null}}function ts(s){if(!s)return null;const r=s.trim().toLowerCase();return!r||r==="default"||r==="unset"||r==="off"||r==="none"||r==="disabled"?null:r}function ue(s){const r=es(s),n=s[r],i=p(n)?{...n}:{};return{extraArgsKey:r,extraArgs:i}}function me(s,r,n){if(Object.keys(n).length===0){delete s[r];return}s[r]=n}function ns(s){return ss(s).map(({rootKey:r,locationType:n,locationKey:i,entry:l})=>{const d=h(l.displayName)??h(l.model_display_name)??"Unnamed model",o=h(l.model)??"",t=h(l.provider)??"unknown",c=G(t),m=rs(c,l);return{id:Ge(r,n,i),rootKey:r,locationType:n,locationKey:i,displayName:d,model:o,provider:t,providerKind:c,effort:m.effort,anthropicBudgetTokens:m.anthropicBudgetTokens}})}function as(s,r,n){const i=de(s),l=ce(i,r);if(!l)return null;const d=ts(n),{extraArgsKey:o,extraArgs:t}=ue(l.entry);if(l.providerKind==="openai")if(delete t.reasoning_effort,delete t.reasoningEffort,!d)delete t.reasoning;else{const c=p(t.reasoning)?t.reasoning:{};t.reasoning={...c,effort:d}}else if(l.providerKind==="anthropic")if(delete t.reasoning_effort,delete t.reasoningEffort,delete t.reasoning,!d)delete t.thinking;else{const c=p(t.thinking)?{...t.thinking}:{},m=D(c.budget_tokens)??D(c.budgetTokens);delete c.budgetTokens,t.thinking={...c,type:"enabled",budget_tokens:m??We[d]??3e4}}else delete t.reasoning,delete t.reasoningEffort,d?t.reasoning_effort=d:delete t.reasoning_effort;return me(l.entry,o,t),i}function is(s,r,n){const i=de(s),l=ce(i,r);if(!l||l.providerKind!=="anthropic")return null;const{extraArgsKey:d,extraArgs:o}=ue(l.entry),t=p(o.thinking)?{...o.thinking}:{};if(t.type="enabled",n===null)delete t.budget_tokens,delete t.budgetTokens;else{const c=Math.max(1024,Math.floor(n));t.budget_tokens=c,delete t.budgetTokens}return o.thinking=t,me(l.entry,d,o),i}const $="__unset__";function os(s){return s.providerKind==="openai"?"Writes: extraArgs.reasoning.effort":s.providerKind==="anthropic"?"Writes: extraArgs.thinking.{type,budget_tokens}":"Writes: extraArgs.reasoning_effort"}function ls({models:s,disabled:r,disabledReason:n,onEffortChange:i,onAnthropicBudgetChange:l}){const{t:d}=Z();return e.jsxs(b,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(_e,{className:"h-4 w-4"}),d("droidSettings.reasoningControls"),e.jsx(E,{variant:"outline",className:"text-[10px] font-normal",children:"customModels"})]})}),e.jsxs(N,{className:"space-y-3",children:[n&&e.jsx("p",{className:"text-xs text-amber-600",children:n}),s.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No BYOK custom models found in settings.json (`customModels` or `custom_models`)."}):e.jsx("div",{className:"space-y-2",children:s.map(o=>e.jsxs("div",{className:"rounded-md border p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:o.displayName}),e.jsx("p",{className:"text-[11px] font-mono text-muted-foreground truncate",children:o.model||"(missing model id)"})]}),e.jsx(E,{variant:"outline",className:"font-mono text-[10px] shrink-0",children:o.provider})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-medium",children:d("codex.reasoningEffortCapitalized")}),e.jsxs(q,{value:o.effort??$,onValueChange:t=>i(o.id,t===$?null:t),disabled:r,children:[e.jsx(H,{className:"h-8 text-xs",children:e.jsx(W,{placeholder:"Use provider default"})}),e.jsxs(Y,{children:[e.jsx(k,{value:$,children:"Use provider default"}),Ye.map(t=>e.jsx(k,{value:t,children:t},t))]})]})]}),o.providerKind==="anthropic"&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-medium",children:d("codex.thinkingBudgetTokens")}),e.jsx(le,{type:"number",min:1024,step:1024,value:o.anthropicBudgetTokens??"",placeholder:"auto",className:"h-8 text-xs",disabled:r,onChange:t=>{const c=t.target.value.trim();if(!c){l(o.id,null);return}const m=Number.parseInt(c,10);Number.isFinite(m)&&l(o.id,Math.max(1024,m))}})]})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:os(o)})]},o.id))})]})]})}const T="__unset__",ds=[{key:"reasoningEffort",label:"Reasoning Effort",description:"none | medium | high | max",options:[{value:"none",label:"none"},{value:"medium",label:"medium"},{value:"high",label:"high"},{value:"max",label:"max"}]},{key:"autonomyLevel",label:"Autonomy Level",description:"suggest | aggressive | full",options:[{value:"suggest",label:"suggest"},{value:"aggressive",label:"aggressive"},{value:"full",label:"full"}]},{key:"diffMode",label:"Diff Mode",description:"auto | none | inline | split",options:[{value:"auto",label:"auto"},{value:"none",label:"none"},{value:"inline",label:"inline"},{value:"split",label:"split"}]}],cs=[{key:"todoEnabled",label:"Todo Enabled"},{key:"todoAutoRefresh",label:"Todo Auto Refresh"},{key:"autoCompactEnabled",label:"Auto Compact Enabled"},{key:"soundEnabled",label:"Sound Enabled"}],us=[{key:"maxTurns",label:"Max Turns",min:1,step:1},{key:"maxToolCalls",label:"Max Tool Calls",min:1,step:1},{key:"autoCompactThreshold",label:"Auto Compact Threshold",min:1e3,step:1e3}];function ms(s){return s===!0?"true":s===!1?"false":T}function xs(s){return s==="true"?!0:s==="false"?!1:null}function gs({values:s,disabled:r,disabledReason:n,onEnumSettingChange:i,onBooleanSettingChange:l,onNumberSettingChange:d}){const{t:o}=Z();return e.jsxs(b,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(De,{className:"h-4 w-4"}),o("droidSettings.quickControls"),e.jsx(E,{variant:"outline",className:"text-[10px] font-normal",children:"settings.json"})]})}),e.jsxs(N,{className:"space-y-4",children:[n&&e.jsx("p",{className:"text-xs text-amber-600",children:n}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[ds.map(t=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:t.label}),e.jsxs(q,{value:s[t.key]??T,onValueChange:c=>i(t.key,c===T?null:c),disabled:r,children:[e.jsx(H,{className:"h-8 text-xs",children:e.jsx(W,{placeholder:o("codex.useDefault")})}),e.jsxs(Y,{children:[e.jsx(k,{value:T,children:o("codex.useDefault")}),t.options.map(c=>e.jsx(k,{value:c.value,children:c.label},c.value))]})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:t.description})]},t.key)),us.map(t=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:t.label}),e.jsx(le,{type:"number",min:t.min,step:t.step,value:s[t.key]??"",onChange:c=>{const m=c.target.value.trim();if(!m){d(t.key,null);return}const S=Number.parseInt(m,10);Number.isFinite(S)&&d(t.key,Math.max(t.min,S))},className:"h-8 text-xs",disabled:r})]},t.key)),cs.map(t=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:t.label}),e.jsxs(q,{value:ms(s[t.key]),onValueChange:c=>l(t.key,xs(c)),disabled:r,children:[e.jsx(H,{className:"h-8 text-xs",children:e.jsx(W,{placeholder:o("codex.useDefault")})}),e.jsxs(Y,{children:[e.jsx(k,{value:T,children:o("codex.useDefault")}),e.jsx(k,{value:"true",children:"true"}),e.jsx(k,{value:"false",children:"false"})]})]})]},t.key))]})]})]})}const fs=[{id:"droid-cli-overview",label:"Droid CLI Overview",url:"https://docs.factory.ai/cli/",description:"Primary entry docs for setup, auth, and core CLI usage."},{id:"droid-byok-overview",label:"BYOK Overview",url:"https://docs.factory.ai/cli/byok/overview/",description:"BYOK model/provider shape, provider values, and migration notes."},{id:"droid-settings-reference",label:"settings.json Reference",url:"https://docs.factory.ai/cli/configuration/settings/",description:"Supported settings keys, defaults, and allowed values."}],ps=[{provider:"anthropic",label:"Anthropic Messages API",apiFormat:"Messages API",url:"https://docs.anthropic.com/en/api/messages"},{provider:"openai",label:"OpenAI Responses API",apiFormat:"Responses API",url:"https://platform.openai.com/docs/api-reference/responses"},{provider:"generic-chat-completion-api",label:"OpenAI Chat Completions Spec",apiFormat:"Chat Completions API",url:"https://platform.openai.com/docs/api-reference/chat"}];function hs(s){const r=/https?:\/\/[^\s)]+/g,n=[];let i=0,l;for(;(l=r.exec(s))!==null;){const[d]=l,o=l.index;o>i&&n.push(s.slice(i,o)),n.push(e.jsx("a",{href:d,target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:d},`${d}-${o}`)),i=o+d.length}return i<s.length&&n.push(s.slice(i)),n.length>0?n:[s]}function js(s){return!s||!Number.isFinite(s)?"N/A":new Date(s).toLocaleString()}function bs(s){return!s||s<=0?"0 B":s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(2)} MB`}function vs(s){try{const r=JSON.parse(s);return!r||typeof r!="object"||Array.isArray(r)?{valid:!1,error:"JSON root must be an object."}:{valid:!0,value:r}}catch(r){return{valid:!1,error:r.message}}}function z(s){return typeof s=="string"?s:null}function J(s){return typeof s=="number"&&Number.isFinite(s)?s:null}function _(s){return typeof s=="boolean"?s:null}function g({label:s,value:r,mono:n=!1}){return e.jsxs("div",{className:"flex items-start justify-between gap-3 text-sm",children:[e.jsx("span",{className:"text-muted-foreground shrink-0",children:s}),e.jsx("span",{className:Ce("text-right break-all",n&&"font-mono text-xs"),children:r})]})}function _s(){const{t:s}=Z(),{diagnostics:r,diagnosticsLoading:n,diagnosticsError:i,refetchDiagnostics:l,rawSettings:d,rawSettingsLoading:o,refetchRawSettings:t,saveRawSettingsAsync:c,isSavingRawSettings:m}=qe(),[S,O]=Q.useState(null),M=d?.rawText??"{}",B=S??M,ee=S!==null&&S!==M,u=vs(B),F=u.valid?{valid:!0}:{valid:!1,error:u.error},se=x=>{if(x===M){O(null);return}O(x)},L=x=>{se(JSON.stringify(x,null,2)+`
|
|
2
|
+
`)},I=(x,w)=>{if(!u.valid){j.error(s("droidPage.fixJsonBeforeQuickSettings"));return}const P={...u.value};w==null?delete P[x]:P[x]=w,L(P)},xe=u.valid?{reasoningEffort:z(u.value.reasoningEffort),autonomyLevel:z(u.value.autonomyLevel),diffMode:z(u.value.diffMode),maxTurns:J(u.value.maxTurns),maxToolCalls:J(u.value.maxToolCalls),autoCompactThreshold:J(u.value.autoCompactThreshold),todoEnabled:_(u.value.todoEnabled),todoAutoRefresh:_(u.value.todoAutoRefresh),autoCompactEnabled:_(u.value.autoCompactEnabled),soundEnabled:_(u.value.soundEnabled)}:{reasoningEffort:null,autonomyLevel:null,diffMode:null,maxTurns:null,maxToolCalls:null,autoCompactThreshold:null,todoEnabled:null,todoAutoRefresh:null,autoCompactEnabled:null,soundEnabled:null},ge=u.valid?ns(u.value):[],fe=async()=>{await Promise.all([l(),t()])},pe=async()=>{if(!F.valid){j.error(s("droidPage.invalidJson",{value:F.error}));return}try{await c({rawText:B,expectedMtime:d?.exists?d.mtime:void 0}),O(null),j.success(s("droidPage.saved"))}catch(x){Ee(x)?j.error(s("droidPage.changedExternally")):j.error(x.message||s("droidPage.failedSave"))}},re=r?.byok.customModels??[],te=Q.useMemo(()=>Object.entries(r?.byok.providerBreakdown??{}).sort((x,w)=>w[1]-x[1]),[r?.byok.providerBreakdown]),he=()=>{if(n)return e.jsxs("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:[e.jsx(Me,{className:"h-5 w-5 animate-spin mr-2"}),s("droidPage.loadingDiagnostics")]});if(i||!r)return e.jsx("div",{className:"flex h-full items-center justify-center text-destructive px-6 text-center",children:s("droidPage.failedDiagnostics")});const x=r.docsReference??{notes:[],links:[],providerDocs:[],providerValues:[],settingsHierarchy:[]},w=x.notes??[],P=x.links??[],ne=x.providerDocs??[],je=P.length>0?P:fs,be=ne.length>0?ne:ps,ve=x.providerValues??[],ye=x.settingsHierarchy??[],K="mt-0 h-full border-0 p-0 data-[state=inactive]:hidden";return e.jsxs(Se,{defaultValue:"byok",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(Pe,{className:"grid w-full grid-cols-3",children:[e.jsx(U,{value:"overview",children:s("droidPage.overview")}),e.jsx(U,{value:"byok",children:s("droidPage.byok")}),e.jsx(U,{value:"docs",children:s("droidPage.docs")})]})}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden px-4 pb-4 pt-3",children:[e.jsx(V,{value:"overview",className:K,children:e.jsx(A,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 pr-1",children:[e.jsxs(b,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(Be,{className:"h-4 w-4"}),s("droidPage.runtimeInstall")]})}),e.jsxs(N,{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:s("droidPage.status")}),e.jsx(E,{variant:r.binary.installed?"default":"secondary",children:r.binary.installed?s("droidPage.detected"):s("droidPage.notFound")})]}),e.jsx(g,{label:s("droidPage.detectionSource"),value:r.binary.source,mono:!0}),e.jsx(g,{label:s("droidPage.binaryPath"),value:r.binary.path||s("droidPage.notFound"),mono:!0}),e.jsx(g,{label:s("droidPage.installDirectory"),value:r.binary.installDir||"N/A",mono:!0}),e.jsx(g,{label:s("droidPage.version"),value:r.binary.version||"Unknown",mono:!0}),e.jsx(g,{label:s("droidPage.overridePath"),value:r.binary.overridePath||"Not set",mono:!0})]})]}),e.jsxs(b,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(Fe,{className:"h-4 w-4"}),s("droidPage.configFiles")]})}),e.jsx(N,{className:"space-y-3",children:[r.files.settings,r.files.legacyConfig].map(a=>e.jsxs("div",{className:"rounded-md border p-3 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"font-medium text-sm",children:a.label}),a.exists?e.jsx(Le,{className:"h-4 w-4 text-green-600"}):e.jsx(Ie,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(g,{label:s("droidPage.path"),value:a.path,mono:!0}),e.jsx(g,{label:s("droidPage.resolved"),value:a.resolvedPath,mono:!0}),e.jsx(g,{label:s("droidPage.size"),value:bs(a.sizeBytes)}),e.jsx(g,{label:s("droidPage.lastModified"),value:js(a.mtimeMs)}),a.parseError&&e.jsx("p",{className:"text-xs text-amber-600",children:s("droidPage.parseWarning",{value:a.parseError})}),a.readError&&e.jsx("p",{className:"text-xs text-destructive",children:s("droidPage.readWarning",{value:a.readError})})]},a.label))})]}),r.warnings.length>0&&e.jsxs(b,{className:"border-amber-200 bg-amber-50/50 dark:bg-amber-950/20",children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(Ke,{className:"h-4 w-4 text-amber-600"}),s("droidPage.warnings")]})}),e.jsx(N,{className:"space-y-1.5",children:r.warnings.map(a=>e.jsxs("p",{className:"text-sm text-amber-800 dark:text-amber-300",children:["- ",a]},a))})]})]})})}),e.jsx(V,{value:"byok",className:K,children:e.jsx(A,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 pr-1",children:[e.jsx(gs,{values:xe,disabled:o||!u.valid,disabledReason:u.valid?null:`Quick settings disabled: ${u.error}`,onEnumSettingChange:(a,f)=>{I(a,f)},onBooleanSettingChange:(a,f)=>{I(a,f)},onNumberSettingChange:(a,f)=>{I(a,f)}}),e.jsx(ls,{models:ge,disabled:o||!u.valid,disabledReason:u.valid?null:`${s("droidPage.byok")}: ${u.error}`,onEffortChange:(a,f)=>{if(!u.valid){j.error(s("droidPage.fixJsonBeforeReasoning"));return}const C=as(u.value,a,f);if(!C){j.error(s("droidPage.unableUpdateReasoning"));return}L(C)},onAnthropicBudgetChange:(a,f)=>{if(!u.valid){j.error(s("droidPage.fixJsonBeforeBudget"));return}const C=is(u.value,a,f);if(!C){j.error(s("droidPage.anthropicOnlyBudget"));return}L(C)}}),e.jsxs(b,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(Ue,{className:"h-4 w-4"}),s("droidPage.byokSummary")]})}),e.jsxs(N,{className:"space-y-2",children:[e.jsx(g,{label:s("droidPage.activeModelSelector"),value:r.byok.activeModelSelector||"Not set",mono:!0}),e.jsx(g,{label:s("droidPage.customModels"),value:String(r.byok.customModelCount)}),e.jsx(g,{label:s("droidPage.ccsManaged"),value:String(r.byok.ccsManagedCount)}),e.jsx(g,{label:s("droidPage.userManaged"),value:String(r.byok.userManagedCount)}),e.jsx(g,{label:s("droidPage.malformedEntries"),value:String(r.byok.invalidModelEntryCount)}),e.jsx(R,{}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:s("droidPage.providers")}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[te.length===0&&e.jsx(E,{variant:"secondary",className:"font-mono",children:s("droidPage.none")}),te.map(([a,f])=>e.jsxs(E,{variant:"outline",className:"font-mono text-xs",children:[a,": ",f]},a))]})]})]})]}),e.jsxs(b,{children:[e.jsx(v,{className:"pb-2",children:e.jsx(y,{className:"text-base",children:s("droidPage.customModelsTitle")})}),e.jsx(N,{children:e.jsxs("div",{className:"rounded-md border overflow-hidden",children:[e.jsxs("div",{className:"grid grid-cols-[2fr_1fr_2fr] bg-muted/40 px-3 py-2 text-xs font-medium",children:[e.jsx("span",{children:s("droidPage.modelName")}),e.jsx("span",{children:s("droidPage.provider")}),e.jsx("span",{children:s("droidPage.baseUrl")})]}),e.jsx(A,{className:"h-52",children:e.jsxs("div",{className:"divide-y",children:[re.length===0&&e.jsx("div",{className:"px-3 py-4 text-xs text-muted-foreground",children:s("droidPage.noCustomModels")}),re.map(a=>e.jsxs("div",{className:"grid grid-cols-[2fr_1fr_2fr] gap-2 px-3 py-2 text-xs",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:a.displayName}),e.jsx("p",{className:"text-muted-foreground font-mono truncate",children:a.model})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate",children:a.provider}),e.jsx("p",{className:"text-muted-foreground",children:a.apiKeyPreview||"no-key"})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate",title:a.baseUrl,children:a.host||a.baseUrl}),e.jsx("p",{className:"text-muted-foreground font-mono truncate",children:a.baseUrl})]})]},`${a.displayName}-${a.model}-${a.baseUrl}`))]})})]})})]})]})})}),e.jsx(V,{value:"docs",className:K,children:e.jsx(A,{className:"h-full",children:e.jsx("div",{className:"space-y-4 pr-1",children:e.jsxs(b,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(Ve,{className:"h-4 w-4"}),s("droidPage.docsAlignedNotes")]})}),e.jsxs(N,{className:"space-y-2 text-sm",children:[w.map((a,f)=>e.jsxs("p",{className:"text-muted-foreground",children:["- ",hs(a)]},`${f}-${a}`)),e.jsx(R,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:s("droidPage.factoryDocs")}),e.jsx("div",{className:"space-y-1.5",children:je.map(a=>e.jsxs("a",{href:a.url,target:"_blank",rel:"noreferrer",className:"block rounded-md border px-2.5 py-2 transition-colors hover:bg-muted/50",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-xs font-medium",children:a.label}),e.jsx(oe,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),e.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:a.description}),e.jsx("p",{className:"mt-1 break-all font-mono text-[11px] text-muted-foreground/90 underline underline-offset-2",children:a.url})]},a.id))})]}),e.jsx(R,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:s("droidPage.providerFactCheckDocs")}),e.jsx("div",{className:"space-y-1.5",children:be.map(a=>e.jsxs("a",{href:a.url,target:"_blank",rel:"noreferrer",className:"block rounded-md border px-2.5 py-2 transition-colors hover:bg-muted/50",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-xs font-medium",children:a.label}),e.jsx(oe,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),e.jsxs("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:["provider: ",a.provider," | format: ",a.apiFormat]}),e.jsx("p",{className:"mt-1 break-all font-mono text-[11px] text-muted-foreground/90 underline underline-offset-2",children:a.url})]},`${a.provider}-${a.url}`))})]}),e.jsx(R,{}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("droidPage.providerValues",{value:ve.join(", ")})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("droidPage.settingsHierarchy",{value:ye.join(" -> ")})})]})]})})})})]})]})};return e.jsx("div",{className:"h-full min-h-0 overflow-hidden",children:e.jsxs(we,{direction:"horizontal",className:"h-full",children:[e.jsx(ae,{defaultSize:45,minSize:35,children:e.jsx("div",{className:"h-full border-r bg-muted/20",children:he()})}),e.jsx(ke,{className:"w-2 bg-border hover:bg-primary/20 transition-colors cursor-col-resize flex items-center justify-center group",children:e.jsx(Oe,{className:"w-3 h-3 text-muted-foreground group-hover:text-primary"})}),e.jsx(ae,{defaultSize:55,minSize:35,children:e.jsx(Re,{title:s("droidPage.settingsTitle"),pathLabel:d?.path||"~/.factory/settings.json",loading:o,parseWarning:d?.parseError,value:B,dirty:ee,saving:m,saveDisabled:!ee||m||o||!F.valid,onChange:x=>{se(x)},onSave:pe,onRefresh:fe})})]})})}export{_s as DroidPage};
|