@kaitranntt/ccs 7.71.0 → 7.72.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/README.md +39 -2
- package/config/base-codebuddy.settings.json +10 -0
- package/config/base-codex.settings.json +4 -4
- package/config/base-cursor.settings.json +10 -0
- package/config/base-gitlab.settings.json +10 -0
- package/config/base-kilo.settings.json +10 -0
- package/dist/auth/profile-detector.d.ts +2 -3
- package/dist/auth/profile-detector.d.ts.map +1 -1
- package/dist/auth/profile-detector.js +19 -19
- package/dist/auth/profile-detector.js.map +1 -1
- package/dist/ccs.js +89 -27
- package/dist/ccs.js.map +1 -1
- package/dist/cliproxy/accounts/email-account-identity.d.ts.map +1 -1
- package/dist/cliproxy/accounts/email-account-identity.js +22 -2
- package/dist/cliproxy/accounts/email-account-identity.js.map +1 -1
- package/dist/cliproxy/auth/auth-types.d.ts +10 -0
- package/dist/cliproxy/auth/auth-types.d.ts.map +1 -1
- package/dist/cliproxy/auth/auth-types.js +32 -0
- package/dist/cliproxy/auth/auth-types.js.map +1 -1
- package/dist/cliproxy/auth/gitlab-pat-response.d.ts +9 -0
- package/dist/cliproxy/auth/gitlab-pat-response.d.ts.map +1 -0
- package/dist/cliproxy/auth/gitlab-pat-response.js +64 -0
- package/dist/cliproxy/auth/gitlab-pat-response.js.map +1 -0
- package/dist/cliproxy/auth/kiro-import.js +1 -1
- package/dist/cliproxy/auth/kiro-import.js.map +1 -1
- package/dist/cliproxy/auth/oauth-handler.d.ts +3 -0
- package/dist/cliproxy/auth/oauth-handler.d.ts.map +1 -1
- package/dist/cliproxy/auth/oauth-handler.js +120 -4
- package/dist/cliproxy/auth/oauth-handler.js.map +1 -1
- package/dist/cliproxy/auth/provider-refreshers/index.d.ts +1 -2
- package/dist/cliproxy/auth/provider-refreshers/index.d.ts.map +1 -1
- package/dist/cliproxy/auth/provider-refreshers/index.js +6 -25
- package/dist/cliproxy/auth/provider-refreshers/index.js.map +1 -1
- package/dist/cliproxy/auth/token-manager.d.ts +1 -1
- package/dist/cliproxy/auth/token-manager.d.ts.map +1 -1
- package/dist/cliproxy/auth/token-manager.js +9 -6
- package/dist/cliproxy/auth/token-manager.js.map +1 -1
- package/dist/cliproxy/binary/lifecycle.d.ts.map +1 -1
- package/dist/cliproxy/binary/lifecycle.js +12 -1
- package/dist/cliproxy/binary/lifecycle.js.map +1 -1
- package/dist/cliproxy/binary-manager.d.ts +5 -1
- package/dist/cliproxy/binary-manager.d.ts.map +1 -1
- package/dist/cliproxy/binary-manager.js +10 -2
- package/dist/cliproxy/binary-manager.js.map +1 -1
- package/dist/cliproxy/codex-plan-compatibility.d.ts.map +1 -1
- package/dist/cliproxy/codex-plan-compatibility.js +6 -6
- package/dist/cliproxy/codex-plan-compatibility.js.map +1 -1
- package/dist/cliproxy/config/env-builder.d.ts +5 -0
- package/dist/cliproxy/config/env-builder.d.ts.map +1 -1
- package/dist/cliproxy/config/env-builder.js +56 -4
- package/dist/cliproxy/config/env-builder.js.map +1 -1
- package/dist/cliproxy/config/generator.d.ts +6 -1
- package/dist/cliproxy/config/generator.d.ts.map +1 -1
- package/dist/cliproxy/config/generator.js +4 -3
- package/dist/cliproxy/config/generator.js.map +1 -1
- package/dist/cliproxy/config/path-resolver.d.ts +21 -0
- package/dist/cliproxy/config/path-resolver.d.ts.map +1 -1
- package/dist/cliproxy/config/path-resolver.js +42 -2
- package/dist/cliproxy/config/path-resolver.js.map +1 -1
- package/dist/cliproxy/executor/index.d.ts +1 -0
- package/dist/cliproxy/executor/index.d.ts.map +1 -1
- package/dist/cliproxy/executor/index.js +42 -12
- package/dist/cliproxy/executor/index.js.map +1 -1
- package/dist/cliproxy/model-catalog.d.ts.map +1 -1
- package/dist/cliproxy/model-catalog.js +14 -59
- package/dist/cliproxy/model-catalog.js.map +1 -1
- package/dist/cliproxy/model-config.js +4 -4
- package/dist/cliproxy/model-config.js.map +1 -1
- package/dist/cliproxy/model-id-normalizer.d.ts +2 -0
- package/dist/cliproxy/model-id-normalizer.d.ts.map +1 -1
- package/dist/cliproxy/model-id-normalizer.js +25 -1
- package/dist/cliproxy/model-id-normalizer.js.map +1 -1
- package/dist/cliproxy/provider-capabilities.d.ts.map +1 -1
- package/dist/cliproxy/provider-capabilities.js +49 -1
- package/dist/cliproxy/provider-capabilities.js.map +1 -1
- package/dist/cliproxy/quota-fetcher-claude-normalizer.d.ts +1 -5
- package/dist/cliproxy/quota-fetcher-claude-normalizer.d.ts.map +1 -1
- package/dist/cliproxy/quota-fetcher-claude-normalizer.js +33 -6
- package/dist/cliproxy/quota-fetcher-claude-normalizer.js.map +1 -1
- package/dist/cliproxy/quota-fetcher-claude.d.ts +2 -2
- package/dist/cliproxy/quota-fetcher-claude.d.ts.map +1 -1
- package/dist/cliproxy/quota-fetcher-claude.js +18 -32
- package/dist/cliproxy/quota-fetcher-claude.js.map +1 -1
- package/dist/cliproxy/quota-fetcher-codex.d.ts.map +1 -1
- package/dist/cliproxy/quota-fetcher-codex.js +2 -0
- package/dist/cliproxy/quota-fetcher-codex.js.map +1 -1
- package/dist/cliproxy/quota-fetcher-gemini-cli.d.ts.map +1 -1
- package/dist/cliproxy/quota-fetcher-gemini-cli.js +221 -99
- package/dist/cliproxy/quota-fetcher-gemini-cli.js.map +1 -1
- package/dist/cliproxy/quota-types.d.ts +2 -2
- package/dist/cliproxy/quota-types.d.ts.map +1 -1
- package/dist/cliproxy/routing-strategy.d.ts.map +1 -1
- package/dist/cliproxy/routing-strategy.js +4 -1
- package/dist/cliproxy/routing-strategy.js.map +1 -1
- package/dist/cliproxy/service-manager.d.ts.map +1 -1
- package/dist/cliproxy/service-manager.js +4 -1
- package/dist/cliproxy/service-manager.js.map +1 -1
- package/dist/cliproxy/types.d.ts +11 -3
- package/dist/cliproxy/types.d.ts.map +1 -1
- package/dist/cliproxy/types.js +8 -1
- package/dist/cliproxy/types.js.map +1 -1
- package/dist/commands/browser-command.d.ts +5 -0
- package/dist/commands/browser-command.d.ts.map +1 -0
- package/dist/commands/browser-command.js +118 -0
- package/dist/commands/browser-command.js.map +1 -0
- package/dist/commands/command-catalog.d.ts +3 -2
- package/dist/commands/command-catalog.d.ts.map +1 -1
- package/dist/commands/command-catalog.js +29 -4
- package/dist/commands/command-catalog.js.map +1 -1
- package/dist/commands/completion-backend.d.ts.map +1 -1
- package/dist/commands/completion-backend.js +4 -0
- package/dist/commands/completion-backend.js.map +1 -1
- package/dist/commands/cursor-command-display.d.ts.map +1 -1
- package/dist/commands/cursor-command-display.js +43 -30
- 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 +30 -13
- package/dist/commands/cursor-command.js.map +1 -1
- package/dist/commands/help-command.d.ts +2 -0
- package/dist/commands/help-command.d.ts.map +1 -1
- package/dist/commands/help-command.js +62 -3
- package/dist/commands/help-command.js.map +1 -1
- package/dist/commands/index.d.ts +1 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +3 -1
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/proxy-command.d.ts +2 -0
- package/dist/commands/proxy-command.d.ts.map +1 -0
- package/dist/commands/proxy-command.js +156 -0
- package/dist/commands/proxy-command.js.map +1 -0
- package/dist/commands/root-command-router.d.ts.map +1 -1
- package/dist/commands/root-command-router.js +14 -0
- package/dist/commands/root-command-router.js.map +1 -1
- package/dist/config/reserved-names.d.ts +1 -1
- package/dist/config/reserved-names.d.ts.map +1 -1
- package/dist/config/reserved-names.js +10 -0
- package/dist/config/reserved-names.js.map +1 -1
- package/dist/config/unified-config-loader.d.ts +6 -1
- package/dist/config/unified-config-loader.d.ts.map +1 -1
- package/dist/config/unified-config-loader.js +67 -1
- package/dist/config/unified-config-loader.js.map +1 -1
- package/dist/config/unified-config-types.d.ts +37 -0
- package/dist/config/unified-config-types.d.ts.map +1 -1
- package/dist/config/unified-config-types.js +25 -1
- package/dist/config/unified-config-types.js.map +1 -1
- package/dist/cursor/constants.d.ts +3 -0
- package/dist/cursor/constants.d.ts.map +1 -1
- package/dist/cursor/constants.js +26 -1
- package/dist/cursor/constants.js.map +1 -1
- package/dist/cursor/cursor-anthropic-response.d.ts +1 -6
- package/dist/cursor/cursor-anthropic-response.d.ts.map +1 -1
- package/dist/cursor/cursor-anthropic-response.js +3 -186
- package/dist/cursor/cursor-anthropic-response.js.map +1 -1
- package/dist/cursor/cursor-daemon-entry.js +2 -2
- package/dist/cursor/cursor-daemon-entry.js.map +1 -1
- package/dist/cursor/cursor-profile-executor.js +4 -4
- package/dist/cursor/cursor-profile-executor.js.map +1 -1
- package/dist/cursor/cursor-runtime-probe.js +3 -3
- package/dist/cursor/cursor-runtime-probe.js.map +1 -1
- package/dist/glmt/sse-parser.d.ts.map +1 -1
- package/dist/glmt/sse-parser.js +46 -41
- package/dist/glmt/sse-parser.js.map +1 -1
- package/dist/management/shared-manager.d.ts +2 -0
- package/dist/management/shared-manager.d.ts.map +1 -1
- package/dist/management/shared-manager.js +25 -10
- package/dist/management/shared-manager.js.map +1 -1
- package/dist/proxy/index.d.ts +8 -0
- package/dist/proxy/index.d.ts.map +1 -0
- package/dist/proxy/index.js +24 -0
- package/dist/proxy/index.js.map +1 -0
- package/dist/proxy/profile-router.d.ts +28 -0
- package/dist/proxy/profile-router.d.ts.map +1 -0
- package/dist/proxy/profile-router.js +43 -0
- package/dist/proxy/profile-router.js.map +1 -0
- package/dist/proxy/proxy-daemon-entry.d.ts +2 -0
- package/dist/proxy/proxy-daemon-entry.d.ts.map +1 -0
- package/dist/proxy/proxy-daemon-entry.js +68 -0
- package/dist/proxy/proxy-daemon-entry.js.map +1 -0
- package/dist/proxy/proxy-daemon-paths.d.ts +6 -0
- package/dist/proxy/proxy-daemon-paths.d.ts.map +1 -0
- package/dist/proxy/proxy-daemon-paths.js +43 -0
- package/dist/proxy/proxy-daemon-paths.js.map +1 -0
- package/dist/proxy/proxy-daemon-state.d.ts +18 -0
- package/dist/proxy/proxy-daemon-state.d.ts.map +1 -0
- package/dist/proxy/proxy-daemon-state.js +92 -0
- package/dist/proxy/proxy-daemon-state.js.map +1 -0
- package/dist/proxy/proxy-daemon.d.ts +26 -0
- package/dist/proxy/proxy-daemon.d.ts.map +1 -0
- package/dist/proxy/proxy-daemon.js +350 -0
- package/dist/proxy/proxy-daemon.js.map +1 -0
- package/dist/proxy/proxy-env.d.ts +3 -0
- package/dist/proxy/proxy-env.d.ts.map +1 -0
- package/dist/proxy/proxy-env.js +26 -0
- package/dist/proxy/proxy-env.js.map +1 -0
- package/dist/proxy/request-router.d.ts +12 -0
- package/dist/proxy/request-router.d.ts.map +1 -0
- package/dist/proxy/request-router.js +163 -0
- package/dist/proxy/request-router.js.map +1 -0
- package/dist/proxy/routing-config.d.ts +10 -0
- package/dist/proxy/routing-config.d.ts.map +1 -0
- package/dist/proxy/routing-config.js +79 -0
- package/dist/proxy/routing-config.js.map +1 -0
- package/dist/proxy/server/http-helpers.d.ts +8 -0
- package/dist/proxy/server/http-helpers.d.ts.map +1 -0
- package/dist/proxy/server/http-helpers.js +73 -0
- package/dist/proxy/server/http-helpers.js.map +1 -0
- package/dist/proxy/server/messages-route.d.ts +12 -0
- package/dist/proxy/server/messages-route.d.ts.map +1 -0
- package/dist/proxy/server/messages-route.js +208 -0
- package/dist/proxy/server/messages-route.js.map +1 -0
- package/dist/proxy/server/proxy-server.d.ts +12 -0
- package/dist/proxy/server/proxy-server.d.ts.map +1 -0
- package/dist/proxy/server/proxy-server.js +110 -0
- package/dist/proxy/server/proxy-server.js.map +1 -0
- package/dist/proxy/transformers/request-transformer.d.ts +52 -0
- package/dist/proxy/transformers/request-transformer.d.ts.map +1 -0
- package/dist/proxy/transformers/request-transformer.js +254 -0
- package/dist/proxy/transformers/request-transformer.js.map +1 -0
- package/dist/proxy/transformers/sse-stream-transformer.d.ts +11 -0
- package/dist/proxy/transformers/sse-stream-transformer.d.ts.map +1 -0
- package/dist/proxy/transformers/sse-stream-transformer.js +199 -0
- package/dist/proxy/transformers/sse-stream-transformer.js.map +1 -0
- package/dist/proxy/upstream-url.d.ts +3 -0
- package/dist/proxy/upstream-url.d.ts.map +1 -0
- package/dist/proxy/upstream-url.js +35 -0
- package/dist/proxy/upstream-url.js.map +1 -0
- package/dist/shared/claude-extension-setup.js +1 -1
- package/dist/shared/claude-extension-setup.js.map +1 -1
- package/dist/targets/codex-detector.d.ts.map +1 -1
- package/dist/targets/codex-detector.js +17 -8
- package/dist/targets/codex-detector.js.map +1 -1
- package/dist/targets/droid-provider.d.ts.map +1 -1
- package/dist/targets/droid-provider.js +2 -0
- package/dist/targets/droid-provider.js.map +1 -1
- package/dist/types/config.d.ts +13 -0
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/config.js.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/ui/assets/{accounts-B8EmUjf7.js → accounts-DfkqFx14.js} +1 -1
- package/dist/ui/assets/{alert-dialog-zvnFuSZG.js → alert-dialog-BJ9GwHLZ.js} +1 -1
- package/dist/ui/assets/{api-vTHvDFg5.js → api-BVo8Vm1B.js} +1 -1
- package/dist/ui/assets/{auth-section-Dg3AdWQR.js → auth-section-B-Ms1O_M.js} +1 -1
- package/dist/ui/assets/{backups-section-CuRlCk7U.js → backups-section-f8hvkPfH.js} +1 -1
- package/dist/ui/assets/{channels-ByIXpMal.js → channels-Bgvry5fT.js} +1 -1
- package/dist/ui/assets/{checkbox-DoV2JinM.js → checkbox-CbI3Vbww.js} +1 -1
- package/dist/ui/assets/{claude-extension-B-Ofp87Z.js → claude-extension-lDT7lp8C.js} +1 -1
- package/dist/ui/assets/cliproxy-D50Owb9u.js +3 -0
- package/dist/ui/assets/{cliproxy-ai-providers-BVOtMT7b.js → cliproxy-ai-providers-Cjrk90aJ.js} +8 -8
- package/dist/ui/assets/{cliproxy-control-panel-qL0R878z.js → cliproxy-control-panel-DL8JoyKU.js} +1 -1
- package/dist/ui/assets/codex-B3bW7lzx.js +27 -0
- package/dist/ui/assets/{confirm-dialog-BcfzKHj3.js → confirm-dialog-Bm2Y3ArL.js} +1 -1
- package/dist/ui/assets/{copilot-Dti40Uv-.js → copilot-CPLBRpFA.js} +1 -1
- package/dist/ui/assets/cursor-D1xhqEEF.js +1 -0
- package/dist/ui/assets/{droid-BmuIeDFh.js → droid-DiFtSJkl.js} +2 -2
- package/dist/ui/assets/{globalenv-section-CGbpkbpW.js → globalenv-section-BadlR8mm.js} +1 -1
- package/dist/ui/assets/{health-DryU1jzv.js → health-Bxol1p1X.js} +1 -1
- package/dist/ui/assets/{icons-KVCk4_U8.js → icons-Dmi9qMuE.js} +1 -1
- package/dist/ui/assets/{index-Dgu-LYP_.js → index-BPCsEKJ8.js} +1 -1
- package/dist/ui/assets/{index-B_vdNMI1.js → index-BZYBDV6A.js} +1 -1
- package/dist/ui/assets/index-C2-J9AKi.js +1 -0
- package/dist/ui/assets/{index-DUCkRc_D.js → index-CA4r5qY8.js} +1 -1
- package/dist/ui/assets/index-CXRoMyUA.js +9 -0
- package/dist/ui/assets/index-DM7Qb4kd.js +72 -0
- package/dist/ui/assets/index-DuTB1_9r.css +1 -0
- package/dist/ui/assets/{index-Cu--MLG0.js → index-x07V45Iw.js} +1 -1
- package/dist/ui/assets/{logs-CtIgaS7y.js → logs-kvpMF-pw.js} +1 -1
- package/dist/ui/assets/{masked-input-Dm8T-Vtr.js → masked-input-CFQ05toP.js} +1 -1
- package/dist/ui/assets/providers/codebuddy.png +0 -0
- package/dist/ui/assets/providers/cursor.svg +5 -0
- package/dist/ui/assets/providers/gitlab.svg +22 -0
- package/dist/ui/assets/providers/kilo.png +0 -0
- package/dist/ui/assets/{proxy-status-widget-BXghaDz7.js → proxy-status-widget-Df_-wCR0.js} +1 -1
- package/dist/ui/assets/{raw-json-settings-editor-panel-DhhcWn5Q.js → raw-json-settings-editor-panel-DeWgWDSP.js} +1 -1
- package/dist/ui/assets/{searchable-select-DiGUiefs.js → searchable-select-CPbVBSoE.js} +1 -1
- package/dist/ui/assets/{separator-DnQqlaL0.js → separator--T-CzItG.js} +1 -1
- package/dist/ui/assets/{shared-BPuiJsYO.js → shared-Dx_5pa5N.js} +1 -1
- package/dist/ui/assets/{table-BDsTJlxT.js → table-wE_LUUUQ.js} +1 -1
- package/dist/ui/assets/{updates-DQxYQBCf.js → updates-mWDqf-fm.js} +1 -1
- package/dist/ui/index.html +3 -3
- package/dist/utils/browser/browser-settings.d.ts +27 -0
- package/dist/utils/browser/browser-settings.d.ts.map +1 -0
- package/dist/utils/browser/browser-settings.js +127 -0
- package/dist/utils/browser/browser-settings.js.map +1 -0
- package/dist/utils/browser/browser-status.d.ts +39 -0
- package/dist/utils/browser/browser-status.d.ts.map +1 -0
- package/dist/utils/browser/browser-status.js +134 -0
- package/dist/utils/browser/browser-status.js.map +1 -0
- package/dist/utils/browser/chrome-reuse.d.ts +1 -0
- package/dist/utils/browser/chrome-reuse.d.ts.map +1 -1
- package/dist/utils/browser/chrome-reuse.js.map +1 -1
- package/dist/utils/browser/index.d.ts +4 -0
- package/dist/utils/browser/index.d.ts.map +1 -1
- package/dist/utils/browser/index.js +8 -1
- package/dist/utils/browser/index.js.map +1 -1
- package/dist/utils/browser/platform.d.ts +4 -0
- package/dist/utils/browser/platform.d.ts.map +1 -0
- package/dist/utils/browser/platform.js +12 -0
- package/dist/utils/browser/platform.js.map +1 -0
- package/dist/utils/hooks/image-analysis-backend-resolver.js +1 -1
- package/dist/utils/hooks/image-analysis-backend-resolver.js.map +1 -1
- package/dist/web-server/routes/browser-routes.d.ts +3 -0
- package/dist/web-server/routes/browser-routes.d.ts.map +1 -0
- package/dist/web-server/routes/browser-routes.js +116 -0
- package/dist/web-server/routes/browser-routes.js.map +1 -0
- package/dist/web-server/routes/cliproxy-auth-routes.d.ts.map +1 -1
- package/dist/web-server/routes/cliproxy-auth-routes.js +124 -1
- package/dist/web-server/routes/cliproxy-auth-routes.js.map +1 -1
- package/dist/web-server/routes/config-routes.d.ts.map +1 -1
- package/dist/web-server/routes/config-routes.js +3 -0
- package/dist/web-server/routes/config-routes.js.map +1 -1
- package/dist/web-server/routes/index.d.ts.map +1 -1
- package/dist/web-server/routes/index.js +3 -0
- package/dist/web-server/routes/index.js.map +1 -1
- package/dist/web-server/routes/settings-routes.d.ts.map +1 -1
- package/dist/web-server/routes/settings-routes.js +8 -0
- package/dist/web-server/routes/settings-routes.js.map +1 -1
- package/dist/web-server/services/compatible-cli-docs-registry.d.ts.map +1 -1
- package/dist/web-server/services/compatible-cli-docs-registry.js +1 -0
- package/dist/web-server/services/compatible-cli-docs-registry.js.map +1 -1
- package/package.json +1 -1
- package/dist/cliproxy/auth/gemini-token-refresh.d.ts +0 -40
- package/dist/cliproxy/auth/gemini-token-refresh.d.ts.map +0 -1
- package/dist/cliproxy/auth/gemini-token-refresh.js +0 -371
- package/dist/cliproxy/auth/gemini-token-refresh.js.map +0 -1
- package/dist/ui/assets/cliproxy-Bhu0JvIb.js +0 -3
- package/dist/ui/assets/codex-BCHZ-0dx.js +0 -27
- package/dist/ui/assets/cursor-BG0Y8Z5F.js +0 -1
- package/dist/ui/assets/index-B1mN7ZR-.js +0 -72
- package/dist/ui/assets/index-BBVoDJnl.js +0 -1
- package/dist/ui/assets/index-BMC5Tudw.css +0 -1
package/dist/ui/assets/{cliproxy-ai-providers-BVOtMT7b.js → cliproxy-ai-providers-Cjrk90aJ.js}
RENAMED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as o,u as Fe,h as Ge}from"./react-vendor-CNOkPC89.js";import{c as B,
|
|
1
|
+
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as o,u as Fe,h as Ge}from"./react-vendor-CNOkPC89.js";import{c as B,aE as pe,b5 as xe,B as p,a as Ue,b6 as Ie,ah as Ve,ai as ze,aj as Je,ak as _e,al as Qe,L,I as A,M as We,N as Xe,O as Ye,aD as Ze,d as y,b7 as he,b8 as Le,Y as ne,S as be,n as se,Q as je,R as Ne,U as X,V as Y,b9 as we,ba as es,bb as ss}from"./index-DM7Qb4kd.js";import{P as ts}from"./proxy-status-widget-Df_-wCR0.js";import{C as rs}from"./confirm-dialog-Bm2Y3ArL.js";import{l as as,w as Re,m as Te,n as ge,aC as te,s as ns,R as de,Z as is,a9 as Ee,p as qe,O as ls,Q as os,at as ds,au as cs,_ as Ce,aM as Oe,aN as Ke,ai as He,ax as ms,aO as us}from"./icons-Dmi9qMuE.js";import{u as ps,a as fe,b as ve}from"./tanstack-CrmUhA7Z.js";import{t as G}from"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-BJ9GwHLZ.js";function xs(s){switch(s){case"ready":return{icon:Te,text:"Ready",className:"text-green-600"};case"partial":return{icon:Re,text:"Needs attention",className:"text-amber-600"};default:return{icon:as,text:"Not configured",className:"text-muted-foreground"}}}function hs({families:s,selectedFamily:t,onSelect:r}){return e.jsx("div",{className:"space-y-1",children:s.map(n=>{const i=n.id===t,d=xs(n.status),h=d.icon;return e.jsx("button",{type:"button",onClick:()=>r(n.id),className:B("w-full cursor-pointer rounded-lg border px-3 py-2.5 text-left transition-colors",i?"border-primary/20 bg-primary/10":"border-transparent hover:bg-muted/70"),children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(pe,{provider:xe(n.id),size:"md"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-medium",children:n.displayName}),n.entries.length>0&&e.jsx(p,{variant:"secondary",className:"h-4 px-1 text-[10px]",children:n.entries.length})]}),e.jsxs("div",{className:B("mt-0.5 flex items-center gap-1.5 text-xs",d.className),children:[e.jsx(h,{className:"h-3 w-3"}),e.jsx("span",{children:d.text})]})]}),e.jsx(p,{variant:"outline",className:"h-5 px-1.5 text-[9px] uppercase tracking-wide",children:n.authMode})]})},n.id)})})}function gs(s){switch(s){case"gemini-api-key":return{familyName:"Gemini",description:"Store the Gemini key here so CLIProxy can route Gemini requests without creating a separate CCS API Profile.",requiredNow:["Paste the Gemini API key.","Leave Base URL empty unless you use a custom Gemini host."],optionalLater:["Model mappings only when requested names and Gemini names differ.","Headers only when your provider setup requires them."],keyLabel:"Gemini API Key",keyPlaceholder:"AIza...",keyHelper:"This is the only field most Gemini setups need.",baseUrlPlaceholder:"https://generativelanguage.googleapis.com",baseUrlHelper:"Optional. Leave blank to keep the default Gemini endpoint.",aliasesPlaceholder:"claude-sonnet-4-5=gemini-2.5-pro",aliasesHelper:"Format: requested=upstream. Leave this blank unless the upstream Gemini model name differs.",headersPlaceholder:"X-Goog-User-Project: your-project"};case"codex-api-key":return{familyName:"Codex",description:"Store the Codex or OpenAI key here so CLIProxy can route Codex requests without duplicating the setup in API Profiles.",requiredNow:["Paste the Codex or OpenAI API key.","Leave Base URL empty unless this route should target another OpenAI-style endpoint."],optionalLater:["Model mappings only when the upstream model ID differs.","Headers only when org or project routing needs them."],keyLabel:"Codex API Key",keyPlaceholder:"sk-...",keyHelper:"This is the only field most Codex setups need.",baseUrlPlaceholder:"https://api.openai.com/v1",baseUrlHelper:"Optional. Leave blank to keep the default Codex endpoint.",aliasesPlaceholder:"claude-sonnet-4-5=gpt-5",aliasesHelper:"Format: requested=upstream. Add a mapping only when the upstream model name differs.",headersPlaceholder:"OpenAI-Organization: org_..."};case"claude-api-key":return{familyName:"Claude",description:"Store the Anthropic or compatible key here for CLIProxy-managed Claude routing. Save the key first, then add rewrites only if this route needs them.",requiredNow:["Paste the Claude or Anthropic-compatible API key.","Leave Base URL empty unless this route should target another compatible endpoint."],optionalLater:["Model mappings only when the requested and upstream Claude model IDs differ.","Proxy, prefix, exclusions, and headers only for advanced routing cases."],keyLabel:"Claude API Key",keyPlaceholder:"sk-ant-...",keyHelper:"Most Claude routes can start with the key only.",baseUrlPlaceholder:"https://api.anthropic.com",baseUrlHelper:"Optional. Leave blank to keep the default Claude-compatible endpoint.",aliasesPlaceholder:"claude-sonnet-4-5=claude-3-7-sonnet-latest",aliasesHelper:"Format: requested=upstream. Add a mapping only when the upstream model ID should differ.",headersPlaceholder:"X-Project: internal-routing"};case"vertex-api-key":return{familyName:"Vertex",description:"Store the Vertex key here so CLIProxy can route Vertex traffic without creating a separate CCS API Profile.",requiredNow:["Paste the Vertex API key.","Leave Base URL empty unless a regional or gateway endpoint is required."],optionalLater:["Model mappings only when the upstream name differs.","Headers only when the provider expects extra routing context."],keyLabel:"Vertex API Key",keyPlaceholder:"AIza...",keyHelper:"Most Vertex routes only need the key.",baseUrlPlaceholder:"https://vertex.googleapis.com",baseUrlHelper:"Optional. Leave blank to keep the default Vertex endpoint.",aliasesPlaceholder:"claude-sonnet-4-5=gemini-2.5-pro",aliasesHelper:"Format: requested=upstream. Leave blank unless the upstream model name differs.",headersPlaceholder:"X-Goog-User-Project: your-project"};case"openai-compatibility":return{familyName:"OpenAI-Compatible Connector",description:"Create a named connector for OpenRouter, Together, or any OpenAI-style endpoint. This page owns the connector setup directly inside CLIProxy.",requiredNow:["Pick a connector name such as openrouter or together.","Set the connector Base URL.","Add at least one API key before saving."],optionalLater:["Model mappings only when requested and upstream model names differ.","Headers only when the connector requires provider-specific auth or routing."],keyLabel:"API Keys",keyPlaceholder:"sk-...",keyHelper:"Add one key per line. Most connectors start with a single key.",connectorPlaceholder:"openrouter",connectorHelper:"This becomes the connector label in the saved entries list.",baseUrlPlaceholder:"https://openrouter.ai/api/v1",baseUrlHelper:"Required for connectors. This is the upstream OpenAI-style endpoint.",aliasesPlaceholder:"claude-sonnet-4-5=gpt-4.1",aliasesHelper:"Format: requested=upstream. Leave blank unless the connector expects a different model ID.",headersPlaceholder:"HTTP-Referer: https://your-app.example"}}}function ke(s){return s.split(`
|
|
2
2
|
`).map(t=>t.trim()).filter(t=>t.length>0)}function fs(s){return s.split(`
|
|
3
|
-
`).map(t=>t.trim()).filter(t=>t.length>0).map(t=>{const r=t.includes(":")?":":"=",[n,...i]=t.split(r);return{key:n.trim(),value:i.join(r).trim()}}).filter(t=>t.key.length>0)}function vs(s){return
|
|
3
|
+
`).map(t=>t.trim()).filter(t=>t.length>0).map(t=>{const r=t.includes(":")?":":"=",[n,...i]=t.split(r);return{key:n.trim(),value:i.join(r).trim()}}).filter(t=>t.key.length>0)}function vs(s){return Le(s)}function Z({value:s,onChange:t,placeholder:r,rows:n=4}){return e.jsx("textarea",{rows:n,value:s,onChange:i=>t(i.target.value),placeholder:r,className:"flex min-h-24 w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-xs outline-none transition-[color,box-shadow] placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50"})}function ys(s){return(s?.headers||[]).map(t=>`${t.key}: ${t.value}`).join(`
|
|
4
4
|
`)}function bs(s){return(s?.excludedModels||[]).join(`
|
|
5
|
-
`)}function js(s){return he(s?.models)}function Pe({title:s,items:t,icon:r}){return e.jsxs("div",{className:"rounded-xl border bg-background/80 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[r,s]}),e.jsx("div",{className:"mt-3 space-y-3",children:t.map((n,i)=>e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full border bg-muted/40 text-[11px] font-semibold text-muted-foreground",children:i+1}),e.jsx("div",{className:"text-sm leading-6 text-muted-foreground",children:n})]},`${s}:${n}`))})]})}function Ns({family:s,entry:t,open:r,onOpenChange:n,onSubmit:i,isSaving:d}){const{t:h}=Ue(),a=o.useMemo(()=>gs(s),[s]),x=!!t,g=s==="openai-compatibility",C=s==="claude-api-key",[O,S]=o.useState(()=>t?.name||""),[k,M]=o.useState(()=>t?.baseUrl||""),[U,K]=o.useState(()=>t?.proxyUrl||""),[R,J]=o.useState(()=>t?.prefix||""),[b,T]=o.useState(""),[j,m]=o.useState(""),[N,H]=o.useState(()=>ys(t)),[$,F]=o.useState(()=>bs(t)),[q,v]=o.useState(()=>js(t)),
|
|
6
|
-
${a.keyPlaceholder}`}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a.keyHelper})]})]}):e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(I,{htmlFor:"api-key",children:a.keyLabel}),e.jsx(A,{id:"api-key",type:"password",value:b,onChange:f=>T(f.target.value),placeholder:a.keyPlaceholder}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a.keyHelper})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold",children:h("aiProvidersEntryDialog.optionalRouting")}),e.jsx("div",{className:"mt-1 text-sm text-muted-foreground",children:"Only fill these when the route needs more than the default behavior."})]}),g?null:e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(I,{htmlFor:"base-url",children:"Base URL"}),e.jsx(A,{id:"base-url",value:k,onChange:f=>M(f.target.value),placeholder:a.baseUrlPlaceholder}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a.baseUrlHelper})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(I,{children:"Model Mappings"}),e.jsx(Z,{value:q,onChange:v,rows:4,placeholder:a.aliasesPlaceholder}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a.aliasesHelper}),L.length>0?e.jsx("p",{className:"text-xs text-destructive",children:L[0]}):null]})]}),e.jsx(We,{open:P,onOpenChange:_,children:e.jsxs("div",{className:"rounded-xl border",children:[e.jsx(Xe,{asChild:!0,children:e.jsxs("button",{type:"button",className:"flex w-full items-center justify-between gap-4 px-4 py-4 text-left",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(te,{className:"h-4 w-4 text-primary"}),"Advanced routing"]}),e.jsxs("div",{className:"mt-1 text-sm text-muted-foreground",children:["Headers",C?", proxy, prefix, and exclusions.":" and provider-specific overrides."]})]}),e.jsx(ns,{className:B("h-4 w-4 text-muted-foreground transition-transform",P&&"rotate-180")})]})}),e.jsx(Ye,{className:"border-t px-4 py-4",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(I,{children:"Headers"}),e.jsx(Z,{value:N,onChange:H,rows:3,placeholder:a.headersPlaceholder}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Use headers only when the provider requires extra routing or auth context."})]}),C?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(I,{htmlFor:"prefix",children:"Prefix"}),e.jsx(A,{id:"prefix",value:R,onChange:f=>J(f.target.value),placeholder:"glm-"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. Prepends model names before routing."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(I,{htmlFor:"proxy-url",children:"Proxy URL"}),e.jsx(A,{id:"proxy-url",value:U,onChange:f=>K(f.target.value),placeholder:"http://127.0.0.1:8080"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. Sends requests through an intermediate proxy."})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(I,{children:"Excluded Models"}),e.jsx(Z,{value:$,onChange:F,rows:3,placeholder:"claude-opus-4-1\\nclaude-sonnet-4-5"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. One model ID per line when this route should reject specific upstream models."})]})]}):null]})})]})})]}),e.jsxs(Ze,{className:"border-t bg-muted/10 px-6 py-4",children:[e.jsx(y,{type:"button",variant:"outline",onClick:()=>n(!1),children:"Cancel"}),e.jsx(y,{type:"button",onClick:()=>void l(),disabled:d||L.length>0,children:d?"Saving...":g?x?"Save Connector":"Create Connector":"Save Entry"})]})]})})})}const ie=["cliproxy-ai-providers"];function ws(){return ps({queryKey:ie,queryFn:()=>ne.cliproxy.aiProviders.list()})}function Cs(){const s=fe();return ve({mutationFn:({family:t,data:r})=>ne.cliproxy.aiProviders.create(t,r),onSuccess:()=>{s.invalidateQueries({queryKey:ie}),G.success("Provider entry created")},onError:t=>{G.error(t.message)}})}function ks(){const s=fe();return ve({mutationFn:({family:t,entryId:r,data:n})=>ne.cliproxy.aiProviders.update(t,r,n),onSuccess:()=>{s.invalidateQueries({queryKey:ie}),G.success("Provider entry updated")},onError:t=>{G.error(t.message)}})}function Ps(){const s=fe();return ve({mutationFn:({family:t,entryId:r})=>ne.cliproxy.aiProviders.delete(t,r),onSuccess:()=>{s.invalidateQueries({queryKey:ie}),G.success("Provider entry removed")},onError:t=>{G.error(t.message)}})}function Q({label:s,value:t,hint:r}){return e.jsxs("div",{className:"rounded-lg border bg-background p-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:s}),e.jsx("div",{className:"mt-1 break-all text-sm font-medium leading-5",children:t}),r?e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:r}):null]})}function As(s){switch(s){case"ready":return{label:"Ready",className:"bg-emerald-50 text-emerald-700 hover:bg-emerald-50"};case"partial":return{label:"Needs attention",className:"bg-amber-50 text-amber-700 hover:bg-amber-50"};default:return{label:"Empty",className:"bg-muted text-muted-foreground hover:bg-muted"}}}function me(s){return s.proxyUrl?"Proxy override":s.prefix?"Prefixed route":s.baseUrl?"Direct upstream":"Default runtime"}function $e(s){return s.filter(t=>t.alias.trim().length>0).length}function De(s){return s.filter(t=>t.name.trim().length>0&&t.alias.trim().length===0).length}function re(s){const t=$e(s),r=De(s),n=[];return t>0&&n.push(`${t} mapped`),r>0&&n.push(`${r} direct`),n.length>0?n.join(" + "):"No model rules"}function ue({configured:s}){return e.jsx(p,{variant:"secondary",className:B("border-transparent text-[10px]",s?"bg-emerald-50 text-emerald-700 hover:bg-emerald-50":"bg-muted text-muted-foreground hover:bg-muted"),children:s?"Configured":"Missing secret"})}const V="<stored in CLIProxy>";function Be(s){switch(s.id){case"gemini-api-key":return{requiredNow:["Save the Gemini API key.","Leave Base URL blank unless you use a custom Gemini gateway.","Add model mappings only when Gemini model names differ from the requested ones."],optionalLater:["Headers for provider-specific project routing.","Base URL override for a proxy or regional endpoint.","Mappings such as claude-sonnet-4-5 -> gemini-2.5-pro."],emptyStateSummary:[`Requests to ${s.routePath} use CLIProxy-managed Gemini credentials.`,"The default upstream is enough for most Gemini setups.","Model mappings and headers are optional, not step one."],profileBoundary:"Use API Profiles when you want a CCS-native Anthropic-compatible profile instead of this CLIProxy-managed Gemini route.",editPrompts:[{label:"Base URL",hint:"Change it only for a custom Gemini gateway or regional endpoint."},{label:"Model mappings",hint:"Add them only when requested names and Gemini names differ."},{label:"Headers",hint:"Keep them empty unless the provider requires project or org routing."}]};case"codex-api-key":return{requiredNow:["Save the Codex or OpenAI API key.","Leave Base URL blank unless this route should hit a different OpenAI-style host.","Add mappings only when the upstream model name differs from what CCS requests."],optionalLater:["Base URL override for a gateway, proxy, or self-hosted endpoint.","Headers for org or project routing.","Mappings such as claude-sonnet-4-5 -> gpt-5."],emptyStateSummary:[`Requests to ${s.routePath} use CLIProxy-managed Codex credentials.`,"Most setups can keep the default upstream and skip extra routing.","Mappings are only needed when the upstream model naming does not match the requested one."],profileBoundary:"Use API Profiles when you want a CCS-native Anthropic-compatible profile rather than this CLIProxy-managed Codex route.",editPrompts:[{label:"Base URL",hint:"Change it only when Codex should resolve through another OpenAI-style endpoint."},{label:"Model mappings",hint:"Map requested model names to the exact upstream model ID only when needed."},{label:"Headers",hint:"Use headers sparingly for project routing or extra auth."}]};case"claude-api-key":return{requiredNow:["Save the Anthropic or compatible API key.","Leave Base URL blank unless this route should point at a custom Claude-compatible endpoint.","Add mappings only when the upstream model ID differs from the requested Claude model name."],optionalLater:["Prefix or proxy overrides for advanced route rewriting.","Excluded models when a route should block specific model IDs.","Headers for project-scoped routing."],emptyStateSummary:[`Requests to ${s.routePath} use a CLIProxy-managed Claude-compatible key.`,"Base URL, proxy, and prefix rewrites are advanced options, not the minimum setup.","Most users can start with a key only, then add mappings or filters if routing needs it."],profileBoundary:"Use API Profiles when you want a CCS-native Anthropic-compatible profile or preset instead of this CLIProxy-managed Claude route.",editPrompts:[{label:"Base URL",hint:"Change it only when Claude traffic should target another compatible endpoint."},{label:"Mappings",hint:"Add them only when the requested Claude model name should route to a different upstream ID."},{label:"Advanced routing",hint:"Proxy, prefix, headers, and exclusions are for edge cases. Leave them blank when unsure."}]};case"vertex-api-key":return{requiredNow:["Save the Vertex API key.","Leave Base URL blank unless a regional or gateway endpoint is required.","Add mappings only when the upstream model name differs from the requested name."],optionalLater:["Base URL override for a regional gateway.","Headers for provider-specific routing.","Mappings for translating requested names to Vertex model IDs."],emptyStateSummary:[`Requests to ${s.routePath} use CLIProxy-managed Vertex credentials.`,"Most setups start with the key only and keep the default endpoint.","Mappings and headers are optional follow-up steps."],profileBoundary:"Use API Profiles when you need a CCS-native Anthropic-compatible profile rather than this CLIProxy-managed Vertex route.",editPrompts:[{label:"Base URL",hint:"Use it only for a regional gateway or managed Vertex endpoint."},{label:"Model mappings",hint:"Add them only when the requested names need translating upstream."},{label:"Headers",hint:"Keep them empty unless the provider requires extra routing context."}]};case"openai-compatibility":return{requiredNow:["Name the connector, for example openrouter or together.","Set the connector Base URL.","Add at least one API key before saving."],optionalLater:["Headers for provider-specific auth or project routing.","Model mappings such as claude-sonnet-4-5 -> gpt-4.1.","Additional API keys for the same connector."],emptyStateSummary:[`Requests to ${s.routePath} resolve through a named OpenAI-compatible connector.`,"This flow needs a connector name, a Base URL, and one or more API keys.","Headers and mappings come after the connector is already working."],profileBoundary:"Use API Profiles when you want a CCS-native Anthropic-compatible profile, preset, or provider outside the CLIProxy connector flow.",editPrompts:[{label:"Connector identity",hint:"Keep the connector name and Base URL stable once clients depend on it."},{label:"Model mappings",hint:"Only add them when the connector expects a different upstream model ID."},{label:"Headers",hint:"Use them for provider-specific auth or project routing, not as a default."}]}}}function z(s){return s.split(`
|
|
5
|
+
`)}function js(s){return he(s?.models)}function Pe({title:s,items:t,icon:r}){return e.jsxs("div",{className:"rounded-xl border bg-background/80 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[r,s]}),e.jsx("div",{className:"mt-3 space-y-3",children:t.map((n,i)=>e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full border bg-muted/40 text-[11px] font-semibold text-muted-foreground",children:i+1}),e.jsx("div",{className:"text-sm leading-6 text-muted-foreground",children:n})]},`${s}:${n}`))})]})}function Ns({family:s,entry:t,open:r,onOpenChange:n,onSubmit:i,isSaving:d}){const{t:h}=Ue(),a=o.useMemo(()=>gs(s),[s]),x=!!t,g=s==="openai-compatibility",C=s==="claude-api-key",[O,S]=o.useState(()=>t?.name||""),[k,M]=o.useState(()=>t?.baseUrl||""),[U,K]=o.useState(()=>t?.proxyUrl||""),[R,J]=o.useState(()=>t?.prefix||""),[b,T]=o.useState(""),[j,m]=o.useState(""),[N,H]=o.useState(()=>ys(t)),[$,F]=o.useState(()=>bs(t)),[q,v]=o.useState(()=>js(t)),I=o.useMemo(()=>Ie(q),[q]),[P,_]=o.useState(()=>!!(t?.headers.length||t?.excludedModels.length||t?.proxyUrl||t?.prefix)),D=o.useMemo(()=>!x||!t?.secretConfigured?null:g?"Leave API keys blank to keep the stored connector secrets.":"Leave the API key blank to keep the stored secret.",[t?.secretConfigured,x,g]),l=async()=>{if(I.length>0)return;const f=b.trim(),w=ke(j),le=x&&t?.secretConfigured&&!f.length&&w.length===0,oe={name:g?O:void 0,baseUrl:k,proxyUrl:C?U:void 0,prefix:C?R:void 0,headers:fs(N),excludedModels:C?ke($):void 0,models:vs(q),preserveSecrets:le,...g?w.length>0?{apiKeys:w}:{}:f.length>0?{apiKey:f}:{}};await i(oe)};return e.jsx(Ve,{open:r,onOpenChange:n,children:e.jsx(ze,{className:"overflow-hidden p-0 sm:max-w-3xl",children:e.jsxs("div",{className:"max-h-[85vh] overflow-y-auto",children:[e.jsx("div",{className:"border-b bg-muted/20 px-6 py-5",children:e.jsxs(Je,{className:"gap-4 text-left",children:[e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-xl border bg-background",children:e.jsx(pe,{provider:xe(s),size:"md"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(_e,{children:x?`Edit ${a.familyName}`:`Set up ${a.familyName}`}),e.jsx(p,{variant:"outline",className:"uppercase text-[11px]",children:g?"connector":"api-key"})]}),e.jsx(Qe,{className:"mt-1 max-w-2xl leading-6",children:a.description})]})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsx(Pe,{title:"Required now",items:a.requiredNow,icon:e.jsx(ge,{className:"h-4 w-4 text-primary"})}),e.jsx(Pe,{title:"Optional later",items:a.optionalLater,icon:e.jsx(te,{className:"h-4 w-4 text-primary"})})]}),D?e.jsx("div",{className:"rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs leading-5 text-amber-800",children:D}):null]})}),e.jsxs("div",{className:"space-y-6 px-6 py-6",children:[e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold",children:h("aiProvidersEntryDialog.requiredSetup")}),e.jsx("div",{className:"mt-1 text-sm text-muted-foreground",children:"Save the smallest working configuration first."})]}),g?e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(L,{htmlFor:"connector-name",children:h("aiProvidersEntryDialog.connectorName")}),e.jsx(A,{id:"connector-name",value:O,onChange:f=>S(f.target.value),placeholder:a.connectorPlaceholder}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a.connectorHelper})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(L,{htmlFor:"base-url",children:"Base URL"}),e.jsx(A,{id:"base-url",value:k,onChange:f=>M(f.target.value),placeholder:a.baseUrlPlaceholder}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a.baseUrlHelper})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(L,{children:"API Keys"}),e.jsx(Z,{value:j,onChange:m,rows:4,placeholder:`${a.keyPlaceholder}
|
|
6
|
+
${a.keyPlaceholder}`}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a.keyHelper})]})]}):e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(L,{htmlFor:"api-key",children:a.keyLabel}),e.jsx(A,{id:"api-key",type:"password",value:b,onChange:f=>T(f.target.value),placeholder:a.keyPlaceholder}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a.keyHelper})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold",children:h("aiProvidersEntryDialog.optionalRouting")}),e.jsx("div",{className:"mt-1 text-sm text-muted-foreground",children:"Only fill these when the route needs more than the default behavior."})]}),g?null:e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(L,{htmlFor:"base-url",children:"Base URL"}),e.jsx(A,{id:"base-url",value:k,onChange:f=>M(f.target.value),placeholder:a.baseUrlPlaceholder}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a.baseUrlHelper})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(L,{children:"Model Mappings"}),e.jsx(Z,{value:q,onChange:v,rows:4,placeholder:a.aliasesPlaceholder}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a.aliasesHelper}),I.length>0?e.jsx("p",{className:"text-xs text-destructive",children:I[0]}):null]})]}),e.jsx(We,{open:P,onOpenChange:_,children:e.jsxs("div",{className:"rounded-xl border",children:[e.jsx(Xe,{asChild:!0,children:e.jsxs("button",{type:"button",className:"flex w-full items-center justify-between gap-4 px-4 py-4 text-left",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(te,{className:"h-4 w-4 text-primary"}),"Advanced routing"]}),e.jsxs("div",{className:"mt-1 text-sm text-muted-foreground",children:["Headers",C?", proxy, prefix, and exclusions.":" and provider-specific overrides."]})]}),e.jsx(ns,{className:B("h-4 w-4 text-muted-foreground transition-transform",P&&"rotate-180")})]})}),e.jsx(Ye,{className:"border-t px-4 py-4",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(L,{children:"Headers"}),e.jsx(Z,{value:N,onChange:H,rows:3,placeholder:a.headersPlaceholder}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Use headers only when the provider requires extra routing or auth context."})]}),C?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(L,{htmlFor:"prefix",children:"Prefix"}),e.jsx(A,{id:"prefix",value:R,onChange:f=>J(f.target.value),placeholder:"glm-"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. Prepends model names before routing."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(L,{htmlFor:"proxy-url",children:"Proxy URL"}),e.jsx(A,{id:"proxy-url",value:U,onChange:f=>K(f.target.value),placeholder:"http://127.0.0.1:8080"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. Sends requests through an intermediate proxy."})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(L,{children:"Excluded Models"}),e.jsx(Z,{value:$,onChange:F,rows:3,placeholder:"claude-opus-4-1\\nclaude-sonnet-4-5"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. One model ID per line when this route should reject specific upstream models."})]})]}):null]})})]})})]}),e.jsxs(Ze,{className:"border-t bg-muted/10 px-6 py-4",children:[e.jsx(y,{type:"button",variant:"outline",onClick:()=>n(!1),children:"Cancel"}),e.jsx(y,{type:"button",onClick:()=>void l(),disabled:d||I.length>0,children:d?"Saving...":g?x?"Save Connector":"Create Connector":"Save Entry"})]})]})})})}const ie=["cliproxy-ai-providers"];function ws(){return ps({queryKey:ie,queryFn:()=>ne.cliproxy.aiProviders.list()})}function Cs(){const s=fe();return ve({mutationFn:({family:t,data:r})=>ne.cliproxy.aiProviders.create(t,r),onSuccess:()=>{s.invalidateQueries({queryKey:ie}),G.success("Provider entry created")},onError:t=>{G.error(t.message)}})}function ks(){const s=fe();return ve({mutationFn:({family:t,entryId:r,data:n})=>ne.cliproxy.aiProviders.update(t,r,n),onSuccess:()=>{s.invalidateQueries({queryKey:ie}),G.success("Provider entry updated")},onError:t=>{G.error(t.message)}})}function Ps(){const s=fe();return ve({mutationFn:({family:t,entryId:r})=>ne.cliproxy.aiProviders.delete(t,r),onSuccess:()=>{s.invalidateQueries({queryKey:ie}),G.success("Provider entry removed")},onError:t=>{G.error(t.message)}})}function Q({label:s,value:t,hint:r}){return e.jsxs("div",{className:"rounded-lg border bg-background p-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:s}),e.jsx("div",{className:"mt-1 break-all text-sm font-medium leading-5",children:t}),r?e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:r}):null]})}function As(s){switch(s){case"ready":return{label:"Ready",className:"bg-emerald-50 text-emerald-700 hover:bg-emerald-50"};case"partial":return{label:"Needs attention",className:"bg-amber-50 text-amber-700 hover:bg-amber-50"};default:return{label:"Empty",className:"bg-muted text-muted-foreground hover:bg-muted"}}}function me(s){return s.proxyUrl?"Proxy override":s.prefix?"Prefixed route":s.baseUrl?"Direct upstream":"Default runtime"}function $e(s){return s.filter(t=>t.alias.trim().length>0).length}function De(s){return s.filter(t=>t.name.trim().length>0&&t.alias.trim().length===0).length}function re(s){const t=$e(s),r=De(s),n=[];return t>0&&n.push(`${t} mapped`),r>0&&n.push(`${r} direct`),n.length>0?n.join(" + "):"No model rules"}function ue({configured:s}){return e.jsx(p,{variant:"secondary",className:B("border-transparent text-[10px]",s?"bg-emerald-50 text-emerald-700 hover:bg-emerald-50":"bg-muted text-muted-foreground hover:bg-muted"),children:s?"Configured":"Missing secret"})}const V="<stored in CLIProxy>";function Be(s){switch(s.id){case"gemini-api-key":return{requiredNow:["Save the Gemini API key.","Leave Base URL blank unless you use a custom Gemini gateway.","Add model mappings only when Gemini model names differ from the requested ones."],optionalLater:["Headers for provider-specific project routing.","Base URL override for a proxy or regional endpoint.","Mappings such as claude-sonnet-4-5 -> gemini-2.5-pro."],emptyStateSummary:[`Requests to ${s.routePath} use CLIProxy-managed Gemini credentials.`,"The default upstream is enough for most Gemini setups.","Model mappings and headers are optional, not step one."],profileBoundary:"Use API Profiles when you want a CCS-native Anthropic-compatible profile instead of this CLIProxy-managed Gemini route.",editPrompts:[{label:"Base URL",hint:"Change it only for a custom Gemini gateway or regional endpoint."},{label:"Model mappings",hint:"Add them only when requested names and Gemini names differ."},{label:"Headers",hint:"Keep them empty unless the provider requires project or org routing."}]};case"codex-api-key":return{requiredNow:["Save the Codex or OpenAI API key.","Leave Base URL blank unless this route should hit a different OpenAI-style host.","Add mappings only when the upstream model name differs from what CCS requests."],optionalLater:["Base URL override for a gateway, proxy, or self-hosted endpoint.","Headers for org or project routing.","Mappings such as claude-sonnet-4-5 -> gpt-5."],emptyStateSummary:[`Requests to ${s.routePath} use CLIProxy-managed Codex credentials.`,"Most setups can keep the default upstream and skip extra routing.","Mappings are only needed when the upstream model naming does not match the requested one."],profileBoundary:"Use API Profiles when you want a CCS-native Anthropic-compatible profile rather than this CLIProxy-managed Codex route.",editPrompts:[{label:"Base URL",hint:"Change it only when Codex should resolve through another OpenAI-style endpoint."},{label:"Model mappings",hint:"Map requested model names to the exact upstream model ID only when needed."},{label:"Headers",hint:"Use headers sparingly for project routing or extra auth."}]};case"claude-api-key":return{requiredNow:["Save the Anthropic or compatible API key.","Leave Base URL blank unless this route should point at a custom Claude-compatible endpoint.","Add mappings only when the upstream model ID differs from the requested Claude model name."],optionalLater:["Prefix or proxy overrides for advanced route rewriting.","Excluded models when a route should block specific model IDs.","Headers for project-scoped routing."],emptyStateSummary:[`Requests to ${s.routePath} use a CLIProxy-managed Claude-compatible key.`,"Base URL, proxy, and prefix rewrites are advanced options, not the minimum setup.","Most users can start with a key only, then add mappings or filters if routing needs it."],profileBoundary:"Use API Profiles when you want a CCS-native Anthropic-compatible profile or preset instead of this CLIProxy-managed Claude route.",editPrompts:[{label:"Base URL",hint:"Change it only when Claude traffic should target another compatible endpoint."},{label:"Mappings",hint:"Add them only when the requested Claude model name should route to a different upstream ID."},{label:"Advanced routing",hint:"Proxy, prefix, headers, and exclusions are for edge cases. Leave them blank when unsure."}]};case"vertex-api-key":return{requiredNow:["Save the Vertex API key.","Leave Base URL blank unless a regional or gateway endpoint is required.","Add mappings only when the upstream model name differs from the requested name."],optionalLater:["Base URL override for a regional gateway.","Headers for provider-specific routing.","Mappings for translating requested names to Vertex model IDs."],emptyStateSummary:[`Requests to ${s.routePath} use CLIProxy-managed Vertex credentials.`,"Most setups start with the key only and keep the default endpoint.","Mappings and headers are optional follow-up steps."],profileBoundary:"Use API Profiles when you need a CCS-native Anthropic-compatible profile rather than this CLIProxy-managed Vertex route.",editPrompts:[{label:"Base URL",hint:"Use it only for a regional gateway or managed Vertex endpoint."},{label:"Model mappings",hint:"Add them only when the requested names need translating upstream."},{label:"Headers",hint:"Keep them empty unless the provider requires extra routing context."}]};case"openai-compatibility":return{requiredNow:["Name the connector, for example openrouter or together.","Set the connector Base URL.","Add at least one API key before saving."],optionalLater:["Headers for provider-specific auth or project routing.","Model mappings such as claude-sonnet-4-5 -> gpt-4.1.","Additional API keys for the same connector."],emptyStateSummary:[`Requests to ${s.routePath} resolve through a named OpenAI-compatible connector.`,"This flow needs a connector name, a Base URL, and one or more API keys.","Headers and mappings come after the connector is already working."],profileBoundary:"Use API Profiles when you want a CCS-native Anthropic-compatible profile, preset, or provider outside the CLIProxy connector flow.",editPrompts:[{label:"Connector identity",hint:"Keep the connector name and Base URL stable once clients depend on it."},{label:"Model mappings",hint:"Only add them when the connector expects a different upstream model ID."},{label:"Headers",hint:"Use them for provider-specific auth or project routing, not as a default."}]}}}function z(s){return s.split(`
|
|
7
7
|
`).map(t=>t.trim()).filter(t=>t.length>0)}function ae(s){return s.split(`
|
|
8
|
-
`).map(t=>t.trim()).filter(t=>t.length>0).map(t=>{const r=t.includes(":")?":":"=",[n,...i]=t.split(r);return{key:n.trim(),value:i.join(r).trim()}}).filter(t=>t.key.length>0)}function W(s){return
|
|
8
|
+
`).map(t=>t.trim()).filter(t=>t.length>0).map(t=>{const r=t.includes(":")?":":"=",[n,...i]=t.split(r);return{key:n.trim(),value:i.join(r).trim()}}).filter(t=>t.key.length>0)}function W(s){return Le(s)}function Ss(s){return(s?.headers||[]).map(t=>`${t.key}: ${t.value}`).join(`
|
|
9
9
|
`)}function Ms(s){return(s?.excludedModels||[]).join(`
|
|
10
|
-
`)}function Us(s){return he(s?.models)}function ce(s){return{name:s.name||"",baseUrl:s.baseUrl||"",proxyUrl:s.proxyUrl||"",prefix:s.prefix||"",headersText:Ss(s),excludedModelsText:Ms(s),modelAliasesText:Us(s),apiKey:"",apiKeysText:""}}function
|
|
10
|
+
`)}function Us(s){return he(s?.models)}function ce(s){return{name:s.name||"",baseUrl:s.baseUrl||"",proxyUrl:s.proxyUrl||"",prefix:s.prefix||"",headersText:Ss(s),excludedModelsText:Ms(s),modelAliasesText:Us(s),apiKey:"",apiKeysText:""}}function Is(s){const t=ae(s);if(t.length!==0)return Object.fromEntries(t.map(r=>[r.key,r.value]))}function Ls(s){const t=W(s).map(r=>r.alias.trim()?{name:r.name,alias:r.alias}:{name:r.name});return t.length>0?t:void 0}function Ae(s){return Array.isArray(s)?he(s):""}function Rs(s){const t=z(s);return t.length>0?t:void 0}function Se(s,t,r){const n=Is(r.headersText),i=Ls(r.modelAliasesText),d=Rs(r.excludedModelsText),h=r.apiKey.trim()||(t.secretConfigured?V:"");if(s.id==="openai-compatibility"){const a=z(r.apiKeysText),x=t.apiKeysMasked?.length||1;return{name:r.name.trim()||t.name||"connector","base-url":r.baseUrl.trim(),...n?{headers:n}:{},"api-key-entries":a.length>0?a.map(g=>({"api-key":g})):t.secretConfigured?Array.from({length:x},()=>({"api-key":V})):[],...i?{models:i}:{}}}return{"api-key":h,...r.baseUrl.trim()?{"base-url":r.baseUrl.trim()}:{},...r.proxyUrl.trim()?{"proxy-url":r.proxyUrl.trim()}:{},...r.prefix.trim()?{prefix:r.prefix.trim()}:{},...n?{headers:n}:{},...d?{"excluded-models":d}:{},...i?{models:i}:{}}}function Ts(s,t,r){const n=JSON.parse(r);if(!n||typeof n!="object"||Array.isArray(n))throw new Error("Raw config must be a JSON object.");if(s.id==="openai-compatibility"){const d=n,a=(Array.isArray(d["api-key-entries"])?d["api-key-entries"]:[]).map(x=>typeof x=="string"?x:x&&typeof x=="object"&&typeof x["api-key"]=="string"?x["api-key"]:"").filter(x=>x&&x!==V);return{name:typeof d.name=="string"?d.name:t.name||"",baseUrl:typeof d["base-url"]=="string"?d["base-url"]:"",proxyUrl:"",prefix:"",headersText:d.headers&&typeof d.headers=="object"&&!Array.isArray(d.headers)?Object.entries(d.headers).map(([x,g])=>`${x}: ${g}`).join(`
|
|
11
11
|
`):"",excludedModelsText:"",modelAliasesText:Ae(d.models),apiKey:"",apiKeysText:a.join(`
|
|
12
12
|
`)}}const i=n;return{name:"",baseUrl:typeof i["base-url"]=="string"?i["base-url"]:"",proxyUrl:typeof i["proxy-url"]=="string"?i["proxy-url"]:"",prefix:typeof i.prefix=="string"?i.prefix:"",headersText:i.headers&&typeof i.headers=="object"&&!Array.isArray(i.headers)?Object.entries(i.headers).map(([d,h])=>`${d}: ${h}`).join(`
|
|
13
13
|
`):"",excludedModelsText:Array.isArray(i["excluded-models"])?i["excluded-models"].join(`
|
|
14
|
-
`):"",modelAliasesText:Ae(i.models),apiKey:typeof i["api-key"]=="string"&&i["api-key"]!==V?i["api-key"]:"",apiKeysText:""}}function Es(s,t,r){if(s.id==="openai-compatibility"){const d=z(r.apiKeysText),h=t.secretConfigured&&d.length===0;return{name:r.name.trim(),baseUrl:r.baseUrl.trim(),headers:ae(r.headersText),models:W(r.modelAliasesText),preserveSecrets:h,...d.length>0?{apiKeys:d}:{}}}const n=r.apiKey.trim(),i=t.secretConfigured&&n.length===0;return{baseUrl:r.baseUrl.trim(),proxyUrl:r.proxyUrl.trim(),prefix:r.prefix.trim(),headers:ae(r.headersText),excludedModels:z(r.excludedModelsText),models:W(r.modelAliasesText),preserveSecrets:i,...n.length>0?{apiKey:n}:{}}}function qs(s,t,r){const n={ANTHROPIC_BASE_URL:`${r.target}${s.routePath}`,ANTHROPIC_AUTH_TOKEN:"ccs-internal-managed"},i=W(t.modelAliasesText).find(d=>d.name.trim());return i?.name&&(n.ANTHROPIC_MODEL=ss(i)),{env:n}}function Me({badge:s,title:t,items:r}){return e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(p,{variant:"secondary",className:"text-[11px]",children:s}),e.jsx("div",{className:"text-sm font-medium",children:t})]}),e.jsx("div",{className:"mt-4 space-y-3",children:r.map((n,i)=>e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border bg-muted/10 px-3 py-3",children:[e.jsx("div",{className:"mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full border bg-background text-[11px] font-semibold text-muted-foreground",children:i+1}),e.jsx("div",{className:"text-sm leading-6 text-muted-foreground",children:n})]},`${t}:${n}`))})]})}function E({label:s,helper:t,children:r}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:s}),r,t?e.jsx("div",{className:"text-xs leading-5 text-muted-foreground",children:t}):null]})}function ee({value:s,onChange:t,placeholder:r,rows:n=4}){return e.jsx("textarea",{rows:n,value:s,onChange:i=>t(i.target.value),placeholder:r,className:"flex min-h-24 w-full rounded-md border border-input bg-background px-3 py-2 text-sm shadow-xs outline-none transition-[color,box-shadow] placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50"})}function Os({family:s,entry:t,source:r,isSaving:n,onSave:i,onDelete:d}){const h=Be(s),[a,x]=o.useState(()=>ce(t)),[g,C]=o.useState(null),[O,S]=o.useState(!0),[k,M]=o.useState(null),[U,K]=o.useState("config"),[R,J]=o.useState("raw"),b=o.useMemo(()=>JSON.stringify(Se(s,t,ce(t)),null,2),[t,s]),T=o.useMemo(()=>JSON.stringify(Se(s,t,a),null,2),[a,t,s]),j=g??T,m=o.useMemo(()=>qs(s,a,r),[a,s,r]),N=o.useMemo(()=>W(a.modelAliasesText),[a.modelAliasesText]),H=o.useMemo(()=>Le(a.modelAliasesText),[a.modelAliasesText]),$=o.useMemo(()=>ae(a.headersText),[a.headersText]),F=o.useMemo(()=>z(a.excludedModelsText),[a.excludedModelsText]),q=o.useMemo(()=>JSON.stringify(m,null,2),[m]),v=$e(N),L=De(N),P=$.length+F.length+(a.proxyUrl.trim()?1:0)+(a.prefix.trim()?1:0),_=s.id==="openai-compatibility"?a.headersText.trim().length>0:!!(a.proxyUrl.trim()||a.prefix.trim()||a.headersText.trim()||a.excludedModelsText.trim()),D=g!==null?g!==b:T!==b,l=o.useMemo(()=>{if(s.id==="openai-compatibility"){const c=[];return a.name.trim()||c.push("name"),a.baseUrl.trim()||c.push("base-url"),!t.secretConfigured&&z(a.apiKeysText).length===0&&c.push("api-key-entries"),c}return!t.secretConfigured&&!a.apiKey.trim()?["api-key"]:[]},[a.apiKey,a.apiKeysText,a.baseUrl,a.name,t.secretConfigured,s.id]),f=O&&l.length===0&&H.length===0&&D,w=c=>{x(u=>c(u)),C(null),S(!0),M(null)},le=c=>{C(c);try{const u=Ts(s,t,c);x(u),S(!0),M(null)}catch(u){S(!1),M(u instanceof Error?u.message:"Invalid JSON")}},oe=()=>{x(ce(t)),C(null),S(!0),M(null)},ye=c=>{w(u=>c==="minimal"?s.id==="openai-compatibility"?{...u,headersText:"",modelAliasesText:""}:{...u,baseUrl:"",proxyUrl:"",prefix:"",headersText:"",excludedModelsText:"",modelAliasesText:""}:{...u,proxyUrl:"",prefix:"",headersText:"",excludedModelsText:s.id==="openai-compatibility"?u.excludedModelsText:""})};return e.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-[minmax(360px,0.44fr)_minmax(0,0.56fr)] divide-x overflow-hidden rounded-b-xl border-x border-b bg-card",children:[e.jsx("div",{className:"min-h-0 overflow-hidden bg-muted/5",children:e.jsxs(je,{value:U,onValueChange:K,className:"flex h-full flex-col",children:[e.jsxs("div",{className:"border-b bg-background px-4 pt-4",children:[e.jsxs("div",{className:"mb-3 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("h3",{className:"truncate text-lg font-semibold",children:t.label}),e.jsx(ue,{configured:t.secretConfigured}),e.jsx(p,{variant:"outline",className:"uppercase",children:s.authMode})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(p,{variant:"outline",className:"font-mono text-[11px]",children:s.routePath}),e.jsx(p,{variant:"outline",className:"text-[11px]",children:me(t)}),e.jsx(p,{variant:"outline",className:"text-[11px]",children:r.label})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(y,{type:"button",size:"sm",variant:"outline",onClick:oe,disabled:!D,children:[e.jsx(os,{className:"mr-1 h-3.5 w-3.5"}),"Reset"]}),e.jsxs(y,{type:"button",size:"sm",variant:"outline",onClick:d,children:[e.jsx(ds,{className:"mr-1 h-3.5 w-3.5"}),"Remove"]}),e.jsxs(y,{type:"button",size:"sm",onClick:()=>void i(Es(s,t,a)),disabled:!f||n,children:[e.jsx(cs,{className:"mr-1 h-3.5 w-3.5"}),n?"Saving...":"Save"]})]})]}),e.jsxs(Ne,{className:"grid w-full grid-cols-2",children:[e.jsxs(X,{value:"config",className:"gap-2 text-xs",children:[e.jsx(te,{className:"h-3.5 w-3.5"}),"Config"]}),e.jsxs(X,{value:"usage",className:"gap-2 text-xs",children:[e.jsx(Ce,{className:"h-3.5 w-3.5"}),"Info & Usage"]})]})]}),e.jsx(Y,{value:"config",className:"mt-0 min-h-0 flex-1 overflow-hidden data-[state=inactive]:hidden",children:e.jsx(se,{className:"h-full",children:e.jsxs("div",{className:"space-y-6 p-5",children:[e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm font-medium",children:"Workspace presets"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Keep the route lean by default, then layer routing only when this entry actually needs it."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(y,{type:"button",size:"sm",variant:"outline",onClick:()=>ye("minimal"),children:"Minimal setup"}),e.jsx(y,{type:"button",size:"sm",variant:"outline",onClick:()=>ye("clean-routing"),children:"Clear routing noise"})]})]}),e.jsxs("div",{className:"mt-4 grid gap-3 2xl:grid-cols-3",children:[e.jsx(Q,{label:"Secret",value:t.secretConfigured?"Stored in CLIProxy":"Missing",hint:t.secretConfigured?"Rotate only when needed":"Required to save"}),e.jsx(Q,{label:"Model Rules",value:N.length>0?re(N):"No model rules",hint:"Requested model names stay direct unless remapped"}),e.jsx(Q,{label:"Advanced",value:P>0?`${P} active`:"Optional",hint:"Proxy, prefix, headers, and exclusions"})]})]}),l.length>0?e.jsxs("div",{className:"rounded-xl border border-amber-200 bg-amber-50/80 p-4 text-sm text-amber-900",children:["Missing required fields:"," ",e.jsx("span",{className:"font-mono",children:l.join(", ")})]}):null,e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"mb-4 flex items-center gap-2 text-sm font-medium",children:[e.jsx(ge,{className:"h-4 w-4 text-primary"}),"Connection"]}),e.jsxs("div",{className:"grid gap-4 2xl:grid-cols-2",children:[s.id==="openai-compatibility"?e.jsx(E,{label:"Connector Name",helper:"This is the saved connector label shown in the entry switcher.",children:e.jsx(A,{value:a.name,onChange:c=>w(u=>({...u,name:c.target.value})),placeholder:"openrouter"})}):e.jsx(E,{label:`${s.displayName} API Key`,helper:t.secretConfigured?"Leave blank to keep the stored secret. Enter a new value only to rotate it.":"Required before this route can authenticate.",children:e.jsx(A,{type:"password",value:a.apiKey,onChange:c=>w(u=>({...u,apiKey:c.target.value})),placeholder:t.secretConfigured?t.apiKeyMasked||V:"Paste provider API key"})}),s.id==="openai-compatibility"?e.jsx(E,{label:"API Keys",helper:t.secretConfigured?"One key per line. Leave empty to preserve the stored connector keys.":"Add one key per line. A connector needs at least one key.",children:e.jsx(ee,{value:a.apiKeysText,onChange:c=>w(u=>({...u,apiKeysText:c})),placeholder:"sk-...",rows:4})}):null,e.jsx(E,{label:"Base URL",helper:s.id==="openai-compatibility"?"Required for connectors. This is the upstream OpenAI-style endpoint.":"Leave blank unless this route should target another upstream host.",children:e.jsx(A,{value:a.baseUrl,onChange:c=>w(u=>({...u,baseUrl:c.target.value})),placeholder:s.id==="codex-api-key"?"https://api.openai.com/v1":s.id==="claude-api-key"?"https://api.anthropic.com":s.id==="openai-compatibility"?"https://openrouter.ai/api/v1":"https://provider.example.com"})}),s.id!=="openai-compatibility"?e.jsx(E,{label:"Proxy URL",helper:"Optional intermediary endpoint. Leave blank for direct routing.",children:e.jsx(A,{value:a.proxyUrl,onChange:c=>w(u=>({...u,proxyUrl:c.target.value})),placeholder:"https://proxy.example.com/v1"})}):null,s.id!=="openai-compatibility"?e.jsx(E,{label:"Prefix",helper:"Optional model prefix rewrite for advanced routing only.",children:e.jsx(A,{value:a.prefix,onChange:c=>w(u=>({...u,prefix:c.target.value})),placeholder:"provider/"})}):null]})]}),e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(Oe,{className:"h-4 w-4 text-primary"}),"Model rules"]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[v>0?e.jsxs(p,{variant:"outline",children:[v," mapped"]}):null,L>0?e.jsxs(p,{variant:"outline",children:[L," direct"]}):null,N.length===0?e.jsx(p,{variant:"outline",children:"Optional"}):null]})]}),e.jsx(E,{label:"Requested [= Upstream]",helper:"Use requested=upstream for remaps. Use a plain model name when you want the route to expose that model directly.",children:e.jsx(ee,{value:a.modelAliasesText,onChange:c=>w(u=>({...u,modelAliasesText:c})),placeholder:`claude-sonnet-4-5=gpt-5
|
|
15
|
-
glm-5`,rows:6})}),H.length>0?e.jsx("div",{className:"mt-3 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:H[0]}):null]}),e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(te,{className:"h-4 w-4 text-primary"}),"Advanced routing"]}),e.jsx(p,{variant:"outline",children:_?`${P} active`:"Optional"})]}),e.jsxs("div",{className:"grid gap-4 2xl:grid-cols-2",children:[e.jsx(E,{label:"Headers",helper:"One header per line. Use only when the upstream expects org, project, or secondary auth headers.",children:e.jsx(ee,{value:a.headersText,onChange:c=>w(u=>({...u,headersText:c})),placeholder:"OpenAI-Organization: org_...",rows:5})}),s.id!=="openai-compatibility"?e.jsx(E,{label:"Excluded Models",helper:"One model ID per line. These models will be blocked for this entry.",children:e.jsx(ee,{value:a.excludedModelsText,onChange:c=>w(u=>({...u,excludedModelsText:c})),placeholder:"claude-opus-4-1",rows:5})}):e.jsx("div",{className:"rounded-xl border border-dashed bg-muted/10 p-4 text-sm text-muted-foreground",children:"OpenAI-compatible connectors keep advanced routing lean. Add headers or model mappings first before introducing extra route layers elsewhere."})]})]})]})})}),e.jsx(Y,{value:"usage",className:"mt-0 min-h-0 flex-1 overflow-hidden data-[state=inactive]:hidden",children:e.jsx(se,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 p-5",children:[e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(Ke,{className:"h-4 w-4 text-primary"}),"How this route behaves"]}),e.jsxs("div",{className:"mt-3 space-y-3 text-sm leading-6 text-muted-foreground",children:[e.jsxs("div",{className:"rounded-lg border bg-muted/10 p-4",children:["Calls to ",e.jsx("span",{className:"font-mono",children:s.routePath})," use this saved entry inside CLIProxy."]}),e.jsx("div",{className:"rounded-lg border bg-muted/10 p-4",children:a.baseUrl.trim()?`Traffic resolves to ${a.baseUrl.trim()} unless you layer another proxy in front.`:"Traffic keeps the family default upstream unless you add a custom base URL."}),e.jsx("div",{className:"rounded-lg border bg-muted/10 p-4",children:N.length>0?`${re(N)} rule${N.length===1?"":"s"} active for this entry.`:"Requested model names pass through unchanged until you add explicit model rules."})]})]}),e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(Ce,{className:"h-4 w-4 text-primary"}),"When API Profiles fits better"]}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-muted-foreground",children:h.profileBoundary})]}),e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(He,{className:"h-4 w-4 text-primary"}),"Editing rule of thumb"]}),e.jsx("div",{className:"mt-3 space-y-3",children:h.editPrompts.map(c=>e.jsxs("div",{className:"rounded-lg border bg-muted/10 p-4",children:[e.jsx("div",{className:"text-sm font-medium",children:c.label}),e.jsx("div",{className:"mt-1 text-sm leading-6 text-muted-foreground",children:c.hint})]},c.label))})]})]})})})]})}),e.jsx("div",{className:"min-h-0 overflow-hidden",children:e.jsxs(je,{value:R,onValueChange:J,className:"flex h-full flex-col",children:[e.jsxs("div",{className:"border-b bg-background px-4 pt-4",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between gap-3",children:[e.jsx("div",{className:"text-sm font-medium",children:"Raw configuration"}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Target ",e.jsx("span",{className:"font-mono",children:r.target})]})]}),e.jsxs(Ne,{className:"grid w-full grid-cols-2",children:[e.jsxs(X,{value:"raw",className:"gap-2 text-xs",children:[e.jsx(ms,{className:"h-3.5 w-3.5"}),"Raw Entry Config"]}),e.jsxs(X,{value:"preview",className:"gap-2 text-xs",children:[e.jsx(us,{className:"h-3.5 w-3.5"}),"settings.json Preview"]})]})]}),e.jsx(Y,{value:"raw",className:"mt-0 min-h-0 flex-1 overflow-hidden data-[state=inactive]:hidden",children:e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsx("div",{className:"border-b bg-muted/10 px-6 py-3 text-sm text-muted-foreground",children:t.secretConfigured?`Stored secrets are shown as ${V}. Replace the placeholder only when you want to rotate the secret.`:"Add secrets directly in the JSON or use the form on the left."}),k?e.jsx("div",{className:"mx-6 mt-4 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:k}):null,e.jsx("div",{className:"min-h-0 flex-1 px-6 pb-4 pt-4",children:e.jsx("div",{className:"h-full overflow-hidden rounded-md border bg-background",children:e.jsx(we,{value:j,onChange:le,language:"json",minHeight:"100%",heightMode:"fill-parent"})})})]})}),e.jsx(Y,{value:"preview",className:"mt-0 min-h-0 flex-1 overflow-hidden data-[state=inactive]:hidden",children:e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsx("div",{className:"border-b bg-muted/10 px-6 py-3 text-sm text-muted-foreground",children:"Derived preview for a CCS profile that points to this CLIProxy route. The route stays local; the upstream key remains managed here."}),e.jsx("div",{className:"min-h-0 flex-1 px-6 pb-4 pt-4",children:e.jsx("div",{className:"h-full overflow-hidden rounded-md border bg-background",children:e.jsx(we,{value:q,onChange:()=>{},language:"json",readonly:!0,minHeight:"100%",heightMode:"fill-parent"})})}),e.jsx("div",{className:"mx-6 mb-4 overflow-hidden rounded-md border",children:e.jsx(es,{profileEnv:m.env})})]})})]})})]})}function Ks({family:s,onAddEntry:t,onOpenControlPanel:r,onOpenProfiles:n}){const i=Be(s),d=s.supportsNamedEntries?"Create connector":`Add ${s.displayName} entry`;return e.jsx("div",{className:"space-y-5",children:e.jsxs("div",{className:"grid gap-5 2xl:grid-cols-[minmax(0,1fr)_320px]",children:[e.jsxs("div",{className:"rounded-xl border bg-card",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4 border-b px-5 py-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg bg-muted",children:e.jsx(ge,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsxs("h3",{className:"text-lg font-semibold",children:["Set up ",s.displayName]}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Start with the smallest working setup. Add routing rules only after the route is already working."})]})]}),e.jsxs(y,{type:"button",onClick:t,children:[e.jsx(Ee,{className:"mr-1 h-4 w-4"}),d]})]}),e.jsxs("div",{className:"space-y-4 p-5",children:[e.jsxs("div",{className:"rounded-xl border bg-muted/10 p-4",children:[e.jsx("div",{className:"text-sm font-medium",children:"Recommended setup flow"}),e.jsx("div",{className:"mt-1 text-sm text-muted-foreground",children:"Finish the left section first. Treat the right section as optional follow-up."}),e.jsxs("div",{className:"mt-4 space-y-4",children:[e.jsx(Me,{badge:"Do this first",title:"Minimum working setup",items:i.requiredNow}),e.jsx(Me,{badge:"Only if needed",title:"Optional later",items:i.optionalLater})]})]}),e.jsxs("div",{className:"rounded-xl border bg-muted/15 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(He,{className:"h-4 w-4 text-emerald-600"}),"Need the other pages?"]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:"Use Overview or Control Panel for OAuth sign-ins. Use API Profiles only for CCS-native Anthropic-compatible profiles and presets."}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsx(y,{type:"button",size:"sm",variant:"outline",onClick:r,children:"Control Panel"}),e.jsxs(y,{type:"button",size:"sm",variant:"outline",onClick:n,children:["API Profiles",e.jsx(qe,{className:"ml-1 h-3.5 w-3.5"})]})]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-xl border bg-card p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(Ke,{className:"h-4 w-4 text-primary"}),"What this route does"]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(p,{variant:"outline",className:"font-mono text-[11px]",children:s.routePath}),e.jsx(p,{variant:"outline",className:"uppercase text-[11px]",children:s.authMode})]}),e.jsx("div",{className:"mt-4 space-y-3",children:i.emptyStateSummary.map(h=>e.jsx("div",{className:"rounded-lg border bg-muted/10 p-4 text-sm leading-6 text-muted-foreground",children:h},h))})]}),e.jsxs("div",{className:"rounded-xl border bg-card p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(Oe,{className:"h-4 w-4 text-primary"}),"When API Profiles is the better fit"]}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-muted-foreground",children:i.profileBoundary})]})]})]})})}function Xs(){const s=Fe(),t=Ge(),{t:r}=Ue(),{data:n,error:i,isLoading:d,isFetching:h,refetch:a}=ws(),x=Cs(),g=ks(),C=Ps(),[O,S]=o.useState(!1),[k,M]=o.useState(null),[U,K]=o.useState(null),[R,J]=o.useState(null),b=o.useMemo(()=>n?.families??[],[n?.families]),T=o.useMemo(()=>new URLSearchParams(s.search).get("family")||null,[s.search]),j=o.useMemo(()=>T&&b.some(l=>l.id===T)?T:b[0]?.id??"gemini-api-key",[b,T]),m=o.useMemo(()=>b.find(l=>l.id===j)||null,[b,j]),N=o.useMemo(()=>{const l=m?.entries??[];return l.length===0?null:R&&l.some(f=>f.id===R)?R:l[0]?.id??null},[R,m?.entries]),H=l=>{t({pathname:s.pathname,search:`?family=${l}`},{replace:!0})},$=()=>{M(null),S(!0)};if(d)return e.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden",children:[e.jsx(be,{className:"h-full w-80 rounded-none"}),e.jsx(be,{className:"h-full flex-1 rounded-none"})]});if(i||!n||!m){const l=i instanceof Error?i.message:"Failed to load CLIProxy AI providers. Check the local server and try again.";return e.jsx("div",{className:"flex h-full min-h-0 items-center justify-center bg-muted/10 p-6",children:e.jsx("div",{className:"w-full max-w-2xl rounded-xl border bg-card p-6 shadow-sm",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex h-11 w-11 items-center justify-center rounded-lg bg-destructive/10",children:e.jsx(Re,{className:"h-5 w-5 text-destructive"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-lg font-semibold",children:r("aiProvidersPage.unableToLoad")}),e.jsx("div",{className:"mt-2 text-sm text-muted-foreground",children:l}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsxs(y,{type:"button",onClick:()=>void a(),children:[e.jsx(de,{className:"mr-2 h-4 w-4"}),"Retry"]}),e.jsx(y,{type:"button",variant:"outline",onClick:()=>t("/cliproxy/control-panel"),children:"Control Panel"}),e.jsx(y,{type:"button",variant:"outline",onClick:()=>t("/providers"),children:"API Profiles"})]})]})]})})})}const F=m.entries.filter(l=>l.secretConfigured),q=b.filter(l=>l.status==="ready").length,v=m.entries.find(l=>l.id===N)??null,L=m.entries.length>1,P=As(m.status),_=m.entries.length>0,D=e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:"Setup status"}),e.jsx("div",{className:"mt-1 text-sm font-medium",children:m.routePath})]}),e.jsx(p,{variant:"secondary",className:P.className,children:P.label})]}),e.jsxs("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:[e.jsx(Q,{label:"Entries",value:`${m.entries.length}`,hint:"configured rows"}),e.jsx(Q,{label:"Secrets",value:`${F.length}/${m.entries.length||0}`,hint:"stored in CLIProxy"})]}),e.jsx("div",{className:"mt-3 rounded-lg border bg-muted/15 p-3 text-xs leading-5 text-muted-foreground",children:"Overview handles OAuth sign-ins. This page stores CLIProxy-managed keys and connectors. API Profiles remains for CCS-native Anthropic-compatible profiles."})]});return e.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"flex w-80 flex-col border-r bg-muted/30",children:[e.jsxs("div",{className:"border-b bg-background p-4",children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(is,{className:"h-5 w-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:"CLIProxy Plus"})]}),e.jsx(y,{variant:"ghost",size:"icon",className:"h-8 w-8",type:"button",onClick:()=>void a(),disabled:h,children:e.jsx(de,{className:B("h-4 w-4",h&&"animate-spin")})})]}),e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"AI Providers"}),e.jsxs(y,{variant:"default",size:"sm",className:"w-full gap-2",type:"button",onClick:$,children:[e.jsx(Ee,{className:"h-4 w-4"}),m.supportsNamedEntries?"Create Connector":`Add ${m.displayName} Entry`]})]}),e.jsx(se,{className:"flex-1",children:e.jsxs("div",{className:"p-2",children:[e.jsx("div",{className:"px-3 py-2 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Provider Families"}),e.jsx(hs,{families:b,selectedFamily:j,onSelect:H})]})}),e.jsx("div",{className:"border-t p-3",children:e.jsx(ts,{})}),e.jsx("div",{className:"border-t bg-background p-3 text-xs text-muted-foreground",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{children:[b.length," families"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Te,{className:"h-3 w-3 text-emerald-600"}),q," ready"]})]})})]}),e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col bg-background",children:[e.jsx("div",{className:"shrink-0 border-b bg-background px-6 py-4",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(pe,{provider:xe(m.id),size:"lg"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:m.displayName}),e.jsx(p,{variant:"secondary",className:P.className,children:P.label}),e.jsx(p,{variant:"outline",className:"uppercase",children:m.authMode}),e.jsx(p,{variant:"outline",className:"font-mono text-[11px]",children:m.routePath})]}),e.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:m.description})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(y,{type:"button",variant:"ghost",size:"sm",onClick:()=>void a(),disabled:h,children:e.jsx(de,{className:B("h-4 w-4",h&&"animate-spin")})}),e.jsx(y,{type:"button",variant:"outline",onClick:()=>t("/cliproxy/control-panel"),children:"Control Panel"}),e.jsxs(y,{type:"button",variant:"outline",onClick:()=>t("/providers"),children:["API Profiles",e.jsx(qe,{className:"ml-1 h-3.5 w-3.5"})]})]})]})}),_?e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[e.jsxs("div",{className:"shrink-0 border-b bg-muted/5 px-6 py-4",children:[e.jsxs("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:[e.jsx(ls,{className:"h-3 w-3"}),L?"Saved entries":"Saved entry"]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(p,{variant:"outline",className:"text-[11px]",children:[m.entries.length," entries"]}),e.jsxs(p,{variant:"outline",className:"text-[11px]",children:[F.length,"/",m.entries.length," secrets stored"]})]})]}),L?e.jsx("div",{className:"flex flex-wrap gap-3",children:m.entries.map(l=>e.jsxs("button",{type:"button",onClick:()=>J(l.id),className:B("min-w-[220px] max-w-[280px] flex-1 rounded-xl border bg-background px-4 py-3 text-left transition-colors",l.id===N?"border-primary/30 bg-primary/5 shadow-sm":"border-border/60 hover:bg-muted/50"),children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:l.label}),e.jsx(ue,{configured:l.secretConfigured})]}),e.jsx("div",{className:"mt-2 truncate text-xs text-muted-foreground",children:l.baseUrl||m.routePath}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-1.5",children:[e.jsx(p,{variant:"outline",className:"text-[10px]",children:me(l)}),l.models.length>0?e.jsx(p,{variant:"outline",className:"text-[10px]",children:re(l.models)}):null,e.jsxs(p,{variant:"outline",className:"text-[10px]",children:[l.headers.length," hdr"]})]})]},l.id))}):v?e.jsx("div",{className:"rounded-xl border bg-background px-4 py-3",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:v.label}),e.jsx(ue,{configured:v.secretConfigured})]}),e.jsx("div",{className:"mt-1 truncate text-xs text-muted-foreground",children:v.baseUrl||m.routePath})]}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsx(p,{variant:"outline",className:"text-[10px]",children:me(v)}),v.models.length>0?e.jsx(p,{variant:"outline",className:"text-[10px]",children:re(v.models)}):null,e.jsxs(p,{variant:"outline",className:"text-[10px]",children:[v.headers.length," hdr"]})]})]})}):null]}),v?e.jsx(Os,{family:m,entry:v,source:n.source,isSaving:g.isPending,onSave:async l=>{await g.mutateAsync({family:j,entryId:v.id,data:l}),a()},onDelete:()=>K(v)},v.id):null]}):e.jsx(se,{className:"flex-1",children:e.jsxs("div",{className:"space-y-6 p-6",children:[D,e.jsx(Ks,{family:m,onAddEntry:$,onOpenControlPanel:()=>t("/cliproxy/control-panel"),onOpenProfiles:()=>t("/providers")})]})})]}),e.jsx(Ns,{family:j,entry:k,open:O,onOpenChange:S,onSubmit:async l=>{k?await g.mutateAsync({family:j,entryId:k.id,data:l}):await x.mutateAsync({family:j,data:l}),S(!1),M(null),a()},isSaving:x.isPending||g.isPending},`${j}:${k?.id??"new"}:${O?"open":"closed"}`),e.jsx(rs,{open:U!==null,title:"Remove provider entry?",description:U?`This removes ${U.label} from ${m.displayName}.`:"",confirmText:"Remove",variant:"destructive",onConfirm:async()=>{U&&(await C.mutateAsync({family:j,entryId:U.id}),K(null))},onCancel:()=>K(null)})]})}export{Xs as CliproxyAiProvidersPage};
|
|
14
|
+
`):"",modelAliasesText:Ae(i.models),apiKey:typeof i["api-key"]=="string"&&i["api-key"]!==V?i["api-key"]:"",apiKeysText:""}}function Es(s,t,r){if(s.id==="openai-compatibility"){const d=z(r.apiKeysText),h=t.secretConfigured&&d.length===0;return{name:r.name.trim(),baseUrl:r.baseUrl.trim(),headers:ae(r.headersText),models:W(r.modelAliasesText),preserveSecrets:h,...d.length>0?{apiKeys:d}:{}}}const n=r.apiKey.trim(),i=t.secretConfigured&&n.length===0;return{baseUrl:r.baseUrl.trim(),proxyUrl:r.proxyUrl.trim(),prefix:r.prefix.trim(),headers:ae(r.headersText),excludedModels:z(r.excludedModelsText),models:W(r.modelAliasesText),preserveSecrets:i,...n.length>0?{apiKey:n}:{}}}function qs(s,t,r){const n={ANTHROPIC_BASE_URL:`${r.target}${s.routePath}`,ANTHROPIC_AUTH_TOKEN:"ccs-internal-managed"},i=W(t.modelAliasesText).find(d=>d.name.trim());return i?.name&&(n.ANTHROPIC_MODEL=ss(i)),{env:n}}function Me({badge:s,title:t,items:r}){return e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(p,{variant:"secondary",className:"text-[11px]",children:s}),e.jsx("div",{className:"text-sm font-medium",children:t})]}),e.jsx("div",{className:"mt-4 space-y-3",children:r.map((n,i)=>e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border bg-muted/10 px-3 py-3",children:[e.jsx("div",{className:"mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full border bg-background text-[11px] font-semibold text-muted-foreground",children:i+1}),e.jsx("div",{className:"text-sm leading-6 text-muted-foreground",children:n})]},`${t}:${n}`))})]})}function E({label:s,helper:t,children:r}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:s}),r,t?e.jsx("div",{className:"text-xs leading-5 text-muted-foreground",children:t}):null]})}function ee({value:s,onChange:t,placeholder:r,rows:n=4}){return e.jsx("textarea",{rows:n,value:s,onChange:i=>t(i.target.value),placeholder:r,className:"flex min-h-24 w-full rounded-md border border-input bg-background px-3 py-2 text-sm shadow-xs outline-none transition-[color,box-shadow] placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50"})}function Os({family:s,entry:t,source:r,isSaving:n,onSave:i,onDelete:d}){const h=Be(s),[a,x]=o.useState(()=>ce(t)),[g,C]=o.useState(null),[O,S]=o.useState(!0),[k,M]=o.useState(null),[U,K]=o.useState("config"),[R,J]=o.useState("raw"),b=o.useMemo(()=>JSON.stringify(Se(s,t,ce(t)),null,2),[t,s]),T=o.useMemo(()=>JSON.stringify(Se(s,t,a),null,2),[a,t,s]),j=g??T,m=o.useMemo(()=>qs(s,a,r),[a,s,r]),N=o.useMemo(()=>W(a.modelAliasesText),[a.modelAliasesText]),H=o.useMemo(()=>Ie(a.modelAliasesText),[a.modelAliasesText]),$=o.useMemo(()=>ae(a.headersText),[a.headersText]),F=o.useMemo(()=>z(a.excludedModelsText),[a.excludedModelsText]),q=o.useMemo(()=>JSON.stringify(m,null,2),[m]),v=$e(N),I=De(N),P=$.length+F.length+(a.proxyUrl.trim()?1:0)+(a.prefix.trim()?1:0),_=s.id==="openai-compatibility"?a.headersText.trim().length>0:!!(a.proxyUrl.trim()||a.prefix.trim()||a.headersText.trim()||a.excludedModelsText.trim()),D=g!==null?g!==b:T!==b,l=o.useMemo(()=>{if(s.id==="openai-compatibility"){const c=[];return a.name.trim()||c.push("name"),a.baseUrl.trim()||c.push("base-url"),!t.secretConfigured&&z(a.apiKeysText).length===0&&c.push("api-key-entries"),c}return!t.secretConfigured&&!a.apiKey.trim()?["api-key"]:[]},[a.apiKey,a.apiKeysText,a.baseUrl,a.name,t.secretConfigured,s.id]),f=O&&l.length===0&&H.length===0&&D,w=c=>{x(u=>c(u)),C(null),S(!0),M(null)},le=c=>{C(c);try{const u=Ts(s,t,c);x(u),S(!0),M(null)}catch(u){S(!1),M(u instanceof Error?u.message:"Invalid JSON")}},oe=()=>{x(ce(t)),C(null),S(!0),M(null)},ye=c=>{w(u=>c==="minimal"?s.id==="openai-compatibility"?{...u,headersText:"",modelAliasesText:""}:{...u,baseUrl:"",proxyUrl:"",prefix:"",headersText:"",excludedModelsText:"",modelAliasesText:""}:{...u,proxyUrl:"",prefix:"",headersText:"",excludedModelsText:s.id==="openai-compatibility"?u.excludedModelsText:""})};return e.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-[minmax(360px,0.44fr)_minmax(0,0.56fr)] divide-x overflow-hidden rounded-b-xl border-x border-b bg-card",children:[e.jsx("div",{className:"min-h-0 overflow-hidden bg-muted/5",children:e.jsxs(je,{value:U,onValueChange:K,className:"flex h-full flex-col",children:[e.jsxs("div",{className:"border-b bg-background px-4 pt-4",children:[e.jsxs("div",{className:"mb-3 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("h3",{className:"truncate text-lg font-semibold",children:t.label}),e.jsx(ue,{configured:t.secretConfigured}),e.jsx(p,{variant:"outline",className:"uppercase",children:s.authMode})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(p,{variant:"outline",className:"font-mono text-[11px]",children:s.routePath}),e.jsx(p,{variant:"outline",className:"text-[11px]",children:me(t)}),e.jsx(p,{variant:"outline",className:"text-[11px]",children:r.label})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(y,{type:"button",size:"sm",variant:"outline",onClick:oe,disabled:!D,children:[e.jsx(os,{className:"mr-1 h-3.5 w-3.5"}),"Reset"]}),e.jsxs(y,{type:"button",size:"sm",variant:"outline",onClick:d,children:[e.jsx(ds,{className:"mr-1 h-3.5 w-3.5"}),"Remove"]}),e.jsxs(y,{type:"button",size:"sm",onClick:()=>void i(Es(s,t,a)),disabled:!f||n,children:[e.jsx(cs,{className:"mr-1 h-3.5 w-3.5"}),n?"Saving...":"Save"]})]})]}),e.jsxs(Ne,{className:"grid w-full grid-cols-2",children:[e.jsxs(X,{value:"config",className:"gap-2 text-xs",children:[e.jsx(te,{className:"h-3.5 w-3.5"}),"Config"]}),e.jsxs(X,{value:"usage",className:"gap-2 text-xs",children:[e.jsx(Ce,{className:"h-3.5 w-3.5"}),"Info & Usage"]})]})]}),e.jsx(Y,{value:"config",className:"mt-0 min-h-0 flex-1 overflow-hidden data-[state=inactive]:hidden",children:e.jsx(se,{className:"h-full",children:e.jsxs("div",{className:"space-y-6 p-5",children:[e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm font-medium",children:"Workspace presets"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Keep the route lean by default, then layer routing only when this entry actually needs it."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(y,{type:"button",size:"sm",variant:"outline",onClick:()=>ye("minimal"),children:"Minimal setup"}),e.jsx(y,{type:"button",size:"sm",variant:"outline",onClick:()=>ye("clean-routing"),children:"Clear routing noise"})]})]}),e.jsxs("div",{className:"mt-4 grid gap-3 2xl:grid-cols-3",children:[e.jsx(Q,{label:"Secret",value:t.secretConfigured?"Stored in CLIProxy":"Missing",hint:t.secretConfigured?"Rotate only when needed":"Required to save"}),e.jsx(Q,{label:"Model Rules",value:N.length>0?re(N):"No model rules",hint:"Requested model names stay direct unless remapped"}),e.jsx(Q,{label:"Advanced",value:P>0?`${P} active`:"Optional",hint:"Proxy, prefix, headers, and exclusions"})]})]}),l.length>0?e.jsxs("div",{className:"rounded-xl border border-amber-200 bg-amber-50/80 p-4 text-sm text-amber-900",children:["Missing required fields:"," ",e.jsx("span",{className:"font-mono",children:l.join(", ")})]}):null,e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"mb-4 flex items-center gap-2 text-sm font-medium",children:[e.jsx(ge,{className:"h-4 w-4 text-primary"}),"Connection"]}),e.jsxs("div",{className:"grid gap-4 2xl:grid-cols-2",children:[s.id==="openai-compatibility"?e.jsx(E,{label:"Connector Name",helper:"This is the saved connector label shown in the entry switcher.",children:e.jsx(A,{value:a.name,onChange:c=>w(u=>({...u,name:c.target.value})),placeholder:"openrouter"})}):e.jsx(E,{label:`${s.displayName} API Key`,helper:t.secretConfigured?"Leave blank to keep the stored secret. Enter a new value only to rotate it.":"Required before this route can authenticate.",children:e.jsx(A,{type:"password",value:a.apiKey,onChange:c=>w(u=>({...u,apiKey:c.target.value})),placeholder:t.secretConfigured?t.apiKeyMasked||V:"Paste provider API key"})}),s.id==="openai-compatibility"?e.jsx(E,{label:"API Keys",helper:t.secretConfigured?"One key per line. Leave empty to preserve the stored connector keys.":"Add one key per line. A connector needs at least one key.",children:e.jsx(ee,{value:a.apiKeysText,onChange:c=>w(u=>({...u,apiKeysText:c})),placeholder:"sk-...",rows:4})}):null,e.jsx(E,{label:"Base URL",helper:s.id==="openai-compatibility"?"Required for connectors. This is the upstream OpenAI-style endpoint.":"Leave blank unless this route should target another upstream host.",children:e.jsx(A,{value:a.baseUrl,onChange:c=>w(u=>({...u,baseUrl:c.target.value})),placeholder:s.id==="codex-api-key"?"https://api.openai.com/v1":s.id==="claude-api-key"?"https://api.anthropic.com":s.id==="openai-compatibility"?"https://openrouter.ai/api/v1":"https://provider.example.com"})}),s.id!=="openai-compatibility"?e.jsx(E,{label:"Proxy URL",helper:"Optional intermediary endpoint. Leave blank for direct routing.",children:e.jsx(A,{value:a.proxyUrl,onChange:c=>w(u=>({...u,proxyUrl:c.target.value})),placeholder:"https://proxy.example.com/v1"})}):null,s.id!=="openai-compatibility"?e.jsx(E,{label:"Prefix",helper:"Optional model prefix rewrite for advanced routing only.",children:e.jsx(A,{value:a.prefix,onChange:c=>w(u=>({...u,prefix:c.target.value})),placeholder:"provider/"})}):null]})]}),e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(Oe,{className:"h-4 w-4 text-primary"}),"Model rules"]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[v>0?e.jsxs(p,{variant:"outline",children:[v," mapped"]}):null,I>0?e.jsxs(p,{variant:"outline",children:[I," direct"]}):null,N.length===0?e.jsx(p,{variant:"outline",children:"Optional"}):null]})]}),e.jsx(E,{label:"Requested [= Upstream]",helper:"Use requested=upstream for remaps. Use a plain model name when you want the route to expose that model directly.",children:e.jsx(ee,{value:a.modelAliasesText,onChange:c=>w(u=>({...u,modelAliasesText:c})),placeholder:`claude-sonnet-4-5=gpt-5
|
|
15
|
+
glm-5`,rows:6})}),H.length>0?e.jsx("div",{className:"mt-3 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:H[0]}):null]}),e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(te,{className:"h-4 w-4 text-primary"}),"Advanced routing"]}),e.jsx(p,{variant:"outline",children:_?`${P} active`:"Optional"})]}),e.jsxs("div",{className:"grid gap-4 2xl:grid-cols-2",children:[e.jsx(E,{label:"Headers",helper:"One header per line. Use only when the upstream expects org, project, or secondary auth headers.",children:e.jsx(ee,{value:a.headersText,onChange:c=>w(u=>({...u,headersText:c})),placeholder:"OpenAI-Organization: org_...",rows:5})}),s.id!=="openai-compatibility"?e.jsx(E,{label:"Excluded Models",helper:"One model ID per line. These models will be blocked for this entry.",children:e.jsx(ee,{value:a.excludedModelsText,onChange:c=>w(u=>({...u,excludedModelsText:c})),placeholder:"claude-opus-4-1",rows:5})}):e.jsx("div",{className:"rounded-xl border border-dashed bg-muted/10 p-4 text-sm text-muted-foreground",children:"OpenAI-compatible connectors keep advanced routing lean. Add headers or model mappings first before introducing extra route layers elsewhere."})]})]})]})})}),e.jsx(Y,{value:"usage",className:"mt-0 min-h-0 flex-1 overflow-hidden data-[state=inactive]:hidden",children:e.jsx(se,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 p-5",children:[e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(Ke,{className:"h-4 w-4 text-primary"}),"How this route behaves"]}),e.jsxs("div",{className:"mt-3 space-y-3 text-sm leading-6 text-muted-foreground",children:[e.jsxs("div",{className:"rounded-lg border bg-muted/10 p-4",children:["Calls to ",e.jsx("span",{className:"font-mono",children:s.routePath})," use this saved entry inside CLIProxy."]}),e.jsx("div",{className:"rounded-lg border bg-muted/10 p-4",children:a.baseUrl.trim()?`Traffic resolves to ${a.baseUrl.trim()} unless you layer another proxy in front.`:"Traffic keeps the family default upstream unless you add a custom base URL."}),e.jsx("div",{className:"rounded-lg border bg-muted/10 p-4",children:N.length>0?`${re(N)} rule${N.length===1?"":"s"} active for this entry.`:"Requested model names pass through unchanged until you add explicit model rules."})]})]}),e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(Ce,{className:"h-4 w-4 text-primary"}),"When API Profiles fits better"]}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-muted-foreground",children:h.profileBoundary})]}),e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(He,{className:"h-4 w-4 text-primary"}),"Editing rule of thumb"]}),e.jsx("div",{className:"mt-3 space-y-3",children:h.editPrompts.map(c=>e.jsxs("div",{className:"rounded-lg border bg-muted/10 p-4",children:[e.jsx("div",{className:"text-sm font-medium",children:c.label}),e.jsx("div",{className:"mt-1 text-sm leading-6 text-muted-foreground",children:c.hint})]},c.label))})]})]})})})]})}),e.jsx("div",{className:"min-h-0 overflow-hidden",children:e.jsxs(je,{value:R,onValueChange:J,className:"flex h-full flex-col",children:[e.jsxs("div",{className:"border-b bg-background px-4 pt-4",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between gap-3",children:[e.jsx("div",{className:"text-sm font-medium",children:"Raw configuration"}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Target ",e.jsx("span",{className:"font-mono",children:r.target})]})]}),e.jsxs(Ne,{className:"grid w-full grid-cols-2",children:[e.jsxs(X,{value:"raw",className:"gap-2 text-xs",children:[e.jsx(ms,{className:"h-3.5 w-3.5"}),"Raw Entry Config"]}),e.jsxs(X,{value:"preview",className:"gap-2 text-xs",children:[e.jsx(us,{className:"h-3.5 w-3.5"}),"settings.json Preview"]})]})]}),e.jsx(Y,{value:"raw",className:"mt-0 min-h-0 flex-1 overflow-hidden data-[state=inactive]:hidden",children:e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsx("div",{className:"border-b bg-muted/10 px-6 py-3 text-sm text-muted-foreground",children:t.secretConfigured?`Stored secrets are shown as ${V}. Replace the placeholder only when you want to rotate the secret.`:"Add secrets directly in the JSON or use the form on the left."}),k?e.jsx("div",{className:"mx-6 mt-4 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:k}):null,e.jsx("div",{className:"min-h-0 flex-1 px-6 pb-4 pt-4",children:e.jsx("div",{className:"h-full overflow-hidden rounded-md border bg-background",children:e.jsx(we,{value:j,onChange:le,language:"json",minHeight:"100%",heightMode:"fill-parent"})})})]})}),e.jsx(Y,{value:"preview",className:"mt-0 min-h-0 flex-1 overflow-hidden data-[state=inactive]:hidden",children:e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsx("div",{className:"border-b bg-muted/10 px-6 py-3 text-sm text-muted-foreground",children:"Derived preview for a CCS profile that points to this CLIProxy route. The route stays local; the upstream key remains managed here."}),e.jsx("div",{className:"min-h-0 flex-1 px-6 pb-4 pt-4",children:e.jsx("div",{className:"h-full overflow-hidden rounded-md border bg-background",children:e.jsx(we,{value:q,onChange:()=>{},language:"json",readonly:!0,minHeight:"100%",heightMode:"fill-parent"})})}),e.jsx("div",{className:"mx-6 mb-4 overflow-hidden rounded-md border",children:e.jsx(es,{profileEnv:m.env})})]})})]})})]})}function Ks({family:s,onAddEntry:t,onOpenControlPanel:r,onOpenProfiles:n}){const i=Be(s),d=s.supportsNamedEntries?"Create connector":`Add ${s.displayName} entry`;return e.jsx("div",{className:"space-y-5",children:e.jsxs("div",{className:"grid gap-5 2xl:grid-cols-[minmax(0,1fr)_320px]",children:[e.jsxs("div",{className:"rounded-xl border bg-card",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4 border-b px-5 py-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg bg-muted",children:e.jsx(ge,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsxs("h3",{className:"text-lg font-semibold",children:["Set up ",s.displayName]}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Start with the smallest working setup. Add routing rules only after the route is already working."})]})]}),e.jsxs(y,{type:"button",onClick:t,children:[e.jsx(Ee,{className:"mr-1 h-4 w-4"}),d]})]}),e.jsxs("div",{className:"space-y-4 p-5",children:[e.jsxs("div",{className:"rounded-xl border bg-muted/10 p-4",children:[e.jsx("div",{className:"text-sm font-medium",children:"Recommended setup flow"}),e.jsx("div",{className:"mt-1 text-sm text-muted-foreground",children:"Finish the left section first. Treat the right section as optional follow-up."}),e.jsxs("div",{className:"mt-4 space-y-4",children:[e.jsx(Me,{badge:"Do this first",title:"Minimum working setup",items:i.requiredNow}),e.jsx(Me,{badge:"Only if needed",title:"Optional later",items:i.optionalLater})]})]}),e.jsxs("div",{className:"rounded-xl border bg-muted/15 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(He,{className:"h-4 w-4 text-emerald-600"}),"Need the other pages?"]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:"Use Overview or Control Panel for OAuth sign-ins. Use API Profiles only for CCS-native Anthropic-compatible profiles and presets."}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsx(y,{type:"button",size:"sm",variant:"outline",onClick:r,children:"Control Panel"}),e.jsxs(y,{type:"button",size:"sm",variant:"outline",onClick:n,children:["API Profiles",e.jsx(qe,{className:"ml-1 h-3.5 w-3.5"})]})]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-xl border bg-card p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(Ke,{className:"h-4 w-4 text-primary"}),"What this route does"]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(p,{variant:"outline",className:"font-mono text-[11px]",children:s.routePath}),e.jsx(p,{variant:"outline",className:"uppercase text-[11px]",children:s.authMode})]}),e.jsx("div",{className:"mt-4 space-y-3",children:i.emptyStateSummary.map(h=>e.jsx("div",{className:"rounded-lg border bg-muted/10 p-4 text-sm leading-6 text-muted-foreground",children:h},h))})]}),e.jsxs("div",{className:"rounded-xl border bg-card p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(Oe,{className:"h-4 w-4 text-primary"}),"When API Profiles is the better fit"]}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-muted-foreground",children:i.profileBoundary})]})]})]})})}function Xs(){const s=Fe(),t=Ge(),{t:r}=Ue(),{data:n,error:i,isLoading:d,isFetching:h,refetch:a}=ws(),x=Cs(),g=ks(),C=Ps(),[O,S]=o.useState(!1),[k,M]=o.useState(null),[U,K]=o.useState(null),[R,J]=o.useState(null),b=o.useMemo(()=>n?.families??[],[n?.families]),T=o.useMemo(()=>new URLSearchParams(s.search).get("family")||null,[s.search]),j=o.useMemo(()=>T&&b.some(l=>l.id===T)?T:b[0]?.id??"gemini-api-key",[b,T]),m=o.useMemo(()=>b.find(l=>l.id===j)||null,[b,j]),N=o.useMemo(()=>{const l=m?.entries??[];return l.length===0?null:R&&l.some(f=>f.id===R)?R:l[0]?.id??null},[R,m?.entries]),H=l=>{t({pathname:s.pathname,search:`?family=${l}`},{replace:!0})},$=()=>{M(null),S(!0)};if(d)return e.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden",children:[e.jsx(be,{className:"h-full w-80 rounded-none"}),e.jsx(be,{className:"h-full flex-1 rounded-none"})]});if(i||!n||!m){const l=i instanceof Error?i.message:"Failed to load CLIProxy AI providers. Check the local server and try again.";return e.jsx("div",{className:"flex h-full min-h-0 items-center justify-center bg-muted/10 p-6",children:e.jsx("div",{className:"w-full max-w-2xl rounded-xl border bg-card p-6 shadow-sm",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex h-11 w-11 items-center justify-center rounded-lg bg-destructive/10",children:e.jsx(Re,{className:"h-5 w-5 text-destructive"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-lg font-semibold",children:r("aiProvidersPage.unableToLoad")}),e.jsx("div",{className:"mt-2 text-sm text-muted-foreground",children:l}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsxs(y,{type:"button",onClick:()=>void a(),children:[e.jsx(de,{className:"mr-2 h-4 w-4"}),"Retry"]}),e.jsx(y,{type:"button",variant:"outline",onClick:()=>t("/cliproxy/control-panel"),children:"Control Panel"}),e.jsx(y,{type:"button",variant:"outline",onClick:()=>t("/providers"),children:"API Profiles"})]})]})]})})})}const F=m.entries.filter(l=>l.secretConfigured),q=b.filter(l=>l.status==="ready").length,v=m.entries.find(l=>l.id===N)??null,I=m.entries.length>1,P=As(m.status),_=m.entries.length>0,D=e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:"Setup status"}),e.jsx("div",{className:"mt-1 text-sm font-medium",children:m.routePath})]}),e.jsx(p,{variant:"secondary",className:P.className,children:P.label})]}),e.jsxs("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:[e.jsx(Q,{label:"Entries",value:`${m.entries.length}`,hint:"configured rows"}),e.jsx(Q,{label:"Secrets",value:`${F.length}/${m.entries.length||0}`,hint:"stored in CLIProxy"})]}),e.jsx("div",{className:"mt-3 rounded-lg border bg-muted/15 p-3 text-xs leading-5 text-muted-foreground",children:"Overview handles OAuth sign-ins. This page stores CLIProxy-managed keys and connectors. API Profiles remains for CCS-native Anthropic-compatible profiles."})]});return e.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"flex w-80 flex-col border-r bg-muted/30",children:[e.jsxs("div",{className:"border-b bg-background p-4",children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(is,{className:"h-5 w-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:"CLIProxy Plus"})]}),e.jsx(y,{variant:"ghost",size:"icon",className:"h-8 w-8",type:"button",onClick:()=>void a(),disabled:h,children:e.jsx(de,{className:B("h-4 w-4",h&&"animate-spin")})})]}),e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"AI Providers"}),e.jsxs(y,{variant:"default",size:"sm",className:"w-full gap-2",type:"button",onClick:$,children:[e.jsx(Ee,{className:"h-4 w-4"}),m.supportsNamedEntries?"Create Connector":`Add ${m.displayName} Entry`]})]}),e.jsx(se,{className:"flex-1",children:e.jsxs("div",{className:"p-2",children:[e.jsx("div",{className:"px-3 py-2 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Provider Families"}),e.jsx(hs,{families:b,selectedFamily:j,onSelect:H})]})}),e.jsx("div",{className:"border-t p-3",children:e.jsx(ts,{})}),e.jsx("div",{className:"border-t bg-background p-3 text-xs text-muted-foreground",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{children:[b.length," families"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Te,{className:"h-3 w-3 text-emerald-600"}),q," ready"]})]})})]}),e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col bg-background",children:[e.jsx("div",{className:"shrink-0 border-b bg-background px-6 py-4",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(pe,{provider:xe(m.id),size:"lg"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:m.displayName}),e.jsx(p,{variant:"secondary",className:P.className,children:P.label}),e.jsx(p,{variant:"outline",className:"uppercase",children:m.authMode}),e.jsx(p,{variant:"outline",className:"font-mono text-[11px]",children:m.routePath})]}),e.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:m.description})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(y,{type:"button",variant:"ghost",size:"sm",onClick:()=>void a(),disabled:h,children:e.jsx(de,{className:B("h-4 w-4",h&&"animate-spin")})}),e.jsx(y,{type:"button",variant:"outline",onClick:()=>t("/cliproxy/control-panel"),children:"Control Panel"}),e.jsxs(y,{type:"button",variant:"outline",onClick:()=>t("/providers"),children:["API Profiles",e.jsx(qe,{className:"ml-1 h-3.5 w-3.5"})]})]})]})}),_?e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[e.jsxs("div",{className:"shrink-0 border-b bg-muted/5 px-6 py-4",children:[e.jsxs("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:[e.jsx(ls,{className:"h-3 w-3"}),I?"Saved entries":"Saved entry"]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(p,{variant:"outline",className:"text-[11px]",children:[m.entries.length," entries"]}),e.jsxs(p,{variant:"outline",className:"text-[11px]",children:[F.length,"/",m.entries.length," secrets stored"]})]})]}),I?e.jsx("div",{className:"flex flex-wrap gap-3",children:m.entries.map(l=>e.jsxs("button",{type:"button",onClick:()=>J(l.id),className:B("min-w-[220px] max-w-[280px] flex-1 rounded-xl border bg-background px-4 py-3 text-left transition-colors",l.id===N?"border-primary/30 bg-primary/5 shadow-sm":"border-border/60 hover:bg-muted/50"),children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:l.label}),e.jsx(ue,{configured:l.secretConfigured})]}),e.jsx("div",{className:"mt-2 truncate text-xs text-muted-foreground",children:l.baseUrl||m.routePath}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-1.5",children:[e.jsx(p,{variant:"outline",className:"text-[10px]",children:me(l)}),l.models.length>0?e.jsx(p,{variant:"outline",className:"text-[10px]",children:re(l.models)}):null,e.jsxs(p,{variant:"outline",className:"text-[10px]",children:[l.headers.length," hdr"]})]})]},l.id))}):v?e.jsx("div",{className:"rounded-xl border bg-background px-4 py-3",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:v.label}),e.jsx(ue,{configured:v.secretConfigured})]}),e.jsx("div",{className:"mt-1 truncate text-xs text-muted-foreground",children:v.baseUrl||m.routePath})]}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsx(p,{variant:"outline",className:"text-[10px]",children:me(v)}),v.models.length>0?e.jsx(p,{variant:"outline",className:"text-[10px]",children:re(v.models)}):null,e.jsxs(p,{variant:"outline",className:"text-[10px]",children:[v.headers.length," hdr"]})]})]})}):null]}),v?e.jsx(Os,{family:m,entry:v,source:n.source,isSaving:g.isPending,onSave:async l=>{await g.mutateAsync({family:j,entryId:v.id,data:l}),a()},onDelete:()=>K(v)},v.id):null]}):e.jsx(se,{className:"flex-1",children:e.jsxs("div",{className:"space-y-6 p-6",children:[D,e.jsx(Ks,{family:m,onAddEntry:$,onOpenControlPanel:()=>t("/cliproxy/control-panel"),onOpenProfiles:()=>t("/providers")})]})})]}),e.jsx(Ns,{family:j,entry:k,open:O,onOpenChange:S,onSubmit:async l=>{k?await g.mutateAsync({family:j,entryId:k.id,data:l}):await x.mutateAsync({family:j,data:l}),S(!1),M(null),a()},isSaving:x.isPending||g.isPending},`${j}:${k?.id??"new"}:${O?"open":"closed"}`),e.jsx(rs,{open:U!==null,title:"Remove provider entry?",description:U?`This removes ${U.label} from ${m.displayName}.`:"",confirmText:"Remove",variant:"destructive",onConfirm:async()=>{U&&(await C.mutateAsync({family:j,entryId:U.id}),K(null))},onCancel:()=>K(null)})]})}export{Xs as CliproxyAiProvidersPage};
|
package/dist/ui/assets/{cliproxy-control-panel-qL0R878z.js → cliproxy-control-panel-DL8JoyKU.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as s}from"./react-vendor-CNOkPC89.js";import{u as S}from"./tanstack-CrmUhA7Z.js";import{a as D,
|
|
1
|
+
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as s}from"./react-vendor-CNOkPC89.js";import{u as S}from"./tanstack-CrmUhA7Z.js";import{a as D,bc as g,Y as I}from"./index-DM7Qb4kd.js";import{C as _}from"./default-ports-1QQSffYX.js";import{G as Q,R as $,w as X}from"./icons-Dmi9qMuE.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";const k="cli-proxy-auth",O="isLoggedIn",U="apiBase",K="apiUrl",F="managementKey";function A(a){return a.startsWith("/")?new URL(a.replace(/\/$/,""),window.location.origin).href:a.replace(/\/$/,"")}function J(a,u){window.localStorage.removeItem(k),window.localStorage.setItem(U,a),window.localStorage.setItem(K,a),window.localStorage.setItem(F,u),window.localStorage.setItem(O,"true")}function T(){window.localStorage.removeItem(k),window.localStorage.removeItem(U),window.localStorage.removeItem(K),window.localStorage.removeItem(F),window.localStorage.removeItem(O)}function V({port:a=_}){const{t:u}=D(),f=s.useRef(null),[M,N]=s.useState(null),[B,Y]=s.useState(0),[L,v]=s.useState(null),[G,E]=s.useState(!1),{data:l,error:w}=S({queryKey:["cliproxy-server-config"],queryFn:()=>I.cliproxyServer.get(),staleTime:3e4});s.useEffect(()=>{w&&console.warn("[ControlPanelEmbed] Config fetch failed, using local mode:",w)},[w]);const j=!!(l?.remote?.enabled&&l?.remote?.host),{data:y,error:x}=S({queryKey:["auth-tokens-raw",j?"remote":"local"],enabled:l!==void 0&&!j,queryFn:async()=>{try{const t=await fetch(g("/settings/auth/tokens/raw"));if(!t.ok)throw new Error("Failed to fetch auth tokens");const n=await t.json(),o=n.managementSecret.value.trim();if(!o)throw new Error("Management secret missing");return J(A(g("/cliproxy-local/")),o),n}catch(t){throw T(),t}},staleTime:3e4}),{managementUrl:R,checkUrl:h,authToken:b,isRemote:i,displayHost:c}=s.useMemo(()=>{const t=l?.remote,n=l?.local?.port??a;if(t?.enabled&&t?.host){const o=t.protocol||"http",m=t.port||(o==="https"?443:_),p=o==="https"&&m===443||o==="http"&&m===80?"":`:${m}`,r=`${o}://${t.host}${p}`;return{managementUrl:`${r}/management.html`,checkUrl:`${r}/`,authToken:t.auth_token||void 0,isRemote:!0,displayHost:`${t.host}${p}`}}return{managementUrl:g("/cliproxy-local/management.html"),checkUrl:g("/cliproxy-local/"),authToken:y?.managementSecret?.value||void 0,isRemote:!1,displayHost:`localhost:${n}`}},[l,y,a]),C=`${R}:${i?"remote":"local"}:${h}:${b??"missing"}:${B}`,P=l!==void 0&&(i||!!y||!!x);s.useEffect(()=>{x&&console.warn("[ControlPanelEmbed] Failed to preload local control panel session, falling back to manual login:",x)},[x]),s.useEffect(()=>{if(!i)return()=>{T()}},[i]);const H=!P||!(M===C),q=()=>{if(!(!i||!f.current?.contentWindow||!b))try{const t=A(h),n=new URL(`${t}/`).origin;if(new URL(f.current.src,window.location.origin).origin!==n){console.warn("[ControlPanelEmbed] Remote iframe origin mismatch, skipping postMessage");return}f.current.contentWindow.postMessage({type:"ccs-auto-login",apiBase:t,managementKey:b},n)}catch(t){console.debug("[ControlPanelEmbed] Remote postMessage bootstrap failed:",t)}};s.useEffect(()=>{const t=new AbortController;let n=!1;const o=(r,d)=>{n||(E(r),v(d))},m=async()=>{try{if(i){const r=l?.remote,d=await I.cliproxyServer.test({host:r?.host??"",port:r?.port,protocol:r?.protocol??"http",authToken:r?.auth_token});d?.reachable?o(!0,null):o(!1,d?.error?`Remote CLIProxy at ${c}: ${d.error}`:`Remote CLIProxy at ${c} returned an error`)}else(await fetch(h,{signal:t.signal})).ok?o(!0,null):o(!1,"CLIProxy returned an error")}catch(r){if(r instanceof Error&&r.name==="AbortError")return;o(!1,i?`Remote CLIProxy at ${c} is not reachable`:"CLIProxy is not running")}},p=setTimeout(()=>t.abort(),2e3);return m().finally(()=>clearTimeout(p)),()=>{n=!0,t.abort()}},[h,i,c,l]);const W=()=>{N(C),q()},z=()=>{N(null),Y(t=>t+1),v(null),E(!1)};return!G&&L?e.jsxs("div",{className:"flex-1 flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Q,{className:"w-5 h-5 text-primary"}),e.jsx("h2",{className:"font-semibold",children:u("cliproxyHeader.cliproxyControlPanel")})]}),e.jsxs("button",{className:"inline-flex items-center gap-2 px-3 py-1.5 text-sm border rounded-md hover:bg-muted",onClick:z,children:[e.jsx($,{className:"w-4 h-4"}),"Retry"]})]}),e.jsx("div",{className:"flex-1 flex items-center justify-center bg-muted/20",children:e.jsxs("div",{className:"text-center max-w-md px-8",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-destructive/10 flex items-center justify-center mx-auto mb-6",children:e.jsx(X,{className:"w-8 h-8 text-destructive"})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:u("cliproxyHeader.cliproxyNotAvailable")}),e.jsx("p",{className:"text-muted-foreground mb-4",children:L}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Start a CLIProxy session with"," ",e.jsx("code",{className:"bg-muted px-1 rounded",children:"ccs gemini"})," or run"," ",e.jsx("code",{className:"bg-muted px-1 rounded",children:"ccs config"})," which auto-starts it."]})]})})]}):e.jsx("div",{className:"flex-1 flex flex-col",children:e.jsxs("div",{className:"flex-1 flex flex-col relative",children:[H&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/80 z-10",children:e.jsxs("div",{className:"text-center",children:[e.jsx($,{className:"w-8 h-8 animate-spin text-primary mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:i?`Loading Control Panel from ${c}...`:"Loading Control Panel..."})]})}),P?e.jsx("iframe",{ref:f,src:R,className:"flex-1 w-full border-0",title:"CLIProxy Management Panel",onLoad:W},C):null]})})}function me(){return e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:e.jsx(V,{})})}export{me as CliproxyControlPanelPage};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as N}from"./react-vendor-CNOkPC89.js";import{t as U}from"./notifications-B2HqRBj7.js";import{C as I,j as F,k as W,B as _,b as K,a as E,d as C,aG as J,r as P,s as O,t as D,v as L,w as b,I as S,n as fe,W as y,bc as se,bd as Pe,c as Oe,bj as He,bk as ve,bl as Qe,Q as Je,R as Ze,U as ae,V as oe,be}from"./index-DM7Qb4kd.js";import{aa as es,aS as ss,at as re,L as z,n as rs,aT as ts,aU as ns,aC as as,w as os,a7 as ls,aV as is,aW as cs,aX as ds,ai as me,p as we,$ as xs,m as us,o as ms,_ as ps,S as hs,aN as Ne,aY as fs,x as gs,I as js,T as vs,N as bs}from"./icons-Dmi9qMuE.js";import{S as ee}from"./separator--T-CzItG.js";import{a as ws,u as ye,b as Ce}from"./tanstack-CrmUhA7Z.js";import"./code-highlight-BRUf_pqB.js";import{T as Ns,a as ys,b as Se,c as le,d as Cs,e as ie}from"./table-wE_LUUUQ.js";import{R as Ss}from"./raw-json-settings-editor-panel-DeWgWDSP.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";function Z({title:s,icon:r,badge:t,description:l,disabledReason:o,children:n}){return e.jsxs(I,{children:[e.jsxs(F,{className:"pb-2",children:[e.jsxs(W,{className:"flex items-center gap-2 text-base",children:[r,s,t?e.jsx(_,{variant:"outline",className:"text-[10px] font-normal",children:t}):null]}),l?e.jsx("p",{className:"text-xs text-muted-foreground",children:l}):null]}),e.jsxs(K,{className:"space-y-3",children:[o?e.jsx("p",{className:"text-xs text-amber-600",children:o}):null,n]})]})}function _s({catalog:s,state:r,disabled:t=!1,disabledReason:l,onToggle:o}){const{t:n}=E(),a=new Set(s.map(i=>i.name)),c=Object.entries(r).filter(([i])=>!a.has(i)).sort(([i],[d])=>i.localeCompare(d));return e.jsxs(Z,{title:n("codex.features"),badge:"features",icon:e.jsx(es,{className:"h-4 w-4"}),description:n("codex.featuresDesc"),disabledReason:l,children:[e.jsx("div",{className:"space-y-2",children:s.map(i=>{const d=r[i.name]??null;return e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-sm font-medium",children:i.label}),e.jsx(_,{variant:"outline",className:"font-mono text-[10px]",children:i.name})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:i.description})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[d!==null?e.jsx(C,{variant:"outline",size:"sm",onClick:()=>o(i.name,null),disabled:t,children:n("codex.useDefault")}):null,e.jsx(J,{checked:d===!0,onCheckedChange:m=>o(i.name,m),disabled:t})]})]},i.name)})}),c.length>0?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:n("codex.configOnlyFlags")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n("codex.configOnlyFlagsDesc")})]}),c.map(([i,d])=>e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border border-dashed px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-sm font-medium",children:i}),e.jsx(_,{variant:"secondary",className:"text-[10px]",children:n("codex.existing")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n(d===null?"codex.nonBooleanForm":"codex.discoveredFromFile")})]}),d===null?e.jsx(_,{variant:"outline",children:n("codex.rawOnly")}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{variant:"outline",size:"sm",onClick:()=>o(i,null),disabled:t,children:n("codex.useDefault")}),e.jsx(J,{checked:d===!0,onCheckedChange:m=>o(i,m),disabled:t})]})]},i))]}):null]})}const ks={name:"",transport:"stdio",command:null,args:[],url:null,enabled:!0,required:!1,startupTimeoutSec:null,toolTimeoutSec:null,enabledTools:[],disabledTools:[],isCcsManaged:!1,managementSurface:null};function ce(s){return s.join(", ")}function de(s){return s.split(",").map(r=>r.trim()).filter(Boolean)}function Ts({initialDraft:s,isNew:r,disabled:t,saving:l,canDelete:o,onSave:n,onDelete:a}){const{t:c}=E(),[i,d]=N.useState(s),m=r&&i.name.trim()==="ccs_browser";return e.jsxs(e.Fragment,{children:[m?e.jsxs("div",{className:"rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-sm text-amber-900 dark:text-amber-200",children:[e.jsx("strong",{children:"ccs_browser"})," is reserved for the CCS-managed browser tooling path. Configure it from ",e.jsx("code",{children:"Settings > Browser"})," instead of creating it here."]}):null,e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(S,{value:i.name,onChange:p=>d(x=>({...x,name:p.target.value})),placeholder:"playwright",disabled:t||!r}),e.jsxs(P,{value:i.transport,onValueChange:p=>d(x=>({...x,transport:p})),disabled:t,children:[e.jsx(O,{children:e.jsx(D,{})}),e.jsxs(L,{children:[e.jsx(b,{value:"stdio",children:c("codex.stdio")}),e.jsx(b,{value:"streamable-http",children:c("codex.streamableHttp")})]})]}),i.transport==="stdio"?e.jsxs(e.Fragment,{children:[e.jsx(S,{value:i.command??"",onChange:p=>d(x=>({...x,command:p.target.value||null})),placeholder:"npx",disabled:t}),e.jsx(S,{value:ce(i.args),onChange:p=>d(x=>({...x,args:de(p.target.value)})),placeholder:"@playwright/mcp@latest, --flag",disabled:t})]}):e.jsx(S,{className:"sm:col-span-2",value:i.url??"",onChange:p=>d(x=>({...x,url:p.target.value||null})),placeholder:"https://example.test/mcp",disabled:t}),e.jsx(S,{type:"number",min:1,value:i.startupTimeoutSec??"",onChange:p=>d(x=>({...x,startupTimeoutSec:p.target.value?Number(p.target.value):null})),placeholder:"Startup timeout (sec)",disabled:t}),e.jsx(S,{type:"number",min:1,value:i.toolTimeoutSec??"",onChange:p=>d(x=>({...x,toolTimeoutSec:p.target.value?Number(p.target.value):null})),placeholder:"Tool timeout (sec)",disabled:t}),e.jsx(S,{value:ce(i.enabledTools),onChange:p=>d(x=>({...x,enabledTools:de(p.target.value)})),placeholder:"enabled_tools",disabled:t}),e.jsx(S,{value:ce(i.disabledTools),onChange:p=>d(x=>({...x,disabledTools:de(p.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(J,{checked:i.enabled,onCheckedChange:p=>d(x=>({...x,enabled:p})),disabled:t})]}),e.jsxs("label",{className:"flex items-center justify-between rounded-md border px-3 py-2 text-sm",children:["Required",e.jsx(J,{checked:i.required,onCheckedChange:p=>d(x=>({...x,required:p})),disabled:t})]})]}),e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsxs(C,{variant:"outline",onClick:a,disabled:t||l||!o,children:[e.jsx(re,{className:"mr-2 h-4 w-4"}),"Delete"]}),e.jsxs(C,{onClick:()=>n(i.name,{transport:i.transport,command:i.command,args:i.args,url:i.url,enabled:i.enabled,required:i.required,startupTimeoutSec:i.startupTimeoutSec,toolTimeoutSec:i.toolTimeoutSec,enabledTools:i.enabledTools,disabledTools:i.disabledTools}),disabled:t||l||i.name.trim().length===0||m,children:[l?e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save MCP server"]})]})]})}function Es({entries:s,disabled:r=!1,disabledReason:t,saving:l=!1,onSave:o,onDelete:n}){const{t:a}=E(),[c,i]=N.useState("new"),d=N.useMemo(()=>s.find(j=>j.name===c)??null,[s,c]),m=d??ks,p=JSON.stringify(m),x=d?.isCcsManaged&&d.managementSurface==="browser-settings";return e.jsxs(Z,{title:"MCP servers",badge:"mcp_servers",icon:e.jsx(ss,{className:"h-4 w-4"}),description:"Manage the safe MCP transport fields. Keep auth headers and bearer tokens in raw TOML.",disabledReason:t,children:[x?e.jsxs("div",{className:"rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-sm text-amber-900 dark:text-amber-200",children:[e.jsx("strong",{children:d?.name})," is CCS-managed. Configure browser tooling from"," ",e.jsx("code",{children:"Settings > Browser"}),"; the generic MCP editor is read-only for this entry."]}):null,e.jsxs(P,{value:c,onValueChange:i,disabled:r,children:[e.jsx(O,{children:e.jsx(D,{placeholder:"Select MCP server"})}),e.jsxs(L,{children:[e.jsx(b,{value:"new",children:a("codex.createNewMcpServer")}),s.map(j=>e.jsx(b,{value:j.name,children:j.isCcsManaged?`${j.name} (CCS managed)`:j.name},j.name))]})]}),e.jsx(Ts,{initialDraft:m,isNew:c==="new",disabled:r||!!x,saving:l,canDelete:d!==null&&!x,onDelete:async()=>{d&&(await n(d.name),i("new"))},onSave:async(j,h)=>{await o(j,h),i(j)}},p)]})}const Ps={name:"",displayName:null,baseUrl:null,envKey:null,wireApi:"responses",requiresOpenaiAuth:!1,supportsWebsockets:!1},Os={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 Ds({initialDraft:s,isNew:r,disabled:t,saving:l,canDelete:o,onSave:n,onDelete:a}){const{t:c}=E(),[i,d]=N.useState(s);return e.jsxs(e.Fragment,{children:[r&&e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-md border border-dashed px-3 py-2 text-xs text-muted-foreground",children:[e.jsxs("p",{children:["Quick start: apply the CLIProxy Codex preset here, then set"," ",e.jsx("strong",{children:c("codex.defaultProvider")})," to ",e.jsx("code",{children:"cliproxy"})," in Top-level settings."]}),e.jsx(C,{variant:"outline",size:"sm",onClick:()=>d(Os),disabled:t,children:"Use CLIProxy Codex preset"})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(S,{value:i.name,onChange:m=>d(p=>({...p,name:m.target.value})),placeholder:"Provider id",disabled:t||!r}),e.jsx(S,{value:i.displayName??"",onChange:m=>d(p=>({...p,displayName:m.target.value||null})),placeholder:"Display name",disabled:t}),e.jsx(S,{value:i.baseUrl??"",onChange:m=>d(p=>({...p,baseUrl:m.target.value||null})),placeholder:"http://127.0.0.1:8317/api/provider/codex",disabled:t}),e.jsx(S,{value:i.envKey??"",onChange:m=>d(p=>({...p,envKey:m.target.value||null})),placeholder:"CLIPROXY_API_KEY",disabled:t})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[e.jsxs(P,{value:i.wireApi??"responses",onValueChange:m=>d(p=>({...p,wireApi:m})),disabled:t,children:[e.jsx(O,{children:e.jsx(D,{})}),e.jsx(L,{children:e.jsx(b,{value:"responses",children:c("codex.responses")})})]}),e.jsxs("label",{className:"flex items-center justify-between rounded-md border px-3 py-2 text-sm",children:["Requires OpenAI auth",e.jsx(J,{checked:i.requiresOpenaiAuth,onCheckedChange:m=>d(p=>({...p,requiresOpenaiAuth:m})),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(J,{checked:i.supportsWebsockets,onCheckedChange:m=>d(p=>({...p,supportsWebsockets:m})),disabled:t})]})]}),e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsxs(C,{variant:"outline",onClick:a,disabled:t||l||!o,children:[e.jsx(re,{className:"mr-2 h-4 w-4"}),"Delete"]}),e.jsxs(C,{onClick:()=>n(i.name,{displayName:i.displayName,baseUrl:i.baseUrl,envKey:i.envKey,wireApi:i.wireApi,requiresOpenaiAuth:i.requiresOpenaiAuth,supportsWebsockets:i.supportsWebsockets}),disabled:t||l||i.name.trim().length===0,children:[l?e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save provider"]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["If you want plain native ",e.jsx("code",{children:"codex"})," to default to CLIProxy, save a provider named"," ",e.jsx("code",{children:"cliproxy"})," with ",e.jsx("code",{children:"CLIPROXY_API_KEY"})," here, then pick"," ",e.jsx("code",{children:"cliproxy"})," in the ",e.jsx("strong",{children:c("codex.defaultProvider")})," control above."]})]})}function Ls({entries:s,disabled:r=!1,disabledReason:t,saving:l=!1,onSave:o,onDelete:n}){const{t:a}=E(),[c,i]=N.useState("new"),d=N.useMemo(()=>s.find(x=>x.name===c)??null,[s,c]),m=d??Ps,p=JSON.stringify(m);return e.jsxs(Z,{title:"Model providers",badge:"model_providers",icon:e.jsx(rs,{className:"h-4 w-4"}),description:"Edit the common provider fields CCS can support safely. Keep secret migration and inline bearer tokens in raw TOML.",disabledReason:t,children:[e.jsxs(P,{value:c,onValueChange:i,disabled:r,children:[e.jsx(O,{children:e.jsx(D,{placeholder:"Select provider"})}),e.jsxs(L,{children:[e.jsx(b,{value:"new",children:a("codex.createNewProvider")}),s.map(x=>e.jsx(b,{value:x.name,children:x.name},x.name))]})]}),e.jsx(Ds,{initialDraft:m,isNew:c==="new",disabled:r,saving:l,canDelete:d!==null,onDelete:async()=>{d&&(await n(d.name),i("new"))},onSave:async(x,j)=>{await o(x,j),i(x)}},p)]})}function As({initialName:s,initialModel:r,initialProvider:t,initialEffort:l,providerNames:o,activeProfile:n,selectedEntryName:a,disabled:c,saving:i,onSave:d,onDelete:m,onSetActive:p}){const{t:x}=E(),[j,h]=N.useState(s),[w,M]=N.useState(r),[q,u]=N.useState(t),[v,B]=N.useState(l);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(S,{value:j,onChange:g=>h(g.target.value),placeholder:"deep-review",disabled:c||a!==null}),e.jsx(S,{value:w??"",onChange:g=>M(g.target.value||null),placeholder:"gpt-5.4",disabled:c}),e.jsxs(P,{value:q??"__unset__",onValueChange:g=>u(g==="__unset__"?null:g),disabled:c,children:[e.jsx(O,{children:e.jsx(D,{placeholder:x("codex.useGlobalProvider")})}),e.jsxs(L,{children:[e.jsx(b,{value:"__unset__",children:x("codex.useGlobalProvider")}),o.map(g=>e.jsx(b,{value:g,children:g},g))]})]}),e.jsxs(P,{value:v??"__unset__",onValueChange:g=>B(g==="__unset__"?null:g),disabled:c,children:[e.jsx(O,{children:e.jsx(D,{placeholder:x("codex.useGlobalEffort")})}),e.jsxs(L,{children:[e.jsx(b,{value:"__unset__",children:x("codex.useGlobalEffort")}),["minimal","low","medium","high","xhigh"].map(g=>e.jsx(b,{value:g,children:g},g))]})]})]}),e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(C,{variant:"outline",onClick:m,disabled:c||i||!a,children:[e.jsx(re,{className:"mr-2 h-4 w-4"}),"Delete"]}),e.jsx(C,{variant:"outline",onClick:p,disabled:c||i||!a||a===n,children:"Set active"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(C,{variant:"outline",onClick:()=>d(j,{model:w,modelProvider:q,modelReasoningEffort:v},!1),disabled:c||i||j.trim().length===0,children:[i?e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save profile"]}),e.jsxs(C,{onClick:()=>d(j,{model:w,modelProvider:q,modelReasoningEffort:v},!0),disabled:c||i||j.trim().length===0,children:[i?e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save + activate"]})]})]})]})}function Ms({activeProfile:s,entries:r,providerNames:t,disabled:l=!1,disabledReason:o,saving:n=!1,onSave:a,onDelete:c,onSetActive:i}){const{t:d}=E(),[m,p]=N.useState("new"),x=N.useMemo(()=>r.find(h=>h.name===m)??null,[r,m]),j=JSON.stringify(x??{name:"",values:{}});return e.jsxs(Z,{title:d("codex.profiles"),badge:"profiles",icon:e.jsx(ts,{className:"h-4 w-4"}),description:"Create reusable Codex overlays and set the active default profile.",disabledReason:o,children:[e.jsxs(P,{value:m,onValueChange:p,disabled:l,children:[e.jsx(O,{children:e.jsx(D,{placeholder:"Select profile"})}),e.jsxs(L,{children:[e.jsx(b,{value:"new",children:d("codex.createNewProfile")}),r.map(h=>e.jsxs(b,{value:h.name,children:[h.name,h.name===s?" (active)":""]},h.name))]})]}),e.jsx(As,{initialName:x?.name??"",initialModel:x?.values.model??null,initialProvider:x?.values.modelProvider??null,initialEffort:x?.values.modelReasoningEffort??null,providerNames:t,activeProfile:s,selectedEntryName:x?.name??null,disabled:l,saving:n,onDelete:async()=>{x&&(await c(x.name),p("new"))},onSetActive:async()=>{x&&await i(x.name)},onSave:async(h,w,M)=>{await a(h,w,M),p(h)}},j)]})}function Rs({workspacePath:s,disabled:r,saving:t,onSave:l}){const{t:o}=E(),[n,a]=N.useState(s),[c,i]=N.useState("trusted");return e.jsxs("div",{className:"grid gap-2 sm:grid-cols-[1fr_160px_auto]",children:[e.jsx(S,{value:n,onChange:d=>a(d.target.value),placeholder:"~/repo or /absolute/path",disabled:r}),e.jsxs(P,{value:c,onValueChange:i,disabled:r,children:[e.jsx(O,{children:e.jsx(D,{})}),e.jsxs(L,{children:[e.jsx(b,{value:"trusted",children:o("codex.trusted")}),e.jsx(b,{value:"untrusted",children:o("codex.untrusted")})]})]}),e.jsxs(C,{onClick:()=>l(n,c),disabled:r||t,children:[t?e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save trust"]})]})}function Is({workspacePath:s,entries:r,disabled:t=!1,disabledReason:l,saving:o=!1,onSave:n}){const{t:a}=E();return e.jsxs(Z,{title:"Project trust",badge:"projects",icon:e.jsx(ns,{className:"h-4 w-4"}),description:"Trust current workspaces or remove stale trust entries without opening raw TOML.",disabledReason:l,children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Paths must be absolute or start with ",e.jsx("code",{children:"~/"}),". Relative paths are rejected so CCS does not trust the wrong folder."]}),e.jsx(Rs,{workspacePath:s,disabled:t,saving:o,onSave:n},s),e.jsx(C,{variant:"outline",className:"w-full justify-start",onClick:()=>n(s,"trusted"),disabled:t||o,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:a("codex.noProjectTrustEntries")}):r.map(c=>e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:c.path}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["trust_level = ",c.trustLevel]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{variant:"ghost",size:"sm",onClick:()=>n(c.path,c.trustLevel==="trusted"?"untrusted":"trusted"),disabled:t||o,children:"Toggle"}),e.jsx(C,{variant:"ghost",size:"icon",onClick:()=>n(c.path,null),disabled:t||o,children:e.jsx(re,{className:"h-4 w-4"})})]})]},c.path))})]})}const A="__unset__",Fs=105e4,Ws=272e3,_e=8e5,ke=7e5,Ks=new Intl.NumberFormat("en-US");function X(s){return s??A}function Y(s,r){return r&&!s.includes(r)?[r,...s]:s}function xe(s){return Ks.format(s)}function qs(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 Vs({initialValues:s,providerNames:r,disabled:t,saving:l,onSave:o}){const{t:n}=E(),[a,c]=N.useState(s),i=Y(["minimal","low","medium","high","xhigh"],a.modelReasoningEffort),d=Y(r,a.modelProvider),m=Y(["on-request","never","untrusted"],a.approvalPolicy),p=Y(["read-only","workspace-write","danger-full-access"],a.sandboxMode),x=Y(["cached","live","disabled"],a.webSearch),j=Y(["none","friendly","pragmatic"],a.personality),h=Us(s,a),w=Object.keys(h).length>0,M=qs(a.model),q=u=>{const v=u.trim();return v.length>0?Number(v):null};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.model")}),e.jsx(S,{value:a.model??"",onChange:u=>c(v=>({...v,model:u.target.value||null})),placeholder:"gpt-5.4",disabled:t})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.reasoningEffort")}),e.jsxs(P,{value:X(a.modelReasoningEffort),onValueChange:u=>c(v=>({...v,modelReasoningEffort:u===A?null:u})),disabled:t,children:[e.jsx(O,{children:e.jsx(D,{placeholder:n("codex.useDefault")})}),e.jsxs(L,{children:[e.jsx(b,{value:A,children:n("codex.useDefault")}),i.map(u=>e.jsx(b,{value:u,children:u},u))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.defaultProvider")}),e.jsxs(P,{value:X(a.modelProvider),onValueChange:u=>c(v=>({...v,modelProvider:u===A?null:u})),disabled:t,children:[e.jsx(O,{children:e.jsx(D,{placeholder:n("codex.useCodexDefault")})}),e.jsxs(L,{children:[e.jsx(b,{value:A,children:n("codex.useCodexDefault")}),d.map(u=>e.jsx(b,{value:u,children:u},u))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.approvalPolicy")}),e.jsxs(P,{value:X(a.approvalPolicy),onValueChange:u=>c(v=>({...v,approvalPolicy:u===A?null:u})),disabled:t,children:[e.jsx(O,{children:e.jsx(D,{placeholder:n("codex.useDefault")})}),e.jsxs(L,{children:[e.jsx(b,{value:A,children:n("codex.useDefault")}),m.map(u=>e.jsx(b,{value:u,children:u},u))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.sandboxMode")}),e.jsxs(P,{value:X(a.sandboxMode),onValueChange:u=>c(v=>({...v,sandboxMode:u===A?null:u})),disabled:t,children:[e.jsx(O,{children:e.jsx(D,{placeholder:n("codex.useDefault")})}),e.jsxs(L,{children:[e.jsx(b,{value:A,children:n("codex.useDefault")}),p.map(u=>e.jsx(b,{value:u,children:u},u))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.webSearch")}),e.jsxs(P,{value:X(a.webSearch),onValueChange:u=>c(v=>({...v,webSearch:u===A?null:u})),disabled:t,children:[e.jsx(O,{children:e.jsx(D,{placeholder:n("codex.useDefault")})}),e.jsxs(L,{children:[e.jsx(b,{value:A,children:n("codex.useDefault")}),x.map(u=>e.jsx(b,{value:u,children:u},u))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.toolOutputTokenLimit")}),e.jsx(S,{type:"number",min:1,value:a.toolOutputTokenLimit??"",onChange:u=>c(v=>({...v,toolOutputTokenLimit:u.target.value?Number(u.target.value):null})),placeholder:"25000",disabled:t})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.personality")}),e.jsxs(P,{value:X(a.personality),onValueChange:u=>c(v=>({...v,personality:u===A?null:u})),disabled:t,children:[e.jsx(O,{children:e.jsx(D,{placeholder:n("codex.useDefault")})}),e.jsxs(L,{children:[e.jsx(b,{value:A,children:n("codex.useDefault")}),j.map(u=>e.jsx(b,{value:u,children:u},u))]})]})]})]}),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(os,{className:"h-4 w-4 text-amber-600 dark:text-amber-300"}),e.jsx("p",{className:"text-sm font-semibold",children:n("codex.longContextOverride")}),e.jsx(_,{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(_,{variant:"secondary",className:"text-[10px] uppercase tracking-[0.16em] text-muted-foreground",children:M?"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(C,{type:"button",variant:"outline",size:"sm",disabled:t,onClick:()=>c(u=>({...u,modelContextWindow:_e,modelAutoCompactTokenLimit:ke})),children:"Fill cautious pair"}),e.jsx(C,{type:"button",variant:"outline",size:"sm",disabled:t,onClick:()=>c(u=>({...u,modelContextWindow:Fs})),children:"Set official max window"}),e.jsx(C,{type:"button",variant:"ghost",size:"sm",disabled:t,onClick:()=>c(u=>({...u,modelContextWindow:null,modelAutoCompactTokenLimit:null})),children:"Clear"})]})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-3",children:[e.jsxs("div",{className:"rounded-lg border bg-background/85 px-3 py-3 shadow-sm shadow-black/5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"Official max"}),e.jsx("p",{className:"mt-1 font-mono text-base font-semibold text-foreground",children:"1.05M / 1M"}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:n("codex.gptContextCap")})]}),e.jsxs("div",{className:"rounded-lg border bg-background/85 px-3 py-3 shadow-sm shadow-black/5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"Standard window"}),e.jsx("p",{className:"mt-1 font-mono text-base font-semibold text-foreground",children:xe(Ws)}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:n("codex.normalUsageWindow")})]}),e.jsxs("div",{className:"rounded-lg border bg-background/85 px-3 py-3 shadow-sm shadow-black/5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"Above 272K"}),e.jsx("p",{className:"mt-1 font-mono text-base font-semibold text-foreground",children:n("codex.counts2x")}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:n("codex.usageLimitCost")})]})]}),e.jsxs("div",{className:"space-y-3 rounded-lg border bg-background/75 px-3 py-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"One cautious pair"}),e.jsxs("div",{className:"rounded-full border bg-background px-2.5 py-1 font-mono text-[11px] font-medium",children:["Context ",xe(_e)]}),e.jsxs("div",{className:"rounded-full border bg-background px-2.5 py-1 font-mono text-[11px] font-medium",children:["Auto-compact ",xe(ke)]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx(_,{variant:"outline",className:"border-border/70 bg-background/80 text-[10px] uppercase tracking-[0.14em] text-muted-foreground",children:"Not official"}),e.jsx(_,{variant:"outline",className:"border-border/70 bg-background/80 text-[10px] uppercase tracking-[0.14em] text-muted-foreground",children:"Draft only"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px] text-muted-foreground",children:[e.jsx("span",{children:n("codex.quickFillWarning")}),!M&&a.model?e.jsxs("span",{children:[e.jsx("code",{children:a.model})," should be checked separately."]}):null]})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.modelContextWindow")}),e.jsx(S,{"aria-label":n("codex.modelContextWindow"),type:"number",min:1,value:a.modelContextWindow??"",onChange:u=>c(v=>({...v,modelContextWindow:q(u.target.value)})),placeholder:"Unset",disabled:t}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Writes ",e.jsx("code",{children:"model_context_window"}),". Leave unset to keep Codex defaults."]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.autoCompactTokenLimit")}),e.jsx(S,{"aria-label":n("codex.autoCompactTokenLimit"),type:"number",min:1,value:a.modelAutoCompactTokenLimit??"",onChange:u=>c(v=>({...v,modelAutoCompactTokenLimit:q(u.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(C,{onClick:()=>o(h),disabled:t||l||!w,children:[l?e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save top-level settings"]})})]})}function Gs({values:s,providerNames:r,disabled:t=!1,disabledReason:l,saving:o=!1,onSave:n}){return e.jsx(Z,{title:"Top-level controls",badge:"config.toml",icon:e.jsx(as,{className:"h-4 w-4"}),description:"Structured controls for the stable top-level Codex settings users touch most often. Unsupported upstream shapes stay untouched and should be edited in raw TOML.",disabledReason:l,children:e.jsx(Vs,{initialValues:s,providerNames:r,disabled:t,saving:o,onSave:n},JSON.stringify(s))})}function Bs({workspacePath:s,activeProfile:r,topLevelSettings:t,projectTrustEntries:l,profileEntries:o,modelProviderEntries:n,mcpServerEntries:a,featureCatalog:c,featureState:i,disabled:d,disabledReason:m,saving:p,onPatch:x}){const{t:j}=E();return e.jsx(fe,{className:"h-full",children:e.jsxs("div",{className:"space-y-6 pr-1 pb-6",children:[e.jsxs("div",{className:"group relative overflow-hidden rounded-xl border border-border/80 bg-background/50 p-5 shadow-sm transition-all hover:bg-background hover:shadow-md dark:border-border/60",children:[e.jsx("div",{className:"absolute inset-x-0 -top-px h-px bg-gradient-to-r from-transparent via-foreground/15 to-transparent transition-opacity group-hover:via-foreground/30"}),e.jsxs("div",{className:"flex flex-col gap-6 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{className:"flex-1 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary transition-colors group-hover:border-primary/30",children:e.jsx(ls,{className:"h-4 w-4"})}),e.jsx("div",{children:e.jsx("h2",{className:"text-base font-semibold tracking-tight text-foreground",children:j("codex.controlCenter")})})]}),e.jsxs("ul",{className:"grid gap-3 sm:grid-cols-2 text-sm text-muted-foreground",children:[e.jsxs("li",{className:"flex items-start gap-2.5",children:[e.jsx(is,{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(cs,{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(ds,{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(Gs,{values:t,providerNames:n.map(h=>h.name),disabled:d,disabledReason:m,saving:p,onSave:h=>x({kind:"top-level",values:h},j("toasts.codexSaved"))}),e.jsx(Is,{workspacePath:s,entries:l,disabled:d,disabledReason:m,saving:p,onSave:(h,w)=>x({kind:"project-trust",path:h,trustLevel:w},w?"Saved project trust entry.":"Removed project trust entry.")}),e.jsx(Ms,{activeProfile:r,entries:o,providerNames:n.map(h=>h.name),disabled:d,disabledReason:m,saving:p,onSave:(h,w,M)=>x({kind:"profile",action:"upsert",name:h,values:w,setAsActive:M},"Saved profile."),onDelete:h=>x({kind:"profile",action:"delete",name:h},"Deleted profile."),onSetActive:h=>x({kind:"profile",action:"set-active",name:h},"Set active profile.")}),e.jsx(Ls,{entries:n,disabled:d,disabledReason:m,saving:p,onSave:(h,w)=>x({kind:"model-provider",action:"upsert",name:h,values:w},"Saved model provider."),onDelete:h=>x({kind:"model-provider",action:"delete",name:h},"Deleted model provider.")}),e.jsx(Es,{entries:a,disabled:d,disabledReason:m,saving:p,onSave:(h,w)=>x({kind:"mcp-server",action:"upsert",name:h,values:w},"Saved MCP server."),onDelete:h=>x({kind:"mcp-server",action:"delete",name:h},"Deleted MCP server.")}),e.jsx(_s,{catalog:c,state:i,disabled:d,disabledReason:m,onToggle:(h,w)=>x({kind:"feature",feature:h,enabled:w},"Saved feature toggle.")})]})})}const De=`model_provider = "cliproxy"
|
|
2
|
+
|
|
3
|
+
[model_providers.cliproxy]
|
|
4
|
+
base_url = "http://127.0.0.1:8317/api/provider/codex"
|
|
5
|
+
env_key = "CLIPROXY_API_KEY"
|
|
6
|
+
wire_api = "responses"`,$s=["multi_agent","unified_exec","shell_snapshot","apply_patch_freeform","js_repl","runtime_metrics","prevent_idle_sleep","fast_mode","apps","smart_approvals"];function zs(){return[{name:"multi_agent",label:y.t("codex.featureMultiAgentLabel"),description:y.t("codex.featureMultiAgentDesc")},{name:"unified_exec",label:y.t("codex.featureUnifiedExecLabel"),description:y.t("codex.featureUnifiedExecDesc")},{name:"shell_snapshot",label:y.t("codex.featureShellSnapshotLabel"),description:y.t("codex.featureShellSnapshotDesc")},{name:"apply_patch_freeform",label:y.t("codex.featureApplyPatchLabel"),description:y.t("codex.featureApplyPatchDesc")},{name:"js_repl",label:y.t("codex.featureJsReplLabel"),description:y.t("codex.featureJsReplDesc")},{name:"runtime_metrics",label:y.t("codex.featureRuntimeMetricsLabel"),description:y.t("codex.featureRuntimeMetricsDesc")},{name:"prevent_idle_sleep",label:y.t("codex.featurePreventIdleSleepLabel"),description:y.t("codex.featurePreventIdleSleepDesc")},{name:"fast_mode",label:y.t("codex.featureFastModeLabel"),description:y.t("codex.featureFastModeDesc")},{name:"apps",label:y.t("codex.featureAppsLabel"),description:y.t("codex.featureAppsDesc")},{name:"smart_approvals",label:y.t("codex.featureSmartApprovalsLabel"),description:y.t("codex.featureSmartApprovalsDesc")}]}function G(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)?s:null}function T(s){return typeof s=="string"&&s.trim().length>0?s.trim():null}function Q(s){return typeof s=="number"&&Number.isFinite(s)?s:null}function ue(s){return Array.isArray(s)?s.filter(r=>typeof r=="string").map(r=>r.trim()):[]}function Le(s){return{model:T(s?.model),modelReasoningEffort:T(s?.model_reasoning_effort),modelContextWindow:Q(s?.model_context_window),modelAutoCompactTokenLimit:Q(s?.model_auto_compact_token_limit),modelProvider:T(s?.model_provider),approvalPolicy:T(s?.approval_policy),sandboxMode:T(s?.sandbox_mode),webSearch:T(s?.web_search),toolOutputTokenLimit:Q(s?.tool_output_token_limit),personality:T(s?.personality)}}function Xs(s){const r=G(s?.projects);return r?Object.entries(r).map(([t,l])=>{const o=T(G(l)?.trust_level);return o?{path:t,trustLevel:o}:null}).filter(t=>t!==null).sort((t,l)=>t.path.localeCompare(l.path)):[]}function Ys(s){const r=G(s?.profiles);return r?Object.entries(r).map(([t,l])=>({name:t,values:Le(G(l))})).sort((t,l)=>t.name.localeCompare(l.name)):[]}function Hs(s){const r=G(s?.model_providers);return r?Object.entries(r).map(([t,l])=>{const o=G(l);return o?{name:t,displayName:T(o.name),baseUrl:T(o.base_url),envKey:T(o.env_key),wireApi:T(o.wire_api),requiresOpenaiAuth:o.requires_openai_auth===!0,supportsWebsockets:o.supports_websockets===!0}:null}).filter(t=>t!==null).sort((t,l)=>t.name.localeCompare(l.name)):[]}function Qs(s){const r=G(s?.mcp_servers);return r?Object.entries(r).map(([t,l])=>{const o=G(l);if(!o)return null;const n=T(o.command)?"stdio":"streamable-http",a=Q(o.startup_timeout_ms);return{name:t,transport:n,command:T(o.command),args:ue(o.args),url:T(o.url),enabled:o.enabled!==!1,required:o.required===!0,startupTimeoutSec:Q(o.startup_timeout_sec)??(a!==null?a/1e3:null),toolTimeoutSec:Q(o.tool_timeout_sec),enabledTools:ue(o.enabled_tools),disabledTools:ue(o.disabled_tools),isCcsManaged:t==="ccs_browser",managementSurface:t==="ccs_browser"?"browser-settings":null}}).filter(t=>t!==null).sort((t,l)=>t.name.localeCompare(l.name)):[]}function Js(s){const r=G(s?.features),t={};for(const l of $s){const o=r?.[l];t[l]=typeof o=="boolean"?o:null}if(r)for(const[l,o]of Object.entries(r))l in t||(t[l]=typeof o=="boolean"?o:null);return t}const Zs=[{id:"codex-config-basic",label:"Codex Config Basics",url:"https://developers.openai.com/codex/config-basic",description:"Official user-layer setup, config location, and baseline configuration behavior."},{id:"codex-config-advanced",label:"Codex Config Advanced",url:"https://developers.openai.com/codex/config-advanced",description:"Layering, trust, profiles, and advanced config behavior."},{id:"codex-config-reference",label:"Codex Config Reference",url:"https://developers.openai.com/codex/config-reference",description:"Canonical upstream config surface for providers, MCP, features, and trust."},{id:"codex-releases",label:"Codex GitHub Releases",url:"https://github.com/openai/codex/releases",description:"Track upstream release notes and fast-moving CLI changes."}],er=[{provider:"openai",label:"OpenAI Responses API",apiFormat:"Responses API",url:"https://platform.openai.com/docs/api-reference/responses"}];function sr(s){const r=/https?:\/\/[^\s)]+/g,t=[];let l=0,o;for(;(o=r.exec(s))!==null;){const[n]=o,a=o.index;a>l&&t.push(s.slice(l,a)),t.push(e.jsx("a",{href:n,target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:n},`${n}-${a}`)),l=a+n.length}return l<s.length&&t.push(s.slice(l)),t.length>0?t:[s]}function rr({diagnostics:s}){const{t:r}=E(),t=s.docsReference??{notes:[],links:[],providerDocs:[],providerValues:[],settingsHierarchy:[]},l=t.links.length>0?t.links:Zs,o=t.providerDocs.length>0?t.providerDocs:er;return e.jsx(fe,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 pr-1",children:[e.jsxs(I,{children:[e.jsx(F,{className:"pb-2",children:e.jsxs(W,{className:"flex items-center gap-2 text-base",children:[e.jsx(me,{className:"h-4 w-4"}),"CCS bridge recipe"]})}),e.jsxs(K,{className:"space-y-3 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("p",{children:[e.jsx("strong",{children:"Built-in:"})," Use ",e.jsx("code",{children:"ccsxp"})," for the CCS provider shortcut."]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Native:"})," Configure the recipe below to use CLIProxy directly with"," ",e.jsx("code",{children:"codex"}),"."]})]}),e.jsx("pre",{className:"overflow-x-auto rounded-md border bg-muted/20 p-3 text-xs text-foreground",children:De}),e.jsxs("ol",{className:"ml-4 list-decimal space-y-1.5 [&>li]:pl-1",children:[e.jsxs("li",{children:["Save the ",e.jsx("code",{children:"cliproxy"})," provider in your user config."]}),e.jsxs("li",{children:["Set top-level ",e.jsx("code",{children:"model_provider"})," to ",e.jsx("code",{children:"cliproxy"}),"."]}),e.jsxs("li",{children:["Export ",e.jsx("code",{children:"CLIPROXY_API_KEY"})," before launching native Codex."]})]}),e.jsxs("p",{children:["CCS-managed browser tooling belongs to ",e.jsx("code",{children:"Settings > Browser"}),". Do not edit the ",e.jsx("code",{children:"ccs_browser"})," entry from the generic MCP card unless you are intentionally overriding the managed path in raw TOML."]})]})]}),e.jsxs(I,{children:[e.jsx(F,{className:"pb-2",children:e.jsxs(W,{className:"flex items-center gap-2 text-base",children:[e.jsx(me,{className:"h-4 w-4"}),"Upstream notes"]})}),e.jsxs(K,{className:"space-y-2 text-sm",children:[t.notes.length>0&&e.jsx("ul",{className:"ml-4 list-disc space-y-1.5 text-muted-foreground [&>li]:pl-1",children:t.notes.map((n,a)=>e.jsx("li",{children:sr(n)},`${a}-${n}`))}),e.jsx(ee,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:r("codex.codexDocs")}),e.jsx("div",{className:"space-y-1.5",children:l.map(n=>e.jsxs("a",{href:n.url,target:"_blank",rel:"noreferrer",className:"block rounded-md border px-2.5 py-2 transition-colors hover:bg-muted/50",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-xs font-medium",children:n.label}),e.jsx(we,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),e.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:n.description}),e.jsx("p",{className:"mt-1 break-all font-mono text-[11px] text-muted-foreground/90 underline underline-offset-2",children:n.url})]},n.id))})]}),e.jsx(ee,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:"Provider / bridge reference"}),e.jsx("div",{className:"space-y-1.5",children:o.map(n=>e.jsxs("a",{href:n.url,target:"_blank",rel:"noreferrer",className:"block rounded-md border px-2.5 py-2 transition-colors hover:bg-muted/50",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-xs font-medium",children:n.label}),e.jsx(we,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),e.jsxs("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:["provider: ",n.provider," | format: ",n.apiFormat]}),e.jsx("p",{className:"mt-1 break-all font-mono text-[11px] text-muted-foreground/90 underline underline-offset-2",children:n.url})]},`${n.provider}-${n.url}`))})]}),t.providerValues.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(ee,{}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Provider values: ",t.providerValues.join(", ")]})]}),t.settingsHierarchy.length>0&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Settings hierarchy: ",t.settingsHierarchy.join(" -> ")]})]})]})]})})}function tr(s,r){let t=s.slice(0,r).split(/\r\n|\n|\r/g);return[t.length,t.pop().length+1]}function nr(s,r,t){let l=s.split(/\r\n|\n|\r/g),o="",n=(Math.log10(r+1)|0)+1;for(let a=r-1;a<=r+1;a++){let c=l[a-1];c&&(o+=a.toString().padEnd(n," "),o+=": ",o+=c,o+=`
|
|
7
|
+
`,a===r&&(o+=" ".repeat(n+t+2),o+=`^
|
|
8
|
+
`))}return o}class f extends Error{line;column;codeblock;constructor(r,t){const[l,o]=tr(t.toml,t.ptr),n=nr(t.toml,l,o);super(`Invalid TOML document: ${r}
|
|
9
|
+
|
|
10
|
+
${n}`,t),this.line=l,this.column=o,this.codeblock=n}}function ar(s,r){let t=0;for(;s[r-++t]==="\\";);return--t&&t%2}function pe(s,r=0,t=s.length){let l=s.indexOf(`
|
|
11
|
+
`,r);return s[l-1]==="\r"&&l--,l<=t?l:-1}function te(s,r){for(let t=r;t<s.length;t++){let l=s[t];if(l===`
|
|
12
|
+
`)return t;if(l==="\r"&&s[t+1]===`
|
|
13
|
+
`)return t+1;if(l<" "&&l!==" "||l==="")throw new f("control characters are not allowed in comments",{toml:s,ptr:r})}return s.length}function V(s,r,t,l){let o;for(;;){for(;(o=s[r])===" "||o===" "||!t&&(o===`
|
|
14
|
+
`||o==="\r"&&s[r+1]===`
|
|
15
|
+
`);)r++;if(l||o!=="#")break;r=te(s,r)}return r}function or(s,r,t,l,o=!1){if(!l)return r=pe(s,r),r<0?s.length:r;for(let n=r;n<s.length;n++){let a=s[n];if(a==="#")n=pe(s,n);else{if(a===t)return n+1;if(a===l||o&&(a===`
|
|
16
|
+
`||a==="\r"&&s[n+1]===`
|
|
17
|
+
`))return n}}throw new f("cannot find end of structure",{toml:s,ptr:r})}function Ae(s,r){let t=s[r],l=t===s[r+1]&&s[r+1]===s[r+2]?s.slice(r,r+3):t;r+=l.length-1;do r=s.indexOf(l,++r);while(r>-1&&t!=="'"&&ar(s,r));return r>-1&&(r+=l.length,l.length>1&&(s[r]===t&&r++,s[r]===t&&r++)),r}let lr=/^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;class H extends Date{#s=!1;#r=!1;#e=null;constructor(r){let t=!0,l=!0,o="Z";if(typeof r=="string"){let n=r.match(lr);n?(n[1]||(t=!1,r=`0000-01-01T${r}`),l=!!n[2],l&&r[10]===" "&&(r=r.replace(" ","T")),n[2]&&+n[2]>23?r="":(o=n[3]||null,r=r.toUpperCase(),!o&&l&&(r+="Z"))):r=""}super(r),isNaN(this.getTime())||(this.#s=t,this.#r=l,this.#e=o)}isDateTime(){return this.#s&&this.#r}isLocal(){return!this.#s||!this.#r||!this.#e}isDate(){return this.#s&&!this.#r}isTime(){return this.#r&&!this.#s}isValid(){return this.#s||this.#r}toISOString(){let r=super.toISOString();if(this.isDate())return r.slice(0,10);if(this.isTime())return r.slice(11,23);if(this.#e===null)return r.slice(0,-1);if(this.#e==="Z")return r;let t=+this.#e.slice(1,3)*60+ +this.#e.slice(4,6);return t=this.#e[0]==="-"?t:-t,new Date(this.getTime()-t*6e4).toISOString().slice(0,-1)+this.#e}static wrapAsOffsetDateTime(r,t="Z"){let l=new H(r);return l.#e=t,l}static wrapAsLocalDateTime(r){let t=new H(r);return t.#e=null,t}static wrapAsLocalDate(r){let t=new H(r);return t.#r=!1,t.#e=null,t}static wrapAsLocalTime(r){let t=new H(r);return t.#s=!1,t.#e=null,t}}let ir=/^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/,cr=/^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/,dr=/^[+-]?0[0-9_]/,xr=/^[0-9a-f]{2,8}$/i,Te={b:"\b",t:" ",n:`
|
|
18
|
+
`,f:"\f",r:"\r",e:"\x1B",'"':'"',"\\":"\\"};function Me(s,r=0,t=s.length){let l=s[r]==="'",o=s[r++]===s[r]&&s[r]===s[r+1];o&&(t-=2,s[r+=2]==="\r"&&r++,s[r]===`
|
|
19
|
+
`&&r++);let n=0,a,c="",i=r;for(;r<t-1;){let d=s[r++];if(d===`
|
|
20
|
+
`||d==="\r"&&s[r]===`
|
|
21
|
+
`){if(!o)throw new f("newlines are not allowed in strings",{toml:s,ptr:r-1})}else if(d<" "&&d!==" "||d==="")throw new f("control characters are not allowed in strings",{toml:s,ptr:r-1});if(a){if(a=!1,d==="x"||d==="u"||d==="U"){let m=s.slice(r,r+=d==="x"?2:d==="u"?4:8);if(!xr.test(m))throw new f("invalid unicode escape",{toml:s,ptr:n});try{c+=String.fromCodePoint(parseInt(m,16))}catch{throw new f("invalid unicode escape",{toml:s,ptr:n})}}else if(o&&(d===`
|
|
22
|
+
`||d===" "||d===" "||d==="\r")){if(r=V(s,r-1,!0),s[r]!==`
|
|
23
|
+
`&&s[r]!=="\r")throw new f("invalid escape: only line-ending whitespace may be escaped",{toml:s,ptr:n});r=V(s,r)}else if(d in Te)c+=Te[d];else throw new f("unrecognized escape sequence",{toml:s,ptr:n});i=r}else!l&&d==="\\"&&(n=r-1,a=!0,c+=s.slice(i,n))}return c+s.slice(i,t-1)}function ur(s,r,t,l){if(s==="true")return!0;if(s==="false")return!1;if(s==="-inf")return-1/0;if(s==="inf"||s==="+inf")return 1/0;if(s==="nan"||s==="+nan"||s==="-nan")return NaN;if(s==="-0")return l?0n:0;let o=ir.test(s);if(o||cr.test(s)){if(dr.test(s))throw new f("leading zeroes are not allowed",{toml:r,ptr:t});s=s.replace(/_/g,"");let a=+s;if(isNaN(a))throw new f("invalid number",{toml:r,ptr:t});if(o){if((o=!Number.isSafeInteger(a))&&!l)throw new f("integer value cannot be represented losslessly",{toml:r,ptr:t});(o||l===!0)&&(a=BigInt(s))}return a}const n=new H(s);if(!n.isValid())throw new f("invalid value",{toml:r,ptr:t});return n}function mr(s,r,t){let l=s.slice(r,t),o=l.indexOf("#");return o>-1&&(te(s,o),l=l.slice(0,o)),[l.trimEnd(),o]}function ge(s,r,t,l,o){if(l===0)throw new f("document contains excessively nested structures. aborting.",{toml:s,ptr:r});let n=s[r];if(n==="["||n==="{"){let[i,d]=n==="["?fr(s,r,l,o):hr(s,r,l,o);if(t){if(d=V(s,d),s[d]===",")d++;else if(s[d]!==t)throw new f("expected comma or end of structure",{toml:s,ptr:d})}return[i,d]}let a;if(n==='"'||n==="'"){a=Ae(s,r);let i=Me(s,r,a);if(t){if(a=V(s,a),s[a]&&s[a]!==","&&s[a]!==t&&s[a]!==`
|
|
24
|
+
`&&s[a]!=="\r")throw new f("unexpected character encountered",{toml:s,ptr:a});a+=+(s[a]===",")}return[i,a]}a=or(s,r,",",t);let c=mr(s,r,a-+(s[a-1]===","));if(!c[0])throw new f("incomplete key-value declaration: no value specified",{toml:s,ptr:r});return t&&c[1]>-1&&(a=V(s,r+c[1]),a+=+(s[a]===",")),[ur(c[0],s,r,o),a]}let pr=/^[a-zA-Z0-9-_]+[ \t]*$/;function he(s,r,t="="){let l=r-1,o=[],n=s.indexOf(t,r);if(n<0)throw new f("incomplete key-value: cannot find end of key",{toml:s,ptr:r});do{let a=s[r=++l];if(a!==" "&&a!==" ")if(a==='"'||a==="'"){if(a===s[r+1]&&a===s[r+2])throw new f("multiline strings are not allowed in keys",{toml:s,ptr:r});let c=Ae(s,r);if(c<0)throw new f("unfinished string encountered",{toml:s,ptr:r});l=s.indexOf(".",c);let i=s.slice(c,l<0||l>n?n:l),d=pe(i);if(d>-1)throw new f("newlines are not allowed in keys",{toml:s,ptr:r+l+d});if(i.trimStart())throw new f("found extra tokens after the string part",{toml:s,ptr:c});if(n<c&&(n=s.indexOf(t,c),n<0))throw new f("incomplete key-value: cannot find end of key",{toml:s,ptr:r});o.push(Me(s,r,c))}else{l=s.indexOf(".",r);let c=s.slice(r,l<0||l>n?n:l);if(!pr.test(c))throw new f("only letter, numbers, dashes and underscores are allowed in keys",{toml:s,ptr:r});o.push(c.trimEnd())}}while(l+1&&l<n);return[o,V(s,n+1,!0,!0)]}function hr(s,r,t,l){let o={},n=new Set,a;for(r++;(a=s[r++])!=="}"&&a;){if(a===",")throw new f("expected value, found comma",{toml:s,ptr:r-1});if(a==="#")r=te(s,r);else if(a!==" "&&a!==" "&&a!==`
|
|
25
|
+
`&&a!=="\r"){let c,i=o,d=!1,[m,p]=he(s,r-1);for(let h=0;h<m.length;h++){if(h&&(i=d?i[c]:i[c]={}),c=m[h],(d=Object.hasOwn(i,c))&&(typeof i[c]!="object"||n.has(i[c])))throw new f("trying to redefine an already defined value",{toml:s,ptr:r});!d&&c==="__proto__"&&Object.defineProperty(i,c,{enumerable:!0,configurable:!0,writable:!0})}if(d)throw new f("trying to redefine an already defined value",{toml:s,ptr:r});let[x,j]=ge(s,p,"}",t-1,l);n.add(x),i[c]=x,r=j}}if(!a)throw new f("unfinished table encountered",{toml:s,ptr:r});return[o,r]}function fr(s,r,t,l){let o=[],n;for(r++;(n=s[r++])!=="]"&&n;){if(n===",")throw new f("expected value, found comma",{toml:s,ptr:r-1});if(n==="#")r=te(s,r);else if(n!==" "&&n!==" "&&n!==`
|
|
26
|
+
`&&n!=="\r"){let a=ge(s,r-1,"]",t-1,l);o.push(a[0]),r=a[1]}}if(!n)throw new f("unfinished array encountered",{toml:s,ptr:r});return[o,r]}function Ee(s,r,t,l){let o=r,n=t,a,c=!1,i;for(let d=0;d<s.length;d++){if(d){if(o=c?o[a]:o[a]={},n=(i=n[a]).c,l===0&&(i.t===1||i.t===2))return null;if(i.t===2){let m=o.length-1;o=o[m],n=n[m].c}}if(a=s[d],(c=Object.hasOwn(o,a))&&n[a]?.t===0&&n[a]?.d)return null;c||(a==="__proto__"&&(Object.defineProperty(o,a,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(n,a,{enumerable:!0,configurable:!0,writable:!0})),n[a]={t:d<s.length-1&&l===2?3:l,d:!1,i:0,c:{}})}if(i=n[a],i.t!==l&&!(l===1&&i.t===3)||(l===2&&(i.d||(i.d=!0,o[a]=[]),o[a].push(o={}),i.c[i.i++]=i={t:1,d:!1,i:0,c:{}}),i.d))return null;if(i.d=!0,l===1)o=c?o[a]:o[a]={};else if(l===0&&c)return null;return[a,o,i.c]}function gr(s,{maxDepth:r=1e3,integersAsBigInt:t}={}){let l={},o={},n=l,a=o;for(let c=V(s,0);c<s.length;){if(s[c]==="["){let i=s[++c]==="[",d=he(s,c+=+i,"]");if(i){if(s[d[1]-1]!=="]")throw new f("expected end of table declaration",{toml:s,ptr:d[1]-1});d[1]++}let m=Ee(d[0],l,o,i?2:1);if(!m)throw new f("trying to redefine an already defined table or value",{toml:s,ptr:c});a=m[2],n=m[1],c=d[1]}else{let i=he(s,c),d=Ee(i[0],n,a,0);if(!d)throw new f("trying to redefine an already defined table or value",{toml:s,ptr:c});let m=ge(s,i[1],void 0,r,t);d[1][d[0]]=m[0],c=m[1]}if(c=V(s,c,!0),s[c]&&s[c]!==`
|
|
27
|
+
`&&s[c]!=="\r")throw new f("each key-value declaration must be followed by an end-of-line",{toml:s,ptr:c});c=V(s,c)}return l}function jr(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)}function vr(s){if(!s.trim())return{};const t=gr(s);if(!jr(t))throw new Error("TOML root must be a table.");return t}function Re(s){try{return{config:vr(s),parseError:null}}catch(r){return{config:null,parseError:r.message}}}async function br(){const s=await fetch(se("/codex/diagnostics"));if(!s.ok)throw new Error("Failed to fetch Codex diagnostics");return s.json()}async function wr(){const s=await fetch(se("/codex/config/raw"));if(!s.ok)throw new Error("Failed to fetch Codex raw config");return s.json()}async function Nr(s){const r=await fetch(se("/codex/config/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(r.status===409)throw new Pe("Codex raw config changed externally");if(!r.ok){const t=await r.json().catch(()=>null);throw new Error(t?.error||"Failed to save Codex raw config")}return r.json()}async function yr(s){const r=await fetch(se("/codex/config/patch"),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(r.status===409)throw new Pe("Codex config changed externally");if(!r.ok){const t=await r.json().catch(()=>null);throw new Error(t?.error||"Failed to patch Codex config")}return r.json()}function Cr(){const s=ws(),r=ye({queryKey:["codex-diagnostics"],queryFn:br,refetchInterval:1e4}),t=ye({queryKey:["codex-raw-config"],queryFn:wr}),l=Ce({mutationFn:Nr,onSuccess:(n,a)=>{s.setQueryData(["codex-raw-config"],c=>{const i=c?.path??"$CODEX_HOME/config.toml",d=c?.resolvedPath??i,m=Re(a.rawText);return{path:i,resolvedPath:d,exists:!0,mtime:n.mtime,rawText:a.rawText,config:m.config,parseError:m.parseError,readError:null}}),s.invalidateQueries({queryKey:["codex-diagnostics"]})}}),o=Ce({mutationFn:yr,onSuccess:n=>{s.setQueryData(["codex-raw-config"],n),s.invalidateQueries({queryKey:["codex-diagnostics"]})}});return N.useMemo(()=>({diagnostics:r.data,diagnosticsLoading:r.isLoading,diagnosticsError:r.error,refetchDiagnostics:r.refetch,rawConfig:t.data,rawConfigLoading:t.isLoading,rawConfigError:t.error,refetchRawConfig:t.refetch,saveRawConfig:l.mutate,saveRawConfigAsync:l.mutateAsync,isSavingRawConfig:l.isPending,patchConfig:o.mutate,patchConfigAsync:o.mutateAsync,isPatchingConfig:o.isPending}),[r.data,r.isLoading,r.error,r.refetch,t.data,t.isLoading,t.error,t.refetch,l.mutate,l.mutateAsync,l.isPending,o.mutate,o.mutateAsync,o.isPending])}const Sr=[{label:"Start Default",command:"ccs",description:"Launch Claude with default profile"},{label:"GLM Profile",command:"ccs glm",description:"Switch to GLM model"},{label:"Health Check",command:"ccs doctor",description:"Run system diagnostics"},{label:"Delegate Task",command:'ccs glm -p "your task"',description:"Delegate to GLM profile"}];function _r({snippets:s=Sr}){const[r,t]=N.useState(null),{t:l}=E(),o=async(n,a)=>{await navigator.clipboard.writeText(n),t(a),setTimeout(()=>t(null),2e3)};return e.jsxs(I,{children:[e.jsx(F,{className:"pb-3",children:e.jsxs(W,{className:"text-lg flex items-center gap-2",children:[e.jsx(xs,{className:"w-5 h-5 text-muted-foreground"}),l("quickCommands.title")]})}),e.jsx(K,{children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:s.map((n,a)=>e.jsxs("div",{className:Oe("group flex items-center justify-between gap-2 px-3 py-2","rounded-lg border bg-muted/30 hover:bg-muted/50 transition-colors"),children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:n.label}),e.jsx("code",{className:"text-sm font-mono font-medium truncate block",children:n.command})]}),e.jsx(C,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>o(n.command,a),title:n.description,children:r===a?e.jsx(us,{className:"h-4 w-4 text-green-600"}):e.jsx(ms,{className:"h-4 w-4"})})]},a))})})]})}function kr(s){return!s||!Number.isFinite(s)?"N/A":new Date(s).toLocaleString()}function Tr(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 k({label:s,value:r,mono:t=!1}){return e.jsxs("div",{className:"flex items-start justify-between gap-3 text-sm",children:[e.jsx("span",{className:"text-muted-foreground shrink-0",children:s}),e.jsx("span",{className:Oe("text-right break-all",t&&"font-mono text-xs"),children:r})]})}function Er({diagnostics:s}){const{t:r}=E(),t=s.config.activeProfile?`codex --profile ${s.config.activeProfile}`:"codex",l=s.binary.supportsConfigOverrides;return e.jsx(fe,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 pr-1",children:[e.jsxs(I,{children:[e.jsx(F,{className:"pb-2",children:e.jsxs(W,{className:"flex items-center gap-2 text-base",children:[e.jsx(ps,{className:"h-4 w-4"}),r("codex.howCodexWorks")]})}),e.jsx(K,{className:"text-sm text-muted-foreground",children:e.jsxs("ul",{className:"ml-4 list-disc space-y-1.5 [&>li]:pl-1",children:[e.jsx("li",{children:r("codex.nativeDesc")}),e.jsxs("li",{children:[e.jsx("strong",{children:r("codex.nativeConfigLabel")})," ",r("codex.nativeConfigDesc")]}),e.jsxs("li",{children:[e.jsx("strong",{children:r("codex.transientOverridesLabel")})," ",r("codex.transientOverridesDesc")]}),e.jsxs("li",{children:[e.jsx("strong",{children:r("codex.cliproxyDefaultLabel")})," ",r("codex.cliproxyDefaultDesc")]}),e.jsx("li",{children:r("codex.apiProfilesDefault")})]})})]}),e.jsxs(I,{children:[e.jsx(F,{className:"pb-2",children:e.jsxs(W,{className:"flex items-center gap-2 text-base",children:[e.jsx(hs,{className:"h-4 w-4"}),r("codex.runtimeInstall")]})}),e.jsxs(K,{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:r("codex.status")}),e.jsx(_,{variant:s.binary.installed?"default":"secondary",children:s.binary.installed?r("codex.detected"):r("codex.notFound")})]}),e.jsx(k,{label:r("codex.detectionSource"),value:s.binary.source,mono:!0}),e.jsx(k,{label:r("codex.binaryPath"),value:s.binary.path||r("codex.notFound"),mono:!0}),e.jsx(k,{label:r("codex.installDirectory"),value:s.binary.installDir||"N/A",mono:!0}),e.jsx(k,{label:r("codex.versionLabel"),value:s.binary.version||"Unknown",mono:!0}),e.jsx(k,{label:r("codex.nativeAliases"),value:"ccs-codex, ccsx",mono:!0}),e.jsx(k,{label:r("codex.ccsProviderShortcut"),value:"ccsxp",mono:!0}),e.jsxs("div",{className:"flex items-center justify-between rounded-md border px-3 py-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:r("codex.configOverrideSupport")}),e.jsx(_,{variant:s.binary.supportsConfigOverrides?"default":"secondary",children:s.binary.supportsConfigOverrides?r("codex.available"):r("codex.missing")})]})]})]}),e.jsxs(I,{children:[e.jsx(F,{className:"pb-2",children:e.jsxs(W,{className:"flex items-center gap-2 text-base",children:[e.jsx(Ne,{className:"h-4 w-4"}),r("codex.cliproxyNativeCodex")]})}),e.jsx(K,{className:"space-y-3 text-sm text-muted-foreground",children:l?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{children:e.jsx("strong",{children:r("codex.twoSupportedPaths")})}),e.jsxs("ul",{className:"ml-4 list-disc space-y-1 [&>li]:pl-1",children:[e.jsxs("li",{children:[e.jsx("strong",{children:r("codex.builtInLabel")})," ",r("codex.builtInCcsxpDesc")]}),e.jsxs("li",{children:[e.jsx("strong",{children:r("codex.nativeRecipeLabel")})," ",r("codex.nativeRecipeDesc")]})]})]}),e.jsxs("div",{className:"rounded-md border bg-muted/20 p-3",children:[e.jsx("p",{className:"font-medium text-foreground",children:r("codex.codexNativeRecipe")}),e.jsx("pre",{className:"mt-2 overflow-x-auto rounded-md bg-background p-3 text-xs text-foreground",children:De})]}),e.jsxs("ol",{className:"ml-4 list-decimal space-y-1.5 [&>li]:pl-1",children:[e.jsx("li",{children:r("codex.saveProviderNamedCliproxy")}),e.jsx("li",{children:r("codex.inTopLevelSetDefault")}),e.jsx("li",{children:r("codex.exportCliproxyApiKey")})]})]}):e.jsx("p",{children:r("codex.noConfigOverrides")})})]}),e.jsxs(I,{children:[e.jsx(F,{className:"pb-2",children:e.jsxs(W,{className:"flex items-center gap-2 text-base",children:[e.jsx(fs,{className:"h-4 w-4"}),r("codex.configFile")]})}),e.jsx(K,{className:"space-y-3",children:e.jsxs("div",{className:"rounded-md border p-3 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"font-medium text-sm",children:r("codex.userConfig")}),s.file.exists?e.jsx(gs,{className:"h-4 w-4 text-green-600"}):e.jsx(js,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(k,{label:r("codex.path"),value:s.file.path,mono:!0}),e.jsx(k,{label:r("codex.resolved"),value:s.file.resolvedPath,mono:!0}),e.jsx(k,{label:r("codex.size"),value:Tr(s.file.sizeBytes)}),e.jsx(k,{label:r("codex.lastModified"),value:kr(s.file.mtimeMs)}),s.file.parseError&&e.jsxs("p",{className:"text-xs text-amber-600",children:[r("codex.tomlWarning"),": ",s.file.parseError]}),s.file.readError&&e.jsxs("p",{className:"text-xs text-destructive",children:[r("codex.readWarning"),": ",s.file.readError]})]})})]}),e.jsxs(I,{children:[e.jsx(F,{className:"pb-2",children:e.jsxs(W,{className:"flex items-center gap-2 text-base",children:[e.jsx(me,{className:"h-4 w-4"}),r("codex.currentUserLayerSummary")]})}),e.jsxs(K,{className:"space-y-3",children:[e.jsx(k,{label:r("codex.model"),value:s.config.model||r("codex.notSet"),mono:!0}),e.jsx(k,{label:r("codex.defaultProvider"),value:s.config.modelProvider||r("codex.notSet"),mono:!0}),e.jsx(k,{label:r("codex.activeProfile"),value:s.config.activeProfile||r("codex.notSet"),mono:!0}),e.jsx(k,{label:r("codex.approvalPolicy"),value:s.config.approvalPolicy||r("codex.notSet"),mono:!0}),e.jsx(k,{label:r("codex.sandboxMode"),value:s.config.sandboxMode||r("codex.notSet"),mono:!0}),e.jsx(k,{label:r("codex.webSearch"),value:s.config.webSearch||r("codex.notSet"),mono:!0}),e.jsx(ee,{}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[e.jsx(_,{variant:"outline",className:"justify-center",children:r("codex.providersCount",{count:s.config.modelProviderCount})}),e.jsx(_,{variant:"outline",className:"justify-center",children:r("codex.profilesCount",{count:s.config.profileCount})}),e.jsx(_,{variant:"outline",className:"justify-center",children:r("codex.enabledFeaturesCount",{count:s.config.enabledFeatures.length})}),e.jsx(_,{variant:"outline",className:"justify-center",children:r("codex.mcpServersCount",{count:s.config.mcpServerCount})})]}),s.config.topLevelKeys.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:r("codex.userLayerKeysPresent")}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.config.topLevelKeys.map(o=>e.jsx(_,{variant:"secondary",className:"font-mono text-[10px]",children:o},o))})]})]})]}),e.jsx(_r,{snippets:[{label:r("codex.nativeShortAlias"),command:"ccsx",description:"Launch the short native Codex runtime alias."},{label:r("codex.ccsCodexShortcut"),command:'ccsxp "your prompt"',description:l?r("codex.runBuiltInCodex"):"Requires a Codex build that exposes --config overrides."},{label:r("codex.explicitProviderRoute"),command:'ccs codex --target codex "your prompt"',description:l?r("codex.runBuiltInCodexExplicit"):"Requires a Codex build that exposes --config overrides."},{label:s.config.activeProfile?"Inspect active profile":r("codex.openNativeCodex"),command:t,description:s.config.activeProfile?"Inspect the active named profile directly in native Codex.":"Open native Codex without forcing a named profile overlay."}]}),e.jsxs(I,{children:[e.jsx(F,{className:"pb-2",children:e.jsxs(W,{className:"flex items-center gap-2 text-base",children:[e.jsx(Ne,{className:"h-4 w-4"}),r("codex.runtimeVsProvider")]})}),e.jsxs(K,{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("div",{className:"flex flex-col rounded-md border p-3 text-sm",children:[e.jsx("p",{className:"font-medium text-foreground",children:r("codex.nativeCodexRuntime")}),e.jsxs("ul",{className:"mt-2 flex-grow list-disc space-y-1.5 pl-4 text-muted-foreground [&>li]:pl-1",children:[e.jsx("li",{children:e.jsx("code",{children:"ccs-codex"})}),e.jsx("li",{children:e.jsx("code",{children:"ccsx"})}),e.jsx("li",{children:e.jsx("code",{children:"--target codex"})})]}),e.jsx(_,{variant:"secondary",className:"mt-4 w-fit justify-center font-normal",children:r("codex.honorsSavedNativeConfig")})]}),e.jsxs("div",{className:"flex flex-col rounded-md border p-3 text-sm",children:[e.jsx("p",{className:"font-medium text-foreground",children:r("codex.ccsCodexProvider")}),l?e.jsxs(e.Fragment,{children:[e.jsxs("ul",{className:"mt-2 flex-grow list-disc space-y-1.5 pl-4 text-muted-foreground [&>li]:pl-1",children:[e.jsx("li",{children:e.jsx("code",{children:"ccsxp"})}),e.jsx("li",{children:e.jsx("code",{children:"ccs codex --target codex"})})]}),e.jsx(_,{variant:"secondary",className:"mt-4 w-fit justify-center font-normal",children:r("codex.usesTransientOverrides")})]}):e.jsx("p",{className:"mt-2 text-muted-foreground",children:r("codex.unavailableNoConfig")})]})]})]}),e.jsxs(I,{children:[e.jsx(F,{className:"pb-2",children:e.jsx(W,{className:"text-base",children:r("codex.supportedFlows")})}),e.jsx(K,{children:e.jsxs(Ns,{children:[e.jsx(ys,{children:e.jsxs(Se,{children:[e.jsx(le,{children:r("codex.flow")}),e.jsx(le,{children:r("codex.status")}),e.jsx(le,{children:r("codex.notes")})]})}),e.jsx(Cs,{children:s.supportMatrix.map(o=>e.jsxs(Se,{children:[e.jsx(ie,{className:"font-mono text-xs",children:o.label}),e.jsx(ie,{children:e.jsx(_,{variant:o.supported?"default":"secondary",children:o.supported?r("codex.yes"):r("codex.no")})}),e.jsx(ie,{className:"text-xs text-muted-foreground",children:o.notes})]},o.id))})]})})]}),s.warnings.length>0&&e.jsxs(I,{className:"border-amber-200 bg-amber-50/50 dark:bg-amber-950/20",children:[e.jsx(F,{className:"pb-2",children:e.jsxs(W,{className:"flex items-center gap-2 text-base",children:[e.jsx(vs,{className:"h-4 w-4 text-amber-600"}),r("codex.warningsTitle")]})}),e.jsx(K,{className:"space-y-1.5",children:s.warnings.map(o=>e.jsxs("p",{className:"text-sm text-amber-800 dark:text-amber-300",children:["- ",o]},o))})]})]})})}function Ur(){const{t:s}=E(),r=zs(),{diagnostics:t,diagnosticsLoading:l,diagnosticsError:o,refetchDiagnostics:n,rawConfig:a,rawConfigLoading:c,rawConfigError:i,refetchRawConfig:d,saveRawConfigAsync:m,isSavingRawConfig:p,patchConfigAsync:x,isPatchingConfig:j}=Cr(),[h,w]=N.useState(null),M=a?.rawText??"",q=h??M,u=h!==null&&h!==M,v=Re(q),B=v.parseError?{valid:!1,error:v.parseError}:{valid:!0},g=a?.config??null,Ie=c||!a||u||a?.parseError!==null||a?.readError!==null,Fe=i?"Structured controls unavailable: failed to load the current config.toml.":a?.readError?`Structured controls unavailable: ${a.readError}`:u?B.valid?"Save or discard raw TOML edits before using structured controls.":"Fix or discard raw TOML edits before using structured controls.":a?.parseError?`Structured controls disabled: ${a.parseError}`:null,We=N.useMemo(()=>Le(g),[g]),Ke=N.useMemo(()=>Xs(g),[g]),qe=N.useMemo(()=>Ys(g),[g]),Ue=N.useMemo(()=>Hs(g),[g]),Ve=N.useMemo(()=>Qs(g),[g]),Ge=N.useMemo(()=>Js(g),[g]),Be=R=>{if(R===M){w(null);return}w(R)},$e=async()=>{try{if((await Promise.all([n(),d()])).some($=>!$||$.status==="error"||$.isError||$.error)){U.error(s("toasts.codexRefreshFailed"));return}w(null)}catch(R){U.error(R.message||s("toasts.codexRefreshError"))}},ze=async()=>{if(!B.valid){U.error(s("toasts.codexFixToml"));return}try{await m({rawText:q,expectedMtime:a?.exists?a.mtime:void 0}),w(null),U.success(s("toasts.codexSaved")),await n()}catch(R){be(R)?U.error(s("toasts.codexChangedExternally")):U.error(R.message||s("toasts.codexSaveFailed"))}},Xe=async(R,je)=>{try{await x({...R,expectedMtime:a?.exists?a.mtime:void 0}),w(null),U.success(je)}catch($){be($)?U.error(s("toasts.codexChangedExternally")):U.error($.message||s("toasts.codexUpdateFailed"))}},ne="mt-0 h-full border-0 p-0 data-[state=inactive]:hidden",Ye=()=>l?e.jsxs("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:[e.jsx(z,{className:"mr-2 h-5 w-5 animate-spin"}),"Loading Codex diagnostics..."]}):o||!t?e.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center text-destructive",children:"Failed to load Codex diagnostics."}):e.jsxs(Je,{defaultValue:"overview",className:"flex h-full flex-col",children:[e.jsx("div",{className:"shrink-0 px-4 pt-4",children:e.jsxs(Ze,{className:"grid w-full grid-cols-3",children:[e.jsx(ae,{value:"overview",children:s("codexPage.overview")}),e.jsx(ae,{value:"controls",children:s("codexPage.controlCenter")}),e.jsx(ae,{value:"docs",children:s("codexPage.docs")})]})}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden px-4 pb-4 pt-3",children:[e.jsx(oe,{value:"overview",className:ne,children:e.jsx(Er,{diagnostics:t})}),e.jsx(oe,{value:"controls",className:ne,children:e.jsx(Bs,{workspacePath:t.workspacePath,activeProfile:t.config.activeProfile,topLevelSettings:We,projectTrustEntries:Ke,profileEntries:qe,modelProviderEntries:Ue,mcpServerEntries:Ve,featureCatalog:r,featureState:Ge,disabled:Ie,disabledReason:Fe,saving:j,onPatch:Xe})}),e.jsx(oe,{value:"docs",className:ne,children:e.jsx(rr,{diagnostics:t})})]})]});return e.jsx("div",{className:"h-full min-h-0 overflow-hidden",children:e.jsxs(He,{direction:"horizontal",className:"h-full",children:[e.jsx(ve,{defaultSize:45,minSize:35,children:e.jsx("div",{className:"h-full border-r bg-muted/20",children:Ye()})}),e.jsx(Qe,{className:"group flex w-2 cursor-col-resize items-center justify-center bg-border transition-colors hover:bg-primary/20",children:e.jsx(bs,{className:"h-3 w-3 text-muted-foreground group-hover:text-primary"})}),e.jsx(ve,{defaultSize:55,minSize:35,children:e.jsx(Ss,{title:"Codex config.toml",pathLabel:a?.path||t?.file.path||"$CODEX_HOME/config.toml",loading:c,parseWarning:B.valid?a?.parseError:B.error,readWarning:a?.readError,value:q,dirty:u,readOnly:!!a?.readError,saving:p,saveDisabled:!u||p||c||!B.valid||!!a?.readError,onChange:R=>{Be(R)},onSave:ze,onRefresh:$e,onDiscard:()=>w(null),language:"toml",loadingLabel:"Loading config.toml...",parseWarningLabel:"TOML warning",ownershipNotice:e.jsxs("div",{className:"rounded-md border border-amber-200 bg-amber-50/60 px-3 py-2 text-sm text-amber-900 dark:bg-amber-950/20 dark:text-amber-300",children:[e.jsx("p",{className:"font-medium",children:"This file is upstream-owned by Codex CLI."}),e.jsxs("p",{children:["CCS does not keep ",e.jsx("code",{children:"~/.codex/config.toml"})," in sync for you."]}),e.jsxs("p",{children:["CCS-backed Codex launches may apply transient ",e.jsx("code",{children:"-c"})," overrides and",e.jsx("code",{children:" CCS_CODEX_API_KEY"}),"; those effective values may not appear here."]})]})})})]})})}export{Ur as CodexPage};
|