mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-13 05:12:55 -07:00
feat: Add message bus setting guard for tool confirmation (#12169)
This commit is contained in:
@@ -114,13 +114,31 @@ export abstract class BaseToolInvocation<
|
|||||||
/**
|
/**
|
||||||
* Subclasses should override this method to provide custom confirmation UI
|
* Subclasses should override this method to provide custom confirmation UI
|
||||||
* when the policy engine's decision is 'ASK_USER'.
|
* when the policy engine's decision is 'ASK_USER'.
|
||||||
* The base implementation returns false (no confirmation needed).
|
* The base implementation provides a generic confirmation prompt.
|
||||||
* Only tools that need confirmation (e.g., write, execute tools) should override this.
|
|
||||||
*/
|
*/
|
||||||
protected async getConfirmationDetails(
|
protected async getConfirmationDetails(
|
||||||
_abortSignal: AbortSignal,
|
_abortSignal: AbortSignal,
|
||||||
): Promise<ToolCallConfirmationDetails | false> {
|
): Promise<ToolCallConfirmationDetails | false> {
|
||||||
return false;
|
if (!this.messageBus) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const confirmationDetails: ToolCallConfirmationDetails = {
|
||||||
|
type: 'info',
|
||||||
|
title: `Confirm: ${this._toolDisplayName || this._toolName}`,
|
||||||
|
prompt: this.getDescription(),
|
||||||
|
onConfirm: async (outcome: ToolConfirmationOutcome) => {
|
||||||
|
if (outcome === ToolConfirmationOutcome.ProceedAlways) {
|
||||||
|
if (this.messageBus && this._toolName) {
|
||||||
|
this.messageBus.publish({
|
||||||
|
type: MessageBusType.UPDATE_POLICY,
|
||||||
|
toolName: this._toolName,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
return confirmationDetails;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected getMessageBusDecision(
|
protected getMessageBusDecision(
|
||||||
|
|||||||
Reference in New Issue
Block a user