import { x as MessageSendParams, $ as TaskPushNotificationConfig, ae as AgentCard, F as Message, ay as Task, aQ as TaskStatusUpdateEvent, aS as TaskArtifactUpdateEvent, aw as JSONRPCError, J as JSONRPCErrorResponse } from './extensions-DvruCIzw.cjs';
import { A as A2ARequestHandler, S as ServerCallContext } from './a2a_request_handler-B3LxMq3P.cjs';

/**
 * REST API Types (snake_case format)
 *
 * These types mirror the internal types but use snake_case naming
 * to support TCK and clients that send snake_case payloads.
 */

/**
 * REST file with bytes (snake_case mime_type).
 */
interface RestFileWithBytes {
    bytes: string;
    mime_type?: string;
    name?: string;
}
/**
 * REST file with URI (snake_case mime_type).
 */
interface RestFileWithUri {
    uri: string;
    mime_type?: string;
    name?: string;
}
/**
 * REST file union.
 */
type RestFile = RestFileWithBytes | RestFileWithUri;
/**
 * REST Part with snake_case file fields.
 */
type RestPart = {
    kind: 'text';
    text: string;
    metadata?: Record<string, unknown>;
} | {
    kind: 'file';
    file: RestFile;
    metadata?: Record<string, unknown>;
} | {
    kind: 'data';
    data: Record<string, unknown>;
    metadata?: Record<string, unknown>;
};
/**
 * REST Message with snake_case fields.
 */
interface RestMessage {
    kind: 'message';
    role: 'agent' | 'user';
    parts: RestPart[];
    message_id: string;
    context_id?: string;
    task_id?: string;
    reference_task_ids?: string[];
    extensions?: string[];
    metadata?: Record<string, unknown>;
}
/**
 * REST PushNotificationConfig (same as internal, no snake_case fields).
 */
interface RestPushNotificationConfig {
    id: string;
    url: string;
    authentication?: {
        schemes: string[];
        credentials?: string;
    };
}
/**
 * REST MessageSendConfiguration with snake_case fields.
 */
interface RestMessageSendConfiguration {
    blocking?: boolean;
    accepted_output_modes?: string[];
    history_length?: number;
    push_notification_config?: RestPushNotificationConfig;
}
/**
 * REST MessageSendParams with snake_case configuration.
 */
interface RestMessageSendParams {
    message: RestMessage;
    configuration?: RestMessageSendConfiguration;
    metadata?: Record<string, unknown>;
}
/**
 * REST TaskPushNotificationConfig with snake_case fields.
 */
interface RestTaskPushNotificationConfig {
    task_id: string;
    push_notification_config: RestPushNotificationConfig;
}
type MessageSendParamsInput = MessageSendParams | RestMessageSendParams;
type TaskPushNotificationConfigInput = TaskPushNotificationConfig | RestTaskPushNotificationConfig;

/**
 * HTTP+JSON (REST) Transport Handler
 *
 * Accepts both snake_case (REST) and camelCase (internal) input.
 * Returns camelCase (internal types).
 */

/**
 * HTTP status codes used in REST responses.
 */
declare const HTTP_STATUS: {
    readonly OK: 200;
    readonly CREATED: 201;
    readonly ACCEPTED: 202;
    readonly NO_CONTENT: 204;
    readonly BAD_REQUEST: 400;
    readonly UNAUTHORIZED: 401;
    readonly NOT_FOUND: 404;
    readonly CONFLICT: 409;
    readonly INTERNAL_SERVER_ERROR: 500;
    readonly NOT_IMPLEMENTED: 501;
};
/**
 * Type representing valid HTTP status codes from HTTP_STATUS.
 */
type RestHttpStatusCode = (typeof HTTP_STATUS)[keyof typeof HTTP_STATUS];
/**
 * Handles REST transport layer, routing requests to A2ARequestHandler.
 * Performs type conversion, validation, and capability checks.
 * Similar to JsonRpcTransportHandler but for HTTP+JSON (REST) protocol.
 *
 * Accepts both snake_case and camelCase inputs.
 * Outputs camelCase for spec compliance.
 */
declare class RestTransportHandler {
    private requestHandler;
    constructor(requestHandler: A2ARequestHandler);
    /**
     * Gets the agent card (for capability checks).
     */
    getAgentCard(): Promise<AgentCard>;
    /**
     * Gets the authenticated extended agent card.
     */
    getAuthenticatedExtendedAgentCard(): Promise<AgentCard>;
    /**
     * Sends a message to the agent.
     * Accepts both snake_case and camelCase input, returns camelCase.
     */
    sendMessage(params: MessageSendParamsInput, context: ServerCallContext): Promise<Message | Task>;
    /**
     * Sends a message with streaming response.
     * Accepts both snake_case and camelCase input, returns camelCase stream.
     * @throws {A2AError} UnsupportedOperation if streaming not supported
     */
    sendMessageStream(params: MessageSendParamsInput, context: ServerCallContext): Promise<AsyncGenerator<Message | Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent, void, undefined>>;
    /**
     * Gets a task by ID.
     * Validates historyLength parameter if provided.
     */
    getTask(taskId: string, context: ServerCallContext, historyLength?: unknown): Promise<Task>;
    /**
     * Cancels a task.
     */
    cancelTask(taskId: string, context: ServerCallContext): Promise<Task>;
    /**
     * Resubscribes to task updates.
     * Returns camelCase stream of task updates.
     * @throws {A2AError} UnsupportedOperation if streaming not supported
     */
    resubscribe(taskId: string, context: ServerCallContext): Promise<AsyncGenerator<Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent, void, undefined>>;
    /**
     * Sets a push notification configuration.
     * Accepts both snake_case and camelCase input, returns camelCase.
     * @throws {A2AError} PushNotificationNotSupported if push notifications not supported
     */
    setTaskPushNotificationConfig(config: TaskPushNotificationConfigInput, context: ServerCallContext): Promise<TaskPushNotificationConfig>;
    /**
     * Lists all push notification configurations for a task.
     */
    listTaskPushNotificationConfigs(taskId: string, context: ServerCallContext): Promise<TaskPushNotificationConfig[]>;
    /**
     * Gets a specific push notification configuration.
     */
    getTaskPushNotificationConfig(taskId: string, configId: string, context: ServerCallContext): Promise<TaskPushNotificationConfig>;
    /**
     * Deletes a push notification configuration.
     */
    deleteTaskPushNotificationConfig(taskId: string, configId: string, context: ServerCallContext): Promise<void>;
    /**
     * Validates and normalizes message parameters.
     * Accepts both snake_case and camelCase input.
     * @throws {A2AError} InvalidParams if message is missing or conversion fails
     */
    private normalizeMessageParams;
    /**
     * Static map of capability to error for missing capabilities.
     */
    private static readonly CAPABILITY_ERRORS;
    /**
     * Validates that the agent supports a required capability.
     * @throws {A2AError} UnsupportedOperation for streaming, PushNotificationNotSupported for push notifications
     */
    private requireCapability;
    /**
     * Parses and validates historyLength query parameter.
     */
    private parseHistoryLength;
    /**
     * Normalizes Part input - accepts both snake_case and camelCase for file mimeType.
     */
    private normalizePart;
    /**
     * Normalizes File input - accepts both snake_case (mime_type) and camelCase (mimeType).
     */
    private normalizeFile;
    /**
     * Normalizes Message input - accepts both snake_case and camelCase.
     */
    private normalizeMessage;
    /**
     * Normalizes MessageSendParams - accepts both snake_case and camelCase.
     */
    private normalizeMessageSendParams;
    /**
     * Normalizes TaskPushNotificationConfig - accepts both snake_case and camelCase.
     */
    private normalizeTaskPushNotificationConfig;
}

/**
 * Custom error class for A2A server operations, incorporating JSON-RPC error codes.
 */
declare class A2AError extends Error {
    code: number;
    data?: Record<string, unknown>;
    taskId?: string;
    constructor(code: number, message: string, data?: Record<string, unknown>, taskId?: string);
    /**
     * Formats the error into a standard JSON-RPC error object structure.
     */
    toJSONRPCError(): JSONRPCError;
    static parseError(message: string, data?: Record<string, unknown>): A2AError;
    static invalidRequest(message: string, data?: Record<string, unknown>): A2AError;
    static methodNotFound(method: string): A2AError;
    static invalidParams(message: string, data?: Record<string, unknown>): A2AError;
    static internalError(message: string, data?: Record<string, unknown>): A2AError;
    static taskNotFound(taskId: string): A2AError;
    static taskNotCancelable(taskId: string): A2AError;
    static pushNotificationNotSupported(): A2AError;
    static unsupportedOperation(operation: string): A2AError;
    static authenticatedExtendedCardNotConfigured(): A2AError;
}
/**
 * Result of formatting a JSON-RPC error.
 */
interface JsonRpcErrorResult {
    statusCode: number;
    body: JSONRPCErrorResponse;
}
/**
 * Result of formatting a REST error.
 */
interface RestErrorResult {
    statusCode: RestHttpStatusCode;
    body: unknown;
}
/**
 * Formats a general JSON-RPC error response.
 *
 * @param error - The error that occurred
 * @param requestId - The original request ID (or null)
 * @returns Formatted error result with status code and body
 */
declare function formatJsonRpcError(error: unknown, requestId: string | number | null): JsonRpcErrorResult;
/**
 * Formats a JSON parse error response.
 *
 * @returns Formatted error result for invalid JSON
 */
declare function formatParseError(): JsonRpcErrorResult;
/**
 * Formats a streaming error as a JSON-RPC error response.
 *
 * @param error - The error that occurred during streaming
 * @param requestId - The original request ID (or null)
 * @returns Formatted JSON-RPC error response
 */
declare function formatStreamingError(error: unknown, requestId: string | number | null): JSONRPCErrorResponse;
/**
 * Formats a REST API error response.
 *
 * @param error - The error that occurred
 * @returns Formatted error result with status code and body
 */
declare function formatRestError(error: unknown): RestErrorResult;

export { A2AError as A, type JsonRpcErrorResult as J, type MessageSendParamsInput as M, RestTransportHandler as R, type RestErrorResult as a, formatParseError as b, formatStreamingError as c, formatRestError as d, type RestHttpStatusCode as e, formatJsonRpcError as f };
