import { a as RetryPolicy } from './types-mAgSJ57j.js';

declare function redactSensitiveValue(value: unknown): unknown;

/**
 * Shared types for OAuth state machines
 */
type MaybePromise<T> = T | Promise<T>;
type OAuthAuthMode = "interactive" | "headless" | "client_credentials";
type OAuthFlowStep = "idle" | "request_without_token" | "received_401_unauthorized" | "discovery_start" | "request_resource_metadata" | "received_resource_metadata" | "request_authorization_server_metadata" | "received_authorization_server_metadata" | "cimd_prepare" | "cimd_fetch_request" | "cimd_metadata_response" | "request_client_registration" | "received_client_credentials" | "generate_pkce_parameters" | "authorization_request" | "received_authorization_code" | "token_request" | "received_access_token" | "authenticated_mcp_request" | "complete" | "verify_list_tools" | "verify_call_tool";
interface OAuthFlowState {
    isInitiatingAuth: boolean;
    currentStep: OAuthFlowStep;
    serverUrl?: string;
    wwwAuthenticateHeader?: string;
    challengedScopes?: string[];
    resourceMetadataUrl?: string;
    resourceMetadata?: {
        resource: string;
        authorization_servers?: string[];
        bearer_methods_supported?: string[];
        resource_signing_alg_values_supported?: string[];
        scopes_supported?: string[];
    };
    authorizationServerUrl?: string;
    authorizationServerMetadata?: {
        issuer: string;
        authorization_endpoint: string;
        token_endpoint: string;
        registration_endpoint?: string;
        scopes_supported?: string[];
        response_types_supported: string[];
        grant_types_supported?: string[];
        code_challenge_methods_supported?: string[];
        client_id_metadata_document_supported?: boolean;
    };
    clientId?: string;
    clientSecret?: string;
    tokenEndpointAuthMethod?: string;
    codeVerifier?: string;
    codeChallenge?: string;
    codeChallengeMethod?: string;
    authorizationUrl?: string;
    authorizationCode?: string;
    state?: string;
    accessToken?: string;
    refreshToken?: string;
    tokenType?: string;
    expiresIn?: number;
    lastRequest?: {
        method: string;
        url: string;
        headers: Record<string, string>;
        body?: any;
    };
    lastResponse?: {
        status: number;
        statusText: string;
        headers: Record<string, string>;
        body: any;
    };
    httpHistory?: Array<HttpHistoryEntry>;
    infoLogs?: Array<InfoLogEntry>;
    error?: string;
}
type InfoLogLevel = "info" | "warning" | "error";
type LogErrorDetails = {
    message: string;
    details?: unknown;
};
type InfoLogEntry = {
    id: string;
    step: OAuthFlowStep;
    label: string;
    data: any;
    timestamp: number;
    level: InfoLogLevel;
    error?: LogErrorDetails;
};
type HttpHistoryEntry = {
    step: OAuthFlowStep;
    timestamp: number;
    duration?: number;
    request: OAuthHttpRequest;
    response?: OAuthHttpResponse;
    error?: LogErrorDetails;
};
interface OAuthHttpRequest {
    method: string;
    url: string;
    headers: Record<string, string>;
    body?: any;
}
interface OAuthHttpResponse {
    status: number;
    statusText: string;
    headers: Record<string, string>;
    body: any;
}
interface OAuthRequestResult extends OAuthHttpResponse {
    ok: boolean;
}
type OAuthRequestExecutor = (request: OAuthHttpRequest) => Promise<OAuthRequestResult>;
type OAuthAutoAdvanceScheduler = (fn: () => void, delayMs: number) => void;
interface OAuthDynamicRegistrationMetadata {
    client_name: string;
    client_uri?: string;
    logo_uri?: string;
    redirect_uris?: string[];
    grant_types?: string[];
    response_types?: string[];
    token_endpoint_auth_method?: string;
    [key: string]: unknown;
}
interface PreregisteredCredentials {
    clientId?: string;
    clientSecret?: string;
}
type LoadPreregisteredCredentials = (input: {
    serverName: string;
    serverUrl: string;
}) => MaybePromise<PreregisteredCredentials>;
declare const EMPTY_OAUTH_FLOW_STATE: OAuthFlowState;
interface OAuthStateMachine {
    state: OAuthFlowState;
    updateState: (updates: Partial<OAuthFlowState>) => void;
    proceedToNextStep: () => Promise<void>;
    startGuidedFlow: () => Promise<void>;
    resetFlow: () => void;
}
interface BaseOAuthStateMachineConfig {
    state: OAuthFlowState;
    getState?: () => OAuthFlowState;
    updateState: (updates: Partial<OAuthFlowState>) => void;
    serverUrl: string;
    serverName: string;
    redirectUrl: string;
    requestExecutor: OAuthRequestExecutor;
    scheduleAutoAdvance?: OAuthAutoAdvanceScheduler;
    loadPreregisteredCredentials?: LoadPreregisteredCredentials;
    hasClientSecret?: boolean;
    dynamicRegistration?: Partial<OAuthDynamicRegistrationMetadata>;
    clientIdMetadataUrl?: string;
    customScopes?: string;
    customHeaders?: Record<string, string>;
    authMode?: OAuthAuthMode;
    strictConformance?: boolean;
}
type RegistrationStrategy2025_03_26 = "dcr" | "preregistered";
type RegistrationStrategy2025_06_18 = "dcr" | "preregistered";
type RegistrationStrategy2025_11_25 = "cimd" | "dcr" | "preregistered";
type OAuthProtocolVersion = "2025-03-26" | "2025-06-18" | "2025-11-25";

interface ProbeMcpServerConfig {
    url: string;
    protocolVersion?: OAuthProtocolVersion;
    headers?: Record<string, string>;
    accessToken?: string;
    clientCapabilities?: Record<string, unknown>;
    timeoutMs?: number;
    fetchFn?: typeof fetch;
    clientName?: string;
    clientVersion?: string;
    retryPolicy?: RetryPolicy;
}
interface ProbeHttpAttempt {
    name: "streamable_initialize" | "sse_probe" | "resource_metadata" | "authorization_server_metadata";
    request: {
        method: string;
        url: string;
        headers: Record<string, string>;
        body?: unknown;
    };
    response?: {
        status: number;
        statusText: string;
        headers: Record<string, string>;
        body?: unknown;
        contentType?: string;
    };
    error?: string;
    durationMs: number;
}
interface ProbeOAuthDetails {
    required: boolean;
    optional: boolean;
    wwwAuthenticate?: string;
    resourceMetadataUrl?: string;
    resourceMetadata?: Record<string, unknown>;
    authorizationServerMetadataUrl?: string;
    authorizationServerMetadata?: Record<string, unknown>;
    registrationStrategies: Array<"preregistered" | "dcr" | "cimd">;
    discoveryError?: string;
}
interface ProbeInitializeInfo {
    protocolVersion?: string;
    serverInfo?: unknown;
    capabilities?: unknown;
    contentType?: string;
}
interface ProbeTransportResult {
    selected?: "streamable-http" | "sse";
    attempts: ProbeHttpAttempt[];
}
interface ProbeMcpServerResult {
    url: string;
    protocolVersion: OAuthProtocolVersion;
    status: "ready" | "oauth_required" | "reachable" | "error";
    transport: ProbeTransportResult;
    initialize?: ProbeInitializeInfo;
    oauth: ProbeOAuthDetails;
    error?: string;
}
declare function probeMcpServer(config: ProbeMcpServerConfig): Promise<ProbeMcpServerResult>;

interface ServerDoctorError {
    code: string;
    message: string;
    details?: unknown;
}
interface ServerDoctorCheck {
    status: "ok" | "error" | "skipped";
    detail: string;
}
interface ServerDoctorConnection {
    status: "connected" | "error" | "skipped";
    detail: string;
}
interface ServerDoctorChecks {
    probe: ServerDoctorCheck;
    connection: ServerDoctorCheck;
    initialization: ServerDoctorCheck;
    capabilities: ServerDoctorCheck;
    tools: ServerDoctorCheck;
    resources: ServerDoctorCheck;
    resourceTemplates: ServerDoctorCheck;
    prompts: ServerDoctorCheck;
}
interface ServerDoctorResult<TTarget = unknown> {
    target: TTarget;
    generatedAt: string;
    status: "ready" | "oauth_required" | "partial" | "error";
    probe: ProbeMcpServerResult | null;
    connection: ServerDoctorConnection;
    initInfo: unknown | null;
    capabilities: unknown | null;
    tools: unknown[];
    toolsMetadata: Record<string, unknown>;
    resources: unknown[];
    resourceTemplates: unknown[];
    prompts: unknown[];
    checks: ServerDoctorChecks;
    error: ServerDoctorError | null;
}
interface ConnectedServerDoctorState {
    initInfo: unknown | null;
    capabilities: unknown | null;
    tools: unknown[];
    toolsMetadata: Record<string, unknown>;
    resources: unknown[];
    resourceTemplates: unknown[];
    prompts: unknown[];
    checks: Pick<ServerDoctorChecks, "initialization" | "capabilities" | "tools" | "resources" | "resourceTemplates" | "prompts">;
    errors: ServerDoctorError[];
}
declare function normalizeServerDoctorError(error: unknown): ServerDoctorError;

export { type BaseOAuthStateMachineConfig as B, type ConnectedServerDoctorState as C, EMPTY_OAUTH_FLOW_STATE as E, type HttpHistoryEntry as H, type InfoLogEntry as I, type LogErrorDetails as L, type MaybePromise as M, type OAuthProtocolVersion as O, type ProbeHttpAttempt as P, type RegistrationStrategy2025_03_26 as R, type ServerDoctorResult as S, type ProbeInitializeInfo as a, type ProbeMcpServerConfig as b, type ProbeMcpServerResult as c, type ProbeOAuthDetails as d, type ProbeTransportResult as e, type ServerDoctorCheck as f, type ServerDoctorChecks as g, type ServerDoctorConnection as h, type ServerDoctorError as i, type OAuthDynamicRegistrationMetadata as j, type RegistrationStrategy2025_06_18 as k, type RegistrationStrategy2025_11_25 as l, type OAuthFlowState as m, type InfoLogLevel as n, type OAuthFlowStep as o, probeMcpServer as p, type OAuthRequestExecutor as q, redactSensitiveValue as r, type OAuthRequestResult as s, type OAuthStateMachine as t, type OAuthAuthMode as u, type OAuthHttpRequest as v, normalizeServerDoctorError as w };
