UNPKG

capsule-ai-cli

Version:

The AI Model Orchestrator - Intelligent multi-model workflows with device-locked licensing

36 lines 1.43 kB
import { EventEmitter } from 'events'; class ToolExecutionService extends EventEmitter { confirmationResolvers = new Map(); pendingConfirmations = new Map(); emitToolExecution(event) { this.emit('tool-execution', event); } async requestConfirmation(toolCallId, type, data) { this.pendingConfirmations.set(toolCallId, { toolCallId, type, data }); this.emit('confirmation-needed', { toolCallId, type, data }); return new Promise((resolve, reject) => { this.confirmationResolvers.set(toolCallId, { resolve, reject }); }); } resolveConfirmation(toolCallId, approved) { const resolver = this.confirmationResolvers.get(toolCallId); if (resolver) { resolver.resolve(approved); this.confirmationResolvers.delete(toolCallId); this.pendingConfirmations.delete(toolCallId); } } rejectConfirmation(toolCallId, error) { const resolver = this.confirmationResolvers.get(toolCallId); if (resolver) { resolver.reject(error); this.confirmationResolvers.delete(toolCallId); this.pendingConfirmations.delete(toolCallId); } } getPendingConfirmation(toolCallId) { return this.pendingConfirmations.get(toolCallId); } } export const toolExecutionService = new ToolExecutionService(); //# sourceMappingURL=tool-execution.js.map