Skip to content

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode,DeepSeek Harness and more. Only official website: ccswitch.io

feat(agy): replace the legacy env and model editors with config.json

Jason73b12d525df2
diff --git a/src/components/providers/forms/AgyConfigEditor.tsx b/src/components/providers/forms/AgyConfigEditor.tsx
new file mode 100644
index 000000000..c3a1b4037
--- /dev/null
+++ b/src/components/providers/forms/AgyConfigEditor.tsx
@@ -0,0 +1,51 @@
+import { useTranslation } from "react-i18next";
+import JsonEditor from "@/components/JsonEditor";
+import { useDarkMode } from "@/hooks/useDarkMode";
+
+interface AgyConfigEditorProps {
+ value: string;
+ onChange: (value: string) => void;
+ error?: string;
+}
+
+/**
+ * Antigravity 编辑器底部:切到这张卡之后 `~/.gemini/config/config.json` 的样子(后端投影,
+ * 见 `agy_editor.rs`)。网关那几个键由上面的选项决定,其余是 agy 的全局设置。
+ */
+export function AgyConfigEditor({
+ value,
+ onChange,
+ error,
+}: AgyConfigEditorProps) {
+ const { t } = useTranslation();
+ const isDarkMode = useDarkMode();
+
+ return (
+ <div className="space-y-2">
+ <p className="text-xs text-fg-2">
+ {t("provider.form.agy.keyFieldsHint")}
+ </p>
+ <label
+ htmlFor="agyConfigJson"
+ className="block text-sm font-medium text-fg-1"
+ >
+ {t("provider.form.agy.configJson")}
+ </label>
+ <JsonEditor
+ value={value}
+ onChange={onChange}
+ darkMode={isDarkMode}
+ rows={8}
+ showValidation={true}
+ language="json"
+ />
+ {error ? (
+ <p className="text-xs text-danger-text">{error}</p>
+ ) : (
+ <p className="text-xs text-fg-2">
+ {t("provider.form.agy.configJsonHint")}
+ </p>
+ )}
+ </div>
+ );
+}
diff --git a/src/components/providers/forms/GeminiConfigEditor.tsx b/src/components/providers/forms/GeminiConfigEditor.tsx
index 2cd42cfe5..4d9af0f67 100644
--- a/src/components/providers/forms/GeminiConfigEditor.tsx
+++ b/src/components/providers/forms/GeminiConfigEditor.tsx
@@ -5,7 +5,6 @@ import type { ProviderEditorInactiveField } from "@/lib/api/providers";
import { InactiveFieldsPanel } from "./InactiveFieldsPanel";
interface GeminiConfigEditorProps {
- isAgy?: boolean;
envValue: string;
configValue: string;
onEnvChange: (value: string) => void;
@@ -58,7 +57,6 @@ const parseConfig = (configText: string): Record<string, unknown> | null => {
};
const GeminiConfigEditor: React.FC<GeminiConfigEditorProps> = ({
- isAgy = false,
envValue,
configValue,
onEnvChange,
@@ -102,16 +100,13 @@ const GeminiConfigEditor: React.FC<GeminiConfigEditorProps> = ({
return (
<div className="space-y-6">
<p className="text-xs text-fg-2">
- {isAgy
- ? t("provider.form.agy.keyFieldsHint")
- : t("geminiConfig.keyFieldsHint", {
- defaultValue:
- "地址、Key、模型名和认证方式随供应商切换;其余环境变量和 settings.json 是 Gemini CLI 全局设置,保存后对所有供应商生效。",
- })}
+ {t("geminiConfig.keyFieldsHint", {
+ defaultValue:
+ "地址、Key、模型名和认证方式随供应商切换;其余环境变量和 settings.json 是 Gemini CLI 全局设置,保存后对所有供应商生效。",
+ })}
</p>
<GeminiEnvSection
- isAgy={isAgy}
value={envValue}
onChange={onEnvChange}
onBlur={onEnvBlur}
@@ -119,7 +114,6 @@ const GeminiConfigEditor: React.FC<GeminiConfigEditorProps> = ({
/>
<GeminiConfigSection
- isAgy={isAgy}
value={configValue}
onChange={onConfigChange}
configError={configError}
diff --git a/src/components/providers/forms/GeminiConfigSections.tsx b/src/components/providers/forms/GeminiConfigSections.tsx
index 6a3599987..a7fe1aaba 100644
--- a/src/components/providers/forms/GeminiConfigSections.tsx
+++ b/src/components/providers/forms/GeminiConfigSections.tsx
@@ -3,7 +3,6 @@ import { useTranslation } from "react-i18next";
import JsonEditor from "@/components/JsonEditor";
interface GeminiEnvSectionProps {
- isAgy?: boolean;
value: string;
onChange: (value: string) => void;
onBlur?: () => void;
@@ -14,7 +13,6 @@ interface GeminiEnvSectionProps {
* GeminiEnvSection - .env editor section for Gemini environment variables
*/
export const GeminiEnvSection: React.FC<GeminiEnvSectionProps> = ({
- isAgy = false,
value,
onChange,
onBlur,
@@ -51,9 +49,7 @@ export const GeminiEnvSection: React.FC<GeminiEnvSectionProps> = ({
htmlFor="geminiEnv"
className="block text-sm font-medium text-fg-1"
>
- {isAgy
- ? t("provider.form.agy.envFile")
- : t("geminiConfig.envFile", { defaultValue: "环境变量 (.env)" })}
+ {t("geminiConfig.envFile", { defaultValue: "环境变量 (.env)" })}
</label>
<JsonEditor
@@ -72,11 +68,9 @@ GEMINI_MODEL=gemini-3.6-flash`}
{!error && (
<p className="text-xs text-fg-2">
- {isAgy
- ? t("provider.form.agy.envFileHint")
- : t("geminiConfig.envFileHint", {
- defaultValue: "使用 .env 格式配置 Gemini 环境变量",
- })}
+ {t("geminiConfig.envFileHint", {
+ defaultValue: "使用 .env 格式配置 Gemini 环境变量",
+ })}
</p>
)}
</div>
@@ -84,7 +78,6 @@ GEMINI_MODEL=gemini-3.6-flash`}
};
interface GeminiConfigSectionProps {
- isAgy?: boolean;
value: string;
onChange: (value: string) => void;
configError?: string;
@@ -94,7 +87,6 @@ interface GeminiConfigSectionProps {
* GeminiConfigSection - settings.json editor section
*/
export const GeminiConfigSection: React.FC<GeminiConfigSectionProps> = ({
- isAgy = false,
value,
onChange,
configError,
@@ -123,24 +115,18 @@ export const GeminiConfigSection: React.FC<GeminiConfigSectionProps> = ({
htmlFor="geminiConfig"
className="block text-sm font-medium text-fg-1"
>
- {isAgy
- ? t("provider.form.agy.configJson")
- : t("geminiConfig.configJson", {
- defaultValue: "配置文件 (settings.json)",
- })}
+ {t("geminiConfig.configJson", {
+ defaultValue: "配置文件 (settings.json)",
+ })}
</label>
<JsonEditor
value={value}
onChange={onChange}
- placeholder={
- isAgy
- ? '{"model":{"name":"gemini-3.8-flash"}}'
- : `{
+ placeholder={`{
"timeout": 30000,
"maxRetries": 3
-}`
- }
+}`}
darkMode={isDarkMode}
rows={3}
showValidation={true}
@@ -151,12 +137,10 @@ export const GeminiConfigSection: React.FC<GeminiConfigSectionProps> = ({
{!configError && (
<p className="text-xs text-fg-2">
- {isAgy
- ? t("provider.form.agy.configJsonHint")
- : t("geminiConfig.configJsonHint", {
- defaultValue:
- "Gemini CLI 的 settings.json(MCP 服务器在 MCP 面板里管理)",
- })}
+ {t("geminiConfig.configJsonHint", {
+ defaultValue:
+ "Gemini CLI 的 settings.json(MCP 服务器在 MCP 面板里管理)",
+ })}
</p>
)}
</div>
diff --git a/src/components/providers/forms/ProviderForm.tsx b/src/components/providers/forms/ProviderForm.tsx
index 2f67f3dec..e37f44cc0 100644
--- a/src/components/providers/forms/ProviderForm.tsx
+++ b/src/components/providers/forms/ProviderForm.tsx
@@ -26,6 +26,13 @@ import {
withClaudeGatewayDefaults,
} from "@/utils/claudeEditorOverlay";
import { useDarkMode } from "@/hooks/useDarkMode";
+import { AgyConfigEditor } from "./AgyConfigEditor";
+import {
+ AGY_LIVE_CONFIG_KEY,
+ agyLiveConfigText,
+ parseAgyLiveConfig,
+ useAgyLiveConfig,
+} from "./hooks/useAgyLiveConfig";
import type {
ProviderCategory,
ProviderMeta,
@@ -1156,16 +1163,44 @@ function ProviderFormFull({
preferConfigModel: appId === "agy",
});
+ // Antigravity:表单现在的行(不含编辑器投影),用来重新投影底部的 config.json
+ const agyDraftRow = useMemo(() => {
+ if (appId !== "agy") return null;
+ try {
+ const row: Record<string, unknown> = {
+ env: envStringToObj(geminiEnv),
+ config: geminiConfig.trim() ? JSON.parse(geminiConfig) : {},
+ };
+ const gateway =
+ category !== "official" ? agyGatewayToSettings(agyGateway) : undefined;
+ if (gateway) row.gateway = gateway;
+ return row;
+ } catch {
+ return null;
+ }
+ }, [appId, envStringToObj, geminiEnv, geminiConfig, category, agyGateway]);
+ const [agyLiveConfig, setAgyLiveConfig] = useAgyLiveConfig({
+ enabled: appId === "agy",
+ initialSettings: initialData?.settingsConfig,
+ draftRow: agyDraftRow,
+ category,
+ });
+ const agyLiveConfigError =
+ agyLiveConfig.trim() && !parseAgyLiveConfig(agyLiveConfig)
+ ? t("provider.form.agy.configJsonInvalid")
+ : "";
+
const projectGeminiDraft = useCallback(
(
env: Record<string, unknown>,
config: Record<string, unknown>,
category?: string,
) =>
- projectDraft({ env, config }, category, (shown) =>
- resetGeminiConfig(asRecord(shown.env), asRecord(shown.config)),
- ),
- [projectDraft, resetGeminiConfig],
+ projectDraft({ env, config }, category, (shown) => {
+ resetGeminiConfig(asRecord(shown.env), asRecord(shown.config));
+ if (appId === "agy") setAgyLiveConfig(agyLiveConfigText(shown));
+ }),
+ [appId, projectDraft, resetGeminiConfig, setAgyLiveConfig],
);
// resetGeminiConfig 随编辑内容变,不能放进下面的依赖,否则每次编辑都会重新投影、冲掉
// 输入;只在打开和切回「自定义」时投影。
@@ -1497,6 +1532,11 @@ function ProviderFormFull({
return;
}
+ if (agyLiveConfigError) {
+ toast.error(agyLiveConfigError);
+ return;
+ }
+
// 软性问题(业务约束,用户可选择仍要保存)
const issues: string[] = [];
@@ -2008,6 +2048,10 @@ function ProviderFormFull({
? agyGatewayToSettings(agyGateway)
: undefined;
if (gateway) combined.gateway = gateway;
+ // 编辑器显示的 config.json:后端拆出用户改过的全局设置,存行前去掉
+ const liveConfig =
+ appId === "agy" ? parseAgyLiveConfig(agyLiveConfig) : null;
+ if (liveConfig) combined[AGY_LIVE_CONFIG_KEY] = liveConfig;
settingsConfig = JSON.stringify(combined);
} catch (err) {
settingsConfig = values.settingsConfig.trim();
@@ -3390,10 +3434,17 @@ function ProviderFormFull({
/>
{settingsConfigErrorField}
</>
+ ) : appId === "agy" ? (
+ agyLiveConfig.trim() ? (
+ <AgyConfigEditor
+ value={agyLiveConfig}
+ onChange={setAgyLiveConfig}
+ error={agyLiveConfigError}
+ />
+ ) : null
) : usesGeminiStyleForm(appId) ? (
<>
<GeminiConfigEditor
- isAgy={appId === "agy"}
envValue={geminiEnv}
configValue={geminiConfig}
onEnvChange={handleGeminiEnvChange}
diff --git a/src/components/providers/forms/hooks/useAgyLiveConfig.ts b/src/components/providers/forms/hooks/useAgyLiveConfig.ts
new file mode 100644
index 000000000..dee82953b
--- /dev/null
+++ b/src/components/providers/forms/hooks/useAgyLiveConfig.ts
@@ -0,0 +1,105 @@
+import { useEffect, useRef, useState } from "react";
+import { providersApi } from "@/lib/api";
+
+/** 行里放编辑器投影的键(同后端 `agy_editor::LIVE_CONFIG_KEY`),存行前后端会去掉。 */
+export const AGY_LIVE_CONFIG_KEY = "liveConfig";
+
+/** CC Switch 在 config.json 里拥有的顶层键:随卡片切换,由表单上的选项决定。 */
+const OWNED_KEYS = ["gateway", "models", "caCertPath"];
+
+function asObject(value: unknown): Record<string, unknown> | null {
+ return value && typeof value === "object" && !Array.isArray(value)
+ ? (value as Record<string, unknown>)
+ : null;
+}
+
+/** 行(或编辑器投影)里的 config.json,格式化成编辑器文本;没有时为空串。 */
+export function agyLiveConfigText(settings: unknown): string {
+ const config = asObject(asObject(settings)?.[AGY_LIVE_CONFIG_KEY]);
+ return config ? JSON.stringify(config, null, 2) : "";
+}
+
+/** 编辑器文本解析成对象;不是 JSON 对象时为 `null`。 */
+export function parseAgyLiveConfig(
+ text: string,
+): Record<string, unknown> | null {
+ try {
+ return asObject(JSON.parse(text));
+ } catch {
+ return null;
+ }
+}
+
+/**
+ * 把新投影里 CC Switch 拥有的键换进编辑器文本,其余内容(用户在编辑器里改的全局设置)
+ * 保留。键在原文里的位置不变,新出现的排到最后。文本不是 JSON 对象时原样返回。
+ */
+export function spliceAgyOwnedKeys(
+ text: string,
+ projected: Record<string, unknown>,
+): string {
+ const current = parseAgyLiveConfig(text);
+ if (!current) return text;
+ const next: Record<string, unknown> = {};
+ for (const [key, value] of Object.entries(current)) {
+ if (!OWNED_KEYS.includes(key)) next[key] = value;
+ else if (key in projected) next[key] = projected[key];
+ }
+ for (const key of OWNED_KEYS) {
+ if (key in projected && !(key in next)) next[key] = projected[key];
+ }
+ return JSON.stringify(next, null, 2);
+}
+
+/**
+ * Antigravity 编辑器底部的 config.json:初始是打开时的投影;表单上的 Key、地址、协议、
+ * 模型、CA 证书一变,就按草稿行重新投影(后端算,和切换同一个补丁),只换回网关那几个键。
+ */
+export function useAgyLiveConfig({
+ enabled,
+ initialSettings,
+ draftRow,
+ category,
+}: {
+ enabled: boolean;
+ initialSettings: unknown;
+ /** 表单现在的行(不含 liveConfig);`null` 表示还拼不出来,不投影 */
+ draftRow: Record<string, unknown> | null;
+ category?: string;
+}) {
+ const [text, setText] = useState(() => agyLiveConfigText(initialSettings));
+ const draftKey = draftRow ? JSON.stringify(draftRow) : null;
+ // 打开时的投影已经对应初始的行,第一次不用再算
+ const lastProjected = useRef<string | null>(draftKey);
+
+ useEffect(() => {
+ if (!enabled || !draftRow || draftKey === lastProjected.current) return;
+ let cancelled = false;
+ const timer = window.setTimeout(() => {
+ providersApi
+ .getEditorView("agy", draftRow, category)
+ .then((view) => {
+ if (cancelled) return;
+ lastProjected.current = draftKey;
+ const projected = asObject(view.settings[AGY_LIVE_CONFIG_KEY]);
+ if (!projected) return;
+ setText((current) =>
+ current.trim()
+ ? spliceAgyOwnedKeys(current, projected)
+ : JSON.stringify(projected, null, 2),
+ );
+ })
+ .catch((error: unknown) => {
+ // 草稿暂时过不了校验(比如选了 OpenAI 协议还没填地址):保持上一次的显示
+ console.warn("[agy] editor projection failed", error);
+ });
+ }, 300);
+ return () => {
+ cancelled = true;
+ window.clearTimeout(timer);
+ };
+ // draftKey 已经代表 draftRow 的内容,不把对象本身放进依赖
+ }, [enabled, draftKey, category]);
+
+ return [text, setText] as const;
+}
diff --git a/src/config/appSpecs.ts b/src/config/appSpecs.ts
index a07500052..1d6ec35e2 100644
--- a/src/config/appSpecs.ts
+++ b/src/config/appSpecs.ts
@@ -227,7 +227,7 @@ export const APP_SPECS = {
plugins: true,
managedAccount: true,
piFamily: false,
- editorView: false,
+ editorView: true,
officialSubscription: true,
},
omp: {
diff --git a/src/i18n/locales/de.json b/src/i18n/locales/de.json
index 31d404ad0..8a98dc815 100644
--- a/src/i18n/locales/de.json
+++ b/src/i18n/locales/de.json
@@ -225,11 +225,10 @@
"agy": {
"endpointHelp": "Leer lassen, um die Standard-API von Google zu verwenden. Geben Sie nur die Domain oder das Pfadpräfix an; agy hängt /v1beta oder /v1 selbst an.",
"modelHelp": "Verwenden Sie den Anzeigenamen aus der Modellliste (Modelle abrufen). Gilt nur für diese Sitzung.",
- "keyFieldsHint": "Solange diese Karte verwendet wird, werden Schlüssel, Endpunkt, Protokoll und Modelle in die Gateway-Einstellungen in ~/.gemini/config/config.json geschrieben, die sowohl agy als auch die Antigravity-Desktop-App lesen. Beim Wechsel zu einer offiziellen Karte wird das Gateway entfernt und agy nutzt wieder Ihre Google-Anmeldung.",
- "envFile": "Umgebungsvariablen (CC-Switch-Format)",
- "envFileHint": "Nur der API-Schlüssel (GEMINI_API_KEY) und der Endpunkt (GOOGLE_GEMINI_BASE_URL) werden verwendet; sie werden in die Gateway-Einstellungen von agy geschrieben, solange diese Karte verwendet wird. Andere Variablen werden nicht angewendet.",
- "configJson": "Modellkonfiguration (CC-Switch-Format)",
- "configJsonHint": "Hier wirkt nur der Anzeigename des Modells einer offiziellen Karte (beim Öffnen eines Terminals); Protokoll und Modelle einer Drittanbieter-Karte legen Sie im Formular oben fest. MCP wird im MCP-Bereich verwaltet.",
+ "keyFieldsHint": "Unten steht ~/.gemini/config/config.json so, wie sie nach dem Wechsel zu dieser Karte aussieht. gateway, models und caCertPath wechseln mit der Karte und kommen aus den Optionen oben; Änderungen daran werden hier nicht gespeichert. Alles andere (Plugins, Benutzereinstellungen, …) ist die globale Konfiguration von agy und gilt nach dem Speichern für alle Karten.",
+ "configJson": "Konfigurationsdatei (config.json)",
+ "configJsonHint": "Die agy-CLI und die Antigravity-Desktop-App lesen beide diese Datei; die Desktop-App liest sie nur beim Start, also nach dem Speichern neu starten. MCP-Server werden im MCP-Bereich verwaltet.",
+ "configJsonInvalid": "config.json muss ein JSON-Objekt sein",
"account": "Konto",
"accountFollow": "Aktueller Anmeldung von agy folgen",
"accountMissing": "Ein Konto, das nicht auf diesem Computer vorhanden ist",
diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json
index c113b9d55..d65354453 100644
--- a/src/i18n/locales/en.json
+++ b/src/i18n/locales/en.json
@@ -225,11 +225,10 @@
"agy": {
"endpointHelp": "Leave empty to use Google's default API. Enter the domain or path prefix only; agy appends /v1beta or /v1 itself.",
"modelHelp": "Use the display name from the model list (Fetch Models). Applies to that session only.",
- "keyFieldsHint": "While this card is in use, its key, endpoint, protocol, and models are written to the gateway settings in ~/.gemini/config/config.json, which both agy and the Antigravity desktop app read. Switching to an official card clears the gateway, and agy goes back to your Google sign-in.",
- "envFile": "Environment variables (CC Switch format)",
- "envFileHint": "Only the API key (GEMINI_API_KEY) and endpoint (GOOGLE_GEMINI_BASE_URL) are used; they go into agy's gateway settings while this card is in use. Other variables are not applied.",
- "configJson": "Model configuration (CC Switch format)",
- "configJsonHint": "Only an official card's model display name takes effect here (used when opening a terminal); set a third-party card's protocol and models in the form above. MCP is managed in the MCP panel.",
+ "keyFieldsHint": "Below is ~/.gemini/config/config.json as it will look after switching to this card. gateway, models and caCertPath switch with the card and come from the options above; edits to them here are not saved. Everything else (plugins, user settings, …) is agy's global configuration and applies to every card once saved.",
+ "configJson": "Config file (config.json)",
+ "configJsonHint": "Both the agy CLI and the Antigravity desktop app read this file; the desktop app reads it only at startup, so restart it after saving. MCP servers are managed in the MCP panel.",
+ "configJsonInvalid": "config.json must be a JSON object",
"account": "Account",
"accountFollow": "Follow agy's current sign-in",
"accountMissing": "An account not on this computer",
diff --git a/src/i18n/locales/ja.json b/src/i18n/locales/ja.json
index 71b3e30e9..00eb11b33 100644
--- a/src/i18n/locales/ja.json
+++ b/src/i18n/locales/ja.json
@@ -225,11 +225,10 @@
"agy": {
"endpointHelp": "空欄なら Google の既定の API を使います。ドメインかパスのプレフィックスまでを入力してください。/v1beta や /v1 は agy が付け足します。",
"modelHelp": "モデル一覧の表示名を入力してください(「モデル一覧を取得」から選べます)。そのセッションにのみ適用されます。",
- "keyFieldsHint": "このカードを使用中は、キー・エンドポイント・プロトコル・モデルが ~/.gemini/config/config.json のゲートウェイ設定に書き込まれ、agy と Antigravity デスクトップ版の両方がそれを読み込みます。公式カードに切り替えるとゲートウェイ設定が消え、agy は Google ログインに戻ります。",
- "envFile": "環境変数(CC Switch 形式)",
- "envFileHint": "使われるのは API キー(GEMINI_API_KEY)とエンドポイント(GOOGLE_GEMINI_BASE_URL)だけで、このカードの使用中は agy のゲートウェイ設定に書き込まれます。その他の環境変数は適用されません。",
- "configJson": "モデル設定(CC Switch 形式)",
- "configJsonHint": "ここで有効なのは公式カードのモデル表示名だけです(ターミナルを開くときに使用)。サードパーティカードのプロトコルとモデルは上のフォームで設定します。MCP は MCP パネルで管理します。",
+ "keyFieldsHint": "以下は、このカードに切り替えた後の ~/.gemini/config/config.json です。gateway、models、caCertPath はカードと一緒に切り替わり、上のオプションで決まります。ここで変更しても保存されません。それ以外(プラグイン、ユーザー設定など)は agy のグローバル設定で、保存するとすべてのカードに適用されます。",
+ "configJson": "設定ファイル(config.json)",
+ "configJsonHint": "agy CLI と Antigravity デスクトップ版の両方がこのファイルを読みます。デスクトップ版は起動時にしか読まないため、保存後に再起動してください。MCP は MCP パネルで管理します。",
+ "configJsonInvalid": "config.json は JSON オブジェクトである必要があります",
"account": "アカウント",
"accountFollow": "agy の現在のログインに従う",
"accountMissing": "このコンピューターにないアカウント",
diff --git a/src/i18n/locales/ko.json b/src/i18n/locales/ko.json
index 780c4e5b9..3af568999 100644
--- a/src/i18n/locales/ko.json
+++ b/src/i18n/locales/ko.json
@@ -223,11 +223,10 @@
"agy": {
"endpointHelp": "비워 두면 Google 기본 API를 사용합니다. 도메인이나 경로 접두사까지만 입력하세요. /v1beta 또는 /v1은 agy가 직접 붙입니다.",
"modelHelp": "모델 목록에 표시되는 이름을 입력하세요. ‘모델 목록 가져오기’를 눌러 선택할 수 있습니다. 해당 세션에만 적용됩니다.",
- "keyFieldsHint": "이 카드를 사용하는 동안 키, 엔드포인트, 프로토콜, 모델이 ~/.gemini/config/config.json의 게이트웨이 설정에 기록되며, agy와 Antigravity 데스크톱 앱이 모두 이를 읽습니다. 공식 카드로 전환하면 게이트웨이 설정이 지워지고 agy는 Google 로그인으로 돌아갑니다.",
- "envFile": "환경 변수(CC Switch 형식)",
- "envFileHint": "API 키(GEMINI_API_KEY)와 엔드포인트(GOOGLE_GEMINI_BASE_URL)만 사용되며, 이 카드를 사용하는 동안 agy의 게이트웨이 설정에 기록됩니다. 다른 환경 변수는 적용되지 않습니다.",
- "configJson": "모델 설정(CC Switch 형식)",
- "configJsonHint": "여기서는 공식 카드의 모델 표시 이름만 적용됩니다(터미널을 열 때 사용). 서드파티 카드의 프로토콜과 모델은 위 양식에서 설정하세요. MCP는 MCP 패널에서 관리합니다.",
+ "keyFieldsHint": "아래는 이 카드로 전환한 뒤의 ~/.gemini/config/config.json입니다. gateway, models, caCertPath는 카드와 함께 전환되며 위의 옵션으로 정해집니다. 여기서 바꿔도 저장되지 않습니다. 나머지(플러그인, 사용자 설정 등)는 agy의 전역 설정이며, 저장하면 모든 카드에 적용됩니다.",
+ "configJson": "설정 파일(config.json)",
+ "configJsonHint": "agy CLI와 Antigravity 데스크톱 앱 모두 이 파일을 읽습니다. 데스크톱 앱은 시작할 때만 읽으므로 저장한 뒤 다시 시작하세요. MCP 서버는 MCP 패널에서 관리합니다.",
+ "configJsonInvalid": "config.json은 JSON 객체여야 합니다",
"account": "계정",
"accountFollow": "agy의 현재 로그인 따르기",
"accountMissing": "이 컴퓨터에 없는 계정",
diff --git a/src/i18n/locales/ru.json b/src/i18n/locales/ru.json
index 1f1ad2826..1dcabd561 100644
--- a/src/i18n/locales/ru.json
+++ b/src/i18n/locales/ru.json
@@ -225,11 +225,10 @@
"agy": {
"endpointHelp": "Оставьте пустым, чтобы использовать API Google по умолчанию. Укажите только домен или префикс пути: agy сам добавит /v1beta или /v1.",
"modelHelp": "Укажите отображаемое имя из списка моделей («Получить модели»). Действует только для этой сессии.",
- "keyFieldsHint": "Пока используется эта карточка, её ключ, эндпоинт, протокол и модели записываются в настройки шлюза в ~/.gemini/config/config.json, которые читают и agy, и настольное приложение Antigravity. При переключении на официальную карточку шлюз удаляется, и agy снова использует ваш вход Google.",
- "envFile": "Переменные окружения (формат CC Switch)",
- "envFileHint": "Используются только API-ключ (GEMINI_API_KEY) и эндпоинт (GOOGLE_GEMINI_BASE_URL); пока используется эта карточка, они записываются в настройки шлюза agy. Остальные переменные не применяются.",
- "configJson": "Конфигурация моделей (формат CC Switch)",
- "configJsonHint": "Здесь действует только отображаемое имя модели официальной карточки (используется при открытии терминала); протокол и модели сторонней карточки задаются в форме выше. MCP управляется на панели MCP.",
+ "keyFieldsHint": "Ниже — ~/.gemini/config/config.json в том виде, какой он примет после переключения на эту карточку. gateway, models и caCertPath переключаются вместе с карточкой и задаются параметрами выше; изменения в них здесь не сохраняются. Всё остальное (плагины, пользовательские настройки и т. д.) — глобальная конфигурация agy, после сохранения она действует для всех карточек.",
+ "configJson": "Файл конфигурации (config.json)",
+ "configJsonHint": "Этот файл читают и agy CLI, и настольное приложение Antigravity; приложение читает его только при запуске, поэтому после сохранения перезапустите его. MCP-серверы управляются на панели MCP.",
+ "configJsonInvalid": "config.json должен быть JSON-объектом",
"account": "Аккаунт",
"accountFollow": "Как текущий вход agy",
"accountMissing": "Аккаунт не на этом компьютере",
diff --git a/src/i18n/locales/tr.json b/src/i18n/locales/tr.json
index ec84dff32..cab3bc7cb 100644
--- a/src/i18n/locales/tr.json
+++ b/src/i18n/locales/tr.json
@@ -225,11 +225,10 @@
"agy": {
"endpointHelp": "Google'ın varsayılan API'sini kullanmak için boş bırakın. Yalnızca alan adını veya yol önekini girin; agy /v1beta ya da /v1 ekini kendisi ekler.",
"modelHelp": "Model listesindeki görünen adı kullanın (Modelleri Getir). Yalnızca bu oturum için geçerlidir.",
- "keyFieldsHint": "Bu kart kullanılırken anahtarı, uç noktası, protokolü ve modelleri ~/.gemini/config/config.json içindeki ağ geçidi ayarlarına yazılır; hem agy hem de Antigravity masaüstü uygulaması bunu okur. Resmî bir karta geçildiğinde ağ geçidi temizlenir ve agy Google oturumunuza döner.",
- "envFile": "Ortam değişkenleri (CC Switch biçimi)",
- "envFileHint": "Yalnızca API anahtarı (GEMINI_API_KEY) ve uç nokta (GOOGLE_GEMINI_BASE_URL) kullanılır; bu kart kullanılırken agy'nin ağ geçidi ayarlarına yazılır. Diğer değişkenler uygulanmaz.",
- "configJson": "Model yapılandırması (CC Switch biçimi)",
- "configJsonHint": "Burada yalnızca resmî kartın model görünen adı geçerlidir (terminal açılırken kullanılır); üçüncü taraf kartın protokolünü ve modellerini yukarıdaki formda ayarlayın. MCP, MCP panelinden yönetilir.",
+ "keyFieldsHint": "Aşağıda, bu karta geçtikten sonra ~/.gemini/config/config.json dosyasının görünümü var. gateway, models ve caCertPath kartla birlikte değişir ve yukarıdaki seçeneklerden gelir; burada yapılan değişiklikler kaydedilmez. Geri kalan her şey (eklentiler, kullanıcı ayarları, …) agy'nin genel yapılandırmasıdır ve kaydedildikten sonra tüm kartlara uygulanır.",
+ "configJson": "Yapılandırma dosyası (config.json)",
+ "configJsonHint": "agy CLI ve Antigravity masaüstü uygulaması bu dosyayı okur; masaüstü uygulaması yalnızca başlangıçta okuduğundan kaydettikten sonra yeniden başlatın. MCP sunucuları MCP panelinde yönetilir.",
+ "configJsonInvalid": "config.json bir JSON nesnesi olmalıdır",
"account": "Hesap",
"accountFollow": "agy'nin mevcut oturum açma hesabını kullan",
"accountMissing": "Bu bilgisayarda bulunmayan hesap",
diff --git a/src/i18n/locales/zh-TW.json b/src/i18n/locales/zh-TW.json
index 75dbe8c31..049f172c8 100644
--- a/src/i18n/locales/zh-TW.json
+++ b/src/i18n/locales/zh-TW.json
@@ -225,11 +225,10 @@
"agy": {
"endpointHelp": "留空使用 Google 預設 API。位址填到網域或路徑前綴即可,agy 會自己加上 /v1beta 或 /v1。",
"modelHelp": "填模型清單裡的顯示名稱,可點「取得模型清單」選擇。只對那次工作階段生效。",
- "keyFieldsHint": "使用這張卡時,Key、位址、協定和模型寫進 ~/.gemini/config/config.json 的閘道設定,agy 和 Antigravity 桌面版都讀它;切到官方卡時清掉閘道,agy 回到 Google 登入。",
- "envFile": "環境變數(CC Switch 格式)",
- "envFileHint": "只用 API Key(GEMINI_API_KEY)和請求位址(GOOGLE_GEMINI_BASE_URL),使用這張卡時寫進 agy 的閘道設定;其他環境變數不會套用。",
- "configJson": "模型設定(CC Switch 格式)",
- "configJsonHint": "這裡只有官方卡的模型顯示名稱生效(開啟終端機時使用);第三方卡的協定和模型在上面的表單裡設定。MCP 在 MCP 面板中管理。",
+ "keyFieldsHint": "下面是切到這張卡之後 ~/.gemini/config/config.json 的樣子。gateway、models、caCertPath 隨卡片切換,由上面的選項決定,在這裡改不會儲存;其餘(外掛、使用者設定等)是 agy 的全域設定,儲存後對所有卡生效。",
+ "configJson": "設定檔(config.json)",
+ "configJsonHint": "agy CLI 和 Antigravity 桌面版都讀這個檔案;桌面版只在啟動時讀,儲存後要重新啟動。MCP 在 MCP 面板中管理。",
+ "configJsonInvalid": "config.json 必須是一個 JSON 物件",
"account": "帳號",
"accountFollow": "跟隨 agy 目前登入",
"accountMissing": "不在這台電腦上的帳號",
diff --git a/src/i18n/locales/zh.json b/src/i18n/locales/zh.json
index c1bbe532f..af2fa70ae 100644
--- a/src/i18n/locales/zh.json
+++ b/src/i18n/locales/zh.json
@@ -225,11 +225,10 @@
"agy": {
"endpointHelp": "留空用 Google 默认 API。地址填到域名或路径前缀即可,agy 会自己拼上 /v1beta 或 /v1。",
"modelHelp": "填模型列表里的显示名称,可点「获取模型列表」选择。只对那次会话生效。",
- "keyFieldsHint": "使用这张卡时,Key、地址、协议和模型写进 ~/.gemini/config/config.json 的网关设置,agy 和 Antigravity 桌面版都读它;切到官方卡时清掉网关,agy 回到 Google 登录。",
- "envFile": "环境变量(CC Switch 格式)",
- "envFileHint": "只用 API Key(GEMINI_API_KEY)和请求地址(GOOGLE_GEMINI_BASE_URL),使用这张卡时写进 agy 的网关设置;其他环境变量不会应用。",
- "configJson": "模型配置(CC Switch 格式)",
- "configJsonHint": "这里只有官方卡的模型显示名生效(打开终端时使用);第三方卡的协议和模型在上面的表单里设置。MCP 在 MCP 面板中管理。",
+ "keyFieldsHint": "下面是切到这张卡之后 ~/.gemini/config/config.json 的样子。gateway、models、caCertPath 随卡片切换,由上面的选项决定,在这里改不会保存;其余(插件、用户设置等)是 agy 的全局设置,保存后对所有卡生效。",
+ "configJson": "配置文件(config.json)",
+ "configJsonHint": "agy CLI 和 Antigravity 桌面版都读这个文件;桌面版只在启动时读,保存后要重启。MCP 在 MCP 面板中管理。",
+ "configJsonInvalid": "config.json 必须是一个 JSON 对象",
"account": "账号",
"accountFollow": "跟随 agy 当前登录",
"accountMissing": "不在这台电脑上的账号",
diff --git a/tests/components/CommonConfigModalBehavior.test.tsx b/tests/components/CommonConfigModalBehavior.test.tsx
index 27712a8c7..82977c854 100644
--- a/tests/components/CommonConfigModalBehavior.test.tsx
+++ b/tests/components/CommonConfigModalBehavior.test.tsx
@@ -3,6 +3,7 @@ import { fireEvent, render, screen } from "@testing-library/react";
import { describe, expect, it, vi } from "vitest";
import CodexConfigEditor from "@/components/providers/forms/CodexConfigEditor";
import GeminiConfigEditor from "@/components/providers/forms/GeminiConfigEditor";
+import { AgyConfigEditor } from "@/components/providers/forms/AgyConfigEditor";
vi.mock("@/components/common/FullScreenPanel", () => ({
FullScreenPanel: ({
@@ -114,25 +115,9 @@ describe("Common config modals", () => {
});
});
-it("describes the Antigravity launcher instead of Gemini CLI global files", () => {
- render(
- <GeminiConfigEditor
- isAgy
- envValue=""
- configValue="{}"
- onEnvChange={vi.fn()}
- onConfigChange={vi.fn()}
- envError=""
- configError=""
- />,
- );
- for (const key of [
- "keyFieldsHint",
- "envFile",
- "envFileHint",
- "configJson",
- "configJsonHint",
- ]) {
+it("describes Antigravity's config.json instead of Gemini CLI global files", () => {
+ render(<AgyConfigEditor value="{}" onChange={vi.fn()} />);
+ for (const key of ["keyFieldsHint", "configJson", "configJsonHint"]) {
expect(screen.getByText(`provider.form.agy.${key}`)).toBeInTheDocument();
}
expect(screen.queryByText(/Gemini CLI/)).not.toBeInTheDocument();
diff --git a/tests/components/useAgyLiveConfig.test.ts b/tests/components/useAgyLiveConfig.test.ts
new file mode 100644
index 000000000..d8e66dedc
--- /dev/null
+++ b/tests/components/useAgyLiveConfig.test.ts
@@ -0,0 +1,46 @@
+import { describe, expect, it } from "vitest";
+import {
+ agyLiveConfigText,
+ parseAgyLiveConfig,
+ spliceAgyOwnedKeys,
+} from "@/components/providers/forms/hooks/useAgyLiveConfig";
+
+describe("Antigravity editor config.json", () => {
+ it("swaps in only the keys CC Switch owns and keeps their position", () => {
+ const text = JSON.stringify({
+ plugins: { a: true },
+ gateway: { url: "https://old.example" },
+ userSettings: { theme: "light" },
+ caCertPath: "/old.pem",
+ });
+ const next = parseAgyLiveConfig(
+ spliceAgyOwnedKeys(text, {
+ plugins: { a: false },
+ gateway: { url: "https://new.example" },
+ models: { defaultModelId: "m1" },
+ }),
+ );
+ expect(Object.keys(next ?? {})).toEqual([
+ "plugins",
+ "gateway",
+ "userSettings",
+ "models",
+ ]);
+ // 用户在编辑器里的全局设置不被投影覆盖
+ expect(next?.plugins).toEqual({ a: true });
+ expect(next?.gateway).toEqual({ url: "https://new.example" });
+ expect(next?.caCertPath).toBeUndefined();
+ });
+
+ it("leaves text that is not a JSON object alone", () => {
+ expect(spliceAgyOwnedKeys("{ broken", { gateway: {} })).toBe("{ broken");
+ expect(parseAgyLiveConfig("[1]")).toBeNull();
+ });
+
+ it("reads the projection from a row", () => {
+ expect(agyLiveConfigText({ env: {} })).toBe("");
+ expect(agyLiveConfigText({ liveConfig: { a: 1 } })).toBe(
+ JSON.stringify({ a: 1 }, null, 2),
+ );
+ });
+});