/** * MCP Sampling with Tools wrapper for RLM sub-calls. * Feature #5: Recursive Sub-Call Handler (MCP Spec 2025-11-25) * * Enables server-side agent loops using MCP Sampling with Tools (SEP-1577). * This allows the server to invoke the LLM directly for sub-queries. */ /** * Tool definition for sampling requests (JSON Schema 2020-12). */ export interface ToolDefinition { name: string; description: string; inputSchema: object; } /** * Tool call result captured during sampling. */ export interface ToolCallResult { name: string; input: unknown; output: unknown; } /** * Sampling request matching MCP Spec 2025-11-25. */ export interface SamplingRequest { messages: { role: 'user' | 'assistant'; content: string; }[]; tools?: ToolDefinition[]; toolChoice?: 'auto' | 'none' | { type: 'tool'; name: string; }; maxTokens?: number; systemPrompt?: string; } /** * Sampling response with content and tool calls. */ export interface SamplingResponse { content: string; toolCalls?: ToolCallResult[]; stopReason: 'end_turn' | 'tool_use' | 'max_tokens'; } /** * Client interface for MCP sampling capability. * This abstraction allows for mocking in tests and future real client integration. */ export interface SamplingClient { /** * Create a sampling message (MCP createMessage request). * @param request - Sampling request * @returns Sampling response with content and tool calls */ createMessage(request: SamplingRequest): Promise; } /** * Create a sampling message using the provided client. * * This is a wrapper around MCP Sampling with Tools (SEP-1577) that: * - Formats the request according to MCP spec * - Handles tool_use stop reason (executes tool, continues sampling) * - Captures tool call results * - Respects toolChoice setting * * @param request - Sampling request * @param client - Optional sampling client (for testing/mocking) * @returns Sampling response with content and tool calls * * @example * const response = await createSamplingMessage({ * messages: [{ role: 'user', content: 'Summarize this section' }], * tools: [{ name: 'analyze', description: '...', inputSchema: {...} }], * toolChoice: 'auto', * maxTokens: 1000 * }, mockClient); */ export declare function createSamplingMessage(request: SamplingRequest, client?: SamplingClient): Promise; /** * Mock sampling client for testing. * Returns predictable responses based on request content. */ export declare class MockSamplingClient implements SamplingClient { private stringResponses; private regexResponses; private defaultResponse?; /** * Set a default response generator. */ setDefaultResponse(generator: (request: SamplingRequest) => SamplingResponse): void; /** * Set a specific response for a message content pattern. */ setResponse(pattern: string | RegExp, response: SamplingResponse): void; createMessage(request: SamplingRequest): Promise; } //# sourceMappingURL=sampling.d.ts.map