Fix linter.,

This commit is contained in:
Christian Gunderman
2026-03-07 13:23:12 -08:00
parent 10f1dff6dd
commit e05de8f870
5 changed files with 33 additions and 48 deletions

View File

@@ -19,7 +19,7 @@ import {
} from '../tools/tools.js';
import { createMockMessageBus } from './mock-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 {
name: string;

View File

@@ -26,7 +26,6 @@ import { ToolErrorType } from './tool-error.js';
import { makeRelative, shortenPath } from '../utils/paths.js';
import { isNodeError } from '../utils/errors.js';
import type { Config } from '../config/config.js';
import { type ApprovalMode } from '../policy/types.js';
import { CoreToolCallStatus } from '../scheduler/types.js';
import { DEFAULT_DIFF_OPTIONS, getDiffStat } from './diffOptions.js';
@@ -449,7 +448,16 @@ class EditToolInvocation
toolName?: string,
displayName?: string,
) {
super(params, messageBus, toolName, displayName);
super(
params,
messageBus,
toolName,
displayName,
undefined,
undefined,
true,
() => this.config.getApprovalMode(),
);
}
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.
* It needs to calculate the diff to show the user.

View File

@@ -99,6 +99,8 @@ export abstract class BaseToolInvocation<
readonly _toolDisplayName?: string,
readonly _serverName?: string,
readonly _toolAnnotations?: Record<string, unknown>,
readonly respectsAutoEdit: boolean = false,
readonly getApprovalMode: () => ApprovalMode = () => ApprovalMode.DEFAULT,
) {}
abstract getDescription(): string;
@@ -141,23 +143,6 @@ export abstract class BaseToolInvocation<
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.
* Subclasses can override this to provide additional options like

View File

@@ -17,7 +17,6 @@ import type { MessageBus } from '../confirmation-bus/message-bus.js';
import { ToolErrorType } from './tool-error.js';
import { getErrorMessage } from '../utils/errors.js';
import type { Config } from '../config/config.js';
import { type ApprovalMode } from '../policy/types.js';
import { getResponseText } from '../utils/partUtils.js';
import { fetchWithTimeout, isPrivateIp } from '../utils/fetch.js';
import { truncateString } from '../utils/textUtils.js';
@@ -181,7 +180,16 @@ class WebFetchToolInvocation extends BaseToolInvocation<
_toolName?: 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> {
@@ -291,14 +299,6 @@ ${textContent}
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(
_abortSignal: AbortSignal,
): Promise<ToolCallConfirmationDetails | false> {

View File

@@ -11,7 +11,6 @@ import os from 'node:os';
import * as Diff from 'diff';
import { WRITE_FILE_TOOL_NAME, WRITE_FILE_DISPLAY_NAME } from './tool-names.js';
import type { Config } from '../config/config.js';
import { type ApprovalMode } from '../policy/types.js';
import {
BaseDeclarativeTool,
@@ -153,7 +152,16 @@ class WriteFileToolInvocation extends BaseToolInvocation<
toolName?: string,
displayName?: string,
) {
super(params, messageBus, toolName, displayName);
super(
params,
messageBus,
toolName,
displayName,
undefined,
undefined,
true,
() => this.config.getApprovalMode(),
);
this.resolvedPath = path.resolve(
this.config.getTargetDir(),
this.params.file_path,
@@ -172,14 +180,6 @@ class WriteFileToolInvocation extends BaseToolInvocation<
return `Writing to ${shortenPath(relativePath)}`;
}
protected override get respectsAutoEdit(): boolean {
return true;
}
protected override getApprovalMode(): ApprovalMode {
return this.config.getApprovalMode();
}
protected override async getConfirmationDetails(
_abortSignal: AbortSignal,
): Promise<ToolCallConfirmationDetails | false> {