From 5d61adf804e607af974117601d6f1e5b5900fa60 Mon Sep 17 00:00:00 2001 From: Allen Hutchison Date: Tue, 28 Oct 2025 10:18:34 -0700 Subject: [PATCH] feat: Add message bus setting guard for tool confirmation (#12169) --- packages/core/src/tools/tools.ts | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/packages/core/src/tools/tools.ts b/packages/core/src/tools/tools.ts index a69856cd72..35dac2c12d 100644 --- a/packages/core/src/tools/tools.ts +++ b/packages/core/src/tools/tools.ts @@ -114,13 +114,31 @@ export abstract class BaseToolInvocation< /** * Subclasses should override this method to provide custom confirmation UI * when the policy engine's decision is 'ASK_USER'. - * The base implementation returns false (no confirmation needed). - * Only tools that need confirmation (e.g., write, execute tools) should override this. + * The base implementation provides a generic confirmation prompt. */ protected async getConfirmationDetails( _abortSignal: AbortSignal, ): Promise { - 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(