From 7cdc88c4d18b10425b288869ce7f66b1999ff07e Mon Sep 17 00:00:00 2001 From: Ryder Sun Date: Sat, 7 Nov 2026 20:06:51 +0800 Subject: [PATCH] Preserve Gemini native workspace trust settings Forward explicit trusted or restricted workspace settings to Gemini so its native configuration is interpreted consistently. Checks: 146 environment and readiness tests; desktop packaging; git diff --check. --- desktop/src/agents/agent-native-environment.cjs | 2 +- .../cli/cli-native-config-environment.test.cjs | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/desktop/src/agents/agent-native-environment.cjs b/desktop/src/agents/agent-native-environment.cjs index 93b7a5a..bb8a131 100644 --- a/desktop/src/agents/agent-native-environment.cjs +++ b/desktop/src/agents/agent-native-environment.cjs @@ -105,7 +105,7 @@ const RUNTIME_ENV_KEYS = Object.freeze({ 'GEMINI_API_KEY', 'GOOGLE_API_KEY', 'GEMINI_MODEL', 'GEMINI_CLI_HOME', 'GEMINI_DEFAULT_AUTH_TYPE', 'GEMINI_CLI_AUTH_OVERRIDE', 'GEMINI_CLI_USE_COMPUTE_ADC', 'GEMINI_CLI_SYSTEM_SETTINGS_PATH', 'GEMINI_CLI_SYSTEM_DEFAULTS_PATH', - 'GEMINI_CLI_TRUSTED_FOLDERS_PATH', + 'GEMINI_CLI_TRUSTED_FOLDERS_PATH', 'GEMINI_CLI_TRUST_WORKSPACE', 'GEMINI_RESTRICTED_MODE', 'GOOGLE_GEMINI_BASE_URL', 'GOOGLE_VERTEX_BASE_URL', 'GOOGLE_GENAI_API_VERSION', 'GOOGLE_GENAI_USE_VERTEXAI', 'GOOGLE_GENAI_USE_GCA', 'GOOGLE_CLOUD_ACCESS_TOKEN', 'GOOGLE_CLOUD_PROJECT_ID', 'GOOGLE_CLOUD_UNIVERSE_DOMAIN', ...GOOGLE_CLOUD_ENV_KEYS, diff --git a/desktop/test/agents/cli/cli-native-config-environment.test.cjs b/desktop/test/agents/cli/cli-native-config-environment.test.cjs index 2d0b41e..b3da297 100644 --- a/desktop/test/agents/cli/cli-native-config-environment.test.cjs +++ b/desktop/test/agents/cli/cli-native-config-environment.test.cjs @@ -15,6 +15,19 @@ test('declared native credentials work for a future agent without passing unsafe assert.equal(redactChildSecrets('token=synthetic-future-secret', child), 'token=[redacted]') }) +test('Gemini native workspace trust settings reach only its child process', () => { + for (const env of [{ GEMINI_CLI_TRUST_WORKSPACE: 'true' }, + { GEMINI_CLI_TRUST_WORKSPACE: 'false', GEMINI_RESTRICTED_MODE: 'true' }]) { + const native = nativeCredentialEnvironment('gemini', env) + const gemini = childEnvironment({ kind: 'gemini' }, '/workspace', { env: native }, 'darwin') + assert.equal(gemini.GEMINI_CLI_TRUST_WORKSPACE, env.GEMINI_CLI_TRUST_WORKSPACE) + assert.equal(gemini.GEMINI_RESTRICTED_MODE, env.GEMINI_RESTRICTED_MODE) + const other = childEnvironment({ kind: 'codex' }, '/workspace', { env }, 'darwin') + assert.equal(other.GEMINI_CLI_TRUST_WORKSPACE, undefined) + assert.equal(other.GEMINI_RESTRICTED_MODE, undefined) + } +}) + test('short native credentials are redacted without hiding unrelated configuration', () => { const env = { OPENAI_API_KEY: 'abc', AWS_SECRET_ACCESS_KEY: 'xy', AWS_SESSION_TOKEN: 'def', AWS_BEARER_TOKEN_BEDROCK: 'zz', AZURE_CLIENT_SECRET: 'gh', OPENAI_MODEL: 'model-name' }