mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-12 21:03:05 -07:00
Fix linter.,
This commit is contained in:
@@ -19,7 +19,7 @@ import {
|
|||||||
} from '../tools/tools.js';
|
} from '../tools/tools.js';
|
||||||
import { createMockMessageBus } from './mock-message-bus.js';
|
import { createMockMessageBus } from './mock-message-bus.js';
|
||||||
import type { MessageBus } from '../confirmation-bus/message-bus.js';
|
import type { MessageBus } from '../confirmation-bus/message-bus.js';
|
||||||
import type { ShellExecutionConfig } from 'src/services/shellExecutionService.js';
|
import type { ShellExecutionConfig } from '../services/shellExecutionService.js';
|
||||||
|
|
||||||
interface MockToolOptions {
|
interface MockToolOptions {
|
||||||
name: string;
|
name: string;
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ import { ToolErrorType } from './tool-error.js';
|
|||||||
import { makeRelative, shortenPath } from '../utils/paths.js';
|
import { makeRelative, shortenPath } from '../utils/paths.js';
|
||||||
import { isNodeError } from '../utils/errors.js';
|
import { isNodeError } from '../utils/errors.js';
|
||||||
import type { Config } from '../config/config.js';
|
import type { Config } from '../config/config.js';
|
||||||
import { type ApprovalMode } from '../policy/types.js';
|
|
||||||
import { CoreToolCallStatus } from '../scheduler/types.js';
|
import { CoreToolCallStatus } from '../scheduler/types.js';
|
||||||
|
|
||||||
import { DEFAULT_DIFF_OPTIONS, getDiffStat } from './diffOptions.js';
|
import { DEFAULT_DIFF_OPTIONS, getDiffStat } from './diffOptions.js';
|
||||||
@@ -449,7 +448,16 @@ class EditToolInvocation
|
|||||||
toolName?: string,
|
toolName?: string,
|
||||||
displayName?: string,
|
displayName?: string,
|
||||||
) {
|
) {
|
||||||
super(params, messageBus, toolName, displayName);
|
super(
|
||||||
|
params,
|
||||||
|
messageBus,
|
||||||
|
toolName,
|
||||||
|
displayName,
|
||||||
|
undefined,
|
||||||
|
undefined,
|
||||||
|
true,
|
||||||
|
() => this.config.getApprovalMode(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
override toolLocations(): ToolLocation[] {
|
override toolLocations(): ToolLocation[] {
|
||||||
@@ -699,14 +707,6 @@ class EditToolInvocation
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override get respectsAutoEdit(): boolean {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override getApprovalMode(): ApprovalMode {
|
|
||||||
return this.config.getApprovalMode();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the confirmation prompt for the Edit tool in the CLI.
|
* Handles the confirmation prompt for the Edit tool in the CLI.
|
||||||
* It needs to calculate the diff to show the user.
|
* It needs to calculate the diff to show the user.
|
||||||
|
|||||||
@@ -99,6 +99,8 @@ export abstract class BaseToolInvocation<
|
|||||||
readonly _toolDisplayName?: string,
|
readonly _toolDisplayName?: string,
|
||||||
readonly _serverName?: string,
|
readonly _serverName?: string,
|
||||||
readonly _toolAnnotations?: Record<string, unknown>,
|
readonly _toolAnnotations?: Record<string, unknown>,
|
||||||
|
readonly respectsAutoEdit: boolean = false,
|
||||||
|
readonly getApprovalMode: () => ApprovalMode = () => ApprovalMode.DEFAULT,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
abstract getDescription(): string;
|
abstract getDescription(): string;
|
||||||
@@ -141,23 +143,6 @@ export abstract class BaseToolInvocation<
|
|||||||
return this.getConfirmationDetails(abortSignal);
|
return this.getConfirmationDetails(abortSignal);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether this tool respects the AUTO_EDIT approval mode.
|
|
||||||
* Subclasses should override this and return true if they want to skip
|
|
||||||
* confirmation when the session is in AUTO_EDIT mode.
|
|
||||||
*/
|
|
||||||
protected get respectsAutoEdit(): boolean {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the current approval mode from the tool configuration.
|
|
||||||
* Subclasses should override this and return the actual approval mode.
|
|
||||||
*/
|
|
||||||
protected getApprovalMode(): ApprovalMode {
|
|
||||||
return ApprovalMode.DEFAULT;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns tool-specific options for policy updates.
|
* Returns tool-specific options for policy updates.
|
||||||
* Subclasses can override this to provide additional options like
|
* Subclasses can override this to provide additional options like
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import type { MessageBus } from '../confirmation-bus/message-bus.js';
|
|||||||
import { ToolErrorType } from './tool-error.js';
|
import { ToolErrorType } from './tool-error.js';
|
||||||
import { getErrorMessage } from '../utils/errors.js';
|
import { getErrorMessage } from '../utils/errors.js';
|
||||||
import type { Config } from '../config/config.js';
|
import type { Config } from '../config/config.js';
|
||||||
import { type ApprovalMode } from '../policy/types.js';
|
|
||||||
import { getResponseText } from '../utils/partUtils.js';
|
import { getResponseText } from '../utils/partUtils.js';
|
||||||
import { fetchWithTimeout, isPrivateIp } from '../utils/fetch.js';
|
import { fetchWithTimeout, isPrivateIp } from '../utils/fetch.js';
|
||||||
import { truncateString } from '../utils/textUtils.js';
|
import { truncateString } from '../utils/textUtils.js';
|
||||||
@@ -181,7 +180,16 @@ class WebFetchToolInvocation extends BaseToolInvocation<
|
|||||||
_toolName?: string,
|
_toolName?: string,
|
||||||
_toolDisplayName?: string,
|
_toolDisplayName?: string,
|
||||||
) {
|
) {
|
||||||
super(params, messageBus, _toolName, _toolDisplayName);
|
super(
|
||||||
|
params,
|
||||||
|
messageBus,
|
||||||
|
_toolName,
|
||||||
|
_toolDisplayName,
|
||||||
|
undefined,
|
||||||
|
undefined,
|
||||||
|
true,
|
||||||
|
() => this.config.getApprovalMode(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async executeFallback(signal: AbortSignal): Promise<ToolResult> {
|
private async executeFallback(signal: AbortSignal): Promise<ToolResult> {
|
||||||
@@ -291,14 +299,6 @@ ${textContent}
|
|||||||
return `Processing URLs and instructions from prompt: "${displayPrompt}"`;
|
return `Processing URLs and instructions from prompt: "${displayPrompt}"`;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override get respectsAutoEdit(): boolean {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override getApprovalMode(): ApprovalMode {
|
|
||||||
return this.config.getApprovalMode();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override async getConfirmationDetails(
|
protected override async getConfirmationDetails(
|
||||||
_abortSignal: AbortSignal,
|
_abortSignal: AbortSignal,
|
||||||
): Promise<ToolCallConfirmationDetails | false> {
|
): Promise<ToolCallConfirmationDetails | false> {
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import os from 'node:os';
|
|||||||
import * as Diff from 'diff';
|
import * as Diff from 'diff';
|
||||||
import { WRITE_FILE_TOOL_NAME, WRITE_FILE_DISPLAY_NAME } from './tool-names.js';
|
import { WRITE_FILE_TOOL_NAME, WRITE_FILE_DISPLAY_NAME } from './tool-names.js';
|
||||||
import type { Config } from '../config/config.js';
|
import type { Config } from '../config/config.js';
|
||||||
import { type ApprovalMode } from '../policy/types.js';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
BaseDeclarativeTool,
|
BaseDeclarativeTool,
|
||||||
@@ -153,7 +152,16 @@ class WriteFileToolInvocation extends BaseToolInvocation<
|
|||||||
toolName?: string,
|
toolName?: string,
|
||||||
displayName?: string,
|
displayName?: string,
|
||||||
) {
|
) {
|
||||||
super(params, messageBus, toolName, displayName);
|
super(
|
||||||
|
params,
|
||||||
|
messageBus,
|
||||||
|
toolName,
|
||||||
|
displayName,
|
||||||
|
undefined,
|
||||||
|
undefined,
|
||||||
|
true,
|
||||||
|
() => this.config.getApprovalMode(),
|
||||||
|
);
|
||||||
this.resolvedPath = path.resolve(
|
this.resolvedPath = path.resolve(
|
||||||
this.config.getTargetDir(),
|
this.config.getTargetDir(),
|
||||||
this.params.file_path,
|
this.params.file_path,
|
||||||
@@ -172,14 +180,6 @@ class WriteFileToolInvocation extends BaseToolInvocation<
|
|||||||
return `Writing to ${shortenPath(relativePath)}`;
|
return `Writing to ${shortenPath(relativePath)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override get respectsAutoEdit(): boolean {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override getApprovalMode(): ApprovalMode {
|
|
||||||
return this.config.getApprovalMode();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override async getConfirmationDetails(
|
protected override async getConfirmationDetails(
|
||||||
_abortSignal: AbortSignal,
|
_abortSignal: AbortSignal,
|
||||||
): Promise<ToolCallConfirmationDetails | false> {
|
): Promise<ToolCallConfirmationDetails | false> {
|
||||||
|
|||||||
Reference in New Issue
Block a user