Skip to content

Commit c9c633b

Browse files
authored
refactor: move web_fetch tool name to tool-names.ts (#11174)
1 parent 130f0a0 commit c9c633b

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

packages/cli/src/config/policy.test.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
import { describe, it, expect } from 'vitest';
88
import { createPolicyEngineConfig } from './policy.js';
99
import type { Settings } from './settings.js';
10-
import { ApprovalMode, PolicyDecision } from '@google/gemini-cli-core';
10+
import {
11+
ApprovalMode,
12+
PolicyDecision,
13+
WEB_FETCH_TOOL_NAME,
14+
} from '@google/gemini-cli-core';
1115

1216
describe('createPolicyEngineConfig', () => {
1317
it('should return ASK_USER for all tools by default', () => {
@@ -19,7 +23,7 @@ describe('createPolicyEngineConfig', () => {
1923
{ toolName: 'save_memory', decision: 'ask_user', priority: 10 },
2024
{ toolName: 'run_shell_command', decision: 'ask_user', priority: 10 },
2125
{ toolName: 'write_file', decision: 'ask_user', priority: 10 },
22-
{ toolName: 'web_fetch', decision: 'ask_user', priority: 10 },
26+
{ toolName: WEB_FETCH_TOOL_NAME, decision: 'ask_user', priority: 10 },
2327
]);
2428
});
2529

@@ -366,7 +370,7 @@ describe('createPolicyEngineConfig', () => {
366370
'save_memory',
367371
'run_shell_command',
368372
'write_file',
369-
'web_fetch',
373+
WEB_FETCH_TOOL_NAME,
370374
].includes(r.toolName || '') && r.decision === PolicyDecision.ASK_USER,
371375
);
372376
expect(writeToolRules).toHaveLength(0);

packages/cli/src/config/policy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
MemoryTool,
2222
ShellTool,
2323
WRITE_FILE_TOOL_NAME,
24-
WebFetchTool,
24+
WEB_FETCH_TOOL_NAME,
2525
WebSearchTool,
2626
} from '@google/gemini-cli-core';
2727
import type { Settings } from './settings.js';
@@ -49,7 +49,7 @@ const WRITE_TOOLS = new Set([
4949
MemoryTool.Name,
5050
ShellTool.Name,
5151
WRITE_FILE_TOOL_NAME,
52-
WebFetchTool.Name,
52+
WEB_FETCH_TOOL_NAME,
5353
]);
5454

5555
export function createPolicyEngineConfig(

packages/core/src/tools/tool-names.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export const GLOB_TOOL_NAME = 'glob';
1212
export const WRITE_TODOS_TOOL_NAME = 'write_todos';
1313
export const WRITE_FILE_TOOL_NAME = 'write_file';
1414
export const WEB_SEARCH_TOOL_NAME = 'google_web_search';
15+
export const WEB_FETCH_TOOL_NAME = 'web_fetch';
1516

1617
// TODO: Migrate other tool names here to follow this pattern and prevent future circular dependencies.
1718
// Candidates for migration:

packages/core/src/tools/web-fetch.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
logWebFetchFallbackAttempt,
2929
WebFetchFallbackAttemptEvent,
3030
} from '../telemetry/index.js';
31+
import { WEB_FETCH_TOOL_NAME } from './tool-names.js';
3132

3233
const URL_FETCH_TIMEOUT_MS = 10000;
3334
const MAX_CONTENT_LENGTH = 100000;
@@ -379,7 +380,7 @@ export class WebFetchTool extends BaseDeclarativeTool<
379380
WebFetchToolParams,
380381
ToolResult
381382
> {
382-
static readonly Name: string = 'web_fetch';
383+
static readonly Name: string = WEB_FETCH_TOOL_NAME;
383384

384385
constructor(
385386
private readonly config: Config,

0 commit comments

Comments
 (0)