/** * Answers an MCP server's `sampling/createMessage` with this application's own model, through any * client with `complete()`, such as `NexusAI`: so a server's tool may ask for a completion, and every * call is still routed, budgeted, traced, and priced as every completion is. */ import type { CompletionRequest } from '../types/messages.js'; import type { NexusResponse } from '../types/response.js'; import { type McpSamplingRequest, type McpSamplingResult } from './protocol.js'; /** Anything that completes a request, such as a `NexusAI` client. */ export interface McpSamplingClient { /** Runs one completion. */ complete(request: CompletionRequest): Promise; } /** Options for `samplingFrom()`. */ export interface McpSamplingOptions { /** The model asked when the server's hints name none of \`models\`. */ model: string; /** * The models a server may have, by name: each of its hints, most preferred first, picks the first of * these whose name holds it, as MCP's model hints are matched. Without them, \`model\` answers every * request. */ models?: readonly string[]; /** The most tokens a request may ask for; a server asking more gets this many. */ maxTokens?: number; /** Whether to keep the system prompt a server asks for. Defaults to true. */ systemPrompt?: boolean; /** * Decides each request before it reaches the model, as MCP expects a person to be able to: \`false\` * refuses it, and the server is told so. Without it, every request is answered. */ approve?: (request: McpSamplingRequest) => boolean | Promise; } /** * A sampling handler for \`McpClientOptions.sampling\`, answering a server's requests with a client's * own completions: the conversation as messages, an image or audio as a part, the server's system * prompt, temperature, stop sequences, and token limit, the model chosen by its hints. */ export declare function samplingFrom(client: McpSamplingClient, options: McpSamplingOptions): (request: McpSamplingRequest, context: { signal: AbortSignal; }) => Promise;