/**
 * Response Waiter for Awake Lambda Development
 *
 * Handles S3-based polling for responses from Local CLI.
 * Due to Lambda's execution model limitations, we use S3 polling
 * instead of true MQTT subscriptions.
 *
 * @module runtime-awake/response-waiter
 *
 * @see Requirements 1.2, 1.3, 2.3, 2.5, 5.5
 */
import { S3Client } from '@aws-sdk/client-s3';
import type { RuntimeAwakeResponse } from '../../../lib/runtime-web/runtime-awake';
/**
 * Default polling interval in milliseconds.
 */
export declare const DEFAULT_POLL_INTERVAL_MS = 100;
/**
 * Configuration for the ResponseWaiter.
 */
export interface ResponseWaiterConfig {
    /** S3 client instance */
    readonly s3Client: S3Client;
    /** S3 bucket name for response storage */
    readonly bucketName: string;
    /** Polling interval in milliseconds (default: 100ms) */
    readonly pollIntervalMs?: number;
}
/**
 * Response Waiter for S3-based polling.
 *
 * Manages pending response promises and polls S3 for responses
 * from the Local CLI. Each request creates a unique S3 key pattern
 * `runtime-awake/<devId>/<requestId>/response` that the Local CLI
 * writes to and this waiter polls.
 *
 * @see Requirements 1.2, 1.3, 2.3, 2.5, 5.5
 *
 * @example
 * ```typescript
 * const waiter = new ResponseWaiter({
 *   s3Client: new S3Client({ region: 'us-east-1' }),
 *   bucketName: 'my-app-runtime-awake-payloads',
 *   pollIntervalMs: 100,
 * });
 *
 * try {
 *   const response = await waiter.waitForResponse('dev123', 'req-456', 25000);
 *   console.log('Response received:', response);
 * } catch (error) {
 *   console.error('Timeout or error:', error);
 * }
 * ```
 */
export declare class ResponseWaiter {
    private readonly s3Client;
    private readonly bucketName;
    private readonly pollIntervalMs;
    /** Pending response promises keyed by requestId */
    private readonly pendingResponses;
    /**
     * Create a new ResponseWaiter instance.
     *
     * @param config - ResponseWaiter configuration
     */
    constructor(config: ResponseWaiterConfig);
    /**
     * Generate the S3 key for a response.
     *
     * Key pattern: runtime-awake/<devId>/<requestId>/response
     *
     * @param devId - Developer ID
     * @param requestId - Request ID
     * @returns S3 key string
     */
    private generateResponseKey;
    /**
     * Wait for a response from the Local CLI.
     *
     * Polls S3 for the response file until it appears or timeout occurs.
     * The response is expected at key: runtime-awake/<devId>/<requestId>/response
     *
     * @param devId - Developer ID
     * @param requestId - Request ID to wait for
     * @param timeoutMs - Timeout in milliseconds
     * @returns Promise that resolves with the response
     * @throws Error if timeout occurs or S3 operation fails
     *
     * @see Requirements 1.2, 1.3, 2.3
     */
    waitForResponse(devId: string, requestId: string, timeoutMs: number): Promise<RuntimeAwakeResponse>;
    /**
     * Check if a response exists in S3.
     *
     * @param key - S3 key to check
     * @returns Response if found, null otherwise
     */
    private checkForResponse;
    /**
     * Check if an error is a "not found" error from S3.
     *
     * @param error - Error to check
     * @returns True if error indicates object not found
     */
    private isNotFoundError;
    /**
     * Clean up a pending response entry.
     *
     * Clears timeout and polling interval, removes entry from map.
     * Called after resolution, rejection, or timeout.
     *
     * @param requestId - Request ID to clean up
     *
     * @see Requirements 2.5, 5.5
     */
    private cleanup;
    /**
     * Manually resolve a pending response.
     *
     * Can be called when a response is received through an alternative
     * channel (e.g., direct MQTT subscription in future implementations).
     *
     * @param requestId - Request ID
     * @param response - Response message
     * @returns True if response was resolved, false if no pending request
     */
    resolveResponse(requestId: string, response: RuntimeAwakeResponse): boolean;
    /**
     * Manually reject a pending response with an error.
     *
     * @param requestId - Request ID
     * @param error - Error to reject with
     * @returns True if response was rejected, false if no pending request
     */
    rejectResponse(requestId: string, error: Error): boolean;
    /**
     * Check if there's a pending response for the given requestId.
     *
     * @param requestId - Request ID to check
     * @returns True if there's a pending response
     */
    hasPending(requestId: string): boolean;
    /**
     * Get the number of pending responses.
     *
     * @returns Number of pending responses
     */
    getPendingCount(): number;
    /**
     * Cancel all pending responses.
     *
     * @param reason - Reason for cancellation
     */
    cancelAll(reason: string): void;
    /**
     * Get the bucket name.
     *
     * @returns S3 bucket name
     */
    getBucketName(): string;
    /**
     * Get the polling interval.
     *
     * @returns Polling interval in milliseconds
     */
    getPollIntervalMs(): number;
}
