@juspay/neurolink 12.28.3 → 12.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.
Files changed (45) hide show
  1. package/CHANGELOG.md +9 -2
  2. package/dist/adapters/tts/googleTTSHandler.d.ts +71 -1
  3. package/dist/adapters/tts/googleTTSHandler.js +254 -0
  4. package/dist/browser/neurolink.min.js +399 -399
  5. package/dist/cli/commands/voices.d.ts +23 -0
  6. package/dist/cli/commands/voices.js +102 -0
  7. package/dist/cli/loop/optionsSchema.d.ts +1 -1
  8. package/dist/cli/parser.js +3 -0
  9. package/dist/constants/enums.d.ts +13 -0
  10. package/dist/constants/enums.js +15 -0
  11. package/dist/core/baseProvider.d.ts +4 -0
  12. package/dist/core/baseProvider.js +245 -148
  13. package/dist/core/modules/structuredOutputPolicy.d.ts +27 -0
  14. package/dist/core/modules/structuredOutputPolicy.js +36 -0
  15. package/dist/core/nativeGenerateLoop.js +7 -1
  16. package/dist/neurolink.d.ts +42 -0
  17. package/dist/neurolink.js +102 -2
  18. package/dist/providers/catalog/index.generated.d.ts +1 -1
  19. package/dist/providers/catalog/index.generated.js +6 -0
  20. package/dist/providers/catalog/morph.json +97 -0
  21. package/dist/providers/catalog/novita.json +114 -0
  22. package/dist/providers/openaiChatCompletionsBase.d.ts +22 -0
  23. package/dist/providers/openaiChatCompletionsBase.js +291 -8
  24. package/dist/server/utils/validation.d.ts +34 -0
  25. package/dist/server/utils/validation.js +27 -0
  26. package/dist/server/websocket/WebSocketHandler.d.ts +4 -6
  27. package/dist/server/websocket/WebSocketHandler.js +185 -18
  28. package/dist/types/cli.d.ts +11 -0
  29. package/dist/types/generate.d.ts +15 -0
  30. package/dist/types/isolatedAgent.d.ts +16 -7
  31. package/dist/types/openaiCompatible.d.ts +6 -0
  32. package/dist/types/providerCatalog.generated.d.ts +2 -2
  33. package/dist/types/providers.d.ts +50 -3
  34. package/dist/types/server.d.ts +8 -0
  35. package/dist/types/stream.d.ts +30 -0
  36. package/dist/types/tts.d.ts +10 -0
  37. package/dist/types/utilities.d.ts +16 -3
  38. package/dist/utils/logger.d.ts +58 -13
  39. package/dist/utils/logger.js +156 -11
  40. package/dist/utils/providerHealth.d.ts +65 -1
  41. package/dist/utils/providerHealth.js +216 -54
  42. package/dist/utils/ttsProcessor.d.ts +30 -1
  43. package/dist/utils/ttsProcessor.js +76 -0
  44. package/docs-site/static/search-index.json +4 -4
  45. package/package.json +6 -1
@@ -0,0 +1,23 @@
1
+ /**
2
+ * `neurolink voices` — list the TTS voices a provider offers.
3
+ *
4
+ * `--tts-voice` on `generate` takes a provider-specific identifier
5
+ * (`en-US-Neural2-C`, `alloy`, `en-US-JennyNeural`), and nothing in the CLI
6
+ * previously printed what those identifiers are. This is the discovery half
7
+ * of that flag.
8
+ *
9
+ * @module cli/commands/voices
10
+ */
11
+ import type { CommandModule } from "yargs";
12
+ import type { CliVoicesCommandArgs } from "../../types/index.js";
13
+ export declare class VoicesCommandFactory {
14
+ static createVoicesCommand(): CommandModule<object, CliVoicesCommandArgs>;
15
+ /**
16
+ * Registration is credential-gated — `registerDefaultTTSHandlers()` skips
17
+ * any handler whose API key is absent — so an unconfigured provider is
18
+ * indistinguishable from a misspelled one at the registry. Naming what IS
19
+ * registered turns both into the same actionable message.
20
+ */
21
+ private static execute;
22
+ private static formatTable;
23
+ }
@@ -0,0 +1,102 @@
1
+ /**
2
+ * `neurolink voices` — list the TTS voices a provider offers.
3
+ *
4
+ * `--tts-voice` on `generate` takes a provider-specific identifier
5
+ * (`en-US-Neural2-C`, `alloy`, `en-US-JennyNeural`), and nothing in the CLI
6
+ * previously printed what those identifiers are. This is the discovery half
7
+ * of that flag.
8
+ *
9
+ * @module cli/commands/voices
10
+ */
11
+ import chalk from "chalk";
12
+ import { TTSProcessor } from "../../utils/ttsProcessor.js";
13
+ import { logger } from "../../utils/logger.js";
14
+ export class VoicesCommandFactory {
15
+ static createVoicesCommand() {
16
+ return {
17
+ command: "voices",
18
+ describe: "List the text-to-speech voices a provider offers",
19
+ builder: (yargs) => yargs
20
+ .option("provider", {
21
+ type: "string",
22
+ demandOption: true,
23
+ description: "TTS provider to query (e.g. google-ai, openai-tts, elevenlabs)",
24
+ })
25
+ .option("language", {
26
+ type: "string",
27
+ description: "Only show voices for this language (e.g. en-US)",
28
+ })
29
+ .option("json", {
30
+ type: "boolean",
31
+ default: false,
32
+ description: "Emit the voice list as JSON",
33
+ })
34
+ .example("$0 voices --provider openai-tts", "List every OpenAI TTS voice")
35
+ .example("$0 voices --provider google-ai --language en-US", "List Google Cloud TTS voices for US English")
36
+ .example("$0 voices --provider elevenlabs --json", "Emit the voice list as JSON for scripting"),
37
+ handler: async (argv) => {
38
+ await VoicesCommandFactory.execute(argv);
39
+ },
40
+ };
41
+ }
42
+ /**
43
+ * Registration is credential-gated — `registerDefaultTTSHandlers()` skips
44
+ * any handler whose API key is absent — so an unconfigured provider is
45
+ * indistinguishable from a misspelled one at the registry. Naming what IS
46
+ * registered turns both into the same actionable message.
47
+ */
48
+ static async execute(argv) {
49
+ const { ProviderRegistry } = await import("../../factories/providerRegistry.js");
50
+ await ProviderRegistry.registerAllProviders();
51
+ let voices;
52
+ try {
53
+ voices = await TTSProcessor.getVoices(argv.provider, {
54
+ ...(argv.language !== undefined ? { languageCode: argv.language } : {}),
55
+ });
56
+ }
57
+ catch (error) {
58
+ const message = error instanceof Error ? error.message : String(error);
59
+ logger.always(chalk.red(`Could not list voices: ${message}`));
60
+ process.exitCode = 1;
61
+ return;
62
+ }
63
+ const sorted = [...voices].sort((a, b) =>
64
+ // Codepoint order, not localeCompare: collation depends on the Node ICU
65
+ // build, so the same list would sort differently on two machines.
66
+ a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
67
+ if (argv.json === true) {
68
+ logger.always(JSON.stringify(sorted, null, 2));
69
+ return;
70
+ }
71
+ if (sorted.length === 0) {
72
+ logger.always(chalk.yellow(argv.language !== undefined
73
+ ? `No voices for language "${argv.language}" on provider "${argv.provider}".`
74
+ : `Provider "${argv.provider}" reported no voices.`));
75
+ return;
76
+ }
77
+ logger.always(VoicesCommandFactory.formatTable(sorted));
78
+ logger.always(chalk.gray(`\n${sorted.length} voice${sorted.length === 1 ? "" : "s"} for ${argv.provider}` +
79
+ (argv.language !== undefined ? ` (language: ${argv.language})` : "")));
80
+ }
81
+ static formatTable(voices) {
82
+ const headers = ["ID", "NAME", "LANGUAGE", "GENDER", "TYPE"];
83
+ const rows = voices.map((voice) => [
84
+ voice.id,
85
+ voice.name,
86
+ voice.languageCode,
87
+ voice.gender ?? "-",
88
+ voice.type ?? "-",
89
+ ]);
90
+ const widths = headers.map((header, column) => rows.reduce((widest, row) => Math.max(widest, (row[column] ?? "").length), header.length));
91
+ const line = (cells, paint) => paint(cells
92
+ .map((cell, column) => cell.padEnd(widths[column] ?? 0))
93
+ .join(" ")
94
+ .trimEnd());
95
+ return [
96
+ line(headers, chalk.bold),
97
+ chalk.gray(widths.map((width) => "-".repeat(width)).join(" ")),
98
+ ...rows.map((row) => line(row, (s) => s)),
99
+ ].join("\n");
100
+ }
101
+ }
102
+ //# sourceMappingURL=voices.js.map
@@ -4,4 +4,4 @@ import type { OptionSchema, TextGenerationOptions } from "../../types/index.js";
4
4
  * This object provides metadata for validation and help text in the CLI loop.
5
5
  * It is derived from the main TextGenerationOptions interface to ensure consistency.
6
6
  */
7
- export declare const textGenerationOptionsSchema: Record<keyof Omit<TextGenerationOptions, "prompt" | "input" | "schema" | "tools" | "context" | "conversationHistory" | "conversationMessages" | "conversationMemoryConfig" | "originalPrompt" | "middleware" | "expectedOutcome" | "evaluationCriteria" | "region" | "csvOptions" | "pdfOptions" | "imageOptions" | "tts" | "stt" | "thinkingConfig" | "requestId" | "fileRegistry" | "abortSignal" | "toolFilter" | "excludeTools" | "toolChoice" | "prepareStep" | "credentials" | "onFinish" | "onError" | "processors" | "piiDetection" | "responseValidation" | "inputValidation" | "toolExecutionCapture" | "toolExecutionRecorder" | "toolRoots">, OptionSchema>;
7
+ export declare const textGenerationOptionsSchema: Record<keyof Omit<TextGenerationOptions, "prompt" | "input" | "schema" | "tools" | "context" | "conversationHistory" | "conversationMessages" | "conversationMemoryConfig" | "originalPrompt" | "middleware" | "expectedOutcome" | "evaluationCriteria" | "region" | "csvOptions" | "pdfOptions" | "imageOptions" | "videoOptions" | "tts" | "stt" | "thinkingConfig" | "requestId" | "fileRegistry" | "abortSignal" | "toolFilter" | "excludeTools" | "toolChoice" | "prepareStep" | "credentials" | "onFinish" | "onError" | "processors" | "piiDetection" | "responseValidation" | "inputValidation" | "toolExecutionCapture" | "toolExecutionRecorder" | "toolRoots">, OptionSchema>;
@@ -35,6 +35,7 @@ import { AutoresearchCommandFactory } from "./commands/autoresearch.js";
35
35
  import { voiceServerCommand } from "./commands/voiceServer.js";
36
36
  import { DocsCommandFactory } from "./commands/docs.js";
37
37
  import { UsageCommandFactory } from "./commands/usage.js";
38
+ import { VoicesCommandFactory } from "./commands/voices.js";
38
39
  // Enhanced CLI with Professional UX
39
40
  export function initializeCliParser() {
40
41
  return (yargs(hideBin(process.argv))
@@ -192,6 +193,8 @@ export function initializeCliParser() {
192
193
  .command(CLICommandFactory.createBestProviderCommand())
193
194
  // Validate Command (alias for config validate)
194
195
  .command(CLICommandFactory.createValidateCommand())
196
+ // Voices Command - TTS voice discovery for --tts-voice
197
+ .command(VoicesCommandFactory.createVoicesCommand())
195
198
  // Completion Command - Using CLICommandFactory
196
199
  .command(CLICommandFactory.createCompletionCommand())
197
200
  // Ollama Command Group - Using CLICommandFactory
@@ -30,6 +30,8 @@ export declare enum AIProviderName {
30
30
  IO_INTELLIGENCE = "io-intelligence",
31
31
  MANCER = "mancer",
32
32
  MISTRAL = "mistral",
33
+ MORPH = "morph",
34
+ NOVITA = "novita",
33
35
  PERPLEXITY = "perplexity",
34
36
  SAMBANOVA = "sambanova",
35
37
  TOGETHER_AI = "together-ai",
@@ -986,6 +988,17 @@ export declare enum MistralModels {
986
988
  MISTRAL_SMALL_4 = "mistral-small-2603",
987
989
  MISTRAL_SMALL_CREATIVE = "mistral-small-creative"
988
990
  }
991
+ export declare enum MorphModels {
992
+ MORPH_V3_LARGE = "morph-v3-large",
993
+ MORPH_V3_FAST = "morph-v3-fast"
994
+ }
995
+ export declare enum NovitaModels {
996
+ META_LLAMA_LLAMA_3_3_70B_INSTRUCT = "meta-llama/llama-3.3-70b-instruct",
997
+ ZAI_ORG_GLM_5_3_FLASH = "zai-org/glm-5.3-flash",
998
+ DEEPSEEK_DEEPSEEK_V3_0324 = "deepseek/deepseek-v3-0324",
999
+ QWEN_QWEN_2_5_72B_INSTRUCT = "qwen/qwen-2.5-72b-instruct",
1000
+ GOOGLE_GEMMA_3_27B_IT = "google/gemma-3-27b-it"
1001
+ }
989
1002
  export declare enum PerplexityModels {
990
1003
  SONAR = "sonar",
991
1004
  SONAR_PRO = "sonar-pro",
@@ -35,6 +35,8 @@ export var AIProviderName;
35
35
  AIProviderName["IO_INTELLIGENCE"] = "io-intelligence";
36
36
  AIProviderName["MANCER"] = "mancer";
37
37
  AIProviderName["MISTRAL"] = "mistral";
38
+ AIProviderName["MORPH"] = "morph";
39
+ AIProviderName["NOVITA"] = "novita";
38
40
  AIProviderName["PERPLEXITY"] = "perplexity";
39
41
  AIProviderName["SAMBANOVA"] = "sambanova";
40
42
  AIProviderName["TOGETHER_AI"] = "together-ai";
@@ -1227,6 +1229,19 @@ export var MistralModels;
1227
1229
  MistralModels["MISTRAL_SMALL_4"] = "mistral-small-2603";
1228
1230
  MistralModels["MISTRAL_SMALL_CREATIVE"] = "mistral-small-creative";
1229
1231
  })(MistralModels || (MistralModels = {}));
1232
+ export var MorphModels;
1233
+ (function (MorphModels) {
1234
+ MorphModels["MORPH_V3_LARGE"] = "morph-v3-large";
1235
+ MorphModels["MORPH_V3_FAST"] = "morph-v3-fast";
1236
+ })(MorphModels || (MorphModels = {}));
1237
+ export var NovitaModels;
1238
+ (function (NovitaModels) {
1239
+ NovitaModels["META_LLAMA_LLAMA_3_3_70B_INSTRUCT"] = "meta-llama/llama-3.3-70b-instruct";
1240
+ NovitaModels["ZAI_ORG_GLM_5_3_FLASH"] = "zai-org/glm-5.3-flash";
1241
+ NovitaModels["DEEPSEEK_DEEPSEEK_V3_0324"] = "deepseek/deepseek-v3-0324";
1242
+ NovitaModels["QWEN_QWEN_2_5_72B_INSTRUCT"] = "qwen/qwen-2.5-72b-instruct";
1243
+ NovitaModels["GOOGLE_GEMMA_3_27B_IT"] = "google/gemma-3-27b-it";
1244
+ })(NovitaModels || (NovitaModels = {}));
1230
1245
  export var PerplexityModels;
1231
1246
  (function (PerplexityModels) {
1232
1247
  PerplexityModels["SONAR"] = "sonar";
@@ -104,6 +104,10 @@ export declare abstract class BaseProvider implements AIProvider {
104
104
  * over /api/chat, custom OpenAI-compatible servers, etc). Wrapping the
105
105
  * user-facing stream here ensures the callbacks fire regardless of the
106
106
  * underlying transport.
107
+ *
108
+ * `teardownController`, when supplied, is the call's own abort source (see
109
+ * `stream()`): the cancel hook fires it on abandonment so the transport's
110
+ * in-flight HTTP request is cancelled, not just this iterator chain.
107
111
  */
108
112
  private wrapStreamWithLifecycleCallbacks;
109
113
  /**