@juspay/neurolink 11.27.0 → 11.29.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/CHANGELOG.md +2 -2
- package/dist/adapters/video/index.d.ts +30 -0
- package/dist/adapters/video/index.js +74 -0
- package/dist/avatar/index.d.ts +6 -3
- package/dist/avatar/index.js +21 -16
- package/dist/browser/neurolink.min.js +392 -392
- package/dist/cli/factories/commandFactory.d.ts +6 -0
- package/dist/cli/factories/commandFactory.js +6 -2
- package/dist/core/baseProvider.js +24 -20
- package/dist/core/resolveRequestKind.d.ts +27 -0
- package/dist/core/resolveRequestKind.js +50 -0
- package/dist/factories/mediaHandlerCatalog.d.ts +18 -0
- package/dist/factories/mediaHandlerCatalog.js +65 -0
- package/dist/factories/providerRegistry.js +50 -207
- package/dist/index.d.ts +1 -4
- package/dist/index.js +2 -5
- package/dist/music/index.d.ts +6 -3
- package/dist/music/index.js +22 -21
- package/dist/neurolink.js +19 -3
- package/dist/types/dispatch.d.ts +22 -0
- package/dist/types/dispatch.js +6 -0
- package/dist/types/generate.d.ts +29 -37
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +3 -0
- package/dist/types/mediaCatalog.d.ts +12 -0
- package/dist/types/mediaCatalog.js +7 -0
- package/dist/types/video.d.ts +13 -0
- package/dist/utils/videoProcessor.d.ts +11 -5
- package/dist/utils/videoProcessor.js +23 -16
- package/dist/voice/index.d.ts +7 -3
- package/dist/voice/index.js +50 -40
- package/package.json +3 -1
|
@@ -3,6 +3,7 @@ import { logger } from "../utils/logger.js";
|
|
|
3
3
|
import { AIProviderName, GoogleAIModels, OpenAIModels, AnthropicModels, VertexModels, OllamaModels, LiteLLMModels, HuggingFaceModels, DeepSeekModels, NvidiaNimModels, OpenRouterModels, CohereModels, VoyageModels, JinaModels, StabilityModels, IdeogramModels, RecraftModels, ReplicateModels, } from "../constants/enums.js";
|
|
4
4
|
import { PROVIDER_DESCRIPTORS_BY_NAME } from "./providerDescriptors.js";
|
|
5
5
|
import { OPENAI_COMPAT_CATALOG } from "../providers/openaiCompatCatalog.js";
|
|
6
|
+
import { providerChoicesFor } from "./mediaHandlerCatalog.js";
|
|
6
7
|
/**
|
|
7
8
|
* Provider Registry - registers all providers with the factory
|
|
8
9
|
* This is where we migrate providers one by one to the new pattern
|
|
@@ -229,16 +230,23 @@ export class ProviderRegistry {
|
|
|
229
230
|
return new RecraftProvider(modelName, sdk, undefined, recraftCreds);
|
|
230
231
|
}, process.env.RECRAFT_MODEL || RecraftModels.RECRAFT_V3, ["recraft"], PROVIDER_DESCRIPTORS_BY_NAME.get(AIProviderName.RECRAFT));
|
|
231
232
|
logger.debug("All AI providers registered successfully");
|
|
233
|
+
// ===== MEDIA HANDLER REGISTRATION =====
|
|
234
|
+
// Single registration path (Task 11): each ecosystem barrel (voice,
|
|
235
|
+
// adapters/video, avatar, music) owns its own provider-name catalog
|
|
236
|
+
// wiring (MEDIA_HANDLER_CATALOG, Task 8) and exposes an idempotent
|
|
237
|
+
// registerDefault*Handlers() function (Task 10) that constructs and
|
|
238
|
+
// registers every shipped handler whose backing credentials are
|
|
239
|
+
// present in process.env. This block's only job is to invoke each of
|
|
240
|
+
// the six functions via dynamic import — no hand-rolled
|
|
241
|
+
// `new XHandler()` + `registerHandler()` calls live here anymore.
|
|
242
|
+
// Each ecosystem keeps its own try/catch so one broken import can't
|
|
243
|
+
// take down the other five (matches the previous block's isolation).
|
|
232
244
|
// ===== TTS HANDLER REGISTRATION =====
|
|
233
245
|
try {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
TTSProcessor.registerHandler("google-ai", googleHandler);
|
|
239
|
-
TTSProcessor.registerHandler("vertex", googleHandler);
|
|
240
|
-
logger.debug("TTS handlers registered successfully", {
|
|
241
|
-
providers: ["google-ai", "vertex"],
|
|
246
|
+
const { registerDefaultTTSHandlers } = await import("../voice/index.js");
|
|
247
|
+
registerDefaultTTSHandlers();
|
|
248
|
+
logger.debug("TTS handler registration attempted", {
|
|
249
|
+
providers: providerChoicesFor("tts"),
|
|
242
250
|
});
|
|
243
251
|
}
|
|
244
252
|
catch (ttsError) {
|
|
@@ -247,91 +255,12 @@ export class ProviderRegistry {
|
|
|
247
255
|
});
|
|
248
256
|
// Don't throw - TTS is optional functionality
|
|
249
257
|
}
|
|
250
|
-
// New TTS providers
|
|
251
|
-
try {
|
|
252
|
-
const { TTSProcessor } = await import("../utils/ttsProcessor.js");
|
|
253
|
-
const { OpenAITTS } = await import("../voice/providers/OpenAITTS.js");
|
|
254
|
-
TTSProcessor.registerHandler("openai-tts", new OpenAITTS());
|
|
255
|
-
}
|
|
256
|
-
catch (err) {
|
|
257
|
-
logger.debug(`[ProviderRegistry] openai-tts registration skipped: ${err instanceof Error ? err.message : String(err)}`);
|
|
258
|
-
}
|
|
259
|
-
try {
|
|
260
|
-
const { TTSProcessor } = await import("../utils/ttsProcessor.js");
|
|
261
|
-
const { ElevenLabsTTS } = await import("../voice/providers/ElevenLabsTTS.js");
|
|
262
|
-
const elevenLabsHandler = new ElevenLabsTTS();
|
|
263
|
-
TTSProcessor.registerHandler("elevenlabs", elevenLabsHandler);
|
|
264
|
-
TTSProcessor.registerHandler("elevenlabs-tts", elevenLabsHandler);
|
|
265
|
-
}
|
|
266
|
-
catch (err) {
|
|
267
|
-
logger.debug(`[ProviderRegistry] elevenlabs registration skipped: ${err instanceof Error ? err.message : String(err)}`);
|
|
268
|
-
}
|
|
269
|
-
try {
|
|
270
|
-
const { TTSProcessor } = await import("../utils/ttsProcessor.js");
|
|
271
|
-
const { AzureTTS } = await import("../voice/providers/AzureTTS.js");
|
|
272
|
-
TTSProcessor.registerHandler("azure-tts", new AzureTTS());
|
|
273
|
-
}
|
|
274
|
-
catch (err) {
|
|
275
|
-
logger.debug(`[ProviderRegistry] azure-tts registration skipped: ${err instanceof Error ? err.message : String(err)}`);
|
|
276
|
-
}
|
|
277
|
-
// Fish Audio and Cartesia also auto-register via the voice/index.ts
|
|
278
|
-
// barrel side-effect. The supports() guard here keeps registration
|
|
279
|
-
// idempotent across entry points — same handler, no overwrite warning.
|
|
280
|
-
try {
|
|
281
|
-
const { TTSProcessor } = await import("../utils/ttsProcessor.js");
|
|
282
|
-
if (!TTSProcessor.supports("fish-audio")) {
|
|
283
|
-
const { FishAudioTTS } = await import("../voice/providers/FishAudioTTS.js");
|
|
284
|
-
TTSProcessor.registerHandler("fish-audio", new FishAudioTTS());
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
catch (err) {
|
|
288
|
-
logger.debug(`[ProviderRegistry] fish-audio registration skipped: ${err instanceof Error ? err.message : String(err)}`);
|
|
289
|
-
}
|
|
290
|
-
try {
|
|
291
|
-
const { TTSProcessor } = await import("../utils/ttsProcessor.js");
|
|
292
|
-
if (!TTSProcessor.supports("cartesia")) {
|
|
293
|
-
const { CartesiaTTS } = await import("../voice/providers/CartesiaTTS.js");
|
|
294
|
-
TTSProcessor.registerHandler("cartesia", new CartesiaTTS());
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
catch (err) {
|
|
298
|
-
logger.debug(`[ProviderRegistry] cartesia registration skipped: ${err instanceof Error ? err.message : String(err)}`);
|
|
299
|
-
}
|
|
300
258
|
// ===== STT HANDLER REGISTRATION =====
|
|
301
259
|
try {
|
|
302
|
-
const {
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
STTProcessor.registerHandler("whisper", openAISTT);
|
|
307
|
-
STTProcessor.registerHandler("openai-stt", openAISTT);
|
|
308
|
-
}
|
|
309
|
-
catch (err) {
|
|
310
|
-
logger.debug(`[ProviderRegistry] whisper/openai-stt registration skipped: ${err instanceof Error ? err.message : String(err)}`);
|
|
311
|
-
}
|
|
312
|
-
try {
|
|
313
|
-
const { DeepgramSTT } = await import("../voice/providers/DeepgramSTT.js");
|
|
314
|
-
STTProcessor.registerHandler("deepgram", new DeepgramSTT());
|
|
315
|
-
}
|
|
316
|
-
catch (err) {
|
|
317
|
-
logger.debug(`[ProviderRegistry] deepgram registration skipped: ${err instanceof Error ? err.message : String(err)}`);
|
|
318
|
-
}
|
|
319
|
-
try {
|
|
320
|
-
const { GoogleSTT } = await import("../voice/providers/GoogleSTT.js");
|
|
321
|
-
STTProcessor.registerHandler("google-stt", new GoogleSTT());
|
|
322
|
-
}
|
|
323
|
-
catch (err) {
|
|
324
|
-
logger.debug(`[ProviderRegistry] google-stt registration skipped: ${err instanceof Error ? err.message : String(err)}`);
|
|
325
|
-
}
|
|
326
|
-
try {
|
|
327
|
-
const { AzureSTT } = await import("../voice/providers/AzureSTT.js");
|
|
328
|
-
STTProcessor.registerHandler("azure-stt", new AzureSTT());
|
|
329
|
-
}
|
|
330
|
-
catch (err) {
|
|
331
|
-
logger.debug(`[ProviderRegistry] azure-stt registration skipped: ${err instanceof Error ? err.message : String(err)}`);
|
|
332
|
-
}
|
|
333
|
-
logger.debug("STT handlers registered successfully", {
|
|
334
|
-
providers: ["whisper", "deepgram", "google-stt", "azure-stt"],
|
|
260
|
+
const { registerDefaultSTTHandlers } = await import("../voice/index.js");
|
|
261
|
+
registerDefaultSTTHandlers();
|
|
262
|
+
logger.debug("STT handler registration attempted", {
|
|
263
|
+
providers: providerChoicesFor("stt"),
|
|
335
264
|
});
|
|
336
265
|
}
|
|
337
266
|
catch (sttError) {
|
|
@@ -341,33 +270,21 @@ export class ProviderRegistry {
|
|
|
341
270
|
}
|
|
342
271
|
// ===== REALTIME HANDLER REGISTRATION =====
|
|
343
272
|
try {
|
|
344
|
-
const { RealtimeProcessor } = await import("../voice/
|
|
345
|
-
|
|
346
|
-
//
|
|
347
|
-
//
|
|
348
|
-
//
|
|
273
|
+
const { registerDefaultRealtimeHandlers, RealtimeProcessor } = await import("../voice/index.js");
|
|
274
|
+
registerDefaultRealtimeHandlers();
|
|
275
|
+
// M9 + NEW4: registerDefaultRealtimeHandlers() swallows per-handler
|
|
276
|
+
// construction failures internally (it's a shared, idempotent
|
|
277
|
+
// barrel function used by every entry point — see voice/index.ts),
|
|
278
|
+
// so the exact per-handler exception text the old inline block
|
|
279
|
+
// captured is no longer available here. Recover per-name pass/fail
|
|
280
|
+
// via supports() instead so getRegistrationReport() stays truthful
|
|
281
|
+
// for callers that poll it.
|
|
282
|
+
const realtimeNames = providerChoicesFor("realtime");
|
|
349
283
|
const realtimeOutcomes = {};
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
}
|
|
355
|
-
catch (err) {
|
|
356
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
357
|
-
realtimeOutcomes["openai-realtime"] = msg;
|
|
358
|
-
// M9: promote per-handler failures to error level so users can
|
|
359
|
-
// see which shipped voice provider failed to register at startup.
|
|
360
|
-
logger.error(`[ProviderRegistry] openai-realtime registration failed: ${msg}`);
|
|
361
|
-
}
|
|
362
|
-
try {
|
|
363
|
-
const { GeminiLive } = await import("../voice/providers/GeminiLive.js");
|
|
364
|
-
RealtimeProcessor.registerHandler("gemini-live", new GeminiLive());
|
|
365
|
-
realtimeOutcomes["gemini-live"] = "ok";
|
|
366
|
-
}
|
|
367
|
-
catch (err) {
|
|
368
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
369
|
-
realtimeOutcomes["gemini-live"] = msg;
|
|
370
|
-
logger.error(`[ProviderRegistry] gemini-live registration failed: ${msg}`);
|
|
284
|
+
for (const name of realtimeNames) {
|
|
285
|
+
realtimeOutcomes[name] = RealtimeProcessor.supports(name)
|
|
286
|
+
? "ok"
|
|
287
|
+
: "registration failed or handler unavailable";
|
|
371
288
|
}
|
|
372
289
|
// NEW4: report the actual per-handler outcomes instead of an
|
|
373
290
|
// unconditional success log. Stored on the registry so callers can
|
|
@@ -375,7 +292,7 @@ export class ProviderRegistry {
|
|
|
375
292
|
ProviderRegistry.realtimeRegistration = realtimeOutcomes;
|
|
376
293
|
const skipped = Object.entries(realtimeOutcomes).filter(([, v]) => v !== "ok");
|
|
377
294
|
if (skipped.length === 0) {
|
|
378
|
-
logger.info(
|
|
295
|
+
logger.info(`[ProviderRegistry] Realtime handlers registered: ${realtimeNames.join(", ")}`);
|
|
379
296
|
}
|
|
380
297
|
else {
|
|
381
298
|
logger.warn(`[ProviderRegistry] Realtime handlers partial: ${skipped.length} skipped`, { outcomes: realtimeOutcomes });
|
|
@@ -390,67 +307,22 @@ export class ProviderRegistry {
|
|
|
390
307
|
}
|
|
391
308
|
// ===== VIDEO HANDLER REGISTRATION =====
|
|
392
309
|
try {
|
|
393
|
-
const {
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
}
|
|
398
|
-
catch (err) {
|
|
399
|
-
logger.debug(`[ProviderRegistry] vertex video registration skipped: ${err instanceof Error ? err.message : String(err)}`);
|
|
400
|
-
}
|
|
401
|
-
try {
|
|
402
|
-
const { KlingVideoHandler } = await import("../adapters/video/klingVideoHandler.js");
|
|
403
|
-
VideoProcessor.registerHandler("kling", new KlingVideoHandler());
|
|
404
|
-
}
|
|
405
|
-
catch (err) {
|
|
406
|
-
logger.debug(`[ProviderRegistry] kling video registration skipped: ${err instanceof Error ? err.message : String(err)}`);
|
|
407
|
-
}
|
|
408
|
-
try {
|
|
409
|
-
const { RunwayVideoHandler } = await import("../adapters/video/runwayVideoHandler.js");
|
|
410
|
-
VideoProcessor.registerHandler("runway", new RunwayVideoHandler());
|
|
411
|
-
}
|
|
412
|
-
catch (err) {
|
|
413
|
-
logger.debug(`[ProviderRegistry] runway video registration skipped: ${err instanceof Error ? err.message : String(err)}`);
|
|
414
|
-
}
|
|
415
|
-
try {
|
|
416
|
-
const { ReplicateVideoHandler } = await import("../adapters/video/replicateVideoHandler.js");
|
|
417
|
-
VideoProcessor.registerHandler("replicate", new ReplicateVideoHandler());
|
|
418
|
-
}
|
|
419
|
-
catch (err) {
|
|
420
|
-
logger.debug(`[ProviderRegistry] replicate video registration skipped: ${err instanceof Error ? err.message : String(err)}`);
|
|
421
|
-
}
|
|
422
|
-
logger.debug("Video handlers registered");
|
|
310
|
+
const { registerDefaultVideoHandlers } = await import("../adapters/video/index.js");
|
|
311
|
+
registerDefaultVideoHandlers();
|
|
312
|
+
logger.debug("Video handler registration attempted", {
|
|
313
|
+
providers: providerChoicesFor("video"),
|
|
314
|
+
});
|
|
423
315
|
}
|
|
424
316
|
catch (err) {
|
|
425
317
|
logger.warn(`[ProviderRegistry] video registration block failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
426
318
|
}
|
|
427
319
|
// ===== AVATAR HANDLER REGISTRATION =====
|
|
428
320
|
try {
|
|
429
|
-
const {
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
}
|
|
434
|
-
catch (err) {
|
|
435
|
-
logger.debug(`[ProviderRegistry] d-id avatar registration skipped: ${err instanceof Error ? err.message : String(err)}`);
|
|
436
|
-
}
|
|
437
|
-
try {
|
|
438
|
-
const { ReplicateAvatar } = await import("../avatar/providers/ReplicateAvatar.js");
|
|
439
|
-
const replicateAvatar = new ReplicateAvatar();
|
|
440
|
-
AvatarProcessor.registerHandler("replicate", replicateAvatar);
|
|
441
|
-
AvatarProcessor.registerHandler("musetalk", replicateAvatar);
|
|
442
|
-
}
|
|
443
|
-
catch (err) {
|
|
444
|
-
logger.debug(`[ProviderRegistry] replicate avatar registration skipped: ${err instanceof Error ? err.message : String(err)}`);
|
|
445
|
-
}
|
|
446
|
-
try {
|
|
447
|
-
const { HeyGenAvatar } = await import("../avatar/providers/HeyGenAvatar.js");
|
|
448
|
-
AvatarProcessor.registerHandler("heygen", new HeyGenAvatar());
|
|
449
|
-
}
|
|
450
|
-
catch (err) {
|
|
451
|
-
logger.debug(`[ProviderRegistry] heygen avatar registration skipped: ${err instanceof Error ? err.message : String(err)}`);
|
|
452
|
-
}
|
|
453
|
-
logger.debug("Avatar handlers registered");
|
|
321
|
+
const { registerDefaultAvatarHandlers } = await import("../avatar/index.js");
|
|
322
|
+
registerDefaultAvatarHandlers();
|
|
323
|
+
logger.debug("Avatar handler registration attempted", {
|
|
324
|
+
providers: providerChoicesFor("avatar"),
|
|
325
|
+
});
|
|
454
326
|
}
|
|
455
327
|
catch (avatarError) {
|
|
456
328
|
logger.warn("Failed to register Avatar handlers - Avatar functionality will be unavailable", {
|
|
@@ -461,40 +333,11 @@ export class ProviderRegistry {
|
|
|
461
333
|
}
|
|
462
334
|
// ===== MUSIC HANDLER REGISTRATION =====
|
|
463
335
|
try {
|
|
464
|
-
const {
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
}
|
|
469
|
-
catch (err) {
|
|
470
|
-
logger.debug(`[ProviderRegistry] beatoven music registration skipped: ${err instanceof Error ? err.message : String(err)}`);
|
|
471
|
-
}
|
|
472
|
-
try {
|
|
473
|
-
const { ReplicateMusic } = await import("../music/providers/ReplicateMusic.js");
|
|
474
|
-
const replicateMusic = new ReplicateMusic();
|
|
475
|
-
MusicProcessor.registerHandler("replicate", replicateMusic);
|
|
476
|
-
MusicProcessor.registerHandler("musicgen", replicateMusic);
|
|
477
|
-
}
|
|
478
|
-
catch (err) {
|
|
479
|
-
logger.debug(`[ProviderRegistry] replicate music registration skipped: ${err instanceof Error ? err.message : String(err)}`);
|
|
480
|
-
}
|
|
481
|
-
try {
|
|
482
|
-
const { ElevenLabsMusic } = await import("../music/providers/ElevenLabsMusic.js");
|
|
483
|
-
const elevenLabsMusic = new ElevenLabsMusic();
|
|
484
|
-
MusicProcessor.registerHandler("elevenlabs-music", elevenLabsMusic);
|
|
485
|
-
MusicProcessor.registerHandler("elevenlabs-sound", elevenLabsMusic);
|
|
486
|
-
}
|
|
487
|
-
catch (err) {
|
|
488
|
-
logger.debug(`[ProviderRegistry] elevenlabs-music registration skipped: ${err instanceof Error ? err.message : String(err)}`);
|
|
489
|
-
}
|
|
490
|
-
try {
|
|
491
|
-
const { LyriaMusic } = await import("../music/providers/LyriaMusic.js");
|
|
492
|
-
MusicProcessor.registerHandler("lyria", new LyriaMusic());
|
|
493
|
-
}
|
|
494
|
-
catch (err) {
|
|
495
|
-
logger.debug(`[ProviderRegistry] lyria music registration skipped: ${err instanceof Error ? err.message : String(err)}`);
|
|
496
|
-
}
|
|
497
|
-
logger.debug("Music handlers registered");
|
|
336
|
+
const { registerDefaultMusicHandlers } = await import("../music/index.js");
|
|
337
|
+
registerDefaultMusicHandlers();
|
|
338
|
+
logger.debug("Music handler registration attempted", {
|
|
339
|
+
providers: providerChoicesFor("music"),
|
|
340
|
+
});
|
|
498
341
|
}
|
|
499
342
|
catch (musicError) {
|
|
500
343
|
logger.warn("Failed to register Music handlers - Music functionality will be unavailable", {
|
package/dist/index.d.ts
CHANGED
|
@@ -67,10 +67,7 @@ export { STTProcessor } from "./utils/sttProcessor.js";
|
|
|
67
67
|
export { AzureTTS, AzureTTSHandler, CartesiaTTS, CartesiaTTSHandler, ElevenLabsTTS, ElevenLabsTTSHandler, FishAudioTTS, FishAudioTTSHandler, GoogleTTSHandler, OpenAITTS, OpenAITTSHandler, AzureSTT, AzureSTTHandler, DeepgramSTT, DeepgramSTTHandler, GoogleSTT, GoogleSTTHandler, OpenAISTT, OpenAISTTHandler, WhisperSTT, WhisperSTTHandler, BaseRealtimeHandler, GeminiLive, GeminiLiveHandler, OpenAIRealtime, OpenAIRealtimeHandler, RealtimeProcessor, RealtimeError, STTError, VoiceError, registerDefaultRealtimeHandlers, registerDefaultSTTHandlers, registerDefaultTTSHandlers, } from "./voice/index.js";
|
|
68
68
|
export { BeatovenMusic, BeatovenMusicHandler, ElevenLabsMusic, ElevenLabsMusicHandler, LyriaMusic, LyriaMusicHandler, registerDefaultMusicHandlers, ReplicateMusic, ReplicateMusicHandler, } from "./music/index.js";
|
|
69
69
|
export { DIDAvatar, DIDAvatarHandler, HeyGenAvatar, HeyGenAvatarHandler, registerDefaultAvatarHandlers, ReplicateAvatar, ReplicateAvatarHandler, } from "./avatar/index.js";
|
|
70
|
-
export { KlingVideoHandler } from "./adapters/video/
|
|
71
|
-
export { ReplicateVideoHandler } from "./adapters/video/replicateVideoHandler.js";
|
|
72
|
-
export { RunwayVideoHandler } from "./adapters/video/runwayVideoHandler.js";
|
|
73
|
-
export { VertexVideoHandler, isVertexVideoConfigured, } from "./adapters/video/vertexVideoHandler.js";
|
|
70
|
+
export { isVertexVideoConfigured, KlingVideoHandler, registerDefaultVideoHandlers, ReplicateVideoHandler, RunwayVideoHandler, VertexVideoHandler, } from "./adapters/video/index.js";
|
|
74
71
|
export { ImageGenService } from "./image-gen/ImageGenService.js";
|
|
75
72
|
export { HITLManager } from "./hitl/hitlManager.js";
|
|
76
73
|
export { ProviderRegistry } from "./factories/providerRegistry.js";
|
package/dist/index.js
CHANGED
|
@@ -125,11 +125,8 @@ registerDefaultRealtimeHandlers, registerDefaultSTTHandlers, registerDefaultTTSH
|
|
|
125
125
|
export { BeatovenMusic, BeatovenMusicHandler, ElevenLabsMusic, ElevenLabsMusicHandler, LyriaMusic, LyriaMusicHandler, registerDefaultMusicHandlers, ReplicateMusic, ReplicateMusicHandler, } from "./music/index.js";
|
|
126
126
|
// Avatar handlers
|
|
127
127
|
export { DIDAvatar, DIDAvatarHandler, HeyGenAvatar, HeyGenAvatarHandler, registerDefaultAvatarHandlers, ReplicateAvatar, ReplicateAvatarHandler, } from "./avatar/index.js";
|
|
128
|
-
// Video handlers
|
|
129
|
-
export { KlingVideoHandler } from "./adapters/video/
|
|
130
|
-
export { ReplicateVideoHandler } from "./adapters/video/replicateVideoHandler.js";
|
|
131
|
-
export { RunwayVideoHandler } from "./adapters/video/runwayVideoHandler.js";
|
|
132
|
-
export { VertexVideoHandler, isVertexVideoConfigured, } from "./adapters/video/vertexVideoHandler.js";
|
|
128
|
+
// Video handlers
|
|
129
|
+
export { isVertexVideoConfigured, KlingVideoHandler, registerDefaultVideoHandlers, ReplicateVideoHandler, RunwayVideoHandler, VertexVideoHandler, } from "./adapters/video/index.js";
|
|
133
130
|
// Image generation + HITL — surfaced from their dedicated barrels
|
|
134
131
|
export { ImageGenService } from "./image-gen/ImageGenService.js";
|
|
135
132
|
export { HITLManager } from "./hitl/hitlManager.js";
|
package/dist/music/index.d.ts
CHANGED
|
@@ -7,9 +7,12 @@
|
|
|
7
7
|
* Use `MusicProcessor.generate(provider, options)` to dispatch to the
|
|
8
8
|
* registered handler for `provider`.
|
|
9
9
|
*
|
|
10
|
-
* Importing this module
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* Importing this module does NOT register any handlers as a side effect.
|
|
11
|
+
* Call `registerDefaultMusicHandlers()` explicitly (or go through
|
|
12
|
+
* `ProviderRegistry.registerAllProviders()`, which every documented
|
|
13
|
+
* `NeuroLink` entry point already calls) to register every shipped music
|
|
14
|
+
* handler whose backing API key is present in `process.env`. Registration
|
|
15
|
+
* is idempotent and silently skipped if a provider is already registered or
|
|
13
16
|
* its constructor throws (e.g. missing optional native dependency).
|
|
14
17
|
*
|
|
15
18
|
* @module music
|
package/dist/music/index.js
CHANGED
|
@@ -7,13 +7,17 @@
|
|
|
7
7
|
* Use `MusicProcessor.generate(provider, options)` to dispatch to the
|
|
8
8
|
* registered handler for `provider`.
|
|
9
9
|
*
|
|
10
|
-
* Importing this module
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* Importing this module does NOT register any handlers as a side effect.
|
|
11
|
+
* Call `registerDefaultMusicHandlers()` explicitly (or go through
|
|
12
|
+
* `ProviderRegistry.registerAllProviders()`, which every documented
|
|
13
|
+
* `NeuroLink` entry point already calls) to register every shipped music
|
|
14
|
+
* handler whose backing API key is present in `process.env`. Registration
|
|
15
|
+
* is idempotent and silently skipped if a provider is already registered or
|
|
13
16
|
* its constructor throws (e.g. missing optional native dependency).
|
|
14
17
|
*
|
|
15
18
|
* @module music
|
|
16
19
|
*/
|
|
20
|
+
import { MEDIA_HANDLER_CATALOG } from "../factories/mediaHandlerCatalog.js";
|
|
17
21
|
import { logger } from "../utils/logger.js";
|
|
18
22
|
import { MusicProcessor } from "../utils/musicProcessor.js";
|
|
19
23
|
export { MUSIC_ERROR_CODES, MusicError, MusicProcessor, } from "../utils/musicProcessor.js";
|
|
@@ -31,20 +35,21 @@ import { BeatovenMusic } from "./providers/BeatovenMusic.js";
|
|
|
31
35
|
import { ElevenLabsMusic } from "./providers/ElevenLabsMusic.js";
|
|
32
36
|
import { LyriaMusic } from "./providers/LyriaMusic.js";
|
|
33
37
|
import { ReplicateMusic } from "./providers/ReplicateMusic.js";
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
38
|
+
// Provider names + aliases are the Task-8 catalog's job — only the factory
|
|
39
|
+
// (which needs the imported handler class) stays local to this module.
|
|
40
|
+
const MUSIC_HANDLER_FACTORIES = {
|
|
41
|
+
beatoven: () => new BeatovenMusic(),
|
|
42
|
+
"elevenlabs-music": () => new ElevenLabsMusic(),
|
|
43
|
+
lyria: () => new LyriaMusic(),
|
|
44
|
+
replicate: () => new ReplicateMusic(),
|
|
45
|
+
};
|
|
46
|
+
const MUSIC_HANDLER_CANDIDATES = MEDIA_HANDLER_CATALOG.filter((entry) => entry.kind === "music").map((entry) => {
|
|
47
|
+
const factory = MUSIC_HANDLER_FACTORIES[entry.name];
|
|
48
|
+
if (!factory) {
|
|
49
|
+
throw new Error(`[music] no handler factory for catalog entry "${entry.name}"`);
|
|
50
|
+
}
|
|
51
|
+
return { name: entry.name, aliases: entry.aliases, factory };
|
|
52
|
+
});
|
|
48
53
|
/**
|
|
49
54
|
* Register every shipped music handler whose backing credentials are
|
|
50
55
|
* present in the environment. Safe to call multiple times — existing
|
|
@@ -87,7 +92,3 @@ export function registerDefaultMusicHandlers() {
|
|
|
87
92
|
}
|
|
88
93
|
}
|
|
89
94
|
}
|
|
90
|
-
// Run once at module import so consumers who follow the documented
|
|
91
|
-
// `nl.generate(...)` flow get every configured handler without manually
|
|
92
|
-
// calling `registerHandler`.
|
|
93
|
-
registerDefaultMusicHandlers();
|
package/dist/neurolink.js
CHANGED
|
@@ -34,6 +34,7 @@ import { buildToolRoutingCatalog, buildRoutingQueryFromHistory, resolveToolRouti
|
|
|
34
34
|
import { ToolRoutingCache } from "./core/toolRoutingCache.js";
|
|
35
35
|
import { DEFAULT_RECENT_TURNS, KnowledgeGroundingEngine, } from "./knowledge/index.js";
|
|
36
36
|
import { AIProviderFactory } from "./core/factory.js";
|
|
37
|
+
import { resolveRequestKind } from "./core/resolveRequestKind.js";
|
|
37
38
|
import { createToolEventPayload } from "./core/toolEvents.js";
|
|
38
39
|
import { ProviderFactory } from "./factories/providerFactory.js";
|
|
39
40
|
import { ProviderRegistry } from "./factories/providerRegistry.js";
|
|
@@ -3576,13 +3577,16 @@ Current user's request: ${currentInput}`;
|
|
|
3576
3577
|
}
|
|
3577
3578
|
return this.generateWithWorkflow(options);
|
|
3578
3579
|
}
|
|
3579
|
-
|
|
3580
|
+
// Single source of truth for "what kind of request is this" — see
|
|
3581
|
+
// resolveRequestKind's doc comment for the full precedence table.
|
|
3582
|
+
const requestKind = resolveRequestKind(options, options.model);
|
|
3583
|
+
if (requestKind === "music") {
|
|
3580
3584
|
return this.generateWithMusic(options, generateSpan);
|
|
3581
3585
|
}
|
|
3582
|
-
if (
|
|
3586
|
+
if (requestKind === "avatar") {
|
|
3583
3587
|
return this.generateWithAvatar(options, generateSpan);
|
|
3584
3588
|
}
|
|
3585
|
-
if (
|
|
3589
|
+
if (requestKind !== "ppt") {
|
|
3586
3590
|
return null;
|
|
3587
3591
|
}
|
|
3588
3592
|
if (options.stt?.enabled && options.stt?.audio) {
|
|
@@ -4382,6 +4386,13 @@ Current user's request: ${currentInput}`;
|
|
|
4382
4386
|
if (!providerName) {
|
|
4383
4387
|
throw new Error('output.music.provider is required (e.g. "beatoven", "elevenlabs-music", "lyria", "replicate").');
|
|
4384
4388
|
}
|
|
4389
|
+
// This early-dispatch path never creates an AI provider, so
|
|
4390
|
+
// ProviderRegistry.registerAllProviders() has NOT necessarily run —
|
|
4391
|
+
// with the module-scope auto-registration retired, the handlers must
|
|
4392
|
+
// be registered here explicitly. registerDefaultMusicHandlers() is
|
|
4393
|
+
// idempotent (skip-if-registered), so the repeat call is free.
|
|
4394
|
+
const { registerDefaultMusicHandlers } = await import("./music/index.js");
|
|
4395
|
+
registerDefaultMusicHandlers();
|
|
4385
4396
|
const { MusicProcessor } = await import("./utils/musicProcessor.js");
|
|
4386
4397
|
const musicResult = await MusicProcessor.generate(providerName, {
|
|
4387
4398
|
...musicOptions,
|
|
@@ -4414,6 +4425,11 @@ Current user's request: ${currentInput}`;
|
|
|
4414
4425
|
if (!providerName) {
|
|
4415
4426
|
throw new Error('output.avatar.provider is required (e.g. "d-id", "heygen", "replicate").');
|
|
4416
4427
|
}
|
|
4428
|
+
// Same early-dispatch registration as generateWithMusic above: no AI
|
|
4429
|
+
// provider is created on this path, so the retired module-scope
|
|
4430
|
+
// auto-run must be replaced by an explicit (idempotent) call here.
|
|
4431
|
+
const { registerDefaultAvatarHandlers } = await import("./avatar/index.js");
|
|
4432
|
+
registerDefaultAvatarHandlers();
|
|
4417
4433
|
const { AvatarProcessor } = await import("./utils/avatarProcessor.js");
|
|
4418
4434
|
const avatarResult = await AvatarProcessor.generate(providerName, avatarOptions);
|
|
4419
4435
|
generateSpan.setAttribute("neurolink.avatar.provider", providerName);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types backing resolveRequestKind() (src/lib/core/resolveRequestKind.ts) —
|
|
3
|
+
* the single function that decides which of NeuroLink's output modes a
|
|
4
|
+
* generate/stream request is asking for.
|
|
5
|
+
*/
|
|
6
|
+
export type RequestKind = "text" | "image" | "video" | "music" | "avatar" | "tts-direct" | "ppt";
|
|
7
|
+
/**
|
|
8
|
+
* Narrow structural subset of TextGenerationOptions/GenerateOptions that
|
|
9
|
+
* resolveRequestKind() actually reads. Kept intentionally minimal (rather
|
|
10
|
+
* than importing the full options type) so this module has no dependency
|
|
11
|
+
* on the wider options type graph.
|
|
12
|
+
*/
|
|
13
|
+
export type RequestKindInput = {
|
|
14
|
+
output?: {
|
|
15
|
+
mode?: string;
|
|
16
|
+
format?: string;
|
|
17
|
+
};
|
|
18
|
+
tts?: {
|
|
19
|
+
enabled?: boolean;
|
|
20
|
+
useAiResponse?: boolean;
|
|
21
|
+
};
|
|
22
|
+
};
|
package/dist/types/generate.d.ts
CHANGED
|
@@ -802,23 +802,12 @@ export type ToolExecutionCaptureOptions = {
|
|
|
802
802
|
*/
|
|
803
803
|
export type GenerateStopReason = "completed" | "step-cap" | "context-cap" | "time-limit" | "stalled" | "aborted" | "provider-error";
|
|
804
804
|
/**
|
|
805
|
-
*
|
|
806
|
-
*
|
|
805
|
+
* Media generation/processing outputs shared by GenerateResult and
|
|
806
|
+
* TextGenerationResult. Extracted so both result types intersect (&) this
|
|
807
|
+
* single definition instead of each declaring its own drifting copy of the
|
|
808
|
+
* same audio/video/avatar/music/ppt/image/transcription fields.
|
|
807
809
|
*/
|
|
808
|
-
export type
|
|
809
|
-
content: string;
|
|
810
|
-
/** Knowledge-grounding diagnostics for this turn (present only when grounding ran). */
|
|
811
|
-
knowledge?: KnowledgeGroundingMetadata;
|
|
812
|
-
/**
|
|
813
|
-
* Parsed structured object when a `schema` was requested. Populated from
|
|
814
|
-
* AI-SDK experimental_output, or from text-mode coercion (balanced-scan +
|
|
815
|
-
* jsonrepair). Prefer this over JSON.parse(content) — it never requires the
|
|
816
|
-
* caller to re-parse hand-escaped model text.
|
|
817
|
-
*/
|
|
818
|
-
structuredData?: unknown;
|
|
819
|
-
outputs?: {
|
|
820
|
-
text: string;
|
|
821
|
-
};
|
|
810
|
+
export type MediaGenerationOutputs = {
|
|
822
811
|
/**
|
|
823
812
|
* Text-to-Speech audio result
|
|
824
813
|
*
|
|
@@ -911,9 +900,31 @@ export type GenerateResult = {
|
|
|
911
900
|
* ```
|
|
912
901
|
*/
|
|
913
902
|
ppt?: PPTGenerationResult;
|
|
903
|
+
/** Standard format for image generation */
|
|
914
904
|
imageOutput?: {
|
|
915
905
|
base64: string;
|
|
916
906
|
} | null;
|
|
907
|
+
/** STT transcription result (present when stt.enabled is true and audio input was provided) */
|
|
908
|
+
transcription?: STTResult;
|
|
909
|
+
};
|
|
910
|
+
/**
|
|
911
|
+
* Generate function result type - Primary output format
|
|
912
|
+
* Future-ready for multi-modal outputs while maintaining text focus
|
|
913
|
+
*/
|
|
914
|
+
export type GenerateResult = {
|
|
915
|
+
content: string;
|
|
916
|
+
/** Knowledge-grounding diagnostics for this turn (present only when grounding ran). */
|
|
917
|
+
knowledge?: KnowledgeGroundingMetadata;
|
|
918
|
+
/**
|
|
919
|
+
* Parsed structured object when a `schema` was requested. Populated from
|
|
920
|
+
* AI-SDK experimental_output, or from text-mode coercion (balanced-scan +
|
|
921
|
+
* jsonrepair). Prefer this over JSON.parse(content) — it never requires the
|
|
922
|
+
* caller to re-parse hand-escaped model text.
|
|
923
|
+
*/
|
|
924
|
+
structuredData?: unknown;
|
|
925
|
+
outputs?: {
|
|
926
|
+
text: string;
|
|
927
|
+
};
|
|
917
928
|
provider?: string;
|
|
918
929
|
model?: string;
|
|
919
930
|
finishReason?: string;
|
|
@@ -1013,8 +1024,6 @@ export type GenerateResult = {
|
|
|
1013
1024
|
reasoning?: string;
|
|
1014
1025
|
/** Token count for reasoning content */
|
|
1015
1026
|
reasoningTokens?: number;
|
|
1016
|
-
/** STT transcription result (present when stt.enabled is true and audio input was provided) */
|
|
1017
|
-
transcription?: STTResult;
|
|
1018
1027
|
retries?: {
|
|
1019
1028
|
count: number;
|
|
1020
1029
|
errors: Array<{
|
|
@@ -1033,7 +1042,7 @@ export type GenerateResult = {
|
|
|
1033
1042
|
* absolute `requestsRemaining` / `tokensRemaining`.
|
|
1034
1043
|
*/
|
|
1035
1044
|
limits?: ClaudeLimitSnapshot;
|
|
1036
|
-
};
|
|
1045
|
+
} & MediaGenerationOutputs;
|
|
1037
1046
|
/**
|
|
1038
1047
|
* Unified options for both generation and streaming
|
|
1039
1048
|
* Supports factory patterns and domain configuration
|
|
@@ -1467,23 +1476,6 @@ export type TextGenerationResult = {
|
|
|
1467
1476
|
}>;
|
|
1468
1477
|
analytics?: AnalyticsData;
|
|
1469
1478
|
evaluation?: EvaluationData;
|
|
1470
|
-
audio?: TTSResult;
|
|
1471
|
-
/** Outcome of TTS synthesis, including the failure reason. */
|
|
1472
|
-
ttsMetadata?: TTSMetadata;
|
|
1473
|
-
/** STT transcription result (present when stt input was processed) */
|
|
1474
|
-
transcription?: STTResult;
|
|
1475
|
-
/** Video generation result */
|
|
1476
|
-
video?: VideoGenerationResult;
|
|
1477
|
-
/** Avatar (talking-head) generation result */
|
|
1478
|
-
avatar?: AvatarResult;
|
|
1479
|
-
/** Music generation result */
|
|
1480
|
-
music?: MusicResult;
|
|
1481
|
-
/** PowerPoint generation result */
|
|
1482
|
-
ppt?: PPTGenerationResult;
|
|
1483
|
-
/** Image generation output */
|
|
1484
|
-
imageOutput?: {
|
|
1485
|
-
base64: string;
|
|
1486
|
-
} | null;
|
|
1487
1479
|
/** Gemini 3 thought signature for reasoning continuity across turns */
|
|
1488
1480
|
thoughtSignature?: string;
|
|
1489
1481
|
/** Thinking/reasoning text from provider (Anthropic thinking blocks, Gemini thought parts, DeepSeek/NIM reasoning_content) */
|
|
@@ -1497,7 +1489,7 @@ export type TextGenerationResult = {
|
|
|
1497
1489
|
message: string;
|
|
1498
1490
|
}>;
|
|
1499
1491
|
};
|
|
1500
|
-
};
|
|
1492
|
+
} & MediaGenerationOutputs;
|
|
1501
1493
|
/**
|
|
1502
1494
|
* Enhanced result type with optional analytics/evaluation
|
|
1503
1495
|
*/
|
package/dist/types/index.d.ts
CHANGED
|
@@ -79,9 +79,11 @@ 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
86
|
export * from "./classifierRouter.js";
|
|
86
87
|
export * from "./agentNetwork.js";
|
|
87
88
|
export * from "./localUsage.js";
|
|
89
|
+
export * from "./dispatch.js";
|