diff --git a/deploy/README.md b/deploy/README.md index 620ad50ad..388685b19 100644 --- a/deploy/README.md +++ b/deploy/README.md @@ -625,11 +625,28 @@ Caddy 与应用同在容器网络时,将回源地址改为 `codex-proxy-rs:808 直接发送 HTTP 请求时,参见 [Messages 示例](../docs/api.md#messages-请求)和 [GenAI 接口与鉴权](../docs/api.md#antigravity-客户端原生生成) -使用 Codex 时,打开「使用密钥」,按操作系统复制 `config.toml`。 +在密钥列表点「使用密钥」,或在密钥用量页点「配置」,按平台切换 Codex(OpenAI)、Grok Build(xAI)和 Antigravity,再选择操作系统复制配置。Codex 和 Grok Build 模板使用固定模型,可在复制后改为密钥可用的型号 + +Antigravity 桌面版与 CLI 共用 `~/.gemini/config/config.json`(Windows 为 `%USERPROFILE%\.gemini\config\config.json`): + +1. 如 CLI 仍登录旧 Google 账号,在 `agy` 中输入 `/logout`,回到登录选择页后按 Ctrl+C 退出 +2. 在 macOS/Linux 用以下命令准备文件。将弹窗中的 JSON 写入空文件;已有配置只合并或更新顶层 `gateway`,保留 `plugins`、`sidecars`、`userSettings` 等字段 + + ```sh + mkdir -p ~/.gemini/config + touch ~/.gemini/config/config.json + chmod 600 ~/.gemini/config/config.json + ``` + +3. `gateway.url` 填网关根地址,子路径部署保留部署前缀。使用 `genai` 时客户端会追加 `/v1beta/models` +4. 完全退出并重新打开桌面版。CLI 可用 `agy models` 查看目录,运行 `agy` 后输入 `/model` 选择模型 + +使用 Codex 时,按操作系统复制 `config.toml`。 已有配置先备份,合并后完全退出并重启 Codex。代理密钥由 Provider 配置提供, 不需要另写 `auth.json`,已有官方登录文件可以保留 -管理端生成的 CC Switch 一键导入包含连接信息和当前 Key 的日/周额度查询,默认每 30 分钟刷新。 +点「导入到」后选择 CC Switch,导入当前平台的客户端配置和日/周额度查询,默认每 30 分钟刷新。密钥列表的更多菜单和密钥创建成功弹窗也支持直接导入,可在工具选择框切换平台。 +Antigravity 导入为 CC Switch 的 CLI 供应商卡片,模型使用显示名 `Gemini 4 Neon (High)`,从卡片打开终端即可使用。桌面版和独立启动的 CLI 使用上面的共享网关配置。 查询地址和凭据随导入生成,在 CC Switch 中修改 Provider 的地址或 Key 后,需重新导入以同步用量查询。 导入不包含下方模板的远程压缩、异步压缩、原生生图、WebSocket 和语音设置。需要这些设置时,使用下方配置直连 CPR, 避免 CC Switch 切换或接管后重写 Provider 配置 @@ -644,8 +661,8 @@ Linux/macOS 默认目录为 `~/.codex/`,Windows 为 `%USERPROFILE%\.codex\`; ```toml model_provider = "OpenAI" -model = "gpt-5.6-terra" -review_model = "gpt-5.6-terra" +model = "gpt-6-luna" +review_model = "gpt-6-luna" model_reasoning_effort = "max" service_tier = "default" # 语音通话控制地址 diff --git a/docs/architecture.md b/docs/architecture.md index 12a4c71c4..a5010c437 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -1042,7 +1042,7 @@ KeyUsageService 从 AuthService 的服务端身份或 Core 的入口认证结果 ObservabilityStore 的范围查询;数据面额度查询不执行推理准入或开启窗口,入口认证和适用的请求中间件仍会执行。 API 只输出各入口所需的字段白名单,不复用管理员的宽响应。 客户端配置通过 ClientKeyStore 显式读取当前会话绑定 Key 的明文,不进入用量响应。 -前端 `/key-usage` 独立于管理布局,不挂载管理员菜单或请求管理接口;配置弹窗、Codex 配置及 CC Switch +前端 `/key-usage` 独立于管理布局,不挂载管理员菜单或请求管理接口;各平台的配置模板、配置弹窗及 CC Switch 导入链接生成逻辑与管理端共用,明文仅在打开弹窗时获取,关闭后清除,不持久化到浏览器 ## 8. 状态所有权 diff --git a/frontend/src/components/ClientImportModal.vue b/frontend/src/components/ClientImportModal.vue index edc343760..1d76ed642 100644 --- a/frontend/src/components/ClientImportModal.vue +++ b/frontend/src/components/ClientImportModal.vue @@ -1,18 +1,23 @@ @@ -26,6 +31,7 @@ function select() { @closed="emit('afterLeave')" >
+
diff --git a/frontend/src/components/api-key-config-modal/client.ts b/frontend/src/components/api-key-config-modal/client.ts index 7817a99a1..0fa7522da 100644 --- a/frontend/src/components/api-key-config-modal/client.ts +++ b/frontend/src/components/api-key-config-modal/client.ts @@ -1,20 +1,25 @@ +import type { BuiltinProvider } from '@/providers/catalog' import { API_BASE_URL } from '@/api/constants' -const CODEX_DEFAULT_MODEL = 'gpt-5.6-terra' -export const CODEX_WEBSOCKET_ENABLED_BY_DEFAULT = false +const clientPresets = { + openai: { app: 'codex', model: 'gpt-6-luna' }, + xai: { app: 'grokbuild', model: 'grok-4.7' }, + antigravity: { app: 'agy', model: 'Gemini 4 Neon (High)' }, +} satisfies Record -interface CodexConfigInput { +interface SetupInput { + provider: BuiltinProvider apiKey: string - baseUrl: string - websocketEnabled?: boolean + root: string + windows: boolean + websocketEnabled: boolean } -export function buildCodexConfig(input: CodexConfigInput): string { - const baseUrl = input.baseUrl.replace(/\/+$/, '') - const websocketEnabled = input.websocketEnabled ?? CODEX_WEBSOCKET_ENABLED_BY_DEFAULT +function buildCodexConfig(apiKey: string, baseUrl: string, websocketEnabled: boolean) { + const model = JSON.stringify(clientPresets.openai.model) return `model_provider = "OpenAI" -model = "${CODEX_DEFAULT_MODEL}" -review_model = "${CODEX_DEFAULT_MODEL}" +model = ${model} +review_model = ${model} model_reasoning_effort = "max" service_tier = "default" # 语音通话控制地址 @@ -28,7 +33,7 @@ wire_api = "responses" supports_websockets = ${websocketEnabled} requires_openai_auth = false # 代理密钥 -experimental_bearer_token = ${JSON.stringify(input.apiKey)} +experimental_bearer_token = ${JSON.stringify(apiKey)} [model_providers.OpenAI.capabilities] # V2 远程压缩 @@ -45,9 +50,47 @@ image_generation = true goals = true` } -interface CodexCcSwitchImportInput { +export function buildClientConfig({ provider, root, apiKey, windows, websocketEnabled }: SetupInput) { + const path = (relative: string) => windows + ? `%USERPROFILE%\\${relative.replaceAll('/', '\\')}` + : `~/${relative}` + const baseUrl = `${root}/v1` + if (provider === 'openai') { + return { + title: path('.codex/config.toml'), + text: buildCodexConfig(apiKey, baseUrl, websocketEnabled), + } + } + if (provider === 'xai') { + return { + title: path('.grok/config.toml'), + text: `[models] +default = "cpr" + +[model.cpr] +model = ${JSON.stringify(clientPresets.xai.model)} +base_url = ${JSON.stringify(baseUrl)} +api_key = ${JSON.stringify(apiKey)} +api_backend = "responses"`, + } + } + + return { + title: path('.gemini/config/config.json'), + text: JSON.stringify({ + gateway: { + enabled: true, + url: root, + wireProtocol: 'genai', + apiKey, + }, + }, null, 2), + } +} + +interface CcSwitchImportInput { + provider: BuiltinProvider apiKey: string - baseUrl: string providerName: string } @@ -84,16 +127,20 @@ function buildUsageScript(apiKey: string, baseUrl: string) { })` } -export function buildCodexCcSwitchImportDeeplink(input: CodexCcSwitchImportInput): string { - const baseUrl = input.baseUrl.replace(/\/+$/, '') +export function buildCcSwitchImportDeeplink(input: CcSwitchImportInput): string { + const root = resolveServiceRootUrl() + const baseUrl = `${root}/v1` + const endpoint = input.provider === 'antigravity' + ? root + : baseUrl // 导入端会重建 Codex 配置,只传连接信息和用量查询,不传无法保留的完整模板 const entries: [string, string][] = [ ['resource', 'provider'], - ['app', 'codex'], - ['model', CODEX_DEFAULT_MODEL], + ['app', clientPresets[input.provider].app], + ['model', clientPresets[input.provider].model], ['name', input.providerName], - ['homepage', baseUrl], - ['endpoint', baseUrl], + ['homepage', root], + ['endpoint', endpoint], ['apiKey', input.apiKey], ['usageEnabled', 'true'], [ diff --git a/frontend/src/components/api-key-config-modal/index.vue b/frontend/src/components/api-key-config-modal/index.vue index 660890080..d93396197 100644 --- a/frontend/src/components/api-key-config-modal/index.vue +++ b/frontend/src/components/api-key-config-modal/index.vue @@ -1,120 +1,78 @@ diff --git a/frontend/src/i18n/locales/en/keys.json b/frontend/src/i18n/locales/en/keys.json index f97c0f3ab..c25750ea5 100644 --- a/frontend/src/i18n/locales/en/keys.json +++ b/frontend/src/i18n/locales/en/keys.json @@ -1,15 +1,15 @@ { "keys": { "configuration": { - "description": "Save or merge the configuration below and then restart Codex", "platform": "Platform", "toggleWebSocket": "Switch WebSocket configuration", + "fullApiKeyNotAvailable": "Full API key not available", + "title": "Use API key", + "os": "Operating system", "importTo": "Import", "selectImportTool": "Choose a tool to import into", "ccSwitchDescription": "Manage AI client configurations", - "viewOnGitHub": "View {name} on GitHub", - "fullApiKeyNotAvailable": "Full API key not available", - "title": "Use API key" + "viewOnGitHub": "View {name} on GitHub" }, "actions": { "editKey": "Edit key", diff --git a/frontend/src/i18n/locales/zh-Hans/keys.json b/frontend/src/i18n/locales/zh-Hans/keys.json index fcefea71d..0257378d6 100644 --- a/frontend/src/i18n/locales/zh-Hans/keys.json +++ b/frontend/src/i18n/locales/zh-Hans/keys.json @@ -1,15 +1,15 @@ { "keys": { "configuration": { - "description": "保存或合并下方配置后重启 Codex", - "platform": "配置平台", + "platform": "平台", "toggleWebSocket": "切换 WebSocket 配置", + "fullApiKeyNotAvailable": "完整 API密钥不可用", + "title": "使用密钥", + "os": "操作系统", "importTo": "导入到", "selectImportTool": "选择要导入的工具", "ccSwitchDescription": "管理和切换 AI 客户端配置", - "viewOnGitHub": "在 GitHub 查看 {name}", - "fullApiKeyNotAvailable": "完整 API密钥不可用", - "title": "使用密钥" + "viewOnGitHub": "在 GitHub 查看 {name}" }, "actions": { "editKey": "编辑密钥", diff --git a/frontend/src/i18n/locales/zh-Hant/keys.json b/frontend/src/i18n/locales/zh-Hant/keys.json index 1a21a9182..847b5a037 100644 --- a/frontend/src/i18n/locales/zh-Hant/keys.json +++ b/frontend/src/i18n/locales/zh-Hant/keys.json @@ -1,15 +1,15 @@ { "keys": { "configuration": { - "description": "保存或合併下方配置後重啓 Codex", - "platform": "配置平臺", + "platform": "平台", "toggleWebSocket": "切換 WebSocket 配置", + "fullApiKeyNotAvailable": "完整 API密鑰不可用", + "title": "使用密鑰", + "os": "作業系統", "importTo": "導入到", "selectImportTool": "選擇要導入的工具", "ccSwitchDescription": "管理和切換 AI 客戶端配置", - "viewOnGitHub": "在 GitHub 查看 {name}", - "fullApiKeyNotAvailable": "完整 API密鑰不可用", - "title": "使用密鑰" + "viewOnGitHub": "在 GitHub 查看 {name}" }, "actions": { "editKey": "編輯密鑰", diff --git a/frontend/src/providers/catalog.ts b/frontend/src/providers/catalog.ts index ba976b7f4..828d5be56 100644 --- a/frontend/src/providers/catalog.ts +++ b/frontend/src/providers/catalog.ts @@ -5,8 +5,8 @@ import { t } from '@/i18n' const providers = { openai: { label: 'OpenAI', icon: Openai }, - xai: { label: 'xAI', icon: Xai }, antigravity: { label: 'Antigravity', icon: GoogleAntigravity }, + xai: { label: 'xAI', icon: Xai }, } as const export const PROVIDER_IDS = Object.keys(providers) as BuiltinProvider[] diff --git a/frontend/src/views/accounts/components/AccountConnectionTestModal.vue b/frontend/src/views/accounts/components/AccountConnectionTestModal.vue index 24618add6..81672db43 100644 --- a/frontend/src/views/accounts/components/AccountConnectionTestModal.vue +++ b/frontend/src/views/accounts/components/AccountConnectionTestModal.vue @@ -95,6 +95,7 @@ function connectionLogClass(tone: string) {
Boolean(props.account.planType) || props.account.authenticationKind === 'api_key') -const hasForecast = computed(() => props.account.authenticationKind !== 'api_key') +// Antigravity 的额度按模型组返回,不能用于整号周/月预测。 +const hasForecast = computed(() => props.account.provider !== 'antigravity' && props.account.authenticationKind !== 'api_key') const hasPersonalInfo = computed(() => props.account.capabilities.profile || props.account.capabilities.subscription) const needsPeerDiscovery = computed(() => props.account.upstream?.discovered === false) const canRefresh = computed(() => props.account.capabilities.quotaRefresh || props.account.upstream != null) diff --git a/frontend/src/views/accounts/components/account-quota-summary-cell/index.vue b/frontend/src/views/accounts/components/account-quota-summary-cell/index.vue index f7b49cd43..72c828cad 100644 --- a/frontend/src/views/accounts/components/account-quota-summary-cell/index.vue +++ b/frontend/src/views/accounts/components/account-quota-summary-cell/index.vue @@ -109,7 +109,7 @@ const additionalEntryCount = computed(() => Math.max(summaryEntries.value.length
+{{ additionalEntryCount }} diff --git a/frontend/src/views/accounts/composables/useAccountConnectionTest.ts b/frontend/src/views/accounts/composables/useAccountConnectionTest.ts index 1694dc4fe..345279d7e 100644 --- a/frontend/src/views/accounts/composables/useAccountConnectionTest.ts +++ b/frontend/src/views/accounts/composables/useAccountConnectionTest.ts @@ -1,3 +1,4 @@ +import type { SelectOption } from '@codex-proxy/ui' import type { Account, AccountModelsResponse } from '@/api' import { CheckCircle2, Clock3, Wifi, XCircle } from '@lucide/vue' import { useEventSource } from '@vueuse/core' @@ -14,11 +15,6 @@ import { errorMessage } from '@/utils/operation' type ConnectionTestStatus = 'idle' | 'running' | 'success' | 'error' type ConnectionTestLogTone = 'normal' | 'info' | 'success' | 'danger' -interface ConnectionTestModelOption { - label: string - value: string -} - interface ConnectionTestLog { key: string time: string @@ -179,7 +175,7 @@ export function useAccountConnectionTest(options: { reload: () => Promise modelsRequest.loading.value && modelsRequestMode.value === 'load') const refreshingConnectionTestModels = computed(() => modelsRequest.loading.value && modelsRequestMode.value === 'refresh') const connectionTestSelectedModel = shallowRef('') - const connectionTestModelOptions = ref([]) + const connectionTestModelOptions = ref([]) const connectionTestStreamUrl = shallowRef() const { data: connectionTestStreamMessage, @@ -452,7 +448,13 @@ export function useAccountConnectionTest(options: { reload: () => Promise ({ value, label })) + connectionTestModelOptions.value = Array.from(labels, ([value, label]) => ({ + value, + label, + description: value === label + ? undefined + : value, + })) connectionTestSelectedModel.value = labels.has(previousSelection) ? previousSelection : connectionTestModelOptions.value[0]?.value || '' diff --git a/frontend/src/views/key-usage/composables/useKeyConfig.ts b/frontend/src/views/key-usage/composables/useKeyConfig.ts index 9bfa626cc..49b0e0bb8 100644 --- a/frontend/src/views/key-usage/composables/useKeyConfig.ts +++ b/frontend/src/views/key-usage/composables/useKeyConfig.ts @@ -1,6 +1,5 @@ -import { computed, onScopeDispose, shallowRef } from 'vue' +import { onScopeDispose, shallowRef } from 'vue' import { getKeyUsageConfig } from '@/api' -import { resolveServiceRootUrl } from '@/components/api-key-config-modal/client' import { useCopyText } from '@/composables/useCopyText' import { useRequestState } from '@/composables/useRequestState' @@ -9,7 +8,6 @@ export function useKeyConfig() { const configKey = shallowRef<{ name: string, key: string } | null>(null) const request = useRequestState() const copyText = useCopyText() - const apiBaseUrl = computed(() => `${resolveServiceRootUrl()}/v1`) async function openConfig() { if (request.loading.value) @@ -45,7 +43,6 @@ export function useKeyConfig() { showConfig, configKey, configuring: request.loading, - apiBaseUrl, openConfig, copyConfig, } diff --git a/frontend/src/views/key-usage/index.vue b/frontend/src/views/key-usage/index.vue index d4ec6f6ff..ab4c69ede 100644 --- a/frontend/src/views/key-usage/index.vue +++ b/frontend/src/views/key-usage/index.vue @@ -17,7 +17,7 @@ const { t } = useI18n({ useScope: 'global' }) const { period, model, kind, refreshInterval, overview, overviewLoading, refreshing, records, refresh, changePageSize, changePage } = useKeyUsage() const { items, currentPage, pageSize, total, loading: recordsLoading } = records -const { showConfig, configKey, configuring, apiBaseUrl, openConfig, copyConfig } = useKeyConfig() +const { showConfig, configKey, configuring, openConfig, copyConfig } = useKeyConfig() diff --git a/frontend/src/views/keys/components/ApiKeyCreatedModal.vue b/frontend/src/views/keys/components/ApiKeyCreatedModal.vue index d26c4139b..640b4b31a 100644 --- a/frontend/src/views/keys/components/ApiKeyCreatedModal.vue +++ b/frontend/src/views/keys/components/ApiKeyCreatedModal.vue @@ -1,4 +1,5 @@