@juspay/neurolink
Version:
Universal AI Development Platform with working MCP integration, multi-provider support, voice (TTS/STT/realtime), and professional CLI. 58+ external MCP servers discoverable, multimodal file processing, RAG pipelines. Build, test, and deploy AI applicatio
35 lines (34 loc) • 1.57 kB
TypeScript
/**
* Size Guard Utility
*
* Provides bounded binary downloads to prevent OOM when fetching generated
* media from external providers. Applies a Content-Length pre-check and a
* post-buffer guard so multi-GB responses are rejected before they fully
* materialise in process memory.
*
* @module utils/sizeGuard
*/
/** 256 MiB — suitable for video output (MP4). */
export declare const MAX_VIDEO_BYTES: number;
/** 50 MiB — suitable for audio output (MP3/WAV). */
export declare const MAX_AUDIO_BYTES: number;
/** 25 MiB — suitable for image output (PNG/JPEG/WebP). */
export declare const MAX_IMAGE_BYTES: number;
/**
* Download the body of a {@link Response} into a {@link Buffer}, enforcing an
* upper-bound on the number of bytes consumed.
*
* Two checks are performed:
* 1. If the response includes a `Content-Length` header that exceeds
* `maxBytes`, the download is rejected immediately (no data is read).
* 2. After buffering, the actual buffer size is verified against `maxBytes`.
* This catches chunked transfers where no `Content-Length` was provided.
*
* @param response The fetch {@link Response} to drain.
* @param maxBytes Maximum number of bytes allowed.
* @param label Human-readable identifier used in error messages
* (e.g. "Kling video", "D-ID result").
* @returns The response body as a {@link Buffer}.
* @throws {@link Error} when either size check fails.
*/
export declare function readBoundedBuffer(response: Response, maxBytes: number, label: string): Promise<Buffer>;