diff --git a/packages/cli/src/config/config.test.ts b/packages/cli/src/config/config.test.ts index 3e66fcebbf..bfb6967bef 100644 --- a/packages/cli/src/config/config.test.ts +++ b/packages/cli/src/config/config.test.ts @@ -13,6 +13,7 @@ import { SHELL_TOOL_NAME, WRITE_FILE_TOOL_NAME, EDIT_TOOL_NAME, + WEB_FETCH_TOOL_NAME, type ExtensionLoader, debugLogger, } from '@google/gemini-cli-core'; @@ -767,6 +768,7 @@ describe('mergeExcludeTools', () => { SHELL_TOOL_NAME, EDIT_TOOL_NAME, WRITE_FILE_TOOL_NAME, + WEB_FETCH_TOOL_NAME, ]); const originalIsTTY = process.stdin.isTTY; @@ -1645,6 +1647,29 @@ describe('loadCliConfig tool exclusions', () => { expect(config.getExcludeTools()).not.toContain(SHELL_TOOL_NAME); }); + it('should exclude web-fetch in non-interactive mode when not allowed', async () => { + process.stdin.isTTY = false; + process.argv = ['node', 'script.js', '-p', 'test']; + const argv = await parseArguments({} as Settings); + const config = await loadCliConfig({}, 'test-session', argv); + expect(config.getExcludeTools()).toContain(WEB_FETCH_TOOL_NAME); + }); + + it('should not exclude web-fetch in non-interactive mode when allowed', async () => { + process.stdin.isTTY = false; + process.argv = [ + 'node', + 'script.js', + '-p', + 'test', + '--allowed-tools', + WEB_FETCH_TOOL_NAME, + ]; + const argv = await parseArguments({} as Settings); + const config = await loadCliConfig({}, 'test-session', argv); + expect(config.getExcludeTools()).not.toContain(WEB_FETCH_TOOL_NAME); + }); + it('should not exclude shell tool in non-interactive mode when --allowed-tools="run_shell_command" is set', async () => { process.stdin.isTTY = false; process.argv = [ diff --git a/packages/cli/src/config/config.ts b/packages/cli/src/config/config.ts index 7e4f1cd4d0..3a85a0760a 100755 --- a/packages/cli/src/config/config.ts +++ b/packages/cli/src/config/config.ts @@ -29,6 +29,7 @@ import { EDIT_TOOL_NAME, debugLogger, loadServerHierarchicalMemory, + WEB_FETCH_TOOL_NAME, } from '@google/gemini-cli-core'; import type { Settings } from './settings.js'; @@ -530,6 +531,7 @@ export async function loadCliConfig( SHELL_TOOL_NAME, EDIT_TOOL_NAME, WRITE_FILE_TOOL_NAME, + WEB_FETCH_TOOL_NAME, ]; const autoEditExcludes = [SHELL_TOOL_NAME];