@juspay/neurolink 12.2.3 → 12.2.5
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/README.md +1 -0
- package/dist/browser/neurolink.min.js +346 -346
- package/dist/cli/factories/commandFactory.js +1 -0
- package/dist/cli/factories/setupCommandFactory.d.ts +6 -0
- package/dist/cli/factories/setupCommandFactory.js +48 -8
- package/dist/constants/contextWindows.js +9 -0
- package/dist/factories/providerRegistry.js +2 -1
- package/dist/mcp/externalServerManager.d.ts +0 -4
- package/dist/mcp/externalServerManager.js +32 -4
- package/dist/utils/logSanitize.d.ts +2 -2
- package/dist/utils/logSanitize.js +3 -2
- package/dist/utils/pricing.js +10 -0
- package/package.json +1 -1
|
@@ -11,6 +11,12 @@ export declare class SetupCommandFactory {
|
|
|
11
11
|
* Create the main setup command with all provider subcommands
|
|
12
12
|
*/
|
|
13
13
|
static createSetupCommands(): CommandModule;
|
|
14
|
+
/**
|
|
15
|
+
* Every AIProviderName that has no dedicated native setup subcommand
|
|
16
|
+
* above — these route through the generic wizard (handleSetup ->
|
|
17
|
+
* delegateToProviderSetup / EXTRA_PROVIDER_CONFIGS).
|
|
18
|
+
*/
|
|
19
|
+
private static nonNativeProviderIds;
|
|
14
20
|
/**
|
|
15
21
|
* Build common options for provider setup commands
|
|
16
22
|
*/
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Setup Command Factory for NeuroLink
|
|
3
3
|
* Consolidates all provider setup commands into a unified interface
|
|
4
4
|
*/
|
|
5
|
+
import { AIProviderName } from "../../constants/enums.js";
|
|
5
6
|
import { handleGCPSetup } from "../commands/setup-gcp.js";
|
|
6
7
|
import { handleBedrockSetup } from "../commands/setup-bedrock.js";
|
|
7
8
|
import { handleOpenAISetup } from "../commands/setup-openai.js";
|
|
@@ -27,16 +28,18 @@ export class SetupCommandFactory {
|
|
|
27
28
|
.positional("provider", {
|
|
28
29
|
type: "string",
|
|
29
30
|
description: "Specific provider to set up",
|
|
31
|
+
// Derived from the enum, not hand-listed: the wizard's
|
|
32
|
+
// handleSetup delegates every non-native provider through
|
|
33
|
+
// EXTRA_PROVIDER_CONFIGS, but this hand-hardcoded 9-entry
|
|
34
|
+
// list silently gated `neurolink setup <provider>` to the
|
|
35
|
+
// pre-catalog era — even `setup groq` was rejected here
|
|
36
|
+
// while the wizard behind it supported all 31 providers
|
|
37
|
+
// (found completing the cerebras integration surface).
|
|
38
|
+
// "gcp" stays as the one extra: it's a vertex alias with
|
|
39
|
+
// its own native subcommand below, not an enum member.
|
|
30
40
|
choices: [
|
|
31
|
-
|
|
32
|
-
"openai",
|
|
33
|
-
"anthropic",
|
|
34
|
-
"azure",
|
|
35
|
-
"bedrock",
|
|
41
|
+
...Object.values(AIProviderName).filter((name) => name !== AIProviderName.AUTO),
|
|
36
42
|
"gcp",
|
|
37
|
-
"vertex",
|
|
38
|
-
"huggingface",
|
|
39
|
-
"mistral",
|
|
40
43
|
],
|
|
41
44
|
})
|
|
42
45
|
.option("list", {
|
|
@@ -94,6 +97,24 @@ export class SetupCommandFactory {
|
|
|
94
97
|
.command("mistral", "Setup Mistral AI configuration", (y) => this.buildProviderOptions(y),
|
|
95
98
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
96
99
|
async (argv) => await handleMistralSetup(argv))
|
|
100
|
+
// Every remaining provider becomes a real subcommand routing
|
|
101
|
+
// through the generic wizard (EXTRA_PROVIDER_CONFIGS). A bare
|
|
102
|
+
// positional is not enough: yargs's .recommendCommands()
|
|
103
|
+
// (parser.ts) edit-distance-matches unknown positionals
|
|
104
|
+
// against the subcommand names above and dies with e.g.
|
|
105
|
+
// "Did you mean gcp?" for `setup groq` or `setup xai` before
|
|
106
|
+
// the positional choices are ever consulted. Registering the
|
|
107
|
+
// ids as subcommand aliases (hidden from help — the
|
|
108
|
+
// positional's choices already document the roster there)
|
|
109
|
+
// shadows that recommendation, enum-derived so a new provider
|
|
110
|
+
// can never be silently gated out again (this list was last
|
|
111
|
+
// hand-hardcoded at 9 entries in the pre-catalog era; even
|
|
112
|
+
// `setup groq` was rejected).
|
|
113
|
+
.command(SetupCommandFactory.nonNativeProviderIds(), false, (y) => this.buildProviderOptions(y), async (argv) => await handleSetup({
|
|
114
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
115
|
+
...argv,
|
|
116
|
+
provider: String(argv._[argv._.length - 1]),
|
|
117
|
+
}))
|
|
97
118
|
.example("$0 setup", "Interactive setup wizard")
|
|
98
119
|
.example("$0 setup google-ai", "Setup Google AI Studio")
|
|
99
120
|
.example("$0 setup openai --check", "Check OpenAI configuration")
|
|
@@ -107,6 +128,25 @@ export class SetupCommandFactory {
|
|
|
107
128
|
},
|
|
108
129
|
};
|
|
109
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* Every AIProviderName that has no dedicated native setup subcommand
|
|
133
|
+
* above — these route through the generic wizard (handleSetup ->
|
|
134
|
+
* delegateToProviderSetup / EXTRA_PROVIDER_CONFIGS).
|
|
135
|
+
*/
|
|
136
|
+
static nonNativeProviderIds() {
|
|
137
|
+
const nativeSetup = new Set([
|
|
138
|
+
"google-ai",
|
|
139
|
+
"openai",
|
|
140
|
+
"anthropic",
|
|
141
|
+
"azure",
|
|
142
|
+
"bedrock",
|
|
143
|
+
"gcp",
|
|
144
|
+
"vertex",
|
|
145
|
+
"huggingface",
|
|
146
|
+
"mistral",
|
|
147
|
+
]);
|
|
148
|
+
return Object.values(AIProviderName).filter((name) => name !== AIProviderName.AUTO && !nativeSetup.has(name));
|
|
149
|
+
}
|
|
110
150
|
/**
|
|
111
151
|
* Build common options for provider setup commands
|
|
112
152
|
*/
|
|
@@ -70,6 +70,15 @@ export const MODEL_CONTEXT_WINDOWS = {
|
|
|
70
70
|
"gemma2-9b-it": 8_192,
|
|
71
71
|
"mixtral-8x7b-32768": 32_768,
|
|
72
72
|
},
|
|
73
|
+
// Free tier serves 65k context per model; paid tiers 131k
|
|
74
|
+
// (inference-docs.cerebras.ai model pages, checked 2026-08-27). The
|
|
75
|
+
// tier isn't knowable from the key, so budget against the free-tier
|
|
76
|
+
// floor — compacting early is safe, overrunning a 65k window is not.
|
|
77
|
+
cerebras: {
|
|
78
|
+
_default: 65_536,
|
|
79
|
+
"gpt-oss-120b": 65_536,
|
|
80
|
+
"gemma-4-31b": 65_536,
|
|
81
|
+
},
|
|
73
82
|
cohere: {
|
|
74
83
|
_default: 128_000,
|
|
75
84
|
"command-r-plus": 128_000,
|
|
@@ -114,7 +114,8 @@ export class ProviderRegistry {
|
|
|
114
114
|
}, process.env.HUGGINGFACE_MODEL ||
|
|
115
115
|
HuggingFaceModels.QWEN_2_5_72B_INSTRUCT, ["huggingface", "hf"], PROVIDER_DESCRIPTORS_BY_NAME.get(AIProviderName.HUGGINGFACE));
|
|
116
116
|
// Register the config-driven OpenAI-compatible catalog providers
|
|
117
|
-
// (groq, xai, together-ai, fireworks, perplexity, mistral,
|
|
117
|
+
// (cerebras, groq, xai, together-ai, fireworks, perplexity, mistral,
|
|
118
|
+
// cloudflare).
|
|
118
119
|
// To add a new zero-quirk OpenAI-compatible provider, add one entry to
|
|
119
120
|
// OPENAI_COMPAT_CATALOG (openaiCompatCatalog.ts) — not a new block here.
|
|
120
121
|
for (const entry of OPENAI_COMPAT_CATALOG) {
|
|
@@ -9,10 +9,6 @@
|
|
|
9
9
|
import { EventEmitter } from "events";
|
|
10
10
|
import { ToolDiscoveryService } from "./toolDiscoveryService.js";
|
|
11
11
|
import type { HITLManager, JsonObject, ServerLoadResult, ExternalMCPServerInstance, ExternalMCPServerHealth, ExternalMCPConfigValidation, ExternalMCPOperationResult, ExternalMCPManagerConfig, ExternalMCPToolInfo, MCPServerInfo } from "../types/index.js";
|
|
12
|
-
/**
|
|
13
|
-
* ExternalServerManager
|
|
14
|
-
* Core class for managing external MCP servers
|
|
15
|
-
*/
|
|
16
12
|
export declare class ExternalServerManager extends EventEmitter {
|
|
17
13
|
private servers;
|
|
18
14
|
private config;
|
|
@@ -164,6 +164,31 @@ function isValidExternalMCPServerConfig(config) {
|
|
|
164
164
|
* ExternalServerManager
|
|
165
165
|
* Core class for managing external MCP servers
|
|
166
166
|
*/
|
|
167
|
+
/**
|
|
168
|
+
* Process-signal cleanup, shared across every manager instance.
|
|
169
|
+
*
|
|
170
|
+
* Each delegated worker constructs its own NeuroLink and therefore its own
|
|
171
|
+
* manager; registering SIGINT/SIGTERM/beforeExit per instance leaked listeners
|
|
172
|
+
* (never removed) and crossed Node's 10-listener default on multi-worker runs.
|
|
173
|
+
* One process-level trio walks the live set instead; `shutdown()` removes the
|
|
174
|
+
* instance from the set, so a disposed manager costs nothing.
|
|
175
|
+
*/
|
|
176
|
+
const liveManagers = new Set();
|
|
177
|
+
let processCleanupInstalled = false;
|
|
178
|
+
const shutdownLiveManagers = () => {
|
|
179
|
+
for (const manager of liveManagers) {
|
|
180
|
+
void manager.shutdown();
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
const registerManagerForProcessCleanup = (manager) => {
|
|
184
|
+
liveManagers.add(manager);
|
|
185
|
+
if (!processCleanupInstalled) {
|
|
186
|
+
processCleanupInstalled = true;
|
|
187
|
+
process.on("SIGINT", shutdownLiveManagers);
|
|
188
|
+
process.on("SIGTERM", shutdownLiveManagers);
|
|
189
|
+
process.on("beforeExit", shutdownLiveManagers);
|
|
190
|
+
}
|
|
191
|
+
};
|
|
167
192
|
export class ExternalServerManager extends EventEmitter {
|
|
168
193
|
servers = new Map();
|
|
169
194
|
config;
|
|
@@ -205,10 +230,12 @@ export class ExternalServerManager extends EventEmitter {
|
|
|
205
230
|
serverName: this.getServerName(event.serverId),
|
|
206
231
|
});
|
|
207
232
|
});
|
|
208
|
-
// Handle process cleanup
|
|
209
|
-
|
|
210
|
-
process.on(
|
|
211
|
-
|
|
233
|
+
// Handle process cleanup through the SHARED handler set: one trio of process
|
|
234
|
+
// listeners for every manager, however many instances a run constructs.
|
|
235
|
+
// Per-instance `process.on(...)` here crossed Node's 10-listener default as
|
|
236
|
+
// soon as an agent delegated to a handful of workers (each worker builds its
|
|
237
|
+
// own NeuroLink, which builds its own manager) and warned MaxListenersExceeded.
|
|
238
|
+
registerManagerForProcessCleanup(this);
|
|
212
239
|
}
|
|
213
240
|
/**
|
|
214
241
|
* Attach a McpOutputNormalizer to the underlying ToolDiscoveryService.
|
|
@@ -1230,6 +1257,7 @@ export class ExternalServerManager extends EventEmitter {
|
|
|
1230
1257
|
return;
|
|
1231
1258
|
}
|
|
1232
1259
|
this.isShuttingDown = true;
|
|
1260
|
+
liveManagers.delete(this);
|
|
1233
1261
|
mcpLogger.info("[ExternalServerManager] Shutting down all servers...");
|
|
1234
1262
|
const shutdownPromises = Array.from(this.servers.keys()).map((serverId) => this.stopServer(serverId).catch((error) => {
|
|
1235
1263
|
mcpLogger.error(`[ExternalServerManager] Error shutting down ${serverId}:`, error);
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
* - `Authorization: Basic <base64>` (D-ID and similar)
|
|
11
11
|
* - Bare tokens by known provider prefix:
|
|
12
12
|
* sk-/pk- (OpenAI, Anthropic, Stability),
|
|
13
|
-
* r8_ (Replicate), gsk_ (Groq),
|
|
14
|
-
* fw_ (Fireworks), pplx- (Perplexity), pa- (Voyage),
|
|
13
|
+
* r8_ (Replicate), gsk_ (Groq), csk- (Cerebras), xai- (xAI),
|
|
14
|
+
* tgp_ (Together), fw_ (Fireworks), pplx- (Perplexity), pa- (Voyage),
|
|
15
15
|
* jina_ (Jina), fish- (Fish Audio)
|
|
16
16
|
* - Generic key=value pairs: api_key=…, access_token: …, secret_key=…
|
|
17
17
|
*/
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
* - `Authorization: Basic <base64>` (D-ID and similar)
|
|
11
11
|
* - Bare tokens by known provider prefix:
|
|
12
12
|
* sk-/pk- (OpenAI, Anthropic, Stability),
|
|
13
|
-
* r8_ (Replicate), gsk_ (Groq),
|
|
14
|
-
* fw_ (Fireworks), pplx- (Perplexity), pa- (Voyage),
|
|
13
|
+
* r8_ (Replicate), gsk_ (Groq), csk- (Cerebras), xai- (xAI),
|
|
14
|
+
* tgp_ (Together), fw_ (Fireworks), pplx- (Perplexity), pa- (Voyage),
|
|
15
15
|
* jina_ (Jina), fish- (Fish Audio)
|
|
16
16
|
* - Generic key=value pairs: api_key=…, access_token: …, secret_key=…
|
|
17
17
|
*/
|
|
@@ -22,6 +22,7 @@ const TOKEN_PREFIXES = [
|
|
|
22
22
|
"pk",
|
|
23
23
|
"r8",
|
|
24
24
|
"gsk",
|
|
25
|
+
"csk",
|
|
25
26
|
"xai",
|
|
26
27
|
"tgp",
|
|
27
28
|
"fw",
|
package/dist/utils/pricing.js
CHANGED
|
@@ -518,6 +518,15 @@ const PRICING = {
|
|
|
518
518
|
output: 0.24 / 1_000_000,
|
|
519
519
|
},
|
|
520
520
|
},
|
|
521
|
+
// inference-docs.cerebras.ai model pages, checked 2026-08-27. The
|
|
522
|
+
// gemma-4-31b page's prose and structured data disagree ($2.15/$2.70 vs
|
|
523
|
+
// $0.99/$1.49); the structured data feeds the vendor's rendered pricing
|
|
524
|
+
// card, so it's used here.
|
|
525
|
+
cerebras: {
|
|
526
|
+
_default: { input: 0.35 / 1_000_000, output: 0.75 / 1_000_000 },
|
|
527
|
+
"gpt-oss-120b": { input: 0.35 / 1_000_000, output: 0.75 / 1_000_000 },
|
|
528
|
+
"gemma-4-31b": { input: 0.99 / 1_000_000, output: 1.49 / 1_000_000 },
|
|
529
|
+
},
|
|
521
530
|
cohere: {
|
|
522
531
|
_default: { input: 2.5 / 1_000_000, output: 10.0 / 1_000_000 },
|
|
523
532
|
"command-r-plus": { input: 2.5 / 1_000_000, output: 10.0 / 1_000_000 },
|
|
@@ -685,6 +694,7 @@ const PROVIDER_ALIASES = {
|
|
|
685
694
|
xai: "xai",
|
|
686
695
|
grok: "xai",
|
|
687
696
|
groq: "groq",
|
|
697
|
+
cerebras: "cerebras",
|
|
688
698
|
cohere: "cohere",
|
|
689
699
|
togetherai: "together-ai",
|
|
690
700
|
together: "together-ai",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juspay/neurolink",
|
|
3
|
-
"version": "12.2.
|
|
3
|
+
"version": "12.2.5",
|
|
4
4
|
"packageManager": "pnpm@10.15.1",
|
|
5
5
|
"description": "TypeScript AI SDK with 24+ LLM providers behind one consistent API. MCP-native (connect any MCP server), voice TTS/STT/realtime, RAG, agents, memory, context compaction. OpenAI · Anthropic · Gemini · Bedrock · Azure · Ollama · DeepSeek · NVIDIA NIM and more.",
|
|
6
6
|
"author": {
|