mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-13 05:12:55 -07:00
fix: Exclude web-fetch tool from executing in default non-interactive mode to avoid CLI hang. (#14244)
This commit is contained in:
@@ -13,6 +13,7 @@ import {
|
|||||||
SHELL_TOOL_NAME,
|
SHELL_TOOL_NAME,
|
||||||
WRITE_FILE_TOOL_NAME,
|
WRITE_FILE_TOOL_NAME,
|
||||||
EDIT_TOOL_NAME,
|
EDIT_TOOL_NAME,
|
||||||
|
WEB_FETCH_TOOL_NAME,
|
||||||
type ExtensionLoader,
|
type ExtensionLoader,
|
||||||
debugLogger,
|
debugLogger,
|
||||||
} from '@google/gemini-cli-core';
|
} from '@google/gemini-cli-core';
|
||||||
@@ -767,6 +768,7 @@ describe('mergeExcludeTools', () => {
|
|||||||
SHELL_TOOL_NAME,
|
SHELL_TOOL_NAME,
|
||||||
EDIT_TOOL_NAME,
|
EDIT_TOOL_NAME,
|
||||||
WRITE_FILE_TOOL_NAME,
|
WRITE_FILE_TOOL_NAME,
|
||||||
|
WEB_FETCH_TOOL_NAME,
|
||||||
]);
|
]);
|
||||||
const originalIsTTY = process.stdin.isTTY;
|
const originalIsTTY = process.stdin.isTTY;
|
||||||
|
|
||||||
@@ -1645,6 +1647,29 @@ describe('loadCliConfig tool exclusions', () => {
|
|||||||
expect(config.getExcludeTools()).not.toContain(SHELL_TOOL_NAME);
|
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 () => {
|
it('should not exclude shell tool in non-interactive mode when --allowed-tools="run_shell_command" is set', async () => {
|
||||||
process.stdin.isTTY = false;
|
process.stdin.isTTY = false;
|
||||||
process.argv = [
|
process.argv = [
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import {
|
|||||||
EDIT_TOOL_NAME,
|
EDIT_TOOL_NAME,
|
||||||
debugLogger,
|
debugLogger,
|
||||||
loadServerHierarchicalMemory,
|
loadServerHierarchicalMemory,
|
||||||
|
WEB_FETCH_TOOL_NAME,
|
||||||
} from '@google/gemini-cli-core';
|
} from '@google/gemini-cli-core';
|
||||||
import type { Settings } from './settings.js';
|
import type { Settings } from './settings.js';
|
||||||
|
|
||||||
@@ -530,6 +531,7 @@ export async function loadCliConfig(
|
|||||||
SHELL_TOOL_NAME,
|
SHELL_TOOL_NAME,
|
||||||
EDIT_TOOL_NAME,
|
EDIT_TOOL_NAME,
|
||||||
WRITE_FILE_TOOL_NAME,
|
WRITE_FILE_TOOL_NAME,
|
||||||
|
WEB_FETCH_TOOL_NAME,
|
||||||
];
|
];
|
||||||
const autoEditExcludes = [SHELL_TOOL_NAME];
|
const autoEditExcludes = [SHELL_TOOL_NAME];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user