import { z } from "zod";
import { classifyModernError, type ModernClientInfo, type ModernError, type ModernRequest } from "./wire.ts";
export { MODERN_PROTOCOL_VERSION } from "./wire.ts";
export interface ProbeOptions {
    readonly clientInfo: ModernClientInfo;
    readonly clientCapabilities: Readonly<Record<string, unknown>>;
    readonly supportedVersions: readonly string[];
}
export type ProbeRequest = ModernRequest;
declare const discoverySchema: z.ZodObject<{
    resultType: z.ZodLiteral<"complete">;
    supportedVersions: z.ZodArray<z.ZodString>;
    capabilities: z.ZodRecord<z.ZodString, z.ZodUnknown>;
    _meta: z.ZodObject<{
        "io.modelcontextprotocol/serverInfo": z.ZodObject<{
            name: z.ZodString;
            version: z.ZodString;
        }, z.core.$loose>;
    }, z.core.$loose>;
    instructions: z.ZodOptional<z.ZodString>;
    ttlMs: z.ZodOptional<z.ZodNumber>;
    cacheScope: z.ZodOptional<z.ZodString>;
}, z.core.$loose>;
export type { ModernError } from "./wire.ts";
export type DiscoveryResult = z.infer<typeof discoverySchema>;
type ModernOutcome = {
    readonly kind: "modern-OK" | "modern-version-retry";
    readonly version: string;
    readonly discovery?: DiscoveryResult;
    readonly error?: ModernError;
};
export type EraOutcome = ModernOutcome
/**
 * stdio only. `restart`: the probed child exited or its stream failed, so the legacy handshake needs a fresh
 * process. `silent`: no answer in time; the same process gets the legacy handshake, and a late discovery reply
 * may still upgrade it.
 */
 | {
    readonly kind: "legacy-fallback";
    readonly restart?: true;
    readonly silent?: true;
} | {
    readonly kind: "indeterminate";
    readonly reason: string;
    readonly action: string;
    readonly era?: "modern";
    readonly status?: number;
    readonly cause?: unknown;
};
export type ProbeFetch = (url: URL, init: RequestInit) => Promise<Response>;
export type ProbeSend = (request: ProbeRequest) => Promise<unknown>;
export declare const modernError: typeof classifyModernError;
/** The SDK numbers its own requests from 0; a string id can never answer one of them. */
export declare const STDIO_PROBE_ID = "senpi-era-probe";
/** Rejection a stdio `ProbeSend` uses when the child gave no answer in time (as opposed to exiting). */
export declare class StdioProbeSilence extends Error {
    constructor();
}
/** A complete discovery reply to `id`, or undefined. */
export declare function discoveryReply(value: unknown, id: string | number): DiscoveryResult | undefined;
export declare function probeHttpEra(url: URL, fetch: ProbeFetch, options: ProbeOptions): Promise<EraOutcome>;
/**
 * `send` resolves with the reply to its request id, and rejects with `StdioProbeSilence` when no reply came in time
 * or with any other error when the child exited or its stream failed. Once a server has shown it is modern
 * (a -32022), an unclean retry is never downgraded to legacy.
 */
export declare function probeStdioEra(send: ProbeSend, options: ProbeOptions): Promise<EraOutcome>;
//# sourceMappingURL=era.d.ts.map