@juspay/neurolink 11.26.2 → 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.
Files changed (39) hide show
  1. package/CHANGELOG.md +3 -3
  2. package/dist/adapters/providerImageAdapter.js +20 -0
  3. package/dist/adapters/video/index.d.ts +30 -0
  4. package/dist/adapters/video/index.js +74 -0
  5. package/dist/avatar/index.d.ts +6 -3
  6. package/dist/avatar/index.js +21 -16
  7. package/dist/browser/neurolink.min.js +393 -393
  8. package/dist/cli/factories/commandFactory.d.ts +6 -0
  9. package/dist/cli/factories/commandFactory.js +6 -2
  10. package/dist/constants/contextWindows.d.ts +18 -4
  11. package/dist/constants/contextWindows.js +35 -4
  12. package/dist/core/baseProvider.js +5 -3
  13. package/dist/core/constants.js +59 -1
  14. package/dist/factories/mediaHandlerCatalog.d.ts +18 -0
  15. package/dist/factories/mediaHandlerCatalog.js +65 -0
  16. package/dist/factories/providerRegistry.js +50 -207
  17. package/dist/index.d.ts +1 -4
  18. package/dist/index.js +2 -5
  19. package/dist/models/anthropicModels.d.ts +3 -6
  20. package/dist/models/anthropicModels.js +97 -123
  21. package/dist/models/manifestRegistry.d.ts +9 -0
  22. package/dist/models/manifestRegistry.js +23 -0
  23. package/dist/models/manifests/anthropic.js +5 -3
  24. package/dist/models/manifests/azure.js +6 -1
  25. package/dist/models/modelRegistry.d.ts +22 -2
  26. package/dist/models/modelRegistry.js +143 -8
  27. package/dist/music/index.d.ts +6 -3
  28. package/dist/music/index.js +22 -21
  29. package/dist/neurolink.js +12 -0
  30. package/dist/providers/amazonSagemaker.d.ts +1 -1
  31. package/dist/providers/sagemaker/language-model.d.ts +2 -2
  32. package/dist/types/index.d.ts +1 -0
  33. package/dist/types/index.js +1 -0
  34. package/dist/types/mediaCatalog.d.ts +12 -0
  35. package/dist/types/mediaCatalog.js +7 -0
  36. package/dist/utils/pricing.js +51 -0
  37. package/dist/voice/index.d.ts +7 -3
  38. package/dist/voice/index.js +50 -40
  39. package/package.json +2 -1
@@ -300,6 +300,7 @@ export declare class CLICommandFactory {
300
300
  };
301
301
  videoProvider: {
302
302
  type: "string";
303
+ choices: string[];
303
304
  description: string;
304
305
  };
305
306
  videoOutput: {
@@ -328,6 +329,7 @@ export declare class CLICommandFactory {
328
329
  };
329
330
  avatarProvider: {
330
331
  type: "string";
332
+ choices: string[];
331
333
  description: string;
332
334
  };
333
335
  avatarImage: {
@@ -362,6 +364,7 @@ export declare class CLICommandFactory {
362
364
  };
363
365
  musicProvider: {
364
366
  type: "string";
367
+ choices: string[];
365
368
  description: string;
366
369
  };
367
370
  musicDuration: {
@@ -1190,6 +1193,7 @@ export declare const commonOptions: {
1190
1193
  };
1191
1194
  videoProvider: {
1192
1195
  type: "string";
1196
+ choices: string[];
1193
1197
  description: string;
1194
1198
  };
1195
1199
  videoOutput: {
@@ -1218,6 +1222,7 @@ export declare const commonOptions: {
1218
1222
  };
1219
1223
  avatarProvider: {
1220
1224
  type: "string";
1225
+ choices: string[];
1221
1226
  description: string;
1222
1227
  };
1223
1228
  avatarImage: {
@@ -1252,6 +1257,7 @@ export declare const commonOptions: {
1252
1257
  };
1253
1258
  musicProvider: {
1254
1259
  type: "string";
1260
+ choices: string[];
1255
1261
  description: string;
1256
1262
  };
1257
1263
  musicDuration: {
@@ -3,6 +3,7 @@ import path from "node:path";
3
3
  import chalk from "chalk";
4
4
  import ora from "ora";
5
5
  import { ModelResolver } from "../../models/modelResolver.js";
6
+ import { providerChoicesFor } from "../../factories/mediaHandlerCatalog.js";
6
7
  import { globalSession } from "../../session/globalSessionState.js";
7
8
  // Use TokenUsage from standard types - no local interface needed
8
9
  import { ContextFactory, } from "../../types/index.js";
@@ -333,7 +334,7 @@ export class CLICommandFactory {
333
334
  },
334
335
  ttsProvider: {
335
336
  type: "string",
336
- choices: ["google-ai", "vertex", "openai-tts", "elevenlabs", "azure-tts"],
337
+ choices: providerChoicesFor("tts"),
337
338
  description: "TTS provider (overrides --provider for speech synthesis)",
338
339
  },
339
340
  ttsFormat: {
@@ -381,7 +382,7 @@ export class CLICommandFactory {
381
382
  },
382
383
  sttProvider: {
383
384
  type: "string",
384
- choices: ["whisper", "deepgram", "google-stt", "azure-stt"],
385
+ choices: providerChoicesFor("stt"),
385
386
  description: "STT provider to use",
386
387
  },
387
388
  sttLanguage: {
@@ -401,6 +402,7 @@ export class CLICommandFactory {
401
402
  },
402
403
  videoProvider: {
403
404
  type: "string",
405
+ choices: providerChoicesFor("video"),
404
406
  description: "Video provider override (e.g., 'vertex' (default), 'kling', 'runway', 'replicate')",
405
407
  },
406
408
  videoOutput: {
@@ -430,6 +432,7 @@ export class CLICommandFactory {
430
432
  // Avatar Generation options (D-ID, HeyGen, MuseTalk via Replicate)
431
433
  avatarProvider: {
432
434
  type: "string",
435
+ choices: providerChoicesFor("avatar"),
433
436
  description: "Avatar provider (e.g., 'd-id' (default), 'heygen', 'replicate', 'musetalk')",
434
437
  },
435
438
  avatarImage: {
@@ -465,6 +468,7 @@ export class CLICommandFactory {
465
468
  // Music Generation options (Beatoven, ElevenLabs, Lyria, MusicGen via Replicate)
466
469
  musicProvider: {
467
470
  type: "string",
471
+ choices: providerChoicesFor("music"),
468
472
  description: "Music provider (e.g., 'beatoven' (default), 'elevenlabs-music', 'lyria', 'replicate', 'musicgen')",
469
473
  },
470
474
  musicDuration: {
@@ -63,10 +63,24 @@ export declare function clearRuntimeOutputCeilings(): void;
63
63
  * 0.5 Runtime-discovered windows (registerRuntimeContextWindow) — real
64
64
  * per-model limits fetched from the serving infrastructure (LiteLLM
65
65
  * `/model/info`)
66
- * 1. Exact model match under provider in static registry
67
- * 2. Prefix match under provider in static registry
68
- * 3. Provider's _default in static registry
69
- * 4. Global DEFAULT_CONTEXT_WINDOW
66
+ * 1. Manifest exact/alias match ONLY (resolveManifestEntryStrict no prefix, see
67
+ * src/lib/models/manifestRegistry.ts) the emerging single source of
68
+ * truth for per-model metadata. Deliberately consulted for a REAL match
69
+ * only (never the manifest's synthesized/generic default): most provider
70
+ * manifests are still "minimal" stubs holding nothing but a provider-wide
71
+ * default (e.g. vertex.ts, together-ai.ts) and none of the per-model
72
+ * overrides — including Vertex's Claude "claude-" prefix catch-all below,
73
+ * which exists specifically to stop an unlisted Claude-on-Vertex model
74
+ * from inheriting Gemini's 1,048,576 default — that still live only in
75
+ * MODEL_CONTEXT_WINDOWS. Falling back to a manifest-wide default here
76
+ * would silently drop that coverage. When a manifest DOES carry a real
77
+ * entry for this model, it wins even if it disagrees with the legacy
78
+ * table (e.g. Mistral's manifest supersedes the coarser, older
79
+ * MODEL_CONTEXT_WINDOWS.mistral values).
80
+ * 2. Exact model match under provider in static registry
81
+ * 3. Prefix match under provider in static registry
82
+ * 4. Provider's _default in static registry
83
+ * 5. Global DEFAULT_CONTEXT_WINDOW
70
84
  */
71
85
  export declare function getContextWindowSize(provider: string, model?: string): number;
72
86
  /**
@@ -12,6 +12,7 @@
12
12
  */
13
13
  import { DynamicModelProvider } from "../core/dynamicModels.js";
14
14
  import { logger } from "../utils/logger.js";
15
+ import { resolveManifestEntryStrict } from "../models/manifestRegistry.js";
15
16
  /** Default context window when provider/model is unknown */
16
17
  export const DEFAULT_CONTEXT_WINDOW = 128_000;
17
18
  /** Maximum output reserve when maxTokens not specified */
@@ -488,10 +489,24 @@ export function clearRuntimeOutputCeilings() {
488
489
  * 0.5 Runtime-discovered windows (registerRuntimeContextWindow) — real
489
490
  * per-model limits fetched from the serving infrastructure (LiteLLM
490
491
  * `/model/info`)
491
- * 1. Exact model match under provider in static registry
492
- * 2. Prefix match under provider in static registry
493
- * 3. Provider's _default in static registry
494
- * 4. Global DEFAULT_CONTEXT_WINDOW
492
+ * 1. Manifest exact/alias match ONLY (resolveManifestEntryStrict no prefix, see
493
+ * src/lib/models/manifestRegistry.ts) the emerging single source of
494
+ * truth for per-model metadata. Deliberately consulted for a REAL match
495
+ * only (never the manifest's synthesized/generic default): most provider
496
+ * manifests are still "minimal" stubs holding nothing but a provider-wide
497
+ * default (e.g. vertex.ts, together-ai.ts) and none of the per-model
498
+ * overrides — including Vertex's Claude "claude-" prefix catch-all below,
499
+ * which exists specifically to stop an unlisted Claude-on-Vertex model
500
+ * from inheriting Gemini's 1,048,576 default — that still live only in
501
+ * MODEL_CONTEXT_WINDOWS. Falling back to a manifest-wide default here
502
+ * would silently drop that coverage. When a manifest DOES carry a real
503
+ * entry for this model, it wins even if it disagrees with the legacy
504
+ * table (e.g. Mistral's manifest supersedes the coarser, older
505
+ * MODEL_CONTEXT_WINDOWS.mistral values).
506
+ * 2. Exact model match under provider in static registry
507
+ * 3. Prefix match under provider in static registry
508
+ * 4. Provider's _default in static registry
509
+ * 5. Global DEFAULT_CONTEXT_WINDOW
495
510
  */
496
511
  export function getContextWindowSize(provider, model) {
497
512
  // Step 0: Check dynamic model registry first.
@@ -521,6 +536,22 @@ export function getContextWindowSize(provider, model) {
521
536
  // Static fallback chain — normalize aliases first so "lmstudio" / "llama.cpp" /
522
537
  // "nvidianim" find their canonical entries instead of falling back to default.
523
538
  const canonical = normalizeProviderForLookup(provider);
539
+ // Step 1: Manifest real-entry lookup (exact id, alias, or longest-prefix —
540
+ // see resolveManifestEntryStrict's docblock). Tries the alias-normalized
541
+ // provider key first, then the raw provider string, mirroring the
542
+ // `MODEL_CONTEXT_WINDOWS[canonical] ?? MODEL_CONTEXT_WINDOWS[provider]`
543
+ // double-lookup below — MANIFEST_REGISTRY is keyed by the same hyphenated
544
+ // AIProviderName forms (e.g. "together-ai") that normalizeProviderForLookup
545
+ // strips and PROVIDER_ALIAS_MAP doesn't cover, so callers passing the raw
546
+ // enum value still resolve. Only a genuine match short-circuits; a miss
547
+ // falls straight through to the untouched legacy cascade below.
548
+ if (model) {
549
+ const manifestEntry = resolveManifestEntryStrict(canonical, model) ??
550
+ resolveManifestEntryStrict(provider, model);
551
+ if (manifestEntry) {
552
+ return manifestEntry.contextWindow;
553
+ }
554
+ }
524
555
  const providerWindows = MODEL_CONTEXT_WINDOWS[canonical] ?? MODEL_CONTEXT_WINDOWS[provider];
525
556
  if (!providerWindows) {
526
557
  return DEFAULT_CONTEXT_WINDOW;
@@ -1,5 +1,6 @@
1
1
  import { context, SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
2
2
  import { directAgentTools } from "../agent/directTools.js";
3
+ import { defaultProviderFor } from "../factories/mediaHandlerCatalog.js";
3
4
  import { isImageGenerationModel } from "./constants.js";
4
5
  import { MiddlewareFactory } from "../middleware/factory.js";
5
6
  import { modelSupports } from "../models/modelRegistry.js";
@@ -2139,9 +2140,10 @@ export class BaseProvider {
2139
2140
  }
2140
2141
  // Get prompt text
2141
2142
  const prompt = options.prompt || options.input?.text || "";
2142
- // Honor output.video.provider — when omitted, fall back to "vertex"
2143
- // for backward compatibility with the original implementation.
2144
- const requestedProvider = options.output?.video?.provider ?? "vertex";
2143
+ // Honor output.video.provider — when omitted, fall back to the
2144
+ // catalog-derived default (currently "vertex") for backward
2145
+ // compatibility with the original implementation.
2146
+ const requestedProvider = options.output?.video?.provider ?? defaultProviderFor("video");
2145
2147
  if (!VideoProcessor.supports(requestedProvider)) {
2146
2148
  throw new VideoError({
2147
2149
  code: VIDEO_ERROR_CODES.PROVIDER_NOT_SUPPORTED,
@@ -2,6 +2,15 @@
2
2
  * Central configuration constants for NeuroLink
3
3
  * Single source of truth for all default values
4
4
  */
5
+ import { anthropicManifest } from "../models/manifests/anthropic.js";
6
+ import { openaiManifest } from "../models/manifests/openai.js";
7
+ import { googleAiManifest } from "../models/manifests/google-ai.js";
8
+ import { vertexManifest } from "../models/manifests/vertex.js";
9
+ import { bedrockManifest } from "../models/manifests/bedrock.js";
10
+ import { azureManifest } from "../models/manifests/azure.js";
11
+ import { mistralManifest } from "../models/manifests/mistral.js";
12
+ import { ollamaManifest } from "../models/manifests/ollama.js";
13
+ import { litellmManifest } from "../models/manifests/litellm.js";
5
14
  // Image Generation Model Identifiers
6
15
  // Used to detect if a model is an image generation model (not text generation).
7
16
  // `isImageGenerationModel(name)` (below) does boundary-aware matching:
@@ -167,34 +176,83 @@ export const PROVIDER_CONFIG = {
167
176
  temperature: 0.4,
168
177
  },
169
178
  };
170
- // Provider-specific maxTokens limits
179
+ /**
180
+ * Per-model output-token overrides for a manifest, keyed by canonical model
181
+ * id. The manifest's synthetic "_default" entry is excluded — the
182
+ * provider-level `default` in PROVIDER_MAX_TOKENS already carries that role,
183
+ * and is left as the hand-authored value below rather than replaced with
184
+ * this data (a provider's `_default` entry, when present, is a minimal
185
+ * catch-all sized for an unlisted/gateway model id, not a considered
186
+ * provider-wide ceiling).
187
+ */
188
+ function maxTokensOverridesFrom(manifest) {
189
+ const overrides = {};
190
+ for (const [id, entry] of Object.entries(manifest.models)) {
191
+ if (id === "_default") {
192
+ continue;
193
+ }
194
+ overrides[id] = entry.maxOutputTokens;
195
+ }
196
+ return overrides;
197
+ }
198
+ // Provider-specific maxTokens limits. Each provider's `default` is the
199
+ // original hand-authored ceiling (unchanged); per-model keys are generated
200
+ // from that provider's manifest (src/lib/models/manifests/) so
201
+ // getSafeMaxTokens()'s existing per-model lookup (tokenLimits.ts) actually
202
+ // has data to find instead of always falling through to the coarse
203
+ // `default`. This resolves the historical disagreement between
204
+ // getSafeMaxTokens("anthropic", "claude-opus-4-6") (used to return the flat
205
+ // 64000) and resolveClaudeMaxTokens("claude-opus-4-6") (tokenLimits.ts's
206
+ // regex ladder, correctly 32000 for the Opus family) — the manifest's own
207
+ // per-model maxOutputTokens now wins for every listed model, on every
208
+ // provider below, not just Anthropic.
209
+ //
210
+ // Manifests are imported directly from src/lib/models/manifests/ rather
211
+ // than through manifestRegistry.ts's aggregator: manifestRegistry.ts
212
+ // imports PROVIDER_MAX_TOKENS from this file (to size the synthetic
213
+ // `_default` entry for manifests that don't declare their own), so
214
+ // importing the aggregator back here would form a constants.ts <->
215
+ // manifestRegistry.ts import cycle whose safety depends on which module a
216
+ // given entrypoint happens to reach first — an ES module TDZ hazard, not
217
+ // something a type-checker catches. The individual manifest files have no
218
+ // dependency on this module (only on the ProviderModelManifest type), so
219
+ // reaching past the aggregator avoids the cycle entirely.
171
220
  export const PROVIDER_MAX_TOKENS = {
172
221
  anthropic: {
173
222
  default: 64000,
223
+ ...maxTokensOverridesFrom(anthropicManifest),
174
224
  },
175
225
  openai: {
176
226
  default: 128000,
227
+ ...maxTokensOverridesFrom(openaiManifest),
177
228
  },
178
229
  "google-ai": {
179
230
  default: 64000,
231
+ ...maxTokensOverridesFrom(googleAiManifest),
180
232
  },
181
233
  vertex: {
182
234
  default: 64000,
235
+ ...maxTokensOverridesFrom(vertexManifest),
183
236
  },
184
237
  bedrock: {
185
238
  default: 64000,
239
+ ...maxTokensOverridesFrom(bedrockManifest),
186
240
  },
187
241
  azure: {
188
242
  default: 128000,
243
+ ...maxTokensOverridesFrom(azureManifest),
189
244
  },
190
245
  mistral: {
191
246
  default: 128000,
247
+ ...maxTokensOverridesFrom(mistralManifest),
192
248
  },
193
249
  ollama: {
194
250
  default: 64000,
251
+ ...maxTokensOverridesFrom(ollamaManifest),
195
252
  },
196
253
  litellm: {
197
254
  default: 128000,
255
+ ...maxTokensOverridesFrom(litellmManifest),
198
256
  },
199
257
  default: 64000,
200
258
  };
@@ -0,0 +1,18 @@
1
+ import type { MediaHandlerDescriptor, MediaHandlerKind } from "../types/index.js";
2
+ /**
3
+ * Static catalog of every shipped media-handler provider, across all six
4
+ * ecosystems (TTS, STT, Realtime, Video, Avatar, Music). Pure data — no
5
+ * factory functions, no class imports — mirroring the
6
+ * src/lib/factories/providerDescriptors.ts pattern for text/image
7
+ * providers.
8
+ *
9
+ * Entries mirror providerRegistry.ts's hand-constructed TTS/STT/Realtime/
10
+ * Video/Avatar/Music registration blocks (registerAllProviders()) exactly —
11
+ * this file states today's truth, not an aspirational shape. Keep it in
12
+ * sync if those blocks change.
13
+ */
14
+ export declare const MEDIA_HANDLER_CATALOG: readonly MediaHandlerDescriptor[];
15
+ /** Every selectable provider name for `kind`, primaries and aliases both. */
16
+ export declare function providerChoicesFor(kind: MediaHandlerKind): string[];
17
+ /** The first-listed primary provider name for `kind` — used as a fallback default. */
18
+ export declare function defaultProviderFor(kind: MediaHandlerKind): string;
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Static catalog of every shipped media-handler provider, across all six
3
+ * ecosystems (TTS, STT, Realtime, Video, Avatar, Music). Pure data — no
4
+ * factory functions, no class imports — mirroring the
5
+ * src/lib/factories/providerDescriptors.ts pattern for text/image
6
+ * providers.
7
+ *
8
+ * Entries mirror providerRegistry.ts's hand-constructed TTS/STT/Realtime/
9
+ * Video/Avatar/Music registration blocks (registerAllProviders()) exactly —
10
+ * this file states today's truth, not an aspirational shape. Keep it in
11
+ * sync if those blocks change.
12
+ */
13
+ export const MEDIA_HANDLER_CATALOG = [
14
+ // --- TTS ---
15
+ { kind: "tts", name: "google-ai", aliases: ["vertex"] },
16
+ { kind: "tts", name: "openai-tts" },
17
+ { kind: "tts", name: "elevenlabs", aliases: ["elevenlabs-tts"] },
18
+ { kind: "tts", name: "azure-tts" },
19
+ { kind: "tts", name: "fish-audio" },
20
+ { kind: "tts", name: "cartesia" },
21
+ // --- STT ---
22
+ { kind: "stt", name: "whisper", aliases: ["openai-stt"] },
23
+ { kind: "stt", name: "deepgram" },
24
+ { kind: "stt", name: "google-stt" },
25
+ { kind: "stt", name: "azure-stt" },
26
+ // --- Realtime ---
27
+ { kind: "realtime", name: "openai-realtime" },
28
+ { kind: "realtime", name: "gemini-live" },
29
+ // --- Video ---
30
+ { kind: "video", name: "vertex" },
31
+ { kind: "video", name: "kling" },
32
+ { kind: "video", name: "runway" },
33
+ { kind: "video", name: "replicate" },
34
+ // --- Avatar ---
35
+ { kind: "avatar", name: "d-id" },
36
+ { kind: "avatar", name: "replicate", aliases: ["musetalk"] },
37
+ { kind: "avatar", name: "heygen" },
38
+ // --- Music ---
39
+ { kind: "music", name: "beatoven" },
40
+ { kind: "music", name: "replicate", aliases: ["musicgen"] },
41
+ { kind: "music", name: "elevenlabs-music", aliases: ["elevenlabs-sound"] },
42
+ { kind: "music", name: "lyria" },
43
+ ];
44
+ /** Every selectable provider name for `kind`, primaries and aliases both. */
45
+ export function providerChoicesFor(kind) {
46
+ const choices = [];
47
+ for (const entry of MEDIA_HANDLER_CATALOG) {
48
+ if (entry.kind !== kind) {
49
+ continue;
50
+ }
51
+ choices.push(entry.name);
52
+ if (entry.aliases) {
53
+ choices.push(...entry.aliases);
54
+ }
55
+ }
56
+ return choices;
57
+ }
58
+ /** The first-listed primary provider name for `kind` — used as a fallback default. */
59
+ export function defaultProviderFor(kind) {
60
+ const first = MEDIA_HANDLER_CATALOG.find((entry) => entry.kind === kind);
61
+ if (!first) {
62
+ throw new Error(`No media handler catalog entries registered for kind "${kind}"`);
63
+ }
64
+ return first.name;
65
+ }