@juspay/neurolink
Version:
The pipe layer of an AI nervous system: one interface connecting provider neurons to your application, across three inference types — generate, stream and decide. `decide` returns typed, calibrated judgements from a non-generative model (~400ms, ~$0.00002
71 lines (70 loc) • 3.08 kB
TypeScript
/**
* Video Generation Processing Utility
*
* Central registry + dispatch for video-generation handlers across
* providers (Vertex Veo, Kling, Runway, Replicate-hosted models, etc.).
*
* Mirrors the static-handler-registry pattern established by
* `TTSProcessor` (`utils/ttsProcessor.ts`) and `STTProcessor`
* (`utils/sttProcessor.ts`).
*
* @module utils/videoProcessor
*/
import { VIDEO_ERROR_CODES } from "../constants/videoErrors.js";
import type { VideoGenerateOptions, VideoGenerationResult, VideoHandler, VideoOutputOptions, VideoTransitionOptions } from "../types/index.js";
import { VideoError } from "../adapters/video/vertexVideoHandler.js";
export { VideoError, VIDEO_ERROR_CODES };
/**
* Static processor managing the video handler registry.
*
* Handlers register themselves during `ProviderRegistry._doRegister()`
* via `VideoProcessor.registerHandler(name, instance)`. Lookups are
* O(1) on a normalised lower-case provider key.
*/
export declare class VideoProcessor {
private static readonly registry;
/**
* Register a video handler for a specific provider.
*/
static registerHandler(providerName: string, handler: VideoHandler): void;
/**
* Check if a provider has a registered video handler.
*/
static supports(providerName: string): boolean;
/**
* List the names of all registered providers.
*/
static listProviders(): string[];
private static getHandler;
/**
* Clear all registered handlers (for testing).
*/
static clearHandlers(): void;
private static buildSpanAttributes;
/**
* Generate a single video clip via the registered handler.
*
* @param provider - Registered provider name (e.g. "vertex", "kling")
* @param options - Bag of the source image, prompt, optional region
* override, and resolution / length / aspect-ratio / audio options.
* Translated internally into the handler-level 4-positional-argument
* call — `VideoHandler.generate()`'s own signature is unchanged.
* @throws VideoError on registry miss, handler-not-configured, or
* generation failure
*/
static generate(provider: string, options: VideoGenerateOptions): Promise<VideoGenerationResult>;
/**
* @deprecated Positional form kept for backward compatibility with
* pre-bag callers (VideoProcessor is a public export). Use the
* options-bag overload.
*/
static generate(provider: string, image: Buffer, prompt: string, options: VideoOutputOptions, region?: string): Promise<VideoGenerationResult>;
/**
* Generate a transition clip via the registered handler (Director Mode).
*
* Providers without first-and-last-frame interpolation surface a typed
* `TRANSITION_NOT_SUPPORTED` error here; callers should fall back to
* generating a regular clip with a transition prompt.
*/
static generateTransition(provider: string, firstFrame: Buffer, lastFrame: Buffer, prompt: string, options?: VideoTransitionOptions, region?: string): Promise<Buffer>;
}