@juspay/neurolink 11.27.0 → 11.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/neurolink.js CHANGED
@@ -4382,6 +4382,13 @@ Current user's request: ${currentInput}`;
4382
4382
  if (!providerName) {
4383
4383
  throw new Error('output.music.provider is required (e.g. "beatoven", "elevenlabs-music", "lyria", "replicate").');
4384
4384
  }
4385
+ // This early-dispatch path never creates an AI provider, so
4386
+ // ProviderRegistry.registerAllProviders() has NOT necessarily run —
4387
+ // with the module-scope auto-registration retired, the handlers must
4388
+ // be registered here explicitly. registerDefaultMusicHandlers() is
4389
+ // idempotent (skip-if-registered), so the repeat call is free.
4390
+ const { registerDefaultMusicHandlers } = await import("./music/index.js");
4391
+ registerDefaultMusicHandlers();
4385
4392
  const { MusicProcessor } = await import("./utils/musicProcessor.js");
4386
4393
  const musicResult = await MusicProcessor.generate(providerName, {
4387
4394
  ...musicOptions,
@@ -4414,6 +4421,11 @@ Current user's request: ${currentInput}`;
4414
4421
  if (!providerName) {
4415
4422
  throw new Error('output.avatar.provider is required (e.g. "d-id", "heygen", "replicate").');
4416
4423
  }
4424
+ // Same early-dispatch registration as generateWithMusic above: no AI
4425
+ // provider is created on this path, so the retired module-scope
4426
+ // auto-run must be replaced by an explicit (idempotent) call here.
4427
+ const { registerDefaultAvatarHandlers } = await import("./avatar/index.js");
4428
+ registerDefaultAvatarHandlers();
4417
4429
  const { AvatarProcessor } = await import("./utils/avatarProcessor.js");
4418
4430
  const avatarResult = await AvatarProcessor.generate(providerName, avatarOptions);
4419
4431
  generateSpan.setAttribute("neurolink.avatar.provider", providerName);
@@ -79,6 +79,7 @@ export * from "./video.js";
79
79
  export * from "./avatar.js";
80
80
  export * from "./music.js";
81
81
  export * from "./replicate.js";
82
+ export * from "./mediaCatalog.js";
82
83
  export * from "./safeFetch.js";
83
84
  export * from "./modelPool.js";
84
85
  export * from "./requestRouter.js";
@@ -85,6 +85,7 @@ export * from "./video.js";
85
85
  export * from "./avatar.js";
86
86
  export * from "./music.js";
87
87
  export * from "./replicate.js";
88
+ export * from "./mediaCatalog.js";
88
89
  // Safe-fetch helper types (SSRF-hardened download)
89
90
  export * from "./safeFetch.js";
90
91
  // ModelPool — multi-provider failover with per-member cooldown (M9.x+)
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Types backing the static media-handler catalog
3
+ * (src/lib/factories/mediaHandlerCatalog.ts) — the single source of truth
4
+ * for provider names/aliases across the six media-generation ecosystems
5
+ * (TTS, STT, Realtime, Video, Avatar, Music).
6
+ */
7
+ export type MediaHandlerKind = "tts" | "stt" | "realtime" | "video" | "avatar" | "music";
8
+ export type MediaHandlerDescriptor = {
9
+ readonly kind: MediaHandlerKind;
10
+ readonly name: string;
11
+ readonly aliases?: readonly string[];
12
+ };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Types backing the static media-handler catalog
3
+ * (src/lib/factories/mediaHandlerCatalog.ts) — the single source of truth
4
+ * for provider names/aliases across the six media-generation ecosystems
5
+ * (TTS, STT, Realtime, Video, Avatar, Music).
6
+ */
7
+ export {};
@@ -8,9 +8,13 @@
8
8
  * Use STTProcessor (src/lib/utils/sttProcessor.ts) for STT.
9
9
  * Use RealtimeProcessor for realtime voice sessions.
10
10
  *
11
- * Importing this module also auto-registers every shipped TTS / STT /
12
- * Realtime handler whose backing API key is present in `process.env`.
13
- * Registration is idempotent and silently skipped on failure.
11
+ * Importing this module does NOT register any handlers as a side effect.
12
+ * Call `registerDefaultTTSHandlers()` / `registerDefaultSTTHandlers()` /
13
+ * `registerDefaultRealtimeHandlers()` explicitly (or go through
14
+ * `ProviderRegistry.registerAllProviders()`, which every documented
15
+ * `NeuroLink` entry point already calls) to register every shipped handler
16
+ * whose backing API key is present in `process.env`. Registration is
17
+ * idempotent and silently skipped on failure.
14
18
  *
15
19
  * @module voice
16
20
  */
@@ -8,12 +8,17 @@
8
8
  * Use STTProcessor (src/lib/utils/sttProcessor.ts) for STT.
9
9
  * Use RealtimeProcessor for realtime voice sessions.
10
10
  *
11
- * Importing this module also auto-registers every shipped TTS / STT /
12
- * Realtime handler whose backing API key is present in `process.env`.
13
- * Registration is idempotent and silently skipped on failure.
11
+ * Importing this module does NOT register any handlers as a side effect.
12
+ * Call `registerDefaultTTSHandlers()` / `registerDefaultSTTHandlers()` /
13
+ * `registerDefaultRealtimeHandlers()` explicitly (or go through
14
+ * `ProviderRegistry.registerAllProviders()`, which every documented
15
+ * `NeuroLink` entry point already calls) to register every shipped handler
16
+ * whose backing API key is present in `process.env`. Registration is
17
+ * idempotent and silently skipped on failure.
14
18
  *
15
19
  * @module voice
16
20
  */
21
+ import { MEDIA_HANDLER_CATALOG } from "../factories/mediaHandlerCatalog.js";
17
22
  import { logger } from "../utils/logger.js";
18
23
  import { STTProcessor } from "../utils/sttProcessor.js";
19
24
  import { TTSProcessor } from "../utils/ttsProcessor.js";
@@ -76,37 +81,48 @@ import { GoogleSTT } from "./providers/GoogleSTT.js";
76
81
  import { OpenAISTT } from "./providers/OpenAISTT.js";
77
82
  import { GeminiLive } from "./providers/GeminiLive.js";
78
83
  import { OpenAIRealtime } from "./providers/OpenAIRealtime.js";
79
- const TTS_HANDLER_CANDIDATES = [
80
- {
81
- // Google TTS doubles as both the AI Studio and Vertex TTS handler.
82
- name: "google-ai",
83
- aliases: ["vertex"],
84
- factory: () => new GoogleTTSHandler(),
85
- },
86
- { name: "openai-tts", factory: () => new OpenAITTS() },
87
- {
88
- name: "elevenlabs",
89
- aliases: ["elevenlabs-tts"],
90
- factory: () => new ElevenLabsTTS(),
91
- },
92
- { name: "azure-tts", factory: () => new AzureTTS() },
93
- { name: "fish-audio", factory: () => new FishAudioTTS() },
94
- { name: "cartesia", factory: () => new CartesiaTTS() },
95
- ];
96
- const STT_HANDLER_CANDIDATES = [
97
- {
98
- name: "whisper",
99
- aliases: ["openai-stt"],
100
- factory: () => new OpenAISTT(),
101
- },
102
- { name: "deepgram", factory: () => new DeepgramSTT() },
103
- { name: "google-stt", factory: () => new GoogleSTT() },
104
- { name: "azure-stt", factory: () => new AzureSTT() },
105
- ];
106
- const REALTIME_HANDLER_CANDIDATES = [
107
- { name: "openai-realtime", factory: () => new OpenAIRealtime() },
108
- { name: "gemini-live", factory: () => new GeminiLive() },
109
- ];
84
+ // Provider names + aliases are the Task-8 catalog's job — only the factory
85
+ // (which needs the imported handler class) stays local to this module.
86
+ const TTS_HANDLER_FACTORIES = {
87
+ // Google TTS doubles as both the AI Studio and Vertex TTS handler.
88
+ "google-ai": () => new GoogleTTSHandler(),
89
+ "openai-tts": () => new OpenAITTS(),
90
+ elevenlabs: () => new ElevenLabsTTS(),
91
+ "azure-tts": () => new AzureTTS(),
92
+ "fish-audio": () => new FishAudioTTS(),
93
+ cartesia: () => new CartesiaTTS(),
94
+ };
95
+ const TTS_HANDLER_CANDIDATES = MEDIA_HANDLER_CATALOG.filter((entry) => entry.kind === "tts").map((entry) => {
96
+ const factory = TTS_HANDLER_FACTORIES[entry.name];
97
+ if (!factory) {
98
+ throw new Error(`[voice/tts] no handler factory for catalog entry "${entry.name}"`);
99
+ }
100
+ return { name: entry.name, aliases: entry.aliases, factory };
101
+ });
102
+ const STT_HANDLER_FACTORIES = {
103
+ whisper: () => new OpenAISTT(),
104
+ deepgram: () => new DeepgramSTT(),
105
+ "google-stt": () => new GoogleSTT(),
106
+ "azure-stt": () => new AzureSTT(),
107
+ };
108
+ const STT_HANDLER_CANDIDATES = MEDIA_HANDLER_CATALOG.filter((entry) => entry.kind === "stt").map((entry) => {
109
+ const factory = STT_HANDLER_FACTORIES[entry.name];
110
+ if (!factory) {
111
+ throw new Error(`[voice/stt] no handler factory for catalog entry "${entry.name}"`);
112
+ }
113
+ return { name: entry.name, aliases: entry.aliases, factory };
114
+ });
115
+ const REALTIME_HANDLER_FACTORIES = {
116
+ "openai-realtime": () => new OpenAIRealtime(),
117
+ "gemini-live": () => new GeminiLive(),
118
+ };
119
+ const REALTIME_HANDLER_CANDIDATES = MEDIA_HANDLER_CATALOG.filter((entry) => entry.kind === "realtime").map((entry) => {
120
+ const factory = REALTIME_HANDLER_FACTORIES[entry.name];
121
+ if (!factory) {
122
+ throw new Error(`[voice/realtime] no handler factory for catalog entry "${entry.name}"`);
123
+ }
124
+ return { name: entry.name, aliases: entry.aliases, factory };
125
+ });
110
126
  function registerCandidates(candidates, supports, getRegistered, register, scope, requireConfigured) {
111
127
  for (const { name, aliases, factory } of candidates) {
112
128
  // Compute missingName / missingAliases separately so a manually-
@@ -168,9 +184,3 @@ export function registerDefaultSTTHandlers() {
168
184
  export function registerDefaultRealtimeHandlers() {
169
185
  registerCandidates(REALTIME_HANDLER_CANDIDATES, (name) => RealtimeProcessor.supports(name), (name) => RealtimeProcessor.getHandler(name), (name, handler) => RealtimeProcessor.registerHandler(name, handler), "voice/realtime", false);
170
186
  }
171
- // Run once at module import so consumers who follow the documented
172
- // `nl.generate(...)` flow get every configured handler without manually
173
- // calling `registerHandler`.
174
- registerDefaultTTSHandlers();
175
- registerDefaultSTTHandlers();
176
- registerDefaultRealtimeHandlers();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juspay/neurolink",
3
- "version": "11.27.0",
3
+ "version": "11.28.0",
4
4
  "packageManager": "pnpm@10.15.1",
5
5
  "description": "TypeScript AI SDK with 24+ LLM providers behind one consistent API. MCP-native (connect any MCP server), voice TTS/STT/realtime, RAG, agents, memory, context compaction. OpenAI · Anthropic · Gemini · Bedrock · Azure · Ollama · DeepSeek · NVIDIA NIM and more.",
6
6
  "author": {
@@ -80,6 +80,7 @@
80
80
  "test:mcp:cli": "pnpm exec tsx test/continuous-test-suite-mcp-cli.ts",
81
81
  "test:mcp:full": "pnpm run test:mcp:infra && pnpm run test:mcp:spans && pnpm run test:mcp:sdk && pnpm run test:mcp:cli && pnpm run test:mcp:http",
82
82
  "test:media": "pnpm exec tsx test/continuous-test-suite-media-gen.ts",
83
+ "test:media-registry-collisions": "pnpm exec tsx test/continuous-test-suite-media-registry-collisions.ts",
83
84
  "test:memory": "pnpm exec tsx test/continuous-test-suite-memory.ts",
84
85
  "test:openai-compat-streaming-retry": "pnpm exec tsx test/continuous-test-suite-openai-compat-streaming-retry.ts",
85
86
  "test:anthropic-streaming-retry": "pnpm exec tsx test/continuous-test-suite-anthropic-streaming-retry.ts",