UNPKG

giga-code

Version:

A personal AI CLI assistant powered by Grok for local development.

75 lines 3.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ConfirmationTool = void 0; const confirmation_service_1 = require("../utils/confirmation-service"); class ConfirmationTool { constructor() { this.confirmationService = confirmation_service_1.ConfirmationService.getInstance(); } async requestConfirmation(request) { try { // If autoAccept is true, skip the confirmation dialog if (request.autoAccept) { return { success: true, output: `Auto-accepted: ${request.operation}(${request.filename})${request.description ? ` - ${request.description}` : ''}` }; } const options = { operation: request.operation, filename: request.filename, showVSCodeOpen: request.showVSCodeOpen || false }; // Determine operation type based on operation name const operationType = request.operation.toLowerCase().includes('bash') ? 'bash' : 'file'; const result = await this.confirmationService.requestConfirmation(options, operationType); if (result.confirmed) { return { success: true, output: `User confirmed: ${request.operation}(${request.filename})${request.description ? ` - ${request.description}` : ''}${result.dontAskAgain ? ' (Don\'t ask again enabled)' : ''}` }; } else { return { success: false, error: result.feedback || `User rejected: ${request.operation}(${request.filename})` }; } } catch (error) { return { success: false, error: `Confirmation error: ${error.message}` }; } } async checkSessionAcceptance() { try { const sessionFlags = this.confirmationService.getSessionFlags(); // Return structured data without JSON output to avoid displaying raw JSON return { success: true, data: { fileOperationsAccepted: sessionFlags.fileOperations, bashCommandsAccepted: sessionFlags.bashCommands, allOperationsAccepted: sessionFlags.allOperations, hasAnyAcceptance: sessionFlags.fileOperations || sessionFlags.bashCommands || sessionFlags.allOperations } }; } catch (error) { return { success: false, error: `Error checking session acceptance: ${error.message}` }; } } resetSession() { this.confirmationService.resetSession(); } isPending() { return this.confirmationService.isPending(); } } exports.ConfirmationTool = ConfirmationTool; //# sourceMappingURL=confirmation-tool.js.map