@juspay/neurolink
Version:
Universal AI Development Platform with working MCP integration, multi-provider support, voice (TTS/STT/realtime), and professional CLI. 58+ external MCP servers discoverable, multimodal file processing, RAG pipelines. Build, test, and deploy AI applicatio
170 lines (169 loc) • 4.61 kB
TypeScript
/**
* Elicitation Manager
*
* Manager for handling elicitation requests during tool execution.
* Enables MCP tools to request interactive user input mid-execution.
*
* @module mcp/elicitation/elicitationManager
* @since 8.39.0
*/
import { EventEmitter } from "events";
import type { Elicitation, ElicitationResponse, ElicitationHandler, ElicitationManagerConfig, FormField } from "../../types/index.js";
/**
* Manager for handling elicitation requests during tool execution
*
* The elicitation protocol allows MCP tools to request interactive user input
* mid-execution. This is useful for:
* - Confirming destructive operations
* - Requesting missing information
* - Getting user preferences
* - Handling authentication challenges
*
* @example
* ```typescript
* const elicitationManager = new ElicitationManager({
* defaultTimeout: 60000,
* handler: async (request) => {
* // Implement UI prompt based on request type
* if (request.type === "confirmation") {
* const confirmed = await showConfirmDialog(request.message);
* return {
* requestId: request.id,
* responded: true,
* value: confirmed,
* timestamp: Date.now(),
* };
* }
* // Handle other types...
* },
* });
*
* // Use in a tool
* const response = await elicitationManager.request({
* type: "confirmation",
* message: "Are you sure you want to delete this file?",
* toolName: "deleteFile",
* });
*
* if (response.value === true) {
* // Proceed with deletion
* }
* ```
*/
export declare class ElicitationManager extends EventEmitter {
private config;
private pendingRequests;
constructor(config?: ElicitationManagerConfig);
/**
* Set the elicitation handler
*/
setHandler(handler: ElicitationHandler): void;
/**
* Enable or disable elicitation
*/
setEnabled(enabled: boolean): void;
/**
* Check if elicitation is enabled
*/
isEnabled(): boolean;
/**
* Request user input
*/
request(elicitation: Omit<Elicitation, "id"> & {
id?: string;
}): Promise<ElicitationResponse>;
/**
* Convenience method for confirmation requests
*/
confirm(message: string, options?: {
toolName?: string;
serverId?: string;
confirmLabel?: string;
cancelLabel?: string;
timeout?: number;
}): Promise<boolean>;
/**
* Convenience method for text input
*/
getText(message: string, options?: {
toolName?: string;
placeholder?: string;
defaultValue?: string;
timeout?: number;
}): Promise<string | undefined>;
/**
* Convenience method for selection
*/
select<T extends string>(message: string, options: Array<{
value: T;
label: string;
}>, config?: {
toolName?: string;
timeout?: number;
}): Promise<T | undefined>;
/**
* Convenience method for multiple selection
*/
multiSelect<T extends string>(message: string, options: Array<{
value: T;
label: string;
}>, config?: {
toolName?: string;
timeout?: number;
minSelections?: number;
maxSelections?: number;
}): Promise<T[] | undefined>;
/**
* Convenience method for form input
*/
form<T extends Record<string, unknown>>(message: string, fields: FormField[], config?: {
toolName?: string;
serverId?: string;
timeout?: number;
submitLabel?: string;
}): Promise<T | undefined>;
/**
* Convenience method for secret input
*/
getSecret(message: string, options?: {
toolName?: string;
hint?: string;
timeout?: number;
}): Promise<string | undefined>;
/**
* Cancel a pending request
*/
cancel(requestId: string, reason?: string): void;
/**
* Default handler when none is provided
*/
private defaultHandler;
/**
* Handle timeout
*/
private handleTimeout;
/**
* Handle disabled elicitation
*/
private handleDisabled;
/**
* Handle disabled request based on fallback behavior
*/
private handleDisabledRequest;
/**
* Get pending request count
*/
getPendingCount(): number;
/**
* Get all pending requests
*/
getPendingRequests(): Elicitation[];
/**
* Clear all pending requests
*/
clearPending(reason?: string): void;
}
/**
* Global elicitation manager instance
*/
export declare const globalElicitationManager: ElicitationManager;