feat: Add message bus setting guard for tool confirmation (#12169)

This commit is contained in:
Allen Hutchison
2025-10-28 10:18:34 -07:00
committed by GitHub
parent 4e6eef5882
commit 5d61adf804

View File

@@ -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<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(