@kaitranntt/ccs 7.68.2 → 7.69.1-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/commands/create-command-env.d.ts +1 -0
- package/dist/auth/commands/create-command-env.d.ts.map +1 -1
- package/dist/ccs.js +55 -2
- package/dist/ccs.js.map +1 -1
- package/dist/channels/official-channels-runtime.d.ts +1 -0
- package/dist/channels/official-channels-runtime.d.ts.map +1 -1
- package/dist/channels/official-channels-store.d.ts +1 -0
- package/dist/channels/official-channels-store.d.ts.map +1 -1
- package/dist/cliproxy/base-config-loader.d.ts +1 -0
- package/dist/cliproxy/base-config-loader.d.ts.map +1 -1
- package/dist/cliproxy/config/env-builder.d.ts +1 -0
- package/dist/cliproxy/config/env-builder.d.ts.map +1 -1
- package/dist/cliproxy/config/extended-context-config.d.ts +1 -0
- package/dist/cliproxy/config/extended-context-config.d.ts.map +1 -1
- package/dist/cliproxy/config/thinking-config.d.ts +1 -0
- package/dist/cliproxy/config/thinking-config.d.ts.map +1 -1
- package/dist/cliproxy/executor/env-resolver.d.ts +2 -0
- package/dist/cliproxy/executor/env-resolver.d.ts.map +1 -1
- package/dist/cliproxy/executor/env-resolver.js +2 -1
- 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 +28 -1
- package/dist/cliproxy/executor/index.js.map +1 -1
- package/dist/cliproxy/model-id-normalizer.d.ts +1 -0
- package/dist/cliproxy/model-id-normalizer.d.ts.map +1 -1
- package/dist/cliproxy/routing-strategy-http.d.ts +1 -0
- package/dist/cliproxy/routing-strategy-http.d.ts.map +1 -1
- package/dist/cliproxy/tool-sanitization-proxy.d.ts.map +1 -1
- package/dist/cliproxy/tool-sanitization-proxy.js +0 -3
- package/dist/cliproxy/tool-sanitization-proxy.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/catalog-subcommand.d.ts +6 -0
- package/dist/commands/cliproxy/catalog-subcommand.d.ts.map +1 -1
- package/dist/commands/cliproxy/catalog-subcommand.js +39 -1
- package/dist/commands/cliproxy/catalog-subcommand.js.map +1 -1
- package/dist/commands/cliproxy/help-subcommand.d.ts.map +1 -1
- package/dist/commands/cliproxy/help-subcommand.js +1 -0
- package/dist/commands/cliproxy/help-subcommand.js.map +1 -1
- package/dist/commands/cliproxy/index.d.ts.map +1 -1
- package/dist/commands/cliproxy/index.js +6 -0
- package/dist/commands/cliproxy/index.js.map +1 -1
- package/dist/commands/command-catalog.d.ts +1 -1
- package/dist/commands/command-catalog.d.ts.map +1 -1
- package/dist/commands/cursor-command-display.d.ts +2 -0
- package/dist/commands/cursor-command-display.d.ts.map +1 -1
- package/dist/commands/cursor-command-display.js +24 -3
- package/dist/commands/cursor-command-display.js.map +1 -1
- package/dist/commands/cursor-command.d.ts.map +1 -1
- package/dist/commands/cursor-command.js +31 -1
- package/dist/commands/cursor-command.js.map +1 -1
- package/dist/commands/update-command.d.ts +2 -0
- package/dist/commands/update-command.d.ts.map +1 -1
- package/dist/commands/update-command.js +76 -74
- package/dist/commands/update-command.js.map +1 -1
- package/dist/config/migration-manager.d.ts.map +1 -1
- package/dist/config/migration-manager.js +2 -1
- package/dist/config/migration-manager.js.map +1 -1
- package/dist/config/unified-config-loader.d.ts +8 -3
- package/dist/config/unified-config-loader.d.ts.map +1 -1
- package/dist/config/unified-config-loader.js +20 -7
- package/dist/config/unified-config-loader.js.map +1 -1
- package/dist/config/unified-config-types.d.ts +15 -2
- package/dist/config/unified-config-types.d.ts.map +1 -1
- package/dist/config/unified-config-types.js +8 -3
- package/dist/config/unified-config-types.js.map +1 -1
- package/dist/cursor/constants.d.ts +1 -1
- package/dist/cursor/constants.d.ts.map +1 -1
- package/dist/cursor/constants.js +1 -0
- package/dist/cursor/constants.js.map +1 -1
- package/dist/cursor/cursor-anthropic-response.d.ts +1 -0
- package/dist/cursor/cursor-anthropic-response.d.ts.map +1 -1
- package/dist/cursor/cursor-auth.d.ts +1 -0
- package/dist/cursor/cursor-auth.d.ts.map +1 -1
- package/dist/cursor/cursor-auth.js +154 -32
- package/dist/cursor/cursor-auth.js.map +1 -1
- package/dist/cursor/cursor-executor.d.ts +2 -1
- package/dist/cursor/cursor-executor.d.ts.map +1 -1
- package/dist/cursor/cursor-executor.js +295 -160
- package/dist/cursor/cursor-executor.js.map +1 -1
- package/dist/cursor/cursor-protobuf-decoder.d.ts.map +1 -1
- package/dist/cursor/cursor-protobuf-decoder.js +1 -3
- package/dist/cursor/cursor-protobuf-decoder.js.map +1 -1
- package/dist/cursor/cursor-protobuf-schema.d.ts +12 -3
- package/dist/cursor/cursor-protobuf-schema.d.ts.map +1 -1
- package/dist/cursor/cursor-protobuf-schema.js +23 -5
- package/dist/cursor/cursor-protobuf-schema.js.map +1 -1
- package/dist/cursor/cursor-protobuf.d.ts +1 -1
- package/dist/cursor/cursor-protobuf.d.ts.map +1 -1
- package/dist/cursor/cursor-protobuf.js +2 -4
- package/dist/cursor/cursor-protobuf.js.map +1 -1
- package/dist/cursor/cursor-runtime-probe.d.ts +12 -0
- package/dist/cursor/cursor-runtime-probe.d.ts.map +1 -0
- package/dist/cursor/cursor-runtime-probe.js +220 -0
- package/dist/cursor/cursor-runtime-probe.js.map +1 -0
- package/dist/cursor/cursor-stream-parser.d.ts +10 -0
- package/dist/cursor/cursor-stream-parser.d.ts.map +1 -1
- package/dist/cursor/cursor-stream-parser.js +106 -10
- package/dist/cursor/cursor-stream-parser.js.map +1 -1
- package/dist/cursor/index.d.ts +1 -0
- package/dist/cursor/index.d.ts.map +1 -1
- package/dist/cursor/index.js +3 -1
- package/dist/cursor/index.js.map +1 -1
- package/dist/cursor/types.d.ts +6 -0
- package/dist/cursor/types.d.ts.map +1 -1
- package/dist/docker/docker-executor.d.ts +1 -0
- package/dist/docker/docker-executor.d.ts.map +1 -1
- package/dist/docker/supervisord-lifecycle.d.ts +17 -0
- package/dist/docker/supervisord-lifecycle.d.ts.map +1 -0
- package/dist/docker/supervisord-lifecycle.js +58 -0
- package/dist/docker/supervisord-lifecycle.js.map +1 -0
- package/dist/management/instance-manager.d.ts.map +1 -1
- package/dist/management/instance-manager.js +5 -2
- package/dist/management/instance-manager.js.map +1 -1
- package/dist/targets/claude-adapter.d.ts +6 -1
- package/dist/targets/claude-adapter.d.ts.map +1 -1
- package/dist/targets/claude-adapter.js +6 -2
- package/dist/targets/claude-adapter.js.map +1 -1
- package/dist/targets/codex-adapter.d.ts +1 -0
- package/dist/targets/codex-adapter.d.ts.map +1 -1
- package/dist/targets/codex-adapter.js +12 -8
- package/dist/targets/codex-adapter.js.map +1 -1
- package/dist/targets/droid-adapter.d.ts +3 -1
- package/dist/targets/droid-adapter.d.ts.map +1 -1
- package/dist/targets/droid-adapter.js +3 -2
- package/dist/targets/droid-adapter.js.map +1 -1
- package/dist/targets/target-adapter.d.ts +5 -0
- package/dist/targets/target-adapter.d.ts.map +1 -1
- package/dist/types/cli.d.ts +1 -0
- package/dist/types/cli.d.ts.map +1 -1
- package/dist/ui/assets/{accounts-DjL3iVZW.js → accounts-D9eEaNx9.js} +1 -1
- package/dist/ui/assets/{alert-dialog-Tc_D1a_B.js → alert-dialog-QyEXocpn.js} +1 -1
- package/dist/ui/assets/{api-CUtkvXmX.js → api-7vQe0xOg.js} +1 -1
- package/dist/ui/assets/{auth-section-CuKWQHC7.js → auth-section-BszF77uT.js} +1 -1
- package/dist/ui/assets/{backups-section-BKW2pbb9.js → backups-section-D6RgaOx1.js} +1 -1
- package/dist/ui/assets/{channels-DvWJMdaq.js → channels-B1vgnNJX.js} +1 -1
- package/dist/ui/assets/{checkbox-B0hZxMK5.js → checkbox-Dzwkj_Pg.js} +1 -1
- package/dist/ui/assets/{claude-extension-Dfqu-rev.js → claude-extension-CKO4bJ22.js} +1 -1
- package/dist/ui/assets/{cliproxy-ai-providers-BXLuuxNf.js → cliproxy-ai-providers-CmbFYVoR.js} +1 -1
- package/dist/ui/assets/{cliproxy-control-panel-aQ7cCc2U.js → cliproxy-control-panel-M8ZfUq3C.js} +1 -1
- package/dist/ui/assets/{cliproxy-C9RxW-I8.js → cliproxy-kHd-oC5W.js} +1 -1
- package/dist/ui/assets/{codex-aq4RI6_n.js → codex-BJ0RdMuh.js} +1 -1
- package/dist/ui/assets/{confirm-dialog-CpDk6eu4.js → confirm-dialog-BlSaX2gK.js} +1 -1
- package/dist/ui/assets/{copilot-CQRpGXvY.js → copilot-NJKZQXQ_.js} +1 -1
- package/dist/ui/assets/cursor-BrcDgu6X.js +1 -0
- package/dist/ui/assets/{droid-Cgx-yLjy.js → droid-B9u9ZB-a.js} +1 -1
- package/dist/ui/assets/{globalenv-section-DsNqG1yB.js → globalenv-section-DoX37DqB.js} +1 -1
- package/dist/ui/assets/{health-BY-O-JcA.js → health-D_gdcxnc.js} +1 -1
- package/dist/ui/assets/{index-DsCjnpco.js → index-BNU4Hhe_.js} +1 -1
- package/dist/ui/assets/{index-Cet36v1V.js → index-CTGpqIx6.js} +1 -1
- package/dist/ui/assets/index-Cu6e0-ev.css +1 -0
- package/dist/ui/assets/{index-CLGiPB3A.js → index-DFEMq3KP.js} +1 -1
- package/dist/ui/assets/index-DOn6k1jF.js +72 -0
- package/dist/ui/assets/{index-TQFuDZdB.js → index-DoVPk3vW.js} +1 -1
- package/dist/ui/assets/index-h08p9xL5.js +1 -0
- package/dist/ui/assets/{logs-D5ro-pc7.js → logs-DtH4YMt4.js} +1 -1
- package/dist/ui/assets/{masked-input-h0XkMSwB.js → masked-input-C2H-Ax0Z.js} +1 -1
- package/dist/ui/assets/{proxy-status-widget-yBdrFeb7.js → proxy-status-widget-BOrsn86w.js} +1 -1
- package/dist/ui/assets/{raw-json-settings-editor-panel-Cb7ZInQV.js → raw-json-settings-editor-panel-WxTn7-hS.js} +1 -1
- package/dist/ui/assets/{searchable-select-D4xr5xKS.js → searchable-select-1zOULoec.js} +1 -1
- package/dist/ui/assets/{separator-gw5BjIpP.js → separator-BCfZ54mZ.js} +1 -1
- package/dist/ui/assets/{shared-C-VeA1Z9.js → shared-DlTbnc9n.js} +1 -1
- package/dist/ui/assets/{table-Bd4isC18.js → table-Bx2cnkWN.js} +1 -1
- package/dist/ui/assets/{updates-DiK8I67C.js → updates-SiZKOnUD.js} +1 -1
- package/dist/ui/index.html +2 -2
- package/dist/utils/browser/chrome-reuse.d.ts +17 -0
- package/dist/utils/browser/chrome-reuse.d.ts.map +1 -0
- package/dist/utils/browser/chrome-reuse.js +194 -0
- package/dist/utils/browser/chrome-reuse.js.map +1 -0
- package/dist/utils/browser/claude-tool-args.d.ts +2 -0
- package/dist/utils/browser/claude-tool-args.d.ts.map +1 -0
- package/dist/utils/browser/claude-tool-args.js +18 -0
- package/dist/utils/browser/claude-tool-args.js.map +1 -0
- package/dist/utils/browser/index.d.ts +8 -0
- package/dist/utils/browser/index.d.ts.map +1 -0
- package/dist/utils/browser/index.js +24 -0
- package/dist/utils/browser/index.js.map +1 -0
- package/dist/utils/browser/mcp-installer.d.ts +14 -0
- package/dist/utils/browser/mcp-installer.d.ts.map +1 -0
- package/dist/utils/browser/mcp-installer.js +356 -0
- package/dist/utils/browser/mcp-installer.js.map +1 -0
- package/dist/utils/browser-codex-overrides.d.ts +3 -0
- package/dist/utils/browser-codex-overrides.d.ts.map +1 -0
- package/dist/utils/browser-codex-overrides.js +29 -0
- package/dist/utils/browser-codex-overrides.js.map +1 -0
- package/dist/utils/claude-detector.d.ts +1 -0
- package/dist/utils/claude-detector.d.ts.map +1 -1
- package/dist/utils/claude-spawner.d.ts +1 -0
- package/dist/utils/claude-spawner.d.ts.map +1 -1
- package/dist/utils/claude-tool-args.d.ts +7 -0
- package/dist/utils/claude-tool-args.d.ts.map +1 -0
- package/dist/utils/claude-tool-args.js +43 -0
- package/dist/utils/claude-tool-args.js.map +1 -0
- package/dist/utils/image-analysis/claude-tool-args.d.ts +3 -0
- package/dist/utils/image-analysis/claude-tool-args.d.ts.map +1 -1
- package/dist/utils/image-analysis/claude-tool-args.js +21 -47
- package/dist/utils/image-analysis/claude-tool-args.js.map +1 -1
- package/dist/utils/package-manager-detector.d.ts +1 -0
- package/dist/utils/package-manager-detector.d.ts.map +1 -1
- package/dist/utils/prompt-injection-strategy.d.ts +54 -0
- package/dist/utils/prompt-injection-strategy.d.ts.map +1 -0
- package/dist/utils/prompt-injection-strategy.js +128 -0
- package/dist/utils/prompt-injection-strategy.js.map +1 -0
- package/dist/utils/shell-executor.d.ts +1 -0
- package/dist/utils/shell-executor.d.ts.map +1 -1
- package/dist/utils/websearch/claude-tool-args.d.ts +7 -0
- package/dist/utils/websearch/claude-tool-args.d.ts.map +1 -1
- package/dist/utils/websearch/claude-tool-args.js +27 -50
- package/dist/utils/websearch/claude-tool-args.js.map +1 -1
- package/dist/utils/websearch/hook-env.d.ts.map +1 -1
- package/dist/utils/websearch/hook-env.js +19 -1
- package/dist/utils/websearch/hook-env.js.map +1 -1
- package/dist/utils/websearch/status.d.ts +1 -1
- package/dist/utils/websearch/status.d.ts.map +1 -1
- package/dist/utils/websearch/status.js +33 -12
- package/dist/utils/websearch/status.js.map +1 -1
- package/dist/utils/websearch/trace.d.ts +1 -0
- package/dist/utils/websearch/trace.d.ts.map +1 -1
- package/dist/utils/websearch/trace.js +20 -5
- package/dist/utils/websearch/trace.js.map +1 -1
- package/dist/utils/websearch/types.d.ts +12 -2
- package/dist/utils/websearch/types.d.ts.map +1 -1
- package/dist/utils/websearch/types.js +38 -0
- package/dist/utils/websearch/types.js.map +1 -1
- package/dist/web-server/health/websearch-checks.js +1 -1
- package/dist/web-server/health/websearch-checks.js.map +1 -1
- package/dist/web-server/middleware/auth-middleware.d.ts +0 -1
- package/dist/web-server/middleware/auth-middleware.d.ts.map +1 -1
- package/dist/web-server/routes/cliproxy-local-proxy.d.ts.map +1 -1
- package/dist/web-server/routes/cliproxy-local-proxy.js +26 -6
- package/dist/web-server/routes/cliproxy-local-proxy.js.map +1 -1
- package/dist/web-server/routes/cliproxy-stats-routes.d.ts.map +1 -1
- package/dist/web-server/routes/cliproxy-stats-routes.js +8 -1
- package/dist/web-server/routes/cliproxy-stats-routes.js.map +1 -1
- package/dist/web-server/routes/cursor-routes.d.ts +2 -0
- package/dist/web-server/routes/cursor-routes.d.ts.map +1 -1
- package/dist/web-server/routes/cursor-routes.js +44 -2
- package/dist/web-server/routes/cursor-routes.js.map +1 -1
- package/dist/web-server/routes/websearch-routes.d.ts.map +1 -1
- package/dist/web-server/routes/websearch-routes.js +37 -0
- package/dist/web-server/routes/websearch-routes.js.map +1 -1
- package/dist/web-server/services/cliproxy-dashboard-install-service.d.ts.map +1 -1
- package/dist/web-server/services/cliproxy-dashboard-install-service.js +14 -0
- package/dist/web-server/services/cliproxy-dashboard-install-service.js.map +1 -1
- package/dist/web-server/services/codex-dashboard-service.d.ts +1 -0
- package/dist/web-server/services/codex-dashboard-service.d.ts.map +1 -1
- package/dist/web-server/services/droid-dashboard-service.d.ts +1 -0
- package/dist/web-server/services/droid-dashboard-service.d.ts.map +1 -1
- package/lib/hooks/websearch-transformer.cjs +136 -0
- package/lib/mcp/ccs-browser-server.cjs +877 -0
- package/lib/mcp/ccs-websearch-server.cjs +1 -1
- package/package.json +2 -1
- package/dist/ui/assets/cursor-BpXPf6qi.js +0 -1
- package/dist/ui/assets/index-BmSzf0T9.js +0 -72
- package/dist/ui/assets/index-DH6L6ybH.js +0 -1
- package/dist/ui/assets/index-teLjoh2T.css +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as b}from"./react-vendor-CNOkPC89.js";import{t as W}from"./notifications-B2HqRBj7.js";import{C as D,j as M,k as I,B as y,b as F,d as w,aF as B,r as _,s as E,t as P,v as O,w as v,I as C,n as xe,bb as J,bc as Te,c as _e,bi as Ge,bj as fe,bk as Ye,Q as Be,R as He,U as re,V as te,bd as je}from"./index-BmSzf0T9.js";import{aa as Qe,aR as Je,as as Z,L as X,n as Ze,aS as es,aT as ss,aB as rs,w as ts,a7 as ns,aU as as,aV as ls,aW as os,ah as de,p as ge,$ as is,m as cs,o as ds,_ as us,S as ms,aM as ve,aX as xs,x as hs,I as ps,T as fs,N as js}from"./icons-KVCk4_U8.js";import{S as Q}from"./separator-gw5BjIpP.js";import{a as gs,u as be,b as we}from"./tanstack-CrmUhA7Z.js";import"./code-highlight-BRUf_pqB.js";import{T as vs,a as bs,b as Ne,c as ne,d as ws,e as ae}from"./table-Bd4isC18.js";import{R as Ns}from"./raw-json-settings-editor-panel-Cb7ZInQV.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";function H({title:s,icon:r,badge:t,description:a,disabledReason:n,children:l}){return e.jsxs(D,{children:[e.jsxs(M,{className:"pb-2",children:[e.jsxs(I,{className:"flex items-center gap-2 text-base",children:[r,s,t?e.jsx(y,{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(F,{className:"space-y-3",children:[n?e.jsx("p",{className:"text-xs text-amber-600",children:n}):null,l]})]})}function Cs({catalog:s,state:r,disabled:t=!1,disabledReason:a,onToggle:n}){const l=new Set(s.map(o=>o.name)),i=Object.entries(r).filter(([o])=>!l.has(o)).sort(([o],[d])=>o.localeCompare(d));return e.jsxs(H,{title:"Features",badge:"features",icon:e.jsx(Qe,{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(o=>{const d=r[o.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:o.label}),e.jsx(y,{variant:"outline",className:"font-mono text-[10px]",children:o.name})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:o.description})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[d!==null?e.jsx(w,{variant:"outline",size:"sm",onClick:()=>n(o.name,null),disabled:t,children:"Use default"}):null,e.jsx(B,{checked:d===!0,onCheckedChange:c=>n(o.name,c),disabled:t})]})]},o.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(([o,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:o}),e.jsx(y,{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(y,{variant:"outline",children:"Raw only"}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(w,{variant:"outline",size:"sm",onClick:()=>n(o,null),disabled:t,children:"Use default"}),e.jsx(B,{checked:d===!0,onCheckedChange:c=>n(o,c),disabled:t})]})]},o))]}):null]})}const ys={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 Ss({initialDraft:s,isNew:r,disabled:t,saving:a,canDelete:n,onSave:l,onDelete:i}){const[o,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:o.name,onChange:c=>d(u=>({...u,name:c.target.value})),placeholder:"playwright",disabled:t||!r}),e.jsxs(_,{value:o.transport,onValueChange:c=>d(u=>({...u,transport:c})),disabled:t,children:[e.jsx(E,{children:e.jsx(P,{})}),e.jsxs(O,{children:[e.jsx(v,{value:"stdio",children:"stdio"}),e.jsx(v,{value:"streamable-http",children:"streamable-http"})]})]}),o.transport==="stdio"?e.jsxs(e.Fragment,{children:[e.jsx(C,{value:o.command??"",onChange:c=>d(u=>({...u,command:c.target.value||null})),placeholder:"npx",disabled:t}),e.jsx(C,{value:le(o.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:o.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:o.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:o.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(o.enabledTools),onChange:c=>d(u=>({...u,enabledTools:oe(c.target.value)})),placeholder:"enabled_tools",disabled:t}),e.jsx(C,{value:le(o.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:o.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:o.required,onCheckedChange:c=>d(u=>({...u,required:c})),disabled:t})]})]}),e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsxs(w,{variant:"outline",onClick:i,disabled:t||a||!n,children:[e.jsx(Z,{className:"mr-2 h-4 w-4"}),"Delete"]}),e.jsxs(w,{onClick:()=>l(o.name,{transport:o.transport,command:o.command,args:o.args,url:o.url,enabled:o.enabled,required:o.required,startupTimeoutSec:o.startupTimeoutSec,toolTimeoutSec:o.toolTimeoutSec,enabledTools:o.enabledTools,disabledTools:o.disabledTools}),disabled:t||a||o.name.trim().length===0,children:[a?e.jsx(X,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save MCP server"]})]})]})}function ks({entries:s,disabled:r=!1,disabledReason:t,saving:a=!1,onSave:n,onDelete:l}){const[i,o]=b.useState("new"),d=b.useMemo(()=>s.find(h=>h.name===i)??null,[s,i]),c=d??ys,u=JSON.stringify(c);return e.jsxs(H,{title:"MCP servers",badge:"mcp_servers",icon:e.jsx(Je,{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(_,{value:i,onValueChange:o,disabled:r,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Select MCP server"})}),e.jsxs(O,{children:[e.jsx(v,{value:"new",children:"Create new MCP server"}),s.map(h=>e.jsx(v,{value:h.name,children:h.name},h.name))]})]}),e.jsx(Ss,{initialDraft:c,isNew:i==="new",disabled:r,saving:a,canDelete:d!==null,onDelete:async()=>{d&&(await l(d.name),o("new"))},onSave:async(h,j)=>{await n(h,j),o(h)}},u)]})}const Ts={name:"",displayName:null,baseUrl:null,envKey:null,wireApi:"responses",requiresOpenaiAuth:!1,supportsWebsockets:!1},_s={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 Es({initialDraft:s,isNew:r,disabled:t,saving:a,canDelete:n,onSave:l,onDelete:i}){const[o,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(w,{variant:"outline",size:"sm",onClick:()=>d(_s),disabled:t,children:"Use CLIProxy Codex preset"})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(C,{value:o.name,onChange:c=>d(u=>({...u,name:c.target.value})),placeholder:"Provider id",disabled:t||!r}),e.jsx(C,{value:o.displayName??"",onChange:c=>d(u=>({...u,displayName:c.target.value||null})),placeholder:"Display name",disabled:t}),e.jsx(C,{value:o.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:o.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(_,{value:o.wireApi??"responses",onValueChange:c=>d(u=>({...u,wireApi:c})),disabled:t,children:[e.jsx(E,{children:e.jsx(P,{})}),e.jsx(O,{children:e.jsx(v,{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:o.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:o.supportsWebsockets,onCheckedChange:c=>d(u=>({...u,supportsWebsockets:c})),disabled:t})]})]}),e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsxs(w,{variant:"outline",onClick:i,disabled:t||a||!n,children:[e.jsx(Z,{className:"mr-2 h-4 w-4"}),"Delete"]}),e.jsxs(w,{onClick:()=>l(o.name,{displayName:o.displayName,baseUrl:o.baseUrl,envKey:o.envKey,wireApi:o.wireApi,requiresOpenaiAuth:o.requiresOpenaiAuth,supportsWebsockets:o.supportsWebsockets}),disabled:t||a||o.name.trim().length===0,children:[a?e.jsx(X,{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 Ps({entries:s,disabled:r=!1,disabledReason:t,saving:a=!1,onSave:n,onDelete:l}){const[i,o]=b.useState("new"),d=b.useMemo(()=>s.find(h=>h.name===i)??null,[s,i]),c=d??Ts,u=JSON.stringify(c);return e.jsxs(H,{title:"Model providers",badge:"model_providers",icon:e.jsx(Ze,{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(_,{value:i,onValueChange:o,disabled:r,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Select provider"})}),e.jsxs(O,{children:[e.jsx(v,{value:"new",children:"Create new provider"}),s.map(h=>e.jsx(v,{value:h.name,children:h.name},h.name))]})]}),e.jsx(Es,{initialDraft:c,isNew:i==="new",disabled:r,saving:a,canDelete:d!==null,onDelete:async()=>{d&&(await l(d.name),o("new"))},onSave:async(h,j)=>{await n(h,j),o(h)}},u)]})}function Os({initialName:s,initialModel:r,initialProvider:t,initialEffort:a,providerNames:n,activeProfile:l,selectedEntryName:i,disabled:o,saving:d,onSave:c,onDelete:u,onSetActive:h}){const[j,x]=b.useState(s),[g,A]=b.useState(r),[U,m]=b.useState(t),[f,T]=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:j,onChange:N=>x(N.target.value),placeholder:"deep-review",disabled:o||i!==null}),e.jsx(C,{value:g??"",onChange:N=>A(N.target.value||null),placeholder:"gpt-5.4",disabled:o}),e.jsxs(_,{value:U??"__unset__",onValueChange:N=>m(N==="__unset__"?null:N),disabled:o,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Use global provider"})}),e.jsxs(O,{children:[e.jsx(v,{value:"__unset__",children:"Use global provider"}),n.map(N=>e.jsx(v,{value:N,children:N},N))]})]}),e.jsxs(_,{value:f??"__unset__",onValueChange:N=>T(N==="__unset__"?null:N),disabled:o,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Use global effort"})}),e.jsxs(O,{children:[e.jsx(v,{value:"__unset__",children:"Use global effort"}),["minimal","low","medium","high","xhigh"].map(N=>e.jsx(v,{value:N,children:N},N))]})]})]}),e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(w,{variant:"outline",onClick:u,disabled:o||d||!i,children:[e.jsx(Z,{className:"mr-2 h-4 w-4"}),"Delete"]}),e.jsx(w,{variant:"outline",onClick:h,disabled:o||d||!i||i===l,children:"Set active"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(w,{variant:"outline",onClick:()=>c(j,{model:g,modelProvider:U,modelReasoningEffort:f},!1),disabled:o||d||j.trim().length===0,children:[d?e.jsx(X,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save profile"]}),e.jsxs(w,{onClick:()=>c(j,{model:g,modelProvider:U,modelReasoningEffort:f},!0),disabled:o||d||j.trim().length===0,children:[d?e.jsx(X,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save + activate"]})]})]})]})}function Ls({activeProfile:s,entries:r,providerNames:t,disabled:a=!1,disabledReason:n,saving:l=!1,onSave:i,onDelete:o,onSetActive:d}){const[c,u]=b.useState("new"),h=b.useMemo(()=>r.find(x=>x.name===c)??null,[r,c]),j=JSON.stringify(h??{name:"",values:{}});return e.jsxs(H,{title:"Profiles",badge:"profiles",icon:e.jsx(es,{className:"h-4 w-4"}),description:"Create reusable Codex overlays and set the active default profile.",disabledReason:n,children:[e.jsxs(_,{value:c,onValueChange:u,disabled:a,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Select profile"})}),e.jsxs(O,{children:[e.jsx(v,{value:"new",children:"Create new profile"}),r.map(x=>e.jsxs(v,{value:x.name,children:[x.name,x.name===s?" (active)":""]},x.name))]})]}),e.jsx(Os,{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:l,onDelete:async()=>{h&&(await o(h.name),u("new"))},onSetActive:async()=>{h&&await d(h.name)},onSave:async(x,g,A)=>{await i(x,g,A),u(x)}},j)]})}function As({workspacePath:s,disabled:r,saving:t,onSave:a}){const[n,l]=b.useState(s),[i,o]=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=>l(d.target.value),placeholder:"~/repo or /absolute/path",disabled:r}),e.jsxs(_,{value:i,onValueChange:o,disabled:r,children:[e.jsx(E,{children:e.jsx(P,{})}),e.jsxs(O,{children:[e.jsx(v,{value:"trusted",children:"trusted"}),e.jsx(v,{value:"untrusted",children:"untrusted"})]})]}),e.jsxs(w,{onClick:()=>a(n,i),disabled:r||t,children:[t?e.jsx(X,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save trust"]})]})}function Rs({workspacePath:s,entries:r,disabled:t=!1,disabledReason:a,saving:n=!1,onSave:l}){return e.jsxs(H,{title:"Project trust",badge:"projects",icon:e.jsx(ss,{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(As,{workspacePath:s,disabled:t,saving:n,onSave:l},s),e.jsx(w,{variant:"outline",className:"w-full justify-start",onClick:()=>l(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(w,{variant:"ghost",size:"sm",onClick:()=>l(i.path,i.trustLevel==="trusted"?"untrusted":"trusted"),disabled:t||n,children:"Toggle"}),e.jsx(w,{variant:"ghost",size:"icon",onClick:()=>l(i.path,null),disabled:t||n,children:e.jsx(Z,{className:"h-4 w-4"})})]})]},i.path))})]})}const L="__unset__",Ds=105e4,Ms=272e3,Ce=8e5,ye=7e5,Is=new Intl.NumberFormat("en-US");function z(s){return s??L}function $(s,r){return r&&!s.includes(r)?[r,...s]:s}function ie(s){return Is.format(s)}function Fs(s){return s?.trim().toLowerCase().startsWith("gpt-5.4")??!1}function Us(s,r){const t={};return r.model!==s.model&&(t.model=r.model),r.modelReasoningEffort!==s.modelReasoningEffort&&(t.modelReasoningEffort=r.modelReasoningEffort),r.modelContextWindow!==s.modelContextWindow&&(t.modelContextWindow=r.modelContextWindow),r.modelAutoCompactTokenLimit!==s.modelAutoCompactTokenLimit&&(t.modelAutoCompactTokenLimit=r.modelAutoCompactTokenLimit),r.modelProvider!==s.modelProvider&&(t.modelProvider=r.modelProvider),r.approvalPolicy!==s.approvalPolicy&&(t.approvalPolicy=r.approvalPolicy),r.sandboxMode!==s.sandboxMode&&(t.sandboxMode=r.sandboxMode),r.webSearch!==s.webSearch&&(t.webSearch=r.webSearch),r.toolOutputTokenLimit!==s.toolOutputTokenLimit&&(t.toolOutputTokenLimit=r.toolOutputTokenLimit),r.personality!==s.personality&&(t.personality=r.personality),t}function Ws({initialValues:s,providerNames:r,disabled:t,saving:a,onSave:n}){const[l,i]=b.useState(s),o=$(["minimal","low","medium","high","xhigh"],l.modelReasoningEffort),d=$(r,l.modelProvider),c=$(["on-request","never","untrusted"],l.approvalPolicy),u=$(["read-only","workspace-write","danger-full-access"],l.sandboxMode),h=$(["cached","live","disabled"],l.webSearch),j=$(["none","friendly","pragmatic"],l.personality),x=Us(s,l),g=Object.keys(x).length>0,A=Fs(l.model),U=m=>{const f=m.trim();return f.length>0?Number(f):null};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:"Model"}),e.jsx(C,{value:l.model??"",onChange:m=>i(f=>({...f,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(_,{value:z(l.modelReasoningEffort),onValueChange:m=>i(f=>({...f,modelReasoningEffort:m===L?null:m})),disabled:t,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Use default"})}),e.jsxs(O,{children:[e.jsx(v,{value:L,children:"Use default"}),o.map(m=>e.jsx(v,{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(_,{value:z(l.modelProvider),onValueChange:m=>i(f=>({...f,modelProvider:m===L?null:m})),disabled:t,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Use Codex default"})}),e.jsxs(O,{children:[e.jsx(v,{value:L,children:"Use Codex default"}),d.map(m=>e.jsx(v,{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(_,{value:z(l.approvalPolicy),onValueChange:m=>i(f=>({...f,approvalPolicy:m===L?null:m})),disabled:t,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Use default"})}),e.jsxs(O,{children:[e.jsx(v,{value:L,children:"Use default"}),c.map(m=>e.jsx(v,{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(_,{value:z(l.sandboxMode),onValueChange:m=>i(f=>({...f,sandboxMode:m===L?null:m})),disabled:t,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Use default"})}),e.jsxs(O,{children:[e.jsx(v,{value:L,children:"Use default"}),u.map(m=>e.jsx(v,{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(_,{value:z(l.webSearch),onValueChange:m=>i(f=>({...f,webSearch:m===L?null:m})),disabled:t,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Use default"})}),e.jsxs(O,{children:[e.jsx(v,{value:L,children:"Use default"}),h.map(m=>e.jsx(v,{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:l.toolOutputTokenLimit??"",onChange:m=>i(f=>({...f,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(_,{value:z(l.personality),onValueChange:m=>i(f=>({...f,personality:m===L?null:m})),disabled:t,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Use default"})}),e.jsxs(O,{children:[e.jsx(v,{value:L,children:"Use default"}),j.map(m=>e.jsx(v,{value:m,children:m},m))]})]})]})]}),e.jsxs("div",{className:"space-y-4 rounded-xl border border-amber-500/30 bg-amber-500/5 p-4 shadow-sm dark:bg-amber-400/5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(ts,{className:"h-4 w-4 text-amber-600 dark:text-amber-300"}),e.jsx("p",{className:"text-sm font-semibold",children:"Long context override"}),e.jsx(y,{variant:"outline",className:"border-amber-500/40 bg-background/80 text-[10px] uppercase tracking-[0.16em] text-amber-700 dark:text-amber-300",children:"Manual opt-in only"}),e.jsx(y,{variant:"secondary",className:"text-[10px] uppercase tracking-[0.16em] text-muted-foreground",children:A?"GPT-5.4 selected":"GPT-5.4 reference"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Draft values only. Nothing applies until Save."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(w,{type:"button",variant:"outline",size:"sm",disabled:t,onClick:()=>i(m=>({...m,modelContextWindow:Ce,modelAutoCompactTokenLimit:ye})),children:"Fill cautious pair"}),e.jsx(w,{type:"button",variant:"outline",size:"sm",disabled:t,onClick:()=>i(m=>({...m,modelContextWindow:Ds})),children:"Set official max window"}),e.jsx(w,{type:"button",variant:"ghost",size:"sm",disabled:t,onClick:()=>i(m=>({...m,modelContextWindow:null,modelAutoCompactTokenLimit:null})),children:"Clear"})]})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-3",children:[e.jsxs("div",{className:"rounded-lg border bg-background/85 px-3 py-3 shadow-sm shadow-black/5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"Official max"}),e.jsx("p",{className:"mt-1 font-mono text-base font-semibold text-foreground",children:"1.05M / 1M"}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:"GPT-5.4 context cap"})]}),e.jsxs("div",{className:"rounded-lg border bg-background/85 px-3 py-3 shadow-sm shadow-black/5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"Standard window"}),e.jsx("p",{className:"mt-1 font-mono text-base font-semibold text-foreground",children:ie(Ms)}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:"Normal usage window"})]}),e.jsxs("div",{className:"rounded-lg border bg-background/85 px-3 py-3 shadow-sm shadow-black/5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"Above 272K"}),e.jsx("p",{className:"mt-1 font-mono text-base font-semibold text-foreground",children:"Counts 2x"}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:"Usage-limit cost above 272K"})]})]}),e.jsxs("div",{className:"space-y-3 rounded-lg border bg-background/75 px-3 py-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"One cautious pair"}),e.jsxs("div",{className:"rounded-full border bg-background px-2.5 py-1 font-mono text-[11px] font-medium",children:["Context ",ie(Ce)]}),e.jsxs("div",{className:"rounded-full border bg-background px-2.5 py-1 font-mono text-[11px] font-medium",children:["Auto-compact ",ie(ye)]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx(y,{variant:"outline",className:"border-border/70 bg-background/80 text-[10px] uppercase tracking-[0.14em] text-muted-foreground",children:"Not official"}),e.jsx(y,{variant:"outline",className:"border-border/70 bg-background/80 text-[10px] uppercase tracking-[0.14em] text-muted-foreground",children:"Draft only"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px] text-muted-foreground",children:[e.jsx("span",{children:"Quick-fill only. Review before saving."}),!A&&l.model?e.jsxs("span",{children:[e.jsx("code",{children:l.model})," should be checked separately."]}):null]})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:"Model context window"}),e.jsx(C,{"aria-label":"Model context window",type:"number",min:1,value:l.modelContextWindow??"",onChange:m=>i(f=>({...f,modelContextWindow:U(m.target.value)})),placeholder:"Unset",disabled:t}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Writes ",e.jsx("code",{children:"model_context_window"}),". Leave unset to keep Codex defaults."]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:"Auto-compact token limit"}),e.jsx(C,{"aria-label":"Auto-compact token limit",type:"number",min:1,value:l.modelAutoCompactTokenLimit??"",onChange:m=>i(f=>({...f,modelAutoCompactTokenLimit:U(m.target.value)})),placeholder:"Unset",disabled:t}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Writes ",e.jsx("code",{children:"model_auto_compact_token_limit"}),". Leave unset to keep model defaults."]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px] text-muted-foreground",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-[0.14em]",children:"Docs"}),e.jsx("a",{href:"https://developers.openai.com/api/docs/models/gpt-5.4",target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:"GPT-5.4 model page"}),e.jsx("a",{href:"https://openai.com/index/introducing-gpt-5-4/",target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:"Release notes"}),e.jsx("a",{href:"https://developers.openai.com/codex/config-reference",target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:"Config reference"})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(w,{onClick:()=>n(x),disabled:t||a||!g,children:[a?e.jsx(X,{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:l}){return e.jsx(H,{title:"Top-level controls",badge:"config.toml",icon:e.jsx(rs,{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(Ws,{initialValues:s,providerNames:r,disabled:t,saving:n,onSave:l},JSON.stringify(s))})}function qs({workspacePath:s,activeProfile:r,topLevelSettings:t,projectTrustEntries:a,profileEntries:n,modelProviderEntries:l,mcpServerEntries:i,featureCatalog:o,featureState:d,disabled:c,disabledReason:u,saving:h,onPatch:j}){return e.jsx(xe,{className:"h-full",children:e.jsxs("div",{className:"space-y-6 pr-1 pb-6",children:[e.jsxs("div",{className:"group relative overflow-hidden rounded-xl border border-border/80 bg-background/50 p-5 shadow-sm transition-all hover:bg-background hover:shadow-md dark:border-border/60",children:[e.jsx("div",{className:"absolute inset-x-0 -top-px h-px bg-gradient-to-r from-transparent via-foreground/15 to-transparent transition-opacity group-hover:via-foreground/30"}),e.jsxs("div",{className:"flex flex-col gap-6 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{className:"flex-1 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary transition-colors group-hover:border-primary/30",children:e.jsx(ns,{className:"h-4 w-4"})}),e.jsx("div",{children:e.jsx("h2",{className:"text-base font-semibold tracking-tight text-foreground",children:"Structured controls boundary"})})]}),e.jsxs("ul",{className:"grid gap-3 sm:grid-cols-2 text-sm text-muted-foreground",children:[e.jsxs("li",{className:"flex items-start gap-2.5",children:[e.jsx(as,{className:"h-4 w-4 shrink-0 text-muted-foreground/60 mt-0.5"}),e.jsxs("span",{className:"leading-relaxed",children:["Writes exclusively to user-layer"," ",e.jsx("code",{className:"text-[11px] bg-muted/70 px-1.5 py-0.5 rounded border border-border/50",children:"config.toml"})]})]}),e.jsxs("li",{className:"flex items-start gap-2.5",children:[e.jsx(ls,{className:"h-4 w-4 shrink-0 text-muted-foreground/60 mt-0.5"}),e.jsx("span",{className:"leading-relaxed",children:"Does not reflect repo trust layers or CLI overrides"})]})]})]}),e.jsx("div",{className:"shrink-0 lg:w-[280px]",children:e.jsx("div",{className:"relative overflow-hidden rounded-lg border border-amber-500/20 bg-amber-500/5 p-4 transition-colors group-hover:border-amber-500/30 group-hover:bg-amber-500/10 dark:border-amber-400/10 dark:bg-amber-400/5",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(os,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-bold text-amber-700 dark:text-amber-300 uppercase tracking-wider",children:"Formatting Note"}),e.jsx("p",{className:"text-[13px] leading-relaxed text-amber-800/80 dark:text-amber-200/70",children:"Saves normalize TOML formatting and strip comments. Switch to the raw editor if exact layout matters."})]})]})})})]})]}),e.jsx(Ks,{values:t,providerNames:l.map(x=>x.name),disabled:c,disabledReason:u,saving:h,onSave:x=>j({kind:"top-level",values:x},"Saved top-level Codex settings.")}),e.jsx(Rs,{workspacePath:s,entries:a,disabled:c,disabledReason:u,saving:h,onSave:(x,g)=>j({kind:"project-trust",path:x,trustLevel:g},g?"Saved project trust entry.":"Removed project trust entry.")}),e.jsx(Ls,{activeProfile:r,entries:n,providerNames:l.map(x=>x.name),disabled:c,disabledReason:u,saving:h,onSave:(x,g,A)=>j({kind:"profile",action:"upsert",name:x,values:g,setAsActive:A},"Saved profile."),onDelete:x=>j({kind:"profile",action:"delete",name:x},"Deleted profile."),onSetActive:x=>j({kind:"profile",action:"set-active",name:x},"Set active profile.")}),e.jsx(Ps,{entries:l,disabled:c,disabledReason:u,saving:h,onSave:(x,g)=>j({kind:"model-provider",action:"upsert",name:x,values:g},"Saved model provider."),onDelete:x=>j({kind:"model-provider",action:"delete",name:x},"Deleted model provider.")}),e.jsx(ks,{entries:i,disabled:c,disabledReason:u,saving:h,onSave:(x,g)=>j({kind:"mcp-server",action:"upsert",name:x,values:g},"Saved MCP server."),onDelete:x=>j({kind:"mcp-server",action:"delete",name:x},"Deleted MCP server.")}),e.jsx(Cs,{catalog:o,state:d,disabled:c,disabledReason:u,onToggle:(x,g)=>j({kind:"feature",feature:x,enabled:g},"Saved feature toggle.")})]})})}const Ee=`model_provider = "cliproxy"
|
|
1
|
+
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as b}from"./react-vendor-CNOkPC89.js";import{t as W}from"./notifications-B2HqRBj7.js";import{C as D,j as M,k as I,B as y,b as F,d as w,aF as B,r as _,s as E,t as P,v as O,w as v,I as C,n as xe,bb as J,bc as Te,c as _e,bi as Ge,bj as fe,bk as Ye,Q as Be,R as He,U as re,V as te,bd as je}from"./index-DOn6k1jF.js";import{aa as Qe,aR as Je,as as Z,L as X,n as Ze,aS as es,aT as ss,aB as rs,w as ts,a7 as ns,aU as as,aV as ls,aW as os,ah as de,p as ge,$ as is,m as cs,o as ds,_ as us,S as ms,aM as ve,aX as xs,x as hs,I as ps,T as fs,N as js}from"./icons-KVCk4_U8.js";import{S as Q}from"./separator-BCfZ54mZ.js";import{a as gs,u as be,b as we}from"./tanstack-CrmUhA7Z.js";import"./code-highlight-BRUf_pqB.js";import{T as vs,a as bs,b as Ne,c as ne,d as ws,e as ae}from"./table-Bx2cnkWN.js";import{R as Ns}from"./raw-json-settings-editor-panel-WxTn7-hS.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";function H({title:s,icon:r,badge:t,description:a,disabledReason:n,children:l}){return e.jsxs(D,{children:[e.jsxs(M,{className:"pb-2",children:[e.jsxs(I,{className:"flex items-center gap-2 text-base",children:[r,s,t?e.jsx(y,{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(F,{className:"space-y-3",children:[n?e.jsx("p",{className:"text-xs text-amber-600",children:n}):null,l]})]})}function Cs({catalog:s,state:r,disabled:t=!1,disabledReason:a,onToggle:n}){const l=new Set(s.map(o=>o.name)),i=Object.entries(r).filter(([o])=>!l.has(o)).sort(([o],[d])=>o.localeCompare(d));return e.jsxs(H,{title:"Features",badge:"features",icon:e.jsx(Qe,{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(o=>{const d=r[o.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:o.label}),e.jsx(y,{variant:"outline",className:"font-mono text-[10px]",children:o.name})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:o.description})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[d!==null?e.jsx(w,{variant:"outline",size:"sm",onClick:()=>n(o.name,null),disabled:t,children:"Use default"}):null,e.jsx(B,{checked:d===!0,onCheckedChange:c=>n(o.name,c),disabled:t})]})]},o.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(([o,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:o}),e.jsx(y,{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(y,{variant:"outline",children:"Raw only"}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(w,{variant:"outline",size:"sm",onClick:()=>n(o,null),disabled:t,children:"Use default"}),e.jsx(B,{checked:d===!0,onCheckedChange:c=>n(o,c),disabled:t})]})]},o))]}):null]})}const ys={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 Ss({initialDraft:s,isNew:r,disabled:t,saving:a,canDelete:n,onSave:l,onDelete:i}){const[o,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:o.name,onChange:c=>d(u=>({...u,name:c.target.value})),placeholder:"playwright",disabled:t||!r}),e.jsxs(_,{value:o.transport,onValueChange:c=>d(u=>({...u,transport:c})),disabled:t,children:[e.jsx(E,{children:e.jsx(P,{})}),e.jsxs(O,{children:[e.jsx(v,{value:"stdio",children:"stdio"}),e.jsx(v,{value:"streamable-http",children:"streamable-http"})]})]}),o.transport==="stdio"?e.jsxs(e.Fragment,{children:[e.jsx(C,{value:o.command??"",onChange:c=>d(u=>({...u,command:c.target.value||null})),placeholder:"npx",disabled:t}),e.jsx(C,{value:le(o.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:o.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:o.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:o.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(o.enabledTools),onChange:c=>d(u=>({...u,enabledTools:oe(c.target.value)})),placeholder:"enabled_tools",disabled:t}),e.jsx(C,{value:le(o.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:o.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:o.required,onCheckedChange:c=>d(u=>({...u,required:c})),disabled:t})]})]}),e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsxs(w,{variant:"outline",onClick:i,disabled:t||a||!n,children:[e.jsx(Z,{className:"mr-2 h-4 w-4"}),"Delete"]}),e.jsxs(w,{onClick:()=>l(o.name,{transport:o.transport,command:o.command,args:o.args,url:o.url,enabled:o.enabled,required:o.required,startupTimeoutSec:o.startupTimeoutSec,toolTimeoutSec:o.toolTimeoutSec,enabledTools:o.enabledTools,disabledTools:o.disabledTools}),disabled:t||a||o.name.trim().length===0,children:[a?e.jsx(X,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save MCP server"]})]})]})}function ks({entries:s,disabled:r=!1,disabledReason:t,saving:a=!1,onSave:n,onDelete:l}){const[i,o]=b.useState("new"),d=b.useMemo(()=>s.find(h=>h.name===i)??null,[s,i]),c=d??ys,u=JSON.stringify(c);return e.jsxs(H,{title:"MCP servers",badge:"mcp_servers",icon:e.jsx(Je,{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(_,{value:i,onValueChange:o,disabled:r,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Select MCP server"})}),e.jsxs(O,{children:[e.jsx(v,{value:"new",children:"Create new MCP server"}),s.map(h=>e.jsx(v,{value:h.name,children:h.name},h.name))]})]}),e.jsx(Ss,{initialDraft:c,isNew:i==="new",disabled:r,saving:a,canDelete:d!==null,onDelete:async()=>{d&&(await l(d.name),o("new"))},onSave:async(h,j)=>{await n(h,j),o(h)}},u)]})}const Ts={name:"",displayName:null,baseUrl:null,envKey:null,wireApi:"responses",requiresOpenaiAuth:!1,supportsWebsockets:!1},_s={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 Es({initialDraft:s,isNew:r,disabled:t,saving:a,canDelete:n,onSave:l,onDelete:i}){const[o,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(w,{variant:"outline",size:"sm",onClick:()=>d(_s),disabled:t,children:"Use CLIProxy Codex preset"})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(C,{value:o.name,onChange:c=>d(u=>({...u,name:c.target.value})),placeholder:"Provider id",disabled:t||!r}),e.jsx(C,{value:o.displayName??"",onChange:c=>d(u=>({...u,displayName:c.target.value||null})),placeholder:"Display name",disabled:t}),e.jsx(C,{value:o.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:o.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(_,{value:o.wireApi??"responses",onValueChange:c=>d(u=>({...u,wireApi:c})),disabled:t,children:[e.jsx(E,{children:e.jsx(P,{})}),e.jsx(O,{children:e.jsx(v,{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:o.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:o.supportsWebsockets,onCheckedChange:c=>d(u=>({...u,supportsWebsockets:c})),disabled:t})]})]}),e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsxs(w,{variant:"outline",onClick:i,disabled:t||a||!n,children:[e.jsx(Z,{className:"mr-2 h-4 w-4"}),"Delete"]}),e.jsxs(w,{onClick:()=>l(o.name,{displayName:o.displayName,baseUrl:o.baseUrl,envKey:o.envKey,wireApi:o.wireApi,requiresOpenaiAuth:o.requiresOpenaiAuth,supportsWebsockets:o.supportsWebsockets}),disabled:t||a||o.name.trim().length===0,children:[a?e.jsx(X,{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 Ps({entries:s,disabled:r=!1,disabledReason:t,saving:a=!1,onSave:n,onDelete:l}){const[i,o]=b.useState("new"),d=b.useMemo(()=>s.find(h=>h.name===i)??null,[s,i]),c=d??Ts,u=JSON.stringify(c);return e.jsxs(H,{title:"Model providers",badge:"model_providers",icon:e.jsx(Ze,{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(_,{value:i,onValueChange:o,disabled:r,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Select provider"})}),e.jsxs(O,{children:[e.jsx(v,{value:"new",children:"Create new provider"}),s.map(h=>e.jsx(v,{value:h.name,children:h.name},h.name))]})]}),e.jsx(Es,{initialDraft:c,isNew:i==="new",disabled:r,saving:a,canDelete:d!==null,onDelete:async()=>{d&&(await l(d.name),o("new"))},onSave:async(h,j)=>{await n(h,j),o(h)}},u)]})}function Os({initialName:s,initialModel:r,initialProvider:t,initialEffort:a,providerNames:n,activeProfile:l,selectedEntryName:i,disabled:o,saving:d,onSave:c,onDelete:u,onSetActive:h}){const[j,x]=b.useState(s),[g,A]=b.useState(r),[U,m]=b.useState(t),[f,T]=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:j,onChange:N=>x(N.target.value),placeholder:"deep-review",disabled:o||i!==null}),e.jsx(C,{value:g??"",onChange:N=>A(N.target.value||null),placeholder:"gpt-5.4",disabled:o}),e.jsxs(_,{value:U??"__unset__",onValueChange:N=>m(N==="__unset__"?null:N),disabled:o,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Use global provider"})}),e.jsxs(O,{children:[e.jsx(v,{value:"__unset__",children:"Use global provider"}),n.map(N=>e.jsx(v,{value:N,children:N},N))]})]}),e.jsxs(_,{value:f??"__unset__",onValueChange:N=>T(N==="__unset__"?null:N),disabled:o,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Use global effort"})}),e.jsxs(O,{children:[e.jsx(v,{value:"__unset__",children:"Use global effort"}),["minimal","low","medium","high","xhigh"].map(N=>e.jsx(v,{value:N,children:N},N))]})]})]}),e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(w,{variant:"outline",onClick:u,disabled:o||d||!i,children:[e.jsx(Z,{className:"mr-2 h-4 w-4"}),"Delete"]}),e.jsx(w,{variant:"outline",onClick:h,disabled:o||d||!i||i===l,children:"Set active"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(w,{variant:"outline",onClick:()=>c(j,{model:g,modelProvider:U,modelReasoningEffort:f},!1),disabled:o||d||j.trim().length===0,children:[d?e.jsx(X,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save profile"]}),e.jsxs(w,{onClick:()=>c(j,{model:g,modelProvider:U,modelReasoningEffort:f},!0),disabled:o||d||j.trim().length===0,children:[d?e.jsx(X,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save + activate"]})]})]})]})}function Ls({activeProfile:s,entries:r,providerNames:t,disabled:a=!1,disabledReason:n,saving:l=!1,onSave:i,onDelete:o,onSetActive:d}){const[c,u]=b.useState("new"),h=b.useMemo(()=>r.find(x=>x.name===c)??null,[r,c]),j=JSON.stringify(h??{name:"",values:{}});return e.jsxs(H,{title:"Profiles",badge:"profiles",icon:e.jsx(es,{className:"h-4 w-4"}),description:"Create reusable Codex overlays and set the active default profile.",disabledReason:n,children:[e.jsxs(_,{value:c,onValueChange:u,disabled:a,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Select profile"})}),e.jsxs(O,{children:[e.jsx(v,{value:"new",children:"Create new profile"}),r.map(x=>e.jsxs(v,{value:x.name,children:[x.name,x.name===s?" (active)":""]},x.name))]})]}),e.jsx(Os,{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:l,onDelete:async()=>{h&&(await o(h.name),u("new"))},onSetActive:async()=>{h&&await d(h.name)},onSave:async(x,g,A)=>{await i(x,g,A),u(x)}},j)]})}function As({workspacePath:s,disabled:r,saving:t,onSave:a}){const[n,l]=b.useState(s),[i,o]=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=>l(d.target.value),placeholder:"~/repo or /absolute/path",disabled:r}),e.jsxs(_,{value:i,onValueChange:o,disabled:r,children:[e.jsx(E,{children:e.jsx(P,{})}),e.jsxs(O,{children:[e.jsx(v,{value:"trusted",children:"trusted"}),e.jsx(v,{value:"untrusted",children:"untrusted"})]})]}),e.jsxs(w,{onClick:()=>a(n,i),disabled:r||t,children:[t?e.jsx(X,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save trust"]})]})}function Rs({workspacePath:s,entries:r,disabled:t=!1,disabledReason:a,saving:n=!1,onSave:l}){return e.jsxs(H,{title:"Project trust",badge:"projects",icon:e.jsx(ss,{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(As,{workspacePath:s,disabled:t,saving:n,onSave:l},s),e.jsx(w,{variant:"outline",className:"w-full justify-start",onClick:()=>l(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(w,{variant:"ghost",size:"sm",onClick:()=>l(i.path,i.trustLevel==="trusted"?"untrusted":"trusted"),disabled:t||n,children:"Toggle"}),e.jsx(w,{variant:"ghost",size:"icon",onClick:()=>l(i.path,null),disabled:t||n,children:e.jsx(Z,{className:"h-4 w-4"})})]})]},i.path))})]})}const L="__unset__",Ds=105e4,Ms=272e3,Ce=8e5,ye=7e5,Is=new Intl.NumberFormat("en-US");function z(s){return s??L}function $(s,r){return r&&!s.includes(r)?[r,...s]:s}function ie(s){return Is.format(s)}function Fs(s){return s?.trim().toLowerCase().startsWith("gpt-5.4")??!1}function Us(s,r){const t={};return r.model!==s.model&&(t.model=r.model),r.modelReasoningEffort!==s.modelReasoningEffort&&(t.modelReasoningEffort=r.modelReasoningEffort),r.modelContextWindow!==s.modelContextWindow&&(t.modelContextWindow=r.modelContextWindow),r.modelAutoCompactTokenLimit!==s.modelAutoCompactTokenLimit&&(t.modelAutoCompactTokenLimit=r.modelAutoCompactTokenLimit),r.modelProvider!==s.modelProvider&&(t.modelProvider=r.modelProvider),r.approvalPolicy!==s.approvalPolicy&&(t.approvalPolicy=r.approvalPolicy),r.sandboxMode!==s.sandboxMode&&(t.sandboxMode=r.sandboxMode),r.webSearch!==s.webSearch&&(t.webSearch=r.webSearch),r.toolOutputTokenLimit!==s.toolOutputTokenLimit&&(t.toolOutputTokenLimit=r.toolOutputTokenLimit),r.personality!==s.personality&&(t.personality=r.personality),t}function Ws({initialValues:s,providerNames:r,disabled:t,saving:a,onSave:n}){const[l,i]=b.useState(s),o=$(["minimal","low","medium","high","xhigh"],l.modelReasoningEffort),d=$(r,l.modelProvider),c=$(["on-request","never","untrusted"],l.approvalPolicy),u=$(["read-only","workspace-write","danger-full-access"],l.sandboxMode),h=$(["cached","live","disabled"],l.webSearch),j=$(["none","friendly","pragmatic"],l.personality),x=Us(s,l),g=Object.keys(x).length>0,A=Fs(l.model),U=m=>{const f=m.trim();return f.length>0?Number(f):null};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:"Model"}),e.jsx(C,{value:l.model??"",onChange:m=>i(f=>({...f,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(_,{value:z(l.modelReasoningEffort),onValueChange:m=>i(f=>({...f,modelReasoningEffort:m===L?null:m})),disabled:t,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Use default"})}),e.jsxs(O,{children:[e.jsx(v,{value:L,children:"Use default"}),o.map(m=>e.jsx(v,{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(_,{value:z(l.modelProvider),onValueChange:m=>i(f=>({...f,modelProvider:m===L?null:m})),disabled:t,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Use Codex default"})}),e.jsxs(O,{children:[e.jsx(v,{value:L,children:"Use Codex default"}),d.map(m=>e.jsx(v,{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(_,{value:z(l.approvalPolicy),onValueChange:m=>i(f=>({...f,approvalPolicy:m===L?null:m})),disabled:t,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Use default"})}),e.jsxs(O,{children:[e.jsx(v,{value:L,children:"Use default"}),c.map(m=>e.jsx(v,{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(_,{value:z(l.sandboxMode),onValueChange:m=>i(f=>({...f,sandboxMode:m===L?null:m})),disabled:t,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Use default"})}),e.jsxs(O,{children:[e.jsx(v,{value:L,children:"Use default"}),u.map(m=>e.jsx(v,{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(_,{value:z(l.webSearch),onValueChange:m=>i(f=>({...f,webSearch:m===L?null:m})),disabled:t,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Use default"})}),e.jsxs(O,{children:[e.jsx(v,{value:L,children:"Use default"}),h.map(m=>e.jsx(v,{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:l.toolOutputTokenLimit??"",onChange:m=>i(f=>({...f,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(_,{value:z(l.personality),onValueChange:m=>i(f=>({...f,personality:m===L?null:m})),disabled:t,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Use default"})}),e.jsxs(O,{children:[e.jsx(v,{value:L,children:"Use default"}),j.map(m=>e.jsx(v,{value:m,children:m},m))]})]})]})]}),e.jsxs("div",{className:"space-y-4 rounded-xl border border-amber-500/30 bg-amber-500/5 p-4 shadow-sm dark:bg-amber-400/5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(ts,{className:"h-4 w-4 text-amber-600 dark:text-amber-300"}),e.jsx("p",{className:"text-sm font-semibold",children:"Long context override"}),e.jsx(y,{variant:"outline",className:"border-amber-500/40 bg-background/80 text-[10px] uppercase tracking-[0.16em] text-amber-700 dark:text-amber-300",children:"Manual opt-in only"}),e.jsx(y,{variant:"secondary",className:"text-[10px] uppercase tracking-[0.16em] text-muted-foreground",children:A?"GPT-5.4 selected":"GPT-5.4 reference"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Draft values only. Nothing applies until Save."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(w,{type:"button",variant:"outline",size:"sm",disabled:t,onClick:()=>i(m=>({...m,modelContextWindow:Ce,modelAutoCompactTokenLimit:ye})),children:"Fill cautious pair"}),e.jsx(w,{type:"button",variant:"outline",size:"sm",disabled:t,onClick:()=>i(m=>({...m,modelContextWindow:Ds})),children:"Set official max window"}),e.jsx(w,{type:"button",variant:"ghost",size:"sm",disabled:t,onClick:()=>i(m=>({...m,modelContextWindow:null,modelAutoCompactTokenLimit:null})),children:"Clear"})]})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-3",children:[e.jsxs("div",{className:"rounded-lg border bg-background/85 px-3 py-3 shadow-sm shadow-black/5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"Official max"}),e.jsx("p",{className:"mt-1 font-mono text-base font-semibold text-foreground",children:"1.05M / 1M"}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:"GPT-5.4 context cap"})]}),e.jsxs("div",{className:"rounded-lg border bg-background/85 px-3 py-3 shadow-sm shadow-black/5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"Standard window"}),e.jsx("p",{className:"mt-1 font-mono text-base font-semibold text-foreground",children:ie(Ms)}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:"Normal usage window"})]}),e.jsxs("div",{className:"rounded-lg border bg-background/85 px-3 py-3 shadow-sm shadow-black/5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"Above 272K"}),e.jsx("p",{className:"mt-1 font-mono text-base font-semibold text-foreground",children:"Counts 2x"}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:"Usage-limit cost above 272K"})]})]}),e.jsxs("div",{className:"space-y-3 rounded-lg border bg-background/75 px-3 py-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"One cautious pair"}),e.jsxs("div",{className:"rounded-full border bg-background px-2.5 py-1 font-mono text-[11px] font-medium",children:["Context ",ie(Ce)]}),e.jsxs("div",{className:"rounded-full border bg-background px-2.5 py-1 font-mono text-[11px] font-medium",children:["Auto-compact ",ie(ye)]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx(y,{variant:"outline",className:"border-border/70 bg-background/80 text-[10px] uppercase tracking-[0.14em] text-muted-foreground",children:"Not official"}),e.jsx(y,{variant:"outline",className:"border-border/70 bg-background/80 text-[10px] uppercase tracking-[0.14em] text-muted-foreground",children:"Draft only"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px] text-muted-foreground",children:[e.jsx("span",{children:"Quick-fill only. Review before saving."}),!A&&l.model?e.jsxs("span",{children:[e.jsx("code",{children:l.model})," should be checked separately."]}):null]})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:"Model context window"}),e.jsx(C,{"aria-label":"Model context window",type:"number",min:1,value:l.modelContextWindow??"",onChange:m=>i(f=>({...f,modelContextWindow:U(m.target.value)})),placeholder:"Unset",disabled:t}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Writes ",e.jsx("code",{children:"model_context_window"}),". Leave unset to keep Codex defaults."]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:"Auto-compact token limit"}),e.jsx(C,{"aria-label":"Auto-compact token limit",type:"number",min:1,value:l.modelAutoCompactTokenLimit??"",onChange:m=>i(f=>({...f,modelAutoCompactTokenLimit:U(m.target.value)})),placeholder:"Unset",disabled:t}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Writes ",e.jsx("code",{children:"model_auto_compact_token_limit"}),". Leave unset to keep model defaults."]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px] text-muted-foreground",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-[0.14em]",children:"Docs"}),e.jsx("a",{href:"https://developers.openai.com/api/docs/models/gpt-5.4",target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:"GPT-5.4 model page"}),e.jsx("a",{href:"https://openai.com/index/introducing-gpt-5-4/",target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:"Release notes"}),e.jsx("a",{href:"https://developers.openai.com/codex/config-reference",target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:"Config reference"})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(w,{onClick:()=>n(x),disabled:t||a||!g,children:[a?e.jsx(X,{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:l}){return e.jsx(H,{title:"Top-level controls",badge:"config.toml",icon:e.jsx(rs,{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(Ws,{initialValues:s,providerNames:r,disabled:t,saving:n,onSave:l},JSON.stringify(s))})}function qs({workspacePath:s,activeProfile:r,topLevelSettings:t,projectTrustEntries:a,profileEntries:n,modelProviderEntries:l,mcpServerEntries:i,featureCatalog:o,featureState:d,disabled:c,disabledReason:u,saving:h,onPatch:j}){return e.jsx(xe,{className:"h-full",children:e.jsxs("div",{className:"space-y-6 pr-1 pb-6",children:[e.jsxs("div",{className:"group relative overflow-hidden rounded-xl border border-border/80 bg-background/50 p-5 shadow-sm transition-all hover:bg-background hover:shadow-md dark:border-border/60",children:[e.jsx("div",{className:"absolute inset-x-0 -top-px h-px bg-gradient-to-r from-transparent via-foreground/15 to-transparent transition-opacity group-hover:via-foreground/30"}),e.jsxs("div",{className:"flex flex-col gap-6 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{className:"flex-1 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary transition-colors group-hover:border-primary/30",children:e.jsx(ns,{className:"h-4 w-4"})}),e.jsx("div",{children:e.jsx("h2",{className:"text-base font-semibold tracking-tight text-foreground",children:"Structured controls boundary"})})]}),e.jsxs("ul",{className:"grid gap-3 sm:grid-cols-2 text-sm text-muted-foreground",children:[e.jsxs("li",{className:"flex items-start gap-2.5",children:[e.jsx(as,{className:"h-4 w-4 shrink-0 text-muted-foreground/60 mt-0.5"}),e.jsxs("span",{className:"leading-relaxed",children:["Writes exclusively to user-layer"," ",e.jsx("code",{className:"text-[11px] bg-muted/70 px-1.5 py-0.5 rounded border border-border/50",children:"config.toml"})]})]}),e.jsxs("li",{className:"flex items-start gap-2.5",children:[e.jsx(ls,{className:"h-4 w-4 shrink-0 text-muted-foreground/60 mt-0.5"}),e.jsx("span",{className:"leading-relaxed",children:"Does not reflect repo trust layers or CLI overrides"})]})]})]}),e.jsx("div",{className:"shrink-0 lg:w-[280px]",children:e.jsx("div",{className:"relative overflow-hidden rounded-lg border border-amber-500/20 bg-amber-500/5 p-4 transition-colors group-hover:border-amber-500/30 group-hover:bg-amber-500/10 dark:border-amber-400/10 dark:bg-amber-400/5",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(os,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-bold text-amber-700 dark:text-amber-300 uppercase tracking-wider",children:"Formatting Note"}),e.jsx("p",{className:"text-[13px] leading-relaxed text-amber-800/80 dark:text-amber-200/70",children:"Saves normalize TOML formatting and strip comments. Switch to the raw editor if exact layout matters."})]})]})})})]})]}),e.jsx(Ks,{values:t,providerNames:l.map(x=>x.name),disabled:c,disabledReason:u,saving:h,onSave:x=>j({kind:"top-level",values:x},"Saved top-level Codex settings.")}),e.jsx(Rs,{workspacePath:s,entries:a,disabled:c,disabledReason:u,saving:h,onSave:(x,g)=>j({kind:"project-trust",path:x,trustLevel:g},g?"Saved project trust entry.":"Removed project trust entry.")}),e.jsx(Ls,{activeProfile:r,entries:n,providerNames:l.map(x=>x.name),disabled:c,disabledReason:u,saving:h,onSave:(x,g,A)=>j({kind:"profile",action:"upsert",name:x,values:g,setAsActive:A},"Saved profile."),onDelete:x=>j({kind:"profile",action:"delete",name:x},"Deleted profile."),onSetActive:x=>j({kind:"profile",action:"set-active",name:x},"Set active profile.")}),e.jsx(Ps,{entries:l,disabled:c,disabledReason:u,saving:h,onSave:(x,g)=>j({kind:"model-provider",action:"upsert",name:x,values:g},"Saved model provider."),onDelete:x=>j({kind:"model-provider",action:"delete",name:x},"Deleted model provider.")}),e.jsx(ks,{entries:i,disabled:c,disabledReason:u,saving:h,onSave:(x,g)=>j({kind:"mcp-server",action:"upsert",name:x,values:g},"Saved MCP server."),onDelete:x=>j({kind:"mcp-server",action:"delete",name:x},"Deleted MCP server.")}),e.jsx(Cs,{catalog:o,state:d,disabled:c,disabledReason:u,onToggle:(x,g)=>j({kind:"feature",feature:x,enabled:g},"Saved feature toggle.")})]})})}const Ee=`model_provider = "cliproxy"
|
|
2
2
|
|
|
3
3
|
[model_providers.cliproxy]
|
|
4
4
|
base_url = "http://127.0.0.1:8317/api/provider/codex"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{A as c,a as d,b as g,c as x,d as h,e as j,f as A,g as D}from"./alert-dialog-
|
|
1
|
+
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{A as c,a as d,b as g,c as x,d as h,e as j,f as A,g as D}from"./alert-dialog-QyEXocpn.js";function f({open:i,onConfirm:l,onCancel:r,title:s,description:t,confirmText:a="Confirm",variant:o="default"}){return e.jsx(c,{open:i,onOpenChange:n=>!n&&r(),children:e.jsxs(d,{children:[e.jsxs(g,{children:[e.jsx(x,{children:s}),e.jsx(h,{children:t})]}),e.jsxs(j,{children:[e.jsx(A,{onClick:r,children:"Cancel"}),e.jsx(D,{onClick:l,className:o==="destructive"?"bg-red-600 hover:bg-red-700 text-white":"",children:a})]})]})})}export{f as C};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{bb as v,bc as Pe,B as S,d as N,a as ie,V as ne,n as H,L as T,aF as Y,I as ce,r as ke,s as Fe,t as Te,v as Me,w as X,x as he,bd as Le,S as b,be as Re,bf as Ae,bg as Ee,Q as Oe,R as _e,U as Z,bh as qe,c as se}from"./index-BmSzf0T9.js";import{r as w}from"./react-vendor-CNOkPC89.js";import{a as De,u as _,b as M}from"./tanstack-CrmUhA7Z.js";import{C as Ie}from"./confirm-dialog-CpDk6eu4.js";import{R as ge,L as fe,at as Ke,aa as Ue,Z as de,_ as Qe,T as je,aw as $e,b as Je,ad as ze,aE as Be,aO as me,K as Ge,Y as He,aP as Ve,x as we,I as ve}from"./icons-KVCk4_U8.js";import{S as ae}from"./separator-gw5BjIpP.js";import{S as We}from"./searchable-select-D4xr5xKS.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-Tc_D1a_B.js";async function Ye(){const t=await fetch(v("/copilot/status"));if(!t.ok)throw new Error("Failed to fetch copilot status");return t.json()}async function Xe(){const t=await fetch(v("/copilot/config"));if(!t.ok)throw new Error("Failed to fetch copilot config");return t.json()}async function Ze(){const t=await fetch(v("/copilot/models"));if(!t.ok)throw new Error("Failed to fetch copilot models");return t.json()}async function et(){const t=await fetch(v("/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(v("/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(v("/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(v("/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(v("/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(v("/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(v("/copilot/info"));if(!t.ok)throw new Error("Failed to fetch copilot info");return t.json()}async function lt(t){const s=await fetch(v("/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:Ye,refetchInterval:5e3}),l=_({queryKey:["copilot-config"],queryFn:Xe}),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 w.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(H,{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(H,{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(Y,{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(Y,{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(Y,{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(H,{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]=w.useState({}),[u,y]=w.useState(null),[C,P]=w.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(E=>({...E,[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=w.useMemo(()=>u!==null?u:i?.settings?JSON.stringify(i.settings,null,2):`{
|
|
1
|
+
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{bb as v,bc as Pe,B as S,d as N,a as ie,V as ne,n as H,L as T,aF as Y,I as ce,r as ke,s as Fe,t as Te,v as Me,w as X,x as he,bd as Le,S as b,be as Re,bf as Ae,bg as Ee,Q as Oe,R as _e,U as Z,bh as qe,c as se}from"./index-DOn6k1jF.js";import{r as w}from"./react-vendor-CNOkPC89.js";import{a as De,u as _,b as M}from"./tanstack-CrmUhA7Z.js";import{C as Ie}from"./confirm-dialog-BlSaX2gK.js";import{R as ge,L as fe,at as Ke,aa as Ue,Z as de,_ as Qe,T as je,aw as $e,b as Je,ad as ze,aE as Be,aO as me,K as Ge,Y as He,aP as Ve,x as we,I as ve}from"./icons-KVCk4_U8.js";import{S as ae}from"./separator-BCfZ54mZ.js";import{S as We}from"./searchable-select-1zOULoec.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-QyEXocpn.js";async function Ye(){const t=await fetch(v("/copilot/status"));if(!t.ok)throw new Error("Failed to fetch copilot status");return t.json()}async function Xe(){const t=await fetch(v("/copilot/config"));if(!t.ok)throw new Error("Failed to fetch copilot config");return t.json()}async function Ze(){const t=await fetch(v("/copilot/models"));if(!t.ok)throw new Error("Failed to fetch copilot models");return t.json()}async function et(){const t=await fetch(v("/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(v("/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(v("/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(v("/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(v("/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(v("/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(v("/copilot/info"));if(!t.ok)throw new Error("Failed to fetch copilot info");return t.json()}async function lt(t){const s=await fetch(v("/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:Ye,refetchInterval:5e3}),l=_({queryKey:["copilot-config"],queryFn:Xe}),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 w.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(H,{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(H,{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(Y,{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(Y,{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(Y,{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(H,{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]=w.useState({}),[u,y]=w.useState(null),[C,P]=w.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(E=>({...E,[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=w.useMemo(()=>u!==null?u:i?.settings?JSON.stringify(i.settings,null,2):`{
|
|
2
2
|
"env": {}
|
|
3
3
|
}`,[u,i]),m=w.useCallback(h=>{y(h)},[]),oe=w.useMemo(()=>{try{return JSON.parse(k),!0}catch{return!1}},[k]),be=w.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=w.useMemo(()=>{if(u!==null)try{return JSON.parse(u)}catch{return i?.settings}return i?.settings},[u,i?.settings]),ye=w.useMemo(()=>xe(le),[le]),Se=w.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 E=[];if(u!==null&&oe){const F=JSON.parse(k);E=xe(F);const Ce=await x({settings:F,expectedMtime:h?void 0:i?.mtime});j.push(...Ce.warnings??[])}const W=pe(j),O=[];W.length>0&&O.push(W.map(F=>F.message).join(" ")),E.length>0&&O.push(`Missing fields will use defaults: ${E.join(", ")}`),W.length>0?q.warning("Copilot configuration saved with model adjustments",{description:O.join(" ")}):O.length>0?q.success("Copilot configuration saved",{description:O.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(Ee,{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(Oe,{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(Z,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(Z,{value:"settings",className:"flex-1",children:"Settings"}),e.jsx(Z,{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 G({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(we,{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(ve,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:c||"No"})]})})]})}function wt(){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(H,{className:"flex-1",children:l?e.jsx(wt,{}):e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsxs("div",{className:"rounded-md border border-yellow-500/50 bg-yellow-500/15 p-3 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(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(G,{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(G,{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(G,{icon:Ge,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(G,{icon:He,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(we,{className:"w-3 h-3 text-green-500"}),t("copilotPage.active")]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ve,{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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as b}from"./react-vendor-CNOkPC89.js";import{t as o}from"./notifications-B2HqRBj7.js";import{bb as w,bc as us,a as Le,B as A,d as p,c as H,n as G,Q as ms,R as gs,U as le,V as de,L as F,I as ue,aF as Te,bh as hs,ag as xs,ah as fs,ai as ps,aj as js,ak as Ps,aC as bs,bd as ws}from"./index-DOn6k1jF.js";import{a as ys,u as Q,b as T}from"./tanstack-CrmUhA7Z.js";import{D as Ie}from"./default-ports-1QQSffYX.js";import{S as vs}from"./separator-BCfZ54mZ.js";import{S as Ns}from"./searchable-select-1zOULoec.js";import{R as Re,T as Cs,ah as Ss,K as J,ad as ks,aw as me,aP as Fe,aO as _s,L as R,J as Ms,at as As,aa as Ds,Z as ge,x as Ts,I as Rs}from"./icons-KVCk4_U8.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";function Fs(s){if(!s||typeof s!="object")return!1;const a=s;return typeof a.message=="string"&&typeof a.stage=="string"&&typeof a.status=="number"&&typeof a.duration_ms=="number"&&typeof a.ok=="boolean"}function Ls(s){if(!s||typeof s!="object"||!("error"in s))return null;const a=s;return typeof a.error=="string"?a.error:null}async function Is(){const s=await fetch(w("/cursor/status"));if(!s.ok)throw new Error("Failed to fetch cursor status");return s.json()}async function Os(){const s=await fetch(w("/cursor/settings"));if(!s.ok)throw new Error("Failed to fetch cursor config");return s.json()}async function Es(){const s=await fetch(w("/cursor/models"));if(!s.ok)throw new Error("Failed to fetch cursor models");return s.json()}async function Ks(){const s=await fetch(w("/cursor/settings/raw"));if(!s.ok)throw new Error("Failed to fetch cursor raw settings");return s.json()}async function zs(s){const a=await fetch(w("/cursor/settings"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!a.ok)throw new Error("Failed to update cursor config");return a.json()}async function qs(s){const a=await fetch(w("/cursor/settings/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(a.status===409)throw new us("Cursor raw settings changed externally");if(!a.ok)throw new Error("Failed to save cursor raw settings");return a.json()}async function Gs(){const s=await fetch(w("/cursor/auth/auto-detect"),{method:"POST"});if(!s.ok){const a=await s.json().catch(()=>({error:"Auto-detect failed"}));throw new Error(a.error||"Auto-detect failed")}return s.json()}async function Qs(s){const a=await fetch(w("/cursor/auth/import"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!a.ok){const c=await a.json().catch(()=>({error:"Manual import failed"}));throw new Error(c.error||"Manual import failed")}return a.json()}async function Js(){const s=await fetch(w("/cursor/daemon/start"),{method:"POST"});if(!s.ok)throw new Error("Failed to start cursor daemon");return s.json()}async function Us(){const s=await fetch(w("/cursor/daemon/stop"),{method:"POST"});if(!s.ok)throw new Error("Failed to stop cursor daemon");return s.json()}async function Bs(){const s=await fetch(w("/cursor/probe"),{method:"POST"}),a=await s.json().catch(()=>null);return Fs(a)?a:{ok:!1,stage:"runtime",status:s.status,duration_ms:0,error_type:"runtime_error",message:Ls(a)??"Failed to run live probe"}}function Hs(){const s=ys(),a=Q({queryKey:["cursor-status"],queryFn:Is,refetchInterval:5e3}),c=Q({queryKey:["cursor-config"],queryFn:Os}),d=Q({queryKey:["cursor-models"],queryFn:Es}),l=Q({queryKey:["cursor-raw-settings"],queryFn:Ks}),g=()=>{s.invalidateQueries({queryKey:["cursor-status"]}),s.invalidateQueries({queryKey:["cursor-config"]}),s.invalidateQueries({queryKey:["cursor-models"]}),s.invalidateQueries({queryKey:["cursor-raw-settings"]})},h=T({mutationFn:zs,onSuccess:g}),u=T({mutationFn:qs,onSuccess:g}),r=T({mutationFn:Gs,onSuccess:g}),m=T({mutationFn:Qs,onSuccess:g}),x=T({mutationFn:Js,onSuccess:g}),i=T({mutationFn:Us,onSuccess:g}),P=T({mutationFn:Bs,onSettled:()=>{s.invalidateQueries({queryKey:["cursor-status"]}),s.invalidateQueries({queryKey:["cursor-models"]})}});return b.useMemo(()=>({status:a.data,statusLoading:a.isLoading,statusError:a.error,refetchStatus:a.refetch,config:c.data,configLoading:c.isLoading,refetchConfig:c.refetch,models:d.data?.models??[],currentModel:d.data?.current??null,modelsLoading:d.isLoading,rawSettings:l.data,rawSettingsLoading:l.isLoading,refetchRawSettings:l.refetch,updateConfig:h.mutate,updateConfigAsync:h.mutateAsync,isUpdatingConfig:h.isPending,saveRawSettings:u.mutate,saveRawSettingsAsync:u.mutateAsync,isSavingRawSettings:u.isPending,autoDetectAuth:r.mutate,autoDetectAuthAsync:r.mutateAsync,isAutoDetectingAuth:r.isPending,autoDetectAuthResult:r.data,importManualAuth:m.mutate,importManualAuthAsync:m.mutateAsync,isImportingManualAuth:m.isPending,manualAuthResult:m.data,startDaemon:x.mutate,startDaemonAsync:x.mutateAsync,isStartingDaemon:x.isPending,stopDaemon:i.mutate,stopDaemonAsync:i.mutateAsync,isStoppingDaemon:i.isPending,runProbe:P.mutate,runProbeAsync:P.mutateAsync,isRunningProbe:P.isPending,probeResult:P.data,resetProbe:P.reset}),[a.data,a.isLoading,a.error,a.refetch,c.data,c.isLoading,c.refetch,d.data,d.isLoading,l.data,l.isLoading,l.refetch,h.mutate,h.mutateAsync,h.isPending,u.mutate,u.mutateAsync,u.isPending,r.mutate,r.mutateAsync,r.isPending,r.data,m.mutate,m.mutateAsync,m.isPending,m.data,x.mutate,x.mutateAsync,x.isPending,i.mutate,i.mutateAsync,i.isPending,P.mutate,P.mutateAsync,P.isPending,P.data,P.reset])}function he(s,a){return JSON.stringify({enabled:s?.enabled??null,authenticated:s?.authenticated??null,token_expired:s?.token_expired??null,daemon_running:s?.daemon_running??null,port:s?.port??null,ghost_mode:s?.ghost_mode??null,auto_start:a?.auto_start??null,model:a?.model??null})}function U(s){return{port:String(s?.port??Ie),auto_start:s?.auto_start??!1,ghost_mode:s?.ghost_mode??!0,model:s?.model?.trim()||"gpt-5.3-codex",opus_model:s?.opus_model?.trim()||"",sonnet_model:s?.sonnet_model?.trim()||"",haiku_model:s?.haiku_model?.trim()||""}}function C(s,a,c){return s.find(l=>a.some(g=>g.test(l.id)))?.id??c}function xe(s){return s.toLowerCase().replace(/[^a-z0-9]/g,"")}function S(s,a,c){const d=new Set(a.map(xe)),l=s.find(h=>d.has(xe(h.id)));if(l)return l.id;const g=s.find(h=>d.has(xe(h.name)));return g?g.id:c}function Vs(s){try{const a=JSON.parse(s||"{}");return!a||typeof a!="object"||Array.isArray(a)?{isValid:!1,error:"Raw settings must be a JSON object"}:{isValid:!0,settings:a}}catch(a){return{isValid:!1,error:a.message||"Invalid JSON"}}}function B({label:s,description:a,value:c,models:d,disabled:l,allowDefaultFallback:g=!1,onChange:h}){const{t:u}=Le(),r=c||(g?"__default":""),m=b.useMemo(()=>{const x=d.map(i=>({value:i.id,groupKey:"models",searchText:`${i.name||i.id} ${i.id}`,keywords:[i.provider],triggerContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:i.name||i.id}),i.provider&&e.jsx(A,{variant:"outline",className:"text-[9px] h-4 px-1 capitalize",children:i.provider})]}),itemContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate text-xs font-mono",children:i.name||i.id}),e.jsx(A,{variant:"outline",className:"text-[9px] h-4 px-1 capitalize",children:i.provider})]})}));return g?[{value:"__default",groupKey:"models",searchText:u("cursorPage.useDefaultModel"),triggerContent:e.jsx("span",{className:"truncate font-mono text-xs",children:u("cursorPage.useDefaultModel")}),itemContent:e.jsx("span",{children:u("cursorPage.useDefaultModel")})},...x]:x},[g,d,u]);return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx(F,{className:"text-xs font-medium",children:s}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a})]}),e.jsx(Ns,{value:r||void 0,onChange:x=>{if(g&&x==="__default"){h("");return}h(x)},disabled:l,placeholder:u("cursorPage.selectModel"),searchPlaceholder:u("searchableSelect.searchModels"),emptyText:u("searchableSelect.noResults"),triggerClassName:"h-9",groups:[{key:"models",label:u("cursorPage.availableModelCount",{count:d.length})}],options:m})]})}function fe({icon:s,label:a,ok:c,detail:d}){return e.jsxs("div",{className:"flex items-center gap-3 rounded-lg bg-muted/50 px-3 py-2",children:[e.jsx(s,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("p",{className:"text-sm",children:a})}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[c?e.jsx(Ts,{className:"h-4 w-4 text-green-500"}):e.jsx(Rs,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:H("text-xs",c?"text-green-500":"text-muted-foreground"),title:d,children:d})]})]})}function ia(){const{t:s}=Le(),{status:a,statusLoading:c,refetchStatus:d,config:l,refetchConfig:g,updateConfigAsync:h,isUpdatingConfig:u,models:r,modelsLoading:m,currentModel:x,rawSettings:i,rawSettingsLoading:P,refetchRawSettings:Oe,saveRawSettingsAsync:Ee,isSavingRawSettings:pe,autoDetectAuthAsync:Ke,isAutoDetectingAuth:je,importManualAuthAsync:ze,isImportingManualAuth:Pe,startDaemonAsync:qe,isStartingDaemon:Ge,stopDaemonAsync:Qe,isStoppingDaemon:be,runProbeAsync:Je,isRunningProbe:V,probeResult:W,resetProbe:Ue}=Hs(),[D,X]=b.useState(()=>U()),[y,Z]=b.useState(!1),[we,Be]=b.useState("{}"),[L,$]=b.useState(!1),[He,E]=b.useState(!1),[Y,ye]=b.useState(""),[ee,ve]=b.useState(""),[Ne,Ce]=b.useState(()=>W?he(a,l):null),k=U(l),Se=y?D.port:k.port,se=y?D.auto_start:k.auto_start,ae=y?D.ghost_mode:k.ghost_mode,v=y?D.model:k.model,te=y?D.opus_model:k.opus_model,re=y?D.sonnet_model:k.sonnet_model,ne=y?D.haiku_model:k.haiku_model,oe=L?we:JSON.stringify(i?.settings??{},null,2),ke=!!i,I=b.useMemo(()=>Vs(oe),[oe]),_e=I.isValid,K=y||L,Ve=!L||ke&&_e,We=he(a,l),j=W&&!K&&Ne!==null&&Ne===We?W:null,z=b.useMemo(()=>{const t=new Set,n=[...r].sort((M,ce)=>M.name.localeCompare(ce.name)),f=n.filter(M=>t.has(M.id)?!1:(t.add(M.id),!0));return v&&!n.some(M=>M.id===v)?[{id:v,name:v,provider:"custom"},...f]:f},[r,v]),N=t=>{X(n=>t(y?n:k)),Z(!0)},_=()=>{Ue(),Ce(null)},Xe=(t=l)=>{X(U(t)),Z(!1)},Ze=!!(a?.enabled&&a?.authenticated&&!a?.token_expired),$e=b.useMemo(()=>a?.enabled?e.jsx(A,{children:s("cursorPage.enabled")}):e.jsx(A,{variant:"secondary",children:s("cursorPage.disabled")}),[a?.enabled,s]),Ye=async({suppressSuccessToast:t=!1}={})=>{const n=Number(Se);if(!Number.isInteger(n)||n<1||n>65535)return o.error(s("cursorPage.invalidPort")),!1;if(!v.trim())return o.error(s("cursorPage.defaultModelRequired")),!1;try{return await h({port:n,auto_start:se,ghost_mode:ae,model:v,opus_model:te||void 0,sonnet_model:re||void 0,haiku_model:ne||void 0}),Z(!1),X(U({port:n,auto_start:se,ghost_mode:ae,model:v,opus_model:te||void 0,sonnet_model:re||void 0,haiku_model:ne||void 0})),_(),t||o.success(s("cursorPage.savedConfig")),!0}catch(f){return o.error(f.message||s("cursorPage.failedSaveConfig")),!1}},ie=t=>{if(m){o.error(s("cursorPage.modelsLoadingWait"));return}if(r.length===0){o.error(s("cursorPage.noModelsAvailable"));return}const n=v||x||r[0]?.id||"gpt-5.3-codex",f=S(r,["gpt-5.3-codex","gpt53codex","GPT-5.3 Codex"],C(r,[/gpt[-.]?5.*codex/i],n)),M=S(r,["gpt-5.1-codex-max","gpt51codexmax","GPT-5.1 Codex Max"],C(r,[/gpt[-.]?5.*codex.*max/i],f)),ce=S(r,["gpt-5-fast","gpt5fast","GPT-5 Fast"],C(r,[/gpt[-.]?5.*fast/i],f)),cs=S(r,["gpt-5-mini","gpt5mini","GPT-5 Mini"],C(r,[/gpt[-.]?5.*mini/i],ce)),Ae=S(r,["claude-4.6-opus","claude46opus","Claude 4.6 Opus"],C(r,[/claude[-.]?4\.?6.*opus/i,/claude.*opus/i],f)),De=S(r,["claude-4.5-sonnet","claude45sonnet","Claude 4.5 Sonnet"],C(r,[/claude[-.]?4\.?5.*sonnet/i,/claude.*sonnet/i],f)),ls=S(r,["claude-4.5-haiku","claude45haiku","Claude 4.5 Haiku"],C(r,[/claude[-.]?4\.?5.*haiku/i,/haiku/i],De)),q=S(r,["gemini-3-pro","gemini3pro","Gemini 3 Pro"],C(r,[/gemini[-.]?3.*pro/i],f)),ds=S(r,["gemini-3-flash","gemini3flash","Gemini 3 Flash"],C(r,[/gemini[-.]?3.*flash/i,/gemini[-.]?2\.?5.*flash/i],q));if(t==="codex53"){N(O=>({...O,model:f,opus_model:M,sonnet_model:f,haiku_model:cs})),o.success(s("cursorPage.appliedCodexPreset"));return}if(t==="claude46"){N(O=>({...O,model:Ae,opus_model:Ae,sonnet_model:De,haiku_model:ls})),o.success(s("cursorPage.appliedClaudePreset"));return}N(O=>({...O,model:q,opus_model:q,sonnet_model:q,haiku_model:ds})),o.success(s("cursorPage.appliedGeminiPreset"))},Me=async t=>{try{await h({enabled:t}),_(),o.success(s(t?"cursorPage.integrationEnabled":"cursorPage.integrationDisabled"))}catch(n){o.error(n.message||s("cursorPage.failedUpdateIntegration"))}},es=async()=>{try{await Ke(),_(),o.success(s("cursorPage.credentialsImported"))}catch(t){o.error(t.message||s("cursorPage.autoDetectFailed"))}},ss=async()=>{if(!Y.trim()||!ee.trim()){o.error(s("cursorPage.manualRequired"));return}try{await ze({accessToken:Y.trim(),machineId:ee.trim()}),_(),o.success(s("cursorPage.credentialsImported")),E(!1),ye(""),ve("")}catch(t){o.error(t.message||s("cursorPage.manualImportFailed"))}},as=async()=>{try{const t=await qe();if(!t.success){o.error(t.error||s("cursorPage.failedStartDaemon"));return}_(),o.success(t.pid?s("cursorPage.daemonStartedWithPid",{pid:t.pid}):s("cursorPage.daemonStarted"))}catch(t){o.error(t.message||s("cursorPage.failedStartDaemon"))}},ts=async()=>{try{const t=await Qe();if(!t.success){o.error(t.error||s("cursorPage.failedStopDaemon"));return}_(),o.success(s("cursorPage.daemonStopped"))}catch(t){o.error(t.message||s("cursorPage.failedStopDaemon"))}},rs=async()=>{if(K){o.error(s("cursorPage.probeSaveFirst"));return}try{const t=await Je(),n=await d();if(Ce(he(n.data??a,l)),t.ok){o.success(s("cursorPage.probeSucceeded"));return}o.error(t.message||s("cursorPage.probeFailed"))}catch(t){o.error(t.message||s("cursorPage.probeFailed"))}},ns=async({suppressSuccessToast:t=!1}={})=>{if(!ke)return o.error(s("cursorPage.rawLoading")),!1;if(!I.isValid||!I.settings)return o.error(I.error||s("cursorPage.invalidJson")),!1;try{return await Ee({settings:I.settings,expectedMtime:i?.mtime}),$(!1),_(),t||o.success(s("cursorPage.rawSaved")),!0}catch(n){return ws(n)?o.error(s("cursorPage.rawChanged")):o.error(n.message||s("cursorPage.failedSaveRaw")),!1}},os=async()=>{if(!K)return;const t=y,n=L;t&&!await Ye({suppressSuccessToast:n})||n&&!await ns({suppressSuccessToast:t})||t&&n&&o.success(s("cursorPage.savedAll"))},is=async()=>{$(!1),_();const[,t]=await Promise.all([d(),g(),Oe()]);Xe(t.data??l)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col bg-muted/30 shrink-0",children:[e.jsxs("div",{className:"p-4 border-b bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("img",{src:"/assets/sidebar/cursor.svg",alt:"",className:"w-5 h-5 object-contain shrink-0"}),e.jsx("h1",{className:"font-semibold",children:s("cursorPage.title")}),e.jsx(A,{variant:"outline",className:"h-5 border-amber-500/60 bg-amber-500/10 px-1.5 text-[10px] font-semibold uppercase tracking-wide text-amber-800 dark:text-amber-300",children:s("cursorPage.beta")}),$e]}),e.jsx(p,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>d(),disabled:c,"aria-label":s("cursorPage.refreshStatus"),title:s("cursorPage.refreshStatus"),children:e.jsx(Re,{className:H("w-4 h-4",c&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("cursorPage.subtitle")})]}),e.jsx(G,{className:"flex-1",children:e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsxs("div",{className:"rounded-md border border-yellow-500/50 bg-yellow-500/15 p-3 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Cs,{className:"h-4 w-4 text-yellow-600 dark:text-yellow-400 shrink-0"}),e.jsx("span",{className:"text-xs font-semibold text-yellow-800 dark:text-yellow-200",children:s("cursorPage.unofficialTitle")})]}),e.jsxs("ul",{className:"text-[11px] text-yellow-700 dark:text-yellow-300 space-y-0.5 pl-6 list-disc",children:[e.jsx("li",{children:s("cursorPage.unofficialItem1")}),e.jsx("li",{children:s("cursorPage.unofficialItem2")}),e.jsx("li",{children:s("cursorPage.unofficialItem3")})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(fe,{icon:Ss,label:s("cursorPage.integration"),ok:!!a?.enabled,detail:a?.enabled?s("cursorPage.enabled"):s("cursorPage.disabled")}),e.jsx(fe,{icon:J,label:s("cursorPage.authentication"),ok:!!(a?.authenticated&&!a?.token_expired),detail:a?.authenticated?a?.token_expired?s("cursorPage.expired"):a.auth_method??s("cursorPage.connected"):s("cursorPage.notConnected")}),e.jsx(fe,{icon:ks,label:s("cursorPage.daemon"),ok:!!a?.daemon_running,detail:a?.daemon_running?s("cursorPage.running"):s("cursorPage.stopped")})]}),e.jsxs("div",{className:"rounded-md border bg-background/80 p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(me,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:s("cursorPage.liveProbe")})]}),e.jsx(A,{variant:j?"outline":"secondary",className:H(j?.ok&&"border-green-500/40 text-green-600 dark:text-green-300",j&&!j.ok&&"border-red-500/40 text-red-600 dark:text-red-300"),children:j?j.ok?s("cursorPage.probeSucceeded"):s("cursorPage.probeFailed"):s("cursorPage.probeNotRun")})]}),j?e.jsxs("div",{className:"space-y-1 text-xs",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-muted-foreground",children:s("cursorPage.probeStage")}),e.jsx("span",{className:"font-mono uppercase",children:j.stage})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-muted-foreground",children:s("cursorPage.probeHttpStatus")}),e.jsx("span",{className:"font-mono",children:j.status})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-muted-foreground",children:s("cursorPage.probeDuration")}),e.jsxs("span",{className:"font-mono",children:[j.duration_ms," ms"]})]}),j.model?e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-muted-foreground",children:s("cursorPage.probeModel")}),e.jsx("span",{className:"font-mono text-[11px] text-right break-all",children:j.model})]}):null,e.jsxs("div",{className:"space-y-1 pt-1",children:[e.jsx("span",{className:"text-muted-foreground",children:s("cursorPage.probeMessage")}),e.jsx("p",{className:"text-[11px] leading-relaxed break-words",children:j.message})]})]}):e.jsx("p",{className:"text-xs text-muted-foreground",children:s("cursorPage.probeNotRun")}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:s("cursorPage.probeLocalReadinessHint")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:s("cursorPage.actions")}),a?.enabled?e.jsxs(p,{variant:"outline",size:"sm",className:"w-full",onClick:()=>Me(!1),disabled:u,children:[e.jsx(Fe,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.disableIntegration")]}):e.jsxs(p,{size:"sm",className:"w-full",onClick:()=>Me(!0),disabled:u,children:[e.jsx(_s,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.enableIntegration")]}),e.jsxs(p,{variant:"outline",size:"sm",className:"w-full",onClick:es,disabled:je,children:[je?e.jsx(R,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(J,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.autoDetectAuth")]}),e.jsxs(p,{variant:"outline",size:"sm",className:"w-full",onClick:()=>E(!0),children:[e.jsx(J,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.manualAuthImport")]}),e.jsxs(p,{variant:"outline",size:"sm",className:"w-full",onClick:rs,disabled:V,children:[V?e.jsx(R,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(me,{className:"w-3.5 h-3.5 mr-1.5"}),s(V?"cursorPage.probing":j?"cursorPage.rerunLiveProbe":"cursorPage.runLiveProbe")]}),a?.daemon_running?e.jsxs(p,{variant:"outline",size:"sm",className:"w-full",onClick:ts,disabled:be,children:[be?e.jsx(R,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(Fe,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.stopDaemon")]}):e.jsxs(p,{size:"sm",className:"w-full",onClick:as,disabled:!Ze,children:[Ge?e.jsx(R,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(Ms,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.startDaemon")]})]})]})}),e.jsx("div",{className:"p-3 border-t bg-background text-xs text-muted-foreground",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{children:s("cursorPage.port")}),e.jsx("span",{children:a?.port??l?.port??Ie})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-background overflow-hidden",children:e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:s("cursorPage.configuration")}),i&&e.jsx(A,{variant:"outline",className:"text-xs",children:"cursor.settings.json"})]}),i&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[s("cursorPage.lastModified")," ",i.exists?new Date(i.mtime).toLocaleString():s("cursorPage.neverSaved")]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p,{variant:"ghost",size:"sm",onClick:is,disabled:c||P,"aria-label":s("cursorPage.refreshConfiguration"),title:s("cursorPage.refreshConfiguration"),children:e.jsx(Re,{className:H("w-4 h-4",(c||P)&&"animate-spin")})}),e.jsx(p,{size:"sm",onClick:os,disabled:u||pe||!K||!Ve,children:u||pe?e.jsxs(e.Fragment,{children:[e.jsx(R,{className:"w-4 h-4 mr-1 animate-spin"}),s("cursorPage.saving")]}):e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"w-4 h-4 mr-1"}),s("cursorPage.save")]})})]})]}),e.jsxs("div",{className:"flex-1 min-h-0 flex divide-x overflow-hidden",children:[e.jsx("div",{className:"w-[540px] shrink-0 flex flex-col min-h-0 overflow-hidden bg-muted/5",children:e.jsxs(ms,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(gs,{className:"w-full",children:[e.jsx(le,{value:"config",className:"flex-1",children:s("cursorPage.modelConfig")}),e.jsx(le,{value:"settings",className:"flex-1",children:s("cursorPage.settings")}),e.jsx(le,{value:"info",className:"flex-1",children:s("cursorPage.info")})]})}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden flex flex-col",children:[e.jsx(de,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(G,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(Ds,{className:"w-4 h-4"}),s("cursorPage.presets")]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:s("cursorPage.presetsDesc")}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(p,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>ie("codex53"),disabled:m||r.length===0,title:"OpenAI-only mapping: GPT-5.3 Codex / Codex Max / GPT-5 Mini",children:[e.jsx(ge,{className:"w-3 h-3"}),"GPT-5.3 Codex"]}),e.jsxs(p,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>ie("claude46"),disabled:m||r.length===0,title:"Claude-first mapping: Opus 4.6 / Sonnet 4.5 / Haiku 4.5",children:[e.jsx(ge,{className:"w-3 h-3"}),"Claude 4.6"]}),e.jsxs(p,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>ie("gemini3"),disabled:m||r.length===0,title:"Gemini-first mapping: Gemini 3 Pro + Gemini 3 Flash",children:[e.jsx(ge,{className:"w-3 h-3"}),"Gemini 3 Pro"]})]})]}),e.jsx(vs,{}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-2",children:s("cursorPage.modelMapping")}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:s("cursorPage.modelMappingDesc")}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(B,{label:s("cursorPage.defaultModel"),description:s("cursorPage.defaultModelDesc"),value:v,models:z,disabled:m,onChange:t=>{N(n=>({...n,model:t}))}}),e.jsx(B,{label:s("cursorPage.opusModel"),description:s("cursorPage.opusModelDesc"),value:te,models:z,disabled:m,allowDefaultFallback:!0,onChange:t=>{N(n=>({...n,opus_model:t}))}}),e.jsx(B,{label:s("cursorPage.sonnetModel"),description:s("cursorPage.sonnetModelDesc"),value:re,models:z,disabled:m,allowDefaultFallback:!0,onChange:t=>{N(n=>({...n,sonnet_model:t}))}}),e.jsx(B,{label:s("cursorPage.haikuModel"),description:s("cursorPage.haikuModelDesc"),value:ne,models:z,disabled:m,allowDefaultFallback:!0,onChange:t=>{N(n=>({...n,haiku_model:t}))}})]})]})]})})}),e.jsx(de,{value:"settings",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(G,{className:"flex-1",children:e.jsx("div",{className:"p-4 space-y-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:s("cursorPage.runtimeSettings")}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(F,{htmlFor:"cursor-port",className:"text-xs",children:"Port"}),e.jsx(ue,{id:"cursor-port",type:"number",min:1,max:65535,className:"max-w-[150px] h-8",value:Se,onChange:t=>{N(n=>({...n,port:t.target.value}))}})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(F,{htmlFor:"cursor-auto-start",className:"text-xs",children:s("cursorPage.autoStartDaemon")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:s("cursorPage.autoStartDesc")})]}),e.jsx(Te,{id:"cursor-auto-start",checked:se,onCheckedChange:t=>{N(n=>({...n,auto_start:t}))}})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(F,{htmlFor:"cursor-ghost-mode",className:"text-xs",children:s("cursorPage.ghostMode")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:s("cursorPage.ghostModeDesc")})]}),e.jsx(Te,{id:"cursor-ghost-mode",checked:ae,onCheckedChange:t=>{N(n=>({...n,ghost_mode:t}))}})]})]})})})}),e.jsx(de,{value:"info",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(G,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:s("cursorPage.provider")}),e.jsx("span",{className:"font-mono",children:"Cursor IDE"})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:s("cursorPage.filePath")}),e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:i?.path??"~/.ccs/cursor.settings.json"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Model mapping writes `ANTHROPIC_MODEL`, `ANTHROPIC_DEFAULT_OPUS_MODEL`, `ANTHROPIC_DEFAULT_SONNET_MODEL`, and `ANTHROPIC_DEFAULT_HAIKU_MODEL` in `cursor.settings.json`."})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:s("cursorPage.availableModels")}),m?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(R,{className:"w-4 h-4 animate-spin"}),s("cursorPage.loadingModels")]}):r.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:s("cursorPage.noModels")}):e.jsx("div",{className:"space-y-2",children:r.map(t=>e.jsxs("div",{className:"rounded-lg border px-3 py-2 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:t.id}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[t.name," • ",t.provider]})]}),t.id===x&&e.jsx(A,{children:s("cursorPage.default")})]},t.id))})]})]})})})]})]})}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-2 bg-muted/30 border-b flex items-center gap-2 shrink-0 h-[45px]",children:[e.jsx(me,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:s("cursorPage.rawConfiguration")})]}),e.jsx(hs,{rawJsonContent:oe,isRawJsonValid:_e,rawJsonEdits:L?we:null,rawSettingsEnv:i?.settings?.env,onChange:t=>{$(!0),Be(t)}})]})]})]})})]}),e.jsx(xs,{open:He,onOpenChange:E,children:e.jsxs(fs,{children:[e.jsxs(ps,{children:[e.jsx(js,{children:s("cursorPage.manualImportTitle")}),e.jsx(Ps,{children:s("cursorPage.manualImportDesc")})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(F,{htmlFor:"cursor-manual-token",children:s("cursorPage.accessToken")}),e.jsx(ue,{id:"cursor-manual-token",value:Y,onChange:t=>ye(t.target.value),placeholder:s("cursorPage.accessTokenPlaceholder")})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(F,{htmlFor:"cursor-manual-machine-id",children:s("cursorPage.machineId")}),e.jsx(ue,{id:"cursor-manual-machine-id",value:ee,onChange:t=>ve(t.target.value),placeholder:s("cursorPage.machineIdPlaceholder")})]})]}),e.jsxs(bs,{children:[e.jsx(p,{variant:"outline",onClick:()=>E(!1),children:s("cursorPage.cancel")}),e.jsxs(p,{onClick:ss,disabled:Pe,children:[Pe?e.jsx(R,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(J,{className:"w-4 h-4 mr-2"}),s("cursorPage.import")]})]})]})})]})}export{ia as CursorPage};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as Q}from"./react-vendor-CNOkPC89.js";import{t as j}from"./notifications-B2HqRBj7.js";import{bb as X,bc as ye,C as b,j as v,k as y,B as P,b as N,r as H,s as q,t as W,v as Y,w as k,I as oe,a as Ne,bi as we,bj as ne,bk as ke,Q as Se,R as Pe,U,V,n as T,bd as Ee,c as Ce}from"./index-BmSzf0T9.js";import{a as Te,u as ae,b as Ae}from"./tanstack-CrmUhA7Z.js";import{a as Re}from"./raw-json-settings-editor-panel-Cb7ZInQV.js";import{ax as _e,aB as De,N as Oe,L as Be,S as Me,aX as Fe,x as Le,I as Ie,T as Ke,ad as Ue,ah as Ve,p as ie}from"./icons-KVCk4_U8.js";import{S as A}from"./separator-gw5BjIpP.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";function $e(s){try{const r=JSON.parse(s);return!r||typeof r!="object"||Array.isArray(r)?{settings:null,parseError:"JSON root must be an object."}:{settings:r,parseError:null}}catch(r){return{settings:null,parseError:r.message}}}async function ze(){const s=await fetch(X("/droid/diagnostics"));if(!s.ok)throw new Error("Failed to fetch Droid diagnostics");return s.json()}async function Je(){const s=await fetch(X("/droid/settings/raw"));if(!s.ok)throw new Error("Failed to fetch Droid raw settings");return s.json()}async function Qe(s){const r=await fetch(X("/droid/settings/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(r.status===409)throw new ye("Droid raw settings changed externally");if(!r.ok){const n=await r.json().catch(()=>null);throw new Error(n?.error||"Failed to save Droid raw settings")}return r.json()}function He(){const s=Te(),r=ae({queryKey:["droid-diagnostics"],queryFn:ze,refetchInterval:1e4}),n=ae({queryKey:["droid-raw-settings"],queryFn:Je}),o=Ae({mutationFn:Qe,onSuccess:(d,l)=>{s.setQueryData(["droid-raw-settings"],t=>{const a=t?.path??"~/.factory/settings.json",u=t?.resolvedPath??a,x=$e(l.rawText);return{path:a,resolvedPath:u,exists:!0,mtime:d.mtime,rawText:l.rawText,settings:x.settings,parseError:x.parseError}}),s.invalidateQueries({queryKey:["droid-diagnostics"]})}});return Q.useMemo(()=>({diagnostics:r.data,diagnosticsLoading:r.isLoading,diagnosticsError:r.error,refetchDiagnostics:r.refetch,rawSettings:n.data,rawSettingsLoading:n.isLoading,rawSettingsError:n.error,refetchRawSettings:n.refetch,saveRawSettings:o.mutate,saveRawSettingsAsync:o.mutateAsync,isSavingRawSettings:o.isPending}),[r.data,r.isLoading,r.error,r.refetch,n.data,n.isLoading,n.error,n.refetch,o.mutate,o.mutateAsync,o.isPending])}const qe=["customModels","custom_models"],We={low:4e3,medium:12e3,high:3e4,max:5e4,xhigh:64e3},Ye=["low","medium","high","max","xhigh"];function h(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)}function p(s){return typeof s=="string"&&s.trim()?s.trim():null}function _(s){return typeof s=="number"&&Number.isFinite(s)?s:null}function G(s){if(!s)return"unknown";const r=s.toLowerCase();return r==="anthropic"?"anthropic":r==="openai"?"openai":r==="generic-chat-completion-api"?"generic-chat-completion-api":"unknown"}function Ge(s,r,n){return`${s}:${r}:${encodeURIComponent(String(n))}`}function Xe(s){const r=s.indexOf(":"),n=s.indexOf(":",r+1);if(r<=0||n<=r+1)return null;const o=s.slice(0,r),d=s.slice(r+1,n),l=s.slice(n+1);if(o!=="customModels"&&o!=="custom_models"||d!=="array"&&d!=="object")return null;const t=decodeURIComponent(l);if(d==="array"){const a=Number.parseInt(t,10);return!Number.isInteger(a)||a<0?null:{rootKey:o,locationType:d,locationKey:a}}return{rootKey:o,locationType:d,locationKey:t}}function Ze(s){return!s||s<=0?null:s<=4e3?"low":s<=12e3?"medium":s<=3e4?"high":s<=5e4?"max":"xhigh"}function es(s){return Object.prototype.hasOwnProperty.call(s,"extraArgs")?"extraArgs":Object.prototype.hasOwnProperty.call(s,"extra_args")?"extra_args":"extraArgs"}function le(s){return JSON.parse(JSON.stringify(s))}function ss(s){const r=[];for(const n of qe){const o=s[n];if(Array.isArray(o)){o.forEach((d,l)=>{h(d)&&r.push({rootKey:n,locationType:"array",locationKey:l,entry:d})});continue}if(h(o))for(const[d,l]of Object.entries(o))h(l)&&r.push({rootKey:n,locationType:"object",locationKey:d,entry:l})}return r}function de(s,r){const n=Xe(r);if(!n)return null;const o=s[n.rootKey];if(n.locationType==="array"){if(!Array.isArray(o))return null;const t=o[n.locationKey];if(!h(t))return null;const a=p(t.provider);return{entry:t,providerKind:G(a)}}if(!h(o))return null;const d=o[n.locationKey];if(!h(d))return null;const l=p(d.provider);return{entry:d,providerKind:G(l)}}function rs(s,r){const n=r.extraArgs??r.extra_args,o=h(n)?n:null;if(!o)return{effort:null,anthropicBudgetTokens:null};const d=p(o.reasoning_effort)??p(o.reasoningEffort),l=h(o.reasoning)?o.reasoning:null,t=l?p(l.effort):null,a=h(o.thinking)?o.thinking:null,u=a?p(a.type):null,x=a?_(a.budget_tokens)??_(a.budgetTokens):null;return s==="openai"?{effort:t??d,anthropicBudgetTokens:null}:s==="anthropic"?u==="enabled"?{effort:Ze(x)??"high",anthropicBudgetTokens:x}:{effort:t??d,anthropicBudgetTokens:x}:{effort:d??t,anthropicBudgetTokens:null}}function ts(s){if(!s)return null;const r=s.trim().toLowerCase();return!r||r==="default"||r==="unset"||r==="off"||r==="none"||r==="disabled"?null:r}function ce(s){const r=es(s),n=s[r],o=h(n)?{...n}:{};return{extraArgsKey:r,extraArgs:o}}function ue(s,r,n){if(Object.keys(n).length===0){delete s[r];return}s[r]=n}function ns(s){return ss(s).map(({rootKey:r,locationType:n,locationKey:o,entry:d})=>{const l=p(d.displayName)??p(d.model_display_name)??"Unnamed model",t=p(d.model)??"",a=p(d.provider)??"unknown",u=G(a),x=rs(u,d);return{id:Ge(r,n,o),rootKey:r,locationType:n,locationKey:o,displayName:l,model:t,provider:a,providerKind:u,effort:x.effort,anthropicBudgetTokens:x.anthropicBudgetTokens}})}function as(s,r,n){const o=le(s),d=de(o,r);if(!d)return null;const l=ts(n),{extraArgsKey:t,extraArgs:a}=ce(d.entry);if(d.providerKind==="openai")if(delete a.reasoning_effort,delete a.reasoningEffort,!l)delete a.reasoning;else{const u=h(a.reasoning)?a.reasoning:{};a.reasoning={...u,effort:l}}else if(d.providerKind==="anthropic")if(delete a.reasoning_effort,delete a.reasoningEffort,delete a.reasoning,!l)delete a.thinking;else{const u=h(a.thinking)?{...a.thinking}:{},x=_(u.budget_tokens)??_(u.budgetTokens);delete u.budgetTokens,a.thinking={...u,type:"enabled",budget_tokens:x??We[l]??3e4}}else delete a.reasoning,delete a.reasoningEffort,l?a.reasoning_effort=l:delete a.reasoning_effort;return ue(d.entry,t,a),o}function is(s,r,n){const o=le(s),d=de(o,r);if(!d||d.providerKind!=="anthropic")return null;const{extraArgsKey:l,extraArgs:t}=ce(d.entry),a=h(t.thinking)?{...t.thinking}:{};if(a.type="enabled",n===null)delete a.budget_tokens,delete a.budgetTokens;else{const u=Math.max(1024,Math.floor(n));a.budget_tokens=u,delete a.budgetTokens}return t.thinking=a,ue(d.entry,l,t),o}const $="__unset__";function os(s){return s.providerKind==="openai"?"Writes: extraArgs.reasoning.effort":s.providerKind==="anthropic"?"Writes: extraArgs.thinking.{type,budget_tokens}":"Writes: extraArgs.reasoning_effort"}function ls({models:s,disabled:r,disabledReason:n,onEffortChange:o,onAnthropicBudgetChange:d}){return e.jsxs(b,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(_e,{className:"h-4 w-4"}),"BYOK Reasoning / Thinking",e.jsx(P,{variant:"outline",className:"text-[10px] font-normal",children:"customModels"})]})}),e.jsxs(N,{className:"space-y-3",children:[n&&e.jsx("p",{className:"text-xs text-amber-600",children:n}),s.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No BYOK custom models found in settings.json (`customModels` or `custom_models`)."}):e.jsx("div",{className:"space-y-2",children:s.map(l=>e.jsxs("div",{className:"rounded-md border p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:l.displayName}),e.jsx("p",{className:"text-[11px] font-mono text-muted-foreground truncate",children:l.model||"(missing model id)"})]}),e.jsx(P,{variant:"outline",className:"font-mono text-[10px] shrink-0",children:l.provider})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-medium",children:"Reasoning Effort"}),e.jsxs(H,{value:l.effort??$,onValueChange:t=>o(l.id,t===$?null:t),disabled:r,children:[e.jsx(q,{className:"h-8 text-xs",children:e.jsx(W,{placeholder:"Use provider default"})}),e.jsxs(Y,{children:[e.jsx(k,{value:$,children:"Use provider default"}),Ye.map(t=>e.jsx(k,{value:t,children:t},t))]})]})]}),l.providerKind==="anthropic"&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-medium",children:"Thinking Budget Tokens"}),e.jsx(oe,{type:"number",min:1024,step:1024,value:l.anthropicBudgetTokens??"",placeholder:"auto",className:"h-8 text-xs",disabled:r,onChange:t=>{const a=t.target.value.trim();if(!a){d(l.id,null);return}const u=Number.parseInt(a,10);Number.isFinite(u)&&d(l.id,Math.max(1024,u))}})]})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:os(l)})]},l.id))})]})]})}const C="__unset__",ds=[{key:"reasoningEffort",label:"Reasoning Effort",description:"none | medium | high | max",options:[{value:"none",label:"none"},{value:"medium",label:"medium"},{value:"high",label:"high"},{value:"max",label:"max"}]},{key:"autonomyLevel",label:"Autonomy Level",description:"suggest | aggressive | full",options:[{value:"suggest",label:"suggest"},{value:"aggressive",label:"aggressive"},{value:"full",label:"full"}]},{key:"diffMode",label:"Diff Mode",description:"auto | none | inline | split",options:[{value:"auto",label:"auto"},{value:"none",label:"none"},{value:"inline",label:"inline"},{value:"split",label:"split"}]}],cs=[{key:"todoEnabled",label:"Todo Enabled"},{key:"todoAutoRefresh",label:"Todo Auto Refresh"},{key:"autoCompactEnabled",label:"Auto Compact Enabled"},{key:"soundEnabled",label:"Sound Enabled"}],us=[{key:"maxTurns",label:"Max Turns",min:1,step:1},{key:"maxToolCalls",label:"Max Tool Calls",min:1,step:1},{key:"autoCompactThreshold",label:"Auto Compact Threshold",min:1e3,step:1e3}];function ms(s){return s===!0?"true":s===!1?"false":C}function xs(s){return s==="true"?!0:s==="false"?!1:null}function gs({values:s,disabled:r,disabledReason:n,onEnumSettingChange:o,onBooleanSettingChange:d,onNumberSettingChange:l}){return e.jsxs(b,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(De,{className:"h-4 w-4"}),"Quick Settings",e.jsx(P,{variant:"outline",className:"text-[10px] font-normal",children:"settings.json"})]})}),e.jsxs(N,{className:"space-y-4",children:[n&&e.jsx("p",{className:"text-xs text-amber-600",children:n}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[ds.map(t=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:t.label}),e.jsxs(H,{value:s[t.key]??C,onValueChange:a=>o(t.key,a===C?null:a),disabled:r,children:[e.jsx(q,{className:"h-8 text-xs",children:e.jsx(W,{placeholder:"Use default"})}),e.jsxs(Y,{children:[e.jsx(k,{value:C,children:"Use default"}),t.options.map(a=>e.jsx(k,{value:a.value,children:a.label},a.value))]})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:t.description})]},t.key)),us.map(t=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:t.label}),e.jsx(oe,{type:"number",min:t.min,step:t.step,value:s[t.key]??"",onChange:a=>{const u=a.target.value.trim();if(!u){l(t.key,null);return}const x=Number.parseInt(u,10);Number.isFinite(x)&&l(t.key,Math.max(t.min,x))},className:"h-8 text-xs",disabled:r})]},t.key)),cs.map(t=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:t.label}),e.jsxs(H,{value:ms(s[t.key]),onValueChange:a=>d(t.key,xs(a)),disabled:r,children:[e.jsx(q,{className:"h-8 text-xs",children:e.jsx(W,{placeholder:"Use default"})}),e.jsxs(Y,{children:[e.jsx(k,{value:C,children:"Use default"}),e.jsx(k,{value:"true",children:"true"}),e.jsx(k,{value:"false",children:"false"})]})]})]},t.key))]})]})]})}const fs=[{id:"droid-cli-overview",label:"Droid CLI Overview",url:"https://docs.factory.ai/cli/",description:"Primary entry docs for setup, auth, and core CLI usage."},{id:"droid-byok-overview",label:"BYOK Overview",url:"https://docs.factory.ai/cli/byok/overview/",description:"BYOK model/provider shape, provider values, and migration notes."},{id:"droid-settings-reference",label:"settings.json Reference",url:"https://docs.factory.ai/cli/configuration/settings/",description:"Supported settings keys, defaults, and allowed values."}],hs=[{provider:"anthropic",label:"Anthropic Messages API",apiFormat:"Messages API",url:"https://docs.anthropic.com/en/api/messages"},{provider:"openai",label:"OpenAI Responses API",apiFormat:"Responses API",url:"https://platform.openai.com/docs/api-reference/responses"},{provider:"generic-chat-completion-api",label:"OpenAI Chat Completions Spec",apiFormat:"Chat Completions API",url:"https://platform.openai.com/docs/api-reference/chat"}];function ps(s){const r=/https?:\/\/[^\s)]+/g,n=[];let o=0,d;for(;(d=r.exec(s))!==null;){const[l]=d,t=d.index;t>o&&n.push(s.slice(o,t)),n.push(e.jsx("a",{href:l,target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:l},`${l}-${t}`)),o=t+l.length}return o<s.length&&n.push(s.slice(o)),n.length>0?n:[s]}function js(s){return!s||!Number.isFinite(s)?"N/A":new Date(s).toLocaleString()}function bs(s){return!s||s<=0?"0 B":s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(2)} MB`}function vs(s){try{const r=JSON.parse(s);return!r||typeof r!="object"||Array.isArray(r)?{valid:!1,error:"JSON root must be an object."}:{valid:!0,value:r}}catch(r){return{valid:!1,error:r.message}}}function z(s){return typeof s=="string"?s:null}function J(s){return typeof s=="number"&&Number.isFinite(s)?s:null}function R(s){return typeof s=="boolean"?s:null}function g({label:s,value:r,mono:n=!1}){return e.jsxs("div",{className:"flex items-start justify-between gap-3 text-sm",children:[e.jsx("span",{className:"text-muted-foreground shrink-0",children:s}),e.jsx("span",{className:Ce("text-right break-all",n&&"font-mono text-xs"),children:r})]})}function _s(){const{t:s}=Ne(),{diagnostics:r,diagnosticsLoading:n,diagnosticsError:o,refetchDiagnostics:d,rawSettings:l,rawSettingsLoading:t,refetchRawSettings:a,saveRawSettingsAsync:u,isSavingRawSettings:x}=He(),[D,O]=Q.useState(null),B=l?.rawText??"{}",M=D??B,Z=D!==null&&D!==B,c=vs(M),F=c.valid?{valid:!0}:{valid:!1,error:c.error},ee=m=>{if(m===B){O(null);return}O(m)},L=m=>{ee(JSON.stringify(m,null,2)+`
|
|
1
|
+
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as Q}from"./react-vendor-CNOkPC89.js";import{t as j}from"./notifications-B2HqRBj7.js";import{bb as X,bc as ye,C as b,j as v,k as y,B as P,b as N,r as H,s as q,t as W,v as Y,w as k,I as oe,a as Ne,bi as we,bj as ne,bk as ke,Q as Se,R as Pe,U,V,n as T,bd as Ee,c as Ce}from"./index-DOn6k1jF.js";import{a as Te,u as ae,b as Ae}from"./tanstack-CrmUhA7Z.js";import{a as Re}from"./raw-json-settings-editor-panel-WxTn7-hS.js";import{ax as _e,aB as De,N as Oe,L as Be,S as Me,aX as Fe,x as Le,I as Ie,T as Ke,ad as Ue,ah as Ve,p as ie}from"./icons-KVCk4_U8.js";import{S as A}from"./separator-BCfZ54mZ.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";function $e(s){try{const r=JSON.parse(s);return!r||typeof r!="object"||Array.isArray(r)?{settings:null,parseError:"JSON root must be an object."}:{settings:r,parseError:null}}catch(r){return{settings:null,parseError:r.message}}}async function ze(){const s=await fetch(X("/droid/diagnostics"));if(!s.ok)throw new Error("Failed to fetch Droid diagnostics");return s.json()}async function Je(){const s=await fetch(X("/droid/settings/raw"));if(!s.ok)throw new Error("Failed to fetch Droid raw settings");return s.json()}async function Qe(s){const r=await fetch(X("/droid/settings/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(r.status===409)throw new ye("Droid raw settings changed externally");if(!r.ok){const n=await r.json().catch(()=>null);throw new Error(n?.error||"Failed to save Droid raw settings")}return r.json()}function He(){const s=Te(),r=ae({queryKey:["droid-diagnostics"],queryFn:ze,refetchInterval:1e4}),n=ae({queryKey:["droid-raw-settings"],queryFn:Je}),o=Ae({mutationFn:Qe,onSuccess:(d,l)=>{s.setQueryData(["droid-raw-settings"],t=>{const a=t?.path??"~/.factory/settings.json",u=t?.resolvedPath??a,x=$e(l.rawText);return{path:a,resolvedPath:u,exists:!0,mtime:d.mtime,rawText:l.rawText,settings:x.settings,parseError:x.parseError}}),s.invalidateQueries({queryKey:["droid-diagnostics"]})}});return Q.useMemo(()=>({diagnostics:r.data,diagnosticsLoading:r.isLoading,diagnosticsError:r.error,refetchDiagnostics:r.refetch,rawSettings:n.data,rawSettingsLoading:n.isLoading,rawSettingsError:n.error,refetchRawSettings:n.refetch,saveRawSettings:o.mutate,saveRawSettingsAsync:o.mutateAsync,isSavingRawSettings:o.isPending}),[r.data,r.isLoading,r.error,r.refetch,n.data,n.isLoading,n.error,n.refetch,o.mutate,o.mutateAsync,o.isPending])}const qe=["customModels","custom_models"],We={low:4e3,medium:12e3,high:3e4,max:5e4,xhigh:64e3},Ye=["low","medium","high","max","xhigh"];function h(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)}function p(s){return typeof s=="string"&&s.trim()?s.trim():null}function _(s){return typeof s=="number"&&Number.isFinite(s)?s:null}function G(s){if(!s)return"unknown";const r=s.toLowerCase();return r==="anthropic"?"anthropic":r==="openai"?"openai":r==="generic-chat-completion-api"?"generic-chat-completion-api":"unknown"}function Ge(s,r,n){return`${s}:${r}:${encodeURIComponent(String(n))}`}function Xe(s){const r=s.indexOf(":"),n=s.indexOf(":",r+1);if(r<=0||n<=r+1)return null;const o=s.slice(0,r),d=s.slice(r+1,n),l=s.slice(n+1);if(o!=="customModels"&&o!=="custom_models"||d!=="array"&&d!=="object")return null;const t=decodeURIComponent(l);if(d==="array"){const a=Number.parseInt(t,10);return!Number.isInteger(a)||a<0?null:{rootKey:o,locationType:d,locationKey:a}}return{rootKey:o,locationType:d,locationKey:t}}function Ze(s){return!s||s<=0?null:s<=4e3?"low":s<=12e3?"medium":s<=3e4?"high":s<=5e4?"max":"xhigh"}function es(s){return Object.prototype.hasOwnProperty.call(s,"extraArgs")?"extraArgs":Object.prototype.hasOwnProperty.call(s,"extra_args")?"extra_args":"extraArgs"}function le(s){return JSON.parse(JSON.stringify(s))}function ss(s){const r=[];for(const n of qe){const o=s[n];if(Array.isArray(o)){o.forEach((d,l)=>{h(d)&&r.push({rootKey:n,locationType:"array",locationKey:l,entry:d})});continue}if(h(o))for(const[d,l]of Object.entries(o))h(l)&&r.push({rootKey:n,locationType:"object",locationKey:d,entry:l})}return r}function de(s,r){const n=Xe(r);if(!n)return null;const o=s[n.rootKey];if(n.locationType==="array"){if(!Array.isArray(o))return null;const t=o[n.locationKey];if(!h(t))return null;const a=p(t.provider);return{entry:t,providerKind:G(a)}}if(!h(o))return null;const d=o[n.locationKey];if(!h(d))return null;const l=p(d.provider);return{entry:d,providerKind:G(l)}}function rs(s,r){const n=r.extraArgs??r.extra_args,o=h(n)?n:null;if(!o)return{effort:null,anthropicBudgetTokens:null};const d=p(o.reasoning_effort)??p(o.reasoningEffort),l=h(o.reasoning)?o.reasoning:null,t=l?p(l.effort):null,a=h(o.thinking)?o.thinking:null,u=a?p(a.type):null,x=a?_(a.budget_tokens)??_(a.budgetTokens):null;return s==="openai"?{effort:t??d,anthropicBudgetTokens:null}:s==="anthropic"?u==="enabled"?{effort:Ze(x)??"high",anthropicBudgetTokens:x}:{effort:t??d,anthropicBudgetTokens:x}:{effort:d??t,anthropicBudgetTokens:null}}function ts(s){if(!s)return null;const r=s.trim().toLowerCase();return!r||r==="default"||r==="unset"||r==="off"||r==="none"||r==="disabled"?null:r}function ce(s){const r=es(s),n=s[r],o=h(n)?{...n}:{};return{extraArgsKey:r,extraArgs:o}}function ue(s,r,n){if(Object.keys(n).length===0){delete s[r];return}s[r]=n}function ns(s){return ss(s).map(({rootKey:r,locationType:n,locationKey:o,entry:d})=>{const l=p(d.displayName)??p(d.model_display_name)??"Unnamed model",t=p(d.model)??"",a=p(d.provider)??"unknown",u=G(a),x=rs(u,d);return{id:Ge(r,n,o),rootKey:r,locationType:n,locationKey:o,displayName:l,model:t,provider:a,providerKind:u,effort:x.effort,anthropicBudgetTokens:x.anthropicBudgetTokens}})}function as(s,r,n){const o=le(s),d=de(o,r);if(!d)return null;const l=ts(n),{extraArgsKey:t,extraArgs:a}=ce(d.entry);if(d.providerKind==="openai")if(delete a.reasoning_effort,delete a.reasoningEffort,!l)delete a.reasoning;else{const u=h(a.reasoning)?a.reasoning:{};a.reasoning={...u,effort:l}}else if(d.providerKind==="anthropic")if(delete a.reasoning_effort,delete a.reasoningEffort,delete a.reasoning,!l)delete a.thinking;else{const u=h(a.thinking)?{...a.thinking}:{},x=_(u.budget_tokens)??_(u.budgetTokens);delete u.budgetTokens,a.thinking={...u,type:"enabled",budget_tokens:x??We[l]??3e4}}else delete a.reasoning,delete a.reasoningEffort,l?a.reasoning_effort=l:delete a.reasoning_effort;return ue(d.entry,t,a),o}function is(s,r,n){const o=le(s),d=de(o,r);if(!d||d.providerKind!=="anthropic")return null;const{extraArgsKey:l,extraArgs:t}=ce(d.entry),a=h(t.thinking)?{...t.thinking}:{};if(a.type="enabled",n===null)delete a.budget_tokens,delete a.budgetTokens;else{const u=Math.max(1024,Math.floor(n));a.budget_tokens=u,delete a.budgetTokens}return t.thinking=a,ue(d.entry,l,t),o}const $="__unset__";function os(s){return s.providerKind==="openai"?"Writes: extraArgs.reasoning.effort":s.providerKind==="anthropic"?"Writes: extraArgs.thinking.{type,budget_tokens}":"Writes: extraArgs.reasoning_effort"}function ls({models:s,disabled:r,disabledReason:n,onEffortChange:o,onAnthropicBudgetChange:d}){return e.jsxs(b,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(_e,{className:"h-4 w-4"}),"BYOK Reasoning / Thinking",e.jsx(P,{variant:"outline",className:"text-[10px] font-normal",children:"customModels"})]})}),e.jsxs(N,{className:"space-y-3",children:[n&&e.jsx("p",{className:"text-xs text-amber-600",children:n}),s.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No BYOK custom models found in settings.json (`customModels` or `custom_models`)."}):e.jsx("div",{className:"space-y-2",children:s.map(l=>e.jsxs("div",{className:"rounded-md border p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:l.displayName}),e.jsx("p",{className:"text-[11px] font-mono text-muted-foreground truncate",children:l.model||"(missing model id)"})]}),e.jsx(P,{variant:"outline",className:"font-mono text-[10px] shrink-0",children:l.provider})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-medium",children:"Reasoning Effort"}),e.jsxs(H,{value:l.effort??$,onValueChange:t=>o(l.id,t===$?null:t),disabled:r,children:[e.jsx(q,{className:"h-8 text-xs",children:e.jsx(W,{placeholder:"Use provider default"})}),e.jsxs(Y,{children:[e.jsx(k,{value:$,children:"Use provider default"}),Ye.map(t=>e.jsx(k,{value:t,children:t},t))]})]})]}),l.providerKind==="anthropic"&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-medium",children:"Thinking Budget Tokens"}),e.jsx(oe,{type:"number",min:1024,step:1024,value:l.anthropicBudgetTokens??"",placeholder:"auto",className:"h-8 text-xs",disabled:r,onChange:t=>{const a=t.target.value.trim();if(!a){d(l.id,null);return}const u=Number.parseInt(a,10);Number.isFinite(u)&&d(l.id,Math.max(1024,u))}})]})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:os(l)})]},l.id))})]})]})}const C="__unset__",ds=[{key:"reasoningEffort",label:"Reasoning Effort",description:"none | medium | high | max",options:[{value:"none",label:"none"},{value:"medium",label:"medium"},{value:"high",label:"high"},{value:"max",label:"max"}]},{key:"autonomyLevel",label:"Autonomy Level",description:"suggest | aggressive | full",options:[{value:"suggest",label:"suggest"},{value:"aggressive",label:"aggressive"},{value:"full",label:"full"}]},{key:"diffMode",label:"Diff Mode",description:"auto | none | inline | split",options:[{value:"auto",label:"auto"},{value:"none",label:"none"},{value:"inline",label:"inline"},{value:"split",label:"split"}]}],cs=[{key:"todoEnabled",label:"Todo Enabled"},{key:"todoAutoRefresh",label:"Todo Auto Refresh"},{key:"autoCompactEnabled",label:"Auto Compact Enabled"},{key:"soundEnabled",label:"Sound Enabled"}],us=[{key:"maxTurns",label:"Max Turns",min:1,step:1},{key:"maxToolCalls",label:"Max Tool Calls",min:1,step:1},{key:"autoCompactThreshold",label:"Auto Compact Threshold",min:1e3,step:1e3}];function ms(s){return s===!0?"true":s===!1?"false":C}function xs(s){return s==="true"?!0:s==="false"?!1:null}function gs({values:s,disabled:r,disabledReason:n,onEnumSettingChange:o,onBooleanSettingChange:d,onNumberSettingChange:l}){return e.jsxs(b,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(De,{className:"h-4 w-4"}),"Quick Settings",e.jsx(P,{variant:"outline",className:"text-[10px] font-normal",children:"settings.json"})]})}),e.jsxs(N,{className:"space-y-4",children:[n&&e.jsx("p",{className:"text-xs text-amber-600",children:n}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[ds.map(t=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:t.label}),e.jsxs(H,{value:s[t.key]??C,onValueChange:a=>o(t.key,a===C?null:a),disabled:r,children:[e.jsx(q,{className:"h-8 text-xs",children:e.jsx(W,{placeholder:"Use default"})}),e.jsxs(Y,{children:[e.jsx(k,{value:C,children:"Use default"}),t.options.map(a=>e.jsx(k,{value:a.value,children:a.label},a.value))]})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:t.description})]},t.key)),us.map(t=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:t.label}),e.jsx(oe,{type:"number",min:t.min,step:t.step,value:s[t.key]??"",onChange:a=>{const u=a.target.value.trim();if(!u){l(t.key,null);return}const x=Number.parseInt(u,10);Number.isFinite(x)&&l(t.key,Math.max(t.min,x))},className:"h-8 text-xs",disabled:r})]},t.key)),cs.map(t=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:t.label}),e.jsxs(H,{value:ms(s[t.key]),onValueChange:a=>d(t.key,xs(a)),disabled:r,children:[e.jsx(q,{className:"h-8 text-xs",children:e.jsx(W,{placeholder:"Use default"})}),e.jsxs(Y,{children:[e.jsx(k,{value:C,children:"Use default"}),e.jsx(k,{value:"true",children:"true"}),e.jsx(k,{value:"false",children:"false"})]})]})]},t.key))]})]})]})}const fs=[{id:"droid-cli-overview",label:"Droid CLI Overview",url:"https://docs.factory.ai/cli/",description:"Primary entry docs for setup, auth, and core CLI usage."},{id:"droid-byok-overview",label:"BYOK Overview",url:"https://docs.factory.ai/cli/byok/overview/",description:"BYOK model/provider shape, provider values, and migration notes."},{id:"droid-settings-reference",label:"settings.json Reference",url:"https://docs.factory.ai/cli/configuration/settings/",description:"Supported settings keys, defaults, and allowed values."}],hs=[{provider:"anthropic",label:"Anthropic Messages API",apiFormat:"Messages API",url:"https://docs.anthropic.com/en/api/messages"},{provider:"openai",label:"OpenAI Responses API",apiFormat:"Responses API",url:"https://platform.openai.com/docs/api-reference/responses"},{provider:"generic-chat-completion-api",label:"OpenAI Chat Completions Spec",apiFormat:"Chat Completions API",url:"https://platform.openai.com/docs/api-reference/chat"}];function ps(s){const r=/https?:\/\/[^\s)]+/g,n=[];let o=0,d;for(;(d=r.exec(s))!==null;){const[l]=d,t=d.index;t>o&&n.push(s.slice(o,t)),n.push(e.jsx("a",{href:l,target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:l},`${l}-${t}`)),o=t+l.length}return o<s.length&&n.push(s.slice(o)),n.length>0?n:[s]}function js(s){return!s||!Number.isFinite(s)?"N/A":new Date(s).toLocaleString()}function bs(s){return!s||s<=0?"0 B":s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(2)} MB`}function vs(s){try{const r=JSON.parse(s);return!r||typeof r!="object"||Array.isArray(r)?{valid:!1,error:"JSON root must be an object."}:{valid:!0,value:r}}catch(r){return{valid:!1,error:r.message}}}function z(s){return typeof s=="string"?s:null}function J(s){return typeof s=="number"&&Number.isFinite(s)?s:null}function R(s){return typeof s=="boolean"?s:null}function g({label:s,value:r,mono:n=!1}){return e.jsxs("div",{className:"flex items-start justify-between gap-3 text-sm",children:[e.jsx("span",{className:"text-muted-foreground shrink-0",children:s}),e.jsx("span",{className:Ce("text-right break-all",n&&"font-mono text-xs"),children:r})]})}function _s(){const{t:s}=Ne(),{diagnostics:r,diagnosticsLoading:n,diagnosticsError:o,refetchDiagnostics:d,rawSettings:l,rawSettingsLoading:t,refetchRawSettings:a,saveRawSettingsAsync:u,isSavingRawSettings:x}=He(),[D,O]=Q.useState(null),B=l?.rawText??"{}",M=D??B,Z=D!==null&&D!==B,c=vs(M),F=c.valid?{valid:!0}:{valid:!1,error:c.error},ee=m=>{if(m===B){O(null);return}O(m)},L=m=>{ee(JSON.stringify(m,null,2)+`
|
|
2
2
|
`)},I=(m,w)=>{if(!c.valid){j.error(s("droidPage.fixJsonBeforeQuickSettings"));return}const S={...c.value};w==null?delete S[m]:S[m]=w,L(S)},me=c.valid?{reasoningEffort:z(c.value.reasoningEffort),autonomyLevel:z(c.value.autonomyLevel),diffMode:z(c.value.diffMode),maxTurns:J(c.value.maxTurns),maxToolCalls:J(c.value.maxToolCalls),autoCompactThreshold:J(c.value.autoCompactThreshold),todoEnabled:R(c.value.todoEnabled),todoAutoRefresh:R(c.value.todoAutoRefresh),autoCompactEnabled:R(c.value.autoCompactEnabled),soundEnabled:R(c.value.soundEnabled)}:{reasoningEffort:null,autonomyLevel:null,diffMode:null,maxTurns:null,maxToolCalls:null,autoCompactThreshold:null,todoEnabled:null,todoAutoRefresh:null,autoCompactEnabled:null,soundEnabled:null},xe=c.valid?ns(c.value):[],ge=async()=>{await Promise.all([d(),a()])},fe=async()=>{if(!F.valid){j.error(s("droidPage.invalidJson",{value:F.error}));return}try{await u({rawText:M,expectedMtime:l?.exists?l.mtime:void 0}),O(null),j.success(s("droidPage.saved"))}catch(m){Ee(m)?j.error(s("droidPage.changedExternally")):j.error(m.message||s("droidPage.failedSave"))}},se=r?.byok.customModels??[],re=Q.useMemo(()=>Object.entries(r?.byok.providerBreakdown??{}).sort((m,w)=>w[1]-m[1]),[r?.byok.providerBreakdown]),he=()=>{if(n)return e.jsxs("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:[e.jsx(Be,{className:"h-5 w-5 animate-spin mr-2"}),s("droidPage.loadingDiagnostics")]});if(o||!r)return e.jsx("div",{className:"flex h-full items-center justify-center text-destructive px-6 text-center",children:s("droidPage.failedDiagnostics")});const m=r.docsReference??{notes:[],links:[],providerDocs:[],providerValues:[],settingsHierarchy:[]},w=m.notes??[],S=m.links??[],te=m.providerDocs??[],pe=S.length>0?S:fs,je=te.length>0?te:hs,be=m.providerValues??[],ve=m.settingsHierarchy??[],K="mt-0 h-full border-0 p-0 data-[state=inactive]:hidden";return e.jsxs(Se,{defaultValue:"byok",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(Pe,{className:"grid w-full grid-cols-3",children:[e.jsx(U,{value:"overview",children:s("droidPage.overview")}),e.jsx(U,{value:"byok",children:s("droidPage.byok")}),e.jsx(U,{value:"docs",children:s("droidPage.docs")})]})}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden px-4 pb-4 pt-3",children:[e.jsx(V,{value:"overview",className:K,children:e.jsx(T,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 pr-1",children:[e.jsxs(b,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(Me,{className:"h-4 w-4"}),s("droidPage.runtimeInstall")]})}),e.jsxs(N,{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:s("droidPage.status")}),e.jsx(P,{variant:r.binary.installed?"default":"secondary",children:r.binary.installed?s("droidPage.detected"):s("droidPage.notFound")})]}),e.jsx(g,{label:s("droidPage.detectionSource"),value:r.binary.source,mono:!0}),e.jsx(g,{label:s("droidPage.binaryPath"),value:r.binary.path||s("droidPage.notFound"),mono:!0}),e.jsx(g,{label:s("droidPage.installDirectory"),value:r.binary.installDir||"N/A",mono:!0}),e.jsx(g,{label:s("droidPage.version"),value:r.binary.version||"Unknown",mono:!0}),e.jsx(g,{label:s("droidPage.overridePath"),value:r.binary.overridePath||"Not set",mono:!0})]})]}),e.jsxs(b,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(Fe,{className:"h-4 w-4"}),s("droidPage.configFiles")]})}),e.jsx(N,{className:"space-y-3",children:[r.files.settings,r.files.legacyConfig].map(i=>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:i.label}),i.exists?e.jsx(Le,{className:"h-4 w-4 text-green-600"}):e.jsx(Ie,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(g,{label:s("droidPage.path"),value:i.path,mono:!0}),e.jsx(g,{label:s("droidPage.resolved"),value:i.resolvedPath,mono:!0}),e.jsx(g,{label:s("droidPage.size"),value:bs(i.sizeBytes)}),e.jsx(g,{label:s("droidPage.lastModified"),value:js(i.mtimeMs)}),i.parseError&&e.jsx("p",{className:"text-xs text-amber-600",children:s("droidPage.parseWarning",{value:i.parseError})}),i.readError&&e.jsx("p",{className:"text-xs text-destructive",children:s("droidPage.readWarning",{value:i.readError})})]},i.label))})]}),r.warnings.length>0&&e.jsxs(b,{className:"border-amber-200 bg-amber-50/50 dark:bg-amber-950/20",children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(Ke,{className:"h-4 w-4 text-amber-600"}),s("droidPage.warnings")]})}),e.jsx(N,{className:"space-y-1.5",children:r.warnings.map(i=>e.jsxs("p",{className:"text-sm text-amber-800 dark:text-amber-300",children:["- ",i]},i))})]})]})})}),e.jsx(V,{value:"byok",className:K,children:e.jsx(T,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 pr-1",children:[e.jsx(gs,{values:me,disabled:t||!c.valid,disabledReason:c.valid?null:`Quick settings disabled: ${c.error}`,onEnumSettingChange:(i,f)=>{I(i,f)},onBooleanSettingChange:(i,f)=>{I(i,f)},onNumberSettingChange:(i,f)=>{I(i,f)}}),e.jsx(ls,{models:xe,disabled:t||!c.valid,disabledReason:c.valid?null:`${s("droidPage.byok")}: ${c.error}`,onEffortChange:(i,f)=>{if(!c.valid){j.error(s("droidPage.fixJsonBeforeReasoning"));return}const E=as(c.value,i,f);if(!E){j.error(s("droidPage.unableUpdateReasoning"));return}L(E)},onAnthropicBudgetChange:(i,f)=>{if(!c.valid){j.error(s("droidPage.fixJsonBeforeBudget"));return}const E=is(c.value,i,f);if(!E){j.error(s("droidPage.anthropicOnlyBudget"));return}L(E)}}),e.jsxs(b,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(Ue,{className:"h-4 w-4"}),s("droidPage.byokSummary")]})}),e.jsxs(N,{className:"space-y-2",children:[e.jsx(g,{label:s("droidPage.activeModelSelector"),value:r.byok.activeModelSelector||"Not set",mono:!0}),e.jsx(g,{label:s("droidPage.customModels"),value:String(r.byok.customModelCount)}),e.jsx(g,{label:s("droidPage.ccsManaged"),value:String(r.byok.ccsManagedCount)}),e.jsx(g,{label:s("droidPage.userManaged"),value:String(r.byok.userManagedCount)}),e.jsx(g,{label:s("droidPage.malformedEntries"),value:String(r.byok.invalidModelEntryCount)}),e.jsx(A,{}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:s("droidPage.providers")}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[re.length===0&&e.jsx(P,{variant:"secondary",className:"font-mono",children:s("droidPage.none")}),re.map(([i,f])=>e.jsxs(P,{variant:"outline",className:"font-mono text-xs",children:[i,": ",f]},i))]})]})]})]}),e.jsxs(b,{children:[e.jsx(v,{className:"pb-2",children:e.jsx(y,{className:"text-base",children:s("droidPage.customModelsTitle")})}),e.jsx(N,{children:e.jsxs("div",{className:"rounded-md border overflow-hidden",children:[e.jsxs("div",{className:"grid grid-cols-[2fr_1fr_2fr] bg-muted/40 px-3 py-2 text-xs font-medium",children:[e.jsx("span",{children:s("droidPage.modelName")}),e.jsx("span",{children:s("droidPage.provider")}),e.jsx("span",{children:s("droidPage.baseUrl")})]}),e.jsx(T,{className:"h-52",children:e.jsxs("div",{className:"divide-y",children:[se.length===0&&e.jsx("div",{className:"px-3 py-4 text-xs text-muted-foreground",children:s("droidPage.noCustomModels")}),se.map(i=>e.jsxs("div",{className:"grid grid-cols-[2fr_1fr_2fr] gap-2 px-3 py-2 text-xs",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:i.displayName}),e.jsx("p",{className:"text-muted-foreground font-mono truncate",children:i.model})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate",children:i.provider}),e.jsx("p",{className:"text-muted-foreground",children:i.apiKeyPreview||"no-key"})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate",title:i.baseUrl,children:i.host||i.baseUrl}),e.jsx("p",{className:"text-muted-foreground font-mono truncate",children:i.baseUrl})]})]},`${i.displayName}-${i.model}-${i.baseUrl}`))]})})]})})]})]})})}),e.jsx(V,{value:"docs",className:K,children:e.jsx(T,{className:"h-full",children:e.jsx("div",{className:"space-y-4 pr-1",children:e.jsxs(b,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(Ve,{className:"h-4 w-4"}),s("droidPage.docsAlignedNotes")]})}),e.jsxs(N,{className:"space-y-2 text-sm",children:[w.map((i,f)=>e.jsxs("p",{className:"text-muted-foreground",children:["- ",ps(i)]},`${f}-${i}`)),e.jsx(A,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:s("droidPage.factoryDocs")}),e.jsx("div",{className:"space-y-1.5",children:pe.map(i=>e.jsxs("a",{href:i.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:i.label}),e.jsx(ie,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),e.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:i.description}),e.jsx("p",{className:"mt-1 break-all font-mono text-[11px] text-muted-foreground/90 underline underline-offset-2",children:i.url})]},i.id))})]}),e.jsx(A,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:s("droidPage.providerFactCheckDocs")}),e.jsx("div",{className:"space-y-1.5",children:je.map(i=>e.jsxs("a",{href:i.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:i.label}),e.jsx(ie,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),e.jsxs("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:["provider: ",i.provider," | format: ",i.apiFormat]}),e.jsx("p",{className:"mt-1 break-all font-mono text-[11px] text-muted-foreground/90 underline underline-offset-2",children:i.url})]},`${i.provider}-${i.url}`))})]}),e.jsx(A,{}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("droidPage.providerValues",{value:be.join(", ")})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("droidPage.settingsHierarchy",{value:ve.join(" -> ")})})]})]})})})})]})]})};return e.jsx("div",{className:"h-full min-h-0 overflow-hidden",children:e.jsxs(we,{direction:"horizontal",className:"h-full",children:[e.jsx(ne,{defaultSize:45,minSize:35,children:e.jsx("div",{className:"h-full border-r bg-muted/20",children:he()})}),e.jsx(ke,{className:"w-2 bg-border hover:bg-primary/20 transition-colors cursor-col-resize flex items-center justify-center group",children:e.jsx(Oe,{className:"w-3 h-3 text-muted-foreground group-hover:text-primary"})}),e.jsx(ne,{defaultSize:55,minSize:35,children:e.jsx(Re,{title:s("droidPage.settingsTitle"),pathLabel:l?.path||"~/.factory/settings.json",loading:t,parseWarning:l?.parseError,value:M,dirty:Z,saving:x,saveDisabled:!Z||x||t||!F.valid,onChange:m=>{ee(m)},onSave:fe,onRefresh:ge})})]})})}export{_s as DroidPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as g}from"./react-vendor-CNOkPC89.js";import{bt as C,bu as w,a as G,bv as y,be as k,bg as S,n as R,aF as A,d as f,I as j}from"./index-
|
|
1
|
+
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as g}from"./react-vendor-CNOkPC89.js";import{bt as C,bu as w,a as G,bv as y,be as k,bg as S,n as R,aF as A,d as f,I as j}from"./index-DOn6k1jF.js";import{R as N,w as D,x as L,as as T,a9 as I}from"./icons-KVCk4_U8.js";import"./tanstack-CrmUhA7Z.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";function _(){const{state:s}=C(),n=w(),[o,r]=g.useState(""),[c,m]=g.useState(""),u=g.useCallback(async()=>{try{n.setGlobalEnvLoading(!0),n.setGlobalEnvError(null);const a=await fetch("/api/global-env");if(!a.ok)throw new Error("Failed to load Global Env config");const l=await a.json();n.setGlobalEnvConfig(l)}catch(a){n.setGlobalEnvError(a.message)}finally{n.setGlobalEnvLoading(!1)}},[n]),i=g.useCallback(async a=>{const l=s.globalEnvConfig;if(!l)return;const x={...l,...a};n.setGlobalEnvConfig(x);try{n.setGlobalEnvSaving(!0),n.setGlobalEnvError(null);const d=await fetch("/api/global-env",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(x)});if(!d.ok){const h=await d.json();throw new Error(h.error||"Failed to save")}const v=await d.json();n.setGlobalEnvConfig(v.config),n.setGlobalEnvSuccess(!0),setTimeout(()=>n.setGlobalEnvSuccess(!1),1500)}catch(d){n.setGlobalEnvConfig(l),n.setGlobalEnvError(d.message)}finally{n.setGlobalEnvSaving(!1)}},[s.globalEnvConfig,n]),E=g.useCallback(()=>{if(!o.trim()||!s.globalEnvConfig)return;const a={...s.globalEnvConfig.env,[o.trim()]:c};i({env:a}),r(""),m("")},[o,c,s.globalEnvConfig,i]),b=g.useCallback(a=>{if(!s.globalEnvConfig)return;const l={...s.globalEnvConfig.env};delete l[a],i({env:l})},[s.globalEnvConfig,i]);return{config:s.globalEnvConfig,loading:s.globalEnvLoading,saving:s.globalEnvSaving,error:s.globalEnvError,success:s.globalEnvSuccess,newEnvKey:o,setNewEnvKey:r,newEnvValue:c,setNewEnvValue:m,fetchConfig:u,saveConfig:i,addEnvVar:E,removeEnvVar:b}}function Y(){const{t:s}=G(),{config:n,loading:o,saving:r,error:c,success:m,newEnvKey:u,setNewEnvKey:i,newEnvValue:E,setNewEnvValue:b,fetchConfig:a,saveConfig:l,addEnvVar:x,removeEnvVar:d}=_(),{fetchRawConfig:v}=y();g.useEffect(()=>{a(),v()},[a,v]);const h=()=>{l({enabled:!n?.enabled})};return o?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx(N,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:s("settings.loading")})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${c||m?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[c&&e.jsxs(k,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(D,{className:"h-4 w-4"}),e.jsx(S,{children:c})]}),m&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md border border-green-200 bg-green-50 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(L,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:s("settings.saved")})]})]}),e.jsx(R,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("settingsGlobalEnv.description")}),e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:n?.enabled?s("settingsGlobalEnv.enabled"):s("settingsGlobalEnv.disabled")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n?.enabled?s("settingsGlobalEnv.enabledDesc"):s("settingsGlobalEnv.disabledDesc")})]}),e.jsx(A,{checked:n?.enabled??!0,onCheckedChange:h})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:s("settingsGlobalEnv.envVars")}),n?.env&&Object.keys(n.env).length>0?e.jsx("div",{className:"space-y-2",children:Object.entries(n.env).map(([t,p])=>e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg border bg-background",children:[e.jsx("code",{className:"flex-1 font-mono text-sm truncate",children:t}),e.jsx("span",{className:"text-muted-foreground",children:"="}),e.jsx("code",{className:"font-mono text-sm px-2 py-1 bg-muted rounded",children:p}),e.jsx(f,{variant:"ghost",size:"sm",onClick:()=>d(t),disabled:r,className:"h-8 w-8 p-0 text-destructive hover:text-destructive hover:bg-destructive/10",children:e.jsx(T,{className:"w-4 h-4"})})]},t))}):e.jsx("div",{className:"p-4 rounded-lg border border-dashed text-center text-muted-foreground",children:e.jsx("p",{children:s("settingsGlobalEnv.noneConfigured")})}),e.jsxs("div",{className:"p-4 rounded-lg border bg-muted/30",children:[e.jsx("h4",{className:"text-sm font-medium mb-3",children:s("settingsGlobalEnv.addNew")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{value:u,onChange:t=>i(t.target.value.toUpperCase()),placeholder:s("settingsGlobalEnv.keyName"),className:"flex-1 font-mono text-sm h-9",disabled:r}),e.jsx("span",{className:"flex items-center text-muted-foreground",children:"="}),e.jsx(j,{value:E,onChange:t=>b(t.target.value),placeholder:s("settingsGlobalEnv.value"),className:"flex-1 font-mono text-sm h-9",disabled:r}),e.jsxs(f,{size:"sm",onClick:x,disabled:r||!u.trim(),className:"h-9",children:[e.jsx(I,{className:"w-4 h-4 mr-1"}),s("settingsGlobalEnv.add")]})]})]}),e.jsxs("div",{className:"p-4 rounded-lg border bg-muted/30",children:[e.jsx("h4",{className:"text-sm font-medium mb-3",children:s("settingsGlobalEnv.quickAdd")}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[[{key:"DISABLE_BUG_COMMAND",value:"1"},{key:"DISABLE_ERROR_REPORTING",value:"1"},{key:"DISABLE_TELEMETRY",value:"1"}].map(({key:t,value:p})=>!n?.env?.[t]&&e.jsxs(f,{variant:"outline",size:"sm",onClick:()=>{i(t),b(p)},className:"text-xs font-mono",children:["+ ",t]},t)),n?.env&&["DISABLE_BUG_COMMAND","DISABLE_ERROR_REPORTING","DISABLE_TELEMETRY"].every(t=>n.env[t])&&e.jsx("span",{className:"text-sm text-muted-foreground",children:s("settingsGlobalEnv.allConfigured")})]})]})]})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(f,{variant:"outline",size:"sm",onClick:()=>{a(),v()},disabled:o||r,className:"w-full",children:[e.jsx(N,{className:`w-4 h-4 mr-2 ${o?"animate-spin":""}`}),s("settings.refresh")]})})]})}export{Y as default};
|