mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-02 07:54:48 -07:00
feat(core): Introduce message bus for tool execution confirmation (#11544)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
@@ -42,6 +42,7 @@ import { FileOperationEvent } from '../telemetry/types.js';
|
||||
import { FileOperation } from '../telemetry/metrics.js';
|
||||
import { getSpecificMimeType } from '../utils/fileUtils.js';
|
||||
import { getLanguageFromFilePath } from '../utils/language-detection.js';
|
||||
import type { MessageBus } from '../confirmation-bus/message-bus.js';
|
||||
|
||||
/**
|
||||
* Parameters for the WriteFile tool
|
||||
@@ -144,8 +145,11 @@ class WriteFileToolInvocation extends BaseToolInvocation<
|
||||
constructor(
|
||||
private readonly config: Config,
|
||||
params: WriteFileToolParams,
|
||||
messageBus?: MessageBus,
|
||||
toolName?: string,
|
||||
displayName?: string,
|
||||
) {
|
||||
super(params);
|
||||
super(params, messageBus, toolName, displayName);
|
||||
}
|
||||
|
||||
override toolLocations(): ToolLocation[] {
|
||||
@@ -160,7 +164,7 @@ class WriteFileToolInvocation extends BaseToolInvocation<
|
||||
return `Writing to ${shortenPath(relativePath)}`;
|
||||
}
|
||||
|
||||
override async shouldConfirmExecute(
|
||||
protected override async getConfirmationDetails(
|
||||
abortSignal: AbortSignal,
|
||||
): Promise<ToolCallConfirmationDetails | false> {
|
||||
if (this.config.getApprovalMode() === ApprovalMode.AUTO_EDIT) {
|
||||
@@ -392,7 +396,10 @@ export class WriteFileTool
|
||||
{
|
||||
static readonly Name = WRITE_FILE_TOOL_NAME;
|
||||
|
||||
constructor(private readonly config: Config) {
|
||||
constructor(
|
||||
private readonly config: Config,
|
||||
messageBus?: MessageBus,
|
||||
) {
|
||||
super(
|
||||
WriteFileTool.Name,
|
||||
'WriteFile',
|
||||
@@ -415,6 +422,9 @@ export class WriteFileTool
|
||||
required: ['file_path', 'content'],
|
||||
type: 'object',
|
||||
},
|
||||
true,
|
||||
false,
|
||||
messageBus,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -458,7 +468,13 @@ export class WriteFileTool
|
||||
protected createInvocation(
|
||||
params: WriteFileToolParams,
|
||||
): ToolInvocation<WriteFileToolParams, ToolResult> {
|
||||
return new WriteFileToolInvocation(this.config, params);
|
||||
return new WriteFileToolInvocation(
|
||||
this.config,
|
||||
params,
|
||||
this.messageBus,
|
||||
this.name,
|
||||
this.displayName,
|
||||
);
|
||||
}
|
||||
|
||||
getModifyContext(
|
||||
|
||||
Reference in New Issue
Block a user