@kaitranntt/ccs 7.63.1 → 7.64.0-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -3
- package/dist/api/services/profile-lifecycle-service.js +4 -4
- package/dist/api/services/profile-lifecycle-service.js.map +1 -1
- package/dist/api/services/profile-types.d.ts +17 -0
- package/dist/api/services/profile-types.d.ts.map +1 -1
- package/dist/api/services/profile-writer.d.ts.map +1 -1
- package/dist/api/services/profile-writer.js +3 -5
- package/dist/api/services/profile-writer.js.map +1 -1
- package/dist/ccs.js +82 -15
- package/dist/ccs.js.map +1 -1
- package/dist/cliproxy/accounts/email-account-identity.d.ts +12 -0
- package/dist/cliproxy/accounts/email-account-identity.d.ts.map +1 -0
- package/dist/cliproxy/accounts/email-account-identity.js +124 -0
- package/dist/cliproxy/accounts/email-account-identity.js.map +1 -0
- package/dist/cliproxy/accounts/query.d.ts.map +1 -1
- package/dist/cliproxy/accounts/query.js +15 -8
- package/dist/cliproxy/accounts/query.js.map +1 -1
- package/dist/cliproxy/accounts/registry.d.ts +6 -0
- package/dist/cliproxy/accounts/registry.d.ts.map +1 -1
- package/dist/cliproxy/accounts/registry.js +136 -42
- package/dist/cliproxy/accounts/registry.js.map +1 -1
- package/dist/cliproxy/auth/token-manager.d.ts.map +1 -1
- package/dist/cliproxy/auth/token-manager.js +45 -11
- package/dist/cliproxy/auth/token-manager.js.map +1 -1
- package/dist/cliproxy/executor/env-resolver.d.ts +27 -0
- package/dist/cliproxy/executor/env-resolver.d.ts.map +1 -1
- package/dist/cliproxy/executor/env-resolver.js +87 -3
- package/dist/cliproxy/executor/env-resolver.js.map +1 -1
- package/dist/cliproxy/executor/index.d.ts.map +1 -1
- package/dist/cliproxy/executor/index.js +55 -12
- package/dist/cliproxy/executor/index.js.map +1 -1
- package/dist/cliproxy/model-catalog.d.ts +6 -0
- package/dist/cliproxy/model-catalog.d.ts.map +1 -1
- package/dist/cliproxy/model-catalog.js +38 -1
- package/dist/cliproxy/model-catalog.js.map +1 -1
- package/dist/cliproxy/proxy-config-resolver.d.ts +2 -1
- package/dist/cliproxy/proxy-config-resolver.d.ts.map +1 -1
- package/dist/cliproxy/proxy-config-resolver.js +1 -0
- package/dist/cliproxy/proxy-config-resolver.js.map +1 -1
- package/dist/cliproxy/proxy-target-resolver.d.ts +2 -0
- package/dist/cliproxy/proxy-target-resolver.d.ts.map +1 -1
- package/dist/cliproxy/proxy-target-resolver.js +3 -0
- package/dist/cliproxy/proxy-target-resolver.js.map +1 -1
- package/dist/cliproxy/quota-fetcher-codex.d.ts +0 -3
- package/dist/cliproxy/quota-fetcher-codex.d.ts.map +1 -1
- package/dist/cliproxy/quota-fetcher-codex.js +46 -17
- package/dist/cliproxy/quota-fetcher-codex.js.map +1 -1
- package/dist/cliproxy/remote-auth-fetcher.d.ts.map +1 -1
- package/dist/cliproxy/remote-auth-fetcher.js +89 -8
- package/dist/cliproxy/remote-auth-fetcher.js.map +1 -1
- package/dist/cliproxy/services/variant-settings.d.ts.map +1 -1
- package/dist/cliproxy/services/variant-settings.js +23 -10
- package/dist/cliproxy/services/variant-settings.js.map +1 -1
- package/dist/cliproxy/stats-transformer.d.ts.map +1 -1
- package/dist/cliproxy/stats-transformer.js +26 -3
- package/dist/cliproxy/stats-transformer.js.map +1 -1
- package/dist/cliproxy/types.d.ts +2 -0
- package/dist/cliproxy/types.d.ts.map +1 -1
- package/dist/commands/cliproxy/quota-subcommand.d.ts.map +1 -1
- package/dist/commands/cliproxy/quota-subcommand.js +25 -22
- package/dist/commands/cliproxy/quota-subcommand.js.map +1 -1
- package/dist/commands/cliproxy/variant-subcommand.d.ts.map +1 -1
- package/dist/commands/cliproxy/variant-subcommand.js +14 -6
- package/dist/commands/cliproxy/variant-subcommand.js.map +1 -1
- package/dist/commands/config-image-analysis-command.d.ts.map +1 -1
- package/dist/commands/config-image-analysis-command.js +87 -1
- package/dist/commands/config-image-analysis-command.js.map +1 -1
- package/dist/commands/install-command.d.ts.map +1 -1
- package/dist/commands/install-command.js +8 -2
- package/dist/commands/install-command.js.map +1 -1
- package/dist/config/unified-config-loader.d.ts.map +1 -1
- package/dist/config/unified-config-loader.js +9 -4
- package/dist/config/unified-config-loader.js.map +1 -1
- package/dist/config/unified-config-types.d.ts +4 -0
- package/dist/config/unified-config-types.d.ts.map +1 -1
- package/dist/config/unified-config-types.js +4 -2
- package/dist/config/unified-config-types.js.map +1 -1
- package/dist/copilot/copilot-executor.d.ts +13 -0
- package/dist/copilot/copilot-executor.d.ts.map +1 -1
- package/dist/copilot/copilot-executor.js +63 -4
- package/dist/copilot/copilot-executor.js.map +1 -1
- package/dist/delegation/executor/result-aggregator.d.ts +2 -1
- package/dist/delegation/executor/result-aggregator.d.ts.map +1 -1
- package/dist/delegation/executor/result-aggregator.js +21 -1
- package/dist/delegation/executor/result-aggregator.js.map +1 -1
- package/dist/delegation/executor/types.d.ts +6 -0
- package/dist/delegation/executor/types.d.ts.map +1 -1
- package/dist/delegation/headless-executor.d.ts.map +1 -1
- package/dist/delegation/headless-executor.js +69 -4
- package/dist/delegation/headless-executor.js.map +1 -1
- package/dist/management/checks/image-analysis-check.js +1 -1
- package/dist/management/checks/image-analysis-check.js.map +1 -1
- package/dist/management/instance-manager.d.ts +1 -1
- package/dist/management/instance-manager.d.ts.map +1 -1
- package/dist/management/instance-manager.js +10 -2
- package/dist/management/instance-manager.js.map +1 -1
- package/dist/shared/compatible-cli-contracts.d.ts +4 -0
- package/dist/shared/compatible-cli-contracts.d.ts.map +1 -1
- package/dist/targets/codex-adapter.d.ts.map +1 -1
- package/dist/targets/codex-adapter.js +78 -3
- package/dist/targets/codex-adapter.js.map +1 -1
- package/dist/targets/codex-detector.d.ts.map +1 -1
- package/dist/targets/codex-detector.js +28 -7
- package/dist/targets/codex-detector.js.map +1 -1
- package/dist/types/config.d.ts +5 -0
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/config.js.map +1 -1
- package/dist/ui/assets/{accounts-DkxZnPJE.js → accounts-BHEYnq6b.js} +1 -1
- package/dist/ui/assets/{alert-dialog-CiYMglgR.js → alert-dialog-D0EFRcfB.js} +1 -1
- package/dist/ui/assets/api-DhM3BYXr.js +4 -0
- package/dist/ui/assets/{auth-section-BMaKBRA_.js → auth-section-DVp8FQGm.js} +1 -1
- package/dist/ui/assets/{backups-section-DOpSADoH.js → backups-section-CRo0NZkA.js} +1 -1
- package/dist/ui/assets/channels-uZ_9CBqO.js +1 -0
- package/dist/ui/assets/checkbox-32DNqW_Q.js +1 -0
- package/dist/ui/assets/{claude-extension-B5RngGem.js → claude-extension-BfXlz5gV.js} +1 -1
- package/dist/ui/assets/cliproxy-DjNY9H-U.js +3 -0
- package/dist/ui/assets/{cliproxy-ai-providers-DVaaS-CT.js → cliproxy-ai-providers-5SHLMHiy.js} +5 -5
- package/dist/ui/assets/cliproxy-control-panel-Zax_m1AC.js +1 -0
- package/dist/ui/assets/codex-CRUSpjsu.js +27 -0
- package/dist/ui/assets/{confirm-dialog-B9vRgowr.js → confirm-dialog-DVf5ZmCZ.js} +1 -1
- package/dist/ui/assets/copilot-BZrihl_Z.js +3 -0
- package/dist/ui/assets/cursor-BP4nbEk_.js +1 -0
- package/dist/ui/assets/{droid-DshEfT1H.js → droid-BG92rdM2.js} +2 -2
- package/dist/ui/assets/globalenv-section-Cf6dKgSf.js +1 -0
- package/dist/ui/assets/{health-CE0VQs6K.js → health-BTy1UZs3.js} +1 -1
- package/dist/ui/assets/icons-CeH5899d.js +1 -0
- package/dist/ui/assets/index-B6SrL1O-.css +1 -0
- package/dist/ui/assets/index-BVeN0dIB.js +1 -0
- package/dist/ui/assets/index-Corv1lSo.js +69 -0
- package/dist/ui/assets/index-DHrTq-0n.js +1 -0
- package/dist/ui/assets/index-DuRYaONg.js +1 -0
- package/dist/ui/assets/index-N2ZSJurX.js +1 -0
- package/dist/ui/assets/index-wg7UtkFv.js +1 -0
- package/dist/ui/assets/{masked-input-B2tcbvAj.js → masked-input-DX9bedLy.js} +1 -1
- package/dist/ui/assets/{proxy-status-widget-BnJD49TF.js → proxy-status-widget-DVDMuZK5.js} +1 -1
- package/dist/ui/assets/{radix-ui-Dt3edmE5.js → radix-ui-C98W0NRG.js} +1 -1
- package/dist/ui/assets/{raw-json-settings-editor-panel-DnUbq1__.js → raw-json-settings-editor-panel-Dkt5E6Z_.js} +1 -1
- package/dist/ui/assets/{searchable-select-ULayr5K1.js → searchable-select-BP3Q1-Yn.js} +1 -1
- package/dist/ui/assets/separator-BLGGUlh9.js +1 -0
- package/dist/ui/assets/shared-G0XRyLig.js +8 -0
- package/dist/ui/assets/{table-E5IxHhrW.js → table-B4lRrWC-.js} +1 -1
- package/dist/ui/assets/tanstack-CfKik0yL.js +4 -0
- package/dist/ui/assets/updates--A2Sdo7N.js +1 -0
- package/dist/ui/index.html +5 -5
- package/dist/utils/claude-config-path.d.ts +2 -0
- package/dist/utils/claude-config-path.d.ts.map +1 -1
- package/dist/utils/claude-config-path.js +6 -1
- package/dist/utils/claude-config-path.js.map +1 -1
- package/dist/utils/hooks/get-image-analysis-hook-env.d.ts +3 -2
- package/dist/utils/hooks/get-image-analysis-hook-env.d.ts.map +1 -1
- package/dist/utils/hooks/get-image-analysis-hook-env.js +15 -6
- package/dist/utils/hooks/get-image-analysis-hook-env.js.map +1 -1
- package/dist/utils/hooks/image-analysis-backend-resolver.d.ts +53 -0
- package/dist/utils/hooks/image-analysis-backend-resolver.d.ts.map +1 -0
- package/dist/utils/hooks/image-analysis-backend-resolver.js +376 -0
- package/dist/utils/hooks/image-analysis-backend-resolver.js.map +1 -0
- package/dist/utils/hooks/image-analysis-runtime-status.d.ts +17 -0
- package/dist/utils/hooks/image-analysis-runtime-status.d.ts.map +1 -0
- package/dist/utils/hooks/image-analysis-runtime-status.js +132 -0
- package/dist/utils/hooks/image-analysis-runtime-status.js.map +1 -0
- package/dist/utils/hooks/image-analyzer-profile-hook-injector.d.ts +6 -5
- package/dist/utils/hooks/image-analyzer-profile-hook-injector.d.ts.map +1 -1
- package/dist/utils/hooks/image-analyzer-profile-hook-injector.js +37 -17
- package/dist/utils/hooks/image-analyzer-profile-hook-injector.js.map +1 -1
- package/dist/utils/hooks/index.d.ts +2 -0
- package/dist/utils/hooks/index.d.ts.map +1 -1
- package/dist/utils/hooks/index.js +8 -1
- package/dist/utils/hooks/index.js.map +1 -1
- package/dist/utils/websearch/claude-tool-args.d.ts +5 -0
- package/dist/utils/websearch/claude-tool-args.d.ts.map +1 -0
- package/dist/utils/websearch/claude-tool-args.js +125 -0
- package/dist/utils/websearch/claude-tool-args.js.map +1 -0
- package/dist/utils/websearch/hook-env.d.ts.map +1 -1
- package/dist/utils/websearch/hook-env.js +8 -0
- package/dist/utils/websearch/hook-env.js.map +1 -1
- package/dist/utils/websearch/hook-installer.d.ts +3 -2
- package/dist/utils/websearch/hook-installer.d.ts.map +1 -1
- package/dist/utils/websearch/hook-installer.js +3 -2
- package/dist/utils/websearch/hook-installer.js.map +1 -1
- package/dist/utils/websearch/index.d.ts +3 -0
- package/dist/utils/websearch/index.d.ts.map +1 -1
- package/dist/utils/websearch/index.js +23 -2
- package/dist/utils/websearch/index.js.map +1 -1
- package/dist/utils/websearch/mcp-installer.d.ts +14 -0
- package/dist/utils/websearch/mcp-installer.d.ts.map +1 -0
- package/dist/utils/websearch/mcp-installer.js +351 -0
- package/dist/utils/websearch/mcp-installer.js.map +1 -0
- package/dist/utils/websearch/profile-hook-injector.d.ts +5 -3
- package/dist/utils/websearch/profile-hook-injector.d.ts.map +1 -1
- package/dist/utils/websearch/profile-hook-injector.js +5 -3
- package/dist/utils/websearch/profile-hook-injector.js.map +1 -1
- package/dist/utils/websearch/status.d.ts.map +1 -1
- package/dist/utils/websearch/status.js +67 -1
- package/dist/utils/websearch/status.js.map +1 -1
- package/dist/utils/websearch/trace.d.ts +23 -0
- package/dist/utils/websearch/trace.d.ts.map +1 -0
- package/dist/utils/websearch/trace.js +206 -0
- package/dist/utils/websearch/trace.js.map +1 -0
- package/dist/utils/websearch-manager.d.ts +11 -11
- package/dist/utils/websearch-manager.d.ts.map +1 -1
- package/dist/utils/websearch-manager.js +32 -17
- package/dist/utils/websearch-manager.js.map +1 -1
- package/dist/web-server/index.d.ts.map +1 -1
- package/dist/web-server/index.js +9 -1
- package/dist/web-server/index.js.map +1 -1
- package/dist/web-server/routes/account-routes.d.ts.map +1 -1
- package/dist/web-server/routes/account-routes.js +2 -1
- package/dist/web-server/routes/account-routes.js.map +1 -1
- package/dist/web-server/routes/cliproxy-auth-routes.d.ts.map +1 -1
- package/dist/web-server/routes/cliproxy-auth-routes.js +1 -1
- package/dist/web-server/routes/cliproxy-auth-routes.js.map +1 -1
- package/dist/web-server/routes/cliproxy-local-proxy.d.ts +20 -0
- package/dist/web-server/routes/cliproxy-local-proxy.d.ts.map +1 -0
- package/dist/web-server/routes/cliproxy-local-proxy.js +117 -0
- package/dist/web-server/routes/cliproxy-local-proxy.js.map +1 -0
- package/dist/web-server/routes/image-analysis-routes.d.ts +3 -0
- package/dist/web-server/routes/image-analysis-routes.d.ts.map +1 -0
- package/dist/web-server/routes/image-analysis-routes.js +362 -0
- package/dist/web-server/routes/image-analysis-routes.js.map +1 -0
- package/dist/web-server/routes/index.d.ts.map +1 -1
- package/dist/web-server/routes/index.js +2 -0
- package/dist/web-server/routes/index.js.map +1 -1
- package/dist/web-server/routes/settings-routes.d.ts.map +1 -1
- package/dist/web-server/routes/settings-routes.js +67 -5
- package/dist/web-server/routes/settings-routes.js.map +1 -1
- package/dist/web-server/services/codex-dashboard-service.d.ts.map +1 -1
- package/dist/web-server/services/codex-dashboard-service.js +27 -8
- package/dist/web-server/services/codex-dashboard-service.js.map +1 -1
- package/lib/hooks/websearch-transformer.cjs +660 -96
- package/lib/mcp/ccs-websearch-server.cjs +339 -0
- package/package.json +3 -2
- package/scripts/github/normalize-ai-review-output.mjs +232 -16
- package/scripts/github/prepare-ai-review-scope.mjs +317 -0
- package/dist/ui/assets/api-DaOtMRT4.js +0 -4
- package/dist/ui/assets/channels-zDFV-BlC.js +0 -1
- package/dist/ui/assets/checkbox-Cb5AZBZL.js +0 -1
- package/dist/ui/assets/cliproxy-VYe0Qov1.js +0 -3
- package/dist/ui/assets/cliproxy-control-panel-FVIQcFti.js +0 -1
- package/dist/ui/assets/codex-D2yIwOs4.js +0 -27
- package/dist/ui/assets/copilot-HvsOp6hu.js +0 -3
- package/dist/ui/assets/cursor-C1XOjAWS.js +0 -1
- package/dist/ui/assets/globalenv-section-CmcMkb6z.js +0 -1
- package/dist/ui/assets/icons-EMBHZkGo.js +0 -1
- package/dist/ui/assets/index-6dNBcNC3.js +0 -1
- package/dist/ui/assets/index-BAuT6yuc.css +0 -1
- package/dist/ui/assets/index-CesVGA6m.js +0 -1
- package/dist/ui/assets/index-CmKclBR1.js +0 -1
- package/dist/ui/assets/index-CmtSgCxo.js +0 -1
- package/dist/ui/assets/index-DAtuJuGe.js +0 -69
- package/dist/ui/assets/separator--ZH5ZM-3.js +0 -1
- package/dist/ui/assets/shared-qizFb9Ye.js +0 -8
- package/dist/ui/assets/switch-DmDIWykO.js +0 -1
- package/dist/ui/assets/tanstack-B8i0evp-.js +0 -4
- package/dist/ui/assets/updates-2Uu4Mgtg.js +0 -1
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Dt3edmE5.js";import{r as c}from"./react-vendor-CNOkPC89.js";import{a as Je,u as ws,b as Ys}from"./tanstack-B8i0evp-.js";import{a8 as Zs,d as I,C as bs,b as ys,c as B,P as Ee,a as ee,a9 as se,L as Z,I as de,r as Cs,s as ks,t as As,v as Ps,w as Ge,aa as Ss,ab as et,ac as st,ad as tt,u as Ms,ae as We,af as Xe,ag as Ye,ah as Ze,ai as Ds,aj as rs,ak as at,al as nt,W as Ts,am as Ve,an as Es,Y as Me,B as G,ao as Be,ap as os,aq as it,ar as rt,as as ot,at as lt,au as ct,av as ls,aw as dt,x as Rs,n as es,ax as ss,ay as cs,az as ut,m as mt,aA as pt,aB as xt,aC as ht,aD as gt,aE as ft,aF as vt,aG as jt,aH as Nt,aI as fe,T as ve,p as je,q as Ne,aJ as wt,aK as bt,aL as yt,aM as ds,aN as Ct,aO as kt,aP as At,aQ as Pt,aR as St,aS as Mt,aT as Dt,Q as Tt,R as Et,U as us,V as ms,aU as Rt,aV as _t,aW as Ot,aX as It,aY as Lt,aZ as Ft,a_ as Ut,a$ as qt,b0 as Ht,b1 as Kt,b2 as Gt,b3 as Vt,S as Bt}from"./index-DAtuJuGe.js";import{C as $e}from"./default-ports-1QQSffYX.js";import{t as H}from"./notifications-B2HqRBj7.js";import{C as _s,L as W,o as me,Q as $t,l as ue,n as Os,au as ts,R as as,p as pe,a4 as ye,T as Re,a2 as zt,av as Is,at as Qt,aw as _e,Z as Ce,O as Ls,h as Jt,t as Fs,ax as Wt,ak as Xt,X as ns,a3 as Us,m as Yt,x as Zt,y as qs,z as ze,ay as ea,u as ps,az as sa,aj as Hs,v as ta,aA as xs,an as aa,aB as Ks}from"./icons-EMBHZkGo.js";import{R as De,A as hs,D as qe,i as na,a as ia}from"./antigravity-responsibility-constants-Bvh4Ybz0.js";import{C as Te}from"./checkbox-Cb5AZBZL.js";import{C as ra}from"./confirm-dialog-B9vRgowr.js";import{S as is}from"./separator--ZH5ZM-3.js";import{S as oa}from"./searchable-select-ULayr5K1.js";import{S as Gs}from"./switch-DmDIWykO.js";import{P as la}from"./proxy-status-widget-BnJD49TF.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-CiYMglgR.js";const Vs=Object.freeze({"gemini-3-pro-preview":"gemini-3.1-pro-preview","gemini-3.1-pro-preview":"gemini-3-pro-preview","gemini-3-flash-preview":"gemini-3.1-flash-preview","gemini-3.1-flash-preview":"gemini-3-flash-preview"}),ca=/^gemini-(\d+(?:[.-]\d+)*)-(pro|flash)-preview(-customtools)?$/i;function be(s){return Zs(s).toLowerCase()}function Oe(s){const t=be(s),a=t.match(ca);if(!a)return null;const[,n,i,l]=a;return{normalizedId:t,version:n.split(/[.-]/).map(d=>Number(d)),family:i,customtools:!!l,dottedVersion:n.includes(".")}}function Bs(s,t){const a=Math.max(s.length,t.length);for(let n=0;n<a;n+=1){const i=s[n]??0,l=t[n]??0;if(i!==l)return i>l?1:-1}return 0}function da(s,t,a){if(s.customtools!==t.customtools)return s.customtools?1:-1;const n=Bs(s.version,t.version);if(n!==0)return n>0?-1:1;const i=+(s.dottedVersion===a.dottedVersion),l=+(t.dottedVersion===a.dottedVersion);return i!==l?l-i:s.normalizedId.localeCompare(t.normalizedId)}function gs(s,t){const a=be(t);return s.find(n=>be(n.id)===a)?.id}function ua(s,t){const a=Oe(s);return!a||t.length===0?void 0:t.map(i=>{const l=Oe(i.id);return!l||l.family!==a.family?null:{id:i.id,info:l}}).filter(i=>!!i).sort((i,l)=>da(i.info,l.info,a))[0]?.id}const xe={agy:{provider:"agy",displayName:"Antigravity",defaultModel:"claude-opus-4-6-thinking",models:[{id:"claude-opus-4-6-thinking",name:"Claude Opus 4.6 Thinking",description:"Latest flagship, extended thinking",extendedContext:!1,presetMapping:{default:"claude-opus-4-6-thinking",opus:"claude-opus-4-6-thinking",sonnet:"claude-sonnet-4-6",haiku:"claude-sonnet-4-6"}},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",description:"Latest Sonnet with thinking budget support",presetMapping:{default:"claude-sonnet-4-6",opus:"claude-opus-4-6-thinking",sonnet:"claude-sonnet-4-6",haiku:"claude-sonnet-4-6"}},{id:"gemini-3.1-pro-preview",name:"Gemini Pro",description:"Resolves to the best advertised Gemini Pro preview via Antigravity",extendedContext:!0,presetMapping:{default:"gemini-3.1-pro-preview",opus:"gemini-3.1-pro-preview",sonnet:"gemini-3.1-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-3-flash-preview",name:"Gemini Flash",description:"Resolves to the best advertised Gemini Flash preview via Antigravity",extendedContext:!0,presetMapping:{default:"gemini-3-flash-preview",opus:"gemini-3.1-pro-preview",sonnet:"gemini-3.1-pro-preview",haiku:"gemini-3-flash-preview"}}]},gemini:{provider:"gemini",displayName:"Gemini",defaultModel:"gemini-2.5-pro",models:[{id:"gemini-3.1-pro-preview",name:"Gemini Pro",tier:"paid",description:"Uses the best advertised Gemini Pro preview when Google exposes one",extendedContext:!0,presetMapping:{default:"gemini-3.1-pro-preview",opus:"gemini-3.1-pro-preview",sonnet:"gemini-3.1-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-3-flash-preview",name:"Gemini Flash",tier:"paid",description:"Uses the best advertised Gemini Flash preview when Google exposes one",extendedContext:!0,presetMapping:{default:"gemini-3-flash-preview",opus:"gemini-3.1-pro-preview",sonnet:"gemini-3.1-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-2.5-pro",name:"Gemini 2.5 Pro",description:"Stable, works with free Google account",extendedContext:!0,presetMapping:{default:"gemini-2.5-pro",opus:"gemini-2.5-pro",sonnet:"gemini-2.5-pro",haiku:"gemini-2.5-flash"}}]},codex:{provider:"codex",displayName:"Codex",defaultModel:"gpt-5-codex",models:[{id:"gpt-5-codex",name:"GPT-5 Codex",description:"Cross-plan safe Codex default",presetMapping:{default:"gpt-5-codex",opus:"gpt-5-codex",sonnet:"gpt-5-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5-codex-mini",name:"GPT-5 Codex Mini",description:"Faster and cheaper Codex option",presetMapping:{default:"gpt-5-codex-mini",opus:"gpt-5-codex",sonnet:"gpt-5-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5-mini",name:"GPT-5 Mini",description:"Legacy mini model ID kept for backwards compatibility",presetMapping:{default:"gpt-5-mini",opus:"gpt-5-codex",sonnet:"gpt-5-mini",haiku:"gpt-5-mini"}},{id:"gpt-5.1-codex-mini",name:"GPT-5.1 Codex Mini",description:"Legacy fast Codex mini model",presetMapping:{default:"gpt-5.1-codex-mini",opus:"gpt-5.1-codex-max",sonnet:"gpt-5.1-codex-max",haiku:"gpt-5.1-codex-mini"}},{id:"gpt-5.1-codex-max",name:"GPT-5.1 Codex Max",description:"Higher-effort Codex model with xhigh support",presetMapping:{default:"gpt-5.1-codex-max",opus:"gpt-5.1-codex-max",sonnet:"gpt-5.1-codex-max",haiku:"gpt-5.1-codex-mini"}},{id:"gpt-5.2-codex",name:"GPT-5.2 Codex",description:"Cross-plan Codex model with xhigh support",presetMapping:{default:"gpt-5.2-codex",opus:"gpt-5.2-codex",sonnet:"gpt-5.2-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5.3-codex",name:"GPT-5.3 Codex",tier:"paid",description:"Paid Codex plans only",presetMapping:{default:"gpt-5.3-codex",opus:"gpt-5.3-codex",sonnet:"gpt-5.3-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5.3-codex-spark",name:"GPT-5.3 Codex Spark",tier:"paid",description:"Paid Codex plans only, ultra-fast coding model",presetMapping:{default:"gpt-5.3-codex-spark",opus:"gpt-5.3-codex",sonnet:"gpt-5.3-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5.4",name:"GPT-5.4",tier:"paid",description:"Paid Codex plans only, latest GPT-5 family model",presetMapping:{default:"gpt-5.4",opus:"gpt-5.4",sonnet:"gpt-5.4",haiku:"gpt-5-codex-mini"}}]},qwen:{provider:"qwen",displayName:"Qwen",defaultModel:"qwen3-coder-plus",models:[{id:"qwen3-coder-plus",name:"Qwen3 Coder Plus",description:"Code-focused model (1M context)",presetMapping:{default:"qwen3-coder-plus",opus:"qwen3-max",sonnet:"qwen3-coder-plus",haiku:"qwen3-coder-flash"}},{id:"qwen3-max",name:"Qwen3 Max",description:"Flagship model (256K context)",presetMapping:{default:"qwen3-max",opus:"qwen3-max",sonnet:"qwen3-coder-plus",haiku:"qwen3-coder-flash"}},{id:"qwen3-max-preview",name:"Qwen3 Max Preview",description:"Preview with thinking support (256K)",presetMapping:{default:"qwen3-max-preview",opus:"qwen3-max-preview",sonnet:"qwen3-max",haiku:"qwen3-coder-flash"}},{id:"qwen3-235b",name:"Qwen3 235B",description:"Large 235B A22B model",presetMapping:{default:"qwen3-235b",opus:"qwen3-max",sonnet:"qwen3-235b",haiku:"qwen3-coder-flash"}},{id:"qwen3-vl-plus",name:"Qwen3 VL Plus",description:"Vision-language multimodal"},{id:"qwen3-coder-flash",name:"Qwen3 Coder Flash",description:"Fast code generation"},{id:"qwen3-32b",name:"Qwen3 32B",description:"Qwen3 32B model"}]},iflow:{provider:"iflow",displayName:"iFlow",defaultModel:"qwen3-coder-plus",models:[{id:"qwen3-coder-plus",name:"Qwen3 Coder Plus",description:"Recommended default for iFlow accounts",presetMapping:{default:"qwen3-coder-plus",opus:"qwen3-coder-plus",sonnet:"qwen3-coder-plus",haiku:"qwen3-coder-plus"}},{id:"qwen3-max",name:"Qwen3 Max",description:"Flagship Qwen model via iFlow"},{id:"kimi-k2",name:"Kimi K2",description:"Kimi model currently available via iFlow"},{id:"deepseek-v3.2",name:"DeepSeek V3.2",description:"Current DeepSeek V3.2 model via iFlow"},{id:"deepseek-r1",name:"DeepSeek R1",description:"Reasoning-focused DeepSeek model"},{id:"glm-4.6",name:"GLM 4.6",description:"Zhipu GLM 4.6 via iFlow"},{id:"qwen3-vl-plus",name:"Qwen3 VL Plus",description:"Vision-language model"}]},kimi:{provider:"kimi",displayName:"Kimi (Moonshot)",defaultModel:"kimi-k2.5",models:[{id:"kimi-k2.5",name:"Kimi K2.5",description:"Latest multimodal model (262K context)",presetMapping:{default:"kimi-k2.5",opus:"kimi-k2.5",sonnet:"kimi-k2-thinking",haiku:"kimi-k2"}},{id:"kimi-k2-thinking",name:"Kimi K2 Thinking",description:"Extended reasoning model",presetMapping:{default:"kimi-k2-thinking",opus:"kimi-k2.5",sonnet:"kimi-k2-thinking",haiku:"kimi-k2"}},{id:"kimi-k2",name:"Kimi K2",description:"Flagship coding model"}]},kiro:{provider:"kiro",displayName:"Kiro (AWS)",defaultModel:"kiro-claude-sonnet-4-5",models:[{id:"kiro-claude-opus-4-5",name:"Kiro Claude Opus 4.5",description:"Claude Opus 4.5 via Kiro (2.2x credit)",presetMapping:{default:"kiro-claude-opus-4-5",opus:"kiro-claude-opus-4-5",sonnet:"kiro-claude-sonnet-4-5",haiku:"kiro-claude-haiku-4-5"}},{id:"kiro-claude-sonnet-4-5",name:"Kiro Claude Sonnet 4.5",description:"Claude Sonnet 4.5 via Kiro (1.3x credit)",presetMapping:{default:"kiro-claude-sonnet-4-5",opus:"kiro-claude-opus-4-5",sonnet:"kiro-claude-sonnet-4-5",haiku:"kiro-claude-haiku-4-5"}},{id:"kiro-claude-sonnet-4",name:"Kiro Claude Sonnet 4",description:"Claude Sonnet 4 via Kiro (1.3x credit)",presetMapping:{default:"kiro-claude-sonnet-4",opus:"kiro-claude-opus-4-5",sonnet:"kiro-claude-sonnet-4",haiku:"kiro-claude-haiku-4-5"}},{id:"kiro-claude-haiku-4-5",name:"Kiro Claude Haiku 4.5",description:"Claude Haiku 4.5 via Kiro (0.4x credit)"}]},ghcp:{provider:"ghcp",displayName:"GitHub Copilot (OAuth)",defaultModel:"claude-sonnet-4.5",models:[{id:"claude-opus-4.5",name:"Claude Opus 4.5",description:"Anthropic Claude Opus 4.5 via GitHub Copilot",presetMapping:{default:"claude-opus-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"}},{id:"claude-sonnet-4.5",name:"Claude Sonnet 4.5",description:"Anthropic Claude Sonnet 4.5 via GitHub Copilot",presetMapping:{default:"claude-sonnet-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"}},{id:"claude-sonnet-4",name:"Claude Sonnet 4",description:"Anthropic Claude Sonnet 4 via GitHub Copilot"},{id:"claude-haiku-4.5",name:"Claude Haiku 4.5",description:"Anthropic Claude Haiku 4.5 via GitHub Copilot"},{id:"gpt-5.2",name:"GPT-5.2",description:"OpenAI GPT-5.2 via GitHub Copilot",presetMapping:{default:"gpt-5.2",opus:"gpt-5.2",sonnet:"gpt-5.1",haiku:"gpt-5-mini"}},{id:"gpt-5.1",name:"GPT-5.1",description:"OpenAI GPT-5.1 via GitHub Copilot"},{id:"gpt-5",name:"GPT-5",description:"OpenAI GPT-5 via GitHub Copilot"},{id:"gpt-5-mini",name:"GPT-5 Mini",description:"OpenAI GPT-5 Mini via GitHub Copilot"},{id:"gemini-3-pro",name:"Gemini 3 Pro",description:"Google Gemini 3 Pro via GitHub Copilot"}]},claude:{provider:"claude",displayName:"Claude (Anthropic)",defaultModel:"claude-sonnet-4-6",models:[{id:"claude-opus-4-6",name:"Claude Opus 4.6",description:"Latest flagship model",extendedContext:!0,presetMapping:{default:"claude-opus-4-6",opus:"claude-opus-4-6",sonnet:"claude-sonnet-4-6",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",description:"Balanced performance and speed",extendedContext:!0,presetMapping:{default:"claude-sonnet-4-6",opus:"claude-opus-4-6",sonnet:"claude-sonnet-4-6",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-opus-4-5-20251101",name:"Claude Opus 4.5",description:"Most capable Claude model",extendedContext:!0,presetMapping:{default:"claude-opus-4-5-20251101",opus:"claude-opus-4-5-20251101",sonnet:"claude-sonnet-4-5-20250929",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-sonnet-4-5-20250929",name:"Claude Sonnet 4.5",description:"Balanced performance and speed",extendedContext:!0,presetMapping:{default:"claude-sonnet-4-5-20250929",opus:"claude-opus-4-5-20251101",sonnet:"claude-sonnet-4-5-20250929",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-sonnet-4-20250514",name:"Claude Sonnet 4",description:"Previous generation Sonnet",extendedContext:!0,presetMapping:{default:"claude-sonnet-4-20250514",opus:"claude-opus-4-5-20251101",sonnet:"claude-sonnet-4-20250514",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-haiku-4-5-20251001",name:"Claude Haiku 4.5",description:"Fast and efficient"}]}};function $s(s,t){const a=xe[s.toLowerCase()];if(!a)return;const n=be(t),i=Vs[n.toLowerCase()],l=a.models.find(r=>r.id===n||r.id===i);if(l)return l;const d=Oe(n);if(d)return a.models.map(r=>({model:r,info:Oe(r.id)})).filter(r=>!!(r.info&&r.info.family===d.family)).sort((r,o)=>Bs(o.info.version,r.info.version))[0]?.model}function we(s,t=[]){const a=be(s),n=ua(a,t);if(n)return n;const i=gs(t,a);if(i)return i;const l=Vs[a];return(l?gs(t,l):void 0)??a}function ma(s,t=[]){return{default:we(s.default,t),opus:we(s.opus,t),sonnet:we(s.sonnet,t),haiku:we(s.haiku,t)}}function zs(s,t=[]){if(!s)return[];const a=new Set;return s.models.map(n=>{const i=we(n.id,t),l=n.presetMapping?ma(n.presetMapping,t):void 0;return{...n,id:i,presetMapping:l}}).filter(n=>a.has(n.id)?!1:(a.add(n.id),!0))}function pa(s,t){return $s(s,t)?.extendedContext===!0}const He="ccs-internal-managed";async function xa(){try{const s=await fetch("/api/settings/auth/tokens/raw");return s.ok?(await s.json())?.apiKey?.value??He:He}catch{return He}}async function Qe(s,t){const a=xe[s];if(!a)return{success:!1};const n=a.models.find(o=>o.id===a.defaultModel)||a.models[0],i=n?.presetMapping||{default:a.defaultModel,opus:a.defaultModel,sonnet:a.defaultModel,haiku:a.defaultModel},l=await xa(),r={env:{ANTHROPIC_BASE_URL:`http://127.0.0.1:${$e}/api/provider/${s}`,ANTHROPIC_AUTH_TOKEN:l,ANTHROPIC_MODEL:i.default,ANTHROPIC_DEFAULT_OPUS_MODEL:i.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:i.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:i.haiku}};try{return{success:(await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:r})})).ok,presetName:n?.name||a.defaultModel}}catch{return{success:!1}}}function ha({currentProgress:s,allSteps:t}){return e.jsx("div",{className:"flex justify-center gap-1 pt-2",children:t.map((a,n)=>e.jsx("div",{className:`w-2 h-2 rounded-full transition-colors ${s>=n?"bg-primary":"bg-muted"}`},a))})}function ga({providers:s,onSelect:t}){return e.jsx("div",{className:"grid gap-2",children:s.map(a=>e.jsxs("button",{onClick:()=>t(a.id),className:"flex items-center justify-between p-3 border rounded-lg hover:bg-muted/50 transition-colors text-left",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:a.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:a.description})]}),e.jsx(_s,{className:"w-4 h-4 text-muted-foreground"})]},a.id))})}function fa({selectedProvider:s,providers:t,authCommand:a,isRefreshing:n,isPending:i,onBack:l,onStartAuth:d,onRefresh:r}){const[o,u]=c.useState(!1),N=async w=>{await navigator.clipboard.writeText(w),u(!0),setTimeout(()=>u(!1),2e3)};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-center space-y-3",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Authenticate with ",t.find(w=>w.id===s)?.name," to add an account"]}),e.jsx(I,{onClick:d,disabled:i,className:"w-full gap-2",size:"lg",children:i?e.jsxs(e.Fragment,{children:[e.jsx(W,{className:"w-4 h-4 animate-spin"}),"Authenticating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(me,{className:"w-4 h-4"}),"Authenticate in Browser"]})}),i&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Complete the OAuth flow in your browser..."})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:"Or use terminal"})})]}),e.jsx(bs,{children:e.jsxs(ys,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx($t,{className:"w-4 h-4"}),"Run this command in your terminal:"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 px-3 py-2 bg-muted rounded-md font-mono text-sm",children:a}),e.jsx(I,{variant:"outline",size:"icon",onClick:()=>N(a),children:o?e.jsx(ue,{className:"w-4 h-4 text-green-500"}):e.jsx(Os,{className:"w-4 h-4"})})]})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(I,{variant:"ghost",onClick:l,disabled:i,children:[e.jsx(ts,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs(I,{variant:"outline",onClick:r,disabled:n||i,children:[e.jsx(as,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`}),n?"Checking...":"Refresh Status"]})]})]})}function va({accounts:s,privacyMode:t,onSelect:a,onAddNew:n,onBack:i}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:["Select an account (",s.length,")"]}),e.jsx("div",{className:"grid gap-2 max-h-[320px] overflow-y-auto pr-1",children:s.map(l=>e.jsxs("button",{type:"button",onClick:()=>a(l),className:"flex items-center justify-between p-3 border rounded-lg hover:bg-muted/50 transition-colors text-left",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-muted flex items-center justify-center",children:e.jsx(pe,{className:"w-4 h-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:B("font-medium",t&&Ee),children:l.email||l.id}),l.isDefault&&e.jsx("div",{className:"text-xs text-muted-foreground",children:"Default account"})]})]}),e.jsx(_s,{className:"w-4 h-4 text-muted-foreground"})]},l.id))}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:"Or"})})]}),e.jsxs("button",{type:"button",className:"w-full flex items-center gap-3 p-3 border-2 border-dashed border-primary/50 rounded-lg hover:border-primary hover:bg-primary/5 transition-colors text-left",onClick:n,children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(me,{className:"w-4 h-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-primary",children:"Add new account"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Authenticate with a different account"})]})]}),e.jsx("div",{className:"flex items-center justify-between pt-2",children:e.jsxs(I,{variant:"ghost",onClick:i,children:[e.jsx(ts,{className:"w-4 h-4 mr-2"}),"Back"]})})]})}const fs="__custom__";function ja({selectedProvider:s,selectedAccount:t,variantName:a,modelName:n,isPending:i,privacyMode:l,onVariantNameChange:d,onModelChange:r,onBack:o,onSkip:u,onCreate:N}){const{t:w}=ee(),f=xe[s]?.models||[],O=n&&!f.some(g=>g.id===n),[j,k]=c.useState(O),A=s==="agy"&&n.trim().length>0?se(n):!1,P=g=>{g===fs?(k(!0),r("")):(k(!1),r(g))};return e.jsxs("div",{className:"space-y-4",children:[t&&e.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/50 rounded-md text-sm",children:[e.jsx(pe,{className:"w-4 h-4"}),e.jsxs("span",{children:[w("setupVariant.using")," ",e.jsx("span",{className:B(l&&Ee),children:t.email||t.id})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"variant-name",children:w("setupVariant.variantNameRequired")}),e.jsx(de,{id:"variant-name",value:a,onChange:g=>d(g.target.value),placeholder:w("setupVariant.variantNamePlaceholder")}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[w("setupVariant.invokeHintPrefix")," ccs ",a||"<name>",' "prompt"']})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:w("setupVariant.model")}),j?e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{value:n,onChange:g=>r(g.target.value),placeholder:w("setupVariant.modelPlaceholder")}),A&&e.jsx("p",{className:"text-xs text-destructive",children:"Antigravity denylist: Claude Opus 4.5 and Claude Sonnet 4.5 are deprecated."}),e.jsx("button",{type:"button",className:"text-xs text-primary hover:underline",onClick:()=>{k(!1),s==="agy"&&se(n)&&r("")},children:w("setupVariant.choosePresetInstead")})]}):e.jsxs(Cs,{value:f.some(g=>g.id===n)?n:"",onValueChange:P,children:[e.jsx(ks,{children:e.jsx(As,{placeholder:w("setupVariant.selectModel")})}),e.jsxs(Ps,{children:[f.map(g=>e.jsx(Ge,{value:g.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:g.name}),g.description&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",g.description]})]})},g.id)),e.jsx(Ge,{value:fs,children:e.jsx("span",{className:"text-primary",children:w("setupVariant.customModelName")})})]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:j?w("setupVariant.enterAnyModel"):w("setupVariant.defaultModel",{model:xe[s]?.defaultModel||w("setupVariant.providerDefault")})})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs(I,{variant:"ghost",onClick:o,children:[e.jsx(ts,{className:"w-4 h-4 mr-2"}),w("setupVariant.back")]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(I,{variant:"ghost",onClick:u,children:w("setupVariant.skip")}),e.jsx(I,{onClick:N,disabled:!a||i||A,children:w(i?"setupVariant.creating":"setupVariant.createVariant")})]})]}),e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:w("setupVariant.skipHint")})]})}function Na({variantName:s,onClose:t}){return e.jsxs("div",{className:"space-y-4 text-center",children:[e.jsx("div",{className:"flex justify-center",children:e.jsx("div",{className:"w-16 h-16 bg-green-100 dark:bg-green-900/30 rounded-full flex items-center justify-center",children:e.jsx(ue,{className:"w-8 h-8 text-green-600 dark:text-green-400"})})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-lg",children:"Variant Created!"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Your custom variant is ready to use"})]}),e.jsx(bs,{children:e.jsxs(ys,{className:"p-4 space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Usage:"}),e.jsxs("code",{className:"block px-3 py-2 bg-muted rounded-md font-mono text-sm",children:["ccs ",s,' "your prompt here"']})]})}),e.jsx(I,{onClick:t,className:"w-full",children:"Done"})]})}function wa({open:s,onClose:t}){const[a,n]=c.useState("provider"),[i,l]=c.useState(""),[d,r]=c.useState(null),[o,u]=c.useState(""),[N,w]=c.useState(""),[f,O]=c.useState(!1),[j,k]=c.useState(!1),{data:A,refetch:P}=Ss(),g=et(),p=st(),y=tt(),{privacyMode:C}=Ms(),M=A?.authStatus.find(E=>E.provider===i),m=c.useMemo(()=>M?.accounts||[],[M?.accounts]);c.useEffect(()=>{if(!s){const E=setTimeout(()=>{n("provider"),l(""),r(null),u(""),w(""),k(!1)},0);return()=>clearTimeout(E)}},[s]),c.useEffect(()=>{if(a==="auth"&&m.length>0&&!j){const E=setTimeout(()=>{n("account")},0);return()=>clearTimeout(E)}},[a,m,j]);const S=async()=>{O(!0),await P(),O(!1)},T=()=>{const E=(M?.accounts?.length||0)===0;p.mutate({provider:i},{onSuccess:async _=>{if(E){const K=await Qe(i);K.success&&K.presetName?H.success(`Applied "${K.presetName}" preset`):K.success||H.warning(Ts.t("commonToast.accountAddedPresetFailed"))}_.account&&(r(_.account),n("variant")),P()}})},U=E=>{l(E),(A?.authStatus.find(V=>V.provider===E)?.accounts||[]).length===0?n("auth"):n("account")},h=E=>{r(E),n("variant")},v=async()=>{if(!(!o||!i))try{await g.mutateAsync({name:o,provider:i,model:N||void 0,account:d?.id}),n("success")}catch(E){console.error("Failed to create variant:",E)}},b=`ccs ${i} --auth --add`,q=nt(a),L=E=>{if(!E&&(p.isPending&&i&&y.mutate(i),a==="success"||a==="provider")){t();return}};return e.jsx(We,{open:s,onOpenChange:L,children:e.jsxs(Xe,{className:"sm:max-w-lg",onPointerDownOutside:E=>{a!=="success"&&a!=="provider"&&E.preventDefault()},onEscapeKeyDown:E=>{(p.isPending||g.isPending)&&E.preventDefault()},children:[e.jsxs(Ye,{children:[e.jsxs(Ze,{className:"flex items-center gap-2",children:[e.jsx(ye,{className:"w-5 h-5 text-primary"}),"Quick Setup Wizard"]}),e.jsxs(Ds,{children:[a==="provider"&&"Select a provider to get started",a==="auth"&&"Authenticate with your provider",a==="account"&&"Select which account to use",a==="variant"&&"Create your custom variant",a==="success"&&"Setup complete!"]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[a==="provider"&&e.jsx(ga,{providers:rs,onSelect:U}),a==="auth"&&e.jsx(fa,{selectedProvider:i,providers:rs,authCommand:b,isRefreshing:f,isPending:p.isPending,onBack:()=>n("provider"),onStartAuth:T,onRefresh:S}),a==="account"&&e.jsx(va,{accounts:m,privacyMode:C,onSelect:h,onAddNew:()=>{k(!0),n("auth")},onBack:()=>n("provider")}),a==="variant"&&e.jsx(ja,{selectedProvider:i,selectedAccount:d,variantName:o,modelName:N,isPending:g.isPending,privacyMode:C,onVariantNameChange:u,onModelChange:w,onBack:()=>m.length>0?n("account"):n("provider"),onSkip:t,onCreate:v}),a==="success"&&e.jsx(Na,{variantName:o,onClose:t})]}),e.jsx(ha,{currentProgress:q,allSteps:at})]})})}const ba=3e3,ya=300*1e3,Ca=3;async function Ke(s){const t=await s.text();if(!t)return{};try{return JSON.parse(t)}catch{const a=s.status>=400?`Request failed with status ${s.status}`:void 0;return a?{error:a}:{}}}const ce={provider:null,isAuthenticating:!1,error:null,authUrl:null,oauthState:null,isSubmittingCallback:!1,isDeviceCodeFlow:!1};function ka(){const[s,t]=c.useState(ce),a=c.useRef(0),n=c.useRef(null),i=c.useRef(null),l=c.useRef(0),d=c.useRef(0),r=c.useRef(!1),o=Je(),u=c.useCallback(k=>k===a.current,[]),N=c.useCallback(()=>{i.current&&(clearInterval(i.current),i.current=null),d.current=0},[]);c.useEffect(()=>()=>{n.current?.abort(),N(),r.current=!1},[N]);const w=c.useCallback(async(k,A,P)=>{if(u(P)){if(Date.now()-l.current>ya){N(),u(P)&&t(g=>({...g,isAuthenticating:!1,error:"Authentication timed out. Please try again."}));return}try{const g=await fetch(`/api/cliproxy/auth/${k}/status?state=${encodeURIComponent(A)}`);if(!u(P))return;const p=await g.json();if(d.current=0,p.status==="ok"){if(!(typeof p.account=="object"&&p.account!==null)){N();const C="Authenticated account could not be registered";H.error(C),t(M=>({...M,isAuthenticating:!1,error:C}));return}N(),o.invalidateQueries({queryKey:["cliproxy-auth"]}),o.invalidateQueries({queryKey:["cliproxy-accounts"]}),o.invalidateQueries({queryKey:["account-quota"]}),H.success(`${k} authentication successful`),r.current=!1,t(ce)}else if(p.status==="auth_url"){const y=p.url||p.auth_url;y&&(t(C=>({...C,authUrl:y})),r.current||(r.current=!0,window.open(y,"_blank")))}else if(p.status==="device_code"){N();const y=p.user_code&&p.verification_url?`Open ${p.verification_url} and enter code: ${p.user_code}`:"Switch to Device Code method and try again.";H.error("Provider returned Device Code flow in callback mode"),t(C=>({...C,isAuthenticating:!1,error:y}))}else if(p.status==="error"){N();const y=p.error||"Authentication failed";H.error(y),t(C=>({...C,isAuthenticating:!1,error:y}))}}catch(g){if(!u(P)||(d.current+=1,d.current<Ca))return;N();const p=g instanceof Error&&g.message.trim().length>0?g.message:"Lost contact with the auth status endpoint";H.error(p),t(y=>({...y,isAuthenticating:!1,error:p}))}}},[u,o,N]),f=c.useCallback(async(k,A)=>{if(!Ve(k)){t({...ce,error:`Unknown provider: ${k}`});return}n.current?.abort(),N(),r.current=!1,d.current=0;const P=new AbortController,g=a.current+1;a.current=g,n.current=P;const y=(A?.flowType||(Es(k)?"device_code":"authorization_code"))==="device_code",C=A?.startEndpoint||(y?"start":"start-url"),M={nickname:A?.nickname,kiroMethod:A?.kiroMethod,riskAcknowledgement:A?.riskAcknowledgement};t({provider:k,isAuthenticating:!0,error:null,authUrl:null,oauthState:null,isSubmittingCallback:!1,isDeviceCodeFlow:y});try{if(C==="start")fetch(`/api/cliproxy/auth/${k}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(M),signal:P.signal}).then(async m=>{if(!u(g))return;const S=await Ke(m);if(!u(g))return;const T=S.success===!0,U=typeof S.account=="object"&&S.account!==null;if(m.ok&&T&&U)o.invalidateQueries({queryKey:["cliproxy-auth"]}),o.invalidateQueries({queryKey:["cliproxy-accounts"]}),o.invalidateQueries({queryKey:["account-quota"]}),r.current=!1,t(ce);else{const h=typeof S.error=="string"?S.error:T?"Authenticated account could not be registered":"Authentication failed";H.error(h),t(v=>({...v,isAuthenticating:!1,error:h}))}}).catch(m=>{if(!u(g)||m instanceof Error&&m.name==="AbortError")return;const S=m instanceof Error?m.message:"Authentication failed";H.error(S),t(T=>({...T,isAuthenticating:!1,error:S}))});else{const m=await fetch(`/api/cliproxy/auth/${k}/start-url`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(M),signal:P.signal});if(!u(g))return;const S=await Ke(m);if(!u(g))return;const T=S.success===!0;if(!m.ok||!T){const v=typeof S.error=="string"?S.error:"Failed to start OAuth";throw new Error(v)}const U=typeof S.authUrl=="string"?S.authUrl:null,h=typeof S.state=="string"?S.state:null;t(v=>({...v,authUrl:U,oauthState:h})),U&&(r.current=!0,window.open(U,"_blank")),h&&(l.current=Date.now(),i.current=setInterval(()=>{w(k,h,g)},ba))}}catch(m){if(!u(g))return;if(m instanceof Error&&m.name==="AbortError"){r.current=!1,t(ce);return}const S=m instanceof Error?m.message:"Authentication failed";H.error(S),t(T=>({...T,isAuthenticating:!1,error:S}))}},[u,w,N,o]),O=c.useCallback(()=>{const k=s.provider;a.current+=1,n.current?.abort(),N(),r.current=!1,t(ce),k&&Me.cliproxy.auth.cancel(k).catch(()=>{})},[s.provider,N]),j=c.useCallback(async k=>{if(!s.provider)return;const A=a.current,P=s.provider;t(g=>({...g,isSubmittingCallback:!0,error:null}));try{const g=await fetch(`/api/cliproxy/auth/${P}/submit-callback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({redirectUrl:k})});if(!u(A))return;const p=await Ke(g);if(!u(A))return;const y=p.success===!0,C=typeof p.account=="object"&&p.account!==null;if(g.ok&&y&&C)N(),o.invalidateQueries({queryKey:["cliproxy-auth"]}),o.invalidateQueries({queryKey:["cliproxy-accounts"]}),o.invalidateQueries({queryKey:["account-quota"]}),H.success(`${P} authentication successful`),t(ce);else{const M=typeof p.error=="string"?p.error:y?"Authenticated account could not be registered":"Callback submission failed";throw new Error(M)}}catch(g){if(!u(A))return;const p=g instanceof Error?g.message:"Failed to submit callback";H.error(p),t(y=>({...y,isSubmittingCallback:!1,error:p}))}},[u,s.provider,o,N]);return c.useMemo(()=>({...s,startAuth:f,cancelAuth:O,submitCallback:j}),[s,f,O,j])}function Qs({className:s,showAcknowledgement:t=!1,acknowledgementPhrase:a=De,acknowledgementText:n="",onAcknowledgementTextChange:i,disabled:l=!1,showProxySettingsLink:d=!1}){const{t:r}=ee(),o=r("accountSafetyWarning.title"),u=r("accountSafetyWarning.subtitle"),N=r("accountSafetyWarning.firstLine"),w=r("accountSafetyWarning.secondLine"),f="https://github.com/kaitranntt/ccs/issues/509",O=r("accountSafetyWarning.issueLabel"),j=r("accountSafetyWarning.proxySettingsLabel");return e.jsxs("section",{role:"alert",className:B("relative overflow-hidden rounded-xl border border-amber-500/30 bg-gradient-to-br from-amber-50 via-background to-rose-50/70 shadow-sm dark:from-amber-950/20 dark:to-rose-950/20",s),children:[e.jsx("div",{className:"absolute inset-x-0 top-0 h-0.5 bg-gradient-to-r from-amber-500 via-orange-500 to-rose-500"}),e.jsxs("div",{className:"space-y-3 p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx("div",{className:"mt-0.5 inline-flex h-7 w-7 items-center justify-center rounded-md bg-amber-500/15 text-amber-700 dark:text-amber-400",children:e.jsx(Re,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold leading-5",children:o}),e.jsx("p",{className:"text-xs text-muted-foreground",children:u})]})]}),e.jsx(G,{variant:"outline",className:"border-amber-500/40 text-amber-700 dark:text-amber-300",children:"High Risk"})]}),e.jsxs("div",{className:"space-y-2 text-sm leading-relaxed",children:[e.jsx("p",{children:N}),e.jsx("p",{className:"font-medium text-amber-900 dark:text-amber-200",children:w}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"CCS is provided as-is and does not take responsibility for suspension, bans, or access loss from upstream providers."})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("a",{href:f,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1.5 rounded-md border border-amber-500/30 bg-amber-500/10 px-2.5 py-1 text-xs font-medium text-amber-800 transition-colors hover:bg-amber-500/15 dark:text-amber-200",children:[O,e.jsx(me,{className:"h-3.5 w-3.5"})]}),d&&e.jsxs("a",{href:"/settings?tab=proxy",className:"inline-flex items-center gap-1.5 rounded-md border border-amber-500/30 bg-amber-500/10 px-2.5 py-1 text-xs font-medium text-amber-800 transition-colors hover:bg-amber-500/15 dark:text-amber-200",children:[e.jsx(zt,{className:"h-3.5 w-3.5"}),j]}),e.jsx("span",{className:"rounded-md border border-border/70 bg-muted/60 px-2.5 py-1 text-xs text-muted-foreground",children:"Applies to CLI and dashboard auth"})]}),t&&i&&e.jsxs("div",{className:"rounded-lg border border-amber-500/25 bg-amber-500/5 p-2.5",children:[e.jsxs(Z,{htmlFor:"account-risk-ack-text",className:"text-xs leading-5",children:["Type exact phrase to continue:"," ",e.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono",children:a})]}),e.jsx(de,{id:"account-risk-ack-text",value:n,onChange:k=>i(k.target.value),placeholder:a,disabled:l,className:"mt-2 font-mono text-xs"})]})]})]})}function Aa({className:s,value:t,onChange:a,disabled:n=!1}){const{t:i}=ee(),l=[t.reviewedIssue509,t.understandsBanRisk,t.acceptsFullResponsibility,t.typedPhrase.trim().replace(/\s+/g," ").toUpperCase()===hs].filter(Boolean).length,d=l/4*100,r=o=>{a({...t,...o})};return e.jsxs("section",{role:"alert",className:B("relative overflow-hidden rounded-xl border border-rose-500/35 bg-gradient-to-br from-rose-50 via-background to-amber-50/70 p-4 shadow-sm dark:from-rose-950/20 dark:to-amber-950/20",s),children:[e.jsx("div",{className:"absolute inset-x-0 top-0 h-0.5 bg-gradient-to-r from-rose-500 via-orange-500 to-amber-500"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx("div",{className:"mt-0.5 inline-flex h-7 w-7 items-center justify-center rounded-md bg-rose-500/15 text-rose-700 dark:text-rose-300",children:e.jsx(Re,{className:"h-4 w-4"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-semibold leading-5",children:i("antigravityChecklist.title")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:i("antigravityChecklist.subtitle")})]})]}),e.jsx(G,{variant:"outline",className:"border-rose-500/40 text-rose-700 dark:text-rose-300",children:i("antigravityChecklist.mandatory")})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[e.jsx("span",{children:i("antigravityChecklist.completion")}),e.jsx("span",{children:i("antigravityChecklist.stepsCount",{current:l})})]}),e.jsx(Be,{value:d,className:"h-2"})]}),e.jsxs("div",{className:"space-y-3 rounded-lg border border-rose-500/20 bg-rose-500/5 p-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Te,{id:"agy-step-reviewed-issue",checked:t.reviewedIssue509,onCheckedChange:o=>r({reviewedIssue509:!!o}),disabled:n}),e.jsx(Z,{htmlFor:"agy-step-reviewed-issue",className:"text-xs leading-5",children:"Step 1: I reviewed issue #509 and understand AGY OAuth can trigger account bans/suspensions."})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Te,{id:"agy-step-understands-risk",checked:t.understandsBanRisk,onCheckedChange:o=>r({understandsBanRisk:!!o}),disabled:n}),e.jsx(Z,{htmlFor:"agy-step-understands-risk",className:"text-xs leading-5",children:"Step 2: I understand this OAuth action is my own decision and I accept the upstream risk."})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Te,{id:"agy-step-accept-responsibility",checked:t.acceptsFullResponsibility,onCheckedChange:o=>r({acceptsFullResponsibility:!!o}),disabled:n}),e.jsx(Z,{htmlFor:"agy-step-accept-responsibility",className:"text-xs leading-5",children:"Step 3: I accept full responsibility. CCS is not liable for suspension, bans, or access loss."})]})]}),e.jsxs("div",{className:"space-y-2 rounded-lg border border-amber-500/25 bg-amber-500/5 p-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium text-amber-800 dark:text-amber-200",children:[e.jsx(Is,{className:"h-3.5 w-3.5"}),"Step 4: Type exact phrase to continue"]}),e.jsx(de,{value:t.typedPhrase,onChange:o=>r({typedPhrase:o.target.value}),placeholder:hs,disabled:n,className:"font-mono text-xs"})]}),e.jsx("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:e.jsxs("a",{href:"https://github.com/kaitranntt/ccs/issues/509",target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1.5 rounded-md border border-rose-500/30 bg-rose-500/10 px-2.5 py-1 font-medium text-rose-800 transition-colors hover:bg-rose-500/15 dark:text-rose-200",children:["Read issue #509",e.jsx(me,{className:"h-3.5 w-3.5"})]})})]})]})}function Pa(s){return s.trim().replace(/\s+/g," ").toUpperCase()}function Sa({open:s,onClose:t,provider:a,displayName:n,isFirstAccount:i=!1}){const[l,d]=c.useState(""),[r,o]=c.useState(""),[u,N]=c.useState(!1),[w,f]=c.useState(null),[O,j]=c.useState(""),[k,A]=c.useState(qe),[P,g]=c.useState(!1),[p,y]=c.useState(!1),[C,M]=c.useState(os),{t:m}=ee(),S=c.useRef(!1),T=c.useRef(0),U=c.useRef(!1),h=ka(),v=it(),b=a==="kiro",q=a==="agy"||a==="gemini",L=a==="gemini"&&!P,E=a==="agy"&&!P,_=q&&p,K=na(k),V=Pa(O)===De,te=Es(a),X=rt(C),ae=b?X.flowType==="device_code":te,Q=h.isAuthenticating||v.isPending,x=l.trim(),R=w||h.error,$=c.useCallback(async()=>{const D=await fetch("/api/settings/auth/antigravity-risk");if(!D.ok)throw new Error("Failed to load power user mode setting");return(await D.json()).antigravityAckBypass===!0},[]),ne=c.useCallback(async({pendingMessage:D=null,disabledMessage:Y=null}={})=>{const ge=++T.current;y(!0),D!==null&&f(D);try{const le=await $();return T.current!==ge||(g(le),Y?f(le?null:Y):D!==null&&f(null)),le}catch{return T.current!==ge||(g(!1),f(Y??m("addAccountDialog.powerUserLoadFailed")),U.current||(U.current=!0,H.error(m("addAccountDialog.powerUserLoadFailed")))),!1}finally{T.current===ge&&y(!1)}},[$,m]),he=()=>{d(""),o(""),N(!1),f(null),j(""),A(qe),g(!1),y(!1),M(os),T.current+=1,U.current=!1,S.current=!1,t()};c.useEffect(()=>{s&&(j(""),A(qe),f(null))},[a,s]),c.useEffect(()=>()=>{T.current+=1},[]),c.useEffect(()=>{if(!s||!q){T.current+=1,g(!1),y(!1);return}ne()},[s,a,q,ne]),c.useEffect(()=>{if(!s||a!=="agy"||!h.error||!P)return;const D=h.error.toLowerCase();(D.includes("agy_risk_ack_required")||D.includes("responsibility acknowledgement")||D.includes("responsibility checklist"))&&ne({pendingMessage:m("addAccountDialog.powerUserLoading"),disabledMessage:m("addAccountDialog.powerUserUnavailableRetry")})},[h.error,s,P,a,ne,m]),c.useEffect(()=>{!h.isAuthenticating&&!h.error&&h.provider===null&&s&&S.current&&(S.current=!1,(async()=>{try{const Y=await Qe(a);Y.success&&Y.presetName&&i&&H.success(`Applied "${Y.presetName}" preset`)}catch{}he()})())},[h.isAuthenticating,h.error,h.provider]);const ke=()=>{h.cancelAuth(),he()},Ie=async()=>{h.authUrl&&(await navigator.clipboard.writeText(h.authUrl),N(!0),setTimeout(()=>N(!1),2e3))},Le=()=>{r.trim()&&h.submitCallback(r.trim())},Ae=()=>{if(_){f(m("addAccountDialog.powerUserLoading"));return}if(E&&!K){f("Complete all Antigravity responsibility steps before authenticating this provider.");return}if(L&&!V){f(`Type "${De}" to acknowledge the account safety warning before authenticating this provider.`);return}f(null),S.current=!0,h.startAuth(a,{nickname:x||void 0,kiroMethod:b?C:void 0,flowType:b?X.flowType:void 0,startEndpoint:b?X.startEndpoint:void 0,riskAcknowledgement:E?{version:ia,reviewedIssue509:k.reviewedIssue509,understandsBanRisk:k.understandsBanRisk,acceptsFullResponsibility:k.acceptsFullResponsibility,typedPhrase:k.typedPhrase}:void 0})},Pe=()=>{S.current=!0,v.mutate(void 0,{onSuccess:async()=>{const D=await Qe("kiro");D.success&&D.presetName&&i&&H.success(`Applied "${D.presetName}" preset`),he()}})},Fe=D=>{D||ke()},J=h.isAuthenticating;return e.jsx(We,{open:s,onOpenChange:Fe,children:e.jsxs(Xe,{className:"sm:max-w-md",onInteractOutside:D=>{J&&D.preventDefault()},children:[e.jsxs(Ye,{children:[e.jsx(Ze,{children:m("addAccountDialog.title",{displayName:n})}),e.jsx(Ds,{children:m(b?"addAccountDialog.descKiro":ae?"addAccountDialog.descDeviceCode":"addAccountDialog.descOauth")})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[E&&!J&&e.jsx(Aa,{value:k,onChange:D=>{A(D),f(null)},disabled:Q}),q&&P&&!J&&e.jsxs("div",{className:"rounded-lg border border-amber-400/35 bg-amber-50/70 p-3 text-xs text-amber-900 dark:border-amber-800/60 dark:bg-amber-950/25 dark:text-amber-100",children:[e.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5 font-semibold",children:[e.jsx(Is,{className:"h-3.5 w-3.5"}),m("addAccountDialog.powerUserEnabled")]}),m("addAccountDialog.powerUserSkipped")]}),L&&!J&&e.jsx(Qs,{showAcknowledgement:!0,acknowledgementPhrase:De,acknowledgementText:O,onAcknowledgementTextChange:D=>{j(D),f(null)},disabled:Q}),b&&!J&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"kiro-auth-method",children:m("addAccountDialog.authMethod")}),e.jsxs(Cs,{value:C,onValueChange:D=>{M(D),f(null)},children:[e.jsx(ks,{id:"kiro-auth-method",children:e.jsx(As,{placeholder:m("addAccountDialog.selectKiroAuthMethod")})}),e.jsx(Ps,{children:ot.map(D=>e.jsx(Ge,{value:D.id,children:D.label},D.id))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:X.description})]}),!J&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"nickname",children:m("addAccountDialog.nicknameOptional")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pe,{className:"w-4 h-4 text-muted-foreground"}),e.jsx(de,{id:"nickname",value:l,onChange:D=>{d(D.target.value),f(null)},placeholder:m("addAccountDialog.nicknamePlaceholder"),disabled:Q,className:"flex-1"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:m("addAccountDialog.nicknameOptionalHint")})]}),J&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.jsx(W,{className:"w-4 h-4 inline mr-2 animate-spin"}),m("addAccountDialog.waitingForAuth")]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:h.isDeviceCodeFlow?m("addAccountDialog.deviceCodeHint"):m("addAccountDialog.browserHint")})]}),h.authUrl&&!h.isDeviceCodeFlow&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{className:"text-xs",children:m("addAccountDialog.openUrlLabel")}),e.jsxs("div",{className:"p-3 bg-muted rounded-md",children:[e.jsx("p",{className:"text-xs text-muted-foreground break-all font-mono line-clamp-3",children:h.authUrl}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(I,{variant:"outline",size:"sm",onClick:Ie,children:u?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"w-3 h-3 mr-1"}),m("addAccountDialog.copied")]}):e.jsxs(e.Fragment,{children:[e.jsx(Os,{className:"w-3 h-3 mr-1"}),m("addAccountDialog.copy")]})}),e.jsxs(I,{variant:"outline",size:"sm",onClick:()=>{if(!h.authUrl)return;const D=window.open(h.authUrl,"_blank");(!D||D.closed||typeof D.closed>"u")&&H.warning(m("addAccountDialog.popupBlocked"),{duration:5e3})},children:[e.jsx(me,{className:"w-3 h-3 mr-1"}),m("addAccountDialog.open")]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"callback-url",className:"text-xs",children:m("addAccountDialog.redirectPasteLabel")}),e.jsx(de,{id:"callback-url",value:r,onChange:D=>o(D.target.value),placeholder:m("addAccountDialog.callbackPlaceholder"),className:"font-mono text-xs"}),e.jsx(I,{variant:"secondary",size:"sm",onClick:Le,disabled:!r.trim()||h.isSubmittingCallback,children:h.isSubmittingCallback?e.jsxs(e.Fragment,{children:[e.jsx(W,{className:"w-3 h-3 mr-1 animate-spin"}),m("addAccountDialog.submitting")]}):m("addAccountDialog.submitCallback")})]})]}),!h.authUrl&&!h.isDeviceCodeFlow&&e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:m("addAccountDialog.preparingUrl")})]}),R&&e.jsx("p",{className:"text-xs text-center text-destructive",children:R}),v.isPending&&e.jsxs("p",{className:"text-sm text-center text-muted-foreground",children:[e.jsx(W,{className:"w-4 h-4 inline mr-2 animate-spin"}),m("addAccountDialog.importingToken")]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[e.jsx(I,{variant:"ghost",onClick:ke,children:m("addAccountDialog.cancel")}),b&&!J&&e.jsx(I,{variant:"outline",onClick:Pe,disabled:Q,children:v.isPending?e.jsxs(e.Fragment,{children:[e.jsx(W,{className:"w-4 h-4 mr-2 animate-spin"}),m("addAccountDialog.importing")]}):e.jsxs(e.Fragment,{children:[e.jsx(Qt,{className:"w-4 h-4 mr-2"}),m("addAccountDialog.importFromIde")]})}),!J&&e.jsxs(I,{onClick:Ae,disabled:Q||_||E&&!K||L&&!V,children:[e.jsx(me,{className:"w-4 h-4 mr-2"}),m("addAccountDialog.authenticate")]})]})]})]})})}const Ma=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"];function Da(s){const t=s?.env||{};return Ma.filter(a=>!t[a]?.trim())}function Ta(s){const[t,a]=c.useState(null),[n,i]=c.useState(!1),l=Je(),{data:d,isLoading:r,refetch:o}=ws({queryKey:["settings",s],queryFn:async()=>{const h=await fetch(`/api/settings/${s}/raw`);return h.ok?h.json():{profile:s,settings:{env:{}},mtime:Date.now(),path:`~/.ccs/profiles/${s}/settings.json`}}}),u=d?.settings,N=c.useMemo(()=>t!==null?t:u?JSON.stringify(u,null,2):`{
|
|
2
|
-
"env": {}
|
|
3
|
-
}`,[t,u]),w=c.useCallback(h=>{a(h)},[]),f=c.useMemo(()=>{try{return JSON.parse(N)}catch{return u||{env:{}}}},[N,u]),O=f?.env?.ANTHROPIC_MODEL,j=f?.env?.ANTHROPIC_DEFAULT_OPUS_MODEL,k=f?.env?.ANTHROPIC_DEFAULT_SONNET_MODEL,A=f?.env?.ANTHROPIC_DEFAULT_HAIKU_MODEL,P=c.useMemo(()=>lt(f?.env||{}),[f]),g=c.useCallback((h,v)=>ct(h,v,{supportsExtendedContext:b=>pa(s,b)}),[s]),p=c.useCallback((h,v)=>{const b={...f?.env||{},[h]:v},q=ls(h)?g(b,P):b;delete q.CCS_EXTENDED_CONTEXT;const L={...f,env:q};a(JSON.stringify(L,null,2))},[g,f,P]),y=c.useCallback(h=>{const v=f?.env||{},b=g(v,h);delete b.CCS_EXTENDED_CONTEXT;const q={...f,env:b};a(JSON.stringify(q,null,2))},[g,f]),C=c.useCallback(h=>{const v={...f?.env||{},...h},q=Object.keys(h).some(ls)?g(v,P):v;delete q.CCS_EXTENDED_CONTEXT;const L={...f,env:q};a(JSON.stringify(L,null,2))},[g,f,P]),M=c.useMemo(()=>{try{return JSON.parse(N),!0}catch{return!1}},[N]),m=c.useMemo(()=>t===null?!1:t!==JSON.stringify(u,null,2),[t,u]),S=c.useMemo(()=>Da(f),[f]),T=Ys({mutationFn:async()=>{const h=JSON.parse(N),v=await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:h,expectedMtime:d?.mtime})});if(v.status===409)throw new Error("CONFLICT");if(!v.ok)throw new Error("Failed to save");return v.json()},onSuccess:h=>{l.invalidateQueries({queryKey:["settings",s]}),a(null),h?.warning?H.success("Settings saved",{description:h.warning}):H.success("Settings saved")},onError:h=>{h.message==="CONFLICT"?i(!0):H.error(h.message)}}),U=async h=>{i(!1),h?(await o(),T.mutate()):a(null)};return{data:d,isLoading:r,refetch:o,rawJsonContent:N,rawJsonEdits:t,isRawJsonValid:M,hasChanges:m,currentSettings:f,currentModel:O,opusModel:j,sonnetModel:k,haikuModel:A,extendedContextEnabled:P,toggleExtendedContext:y,handleRawJsonChange:w,updateEnvValue:p,updateEnvValues:C,saveMutation:{mutate:()=>T.mutate(),isPending:T.isPending},conflictDialog:n,setConflictDialog:i,handleConflictResolve:U,missingRequiredFields:S}}const Ea=/-(medium|high|xhigh)$/i;function Ra(s){if(!s)return;const t=s.trim().match(Ea);if(t?.[1])return t[1].toLowerCase()}function _a(s){if(!s)return null;const t=Ra(s);return t?{label:`Pinned ${t}`,explicit:!0}:{label:"Auto effort",explicit:!1}}function Oa({label:s}){return e.jsx(G,{variant:"outline",className:"text-[9px] h-4 px-1",children:s})}function Se({modelId:s}){const t=_a(s);return t?e.jsx(G,{variant:t.explicit?"secondary":"outline",className:"text-[9px] h-4 px-1 uppercase",children:t.label}):null}function oe({label:s,description:t,value:a,onChange:n,catalog:i,allModels:l,disabled:d}){const{t:r}=ee(),o=i?.provider==="codex",u=c.useMemo(()=>zs(i,l),[l,i]),N=new Set(u.map(j=>j.id)),w=u.map(j=>({value:j.id,groupKey:"recommended",searchText:`${j.id} ${j.name}`,keywords:[j.tier??"",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:j.id}),o&&e.jsx(Se,{modelId:j.id})]}),itemContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:j.id}),j.tier==="paid"&&e.jsx(Oa,{label:r("providerModelSelector.paid")}),o&&e.jsx(Se,{modelId:j.id})]})})),f=l.filter(j=>!N.has(j.id)).map(j=>({value:j.id,groupKey:"all",searchText:j.id,keywords:[j.owned_by],triggerContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:j.id}),o&&e.jsx(Se,{modelId:j.id})]}),itemContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:j.id}),o&&e.jsx(Se,{modelId:j.id})]})})),O=w.length+f.length>0;return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",children:s}),t&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:t})]}),e.jsx(oa,{value:a||void 0,onChange:n,disabled:d,placeholder:r("providerModelSelector.selectModel"),searchPlaceholder:r("searchableSelect.searchModels"),emptyText:r(O?"searchableSelect.noResults":"providerModelSelector.noModelsAvailable"),triggerClassName:"h-9",groups:[{key:"recommended",label:e.jsx("span",{className:"text-xs text-primary",children:r("providerModelSelector.recommended")})},{key:"all",label:e.jsx("span",{className:"text-xs text-muted-foreground",children:r("providerModelSelector.allModelsCount",{count:l.length})})}],options:[...w,...f]})]})}function Ia({open:s,onClose:t,currentValues:a,onApply:n,onSave:i,isSaving:l,catalog:d,allModels:r}){const{t:o}=ee(),[u,N]=c.useState(a),[w,f]=c.useState(""),O=j=>{j?(N(a),f("")):t()};return e.jsx(We,{open:s,onOpenChange:O,children:e.jsxs(Xe,{className:"sm:max-w-md",children:[e.jsx(Ye,{children:e.jsxs(Ze,{className:"flex items-center gap-2",children:[e.jsx(ye,{className:"w-4 h-4"}),o("customPresetDialog.title")]})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"preset-name",children:o("customPresetDialog.presetNameOptional")}),e.jsx(de,{id:"preset-name",value:w,onChange:j=>f(j.target.value),placeholder:o("customPresetDialog.presetNamePlaceholder"),className:"text-sm"})]}),e.jsx(is,{}),d?.provider==="codex"&&e.jsxs("p",{className:"text-[11px] text-muted-foreground rounded-md border bg-muted/30 px-2.5 py-2",children:[o("customPresetDialog.codexTipPrefix")," ",e.jsx("code",{children:"-medium"}),", ",e.jsx("code",{children:"-high"}),", and"," ",e.jsx("code",{children:"-xhigh"})," ",o("customPresetDialog.codexTipSuffix")]}),e.jsx(oe,{label:o("customPresetDialog.defaultModel"),description:o("customPresetDialog.defaultModelDesc"),value:u.default,onChange:j=>N({...u,default:j}),catalog:d,allModels:r}),e.jsx(oe,{label:o("customPresetDialog.opusModel"),description:o("customPresetDialog.opusModelDesc"),value:u.opus,onChange:j=>N({...u,opus:j}),catalog:d,allModels:r}),e.jsx(oe,{label:o("customPresetDialog.sonnetModel"),description:o("customPresetDialog.sonnetModelDesc"),value:u.sonnet,onChange:j=>N({...u,sonnet:j}),catalog:d,allModels:r}),e.jsx(oe,{label:o("customPresetDialog.haikuModel"),description:o("customPresetDialog.haikuModelDesc"),value:u.haiku,onChange:j=>N({...u,haiku:j}),catalog:d,allModels:r})]}),e.jsxs(dt,{className:"gap-2 sm:gap-0",children:[e.jsx(I,{variant:"outline",onClick:t,children:o("customPresetDialog.cancel")}),i&&e.jsxs(I,{variant:"secondary",onClick:()=>i(u,w||void 0),disabled:l||!w.trim(),children:[l?e.jsx(W,{className:"w-4 h-4 mr-1 animate-spin"}):e.jsx(_e,{className:"w-4 h-4 mr-1"}),o("customPresetDialog.savePreset")]}),e.jsxs(I,{onClick:()=>n(u,w||void 0),children:[e.jsx(Ce,{className:"w-4 h-4 mr-1"}),o("customPresetDialog.applyPreset")]})]})]})})}function re({label:s,command:t}){return e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:s}),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:t}),e.jsx(Rs,{value:t,size:"icon",className:"h-6 w-6"})]})]})}function La({provider:s,displayName:t,defaultTarget:a,data:n,authStatus:i,supportsModelConfig:l=!1}){const d=a||"claude",r=d==="droid",o=s==="codex",u=d==="claude"?`ccs ${s}`:`ccs ${s} --target claude`,N=`${u} --config`,w=`${u} --auth --add`,f=`${u} --accounts`;return e.jsx(es,{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(Ls,{className:"w-4 h-4"}),"Provider Information"]}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Provider"}),e.jsx("span",{className:"font-mono",children:t})]}),n&&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:"File Path"}),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:n.path}),e.jsx(Rs,{value:n.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:"Last Modified"}),e.jsx("span",{className:"text-xs",children:new Date(n.mtime).toLocaleString()})]})]}),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:"Status"}),i.authenticated?e.jsxs(G,{variant:"outline",className:"w-fit text-green-600 border-green-200 bg-green-50",children:[e.jsx(Jt,{className:"w-3 h-3 mr-1"}),"Authenticated"]}):e.jsx(G,{variant:"outline",className:"w-fit text-muted-foreground",children:"Not connected"})]}),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:"Default Target"}),e.jsx("span",{className:"font-mono",children:d})]})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:"Quick Usage"}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsx(re,{label:"Run with prompt",command:`ccs ${s} "your prompt"`}),o&&e.jsxs(e.Fragment,{children:[e.jsx(re,{label:"Run on native Codex (shortcut)",command:'ccsxp "your prompt"'}),e.jsx(re,{label:"Run on native Codex (--target)",command:`ccs ${s} --target codex "your prompt"`})]}),e.jsx(re,{label:r?"Droid alias (explicit)":"Run on Droid",command:`ccs-droid ${s} "your prompt"`}),e.jsx(re,{label:r?"Override to Claude":"Run on Droid (--target)",command:`ccs ${s} --target ${r?"claude":"droid"} "your prompt"`}),l&&e.jsx(re,{label:d==="claude"?"Change model":"Change model (Claude target)",command:N}),e.jsx(re,{label:d==="claude"?"Add account":"Add account (Claude target)",command:w}),e.jsx(re,{label:d==="claude"?"List accounts":"List accounts (Claude target)",command:f}),d!=="claude"&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Account and model-management flags stay on Claude target. Codex and Droid runtime launches reject those CLIProxy management commands."})]})]})]})})}function Fa({displayName:s,logoProvider:t,provider:a,data:n,isLoading:i,hasChanges:l,isRawJsonValid:d,isSaving:r,isRemoteMode:o,port:u,onRefetch:N,onSave:w}){return e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ss,{provider:t||a,size:"lg"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:s}),o&&e.jsxs(G,{variant:"secondary",className:"text-xs gap-1 bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400",children:[e.jsx(Fs,{className:"w-3 h-3"}),"Remote"]}),u&&e.jsxs(G,{variant:"outline",className:"text-xs gap-1 font-mono",children:[e.jsx(Wt,{className:"w-3 h-3"}),":",u]}),!o&&n?.path&&e.jsx(G,{variant:"outline",className:"text-xs",children:n.path.replace(/^.*[\\/]/,"")})]}),o?e.jsx("p",{className:"text-xs text-blue-600 dark:text-blue-400 mt-0.5",children:"Traffic auto-routed to remote server"}):n&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified: ",new Date(n.mtime).toLocaleString()]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(I,{variant:"ghost",size:"sm",onClick:N,disabled:i,children:e.jsx(as,{className:`w-4 h-4 ${i?"animate-spin":""}`})}),e.jsx(I,{size:"sm",onClick:w,disabled:r||!l||!d,children:r?e.jsxs(e.Fragment,{children:[e.jsx(W,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Xt,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}function Ua({models:s,provider:t,enabled:a,onToggle:n,disabled:i,className:l}){if(s.length===0)return null;const d=s.some(u=>cs(u.id)),r=s.some(u=>!cs(u.id));let o="Compatible mappings stay on standard context unless you turn this on.";return d&&r?o="Gemini-compatible mappings can use 1M automatically. Claude mappings stay plain unless you turn this on.":d&&(o="Gemini-compatible mappings can use 1M by default. Turn this off to keep standard context."),e.jsxs("div",{className:B("rounded-lg border p-3 space-y-2",a?"border-primary/50 bg-primary/5":"border-border bg-muted/30",l),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:B("w-4 h-4",a?"text-primary":"text-muted-foreground")}),e.jsx("span",{className:"text-sm font-medium",children:"Extended Context"}),e.jsx(G,{variant:a?"default":"secondary",className:"text-[10px] h-5 px-1.5",children:"1M tokens"})]}),e.jsx(Gs,{checked:a,onCheckedChange:n,disabled:i})]}),e.jsxs("div",{className:"flex items-start gap-2 text-xs text-muted-foreground",children:[e.jsx(Ls,{className:"w-3.5 h-3.5 mt-0.5 shrink-0"}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{children:["Applies the explicit ",e.jsx("code",{children:"[1m]"})," long-context suffix to compatible saved mappings."]}),e.jsx("p",{className:"text-[10px]",children:o}),e.jsxs("p",{className:"text-amber-600 dark:text-amber-500",children:["CCS only saves ",e.jsx("code",{children:"[1m]"}),". Provider pricing and entitlement are separate, and some accounts can still return 429 extra-usage errors for long-context requests."]})]})]})]})}function qa(s){const t=s.presetMapping||{default:s.id,opus:s.id,sonnet:s.id,haiku:s.id};return{ANTHROPIC_MODEL:t.default,ANTHROPIC_DEFAULT_OPUS_MODEL:t.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:t.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:t.haiku}}function Ha({catalog:s,savedPresets:t,currentModel:a,opusModel:n,sonnetModel:i,haikuModel:l,providerModels:d,provider:r,extendedContextEnabled:o,onExtendedContextToggle:u,onApplyPreset:N,onUpdateEnvValue:w,onOpenCustomPreset:f,onDeletePreset:O,isDeletePending:j}){const k=c.useMemo(()=>{if(!s)return[];const p=[a,n,i,l].filter(C=>!!C).map(C=>ut(C));return[...new Set(p)].map(C=>$s(s.provider,C)).filter(C=>!!C?.extendedContext)},[s,a,n,i,l]),A=c.useMemo(()=>zs(s,d),[s,d]),P=c.useMemo(()=>{const p=A.filter(C=>C.presetMapping);return p.length===0?[]:p.some(C=>C.tier==="paid")?[{key:"free",label:"Free Tier",description:"Available on free or paid plans",badgeClassName:"text-[10px] bg-green-100 text-green-700 border-green-200",iconClassName:"text-green-600",models:p.filter(C=>C.tier!=="paid")},{key:"paid",label:"Paid Tier",description:"Requires paid access",badgeClassName:"text-[10px] bg-amber-100 text-amber-700 border-amber-200",iconClassName:"text-amber-700",models:p.filter(C=>C.tier==="paid")}].filter(C=>C.models.length>0):[{key:"default",models:p.slice(0,4)}]},[A]),g=P.length>0||t.length>0;return e.jsxs(e.Fragment,{children:[g&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(ye,{className:"w-4 h-4"}),"Presets"]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"Apply pre-configured model mappings"}),e.jsxs("div",{className:"space-y-4",children:[P.map(p=>e.jsxs("div",{children:["label"in p&&p.label&&e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(G,{variant:"outline",className:p.badgeClassName,children:p.label}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:p.description})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:p.models.map(y=>e.jsxs(I,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>N(qa(y)),children:[e.jsx(Ce,{className:`w-3 h-3 ${"iconClassName"in p?p.iconClassName:""}`}),y.name]},y.id))})]},p.key)),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.map(p=>e.jsxs("div",{className:"group relative",children:[e.jsxs(I,{variant:"secondary",size:"sm",className:"text-xs h-7 gap-1 pr-6",onClick:()=>{N({ANTHROPIC_MODEL:p.default,ANTHROPIC_DEFAULT_OPUS_MODEL:p.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:p.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:p.haiku})},children:[e.jsx(_e,{className:"w-3 h-3 fill-current"}),p.name]}),e.jsx(I,{variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-7 w-5 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:y=>{y.stopPropagation(),O(p.name)},disabled:j,children:e.jsx(ns,{className:"w-3 h-3"})})]},p.name)),e.jsxs(I,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1 border-primary/50 text-primary hover:bg-primary/10 hover:border-primary",onClick:f,children:[e.jsx(Us,{className:"w-3 h-3"}),"Custom"]})]})]})]}),e.jsx(is,{}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-2",children:"Model Mapping"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"Configure which models to use for each tier"}),r==="codex"&&e.jsxs("p",{className:"text-[11px] text-muted-foreground mb-3 rounded-md border bg-muted/30 px-2.5 py-2",children:["Codex tip: suffixes ",e.jsx("code",{children:"-medium"}),", ",e.jsx("code",{children:"-high"}),", and ",e.jsx("code",{children:"-xhigh"})," ","pin reasoning effort. Unsuffixed models use Thinking settings."]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(oe,{label:"Default Model",description:"Used when no specific tier is requested",value:a,onChange:p=>w("ANTHROPIC_MODEL",p),catalog:s,allModels:d}),k.length>0&&u&&e.jsx(Ua,{models:k,provider:r,enabled:o??!1,onToggle:u}),e.jsx(oe,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:n,onChange:p=>w("ANTHROPIC_DEFAULT_OPUS_MODEL",p),catalog:s,allModels:d}),e.jsx(oe,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:i,onChange:p=>w("ANTHROPIC_DEFAULT_SONNET_MODEL",p),catalog:s,allModels:d}),e.jsx(oe,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:l,onChange:p=>w("ANTHROPIC_DEFAULT_HAIKU_MODEL",p),catalog:s,allModels:d})]})]})]})}function vs(s){const t=Math.max(0,Math.min(100,s));return t<=20?"bg-destructive":t<=50?"bg-yellow-500":"bg-green-500"}function js(s){if(!s)return"";try{const t=new Date(s),n=new Date().getTime()-t.getTime();if(n<0)return"just now";const i=Math.floor(n/(1e3*60)),l=Math.floor(n/(1e3*60*60)),d=Math.floor(n/(1e3*60*60*24));return d>0?`${d}d ago`:l>0?`${l}h ago`:i>0?`${i}m ago`:"just now"}catch{return""}}function Ka(s){if(!s)return!1;try{const t=new Date(s);return new Date().getTime()-t.getTime()<3600*1e3}catch{return!1}}function Ga({account:s,onSetDefault:t,onRemove:a,onPauseToggle:n,isRemoving:i,isPausingAccount:l,privacyMode:d,showQuota:r,selectable:o,selected:u,onSelectChange:N}){const{t:w}=ee(),f=s.provider.toLowerCase(),O=f==="codex",j=f==="claude"||f==="anthropic",{data:k}=mt(r),{data:A,isLoading:P}=pt(f,s.id,r),g=xt(k,s)?.lastUsedAt,p=Ka(g),y=ht(s.provider,A),C=gt(s.provider,A),M=O&&A&&ft(A)?vt(A.windows):null,m=[{label:"5h",value:M?.fiveHourWindow?.remainingPercent??null},{label:"Weekly",value:M?.weeklyWindow?.remainingPercent??null}].filter(L=>L.value!==null),S=j&&A&&jt(A)?[{label:"5h",value:A.coreUsage?.fiveHour?.remainingPercent??A.windows.find(L=>L.rateLimitType==="five_hour")?.remainingPercent??null},{label:"Weekly",value:A.coreUsage?.weekly?.remainingPercent??A.windows.find(L=>["seven_day","seven_day_opus","seven_day_sonnet","seven_day_oauth_apps","seven_day_cowork"].includes(L.rateLimitType))?.remainingPercent??null}].filter(L=>L.value!==null):[],T=O?m:j?S:[],U=y!==null?Ct(y):null,h=U!==null?Number(U):null,v=Nt(A),b=v?.label==="Reauth"?Yt:v?.tone==="warning"?Re:Zt,q=v?.tone==="warning"?"border-amber-500/50 text-amber-600 dark:text-amber-400":v?.tone==="destructive"?"border-destructive/50 text-destructive":"border-muted-foreground/50 text-muted-foreground";return e.jsxs("div",{className:B("flex flex-col gap-2 p-3 rounded-lg border transition-colors overflow-hidden",s.isDefault?"border-primary/30 bg-primary/5":"border-border hover:bg-muted/30",s.paused&&"opacity-75",u&&"ring-2 ring-primary/50 bg-primary/5"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[o&&e.jsx("button",{type:"button",onClick:()=>N?.(!u),className:B("flex items-center justify-center w-5 h-5 rounded border-2 transition-colors shrink-0",u?"bg-primary border-primary text-primary-foreground":"border-muted-foreground/30 hover:border-primary/50"),"aria-label":u?"Deselect account":"Select account",children:u&&e.jsx(ue,{className:"w-3 h-3"})}),n&&e.jsx(fe,{children:e.jsxs(ve,{children:[e.jsx(je,{asChild:!0,children:e.jsx(I,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:()=>n(!s.paused),disabled:l,children:l?e.jsx(W,{className:"w-4 h-4 animate-spin"}):s.paused?e.jsx(qs,{className:"w-4 h-4 text-emerald-500"}):e.jsx(ze,{className:"w-4 h-4 text-muted-foreground hover:text-foreground"})})}),e.jsx(Ne,{side:"top",children:s.paused?"Resume account":"Pause account"})]})}),e.jsxs("div",{className:"relative shrink-0",children:[e.jsx("div",{className:B("flex items-center justify-center w-8 h-8 rounded-full",s.isDefault?"bg-primary/10":"bg-muted"),children:e.jsx(pe,{className:"w-4 h-4"})}),s.tier&&s.tier!=="unknown"&&s.tier!=="free"&&e.jsx("span",{className:B("absolute -bottom-0.5 -right-0.5 text-[7px] font-bold uppercase px-1 py-px rounded","ring-1 ring-background",s.tier==="ultra"?"bg-violet-500/20 text-violet-600 dark:bg-violet-500/30 dark:text-violet-300":"bg-yellow-500/20 text-yellow-700 dark:bg-yellow-500/25 dark:text-yellow-400"),children:s.tier==="ultra"?"U":"P"})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:B("font-medium text-sm truncate",d&&Ee),children:s.email||s.id}),s.isDefault&&e.jsxs(G,{variant:"secondary",className:"text-[10px] h-4 px-1.5 gap-0.5",children:[e.jsx(_e,{className:"w-2.5 h-2.5 fill-current"}),"Default"]}),s.paused&&e.jsxs(G,{variant:"outline",className:"text-[10px] h-4 px-1.5 border-yellow-500 text-yellow-600",children:[e.jsx(ze,{className:"w-2 h-2 mr-0.5"}),"Paused"]})]}),s.provider==="agy"&&e.jsx("div",{className:"flex items-center gap-1.5 mt-1",children:s.projectId?e.jsx(fe,{children:e.jsxs(ve,{children:[e.jsx(je,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(ea,{className:"w-3 h-3","aria-hidden":"true"}),e.jsx("span",{className:B("font-mono max-w-[180px] truncate",d&&Ee),title:s.projectId,children:s.projectId})]})}),e.jsx(Ne,{side:"bottom",children:e.jsx("p",{className:"text-xs",children:"GCP Project ID (read-only)"})})]})}):e.jsx(fe,{children:e.jsxs(ve,{children:[e.jsx(je,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-amber-600 dark:text-amber-500",children:[e.jsx(Re,{className:"w-3 h-3","aria-label":"Warning"}),e.jsx("span",{children:"Project ID: N/A"})]})}),e.jsx(Ne,{side:"bottom",className:"max-w-[250px]",children:e.jsxs("div",{className:"text-xs space-y-1",children:[e.jsx("p",{className:"font-medium text-amber-600",children:"Missing Project ID"}),e.jsx("p",{children:"This may cause errors. Remove the account and re-add it to fetch the project ID."})]})})]})})}),s.lastUsedAt&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground mt-0.5",children:[e.jsx(ps,{className:"w-3 h-3"}),"Last used: ",new Date(s.lastUsedAt).toLocaleDateString()]})]})]}),e.jsxs(wt,{children:[e.jsx(bt,{asChild:!0,children:e.jsx(I,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",children:e.jsx(sa,{className:"w-4 h-4"})})}),e.jsxs(yt,{align:"end",children:[!s.isDefault&&e.jsxs(ds,{onClick:t,children:[e.jsx(_e,{className:"w-4 h-4 mr-2"}),"Set as default"]}),e.jsxs(ds,{className:"text-destructive focus:text-destructive",onClick:a,disabled:i,children:[e.jsx(Hs,{className:"w-4 h-4 mr-2"}),i?"Removing...":"Remove account"]})]})]})]}),r&&e.jsx("div",{className:"pl-11",children:P?e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(W,{className:"w-3 h-3 animate-spin"}),e.jsx("span",{children:"Loading quota..."})]}):h!==null?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"flex items-center gap-1.5 text-xs",children:p?e.jsxs(e.Fragment,{children:[e.jsx(ta,{className:"w-3 h-3 text-emerald-500"}),e.jsxs("span",{className:"text-emerald-600 dark:text-emerald-400",children:["Active · ",js(g)]})]}):g?e.jsxs(e.Fragment,{children:[e.jsx(ps,{className:"w-3 h-3 text-muted-foreground"}),e.jsxs("span",{className:"text-muted-foreground",children:["Last used ",js(g)]})]}):e.jsxs(e.Fragment,{children:[e.jsx(xs,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:"Not used yet"})]})}),e.jsx(fe,{children:e.jsxs(ve,{children:[e.jsx(je,{asChild:!0,children:T.length>0?e.jsx("div",{className:"space-y-1.5",children:T.map(L=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-10 text-[10px] text-muted-foreground",children:L.label}),e.jsx(Be,{value:Math.max(0,Math.min(100,L.value)),className:"h-2 flex-1",indicatorClassName:vs(L.value)}),e.jsxs("span",{className:"text-xs font-medium w-10 text-right",children:[L.value,"%"]})]},L.label))}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Be,{value:Math.max(0,Math.min(100,h)),className:"h-2 flex-1",indicatorClassName:vs(h)}),e.jsxs("span",{className:"text-xs font-medium w-10 text-right",children:[U,"%"]})]})}),e.jsx(Ne,{side:"bottom",className:"max-w-xs",children:e.jsx(kt,{quota:A,resetTime:C})})]})})]}):A?.success?e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs(G,{variant:"outline",className:"text-[10px] h-5 px-2 gap-1 border-muted-foreground/50 text-muted-foreground",children:[e.jsx(xs,{className:"w-3 h-3"}),w("accountCard.quotaUnavailable")]})}):v?e.jsx(fe,{children:e.jsxs(ve,{children:[e.jsx(je,{asChild:!0,children:e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs(G,{variant:"outline",className:B("text-[10px] h-5 px-2 gap-1",q),children:[e.jsx(b,{className:"w-3 h-3"}),v.label]})})}),e.jsx(Ne,{side:"bottom",className:"max-w-[260px]",children:e.jsxs("div",{className:"space-y-1 text-xs",children:[e.jsx("p",{children:v.summary}),v.actionHint&&e.jsx("p",{className:"text-muted-foreground",children:v.actionHint}),v.technicalDetail&&e.jsx("p",{className:"font-mono text-[11px] text-muted-foreground",children:v.technicalDetail}),v.rawDetail&&e.jsx("pre",{className:"whitespace-pre-wrap break-all rounded bg-muted/40 px-2 py-1 font-mono text-[10px] text-muted-foreground",children:v.rawDetail})]})})]})}):null})]})}function Va({selectedCount:s,onPauseSelected:t,onResumeSelected:a,onClearSelection:n,isPausing:i,isResuming:l}){if(s<1)return null;const d=i||l;return e.jsxs("div",{className:"flex items-center gap-3 p-2 bg-muted/50 rounded-lg border mt-2",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[s," selected"]}),e.jsx(I,{variant:"ghost",size:"sm",className:"text-xs h-6 px-2",onClick:n,disabled:d,children:"Clear"}),e.jsxs("div",{className:"flex gap-2 ml-auto",children:[e.jsxs(I,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:t,disabled:d,children:[i?e.jsx(W,{className:"w-3 h-3 animate-spin"}):e.jsx(ze,{className:"w-3 h-3"}),"Pause Selected"]}),e.jsxs(I,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:a,disabled:d,children:[l?e.jsx(W,{className:"w-3 h-3 animate-spin"}):e.jsx(qs,{className:"w-3 h-3"}),"Resume Selected"]})]})]})}function Ba({accounts:s,onAddAccount:t,onSetDefault:a,onRemoveAccount:n,onPauseToggle:i,onSoloMode:l,onBulkPause:d,onBulkResume:r,isRemovingAccount:o,isPausingAccount:u,isSoloingAccount:N,isBulkPausing:w,isBulkResuming:f,privacyMode:O,showQuota:j,isKiro:k,kiroNoIncognito:A,onKiroNoIncognitoChange:P,kiroSettingsLoading:g}){const[p,y]=c.useState(new Set),C=c.useMemo(()=>new Set(s.map(_=>_.id)),[s]),M=c.useMemo(()=>new Set([...p].filter(_=>C.has(_))),[p,C]),m=!!(d&&r),S=M.size,T=s.length>0&&M.size===s.length,U=M.size>0&&M.size<s.length,h=c.useCallback(_=>{y(K=>{const V=new Set(K);return V.has(_)?V.delete(_):V.add(_),V})},[]),v=c.useCallback(()=>{y(new Set(s.map(_=>_.id)))},[s]),b=c.useCallback(()=>{y(new Set)},[]),q=c.useCallback(()=>{T?b():v()},[T,v,b]),L=c.useCallback(()=>{d&&M.size>0&&(d(Array.from(M)),y(new Set))},[d,M]),E=c.useCallback(()=>{r&&M.size>0&&(r(Array.from(M)),y(new Set))},[r,M]);return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("h3",{className:"text-sm font-medium flex items-center gap-2",children:[m&&s.length>0&&e.jsx(Te,{checked:T,onCheckedChange:q,"aria-label":"Select all accounts",className:U?"data-[state=checked]:bg-primary/50":"",...U?{"data-state":"indeterminate"}:{}}),e.jsx(pe,{className:"w-4 h-4"}),"Accounts",s.length>0&&e.jsx(G,{variant:"secondary",className:"text-xs",children:s.length})]}),e.jsxs(I,{variant:"default",size:"sm",className:"h-7 text-xs gap-1",onClick:t,children:[e.jsx(Us,{className:"w-3 h-3"}),"Add"]})]}),m&&S>0&&e.jsx(Va,{selectedCount:S,onPauseSelected:L,onResumeSelected:E,onClearSelection:b,isPausing:!!w,isResuming:!!f}),s.length>0?e.jsx("div",{className:"space-y-2",children:s.map(_=>e.jsx(Ga,{account:_,onSetDefault:()=>a(_.id),onRemove:()=>n(_.id),onPauseToggle:i?K=>i(_.id,K):void 0,onSoloMode:l?()=>l(_.id):void 0,isRemoving:o,isPausingAccount:u,isSoloingAccount:N,privacyMode:O,showQuota:j,selectable:m,selected:M.has(_.id),onSelectChange:()=>h(_.id)},_.id))}):e.jsxs("div",{className:"py-6 text-center text-muted-foreground bg-muted/30 rounded-lg border border-dashed",children:[e.jsx(pe,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No accounts connected"}),e.jsx("p",{className:"text-xs opacity-70",children:"Add an account to get started"})]}),k&&P&&e.jsx("div",{className:"mt-3 pt-3 border-t border-dashed",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Fs,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Use incognito"})]}),e.jsx(Gs,{checked:!A,onCheckedChange:_=>P(!_),disabled:g,className:"scale-90"})]})})]})}function $a({provider:s,catalog:t,savedPresets:a,currentModel:n,opusModel:i,sonnetModel:l,haikuModel:d,providerModels:r,extendedContextEnabled:o,onExtendedContextToggle:u,onApplyPreset:N,onUpdateEnvValue:w,onOpenCustomPreset:f,onDeletePreset:O,isDeletePending:j,accounts:k,onAddAccount:A,onSetDefault:P,onRemoveAccount:g,onPauseToggle:p,onSoloMode:y,onBulkPause:C,onBulkResume:M,isRemovingAccount:m,isPausingAccount:S,isSoloingAccount:T,isBulkPausing:U,isBulkResuming:h,privacyMode:v,isRemoteMode:b}){const q=s.toLowerCase(),L=(At.includes(q)||["anthropic","antigravity","gemini-cli","copilot","github-copilot"].includes(q))&&!b,E=s==="kiro",[_,K]=c.useState(!0),[V,te]=c.useState(!0),[X,ae]=c.useState(!1),Q=c.useCallback(async()=>{if(E)try{te(!0);const $=(await Me.config.get()).cliproxy;K($?.kiro_no_incognito??!0)}catch{K(!0)}finally{te(!1)}},[E]),x=c.useCallback(async R=>{K(R),ae(!0);try{const $=await Me.config.get(),ne=$.cliproxy??{};await Me.config.update({...$,cliproxy:{...ne,kiro_no_incognito:R}})}catch{K(!R)}finally{ae(!1)}},[]);return c.useEffect(()=>{Q()},[Q]),e.jsx(es,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsx(Ha,{catalog:t,savedPresets:a,currentModel:n,opusModel:i,sonnetModel:l,haikuModel:d,providerModels:r,provider:s,extendedContextEnabled:o,onExtendedContextToggle:u,onApplyPreset:N,onUpdateEnvValue:w,onOpenCustomPreset:f,onDeletePreset:O,isDeletePending:j}),e.jsx(is,{}),e.jsx(Ba,{accounts:k,onAddAccount:A,onSetDefault:P,onRemoveAccount:g,onPauseToggle:p,onSoloMode:y,onBulkPause:C,onBulkResume:M,isRemovingAccount:m,isPausingAccount:S,isSoloingAccount:T,isBulkPausing:U,isBulkResuming:h,privacyMode:v,showQuota:L,isKiro:E,kiroNoIncognito:_,onKiroNoIncognitoChange:x,kiroSettingsLoading:V||X})]})})}function Ns({provider:s,displayName:t,authStatus:a,catalog:n,logoProvider:i,baseProvider:l,isRemoteMode:d,port:r,defaultTarget:o,onAddAccount:u,onSetDefault:N,onRemoveAccount:w,onPauseToggle:f,onSoloMode:O,onBulkPause:j,onBulkResume:k,isRemovingAccount:A,isPausingAccount:P,isSoloingAccount:g,isBulkPausing:p,isBulkResuming:y}){const[C,M]=c.useState(!1),{privacyMode:m}=Ms(),{data:S}=Pt(),{data:T}=St(s),U=Mt(),h=Dt(),v=l||s,b=v.toLowerCase()==="agy",q=c.useMemo(()=>{const F=T?.presets||[];return b?F.filter(z=>!se(z.default)&&!se(z.opus)&&!se(z.sonnet)&&!se(z.haiku)):F},[b,T?.presets]),L=c.useMemo(()=>{if(!S?.models)return[];const z={gemini:["google"],agy:["antigravity"],codex:["openai"],qwen:["alibaba","qwen"],iflow:["iflow"],kiro:["kiro","aws"],ghcp:["github","copilot"],kimi:["kimi","moonshot"]}[v.toLowerCase()]||[v.toLowerCase()];return S.models.filter(ie=>z.some(Ue=>ie.owned_by.toLowerCase().includes(Ue))?b?!se(ie.id):!0:!1)},[b,S,v]),E=(l||s).toLowerCase(),{data:_,isLoading:K,refetch:V,rawJsonContent:te,rawJsonEdits:X,isRawJsonValid:ae,hasChanges:Q,currentModel:x,opusModel:R,sonnetModel:$,haikuModel:ne,extendedContextEnabled:he,toggleExtendedContext:ke,handleRawJsonChange:Ie,updateEnvValue:Le,updateEnvValues:Ae,saveMutation:Pe,conflictDialog:Fe,handleConflictResolve:J,missingRequiredFields:D}=Ta(s),Y=c.useMemo(()=>(a.accounts||[]).map(F=>({...F,provider:F.provider||l||s})),[a.accounts,l,s]),{data:ge}=ws({queryKey:["auth-tokens-raw"],queryFn:async()=>{const F=await fetch("/api/settings/auth/tokens/raw");return F.ok?F.json():{apiKey:{value:"ccs-internal-managed"}}},staleTime:6e4}),le=ge?.apiKey?.value??"ccs-internal-managed",Js=F=>{if(b&&[F.ANTHROPIC_MODEL,F.ANTHROPIC_DEFAULT_OPUS_MODEL,F.ANTHROPIC_DEFAULT_SONNET_MODEL,F.ANTHROPIC_DEFAULT_HAIKU_MODEL].some(ie=>typeof ie=="string"&&se(ie))){H.error("Antigravity denylist: Claude Opus 4.5 and Claude Sonnet 4.5 are deprecated.");return}Ae({ANTHROPIC_BASE_URL:`http://127.0.0.1:${r??$e}/api/provider/${E}`,ANTHROPIC_AUTH_TOKEN:le,...F}),H.success(`Applied "${F.ANTHROPIC_MODEL?.split("/").pop()||"preset"}" preset`)},Ws=(F,z)=>{if(b&&[F.default,F.opus,F.sonnet,F.haiku].some(Ue=>se(Ue))){H.error("Antigravity denylist: Claude Opus 4.5 and Claude Sonnet 4.5 are deprecated.");return}Ae({ANTHROPIC_BASE_URL:`http://127.0.0.1:${r??$e}/api/provider/${E}`,ANTHROPIC_AUTH_TOKEN:le,ANTHROPIC_MODEL:F.default,ANTHROPIC_DEFAULT_OPUS_MODEL:F.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:F.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:F.haiku}),H.success(`Applied ${z?`"${z}"`:"custom"} preset`),M(!1)},Xs=(F,z)=>{if(!z){H.error(Ts.t("commonToast.enterPresetName"));return}if(b&&[F.default,F.opus,F.sonnet,F.haiku].some(ie=>se(ie))){H.error("Antigravity denylist: Claude Opus 4.5 and Claude Sonnet 4.5 are deprecated.");return}U.mutate({profile:s,data:{name:z,...F}}),M(!1)};return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(Fa,{provider:s,displayName:t,logoProvider:i,data:_,isLoading:K,hasChanges:Q,isRawJsonValid:ae,isSaving:Pe.isPending,isRemoteMode:d,port:r,onRefetch:V,onSave:()=>Pe.mutate()}),K?e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsx(W,{className:"w-8 h-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:"Loading settings..."})]}):e.jsxs("div",{className:"min-h-0 flex-1 grid grid-cols-[40%_60%] divide-x overflow-hidden",children:[e.jsx("div",{className:"flex min-h-0 min-w-0 flex-col overflow-hidden bg-muted/5",children:e.jsxs(Tt,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(Et,{className:"w-full",children:[e.jsx(us,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(us,{value:"info",className:"flex-1",children:"Info & Usage"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsx(ms,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx($a,{provider:s,catalog:n,savedPresets:q,currentModel:x,opusModel:R,sonnetModel:$,haikuModel:ne,providerModels:L,extendedContextEnabled:he,onExtendedContextToggle:ke,onApplyPreset:Js,onUpdateEnvValue:Le,onOpenCustomPreset:()=>M(!0),onDeletePreset:F=>h.mutate({profile:s,name:F}),isDeletePending:h.isPending,accounts:Y,onAddAccount:u,onSetDefault:N,onRemoveAccount:w,onPauseToggle:f,onSoloMode:O,onBulkPause:j,onBulkResume:k,isRemovingAccount:A,isPausingAccount:P,isSoloingAccount:g,isBulkPausing:p,isBulkResuming:y,privacyMode:m,isRemoteMode:d})}),e.jsx(ms,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(La,{provider:s,displayName:t,defaultTarget:o,data:_,authStatus:a,supportsModelConfig:!!n})})]})]})}),e.jsxs("div",{className:"flex min-h-0 min-w-0 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(aa,{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(Rt,{rawJsonContent:te,isRawJsonValid:ae,rawJsonEdits:X,onRawJsonChange:Ie,profileEnv:_?.settings?.env,missingRequiredFields:D})]})]}),e.jsx(ra,{open:Fe,title:"File Modified Externally",description:"This settings file was modified by another process. Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>J(!0),onCancel:()=>J(!1)}),e.jsx(Ia,{open:C,onClose:()=>M(!1),currentValues:{default:x||"",opus:R||"",sonnet:$||"",haiku:ne||""},onApply:Ws,onSave:Xs,isSaving:U.isPending,catalog:n,allModels:L})]})}function za({status:s,isSelected:t,onSelect:a}){const{t:n}=ee(),i=s.accounts?.length||0;return e.jsxs("button",{className:B("w-full flex items-center gap-3 px-3 py-2.5 rounded-lg transition-colors cursor-pointer text-left",t?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:a,children:[e.jsx(ss,{provider:s.provider,size:"md"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm truncate",children:s.displayName}),i>0&&e.jsx(G,{variant:"secondary",className:"text-[10px] h-4 px-1",children:i})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:s.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"w-3 h-3 text-green-600"}),e.jsx("span",{className:"text-xs text-green-600",children:n("cliproxyPage.connected")})]}):e.jsxs(e.Fragment,{children:[e.jsx(ns,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:n("cliproxyPage.notConnected")})]})})]})]})}function Qa({variant:s,parentAuth:t,isSelected:a,onSelect:n,onDelete:i,isDeleting:l}){const{t:d}=ee(),r=()=>{n()};return e.jsxs("div",{role:"button",tabIndex:0,className:B("group w-full flex items-center gap-3 px-3 py-2 rounded-lg transition-colors cursor-pointer text-left pl-6",a?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:r,onKeyDown:o=>{(o.key==="Enter"||o.key===" ")&&(o.preventDefault(),r())},children:[e.jsxs("div",{className:"relative",children:[e.jsx(ss,{provider:s.provider,size:"sm"}),e.jsx(Ks,{className:"w-2.5 h-2.5 absolute -bottom-0.5 -right-0.5 text-muted-foreground"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm truncate",children:s.name}),e.jsx(G,{variant:"outline",className:"text-[9px] h-4 px-1",children:d("cliproxyPage.variant")}),e.jsx(G,{variant:"outline",className:"text-[9px] h-4 px-1 uppercase",children:s.target||"claude"})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:t?.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"w-3 h-3 text-green-600"}),e.jsx("span",{className:"text-xs text-muted-foreground truncate",children:d("cliproxyPage.viaProvider",{provider:s.provider})})]}):e.jsxs(e.Fragment,{children:[e.jsx(ns,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:d("cliproxyPage.parentNotConnected")})]})})]}),e.jsx(I,{variant:"ghost",size:"icon",className:"h-6 w-6 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:o=>{o.stopPropagation(),i()},disabled:l,children:e.jsx(Hs,{className:"w-3 h-3"})})]})}function Ja({onSetup:s}){const{t}=ee();return e.jsx("div",{className:"flex-1 flex items-center justify-center bg-muted/20",children:e.jsxs("div",{className:"text-center max-w-md px-8",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-muted flex items-center justify-center mx-auto mb-6",children:e.jsx(Ce,{className:"w-8 h-8 text-muted-foreground"})}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:t("cliproxyPage.emptyTitle")}),e.jsx("p",{className:"text-muted-foreground mb-4",children:t("cliproxyPage.emptyDesc")}),e.jsxs("p",{className:"text-xs text-muted-foreground mb-6",children:[t("cliproxyPage.emptyControlPanelPrefix")," ",e.jsx("a",{href:"/cliproxy/control-panel",className:"text-primary hover:underline",children:t("cliproxyPage.controlPanel")}),"."]}),e.jsxs(I,{onClick:s,className:"gap-2",children:[e.jsx(ye,{className:"w-4 h-4"}),t("cliproxyPage.quickSetup")]})]})})}function hn(){const{t:s}=ee(),t=Je(),{data:a,isLoading:n}=Ss(),{data:i,isFetching:l}=_t(),{data:d}=Ot(),r=It(),o=Lt(),u=Ft(),N=Ut(),w=qt(),f=Ht(),O=Kt(),j=Gt(),[k,A]=c.useState(()=>{if(typeof window<"u"){const R=new URLSearchParams(window.location.search).get("provider")?.trim().toLowerCase();return R&&Ve(R)?R:localStorage.getItem("cliproxy-selected-provider")}return null}),[P,g]=c.useState(null),[p,y]=c.useState(!1),[C,M]=c.useState(()=>{if(typeof window>"u")return null;const x=new URLSearchParams(window.location.search),R=x.get("provider")?.trim().toLowerCase();return x.get("action")!=="auth"||!R||!Ve(R)?null:{provider:R,displayName:Vt(R),isFirstAccount:!1}}),m=c.useMemo(()=>a?.authStatus||[],[a?.authStatus]),S=a?.source==="remote",T=c.useMemo(()=>i?.variants||[],[i?.variants]),U=x=>{A(x),x&&localStorage.setItem("cliproxy-selected-provider",x)},h=c.useMemo(()=>P?null:k&&m.some(x=>x.provider===k)?k:m.length>0&&(m.find(R=>(R.accounts?.length||0)>0)?.provider||m[0]?.provider)||null,[k,P,m]),v=m.find(x=>x.provider===h),b=T.find(x=>x.name===P),q=b?m.find(x=>x.provider===b.provider):void 0,L=(b?.provider||v?.provider||"").toLowerCase().trim(),E=L==="gemini"||L==="agy",_=()=>{t.invalidateQueries({queryKey:["cliproxy"]}),t.invalidateQueries({queryKey:["cliproxy-auth"]})},K=(x,R,$)=>{u.isPending||N.isPending||($?u.mutate({provider:x,accountId:R}):N.mutate({provider:x,accountId:R}))},V=(x,R)=>{w.isPending||w.mutate({provider:x,accountId:R})},te=(x,R)=>{f.isPending||f.mutate({provider:x,accountIds:R})},X=(x,R)=>{O.isPending||O.mutate({provider:x,accountIds:R})},ae=x=>{U(x),g(null)},Q=x=>{g(x),U(null)};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",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(Ce,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:d?.backendLabel??"CLIProxy"})]}),e.jsx(I,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:_,disabled:l,children:e.jsx(as,{className:B("w-4 h-4",l&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:s("cliproxyPage.accountManagement")}),e.jsxs(I,{variant:"default",size:"sm",className:"w-full gap-2",onClick:()=>y(!0),children:[e.jsx(ye,{className:"w-4 h-4"}),s("cliproxyPage.quickSetup")]})]}),e.jsx(es,{className:"flex-1",children:e.jsxs("div",{className:"p-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide px-3 py-2",children:s("cliproxyPage.providers")}),n?e.jsx("div",{className:"space-y-2 px-2",children:[1,2,3,4].map(x=>e.jsx(Bt,{className:"h-14 w-full rounded-lg"},x))}):e.jsx("div",{className:"space-y-1",children:m.map(x=>e.jsx(za,{status:x,isSelected:h===x.provider,onSelect:()=>ae(x.provider)},x.provider))}),T.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide px-3 py-2 mt-4 flex items-center gap-1.5",children:[e.jsx(Ks,{className:"w-3 h-3"}),s("cliproxyPage.variants")]}),e.jsx("div",{className:"space-y-1",children:T.map(x=>e.jsx(Qa,{variant:x,parentAuth:m.find(R=>R.provider===x.provider),isSelected:P===x.name,onSelect:()=>Q(x.name),onDelete:()=>j.mutate(x.name),isDeleting:j.isPending},x.name))})]})]})}),e.jsx("div",{className:"p-3 border-t",children:e.jsx(la,{})}),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("cliproxyPage.providerCount",{count:m.length})}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ue,{className:"w-3 h-3 text-green-600"}),s("cliproxyPage.connectedCount",{count:m.filter(x=>x.authenticated).length})]})]})})]}),e.jsxs("div",{className:"flex-1 flex flex-col min-w-0 bg-background",children:[E&&e.jsx(Qs,{showProxySettingsLink:!0,className:"mx-4 mt-4"}),b&&q?e.jsx(e.Fragment,{children:e.jsx(Ns,{provider:b.name,displayName:s("cliproxyPage.variantDisplay",{name:b.name,provider:b.provider}),authStatus:q,catalog:xe[b.provider],logoProvider:b.provider,baseProvider:b.provider,defaultTarget:b.target,isRemoteMode:S,port:b.port,onAddAccount:()=>M({provider:b.provider,displayName:q.displayName,isFirstAccount:(q.accounts?.length||0)===0}),onSetDefault:x=>r.mutate({provider:b.provider,accountId:x}),onRemoveAccount:x=>o.mutate({provider:b.provider,accountId:x}),onPauseToggle:(x,R)=>K(b.provider,x,R),onSoloMode:x=>V(b.provider,x),onBulkPause:x=>te(b.provider,x),onBulkResume:x=>X(b.provider,x),isRemovingAccount:o.isPending,isPausingAccount:u.isPending||N.isPending,isSoloingAccount:w.isPending,isBulkPausing:f.isPending,isBulkResuming:O.isPending})}):v?e.jsx(e.Fragment,{children:e.jsx(Ns,{provider:v.provider,displayName:v.displayName,authStatus:v,catalog:xe[v.provider],isRemoteMode:S,onAddAccount:()=>M({provider:v.provider,displayName:v.displayName,isFirstAccount:(v.accounts?.length||0)===0}),onSetDefault:x=>r.mutate({provider:v.provider,accountId:x}),onRemoveAccount:x=>o.mutate({provider:v.provider,accountId:x}),onPauseToggle:(x,R)=>K(v.provider,x,R),onSoloMode:x=>V(v.provider,x),onBulkPause:x=>te(v.provider,x),onBulkResume:x=>X(v.provider,x),isRemovingAccount:o.isPending,isPausingAccount:u.isPending||N.isPending,isSoloingAccount:w.isPending,isBulkPausing:f.isPending,isBulkResuming:O.isPending})}):e.jsx(Ja,{onSetup:()=>y(!0)})]}),e.jsx(wa,{open:p,onClose:()=>y(!1)}),e.jsx(Sa,{open:C!==null,onClose:()=>M(null),provider:C?.provider||"",displayName:C?.displayName||"",isFirstAccount:C?.isFirstAccount||!1})]})}export{hn as CliproxyPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Dt3edmE5.js";import{r as s}from"./react-vendor-CNOkPC89.js";import{u as w}from"./tanstack-B8i0evp-.js";import{Y as U,b7 as A}from"./index-DAtuJuGe.js";import{C as P}from"./default-ports-1QQSffYX.js";import{G as M,R as k,x as q}from"./icons-EMBHZkGo.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";function F({port:a=P}){const l=s.useRef(null),[L,g]=s.useState(null),[$,R]=s.useState(0),[y,c]=s.useState(null),[E,i]=s.useState(!1),{data:b,error:x}=w({queryKey:["cliproxy-server-config"],queryFn:()=>U.cliproxyServer.get(),staleTime:3e4}),{data:j}=w({queryKey:["auth-tokens-raw"],queryFn:async()=>{const t=await fetch(A("/settings/auth/tokens/raw"));if(!t.ok)throw new Error("Failed to fetch auth tokens");return t.json()},staleTime:3e4});s.useEffect(()=>{x&&console.warn("[ControlPanelEmbed] Config fetch failed, using local mode:",x)},[x]);const{managementUrl:n,checkUrl:m,authToken:h,isRemote:d,displayHost:u}=s.useMemo(()=>{const t=b?.remote;if(t?.enabled&&t?.host){const o=t.protocol||"http",r=t.port||(o==="https"?443:P),N=o==="https"&&r===443||o==="http"&&r===80?"":`:${r}`,v=`${o}://${t.host}${N}`;return{managementUrl:`${v}/management.html`,checkUrl:`${v}/`,authToken:t.auth_token||void 0,isRemote:!0,displayHost:`${t.host}${N}`}}const f=j?.managementSecret?.value||"ccs";return{managementUrl:`http://localhost:${a}/management.html`,checkUrl:`http://localhost:${a}/`,authToken:f,isRemote:!1,displayHost:`localhost:${a}`}},[b,j,a]),p=L===n,I=!p;s.useEffect(()=>{const t=new AbortController,f=async()=>{try{(await fetch(m,{signal:t.signal})).ok?(i(!0),c(null)):(i(!1),c(d?`Remote CLIProxy at ${u} returned an error`:"CLIProxy returned an error"))}catch(r){if(r instanceof Error&&r.name==="AbortError")return;i(!1),c(d?`Remote CLIProxy at ${u} is not reachable`:"CLIProxy is not running")}},o=setTimeout(()=>t.abort(),2e3);return f().finally(()=>clearTimeout(o)),()=>t.abort()},[m,d,u]);const C=s.useCallback(()=>{if(!(!p||!l.current?.contentWindow||!h))try{const t=m.replace(/\/$/,"");if(!l.current.src.startsWith(t)){console.warn("[ControlPanelEmbed] Iframe origin mismatch, skipping postMessage");return}l.current.contentWindow.postMessage({type:"ccs-auto-login",apiBase:t,managementKey:h},t)}catch(t){console.debug("[ControlPanelEmbed] postMessage failed - cross-origin:",t)}},[h,m,p]);s.useEffect(()=>{C()},[C]);const S=s.useCallback(()=>{g(n)},[n]),T=()=>{g(null),R(t=>t+1),c(null),i(!1)};return!E&&y?e.jsxs("div",{className:"flex-1 flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(M,{className:"w-5 h-5 text-primary"}),e.jsx("h2",{className:"font-semibold",children:"CLIProxy Control Panel"})]}),e.jsxs("button",{className:"inline-flex items-center gap-2 px-3 py-1.5 text-sm border rounded-md hover:bg-muted",onClick:T,children:[e.jsx(k,{className:"w-4 h-4"}),"Retry"]})]}),e.jsx("div",{className:"flex-1 flex items-center justify-center bg-muted/20",children:e.jsxs("div",{className:"text-center max-w-md px-8",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-destructive/10 flex items-center justify-center mx-auto mb-6",children:e.jsx(q,{className:"w-8 h-8 text-destructive"})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"CLIProxy Not Available"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:y}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Start a CLIProxy session with"," ",e.jsx("code",{className:"bg-muted px-1 rounded",children:"ccs gemini"})," or run"," ",e.jsx("code",{className:"bg-muted px-1 rounded",children:"ccs config"})," which auto-starts it."]})]})})]}):e.jsx("div",{className:"flex-1 flex flex-col",children:e.jsxs("div",{className:"flex-1 flex flex-col relative",children:[I&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/80 z-10",children:e.jsxs("div",{className:"text-center",children:[e.jsx(k,{className:"w-8 h-8 animate-spin text-primary mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:d?`Loading Control Panel from ${u}...`:"Loading Control Panel..."})]})}),e.jsx("iframe",{ref:l,src:n,className:"flex-1 w-full border-0",title:"CLIProxy Management Panel",onLoad:S},`${n}:${$}`)]})})}function Q(){return e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:e.jsx(F,{})})}export{Q as CliproxyControlPanelPage};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Dt3edmE5.js";import{r as b}from"./react-vendor-CNOkPC89.js";import{t as F}from"./notifications-B2HqRBj7.js";import{C as L,j as D,k as R,B as I,b as A,d as y,r as T,s as E,t as k,v as P,w as g,I as C,n as xe,b7 as J,b8 as Ne,c as Se,be as ze,bf as pe,bg as Ye,Q as Xe,R as Be,U as re,V as te,b9 as je}from"./index-DAtuJuGe.js";import{S as B}from"./switch-DmDIWykO.js";import{a4 as We,aK as He,aj as Z,L as $,m as Qe,aL as Ge,aM as Je,ao as Ze,aE as ce,aF as de,o as ge,Q as es,l as ss,n as rs,O as ts,S as ns,aN as as,v as ls,w as os,T as is,D as cs}from"./icons-EMBHZkGo.js";import{S as Q}from"./separator--ZH5ZM-3.js";import{a as ds,u as ve,b as be}from"./tanstack-B8i0evp-.js";import"./code-highlight-BRUf_pqB.js";import{T as us,a as ms,b as we,c as ne,d as xs,e as ae}from"./table-E5IxHhrW.js";import{R as hs}from"./raw-json-settings-editor-panel-DnUbq1__.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";function W({title:s,icon:r,badge:t,description:a,disabledReason:n,children:o}){return e.jsxs(L,{children:[e.jsxs(D,{className:"pb-2",children:[e.jsxs(R,{className:"flex items-center gap-2 text-base",children:[r,s,t?e.jsx(I,{variant:"outline",className:"text-[10px] font-normal",children:t}):null]}),a?e.jsx("p",{className:"text-xs text-muted-foreground",children:a}):null]}),e.jsxs(A,{className:"space-y-3",children:[n?e.jsx("p",{className:"text-xs text-amber-600",children:n}):null,o]})]})}function fs({catalog:s,state:r,disabled:t=!1,disabledReason:a,onToggle:n}){const o=new Set(s.map(l=>l.name)),i=Object.entries(r).filter(([l])=>!o.has(l)).sort(([l],[d])=>l.localeCompare(d));return e.jsxs(W,{title:"Features",badge:"features",icon:e.jsx(We,{className:"h-4 w-4"}),description:"Toggle the supported Codex feature flags CCS can safely manage.",disabledReason:a,children:[e.jsx("div",{className:"space-y-2",children:s.map(l=>{const d=r[l.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:l.label}),e.jsx(I,{variant:"outline",className:"font-mono text-[10px]",children:l.name})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l.description})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[d!==null?e.jsx(y,{variant:"outline",size:"sm",onClick:()=>n(l.name,null),disabled:t,children:"Use default"}):null,e.jsx(B,{checked:d===!0,onCheckedChange:c=>n(l.name,c),disabled:t})]})]},l.name)})}),i.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."})]}),i.map(([l,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:l}),e.jsx(I,{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(I,{variant:"outline",children:"Raw only"}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(y,{variant:"outline",size:"sm",onClick:()=>n(l,null),disabled:t,children:"Use default"}),e.jsx(B,{checked:d===!0,onCheckedChange:c=>n(l,c),disabled:t})]})]},l))]}):null]})}const ps={name:"",transport:"stdio",command:null,args:[],url:null,enabled:!0,required:!1,startupTimeoutSec:null,toolTimeoutSec:null,enabledTools:[],disabledTools:[]};function le(s){return s.join(", ")}function oe(s){return s.split(",").map(r=>r.trim()).filter(Boolean)}function js({initialDraft:s,isNew:r,disabled:t,saving:a,canDelete:n,onSave:o,onDelete:i}){const[l,d]=b.useState(s);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(C,{value:l.name,onChange:c=>d(u=>({...u,name:c.target.value})),placeholder:"playwright",disabled:t||!r}),e.jsxs(T,{value:l.transport,onValueChange:c=>d(u=>({...u,transport:c})),disabled:t,children:[e.jsx(E,{children:e.jsx(k,{})}),e.jsxs(P,{children:[e.jsx(g,{value:"stdio",children:"stdio"}),e.jsx(g,{value:"streamable-http",children:"streamable-http"})]})]}),l.transport==="stdio"?e.jsxs(e.Fragment,{children:[e.jsx(C,{value:l.command??"",onChange:c=>d(u=>({...u,command:c.target.value||null})),placeholder:"npx",disabled:t}),e.jsx(C,{value:le(l.args),onChange:c=>d(u=>({...u,args:oe(c.target.value)})),placeholder:"@playwright/mcp@latest, --flag",disabled:t})]}):e.jsx(C,{className:"sm:col-span-2",value:l.url??"",onChange:c=>d(u=>({...u,url:c.target.value||null})),placeholder:"https://example.test/mcp",disabled:t}),e.jsx(C,{type:"number",min:1,value:l.startupTimeoutSec??"",onChange:c=>d(u=>({...u,startupTimeoutSec:c.target.value?Number(c.target.value):null})),placeholder:"Startup timeout (sec)",disabled:t}),e.jsx(C,{type:"number",min:1,value:l.toolTimeoutSec??"",onChange:c=>d(u=>({...u,toolTimeoutSec:c.target.value?Number(c.target.value):null})),placeholder:"Tool timeout (sec)",disabled:t}),e.jsx(C,{value:le(l.enabledTools),onChange:c=>d(u=>({...u,enabledTools:oe(c.target.value)})),placeholder:"enabled_tools",disabled:t}),e.jsx(C,{value:le(l.disabledTools),onChange:c=>d(u=>({...u,disabledTools:oe(c.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(B,{checked:l.enabled,onCheckedChange:c=>d(u=>({...u,enabled:c})),disabled:t})]}),e.jsxs("label",{className:"flex items-center justify-between rounded-md border px-3 py-2 text-sm",children:["Required",e.jsx(B,{checked:l.required,onCheckedChange:c=>d(u=>({...u,required:c})),disabled:t})]})]}),e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsxs(y,{variant:"outline",onClick:i,disabled:t||a||!n,children:[e.jsx(Z,{className:"mr-2 h-4 w-4"}),"Delete"]}),e.jsxs(y,{onClick:()=>o(l.name,{transport:l.transport,command:l.command,args:l.args,url:l.url,enabled:l.enabled,required:l.required,startupTimeoutSec:l.startupTimeoutSec,toolTimeoutSec:l.toolTimeoutSec,enabledTools:l.enabledTools,disabledTools:l.disabledTools}),disabled:t||a||l.name.trim().length===0,children:[a?e.jsx($,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save MCP server"]})]})]})}function gs({entries:s,disabled:r=!1,disabledReason:t,saving:a=!1,onSave:n,onDelete:o}){const[i,l]=b.useState("new"),d=b.useMemo(()=>s.find(h=>h.name===i)??null,[s,i]),c=d??ps,u=JSON.stringify(c);return e.jsxs(W,{title:"MCP servers",badge:"mcp_servers",icon:e.jsx(He,{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(T,{value:i,onValueChange:l,disabled:r,children:[e.jsx(E,{children:e.jsx(k,{placeholder:"Select MCP server"})}),e.jsxs(P,{children:[e.jsx(g,{value:"new",children:"Create new MCP server"}),s.map(h=>e.jsx(g,{value:h.name,children:h.name},h.name))]})]}),e.jsx(js,{initialDraft:c,isNew:i==="new",disabled:r,saving:a,canDelete:d!==null,onDelete:async()=>{d&&(await o(d.name),l("new"))},onSave:async(h,p)=>{await n(h,p),l(h)}},u)]})}const vs={name:"",displayName:null,baseUrl:null,envKey:null,wireApi:"responses",requiresOpenaiAuth:!1,supportsWebsockets:!1},bs={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 ws({initialDraft:s,isNew:r,disabled:t,saving:a,canDelete:n,onSave:o,onDelete:i}){const[l,d]=b.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:"Default provider"})," to ",e.jsx("code",{children:"cliproxy"})," in Top-level settings."]}),e.jsx(y,{variant:"outline",size:"sm",onClick:()=>d(bs),disabled:t,children:"Use CLIProxy Codex preset"})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(C,{value:l.name,onChange:c=>d(u=>({...u,name:c.target.value})),placeholder:"Provider id",disabled:t||!r}),e.jsx(C,{value:l.displayName??"",onChange:c=>d(u=>({...u,displayName:c.target.value||null})),placeholder:"Display name",disabled:t}),e.jsx(C,{value:l.baseUrl??"",onChange:c=>d(u=>({...u,baseUrl:c.target.value||null})),placeholder:"http://127.0.0.1:8317/api/provider/codex",disabled:t}),e.jsx(C,{value:l.envKey??"",onChange:c=>d(u=>({...u,envKey:c.target.value||null})),placeholder:"CLIPROXY_API_KEY",disabled:t})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[e.jsxs(T,{value:l.wireApi??"responses",onValueChange:c=>d(u=>({...u,wireApi:c})),disabled:t,children:[e.jsx(E,{children:e.jsx(k,{})}),e.jsx(P,{children:e.jsx(g,{value:"responses",children:"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(B,{checked:l.requiresOpenaiAuth,onCheckedChange:c=>d(u=>({...u,requiresOpenaiAuth:c})),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(B,{checked:l.supportsWebsockets,onCheckedChange:c=>d(u=>({...u,supportsWebsockets:c})),disabled:t})]})]}),e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsxs(y,{variant:"outline",onClick:i,disabled:t||a||!n,children:[e.jsx(Z,{className:"mr-2 h-4 w-4"}),"Delete"]}),e.jsxs(y,{onClick:()=>o(l.name,{displayName:l.displayName,baseUrl:l.baseUrl,envKey:l.envKey,wireApi:l.wireApi,requiresOpenaiAuth:l.requiresOpenaiAuth,supportsWebsockets:l.supportsWebsockets}),disabled:t||a||l.name.trim().length===0,children:[a?e.jsx($,{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:"Default provider"})," control above."]})]})}function Cs({entries:s,disabled:r=!1,disabledReason:t,saving:a=!1,onSave:n,onDelete:o}){const[i,l]=b.useState("new"),d=b.useMemo(()=>s.find(h=>h.name===i)??null,[s,i]),c=d??vs,u=JSON.stringify(c);return e.jsxs(W,{title:"Model providers",badge:"model_providers",icon:e.jsx(Qe,{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(T,{value:i,onValueChange:l,disabled:r,children:[e.jsx(E,{children:e.jsx(k,{placeholder:"Select provider"})}),e.jsxs(P,{children:[e.jsx(g,{value:"new",children:"Create new provider"}),s.map(h=>e.jsx(g,{value:h.name,children:h.name},h.name))]})]}),e.jsx(ws,{initialDraft:c,isNew:i==="new",disabled:r,saving:a,canDelete:d!==null,onDelete:async()=>{d&&(await o(d.name),l("new"))},onSave:async(h,p)=>{await n(h,p),l(h)}},u)]})}function ys({initialName:s,initialModel:r,initialProvider:t,initialEffort:a,providerNames:n,activeProfile:o,selectedEntryName:i,disabled:l,saving:d,onSave:c,onDelete:u,onSetActive:h}){const[p,x]=b.useState(s),[j,m]=b.useState(r),[v,H]=b.useState(t),[U,_]=b.useState(a);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(C,{value:p,onChange:w=>x(w.target.value),placeholder:"deep-review",disabled:l||i!==null}),e.jsx(C,{value:j??"",onChange:w=>m(w.target.value||null),placeholder:"gpt-5.4",disabled:l}),e.jsxs(T,{value:v??"__unset__",onValueChange:w=>H(w==="__unset__"?null:w),disabled:l,children:[e.jsx(E,{children:e.jsx(k,{placeholder:"Use global provider"})}),e.jsxs(P,{children:[e.jsx(g,{value:"__unset__",children:"Use global provider"}),n.map(w=>e.jsx(g,{value:w,children:w},w))]})]}),e.jsxs(T,{value:U??"__unset__",onValueChange:w=>_(w==="__unset__"?null:w),disabled:l,children:[e.jsx(E,{children:e.jsx(k,{placeholder:"Use global effort"})}),e.jsxs(P,{children:[e.jsx(g,{value:"__unset__",children:"Use global effort"}),["minimal","low","medium","high","xhigh"].map(w=>e.jsx(g,{value:w,children:w},w))]})]})]}),e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(y,{variant:"outline",onClick:u,disabled:l||d||!i,children:[e.jsx(Z,{className:"mr-2 h-4 w-4"}),"Delete"]}),e.jsx(y,{variant:"outline",onClick:h,disabled:l||d||!i||i===o,children:"Set active"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(y,{variant:"outline",onClick:()=>c(p,{model:j,modelProvider:v,modelReasoningEffort:U},!1),disabled:l||d||p.trim().length===0,children:[d?e.jsx($,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save profile"]}),e.jsxs(y,{onClick:()=>c(p,{model:j,modelProvider:v,modelReasoningEffort:U},!0),disabled:l||d||p.trim().length===0,children:[d?e.jsx($,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save + activate"]})]})]})]})}function Ns({activeProfile:s,entries:r,providerNames:t,disabled:a=!1,disabledReason:n,saving:o=!1,onSave:i,onDelete:l,onSetActive:d}){const[c,u]=b.useState("new"),h=b.useMemo(()=>r.find(x=>x.name===c)??null,[r,c]),p=JSON.stringify(h??{name:"",values:{}});return e.jsxs(W,{title:"Profiles",badge:"profiles",icon:e.jsx(Ge,{className:"h-4 w-4"}),description:"Create reusable Codex overlays and set the active default profile.",disabledReason:n,children:[e.jsxs(T,{value:c,onValueChange:u,disabled:a,children:[e.jsx(E,{children:e.jsx(k,{placeholder:"Select profile"})}),e.jsxs(P,{children:[e.jsx(g,{value:"new",children:"Create new profile"}),r.map(x=>e.jsxs(g,{value:x.name,children:[x.name,x.name===s?" (active)":""]},x.name))]})]}),e.jsx(ys,{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:a,saving:o,onDelete:async()=>{h&&(await l(h.name),u("new"))},onSetActive:async()=>{h&&await d(h.name)},onSave:async(x,j,m)=>{await i(x,j,m),u(x)}},p)]})}function Ss({workspacePath:s,disabled:r,saving:t,onSave:a}){const[n,o]=b.useState(s),[i,l]=b.useState("trusted");return e.jsxs("div",{className:"grid gap-2 sm:grid-cols-[1fr_160px_auto]",children:[e.jsx(C,{value:n,onChange:d=>o(d.target.value),placeholder:"~/repo or /absolute/path",disabled:r}),e.jsxs(T,{value:i,onValueChange:l,disabled:r,children:[e.jsx(E,{children:e.jsx(k,{})}),e.jsxs(P,{children:[e.jsx(g,{value:"trusted",children:"trusted"}),e.jsx(g,{value:"untrusted",children:"untrusted"})]})]}),e.jsxs(y,{onClick:()=>a(n,i),disabled:r||t,children:[t?e.jsx($,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save trust"]})]})}function _s({workspacePath:s,entries:r,disabled:t=!1,disabledReason:a,saving:n=!1,onSave:o}){return e.jsxs(W,{title:"Project trust",badge:"projects",icon:e.jsx(Je,{className:"h-4 w-4"}),description:"Trust current workspaces or remove stale trust entries without opening raw TOML.",disabledReason:a,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(Ss,{workspacePath:s,disabled:t,saving:n,onSave:o},s),e.jsx(y,{variant:"outline",className:"w-full justify-start",onClick:()=>o(s,"trusted"),disabled:t||n,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:"No explicit project trust entries saved."}):r.map(i=>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:i.path}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["trust_level = ",i.trustLevel]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>o(i.path,i.trustLevel==="trusted"?"untrusted":"trusted"),disabled:t||n,children:"Toggle"}),e.jsx(y,{variant:"ghost",size:"icon",onClick:()=>o(i.path,null),disabled:t||n,children:e.jsx(Z,{className:"h-4 w-4"})})]})]},i.path))})]})}const O="__unset__";function z(s){return s??O}function Y(s,r){return r&&!s.includes(r)?[r,...s]:s}function Ts(s,r){const t={};return r.model!==s.model&&(t.model=r.model),r.modelReasoningEffort!==s.modelReasoningEffort&&(t.modelReasoningEffort=r.modelReasoningEffort),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 Es({initialValues:s,providerNames:r,disabled:t,saving:a,onSave:n}){const[o,i]=b.useState(s),l=Y(["minimal","low","medium","high","xhigh"],o.modelReasoningEffort),d=Y(r,o.modelProvider),c=Y(["on-request","never","untrusted"],o.approvalPolicy),u=Y(["read-only","workspace-write","danger-full-access"],o.sandboxMode),h=Y(["cached","live","disabled"],o.webSearch),p=Y(["none","friendly","pragmatic"],o.personality),x=Ts(s,o),j=Object.keys(x).length>0;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:"Model"}),e.jsx(C,{value:o.model??"",onChange:m=>i(v=>({...v,model:m.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:"Reasoning effort"}),e.jsxs(T,{value:z(o.modelReasoningEffort),onValueChange:m=>i(v=>({...v,modelReasoningEffort:m===O?null:m})),disabled:t,children:[e.jsx(E,{children:e.jsx(k,{placeholder:"Use default"})}),e.jsxs(P,{children:[e.jsx(g,{value:O,children:"Use default"}),l.map(m=>e.jsx(g,{value:m,children:m},m))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:"Default provider"}),e.jsxs(T,{value:z(o.modelProvider),onValueChange:m=>i(v=>({...v,modelProvider:m===O?null:m})),disabled:t,children:[e.jsx(E,{children:e.jsx(k,{placeholder:"Use Codex default"})}),e.jsxs(P,{children:[e.jsx(g,{value:O,children:"Use Codex default"}),d.map(m=>e.jsx(g,{value:m,children:m},m))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:"Approval policy"}),e.jsxs(T,{value:z(o.approvalPolicy),onValueChange:m=>i(v=>({...v,approvalPolicy:m===O?null:m})),disabled:t,children:[e.jsx(E,{children:e.jsx(k,{placeholder:"Use default"})}),e.jsxs(P,{children:[e.jsx(g,{value:O,children:"Use default"}),c.map(m=>e.jsx(g,{value:m,children:m},m))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:"Sandbox mode"}),e.jsxs(T,{value:z(o.sandboxMode),onValueChange:m=>i(v=>({...v,sandboxMode:m===O?null:m})),disabled:t,children:[e.jsx(E,{children:e.jsx(k,{placeholder:"Use default"})}),e.jsxs(P,{children:[e.jsx(g,{value:O,children:"Use default"}),u.map(m=>e.jsx(g,{value:m,children:m},m))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:"Web search"}),e.jsxs(T,{value:z(o.webSearch),onValueChange:m=>i(v=>({...v,webSearch:m===O?null:m})),disabled:t,children:[e.jsx(E,{children:e.jsx(k,{placeholder:"Use default"})}),e.jsxs(P,{children:[e.jsx(g,{value:O,children:"Use default"}),h.map(m=>e.jsx(g,{value:m,children:m},m))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:"Tool output token limit"}),e.jsx(C,{type:"number",min:1,value:o.toolOutputTokenLimit??"",onChange:m=>i(v=>({...v,toolOutputTokenLimit:m.target.value?Number(m.target.value):null})),placeholder:"25000",disabled:t})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:"Personality"}),e.jsxs(T,{value:z(o.personality),onValueChange:m=>i(v=>({...v,personality:m===O?null:m})),disabled:t,children:[e.jsx(E,{children:e.jsx(k,{placeholder:"Use default"})}),e.jsxs(P,{children:[e.jsx(g,{value:O,children:"Use default"}),p.map(m=>e.jsx(g,{value:m,children:m},m))]})]})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(y,{onClick:()=>n(x),disabled:t||a||!j,children:[a?e.jsx($,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save top-level settings"]})})]})}function ks({values:s,providerNames:r,disabled:t=!1,disabledReason:a,saving:n=!1,onSave:o}){return e.jsx(W,{title:"Top-level controls",badge:"config.toml",icon:e.jsx(Ze,{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:a,children:e.jsx(Es,{initialValues:s,providerNames:r,disabled:t,saving:n,onSave:o},JSON.stringify(s))})}function Ps({workspacePath:s,activeProfile:r,topLevelSettings:t,projectTrustEntries:a,profileEntries:n,modelProviderEntries:o,mcpServerEntries:i,featureCatalog:l,featureState:d,disabled:c,disabledReason:u,saving:h,onPatch:p}){return e.jsx(xe,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 pr-1",children:[e.jsxs(L,{children:[e.jsx(D,{className:"pb-2",children:e.jsxs(R,{className:"flex items-center gap-2 text-base",children:[e.jsx(ce,{className:"h-4 w-4"}),"Structured controls boundary"]})}),e.jsxs(A,{className:"space-y-2 text-sm text-muted-foreground",children:[e.jsxs("p",{children:["Guided controls write only the user-layer ",e.jsx("code",{children:"config.toml"}),". They do not model the full effective Codex runtime once trusted repo layers and CCS transient"," ",e.jsx("code",{children:"-c"})," overrides are involved."]}),e.jsx("p",{children:"Structured saves normalize TOML formatting and strip comments. Use the raw editor on the right when exact layout matters."})]})]}),e.jsx(ks,{values:t,providerNames:o.map(x=>x.name),disabled:c,disabledReason:u,saving:h,onSave:x=>p({kind:"top-level",values:x},"Saved top-level Codex settings.")}),e.jsx(_s,{workspacePath:s,entries:a,disabled:c,disabledReason:u,saving:h,onSave:(x,j)=>p({kind:"project-trust",path:x,trustLevel:j},j?"Saved project trust entry.":"Removed project trust entry.")}),e.jsx(Ns,{activeProfile:r,entries:n,providerNames:o.map(x=>x.name),disabled:c,disabledReason:u,saving:h,onSave:(x,j,m)=>p({kind:"profile",action:"upsert",name:x,values:j,setAsActive:m},"Saved profile."),onDelete:x=>p({kind:"profile",action:"delete",name:x},"Deleted profile."),onSetActive:x=>p({kind:"profile",action:"set-active",name:x},"Set active profile.")}),e.jsx(Cs,{entries:o,disabled:c,disabledReason:u,saving:h,onSave:(x,j)=>p({kind:"model-provider",action:"upsert",name:x,values:j},"Saved model provider."),onDelete:x=>p({kind:"model-provider",action:"delete",name:x},"Deleted model provider.")}),e.jsx(gs,{entries:i,disabled:c,disabledReason:u,saving:h,onSave:(x,j)=>p({kind:"mcp-server",action:"upsert",name:x,values:j},"Saved MCP server."),onDelete:x=>p({kind:"mcp-server",action:"delete",name:x},"Deleted MCP server.")}),e.jsx(fs,{catalog:l,state:d,disabled:c,disabledReason:u,onToggle:(x,j)=>p({kind:"feature",feature:x,enabled:j},"Saved feature toggle.")})]})})}const _e=`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"`,Te=[{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 V(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)?s:null}function S(s){return typeof s=="string"&&s.trim().length>0?s.trim():null}function G(s){return typeof s=="number"&&Number.isFinite(s)?s:null}function ie(s){return Array.isArray(s)?s.filter(r=>typeof r=="string").map(r=>r.trim()):[]}function Ee(s){return{model:S(s?.model),modelReasoningEffort:S(s?.model_reasoning_effort),modelProvider:S(s?.model_provider),approvalPolicy:S(s?.approval_policy),sandboxMode:S(s?.sandbox_mode),webSearch:S(s?.web_search),toolOutputTokenLimit:G(s?.tool_output_token_limit),personality:S(s?.personality)}}function Os(s){const r=V(s?.projects);return r?Object.entries(r).map(([t,a])=>{const n=S(V(a)?.trust_level);return n?{path:t,trustLevel:n}:null}).filter(t=>t!==null).sort((t,a)=>t.path.localeCompare(a.path)):[]}function Ls(s){const r=V(s?.profiles);return r?Object.entries(r).map(([t,a])=>({name:t,values:Ee(V(a))})).sort((t,a)=>t.name.localeCompare(a.name)):[]}function Ds(s){const r=V(s?.model_providers);return r?Object.entries(r).map(([t,a])=>{const n=V(a);return n?{name:t,displayName:S(n.name),baseUrl:S(n.base_url),envKey:S(n.env_key),wireApi:S(n.wire_api),requiresOpenaiAuth:n.requires_openai_auth===!0,supportsWebsockets:n.supports_websockets===!0}:null}).filter(t=>t!==null).sort((t,a)=>t.name.localeCompare(a.name)):[]}function Rs(s){const r=V(s?.mcp_servers);return r?Object.entries(r).map(([t,a])=>{const n=V(a);if(!n)return null;const o=S(n.command)?"stdio":"streamable-http",i=G(n.startup_timeout_ms);return{name:t,transport:o,command:S(n.command),args:ie(n.args),url:S(n.url),enabled:n.enabled!==!1,required:n.required===!0,startupTimeoutSec:G(n.startup_timeout_sec)??(i!==null?i/1e3:null),toolTimeoutSec:G(n.tool_timeout_sec),enabledTools:ie(n.enabled_tools),disabledTools:ie(n.disabled_tools)}}).filter(t=>t!==null).sort((t,a)=>t.name.localeCompare(a.name)):[]}function As(s){const r=V(s?.features),t={};for(const a of Te){const n=r?.[a.name];t[a.name]=typeof n=="boolean"?n:null}if(r)for(const[a,n]of Object.entries(r))a in t||(t[a]=typeof n=="boolean"?n:null);return t}const Ms=[{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."}],Is=[{provider:"openai",label:"OpenAI Responses API",apiFormat:"Responses API",url:"https://platform.openai.com/docs/api-reference/responses"}];function Us(s){const r=/https?:\/\/[^\s)]+/g,t=[];let a=0,n;for(;(n=r.exec(s))!==null;){const[o]=n,i=n.index;i>a&&t.push(s.slice(a,i)),t.push(e.jsx("a",{href:o,target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:o},`${o}-${i}`)),a=i+o.length}return a<s.length&&t.push(s.slice(a)),t.length>0?t:[s]}function Fs({diagnostics:s}){const r=s.docsReference??{notes:[],links:[],providerDocs:[],providerValues:[],settingsHierarchy:[]},t=r.links.length>0?r.links:Ms,a=r.providerDocs.length>0?r.providerDocs:Is;return e.jsx(xe,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 pr-1",children:[e.jsxs(L,{children:[e.jsx(D,{className:"pb-2",children:e.jsxs(R,{className:"flex items-center gap-2 text-base",children:[e.jsx(de,{className:"h-4 w-4"}),"CCS bridge recipe"]})}),e.jsxs(A,{className:"space-y-3 text-sm text-muted-foreground",children:[e.jsxs("p",{children:["Use ",e.jsx("code",{children:"ccsxp"})," if you want the built-in CCS Codex provider shortcut on native Codex. Use the saved recipe below if you want plain ",e.jsx("code",{children:"codex"})," or a personal alias like ",e.jsx("code",{children:"cxp"})," to default to CLIProxy."]}),e.jsx("pre",{className:"overflow-x-auto rounded-md border bg-muted/20 p-3 text-xs text-foreground",children:_e}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{children:["1. Save the ",e.jsx("code",{children:"cliproxy"})," provider in your user config."]}),e.jsxs("p",{children:["2. Set top-level ",e.jsx("code",{children:"model_provider"})," to ",e.jsx("code",{children:"cliproxy"}),"."]}),e.jsxs("p",{children:["3. Export ",e.jsx("code",{children:"CLIPROXY_API_KEY"})," in your shell before launching native Codex."]})]})]})]}),e.jsxs(L,{children:[e.jsx(D,{className:"pb-2",children:e.jsxs(R,{className:"flex items-center gap-2 text-base",children:[e.jsx(de,{className:"h-4 w-4"}),"Upstream notes"]})}),e.jsxs(A,{className:"space-y-2 text-sm",children:[r.notes.map((n,o)=>e.jsxs("p",{className:"text-muted-foreground",children:["- ",Us(n)]},`${o}-${n}`)),e.jsx(Q,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:"Codex docs"}),e.jsx("div",{className:"space-y-1.5",children:t.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(ge,{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(Q,{}),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(ge,{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}`))})]}),r.providerValues.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(Q,{}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Provider values: ",r.providerValues.join(", ")]})]}),r.settingsHierarchy.length>0&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Settings hierarchy: ",r.settingsHierarchy.join(" -> ")]})]})]})]})})}function Ks(s,r){let t=s.slice(0,r).split(/\r\n|\n|\r/g);return[t.length,t.pop().length+1]}function Vs(s,r,t){let a=s.split(/\r\n|\n|\r/g),n="",o=(Math.log10(r+1)|0)+1;for(let i=r-1;i<=r+1;i++){let l=a[i-1];l&&(n+=i.toString().padEnd(o," "),n+=": ",n+=l,n+=`
|
|
7
|
-
`,i===r&&(n+=" ".repeat(o+t+2),n+=`^
|
|
8
|
-
`))}return n}class f extends Error{line;column;codeblock;constructor(r,t){const[a,n]=Ks(t.toml,t.ptr),o=Vs(t.toml,a,n);super(`Invalid TOML document: ${r}
|
|
9
|
-
|
|
10
|
-
${o}`,t),this.line=a,this.column=n,this.codeblock=o}}function qs(s,r){let t=0;for(;s[r-++t]==="\\";);return--t&&t%2}function ue(s,r=0,t=s.length){let a=s.indexOf(`
|
|
11
|
-
`,r);return s[a-1]==="\r"&&a--,a<=t?a:-1}function ee(s,r){for(let t=r;t<s.length;t++){let a=s[t];if(a===`
|
|
12
|
-
`)return t;if(a==="\r"&&s[t+1]===`
|
|
13
|
-
`)return t+1;if(a<" "&&a!==" "||a==="")throw new f("control characters are not allowed in comments",{toml:s,ptr:r})}return s.length}function K(s,r,t,a){let n;for(;;){for(;(n=s[r])===" "||n===" "||!t&&(n===`
|
|
14
|
-
`||n==="\r"&&s[r+1]===`
|
|
15
|
-
`);)r++;if(a||n!=="#")break;r=ee(s,r)}return r}function $s(s,r,t,a,n=!1){if(!a)return r=ue(s,r),r<0?s.length:r;for(let o=r;o<s.length;o++){let i=s[o];if(i==="#")o=ue(s,o);else{if(i===t)return o+1;if(i===a||n&&(i===`
|
|
16
|
-
`||i==="\r"&&s[o+1]===`
|
|
17
|
-
`))return o}}throw new f("cannot find end of structure",{toml:s,ptr:r})}function ke(s,r){let t=s[r],a=t===s[r+1]&&s[r+1]===s[r+2]?s.slice(r,r+3):t;r+=a.length-1;do r=s.indexOf(a,++r);while(r>-1&&t!=="'"&&qs(s,r));return r>-1&&(r+=a.length,a.length>1&&(s[r]===t&&r++,s[r]===t&&r++)),r}let zs=/^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;class X extends Date{#s=!1;#r=!1;#e=null;constructor(r){let t=!0,a=!0,n="Z";if(typeof r=="string"){let o=r.match(zs);o?(o[1]||(t=!1,r=`0000-01-01T${r}`),a=!!o[2],a&&r[10]===" "&&(r=r.replace(" ","T")),o[2]&&+o[2]>23?r="":(n=o[3]||null,r=r.toUpperCase(),!n&&a&&(r+="Z"))):r=""}super(r),isNaN(this.getTime())||(this.#s=t,this.#r=a,this.#e=n)}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 a=new X(r);return a.#e=t,a}static wrapAsLocalDateTime(r){let t=new X(r);return t.#e=null,t}static wrapAsLocalDate(r){let t=new X(r);return t.#r=!1,t.#e=null,t}static wrapAsLocalTime(r){let t=new X(r);return t.#s=!1,t.#e=null,t}}let Ys=/^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/,Xs=/^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/,Bs=/^[+-]?0[0-9_]/,Ws=/^[0-9a-f]{2,8}$/i,Ce={b:"\b",t:" ",n:`
|
|
18
|
-
`,f:"\f",r:"\r",e:"\x1B",'"':'"',"\\":"\\"};function Pe(s,r=0,t=s.length){let a=s[r]==="'",n=s[r++]===s[r]&&s[r]===s[r+1];n&&(t-=2,s[r+=2]==="\r"&&r++,s[r]===`
|
|
19
|
-
`&&r++);let o=0,i,l="",d=r;for(;r<t-1;){let c=s[r++];if(c===`
|
|
20
|
-
`||c==="\r"&&s[r]===`
|
|
21
|
-
`){if(!n)throw new f("newlines are not allowed in strings",{toml:s,ptr:r-1})}else if(c<" "&&c!==" "||c==="")throw new f("control characters are not allowed in strings",{toml:s,ptr:r-1});if(i){if(i=!1,c==="x"||c==="u"||c==="U"){let u=s.slice(r,r+=c==="x"?2:c==="u"?4:8);if(!Ws.test(u))throw new f("invalid unicode escape",{toml:s,ptr:o});try{l+=String.fromCodePoint(parseInt(u,16))}catch{throw new f("invalid unicode escape",{toml:s,ptr:o})}}else if(n&&(c===`
|
|
22
|
-
`||c===" "||c===" "||c==="\r")){if(r=K(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:o});r=K(s,r)}else if(c in Ce)l+=Ce[c];else throw new f("unrecognized escape sequence",{toml:s,ptr:o});d=r}else!a&&c==="\\"&&(o=r-1,i=!0,l+=s.slice(d,o))}return l+s.slice(d,t-1)}function Hs(s,r,t,a){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 a?0n:0;let n=Ys.test(s);if(n||Xs.test(s)){if(Bs.test(s))throw new f("leading zeroes are not allowed",{toml:r,ptr:t});s=s.replace(/_/g,"");let i=+s;if(isNaN(i))throw new f("invalid number",{toml:r,ptr:t});if(n){if((n=!Number.isSafeInteger(i))&&!a)throw new f("integer value cannot be represented losslessly",{toml:r,ptr:t});(n||a===!0)&&(i=BigInt(s))}return i}const o=new X(s);if(!o.isValid())throw new f("invalid value",{toml:r,ptr:t});return o}function Qs(s,r,t){let a=s.slice(r,t),n=a.indexOf("#");return n>-1&&(ee(s,n),a=a.slice(0,n)),[a.trimEnd(),n]}function he(s,r,t,a,n){if(a===0)throw new f("document contains excessively nested structures. aborting.",{toml:s,ptr:r});let o=s[r];if(o==="["||o==="{"){let[d,c]=o==="["?Zs(s,r,a,n):Js(s,r,a,n);if(t){if(c=K(s,c),s[c]===",")c++;else if(s[c]!==t)throw new f("expected comma or end of structure",{toml:s,ptr:c})}return[d,c]}let i;if(o==='"'||o==="'"){i=ke(s,r);let d=Pe(s,r,i);if(t){if(i=K(s,i),s[i]&&s[i]!==","&&s[i]!==t&&s[i]!==`
|
|
24
|
-
`&&s[i]!=="\r")throw new f("unexpected character encountered",{toml:s,ptr:i});i+=+(s[i]===",")}return[d,i]}i=$s(s,r,",",t);let l=Qs(s,r,i-+(s[i-1]===","));if(!l[0])throw new f("incomplete key-value declaration: no value specified",{toml:s,ptr:r});return t&&l[1]>-1&&(i=K(s,r+l[1]),i+=+(s[i]===",")),[Hs(l[0],s,r,n),i]}let Gs=/^[a-zA-Z0-9-_]+[ \t]*$/;function me(s,r,t="="){let a=r-1,n=[],o=s.indexOf(t,r);if(o<0)throw new f("incomplete key-value: cannot find end of key",{toml:s,ptr:r});do{let i=s[r=++a];if(i!==" "&&i!==" ")if(i==='"'||i==="'"){if(i===s[r+1]&&i===s[r+2])throw new f("multiline strings are not allowed in keys",{toml:s,ptr:r});let l=ke(s,r);if(l<0)throw new f("unfinished string encountered",{toml:s,ptr:r});a=s.indexOf(".",l);let d=s.slice(l,a<0||a>o?o:a),c=ue(d);if(c>-1)throw new f("newlines are not allowed in keys",{toml:s,ptr:r+a+c});if(d.trimStart())throw new f("found extra tokens after the string part",{toml:s,ptr:l});if(o<l&&(o=s.indexOf(t,l),o<0))throw new f("incomplete key-value: cannot find end of key",{toml:s,ptr:r});n.push(Pe(s,r,l))}else{a=s.indexOf(".",r);let l=s.slice(r,a<0||a>o?o:a);if(!Gs.test(l))throw new f("only letter, numbers, dashes and underscores are allowed in keys",{toml:s,ptr:r});n.push(l.trimEnd())}}while(a+1&&a<o);return[n,K(s,o+1,!0,!0)]}function Js(s,r,t,a){let n={},o=new Set,i;for(r++;(i=s[r++])!=="}"&&i;){if(i===",")throw new f("expected value, found comma",{toml:s,ptr:r-1});if(i==="#")r=ee(s,r);else if(i!==" "&&i!==" "&&i!==`
|
|
25
|
-
`&&i!=="\r"){let l,d=n,c=!1,[u,h]=me(s,r-1);for(let j=0;j<u.length;j++){if(j&&(d=c?d[l]:d[l]={}),l=u[j],(c=Object.hasOwn(d,l))&&(typeof d[l]!="object"||o.has(d[l])))throw new f("trying to redefine an already defined value",{toml:s,ptr:r});!c&&l==="__proto__"&&Object.defineProperty(d,l,{enumerable:!0,configurable:!0,writable:!0})}if(c)throw new f("trying to redefine an already defined value",{toml:s,ptr:r});let[p,x]=he(s,h,"}",t-1,a);o.add(p),d[l]=p,r=x}}if(!i)throw new f("unfinished table encountered",{toml:s,ptr:r});return[n,r]}function Zs(s,r,t,a){let n=[],o;for(r++;(o=s[r++])!=="]"&&o;){if(o===",")throw new f("expected value, found comma",{toml:s,ptr:r-1});if(o==="#")r=ee(s,r);else if(o!==" "&&o!==" "&&o!==`
|
|
26
|
-
`&&o!=="\r"){let i=he(s,r-1,"]",t-1,a);n.push(i[0]),r=i[1]}}if(!o)throw new f("unfinished array encountered",{toml:s,ptr:r});return[n,r]}function ye(s,r,t,a){let n=r,o=t,i,l=!1,d;for(let c=0;c<s.length;c++){if(c){if(n=l?n[i]:n[i]={},o=(d=o[i]).c,a===0&&(d.t===1||d.t===2))return null;if(d.t===2){let u=n.length-1;n=n[u],o=o[u].c}}if(i=s[c],(l=Object.hasOwn(n,i))&&o[i]?.t===0&&o[i]?.d)return null;l||(i==="__proto__"&&(Object.defineProperty(n,i,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(o,i,{enumerable:!0,configurable:!0,writable:!0})),o[i]={t:c<s.length-1&&a===2?3:a,d:!1,i:0,c:{}})}if(d=o[i],d.t!==a&&!(a===1&&d.t===3)||(a===2&&(d.d||(d.d=!0,n[i]=[]),n[i].push(n={}),d.c[d.i++]=d={t:1,d:!1,i:0,c:{}}),d.d))return null;if(d.d=!0,a===1)n=l?n[i]:n[i]={};else if(a===0&&l)return null;return[i,n,d.c]}function er(s,{maxDepth:r=1e3,integersAsBigInt:t}={}){let a={},n={},o=a,i=n;for(let l=K(s,0);l<s.length;){if(s[l]==="["){let d=s[++l]==="[",c=me(s,l+=+d,"]");if(d){if(s[c[1]-1]!=="]")throw new f("expected end of table declaration",{toml:s,ptr:c[1]-1});c[1]++}let u=ye(c[0],a,n,d?2:1);if(!u)throw new f("trying to redefine an already defined table or value",{toml:s,ptr:l});i=u[2],o=u[1],l=c[1]}else{let d=me(s,l),c=ye(d[0],o,i,0);if(!c)throw new f("trying to redefine an already defined table or value",{toml:s,ptr:l});let u=he(s,d[1],void 0,r,t);c[1][c[0]]=u[0],l=u[1]}if(l=K(s,l,!0),s[l]&&s[l]!==`
|
|
27
|
-
`&&s[l]!=="\r")throw new f("each key-value declaration must be followed by an end-of-line",{toml:s,ptr:l});l=K(s,l)}return a}function sr(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)}function rr(s){if(!s.trim())return{};const t=er(s);if(!sr(t))throw new Error("TOML root must be a table.");return t}function Oe(s){try{return{config:rr(s),parseError:null}}catch(r){return{config:null,parseError:r.message}}}async function tr(){const s=await fetch(J("/codex/diagnostics"));if(!s.ok)throw new Error("Failed to fetch Codex diagnostics");return s.json()}async function nr(){const s=await fetch(J("/codex/config/raw"));if(!s.ok)throw new Error("Failed to fetch Codex raw config");return s.json()}async function ar(s){const r=await fetch(J("/codex/config/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(r.status===409)throw new Ne("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 lr(s){const r=await fetch(J("/codex/config/patch"),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(r.status===409)throw new Ne("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 or(){const s=ds(),r=ve({queryKey:["codex-diagnostics"],queryFn:tr,refetchInterval:1e4}),t=ve({queryKey:["codex-raw-config"],queryFn:nr}),a=be({mutationFn:ar,onSuccess:(o,i)=>{s.setQueryData(["codex-raw-config"],l=>{const d=l?.path??"$CODEX_HOME/config.toml",c=l?.resolvedPath??d,u=Oe(i.rawText);return{path:d,resolvedPath:c,exists:!0,mtime:o.mtime,rawText:i.rawText,config:u.config,parseError:u.parseError,readError:null}}),s.invalidateQueries({queryKey:["codex-diagnostics"]})}}),n=be({mutationFn:lr,onSuccess:o=>{s.setQueryData(["codex-raw-config"],o),s.invalidateQueries({queryKey:["codex-diagnostics"]})}});return b.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:a.mutate,saveRawConfigAsync:a.mutateAsync,isSavingRawConfig:a.isPending,patchConfig:n.mutate,patchConfigAsync:n.mutateAsync,isPatchingConfig:n.isPending}),[r.data,r.isLoading,r.error,r.refetch,t.data,t.isLoading,t.error,t.refetch,a.mutate,a.mutateAsync,a.isPending,n.mutate,n.mutateAsync,n.isPending])}const ir=[{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=ir}){const[r,t]=b.useState(null),a=async(n,o)=>{await navigator.clipboard.writeText(n),t(o),setTimeout(()=>t(null),2e3)};return e.jsxs(L,{children:[e.jsx(D,{className:"pb-3",children:e.jsxs(R,{className:"text-lg flex items-center gap-2",children:[e.jsx(es,{className:"w-5 h-5 text-muted-foreground"}),"Quick Commands"]})}),e.jsx(A,{children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:s.map((n,o)=>e.jsxs("div",{className:Se("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(y,{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(ss,{className:"h-4 w-4 text-green-600"}):e.jsx(rs,{className:"h-4 w-4"})})]},o))})})]})}function dr(s){return!s||!Number.isFinite(s)?"N/A":new Date(s).toLocaleString()}function ur(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 N({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:Se("text-right break-all",t&&"font-mono text-xs"),children:r})]})}function mr({diagnostics:s}){const r=s.config.activeProfile?`codex --profile ${s.config.activeProfile}`:"codex";return e.jsx(xe,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 pr-1",children:[e.jsxs(L,{children:[e.jsx(D,{className:"pb-2",children:e.jsxs(R,{className:"flex items-center gap-2 text-base",children:[e.jsx(ts,{className:"h-4 w-4"}),"How Codex works in CCS"]})}),e.jsxs(A,{className:"space-y-2 text-sm text-muted-foreground",children:[e.jsx("p",{children:"Codex is a first-class runtime target in CCS, but it stays runtime-only in v1."}),e.jsxs("p",{children:[e.jsx("code",{children:"ccs-codex"})," and ",e.jsx("code",{children:"ccsx"})," launch native Codex against your saved native config, while ",e.jsx("code",{children:"ccsxp"})," is the opinionated shortcut for"," ",e.jsx("code",{children:"ccs codex --target codex"}),"."]}),e.jsxs("p",{children:["Plain ",e.jsx("code",{children:"codex"})," or a personal alias like ",e.jsx("code",{children:"cxp"})," needs"," ",e.jsx("code",{children:'model_provider = "cliproxy"'})," plus a matching"," ",e.jsx("code",{children:"[model_providers.cliproxy]"})," entry if you want CLIProxy as the saved native default."]}),e.jsxs("p",{children:["Built-in ",e.jsx("code",{children:"openai"})," and ",e.jsx("code",{children:"oss"})," providers are also valid native defaults and do not need a custom ",e.jsx("code",{children:"[model_providers]"})," stanza."]}),e.jsx("p",{children:"Saved default targets for API profiles and variants still remain on Claude or Droid."}),e.jsxs("p",{children:["CCS-backed Codex launches can apply transient ",e.jsx("code",{children:"-c"})," overrides and inject",e.jsx("code",{children:" CCS_CODEX_API_KEY"}),", so effective runtime values may not match this file exactly."]})]})]}),e.jsxs(L,{children:[e.jsx(D,{className:"pb-2",children:e.jsxs(R,{className:"flex items-center gap-2 text-base",children:[e.jsx(ns,{className:"h-4 w-4"}),"Runtime install"]})}),e.jsxs(A,{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:"Status"}),e.jsx(I,{variant:s.binary.installed?"default":"secondary",children:s.binary.installed?"Detected":"Not found"})]}),e.jsx(N,{label:"Detection source",value:s.binary.source,mono:!0}),e.jsx(N,{label:"Binary path",value:s.binary.path||"Not found",mono:!0}),e.jsx(N,{label:"Install directory",value:s.binary.installDir||"N/A",mono:!0}),e.jsx(N,{label:"Version",value:s.binary.version||"Unknown",mono:!0}),e.jsx(N,{label:"Native aliases",value:"ccs-codex, ccsx",mono:!0}),e.jsx(N,{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(I,{variant:s.binary.supportsConfigOverrides?"default":"secondary",children:s.binary.supportsConfigOverrides?"Available":"Missing"})]})]})]}),e.jsxs(L,{children:[e.jsx(D,{className:"pb-2",children:e.jsxs(R,{className:"flex items-center gap-2 text-base",children:[e.jsx(ce,{className:"h-4 w-4"}),"CLIProxy-backed native Codex"]})}),e.jsxs(A,{className:"space-y-3 text-sm text-muted-foreground",children:[e.jsxs("p",{children:["There are two supported paths. Use ",e.jsx("code",{children:"ccsxp"})," if you want the built-in CCS Codex provider shortcut. Use the saved recipe below if you want plain"," ",e.jsx("code",{children:"codex"})," or a personal alias like ",e.jsx("code",{children:"cxp"})," to default to CLIProxy."]}),e.jsxs("div",{className:"rounded-md border bg-muted/20 p-3",children:[e.jsx("p",{className:"font-medium text-foreground",children:"Saved native Codex recipe"}),e.jsx("pre",{className:"mt-2 overflow-x-auto rounded-md bg-background p-3 text-xs text-foreground",children:_e})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{children:["1. Save a provider named ",e.jsx("code",{children:"cliproxy"})," with the base URL and env key above."]}),e.jsxs("p",{children:["2. In ",e.jsx("strong",{children:"Top-level settings"}),", set ",e.jsx("strong",{children:"Default provider"})," to"," ",e.jsx("code",{children:"cliproxy"}),"."]}),e.jsxs("p",{children:["3. Export ",e.jsx("code",{children:"CLIPROXY_API_KEY"})," in your shell before launching native Codex."]})]})]})]}),e.jsxs(L,{children:[e.jsx(D,{className:"pb-2",children:e.jsxs(R,{className:"flex items-center gap-2 text-base",children:[e.jsx(as,{className:"h-4 w-4"}),"Config file"]})}),e.jsx(A,{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:"User config"}),s.file.exists?e.jsx(ls,{className:"h-4 w-4 text-green-600"}):e.jsx(os,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(N,{label:"Path",value:s.file.path,mono:!0}),e.jsx(N,{label:"Resolved",value:s.file.resolvedPath,mono:!0}),e.jsx(N,{label:"Size",value:ur(s.file.sizeBytes)}),e.jsx(N,{label:"Last modified",value:dr(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(L,{children:[e.jsx(D,{className:"pb-2",children:e.jsxs(R,{className:"flex items-center gap-2 text-base",children:[e.jsx(de,{className:"h-4 w-4"}),"Current user-layer summary"]})}),e.jsxs(A,{className:"space-y-3",children:[e.jsx(N,{label:"Model",value:s.config.model||"Not set",mono:!0}),e.jsx(N,{label:"Model provider",value:s.config.modelProvider||"Not set",mono:!0}),e.jsx(N,{label:"Active profile",value:s.config.activeProfile||"Not set",mono:!0}),e.jsx(N,{label:"Approval policy",value:s.config.approvalPolicy||"Not set",mono:!0}),e.jsx(N,{label:"Sandbox mode",value:s.config.sandboxMode||"Not set",mono:!0}),e.jsx(N,{label:"Web search",value:s.config.webSearch||"Not set",mono:!0}),e.jsx(Q,{}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[e.jsxs(I,{variant:"outline",className:"justify-center",children:["providers: ",s.config.modelProviderCount]}),e.jsxs(I,{variant:"outline",className:"justify-center",children:["profiles: ",s.config.profileCount]}),e.jsxs(I,{variant:"outline",className:"justify-center",children:["enabled features: ",s.config.enabledFeatures.length]}),e.jsxs(I,{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(t=>e.jsx(I,{variant:"secondary",className:"font-mono text-[10px]",children:t},t))})]})]})]}),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:"Run the built-in CCS Codex provider on native Codex."},{label:"Explicit provider route",command:'ccs codex --target codex "your prompt"',description:"Use the explicit built-in Codex provider route."},{label:s.config.activeProfile?"Inspect active profile":"Open native Codex",command:r,description:s.config.activeProfile?"Inspect the active named profile directly in native Codex.":"Open native Codex without forcing a named profile overlay."}]}),e.jsxs(L,{children:[e.jsx(D,{className:"pb-2",children:e.jsxs(R,{className:"flex items-center gap-2 text-base",children:[e.jsx(ce,{className:"h-4 w-4"}),"Runtime vs provider"]})}),e.jsxs(A,{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("div",{className:"rounded-md border p-3 text-sm",children:[e.jsx("p",{className:"font-medium",children:"Native Codex runtime"}),e.jsxs("p",{className:"mt-1 text-muted-foreground",children:["Use ",e.jsx("code",{children:"ccs-codex"}),", ",e.jsx("code",{children:"ccsx"}),", or ",e.jsx("code",{children:"--target codex"})," when you want the local Codex CLI to honor your saved native user config."]})]}),e.jsxs("div",{className:"rounded-md border p-3 text-sm",children:[e.jsx("p",{className:"font-medium",children:"CCS Codex provider / bridge"}),e.jsxs("p",{className:"mt-1 text-muted-foreground",children:["Use ",e.jsx("code",{children:"ccsxp"})," or ",e.jsx("code",{children:"ccs codex --target codex"})," when you want the built-in CCS Codex provider on native Codex. That path uses transient CCS-managed overrides and is separate from the saved ",e.jsx("code",{children:"cliproxy"})," recipe above."]})]})]})]}),e.jsxs(L,{children:[e.jsx(D,{className:"pb-2",children:e.jsx(R,{className:"text-base",children:"Supported flows"})}),e.jsx(A,{children:e.jsxs(us,{children:[e.jsx(ms,{children:e.jsxs(we,{children:[e.jsx(ne,{children:"Flow"}),e.jsx(ne,{children:"Status"}),e.jsx(ne,{children:"Notes"})]})}),e.jsx(xs,{children:s.supportMatrix.map(t=>e.jsxs(we,{children:[e.jsx(ae,{className:"font-mono text-xs",children:t.label}),e.jsx(ae,{children:e.jsx(I,{variant:t.supported?"default":"secondary",children:t.supported?"Yes":"No"})}),e.jsx(ae,{className:"text-xs text-muted-foreground",children:t.notes})]},t.id))})]})})]}),s.warnings.length>0&&e.jsxs(L,{className:"border-amber-200 bg-amber-50/50 dark:bg-amber-950/20",children:[e.jsx(D,{className:"pb-2",children:e.jsxs(R,{className:"flex items-center gap-2 text-base",children:[e.jsx(is,{className:"h-4 w-4 text-amber-600"}),"Warnings"]})}),e.jsx(A,{className:"space-y-1.5",children:s.warnings.map(t=>e.jsxs("p",{className:"text-sm text-amber-800 dark:text-amber-300",children:["- ",t]},t))})]})]})})}function _r(){const{diagnostics:s,diagnosticsLoading:r,diagnosticsError:t,refetchDiagnostics:a,rawConfig:n,rawConfigLoading:o,rawConfigError:i,refetchRawConfig:l,saveRawConfigAsync:d,isSavingRawConfig:c,patchConfigAsync:u,isPatchingConfig:h}=or(),[p,x]=b.useState(null),j=n?.rawText??"",m=p??j,v=p!==null&&p!==j,H=Oe(m),U=H.parseError?{valid:!1,error:H.parseError}:{valid:!0},_=n?.config??null,w=o||!n||v||n?.parseError!==null||n?.readError!==null,Le=i?"Structured controls unavailable: failed to load the current config.toml.":n?.readError?`Structured controls unavailable: ${n.readError}`:v?U.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,De=b.useMemo(()=>Ee(_),[_]),Re=b.useMemo(()=>Os(_),[_]),Ae=b.useMemo(()=>Ls(_),[_]),Me=b.useMemo(()=>Ds(_),[_]),Ie=b.useMemo(()=>Rs(_),[_]),Ue=b.useMemo(()=>As(_),[_]),Fe=M=>{if(M===j){x(null);return}x(M)},Ke=async()=>{try{if((await Promise.all([a(),l()])).some(q=>!q||q.status==="error"||q.isError||q.error)){F.error("Failed to refresh Codex snapshot. Raw edits were kept.");return}x(null)}catch(M){F.error(M.message||"Failed to refresh Codex snapshot.")}},Ve=async()=>{if(!U.valid){F.error("Fix TOML before saving.");return}try{await d({rawText:m,expectedMtime:n?.exists?n.mtime:void 0}),x(null),F.success("Saved Codex config.toml."),await a()}catch(M){je(M)?F.error("config.toml changed externally. Refresh and retry."):F.error(M.message||"Failed to save Codex config.toml.")}},qe=async(M,fe)=>{try{await u({...M,expectedMtime:n?.exists?n.mtime:void 0}),x(null),F.success(fe)}catch(q){je(q)?F.error("config.toml changed externally. Refresh and retry."):F.error(q.message||"Failed to update Codex config.")}},se="mt-0 h-full border-0 p-0 data-[state=inactive]:hidden",$e=()=>r?e.jsxs("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:[e.jsx($,{className:"mr-2 h-5 w-5 animate-spin"}),"Loading Codex diagnostics..."]}):t||!s?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(Xe,{defaultValue:"overview",className:"flex h-full flex-col",children:[e.jsx("div",{className:"shrink-0 px-4 pt-4",children:e.jsxs(Be,{className:"grid w-full grid-cols-3",children:[e.jsx(re,{value:"overview",children:"Overview"}),e.jsx(re,{value:"controls",children:"Control Center"}),e.jsx(re,{value:"docs",children:"Docs"})]})}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden px-4 pb-4 pt-3",children:[e.jsx(te,{value:"overview",className:se,children:e.jsx(mr,{diagnostics:s})}),e.jsx(te,{value:"controls",className:se,children:e.jsx(Ps,{workspacePath:s.workspacePath,activeProfile:s.config.activeProfile,topLevelSettings:De,projectTrustEntries:Re,profileEntries:Ae,modelProviderEntries:Me,mcpServerEntries:Ie,featureCatalog:Te,featureState:Ue,disabled:w,disabledReason:Le,saving:h,onPatch:qe})}),e.jsx(te,{value:"docs",className:se,children:e.jsx(Fs,{diagnostics:s})})]})]});return e.jsx("div",{className:"h-full min-h-0 overflow-hidden",children:e.jsxs(ze,{direction:"horizontal",className:"h-full",children:[e.jsx(pe,{defaultSize:45,minSize:35,children:e.jsx("div",{className:"h-full border-r bg-muted/20",children:$e()})}),e.jsx(Ye,{className:"group flex w-2 cursor-col-resize items-center justify-center bg-border transition-colors hover:bg-primary/20",children:e.jsx(cs,{className:"h-3 w-3 text-muted-foreground group-hover:text-primary"})}),e.jsx(pe,{defaultSize:55,minSize:35,children:e.jsx(hs,{title:"Codex config.toml",pathLabel:n?.path||s?.file.path||"$CODEX_HOME/config.toml",loading:o,parseWarning:U.valid?n?.parseError:U.error,readWarning:n?.readError,value:m,dirty:v,readOnly:!!n?.readError,saving:c,saveDisabled:!v||c||o||!U.valid||!!n?.readError,onChange:M=>{Fe(M)},onSave:Ve,onRefresh:Ke,onDiscard:()=>x(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{_r as CodexPage};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Dt3edmE5.js";import{b7 as w,b8 as Pe,B as S,d as N,a as ie,V as ne,n as G,L as T,I as ce,r as ke,s as Fe,t as Te,v as Me,w as X,x as he,b9 as Le,S as b,ba as Re,bb as Ae,bc as Oe,Q as Ee,R as _e,U as Y,bd as qe,c as se}from"./index-DAtuJuGe.js";import{r as v}from"./react-vendor-CNOkPC89.js";import{a as De,u as _,b as M}from"./tanstack-B8i0evp-.js";import{C as Ie}from"./confirm-dialog-B9vRgowr.js";import{R as ge,L as fe,ak as Ke,a4 as Ue,Z as de,O as Qe,T as je,an as $e,b as Je,a7 as ze,at as Be,aH as me,K as He,N as Ge,aI as Ve,v as ve,w as we}from"./icons-EMBHZkGo.js";import{S as ae}from"./separator--ZH5ZM-3.js";import{S as We}from"./searchable-select-ULayr5K1.js";import{S as Z}from"./switch-DmDIWykO.js";import{t as q}from"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-CiYMglgR.js";async function Xe(){const t=await fetch(w("/copilot/status"));if(!t.ok)throw new Error("Failed to fetch copilot status");return t.json()}async function Ye(){const t=await fetch(w("/copilot/config"));if(!t.ok)throw new Error("Failed to fetch copilot config");return t.json()}async function Ze(){const t=await fetch(w("/copilot/models"));if(!t.ok)throw new Error("Failed to fetch copilot models");return t.json()}async function et(){const t=await fetch(w("/copilot/settings/raw"));if(!t.ok)throw new Error("Failed to fetch copilot raw settings");return t.json()}async function tt(t){const s=await fetch(w("/copilot/config"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!s.ok)throw new Error("Failed to update copilot config");return s.json()}async function st(t){const s=await fetch(w("/copilot/settings/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(s.status===409)throw new Pe("Copilot raw settings changed externally");if(!s.ok)throw new Error("Failed to save copilot raw settings");return s.json()}async function at(){const t=await fetch(w("/copilot/auth/start"),{method:"POST"});if(!t.ok)throw new Error("Failed to start auth");return t.json()}async function it(){const t=await fetch(w("/copilot/daemon/start"),{method:"POST"});if(!t.ok)throw new Error("Failed to start daemon");return t.json()}async function nt(){const t=await fetch(w("/copilot/daemon/stop"),{method:"POST"});if(!t.ok)throw new Error("Failed to stop daemon");return t.json()}async function ot(){const t=await fetch(w("/copilot/info"));if(!t.ok)throw new Error("Failed to fetch copilot info");return t.json()}async function lt(t){const s=await fetch(w("/copilot/install"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t?{version:t}:{})});if(!s.ok)throw new Error("Failed to install copilot-api");return s.json()}function Ne(){const t=De(),s=_({queryKey:["copilot-status"],queryFn:Xe,refetchInterval:5e3}),l=_({queryKey:["copilot-config"],queryFn:Ye}),c=_({queryKey:["copilot-models"],queryFn:Ze}),i=_({queryKey:["copilot-raw-settings"],queryFn:et}),d=_({queryKey:["copilot-info"],queryFn:ot}),r=M({mutationFn:tt,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]}),t.invalidateQueries({queryKey:["copilot-config"]}),t.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),n=M({mutationFn:st,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]}),t.invalidateQueries({queryKey:["copilot-config"]}),t.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),x=M({mutationFn:at,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]})}}),p=M({mutationFn:it,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]})}}),g=M({mutationFn:nt,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]})}}),o=M({mutationFn:lt,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]}),t.invalidateQueries({queryKey:["copilot-info"]})}});return v.useMemo(()=>({status:s.data,statusLoading:s.isLoading,statusError:s.error,refetchStatus:s.refetch,config:l.data,configLoading:l.isLoading,models:c.data?.models??[],currentModel:c.data?.current,modelsLoading:c.isLoading,rawSettings:i.data,rawSettingsLoading:i.isLoading,refetchRawSettings:i.refetch,updateConfig:r.mutate,updateConfigAsync:r.mutateAsync,isUpdating:r.isPending,saveRawSettings:n.mutate,saveRawSettingsAsync:n.mutateAsync,isSavingRawSettings:n.isPending,startAuth:x.mutate,startAuthAsync:x.mutateAsync,isAuthenticating:x.isPending,authResult:x.data,startDaemon:p.mutate,isStartingDaemon:p.isPending,stopDaemon:g.mutate,isStoppingDaemon:g.isPending,info:d.data,infoLoading:d.isLoading,refetchInfo:d.refetch,install:o.mutate,installAsync:o.mutateAsync,isInstalling:o.isPending}),[s.data,s.isLoading,s.error,s.refetch,l.data,l.isLoading,c.data,c.isLoading,i.data,i.isLoading,i.refetch,r.mutate,r.mutateAsync,r.isPending,n.mutate,n.mutateAsync,n.isPending,x.mutate,x.mutateAsync,x.isPending,x.data,p.mutate,p.isPending,g.mutate,g.isPending,d.data,d.isLoading,d.refetch,o.mutate,o.mutateAsync,o.isPending])}function rt({rawSettings:t,rawSettingsLoading:s,isUpdating:l,isSavingRawSettings:c,hasChanges:i,isRawJsonValid:d,onRefresh:r,onSave:n}){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:"Copilot Configuration"}),t&&e.jsx(S,{variant:"outline",className:"text-xs",children:"copilot.settings.json"})]}),t&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified:"," ",t.exists?new Date(t.mtime).toLocaleString():"Never saved"]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(N,{variant:"ghost",size:"sm",onClick:r,disabled:s,children:e.jsx(ge,{className:`w-4 h-4 ${s?"animate-spin":""}`})}),e.jsx(N,{size:"sm",onClick:n,disabled:l||c||!i||!d,children:l||c?e.jsxs(e.Fragment,{children:[e.jsx(fe,{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 ct=[{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"}],dt=[{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 ue(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 mt(t){return t==null?null:t===0?"Free":t<1?`${t}x`:t===1?"1x":`${t}x`}function z({label:t,description:s,value:l,onChange:c,models:i,disabled:d}){const{t:r}=ie();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(We,{value:l||void 0,onChange:c,disabled:d,placeholder:r("componentModelSelector.selectModel"),searchPlaceholder:r("searchableSelect.searchModels"),emptyText:r("searchableSelect.noResults"),triggerClassName:"h-9",groups:[{key:"models",label:r("componentModelSelector.availableModelsCount",{count:i.length})}],options:i.map(n=>({value:n.id,groupKey:"models",searchText:`${n.name||n.id} ${n.id}`,keywords:[n.minPlan??"",n.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:n.id}),n.minPlan&&e.jsx(S,{variant:"outline",className:`text-[9px] px-1 py-0 h-4 ${ue(n.minPlan)}`,children:n.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:n.name||n.id}),n.minPlan&&e.jsx(S,{variant:"outline",className:`text-[9px] px-1 py-0 h-4 ${ue(n.minPlan)}`,children:n.minPlan}),n.multiplier!==void 0&&e.jsx("span",{className:"text-[9px] text-muted-foreground",children:mt(n.multiplier)}),n.preview&&e.jsx(S,{variant:"secondary",className:"text-[9px] px-1 py-0 h-4",children:r("componentModelSelector.preview")})]})}))})]})}function ee(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 ut(t){if(!t?.limits)return null;const s=[];return t.limits.maxPromptTokens&&s.push(`prompt ${ee(t.limits.maxPromptTokens)}`),t.limits.maxContextWindowTokens&&s.push(`context ${ee(t.limits.maxContextWindowTokens)}`),t.limits.maxOutputTokens&&s.push(`output ${ee(t.limits.maxOutputTokens)}`),s.length>0?s.join(" | "):null}function xt({currentModel:t,opusModel:s,sonnetModel:l,haikuModel:c,models:i,modelsLoading:d,onApplyPreset:r,onUpdateModel:n,onUpdateOpusModel:x,onUpdateSonnetModel:p,onUpdateHaikuModel:g}){const o=[{label:"Default",id:t},{label:"Opus",id:s||t},{label:"Sonnet",id:l||t},{label:"Haiku",id:c||t}].map(({label:a,id:u})=>{const y=i.find(P=>P.id===u),C=ut(y);return C?{label:a,id:u,limits:C}:null}).filter(a=>a!==null);return e.jsx(ne,{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(Ue,{className:"w-4 h-4"}),"Presets"]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"Apply pre-configured model mappings"}),e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(S,{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:"No premium usage count"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:ct.map(a=>e.jsxs(N,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>r(a),title:a.description,children:[e.jsx(de,{className:"w-3 h-3 text-green-600"}),a.name]},a.name))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(S,{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:dt.map(a=>e.jsxs(N,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>r(a),title:a.description,children:[e.jsx(de,{className:"w-3 h-3"}),a.name]},a.name))})]})]}),e.jsx(ae,{}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-2",children:"Model Mapping"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"Configure which models to use for each tier"}),e.jsxs("div",{className:"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:"GitHub Copilot controls prompt/context limits upstream."}),e.jsx("p",{className:"mt-1",children:"CCS can switch Copilot models, but it cannot increase the provider's max prompt or context window."}),o.length>0?e.jsx("div",{className:"mt-2 space-y-1 text-[11px] font-mono",children:o.map(a=>e.jsxs("p",{children:[a.label,": ",a.id," (",a.limits,")"]},`${a.label}-${a.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(z,{label:"Default Model",description:"Used when no specific tier is requested",value:t,onChange:n,models:i,disabled:d}),e.jsx(z,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:s||t,onChange:x,models:i,disabled:d}),e.jsx(z,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:l||t,onChange:p,models:i,disabled:d}),e.jsx(z,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:c||t,onChange:g,models:i,disabled:d})]})]})]})})})}function pt({enabled:t,autoStart:s,port:l,accountType:c,rateLimit:i,waitOnLimit:d,onUpdateEnabled:r,onUpdateAutoStart:n,onUpdatePort:x,onUpdateAccountType:p,onUpdateRateLimit:g,onUpdateWaitOnLimit:o}){const{t:a}=ie();return e.jsx(ne,{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.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(T,{htmlFor:"enabled",className:"text-sm font-medium",children:a("copilotSettings.enableCopilot")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("copilotSettings.enableCopilotDesc")})]}),e.jsx(Z,{id:"enabled",checked:t,onCheckedChange:r})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:a("copilotSettings.basicSettings")}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"port",className:"text-xs",children:a("copilotPage.port")}),e.jsx(ce,{id:"port",type:"number",value:l,onChange:u=>x(parseInt(u.target.value,10)),min:1024,max:65535,className:"max-w-[150px] h-8"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"account-type",className:"text-xs",children:a("copilotSettings.accountType")}),e.jsxs(ke,{value:c,onValueChange:p,children:[e.jsx(Fe,{id:"account-type",className:"max-w-[150px] h-8",children:e.jsx(Te,{})}),e.jsxs(Me,{children:[e.jsx(X,{value:"individual",children:a("copilotSettings.accountTypeIndividual")}),e.jsx(X,{value:"business",children:a("copilotSettings.accountTypeBusiness")}),e.jsx(X,{value:"enterprise",children:a("copilotSettings.accountTypeEnterprise")})]})]})]})]}),e.jsx(ae,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:a("copilotSettings.rateLimiting")}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"rate-limit",className:"text-xs",children:a("copilotSettings.rateLimitSeconds")}),e.jsx(ce,{id:"rate-limit",type:"number",value:i,onChange:u=>g(u.target.value),placeholder:a("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(T,{htmlFor:"wait-on-limit",className:"text-xs",children:a("copilotSettings.waitOnRateLimit")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a("copilotSettings.waitOnRateLimitDesc")})]}),e.jsx(Z,{id:"wait-on-limit",checked:d,onCheckedChange:o})]})]}),e.jsx(ae,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:a("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(T,{htmlFor:"auto-start",className:"text-xs",children:a("copilotSettings.autoStartDaemon")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a("copilotSettings.autoStartDaemonDesc")})]}),e.jsx(Z,{id:"auto-start",checked:s,onCheckedChange:n})]})]})]})})})}function B({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(he,{value:s,size:"icon",className:"h-6 w-6"})]})]})}function ht({rawSettings:t}){return e.jsx(ne,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(G,{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(Qe,{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:"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:"File Path"}),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(he,{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:"Status"}),e.jsx(S,{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:"Quick Usage"}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsx(B,{label:"Run with Copilot",command:"ccs copilot"}),e.jsx(B,{label:"Authenticate",command:"ccs copilot auth"}),e.jsx(B,{label:"Start daemon",command:"ccs copilot --start"}),e.jsx(B,{label:"Stop daemon",command:"ccs copilot --stop"})]})]})]})})})}const gt=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"];function xe(t){const s=t?.env||{};return gt.filter(l=>!s[l]?.trim())}function pe(t){if(!t||t.length===0)return[];const s=new Map;return t.forEach(l=>{s.set(l.message,l)}),[...s.values()]}function ft(){const{config:t,configLoading:s,models:l,modelsLoading:c,rawSettings:i,rawSettingsLoading:d,updateConfigAsync:r,isUpdating:n,saveRawSettingsAsync:x,isSavingRawSettings:p,refetchRawSettings:g}=Ne(),[o,a]=v.useState({}),[u,y]=v.useState(null),[C,P]=v.useState(!1),D=o.enabled??t?.enabled??!1,I=o.autoStart??t?.auto_start??!1,L=o.port??t?.port??4141,K=o.accountType??t?.account_type??"individual",R=o.model??t?.model??"claude-sonnet-4-6",A=o.rateLimit??t?.rate_limit?.toString()??"",f=o.waitOnLimit??t?.wait_on_limit??!0,U=o.opusModel??t?.opus_model??"",Q=o.sonnetModel??t?.sonnet_model??"",$=o.haikuModel??t?.haiku_model??"",J=(h,j)=>{a(O=>({...O,[h]:j}))},V=h=>{a(j=>({...j,model:h.default,opusModel:h.opus,sonnetModel:h.sonnet,haikuModel:h.haiku})),q.success(`Applied "${h.name}" preset`)},k=v.useMemo(()=>u!==null?u:i?.settings?JSON.stringify(i.settings,null,2):`{
|
|
2
|
-
"env": {}
|
|
3
|
-
}`,[u,i]),m=v.useCallback(h=>{y(h)},[]),oe=v.useMemo(()=>{try{return JSON.parse(k),!0}catch{return!1}},[k]),be=v.useMemo(()=>{const h=Object.keys(o).length>0,j=u!==null&&u!==JSON.stringify(i?.settings,null,2);return h||j},[o,u,i]),le=v.useMemo(()=>{if(u!==null)try{return JSON.parse(u)}catch{return i?.settings}return i?.settings},[u,i?.settings]),ye=v.useMemo(()=>xe(le),[le]),Se=v.useMemo(()=>pe([...t?.warnings??[],...i?.warnings??[]]),[t?.warnings,i?.warnings]),re=async({overwriteRawSettings:h=!1}={})=>{try{const j=[];if(Object.keys(o).length>0){const F=await r({enabled:D,auto_start:I,port:L,account_type:K,model:R,rate_limit:A?parseInt(A,10):null,wait_on_limit:f,opus_model:U||void 0,sonnet_model:Q||void 0,haiku_model:$||void 0});j.push(...F.warnings??[])}let O=[];if(u!==null&&oe){const F=JSON.parse(k);O=xe(F);const Ce=await x({settings:F,expectedMtime:h?void 0:i?.mtime});j.push(...Ce.warnings??[])}const W=pe(j),E=[];W.length>0&&E.push(W.map(F=>F.message).join(" ")),O.length>0&&E.push(`Missing fields will use defaults: ${O.join(", ")}`),W.length>0?q.warning("Copilot configuration saved with model adjustments",{description:E.join(" ")}):E.length>0?q.success("Copilot configuration saved",{description:E.join(" ")}):q.success("Copilot configuration saved"),a({}),y(null)}catch(j){Le(j)?P(!0):q.error("Failed to save settings")}};return{configLoading:s,rawSettingsLoading:d,modelsLoading:c,isUpdating:n,isSavingRawSettings:p,models:l,rawSettings:i,rawJsonContent:k,rawJsonEdits:u,enabled:D,autoStart:I,port:L,accountType:K,currentModel:R,rateLimit:A,waitOnLimit:f,opusModel:U,sonnetModel:Q,haikuModel:$,isRawJsonValid:oe,hasChanges:be,normalizationWarnings:Se,conflictDialog:C,updateField:J,applyPreset:V,handleRawJsonChange:m,handleSave:re,handleConflictResolve:async h=>{P(!1),h?await re({overwriteRawSettings:!0}):y(null)},refetchRawSettings:g,missingRequiredFields:ye}}function jt(){const{configLoading:t,rawSettingsLoading:s,modelsLoading:l,isUpdating:c,isSavingRawSettings:i,models:d,rawSettings:r,rawJsonContent:n,rawJsonEdits:x,enabled:p,autoStart:g,port:o,accountType:a,currentModel:u,rateLimit:y,waitOnLimit:C,opusModel:P,sonnetModel:D,haikuModel:I,isRawJsonValid:L,hasChanges:K,normalizationWarnings:R,conflictDialog:A,updateField:f,applyPreset:U,handleRawJsonChange:Q,handleSave:$,handleConflictResolve:J,refetchRawSettings:V,missingRequiredFields:k}=ft();return t||s?e.jsxs("div",{className:"space-y-6",children:[e.jsx(b,{className:"h-10 w-full"}),e.jsx(b,{className:"h-10 w-full"}),e.jsx(b,{className:"h-10 w-full"}),e.jsx(b,{className:"h-10 w-full"})]}):e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(rt,{rawSettings:r,rawSettingsLoading:s,isUpdating:c,isSavingRawSettings:i,hasChanges:K,isRawJsonValid:L,onRefresh:()=>V(),onSave:$}),R.length>0&&e.jsx("div",{className:"px-6 pt-4 shrink-0",children:e.jsxs(Re,{variant:"warning",children:[e.jsx(je,{className:"h-4 w-4"}),e.jsx(Ae,{children:"Deprecated Copilot models detected"}),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:R.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(Ee,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(_e,{className:"w-full",children:[e.jsx(Y,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(Y,{value:"settings",className:"flex-1",children:"Settings"}),e.jsx(Y,{value:"info",className:"flex-1",children:"Info"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsx(xt,{currentModel:u,opusModel:P,sonnetModel:D,haikuModel:I,models:d,modelsLoading:l,onApplyPreset:U,onUpdateModel:m=>f("model",m),onUpdateOpusModel:m=>f("opusModel",m),onUpdateSonnetModel:m=>f("sonnetModel",m),onUpdateHaikuModel:m=>f("haikuModel",m)}),e.jsx(pt,{enabled:p,autoStart:g,port:o,accountType:a,rateLimit:y,waitOnLimit:C,onUpdateEnabled:m=>f("enabled",m),onUpdateAutoStart:m=>f("autoStart",m),onUpdatePort:m=>f("port",m),onUpdateAccountType:m=>f("accountType",m),onUpdateRateLimit:m=>f("rateLimit",m),onUpdateWaitOnLimit:m=>f("waitOnLimit",m)}),e.jsx(ht,{rawSettings:r})]})]})})}),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(qe,{rawJsonContent:n,isRawJsonValid:L,rawJsonEdits:x,rawSettingsEnv:r?.settings?.env,onChange:Q,missingRequiredFields:k})]})]}),e.jsx(Ie,{open:A,title:"File Modified Externally",description:"This settings file was modified by another process. Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>J(!0),onCancel:()=>J(!1)})]})}function te({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 H({icon:t,label:s,status:l,statusText:c,variant:i="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:l?e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:se("w-4 h-4",i==="warning"?"text-yellow-500":"text-green-500")}),e.jsx("span",{className:se("text-xs",i==="warning"?"text-yellow-500":"text-green-500"),children:c||"Yes"})]}):e.jsxs(e.Fragment,{children:[e.jsx(we,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:c||"No"})]})})]})}function vt(){return e.jsxs("div",{className:"space-y-4 p-4",children:[e.jsx(b,{className:"h-8 w-full"}),e.jsx(b,{className:"h-12 w-full"}),e.jsx(b,{className:"h-12 w-full"}),e.jsx(b,{className:"h-12 w-full"})]})}function Et(){const{t}=ie(),{status:s,statusLoading:l,refetchStatus:c,startAuth:i,isAuthenticating:d,startDaemon:r,isStartingDaemon:n,stopDaemon:x,isStoppingDaemon:p,install:g,isInstalling:o}=Ne();return e.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col bg-muted/30 shrink-0",children:[e.jsxs("div",{className:"p-4 border-b bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Je,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:t("copilotPage.title")})]}),e.jsx(N,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>c(),disabled:l,children:e.jsx(ge,{className:se("w-4 h-4",l&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("copilotPage.subtitle")})]}),e.jsx(G,{className:"flex-1",children:l?e.jsx(vt,{}):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(je,{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(te,{title:t("copilotPage.setup"),children:[e.jsx(H,{icon:ze,label:"copilot-api",status:s?.installed??!1,statusText:s?.installed?s.version?`v${s.version}`:t("copilotPage.installed"):t("copilotPage.missing")}),!s?.installed&&e.jsx(N,{size:"sm",className:"w-full mt-2",onClick:()=>g(void 0),disabled:o,children:o?e.jsxs(e.Fragment,{children:[e.jsx(fe,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}),t("copilotPage.installing")]}):e.jsxs(e.Fragment,{children:[e.jsx(Be,{className:"w-3.5 h-3.5 mr-1.5"}),t("copilotPage.installCopilotApi")]})}),s?.installed&&e.jsx(H,{icon:me,label:t("copilotPage.integration"),status:s?.enabled??!1,statusText:s?.enabled?t("copilotPage.enabled"):t("copilotPage.disabled")})]}),s?.installed&&e.jsxs(te,{title:t("copilotPage.auth"),children:[e.jsx(H,{icon:He,label:t("copilotPage.github"),status:s?.authenticated??!1,statusText:s?.authenticated?t("copilotPage.connected"):t("copilotPage.notConnected")}),!s?.authenticated&&e.jsx(N,{size:"sm",className:"w-full mt-2",onClick:()=>i(),disabled:d,children:t(d?"copilotPage.authenticating":"copilotPage.authenticate")})]}),s?.authenticated&&e.jsxs(te,{title:t("copilotPage.daemon"),children:[e.jsx(H,{icon:Ge,label:t("copilotPage.status"),status:s?.daemon_running??!1,statusText:s?.daemon_running?t("copilotPage.running"):t("copilotPage.stopped")}),e.jsxs("div",{className:"px-3 py-1 text-xs text-muted-foreground",children:[t("copilotPage.port"),": ",s?.port??4141]}),e.jsx("div",{className:"px-1",children:s?.daemon_running?e.jsxs(N,{size:"sm",variant:"outline",className:"w-full",onClick:()=>x(),disabled:p,children:[e.jsx(Ve,{className:"w-3.5 h-3.5 mr-1.5"}),t(p?"copilotPage.stopping":"copilotPage.stop")]}):e.jsxs(N,{size:"sm",variant:"outline",className:"w-full",onClick:()=>r(),disabled:n,children:[e.jsx(me,{className:"w-3.5 h-3.5 mr-1.5"}),t(n?"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(ve,{className:"w-3 h-3 text-green-500"}),t("copilotPage.active")]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(we,{className:"w-3 h-3 text-muted-foreground"}),t("copilotPage.inactive")]})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-background overflow-hidden",children:e.jsx(jt,{})})]})}export{Et as CopilotPage};
|