@juspay/neurolink 9.64.0 → 9.65.1
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 +12 -0
- package/README.md +18 -17
- package/dist/adapters/providerImageAdapter.js +29 -1
- package/dist/adapters/replicate/auth.d.ts +19 -0
- package/dist/adapters/replicate/auth.js +32 -0
- package/dist/adapters/replicate/predictionLifecycle.d.ts +46 -0
- package/dist/adapters/replicate/predictionLifecycle.js +283 -0
- package/dist/adapters/video/klingVideoHandler.d.ts +37 -0
- package/dist/adapters/video/klingVideoHandler.js +305 -0
- package/dist/adapters/video/replicateVideoHandler.d.ts +29 -0
- package/dist/adapters/video/replicateVideoHandler.js +157 -0
- package/dist/adapters/video/runwayVideoHandler.d.ts +32 -0
- package/dist/adapters/video/runwayVideoHandler.js +316 -0
- package/dist/adapters/video/vertexVideoHandler.d.ts +19 -1
- package/dist/adapters/video/vertexVideoHandler.js +33 -9
- package/dist/agent/directTools.js +11 -3
- package/dist/autoresearch/runner.js +8 -2
- package/dist/avatar/index.d.ts +13 -0
- package/dist/avatar/index.js +13 -0
- package/dist/avatar/providers/DIDAvatar.d.ts +49 -0
- package/dist/avatar/providers/DIDAvatar.js +501 -0
- package/dist/avatar/providers/HeyGenAvatar.d.ts +30 -0
- package/dist/avatar/providers/HeyGenAvatar.js +337 -0
- package/dist/avatar/providers/ReplicateAvatar.d.ts +36 -0
- package/dist/avatar/providers/ReplicateAvatar.js +267 -0
- package/dist/browser/neurolink.min.js +624 -601
- package/dist/cli/commands/mcp.js +29 -0
- package/dist/cli/commands/proxy.js +24 -5
- package/dist/cli/factories/commandFactory.d.ts +11 -1
- package/dist/cli/factories/commandFactory.js +291 -38
- package/dist/constants/contextWindows.js +101 -0
- package/dist/constants/enums.d.ts +273 -2
- package/dist/constants/enums.js +290 -1
- package/dist/constants/videoErrors.d.ts +4 -0
- package/dist/constants/videoErrors.js +4 -0
- package/dist/core/baseProvider.d.ts +22 -2
- package/dist/core/baseProvider.js +217 -11
- package/dist/core/constants.d.ts +12 -0
- package/dist/core/constants.js +72 -1
- package/dist/evaluation/index.d.ts +2 -0
- package/dist/evaluation/index.js +4 -0
- package/dist/factories/providerFactory.js +7 -1
- package/dist/factories/providerRegistry.js +202 -5
- package/dist/features/ppt/contentPlanner.js +42 -14
- package/dist/index.d.ts +9 -1
- package/dist/index.js +16 -1
- package/dist/lib/adapters/providerImageAdapter.js +29 -1
- package/dist/lib/adapters/replicate/auth.d.ts +19 -0
- package/dist/lib/adapters/replicate/auth.js +33 -0
- package/dist/lib/adapters/replicate/predictionLifecycle.d.ts +46 -0
- package/dist/lib/adapters/replicate/predictionLifecycle.js +284 -0
- package/dist/lib/adapters/video/klingVideoHandler.d.ts +37 -0
- package/dist/lib/adapters/video/klingVideoHandler.js +306 -0
- package/dist/lib/adapters/video/replicateVideoHandler.d.ts +29 -0
- package/dist/lib/adapters/video/replicateVideoHandler.js +158 -0
- package/dist/lib/adapters/video/runwayVideoHandler.d.ts +32 -0
- package/dist/lib/adapters/video/runwayVideoHandler.js +317 -0
- package/dist/lib/adapters/video/vertexVideoHandler.d.ts +19 -1
- package/dist/lib/adapters/video/vertexVideoHandler.js +33 -9
- package/dist/lib/agent/directTools.js +11 -3
- package/dist/lib/autoresearch/runner.js +8 -2
- package/dist/lib/avatar/index.d.ts +13 -0
- package/dist/lib/avatar/index.js +14 -0
- package/dist/lib/avatar/providers/DIDAvatar.d.ts +49 -0
- package/dist/lib/avatar/providers/DIDAvatar.js +502 -0
- package/dist/lib/avatar/providers/HeyGenAvatar.d.ts +30 -0
- package/dist/lib/avatar/providers/HeyGenAvatar.js +338 -0
- package/dist/lib/avatar/providers/ReplicateAvatar.d.ts +36 -0
- package/dist/lib/avatar/providers/ReplicateAvatar.js +268 -0
- package/dist/lib/constants/contextWindows.js +101 -0
- package/dist/lib/constants/enums.d.ts +273 -2
- package/dist/lib/constants/enums.js +290 -1
- package/dist/lib/constants/videoErrors.d.ts +4 -0
- package/dist/lib/constants/videoErrors.js +4 -0
- package/dist/lib/core/baseProvider.d.ts +22 -2
- package/dist/lib/core/baseProvider.js +217 -11
- package/dist/lib/core/constants.d.ts +12 -0
- package/dist/lib/core/constants.js +72 -1
- package/dist/lib/evaluation/index.d.ts +2 -0
- package/dist/lib/evaluation/index.js +4 -0
- package/dist/lib/factories/providerFactory.js +7 -1
- package/dist/lib/factories/providerRegistry.js +202 -5
- package/dist/lib/features/ppt/contentPlanner.js +42 -14
- package/dist/lib/index.d.ts +9 -1
- package/dist/lib/index.js +16 -1
- package/dist/lib/middleware/builtin/lifecycle.js +39 -9
- package/dist/lib/music/index.d.ts +13 -0
- package/dist/lib/music/index.js +14 -0
- package/dist/lib/music/providers/BeatovenMusic.d.ts +31 -0
- package/dist/lib/music/providers/BeatovenMusic.js +334 -0
- package/dist/lib/music/providers/ElevenLabsMusic.d.ts +30 -0
- package/dist/lib/music/providers/ElevenLabsMusic.js +169 -0
- package/dist/lib/music/providers/LyriaMusic.d.ts +29 -0
- package/dist/lib/music/providers/LyriaMusic.js +173 -0
- package/dist/lib/music/providers/ReplicateMusic.d.ts +31 -0
- package/dist/lib/music/providers/ReplicateMusic.js +262 -0
- package/dist/lib/neurolink.d.ts +30 -0
- package/dist/lib/neurolink.js +323 -77
- package/dist/lib/providers/amazonBedrock.d.ts +10 -0
- package/dist/lib/providers/amazonBedrock.js +94 -39
- package/dist/lib/providers/anthropic.js +55 -7
- package/dist/lib/providers/anthropicBaseProvider.js +1 -1
- package/dist/lib/providers/azureOpenai.js +66 -17
- package/dist/lib/providers/cloudflare.d.ts +35 -0
- package/dist/lib/providers/cloudflare.js +174 -0
- package/dist/lib/providers/cohere.d.ts +52 -0
- package/dist/lib/providers/cohere.js +253 -0
- package/dist/lib/providers/deepseek.js +72 -17
- package/dist/lib/providers/fireworks.d.ts +33 -0
- package/dist/lib/providers/fireworks.js +164 -0
- package/dist/lib/providers/googleAiStudio.js +126 -10
- package/dist/lib/providers/googleNativeGemini3.d.ts +26 -6
- package/dist/lib/providers/googleNativeGemini3.js +276 -29
- package/dist/lib/providers/googleVertex.js +639 -181
- package/dist/lib/providers/groq.d.ts +33 -0
- package/dist/lib/providers/groq.js +181 -0
- package/dist/lib/providers/huggingFace.js +9 -8
- package/dist/lib/providers/ideogram.d.ts +34 -0
- package/dist/lib/providers/ideogram.js +184 -0
- package/dist/lib/providers/index.d.ts +13 -0
- package/dist/lib/providers/index.js +13 -0
- package/dist/lib/providers/jina.d.ts +59 -0
- package/dist/lib/providers/jina.js +218 -0
- package/dist/lib/providers/llamaCpp.js +14 -46
- package/dist/lib/providers/lmStudio.js +14 -47
- package/dist/lib/providers/mistral.js +7 -7
- package/dist/lib/providers/nvidiaNim.js +160 -19
- package/dist/lib/providers/ollama.js +7 -7
- package/dist/lib/providers/openAI.d.ts +22 -1
- package/dist/lib/providers/openAI.js +181 -0
- package/dist/lib/providers/openRouter.js +35 -23
- package/dist/lib/providers/openaiCompatible.js +9 -8
- package/dist/lib/providers/perplexity.d.ts +33 -0
- package/dist/lib/providers/perplexity.js +179 -0
- package/dist/lib/providers/recraft.d.ts +34 -0
- package/dist/lib/providers/recraft.js +197 -0
- package/dist/lib/providers/replicate.d.ts +75 -0
- package/dist/lib/providers/replicate.js +403 -0
- package/dist/lib/providers/stability.d.ts +37 -0
- package/dist/lib/providers/stability.js +191 -0
- package/dist/lib/providers/togetherAi.d.ts +33 -0
- package/dist/lib/providers/togetherAi.js +176 -0
- package/dist/lib/providers/voyage.d.ts +47 -0
- package/dist/lib/providers/voyage.js +177 -0
- package/dist/lib/providers/xai.d.ts +33 -0
- package/dist/lib/providers/xai.js +172 -0
- package/dist/lib/telemetry/index.d.ts +1 -1
- package/dist/lib/telemetry/index.js +1 -1
- package/dist/lib/telemetry/tracers.d.ts +19 -0
- package/dist/lib/telemetry/tracers.js +19 -0
- package/dist/lib/telemetry/withSpan.d.ts +35 -0
- package/dist/lib/telemetry/withSpan.js +103 -0
- package/dist/lib/types/avatar.d.ts +143 -0
- package/dist/lib/types/avatar.js +20 -0
- package/dist/lib/types/cli.d.ts +6 -0
- package/dist/lib/types/conversation.d.ts +16 -0
- package/dist/lib/types/generate.d.ts +62 -5
- package/dist/lib/types/index.d.ts +5 -0
- package/dist/lib/types/index.js +7 -0
- package/dist/lib/types/middleware.d.ts +27 -0
- package/dist/lib/types/multimodal.d.ts +35 -2
- package/dist/lib/types/music.d.ts +165 -0
- package/dist/lib/types/music.js +21 -0
- package/dist/lib/types/providers.d.ts +144 -1
- package/dist/lib/types/replicate.d.ts +67 -0
- package/dist/lib/types/replicate.js +10 -0
- package/dist/lib/types/safeFetch.d.ts +15 -0
- package/dist/lib/types/safeFetch.js +7 -0
- package/dist/lib/types/stream.d.ts +2 -1
- package/dist/lib/types/tools.d.ts +13 -0
- package/dist/lib/types/video.d.ts +89 -0
- package/dist/lib/types/video.js +15 -0
- package/dist/lib/utils/avatarProcessor.d.ts +68 -0
- package/dist/lib/utils/avatarProcessor.js +172 -0
- package/dist/lib/utils/cloneOptions.d.ts +36 -0
- package/dist/lib/utils/cloneOptions.js +62 -0
- package/dist/lib/utils/lifecycleCallbacks.d.ts +51 -8
- package/dist/lib/utils/lifecycleCallbacks.js +82 -26
- package/dist/lib/utils/lifecycleTimeout.d.ts +25 -0
- package/dist/lib/utils/lifecycleTimeout.js +39 -0
- package/dist/lib/utils/logSanitize.d.ts +49 -0
- package/dist/lib/utils/logSanitize.js +170 -0
- package/dist/lib/utils/loggingFetch.d.ts +29 -0
- package/dist/lib/utils/loggingFetch.js +60 -0
- package/dist/lib/utils/messageBuilder.js +43 -25
- package/dist/lib/utils/modelChoices.js +236 -3
- package/dist/lib/utils/musicProcessor.d.ts +67 -0
- package/dist/lib/utils/musicProcessor.js +189 -0
- package/dist/lib/utils/optionsConversion.js +3 -2
- package/dist/lib/utils/parameterValidation.js +14 -4
- package/dist/lib/utils/pricing.js +193 -0
- package/dist/lib/utils/providerConfig.d.ts +55 -0
- package/dist/lib/utils/providerConfig.js +224 -0
- package/dist/lib/utils/safeFetch.d.ts +26 -0
- package/dist/lib/utils/safeFetch.js +83 -0
- package/dist/lib/utils/sizeGuard.d.ts +34 -0
- package/dist/lib/utils/sizeGuard.js +45 -0
- package/dist/lib/utils/ssrfGuard.d.ts +52 -0
- package/dist/lib/utils/ssrfGuard.js +411 -0
- package/dist/lib/utils/videoProcessor.d.ts +60 -0
- package/dist/lib/utils/videoProcessor.js +201 -0
- package/dist/lib/voice/providers/FishAudioTTS.d.ts +27 -0
- package/dist/lib/voice/providers/FishAudioTTS.js +183 -0
- package/dist/lib/workflow/core/ensembleExecutor.js +26 -9
- package/dist/middleware/builtin/lifecycle.js +39 -9
- package/dist/music/index.d.ts +13 -0
- package/dist/music/index.js +13 -0
- package/dist/music/providers/BeatovenMusic.d.ts +31 -0
- package/dist/music/providers/BeatovenMusic.js +333 -0
- package/dist/music/providers/ElevenLabsMusic.d.ts +30 -0
- package/dist/music/providers/ElevenLabsMusic.js +168 -0
- package/dist/music/providers/LyriaMusic.d.ts +29 -0
- package/dist/music/providers/LyriaMusic.js +172 -0
- package/dist/music/providers/ReplicateMusic.d.ts +31 -0
- package/dist/music/providers/ReplicateMusic.js +261 -0
- package/dist/neurolink.d.ts +30 -0
- package/dist/neurolink.js +323 -77
- package/dist/providers/amazonBedrock.d.ts +10 -0
- package/dist/providers/amazonBedrock.js +94 -39
- package/dist/providers/anthropic.js +55 -7
- package/dist/providers/anthropicBaseProvider.js +1 -1
- package/dist/providers/azureOpenai.js +66 -17
- package/dist/providers/cloudflare.d.ts +35 -0
- package/dist/providers/cloudflare.js +173 -0
- package/dist/providers/cohere.d.ts +52 -0
- package/dist/providers/cohere.js +252 -0
- package/dist/providers/deepseek.js +72 -17
- package/dist/providers/fireworks.d.ts +33 -0
- package/dist/providers/fireworks.js +163 -0
- package/dist/providers/googleAiStudio.js +126 -10
- package/dist/providers/googleNativeGemini3.d.ts +26 -6
- package/dist/providers/googleNativeGemini3.js +276 -29
- package/dist/providers/googleVertex.js +639 -181
- package/dist/providers/groq.d.ts +33 -0
- package/dist/providers/groq.js +180 -0
- package/dist/providers/huggingFace.js +9 -8
- package/dist/providers/ideogram.d.ts +34 -0
- package/dist/providers/ideogram.js +183 -0
- package/dist/providers/index.d.ts +13 -0
- package/dist/providers/index.js +13 -0
- package/dist/providers/jina.d.ts +59 -0
- package/dist/providers/jina.js +217 -0
- package/dist/providers/llamaCpp.js +14 -46
- package/dist/providers/lmStudio.js +14 -47
- package/dist/providers/mistral.js +7 -7
- package/dist/providers/nvidiaNim.js +160 -19
- package/dist/providers/ollama.js +7 -7
- package/dist/providers/openAI.d.ts +22 -1
- package/dist/providers/openAI.js +181 -0
- package/dist/providers/openRouter.js +35 -23
- package/dist/providers/openaiCompatible.js +9 -8
- package/dist/providers/perplexity.d.ts +33 -0
- package/dist/providers/perplexity.js +178 -0
- package/dist/providers/recraft.d.ts +34 -0
- package/dist/providers/recraft.js +196 -0
- package/dist/providers/replicate.d.ts +75 -0
- package/dist/providers/replicate.js +402 -0
- package/dist/providers/stability.d.ts +37 -0
- package/dist/providers/stability.js +190 -0
- package/dist/providers/togetherAi.d.ts +33 -0
- package/dist/providers/togetherAi.js +175 -0
- package/dist/providers/voyage.d.ts +47 -0
- package/dist/providers/voyage.js +176 -0
- package/dist/providers/xai.d.ts +33 -0
- package/dist/providers/xai.js +171 -0
- package/dist/telemetry/index.d.ts +1 -1
- package/dist/telemetry/index.js +1 -1
- package/dist/telemetry/tracers.d.ts +19 -0
- package/dist/telemetry/tracers.js +19 -0
- package/dist/telemetry/withSpan.d.ts +35 -0
- package/dist/telemetry/withSpan.js +103 -0
- package/dist/types/avatar.d.ts +143 -0
- package/dist/types/avatar.js +19 -0
- package/dist/types/cli.d.ts +6 -0
- package/dist/types/conversation.d.ts +16 -0
- package/dist/types/generate.d.ts +62 -5
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.js +7 -0
- package/dist/types/middleware.d.ts +27 -0
- package/dist/types/multimodal.d.ts +35 -2
- package/dist/types/music.d.ts +165 -0
- package/dist/types/music.js +20 -0
- package/dist/types/providers.d.ts +144 -1
- package/dist/types/replicate.d.ts +67 -0
- package/dist/types/replicate.js +9 -0
- package/dist/types/safeFetch.d.ts +15 -0
- package/dist/types/safeFetch.js +6 -0
- package/dist/types/stream.d.ts +2 -1
- package/dist/types/tools.d.ts +13 -0
- package/dist/types/video.d.ts +89 -0
- package/dist/types/video.js +14 -0
- package/dist/utils/avatarProcessor.d.ts +68 -0
- package/dist/utils/avatarProcessor.js +171 -0
- package/dist/utils/cloneOptions.d.ts +36 -0
- package/dist/utils/cloneOptions.js +61 -0
- package/dist/utils/lifecycleCallbacks.d.ts +51 -8
- package/dist/utils/lifecycleCallbacks.js +82 -26
- package/dist/utils/lifecycleTimeout.d.ts +25 -0
- package/dist/utils/lifecycleTimeout.js +38 -0
- package/dist/utils/logSanitize.d.ts +49 -0
- package/dist/utils/logSanitize.js +169 -0
- package/dist/utils/loggingFetch.d.ts +29 -0
- package/dist/utils/loggingFetch.js +59 -0
- package/dist/utils/messageBuilder.js +43 -25
- package/dist/utils/modelChoices.js +236 -3
- package/dist/utils/musicProcessor.d.ts +67 -0
- package/dist/utils/musicProcessor.js +188 -0
- package/dist/utils/optionsConversion.js +3 -2
- package/dist/utils/parameterValidation.js +14 -4
- package/dist/utils/pricing.js +193 -0
- package/dist/utils/providerConfig.d.ts +55 -0
- package/dist/utils/providerConfig.js +224 -0
- package/dist/utils/safeFetch.d.ts +26 -0
- package/dist/utils/safeFetch.js +82 -0
- package/dist/utils/sizeGuard.d.ts +34 -0
- package/dist/utils/sizeGuard.js +44 -0
- package/dist/utils/ssrfGuard.d.ts +52 -0
- package/dist/utils/ssrfGuard.js +410 -0
- package/dist/utils/videoProcessor.d.ts +60 -0
- package/dist/utils/videoProcessor.js +200 -0
- package/dist/voice/providers/FishAudioTTS.d.ts +27 -0
- package/dist/voice/providers/FishAudioTTS.js +182 -0
- package/dist/workflow/core/ensembleExecutor.js +26 -9
- package/package.json +32 -5
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Video Generation Processing Utility
|
|
3
|
+
*
|
|
4
|
+
* Central registry + dispatch for video-generation handlers across
|
|
5
|
+
* providers (Vertex Veo, Kling, Runway, Replicate-hosted models, etc.).
|
|
6
|
+
*
|
|
7
|
+
* Mirrors the static-handler-registry pattern established by
|
|
8
|
+
* `TTSProcessor` (`utils/ttsProcessor.ts`) and `STTProcessor`
|
|
9
|
+
* (`utils/sttProcessor.ts`).
|
|
10
|
+
*
|
|
11
|
+
* @module utils/videoProcessor
|
|
12
|
+
*/
|
|
13
|
+
import { ErrorCategory, ErrorSeverity } from "../constants/enums.js";
|
|
14
|
+
import { VIDEO_ERROR_CODES } from "../constants/videoErrors.js";
|
|
15
|
+
import { SpanSerializer, SpanStatus, SpanType, getMetricsAggregator, } from "../observability/index.js";
|
|
16
|
+
import { logger } from "./logger.js";
|
|
17
|
+
// VideoError is canonical in vertexVideoHandler.ts (existing). Re-export
|
|
18
|
+
// here so consumers of `VideoProcessor` can import the typed error from
|
|
19
|
+
// the same module. Both throws and instanceof checks resolve to the same
|
|
20
|
+
// class.
|
|
21
|
+
import { VideoError } from "../adapters/video/vertexVideoHandler.js";
|
|
22
|
+
export { VideoError, VIDEO_ERROR_CODES };
|
|
23
|
+
/**
|
|
24
|
+
* Static processor managing the video handler registry.
|
|
25
|
+
*
|
|
26
|
+
* Handlers register themselves during `ProviderRegistry._doRegister()`
|
|
27
|
+
* via `VideoProcessor.registerHandler(name, instance)`. Lookups are
|
|
28
|
+
* O(1) on a normalised lower-case provider key.
|
|
29
|
+
*/
|
|
30
|
+
export class VideoProcessor {
|
|
31
|
+
static handlers = new Map();
|
|
32
|
+
/**
|
|
33
|
+
* Register a video handler for a specific provider.
|
|
34
|
+
*/
|
|
35
|
+
static registerHandler(providerName, handler) {
|
|
36
|
+
if (!providerName) {
|
|
37
|
+
throw new Error("Provider name is required");
|
|
38
|
+
}
|
|
39
|
+
if (!handler) {
|
|
40
|
+
throw new Error("Handler is required");
|
|
41
|
+
}
|
|
42
|
+
const key = providerName.toLowerCase();
|
|
43
|
+
if (this.handlers.has(key)) {
|
|
44
|
+
logger.warn(`[VideoProcessor] Overwriting existing handler for provider: ${key}`);
|
|
45
|
+
}
|
|
46
|
+
this.handlers.set(key, handler);
|
|
47
|
+
logger.debug(`[VideoProcessor] Registered video handler: ${key}`);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Check if a provider has a registered video handler.
|
|
51
|
+
*/
|
|
52
|
+
static supports(providerName) {
|
|
53
|
+
if (!providerName) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
return this.handlers.has(providerName.toLowerCase());
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* List the names of all registered providers.
|
|
60
|
+
*/
|
|
61
|
+
static listProviders() {
|
|
62
|
+
return Array.from(this.handlers.keys());
|
|
63
|
+
}
|
|
64
|
+
static getHandler(providerName) {
|
|
65
|
+
return this.handlers.get(providerName.toLowerCase());
|
|
66
|
+
}
|
|
67
|
+
static buildSpanAttributes(provider, options) {
|
|
68
|
+
return {
|
|
69
|
+
"video.operation": "generate",
|
|
70
|
+
"video.provider": provider,
|
|
71
|
+
"video.resolution": options.resolution,
|
|
72
|
+
"video.duration": options.length,
|
|
73
|
+
"video.aspect_ratio": options.aspectRatio,
|
|
74
|
+
"video.audio": options.audio,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Generate a single video clip via the registered handler.
|
|
79
|
+
*
|
|
80
|
+
* @param provider - Registered provider name (e.g. "vertex", "kling")
|
|
81
|
+
* @param image - Source image buffer
|
|
82
|
+
* @param prompt - Text prompt describing the desired motion / content
|
|
83
|
+
* @param options - Resolution / length / aspect-ratio / audio options
|
|
84
|
+
* @param region - Optional region override (Vertex location, etc.)
|
|
85
|
+
* @throws VideoError on registry miss, handler-not-configured, or
|
|
86
|
+
* generation failure
|
|
87
|
+
*/
|
|
88
|
+
static async generate(provider, image, prompt, options, region) {
|
|
89
|
+
const span = SpanSerializer.createSpan(SpanType.MEDIA_GENERATION, "video.generate", this.buildSpanAttributes(provider, options));
|
|
90
|
+
try {
|
|
91
|
+
const handler = this.getHandler(provider);
|
|
92
|
+
if (!handler) {
|
|
93
|
+
throw new VideoError({
|
|
94
|
+
code: VIDEO_ERROR_CODES.PROVIDER_NOT_SUPPORTED,
|
|
95
|
+
message: `Video provider "${provider}" is not registered. Available: ${this.listProviders().join(", ")}`,
|
|
96
|
+
category: ErrorCategory.CONFIGURATION,
|
|
97
|
+
severity: ErrorSeverity.HIGH,
|
|
98
|
+
retriable: false,
|
|
99
|
+
context: { provider, available: this.listProviders() },
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
if (!handler.isConfigured()) {
|
|
103
|
+
throw new VideoError({
|
|
104
|
+
code: VIDEO_ERROR_CODES.PROVIDER_NOT_CONFIGURED,
|
|
105
|
+
message: `Video provider "${provider}" is not configured. Set the required credentials.`,
|
|
106
|
+
category: ErrorCategory.CONFIGURATION,
|
|
107
|
+
severity: ErrorSeverity.HIGH,
|
|
108
|
+
retriable: false,
|
|
109
|
+
context: { provider },
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
logger.debug(`[VideoProcessor] Starting video generation with provider: ${provider}`);
|
|
113
|
+
const result = await handler.generate(image, prompt, options, region);
|
|
114
|
+
const ended = SpanSerializer.endSpan(span, SpanStatus.OK);
|
|
115
|
+
getMetricsAggregator().recordSpan(ended);
|
|
116
|
+
logger.info(`[VideoProcessor] Generated ${result.data.length} bytes (${provider})`);
|
|
117
|
+
return result;
|
|
118
|
+
}
|
|
119
|
+
catch (err) {
|
|
120
|
+
const ended = SpanSerializer.endSpan(span, SpanStatus.ERROR, err instanceof Error ? err.message : String(err));
|
|
121
|
+
getMetricsAggregator().recordSpan(ended);
|
|
122
|
+
if (err instanceof VideoError) {
|
|
123
|
+
throw err;
|
|
124
|
+
}
|
|
125
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
126
|
+
throw new VideoError({
|
|
127
|
+
code: VIDEO_ERROR_CODES.GENERATION_FAILED,
|
|
128
|
+
message: `Video generation failed for provider "${provider}": ${message}`,
|
|
129
|
+
category: ErrorCategory.EXECUTION,
|
|
130
|
+
severity: ErrorSeverity.HIGH,
|
|
131
|
+
retriable: true,
|
|
132
|
+
context: { provider, options, region },
|
|
133
|
+
originalError: err instanceof Error ? err : undefined,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Generate a transition clip via the registered handler (Director Mode).
|
|
139
|
+
*
|
|
140
|
+
* Providers without first-and-last-frame interpolation surface a typed
|
|
141
|
+
* `TRANSITION_NOT_SUPPORTED` error here; callers should fall back to
|
|
142
|
+
* generating a regular clip with a transition prompt.
|
|
143
|
+
*/
|
|
144
|
+
static async generateTransition(provider, firstFrame, lastFrame, prompt, options, region) {
|
|
145
|
+
const handler = this.getHandler(provider);
|
|
146
|
+
if (!handler) {
|
|
147
|
+
throw new VideoError({
|
|
148
|
+
code: VIDEO_ERROR_CODES.PROVIDER_NOT_SUPPORTED,
|
|
149
|
+
message: `Video provider "${provider}" is not registered for transitions`,
|
|
150
|
+
category: ErrorCategory.CONFIGURATION,
|
|
151
|
+
severity: ErrorSeverity.HIGH,
|
|
152
|
+
retriable: false,
|
|
153
|
+
context: { provider, available: this.listProviders() },
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
if (!handler.generateTransition) {
|
|
157
|
+
throw new VideoError({
|
|
158
|
+
code: VIDEO_ERROR_CODES.TRANSITION_NOT_SUPPORTED,
|
|
159
|
+
message: `Video provider "${provider}" does not support transition clips`,
|
|
160
|
+
category: ErrorCategory.VALIDATION,
|
|
161
|
+
severity: ErrorSeverity.MEDIUM,
|
|
162
|
+
retriable: false,
|
|
163
|
+
context: { provider },
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
if (!handler.isConfigured()) {
|
|
167
|
+
throw new VideoError({
|
|
168
|
+
code: VIDEO_ERROR_CODES.PROVIDER_NOT_CONFIGURED,
|
|
169
|
+
message: `Video provider "${provider}" is not configured`,
|
|
170
|
+
category: ErrorCategory.CONFIGURATION,
|
|
171
|
+
severity: ErrorSeverity.HIGH,
|
|
172
|
+
retriable: false,
|
|
173
|
+
context: { provider },
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
try {
|
|
177
|
+
return await handler.generateTransition(firstFrame, lastFrame, prompt, options, region);
|
|
178
|
+
}
|
|
179
|
+
catch (err) {
|
|
180
|
+
if (err instanceof VideoError) {
|
|
181
|
+
throw err;
|
|
182
|
+
}
|
|
183
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
184
|
+
throw new VideoError({
|
|
185
|
+
code: VIDEO_ERROR_CODES.DIRECTOR_TRANSITION_FAILED,
|
|
186
|
+
message: `Video transition generation failed for provider "${provider}": ${message}`,
|
|
187
|
+
category: ErrorCategory.EXECUTION,
|
|
188
|
+
severity: ErrorSeverity.MEDIUM,
|
|
189
|
+
retriable: true,
|
|
190
|
+
context: {
|
|
191
|
+
provider,
|
|
192
|
+
firstFrameSize: firstFrame.length,
|
|
193
|
+
lastFrameSize: lastFrame.length,
|
|
194
|
+
durationSeconds: options?.durationSeconds,
|
|
195
|
+
},
|
|
196
|
+
originalError: err instanceof Error ? err : undefined,
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
//# sourceMappingURL=videoProcessor.js.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fish Audio TTS Handler
|
|
3
|
+
*
|
|
4
|
+
* Implementation of TTS using Fish Audio API. Lower-cost alternative to
|
|
5
|
+
* ElevenLabs with strong multilingual support and 15s voice cloning.
|
|
6
|
+
*
|
|
7
|
+
* @module voice/providers/FishAudioTTS
|
|
8
|
+
* @see https://docs.fish.audio/text-to-speech/text-to-speech
|
|
9
|
+
*/
|
|
10
|
+
import type { TTSHandler, TTSOptions, TTSResult } from "../../types/index.js";
|
|
11
|
+
/**
|
|
12
|
+
* Fish Audio Text-to-Speech Handler.
|
|
13
|
+
*
|
|
14
|
+
* Auth: `Authorization: Bearer ${FISH_AUDIO_API_KEY}`.
|
|
15
|
+
* Models: speech-1.5 (standard), speech-1.6, s1 (default; latest).
|
|
16
|
+
*/
|
|
17
|
+
export declare class FishAudioTTS implements TTSHandler {
|
|
18
|
+
readonly maxTextLength = 5000;
|
|
19
|
+
private readonly apiKey;
|
|
20
|
+
private readonly baseUrl;
|
|
21
|
+
constructor(apiKey?: string);
|
|
22
|
+
isConfigured(): boolean;
|
|
23
|
+
synthesize(text: string, options?: TTSOptions): Promise<TTSResult>;
|
|
24
|
+
private mapFormat;
|
|
25
|
+
private effectiveFormat;
|
|
26
|
+
private getSampleRate;
|
|
27
|
+
}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fish Audio TTS Handler
|
|
3
|
+
*
|
|
4
|
+
* Implementation of TTS using Fish Audio API. Lower-cost alternative to
|
|
5
|
+
* ElevenLabs with strong multilingual support and 15s voice cloning.
|
|
6
|
+
*
|
|
7
|
+
* @module voice/providers/FishAudioTTS
|
|
8
|
+
* @see https://docs.fish.audio/text-to-speech/text-to-speech
|
|
9
|
+
*/
|
|
10
|
+
import { ErrorCategory, ErrorSeverity } from "../../constants/enums.js";
|
|
11
|
+
import { logger } from "../../utils/logger.js";
|
|
12
|
+
import { TTS_ERROR_CODES, TTSError } from "../../utils/ttsProcessor.js";
|
|
13
|
+
const DEFAULT_BASE_URL = "https://api.fish.audio";
|
|
14
|
+
const REQUEST_TIMEOUT_MS = 30_000;
|
|
15
|
+
/**
|
|
16
|
+
* Default reference voice — "Energetic Male" by official author `lengyue`,
|
|
17
|
+
* a long-standing public English voice on Fish Audio.
|
|
18
|
+
*
|
|
19
|
+
* @see https://fish.audio (model id 802e3bc2b27e49c2995d23ef70e6ac89)
|
|
20
|
+
*
|
|
21
|
+
* Note: the previous default `fb6c0e1ea91e427fb9a93b9bbf0a1e4d` was
|
|
22
|
+
* removed upstream and started returning 400 "Reference not found".
|
|
23
|
+
*/
|
|
24
|
+
const DEFAULT_REFERENCE_ID = "802e3bc2b27e49c2995d23ef70e6ac89";
|
|
25
|
+
/**
|
|
26
|
+
* Fish Audio Text-to-Speech Handler.
|
|
27
|
+
*
|
|
28
|
+
* Auth: `Authorization: Bearer ${FISH_AUDIO_API_KEY}`.
|
|
29
|
+
* Models: speech-1.5 (standard), speech-1.6, s1 (default; latest).
|
|
30
|
+
*/
|
|
31
|
+
export class FishAudioTTS {
|
|
32
|
+
maxTextLength = 5000;
|
|
33
|
+
apiKey;
|
|
34
|
+
baseUrl;
|
|
35
|
+
constructor(apiKey) {
|
|
36
|
+
const resolved = (apiKey ?? process.env.FISH_AUDIO_API_KEY ?? "").trim();
|
|
37
|
+
this.apiKey = resolved.length > 0 ? resolved : null;
|
|
38
|
+
this.baseUrl = (process.env.FISH_AUDIO_BASE_URL ?? DEFAULT_BASE_URL).replace(/\/$/, "");
|
|
39
|
+
}
|
|
40
|
+
isConfigured() {
|
|
41
|
+
return this.apiKey !== null;
|
|
42
|
+
}
|
|
43
|
+
async synthesize(text, options = {}) {
|
|
44
|
+
if (!this.apiKey) {
|
|
45
|
+
throw new TTSError({
|
|
46
|
+
code: TTS_ERROR_CODES.PROVIDER_NOT_CONFIGURED,
|
|
47
|
+
message: "FISH_AUDIO_API_KEY not configured",
|
|
48
|
+
category: ErrorCategory.CONFIGURATION,
|
|
49
|
+
severity: ErrorSeverity.HIGH,
|
|
50
|
+
retriable: false,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
const startTime = Date.now();
|
|
54
|
+
const referenceId = options.voice ?? DEFAULT_REFERENCE_ID;
|
|
55
|
+
const requestedFormat = options.format ?? "mp3";
|
|
56
|
+
const upstreamFormat = this.mapFormat(requestedFormat);
|
|
57
|
+
const body = {
|
|
58
|
+
text,
|
|
59
|
+
reference_id: referenceId,
|
|
60
|
+
format: upstreamFormat,
|
|
61
|
+
mp3_bitrate: 128,
|
|
62
|
+
chunk_length: 200,
|
|
63
|
+
normalize: true,
|
|
64
|
+
latency: "normal",
|
|
65
|
+
};
|
|
66
|
+
const fishOpts = options;
|
|
67
|
+
if (fishOpts.model) {
|
|
68
|
+
body.model = fishOpts.model;
|
|
69
|
+
}
|
|
70
|
+
if (fishOpts.latency) {
|
|
71
|
+
body.latency = fishOpts.latency;
|
|
72
|
+
}
|
|
73
|
+
if (fishOpts.mp3Bitrate !== undefined) {
|
|
74
|
+
body.mp3_bitrate = fishOpts.mp3Bitrate;
|
|
75
|
+
}
|
|
76
|
+
const controller = new AbortController();
|
|
77
|
+
const timeoutId = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
|
|
78
|
+
let response;
|
|
79
|
+
try {
|
|
80
|
+
response = await fetch(`${this.baseUrl}/v1/tts`, {
|
|
81
|
+
method: "POST",
|
|
82
|
+
headers: {
|
|
83
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
84
|
+
"Content-Type": "application/json",
|
|
85
|
+
},
|
|
86
|
+
body: JSON.stringify(body),
|
|
87
|
+
signal: controller.signal,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
catch (err) {
|
|
91
|
+
if (err instanceof Error && err.name === "AbortError") {
|
|
92
|
+
throw new TTSError({
|
|
93
|
+
code: TTS_ERROR_CODES.SYNTHESIS_FAILED,
|
|
94
|
+
message: `Fish Audio request timed out after ${REQUEST_TIMEOUT_MS / 1000}s`,
|
|
95
|
+
category: ErrorCategory.NETWORK,
|
|
96
|
+
severity: ErrorSeverity.HIGH,
|
|
97
|
+
retriable: true,
|
|
98
|
+
originalError: err,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
throw new TTSError({
|
|
102
|
+
code: TTS_ERROR_CODES.SYNTHESIS_FAILED,
|
|
103
|
+
message: `Fish Audio network error: ${err instanceof Error ? err.message : String(err)}`,
|
|
104
|
+
category: ErrorCategory.NETWORK,
|
|
105
|
+
severity: ErrorSeverity.HIGH,
|
|
106
|
+
retriable: true,
|
|
107
|
+
originalError: err instanceof Error ? err : undefined,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
finally {
|
|
111
|
+
clearTimeout(timeoutId);
|
|
112
|
+
}
|
|
113
|
+
if (!response.ok) {
|
|
114
|
+
const text = await response.text();
|
|
115
|
+
const retriable = response.status === 408 ||
|
|
116
|
+
response.status === 429 ||
|
|
117
|
+
response.status >= 500;
|
|
118
|
+
throw new TTSError({
|
|
119
|
+
code: TTS_ERROR_CODES.SYNTHESIS_FAILED,
|
|
120
|
+
message: `Fish Audio synthesis failed: ${response.status} — ${text}`,
|
|
121
|
+
category: retriable ? ErrorCategory.NETWORK : ErrorCategory.EXECUTION,
|
|
122
|
+
severity: ErrorSeverity.HIGH,
|
|
123
|
+
retriable,
|
|
124
|
+
context: { status: response.status, referenceId, upstreamFormat },
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
128
|
+
const audioBuffer = Buffer.from(arrayBuffer);
|
|
129
|
+
const latency = Date.now() - startTime;
|
|
130
|
+
const effectiveFormat = this.effectiveFormat(upstreamFormat);
|
|
131
|
+
const result = {
|
|
132
|
+
buffer: audioBuffer,
|
|
133
|
+
format: effectiveFormat,
|
|
134
|
+
size: audioBuffer.length,
|
|
135
|
+
voice: referenceId,
|
|
136
|
+
sampleRate: this.getSampleRate(effectiveFormat),
|
|
137
|
+
metadata: {
|
|
138
|
+
latency,
|
|
139
|
+
provider: "fish-audio",
|
|
140
|
+
model: fishOpts.model ?? "s1",
|
|
141
|
+
requestedFormat: options.format,
|
|
142
|
+
upstreamFormat,
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
logger.info(`[FishAudioTTS] Synthesized ${audioBuffer.length} bytes in ${latency}ms`);
|
|
146
|
+
return result;
|
|
147
|
+
}
|
|
148
|
+
mapFormat(format) {
|
|
149
|
+
const supported = {
|
|
150
|
+
mp3: "mp3",
|
|
151
|
+
wav: "wav",
|
|
152
|
+
pcm16: "pcm",
|
|
153
|
+
};
|
|
154
|
+
const mapped = supported[format];
|
|
155
|
+
if (!mapped) {
|
|
156
|
+
logger.warn(`[FishAudioTTS] Unsupported format "${format}" — falling back to "mp3"`);
|
|
157
|
+
return "mp3";
|
|
158
|
+
}
|
|
159
|
+
return mapped;
|
|
160
|
+
}
|
|
161
|
+
effectiveFormat(upstreamFormat) {
|
|
162
|
+
if (upstreamFormat === "mp3") {
|
|
163
|
+
return "mp3";
|
|
164
|
+
}
|
|
165
|
+
if (upstreamFormat === "wav") {
|
|
166
|
+
return "wav";
|
|
167
|
+
}
|
|
168
|
+
if (upstreamFormat === "pcm") {
|
|
169
|
+
return "pcm16";
|
|
170
|
+
}
|
|
171
|
+
return "mp3";
|
|
172
|
+
}
|
|
173
|
+
getSampleRate(format) {
|
|
174
|
+
if (format === "wav") {
|
|
175
|
+
return 44_100;
|
|
176
|
+
}
|
|
177
|
+
if (format === "pcm16") {
|
|
178
|
+
return 44_100;
|
|
179
|
+
}
|
|
180
|
+
return 44_100;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
//# sourceMappingURL=FishAudioTTS.js.map
|
|
@@ -120,15 +120,32 @@ async function executeModel(options, workflowDefaultSystemPrompt) {
|
|
|
120
120
|
// 3. Workflow-level default
|
|
121
121
|
// 4. undefined (provider default)
|
|
122
122
|
const resolvedSystemPrompt = systemPrompt || model.systemPrompt || workflowDefaultSystemPrompt;
|
|
123
|
-
// Execute with timeout
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
123
|
+
// Execute with timeout. Some upstream LLM endpoints (notably Vertex
|
|
124
|
+
// under high parallel load) occasionally respond with an empty
|
|
125
|
+
// assistant message instead of content; retry once before giving up so
|
|
126
|
+
// a transient empty response doesn't cascade into an empty ensemble
|
|
127
|
+
// result that downstream tests + judges have no way to evaluate.
|
|
128
|
+
let result;
|
|
129
|
+
let attempts = 0;
|
|
130
|
+
const MAX_ATTEMPTS = 2;
|
|
131
|
+
/* eslint-disable no-constant-condition */
|
|
132
|
+
while (true) {
|
|
133
|
+
attempts++;
|
|
134
|
+
result = await executeWithTimeout(async () => {
|
|
135
|
+
return await provider.generate({
|
|
136
|
+
prompt,
|
|
137
|
+
systemPrompt: resolvedSystemPrompt,
|
|
138
|
+
temperature: model.temperature,
|
|
139
|
+
maxTokens: model.maxTokens,
|
|
140
|
+
});
|
|
141
|
+
}, timeout, `Model ${model.provider}/${model.model} timed out after ${timeout}ms`);
|
|
142
|
+
const contentLen = result?.content?.length ?? 0;
|
|
143
|
+
if (contentLen > 0 || attempts >= MAX_ATTEMPTS) {
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
logger.warn(`[${functionTag}] Model returned empty content — retrying once`, { provider: model.provider, model: model.model, attempt: attempts });
|
|
147
|
+
}
|
|
148
|
+
/* eslint-enable no-constant-condition */
|
|
132
149
|
const responseTime = Date.now() - startTime;
|
|
133
150
|
logger.debug(`[${functionTag}] Model execution successful`, {
|
|
134
151
|
provider: model.provider,
|
|
@@ -10,6 +10,31 @@
|
|
|
10
10
|
import { logger } from "../../utils/logger.js";
|
|
11
11
|
import { isRecoverableError } from "../../utils/errorHandling.js";
|
|
12
12
|
import { fireOnErrorOnce } from "../../utils/lifecycleCallbacks.js";
|
|
13
|
+
/**
|
|
14
|
+
* Normalize a thrown value to an `Error` while preserving structured
|
|
15
|
+
* fields (`code`, `status`, `statusCode`, `retryAfter`, `details`,
|
|
16
|
+
* `cause`, etc.) that downstream retry logic and SDK callers depend on.
|
|
17
|
+
*
|
|
18
|
+
* Previously the lifecycle middleware did
|
|
19
|
+
* `error instanceof Error ? error : new Error(String(error))`, which
|
|
20
|
+
* silently dropped every custom property on non-Error throws — so a
|
|
21
|
+
* provider's `{ code: "RATE_LIMITED", retryAfter: 30 }` rejection
|
|
22
|
+
* surfaced to consumers as a bare `Error("[object Object]")`.
|
|
23
|
+
*/
|
|
24
|
+
function normalizeToError(error) {
|
|
25
|
+
if (error instanceof Error) {
|
|
26
|
+
return error;
|
|
27
|
+
}
|
|
28
|
+
if (typeof error === "object" && error !== null) {
|
|
29
|
+
const obj = error;
|
|
30
|
+
const msg = typeof obj.message === "string" ? obj.message : String(error);
|
|
31
|
+
// Object.assign keeps Error's prototype chain (including the
|
|
32
|
+
// captured stack from this synthetic Error's construction) while
|
|
33
|
+
// copying enumerable fields from the original throw.
|
|
34
|
+
return Object.assign(new Error(msg), obj);
|
|
35
|
+
}
|
|
36
|
+
return new Error(String(error));
|
|
37
|
+
}
|
|
13
38
|
export function createLifecycleMiddleware(config = {}) {
|
|
14
39
|
const metadata = {
|
|
15
40
|
id: "lifecycle",
|
|
@@ -51,13 +76,18 @@ export function createLifecycleMiddleware(config = {}) {
|
|
|
51
76
|
return result;
|
|
52
77
|
}
|
|
53
78
|
catch (error) {
|
|
54
|
-
const err =
|
|
55
|
-
fireOnErrorOnce
|
|
79
|
+
const err = normalizeToError(error);
|
|
80
|
+
// fireOnErrorOnce stamps a Symbol on `err` so the SDK-level catch
|
|
81
|
+
// in neurolink.ts (and baseProvider.handleProviderError) skips
|
|
82
|
+
// its own onError fire for the same logical failure.
|
|
83
|
+
fireOnErrorOnce(config.onError, err, {
|
|
56
84
|
error: err,
|
|
57
85
|
duration: Date.now() - startTime,
|
|
58
86
|
recoverable: isRecoverableError(err),
|
|
59
87
|
});
|
|
60
|
-
|
|
88
|
+
// Rethrow the normalized err (not the raw `error`) so the
|
|
89
|
+
// fired-mark and any preserved structured fields propagate.
|
|
90
|
+
throw err;
|
|
61
91
|
}
|
|
62
92
|
},
|
|
63
93
|
wrapStream: async ({ doStream, }) => {
|
|
@@ -93,13 +123,13 @@ export function createLifecycleMiddleware(config = {}) {
|
|
|
93
123
|
controller.enqueue(chunk);
|
|
94
124
|
}
|
|
95
125
|
catch (error) {
|
|
96
|
-
const err =
|
|
97
|
-
fireOnErrorOnce(config.onError,
|
|
126
|
+
const err = normalizeToError(error);
|
|
127
|
+
fireOnErrorOnce(config.onError, err, {
|
|
98
128
|
error: err,
|
|
99
129
|
duration: Date.now() - startTime,
|
|
100
130
|
recoverable: isRecoverableError(err),
|
|
101
131
|
});
|
|
102
|
-
throw
|
|
132
|
+
throw err;
|
|
103
133
|
}
|
|
104
134
|
},
|
|
105
135
|
flush() {
|
|
@@ -125,13 +155,13 @@ export function createLifecycleMiddleware(config = {}) {
|
|
|
125
155
|
};
|
|
126
156
|
}
|
|
127
157
|
catch (error) {
|
|
128
|
-
const err =
|
|
129
|
-
fireOnErrorOnce(config.onError,
|
|
158
|
+
const err = normalizeToError(error);
|
|
159
|
+
fireOnErrorOnce(config.onError, err, {
|
|
130
160
|
error: err,
|
|
131
161
|
duration: Date.now() - startTime,
|
|
132
162
|
recoverable: isRecoverableError(err),
|
|
133
163
|
});
|
|
134
|
-
throw
|
|
164
|
+
throw err;
|
|
135
165
|
}
|
|
136
166
|
},
|
|
137
167
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Music Module — Music Generation Integration for NeuroLink
|
|
3
|
+
*
|
|
4
|
+
* Provides music-generation capability across providers (Beatoven,
|
|
5
|
+
* ElevenLabs Music, Lyria, Replicate-hosted MusicGen / Riffusion).
|
|
6
|
+
*
|
|
7
|
+
* Use `MusicProcessor.generate(provider, options)` to dispatch to the
|
|
8
|
+
* registered handler for `provider`.
|
|
9
|
+
*
|
|
10
|
+
* @module music
|
|
11
|
+
*/
|
|
12
|
+
export { MUSIC_ERROR_CODES, MusicError, MusicProcessor, } from "../utils/musicProcessor.js";
|
|
13
|
+
export { BeatovenMusic, BeatovenMusic as BeatovenMusicHandler, } from "./providers/BeatovenMusic.js";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Music Module — Music Generation Integration for NeuroLink
|
|
3
|
+
*
|
|
4
|
+
* Provides music-generation capability across providers (Beatoven,
|
|
5
|
+
* ElevenLabs Music, Lyria, Replicate-hosted MusicGen / Riffusion).
|
|
6
|
+
*
|
|
7
|
+
* Use `MusicProcessor.generate(provider, options)` to dispatch to the
|
|
8
|
+
* registered handler for `provider`.
|
|
9
|
+
*
|
|
10
|
+
* @module music
|
|
11
|
+
*/
|
|
12
|
+
export { MUSIC_ERROR_CODES, MusicError, MusicProcessor, } from "../utils/musicProcessor.js";
|
|
13
|
+
export { BeatovenMusic, BeatovenMusic as BeatovenMusicHandler, } from "./providers/BeatovenMusic.js";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Beatoven.ai Music Generation Handler
|
|
3
|
+
*
|
|
4
|
+
* Async track-composition API. Submits a compose-track request, polls the
|
|
5
|
+
* task status, and downloads the resulting audio.
|
|
6
|
+
*
|
|
7
|
+
* @module music/providers/BeatovenMusic
|
|
8
|
+
* @see https://www.beatoven.ai/api-docs
|
|
9
|
+
*/
|
|
10
|
+
import type { MusicAudioFormat, MusicHandler, MusicOptions, MusicResult } from "../../types/index.js";
|
|
11
|
+
/**
|
|
12
|
+
* Beatoven.ai Music Generation Handler.
|
|
13
|
+
*
|
|
14
|
+
* Beatoven is a royalty-free music generation API tuned for
|
|
15
|
+
* background / cinematic / brand music. Tracks are composed
|
|
16
|
+
* asynchronously: submit a prompt, poll the task, then download.
|
|
17
|
+
*/
|
|
18
|
+
export declare class BeatovenMusic implements MusicHandler {
|
|
19
|
+
readonly maxDurationSeconds = 300;
|
|
20
|
+
readonly supportedFormats: readonly MusicAudioFormat[];
|
|
21
|
+
readonly supportedGenres: readonly string[];
|
|
22
|
+
private readonly apiKey;
|
|
23
|
+
private readonly baseUrl;
|
|
24
|
+
constructor(apiKey?: string);
|
|
25
|
+
isConfigured(): boolean;
|
|
26
|
+
generate(options: MusicOptions): Promise<MusicResult>;
|
|
27
|
+
private submitCompose;
|
|
28
|
+
private pollUntilComposed;
|
|
29
|
+
private fetchTaskStatus;
|
|
30
|
+
private downloadTrack;
|
|
31
|
+
}
|