mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-13 05:12:55 -07:00
refactor: move web_fetch tool name to tool-names.ts (#11174)
This commit is contained in:
@@ -7,7 +7,11 @@
|
|||||||
import { describe, it, expect } from 'vitest';
|
import { describe, it, expect } from 'vitest';
|
||||||
import { createPolicyEngineConfig } from './policy.js';
|
import { createPolicyEngineConfig } from './policy.js';
|
||||||
import type { Settings } from './settings.js';
|
import type { Settings } from './settings.js';
|
||||||
import { ApprovalMode, PolicyDecision } from '@google/gemini-cli-core';
|
import {
|
||||||
|
ApprovalMode,
|
||||||
|
PolicyDecision,
|
||||||
|
WEB_FETCH_TOOL_NAME,
|
||||||
|
} from '@google/gemini-cli-core';
|
||||||
|
|
||||||
describe('createPolicyEngineConfig', () => {
|
describe('createPolicyEngineConfig', () => {
|
||||||
it('should return ASK_USER for all tools by default', () => {
|
it('should return ASK_USER for all tools by default', () => {
|
||||||
@@ -19,7 +23,7 @@ describe('createPolicyEngineConfig', () => {
|
|||||||
{ toolName: 'save_memory', decision: 'ask_user', priority: 10 },
|
{ toolName: 'save_memory', decision: 'ask_user', priority: 10 },
|
||||||
{ toolName: 'run_shell_command', decision: 'ask_user', priority: 10 },
|
{ toolName: 'run_shell_command', decision: 'ask_user', priority: 10 },
|
||||||
{ toolName: 'write_file', decision: 'ask_user', priority: 10 },
|
{ toolName: 'write_file', decision: 'ask_user', priority: 10 },
|
||||||
{ toolName: 'web_fetch', decision: 'ask_user', priority: 10 },
|
{ toolName: WEB_FETCH_TOOL_NAME, decision: 'ask_user', priority: 10 },
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -366,7 +370,7 @@ describe('createPolicyEngineConfig', () => {
|
|||||||
'save_memory',
|
'save_memory',
|
||||||
'run_shell_command',
|
'run_shell_command',
|
||||||
'write_file',
|
'write_file',
|
||||||
'web_fetch',
|
WEB_FETCH_TOOL_NAME,
|
||||||
].includes(r.toolName || '') && r.decision === PolicyDecision.ASK_USER,
|
].includes(r.toolName || '') && r.decision === PolicyDecision.ASK_USER,
|
||||||
);
|
);
|
||||||
expect(writeToolRules).toHaveLength(0);
|
expect(writeToolRules).toHaveLength(0);
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import {
|
|||||||
MemoryTool,
|
MemoryTool,
|
||||||
ShellTool,
|
ShellTool,
|
||||||
WRITE_FILE_TOOL_NAME,
|
WRITE_FILE_TOOL_NAME,
|
||||||
WebFetchTool,
|
WEB_FETCH_TOOL_NAME,
|
||||||
WebSearchTool,
|
WebSearchTool,
|
||||||
} from '@google/gemini-cli-core';
|
} from '@google/gemini-cli-core';
|
||||||
import type { Settings } from './settings.js';
|
import type { Settings } from './settings.js';
|
||||||
@@ -49,7 +49,7 @@ const WRITE_TOOLS = new Set([
|
|||||||
MemoryTool.Name,
|
MemoryTool.Name,
|
||||||
ShellTool.Name,
|
ShellTool.Name,
|
||||||
WRITE_FILE_TOOL_NAME,
|
WRITE_FILE_TOOL_NAME,
|
||||||
WebFetchTool.Name,
|
WEB_FETCH_TOOL_NAME,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
export function createPolicyEngineConfig(
|
export function createPolicyEngineConfig(
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ export const GLOB_TOOL_NAME = 'glob';
|
|||||||
export const WRITE_TODOS_TOOL_NAME = 'write_todos';
|
export const WRITE_TODOS_TOOL_NAME = 'write_todos';
|
||||||
export const WRITE_FILE_TOOL_NAME = 'write_file';
|
export const WRITE_FILE_TOOL_NAME = 'write_file';
|
||||||
export const WEB_SEARCH_TOOL_NAME = 'google_web_search';
|
export const WEB_SEARCH_TOOL_NAME = 'google_web_search';
|
||||||
|
export const WEB_FETCH_TOOL_NAME = 'web_fetch';
|
||||||
|
|
||||||
// TODO: Migrate other tool names here to follow this pattern and prevent future circular dependencies.
|
// TODO: Migrate other tool names here to follow this pattern and prevent future circular dependencies.
|
||||||
// Candidates for migration:
|
// Candidates for migration:
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import {
|
|||||||
logWebFetchFallbackAttempt,
|
logWebFetchFallbackAttempt,
|
||||||
WebFetchFallbackAttemptEvent,
|
WebFetchFallbackAttemptEvent,
|
||||||
} from '../telemetry/index.js';
|
} from '../telemetry/index.js';
|
||||||
|
import { WEB_FETCH_TOOL_NAME } from './tool-names.js';
|
||||||
|
|
||||||
const URL_FETCH_TIMEOUT_MS = 10000;
|
const URL_FETCH_TIMEOUT_MS = 10000;
|
||||||
const MAX_CONTENT_LENGTH = 100000;
|
const MAX_CONTENT_LENGTH = 100000;
|
||||||
@@ -379,7 +380,7 @@ export class WebFetchTool extends BaseDeclarativeTool<
|
|||||||
WebFetchToolParams,
|
WebFetchToolParams,
|
||||||
ToolResult
|
ToolResult
|
||||||
> {
|
> {
|
||||||
static readonly Name: string = 'web_fetch';
|
static readonly Name: string = WEB_FETCH_TOOL_NAME;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly config: Config,
|
private readonly config: Config,
|
||||||
|
|||||||
Reference in New Issue
Block a user