import { type OnModuleDestroy } from '@nestjs/common'; import { type ResolvedElicitationOptions } from '../interfaces/elicitation-options.interface'; import { type IElicitationStore } from '../interfaces/elicitation-store.interface'; import type { CompleteElicitationParams, CreateElicitationParams, ElicitationRecord, ElicitationResultRecord } from '../interfaces/elicitation.interface'; /** Callback invoked once an elicitation completes. */ export type CompletionNotifier = () => Promise; /** Options accepted by {@link UrlElicitationHandle.waitForCompletion}. */ export interface ElicitationWaitOptions { signal?: AbortSignal; /** Reject after this many milliseconds without a form submission. */ timeoutMs?: number; } /** * Returned from {@link ElicitationService.startUrlElicitation}. Tool handlers * surface the `url` to the MCP client (typically via `ctx.elicit({ mode: * 'url', ... })`) and `await waitForCompletion()` to resume once the user * submits the form. */ export interface UrlElicitationHandle { elicitationId: string; url: string; waitForCompletion: (options?: ElicitationWaitOptions) => Promise; } /** Parameters accepted by {@link ElicitationService.startUrlElicitation}. */ export interface StartUrlElicitationParams { sessionId: string; userId?: string; /** Endpoint to surface (e.g. `'api-key'`, `'confirm'`). Defaults to `'api-key'`. */ path?: string; /** Metadata stored with the record; merged into form-template inputs. */ metadata?: Record; /** Override the module-default TTL in milliseconds. */ ttlMs?: number; } /** Thrown by `waitForCompletion` when the user cancels the form submission. */ export declare class ElicitationCancelledError extends Error { readonly result: ElicitationResultRecord; constructor(result: ElicitationResultRecord); } /** * Registry mapping `elicitationId` → notifier. Stored in memory because * callbacks aren't serializable; multi-instance deployments must register * the notifier on the same instance that handles the completion request * (typically using a sticky session). */ export type CompletionNotifierRegistry = Map; export declare const COMPLETION_NOTIFIER_REGISTRY: unique symbol; export declare class ElicitationService implements OnModuleDestroy { private readonly store; private readonly options; private readonly notifierRegistry; private readonly logger; private cleanupTimer; constructor(store: IElicitationStore, options: ResolvedElicitationOptions, notifierRegistry: CompletionNotifierRegistry); onModuleDestroy(): void; createElicitation(params: CreateElicitationParams): Promise; registerCompletionNotifier(elicitationId: string, notifier: CompletionNotifier): void; /** * Build a public URL for an elicitation endpoint. `path` should be one of * the configured endpoint paths (e.g. `api-key`, `confirm`). */ buildElicitationUrl(elicitationId: string, path?: string, query?: Record): string; getElicitation(elicitationId: string): Promise; /** * Persist the result, mark the record complete, and fire the registered * completion notifier (if any). Returns true when a notifier was fired. */ completeElicitation(params: CompleteElicitationParams): Promise; getResult(elicitationId: string): Promise; findResultByUserAndType(userId: string, type: string): Promise; removeElicitation(elicitationId: string): Promise; getElicitationsBySession(sessionId: string): Promise; /** * High-level helper for the URL-elicitation flow. Creates a record, returns * the user-facing URL plus a `waitForCompletion` Promise that resolves once * the user submits the form (or rejects when the elicitation is cancelled, * times out, or the abort signal fires). * * The caller is responsible for telling the MCP client to open the URL — * typically via `ctx.elicit({ mode: 'url', message, url, elicitationId })`. */ startUrlElicitation(params: StartUrlElicitationParams): Promise; private startCleanupInterval; } //# sourceMappingURL=elicitation.service.d.ts.map