/**
 * Shared utilities: response extraction and pagination helpers.
 */
import { type RateLimitInfo } from './rate-limit.js';
export interface LastResponseInfo {
    requestId: string | null;
    statusCode: number;
    headers: Headers;
    rateLimit: RateLimitInfo;
}
export interface ResponseMetadata {
    _request_id: string | null;
    lastResponse: LastResponseInfo;
}
export interface AmigoResponse<T> {
    data: WithResponseMetadata<T>;
    response: Response;
    requestId: string | null;
    rateLimit: RateLimitInfo;
}
export type WithResponseMetadata<T> = T extends object ? T & ResponseMetadata : T;
export declare function extractRequestId(response: Response): string | null;
export declare function buildLastResponse(response: Response): LastResponseInfo;
interface OpenApiResult<T> {
    data?: T;
    error?: unknown;
    response?: Response;
}
interface ExtractDataOptions {
    allowEmptyBody?: boolean;
}
/**
 * Extracts the data payload from an openapi-fetch response.
 * Empty-body success responses return undefined; other empty responses throw.
 */
export declare function extractData<T>(result: OpenApiResult<T>, options?: ExtractDataOptions): WithResponseMetadata<T>;
export declare function withResponse<T>(result: OpenApiResult<T> & {
    response: Response;
}, options?: ExtractDataOptions): AmigoResponse<T>;
/**
 * Standard paginated list response shape.
 */
export interface PaginatedList<T> {
    items: T[];
    has_more: boolean;
    continuation_token: number | null;
}
/**
 * Standard query params for paginated list endpoints.
 */
export interface ListParams {
    /** Max items per page. Default varies by endpoint. */
    limit?: number;
    /** Opaque token from previous response for next page. */
    continuation_token?: number;
}
/**
 * Async iterator that auto-paginates through all pages.
 * Yields one item at a time.
 *
 * @example
 * for await (const agent of paginate((token) => client.agents.list({ continuation_token: token }))) {
 *   console.log(agent)
 * }
 */
export declare function paginate<T>(fetcher: (continuationToken?: number) => Promise<PaginatedList<T>>): AsyncGenerator<T>;
export {};
//# sourceMappingURL=utils.d.ts.map