@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
78 lines (77 loc) • 2.66 kB
TypeScript
/**
* Music Generation Processing Utility
*
* Central registry + dispatch for music-generation handlers across
* providers (Beatoven, ElevenLabs Music, Lyria, Replicate-hosted models).
*
* Mirrors the static-handler-registry pattern established by
* `TTSProcessor` / `STTProcessor` / `VideoProcessor`.
*
* @module utils/musicProcessor
*/
import { ErrorCategory, ErrorSeverity } from "../constants/enums.js";
import type { MusicHandler, MusicOptions, MusicResult } from "../types/index.js";
import { NeuroLinkError } from "./errorHandling.js";
/**
* Music-specific error codes.
*/
export declare const MUSIC_ERROR_CODES: {
readonly PROVIDER_NOT_SUPPORTED: "MUSIC_PROVIDER_NOT_SUPPORTED";
readonly PROVIDER_NOT_CONFIGURED: "MUSIC_PROVIDER_NOT_CONFIGURED";
readonly GENERATION_FAILED: "MUSIC_GENERATION_FAILED";
readonly POLL_TIMEOUT: "MUSIC_POLL_TIMEOUT";
readonly PROMPT_REQUIRED: "MUSIC_PROMPT_REQUIRED";
readonly DURATION_INVALID: "MUSIC_DURATION_INVALID";
readonly INVALID_INPUT: "MUSIC_INVALID_INPUT";
};
/**
* Typed error class for music-generation failures.
*/
export declare class MusicError extends NeuroLinkError {
constructor(options: {
code: string;
message: string;
category?: ErrorCategory;
severity?: ErrorSeverity;
retriable?: boolean;
context?: Record<string, unknown>;
originalError?: Error;
});
}
/**
* Static processor managing the music handler registry.
*/
export declare class MusicProcessor {
private static readonly registry;
/**
* Register a music handler for a specific provider.
*/
static registerHandler(providerName: string, handler: MusicHandler): void;
/**
* Check if a provider has a registered music handler.
*/
static supports(providerName: string): boolean;
/**
* List the names of all registered providers.
*/
static listProviders(): string[];
/**
* Get a registered music handler by provider name.
*
* Exposed publicly so module-level auto-registration code can reuse an
* already-registered primary handler when backfilling its aliases.
*/
static getHandler(providerName: string): MusicHandler | undefined;
/**
* Clear all registered handlers (for testing).
*/
static clearHandlers(): void;
private static buildSpanAttributes;
/**
* Generate a music track via the registered handler.
*
* @throws MusicError on registry miss, handler-not-configured, or
* generation failure.
*/
static generate(provider: string, options: MusicOptions): Promise<MusicResult>;
}