@juspay/neurolink 10.8.5 → 10.8.7
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/dist/browser/neurolink.min.js +403 -403
- package/dist/core/baseProvider.js +5 -1
- package/dist/lib/core/baseProvider.js +5 -1
- package/dist/lib/providers/googleVertex/client.d.ts +20 -0
- package/dist/lib/providers/googleVertex/client.js +39 -15
- package/dist/lib/proxy/modelRouter.d.ts +10 -0
- package/dist/lib/proxy/modelRouter.js +17 -0
- package/dist/lib/proxy/proxyConfig.js +46 -0
- package/dist/lib/proxy/rollingWorkerSupervisor.d.ts +1 -0
- package/dist/lib/proxy/rollingWorkerSupervisor.js +41 -15
- package/dist/lib/proxy/routingPolicy.d.ts +4 -2
- package/dist/lib/proxy/routingPolicy.js +8 -5
- package/dist/lib/proxy/runtimeConfig.js +2 -0
- package/dist/lib/server/routes/claudeProxyRoutes.d.ts +52 -1
- package/dist/lib/server/routes/claudeProxyRoutes.js +467 -221
- package/dist/lib/server/routes/openaiProxyRoutes.js +1 -1
- package/dist/lib/types/proxy.d.ts +26 -0
- package/dist/lib/types/subscription.d.ts +4 -0
- package/dist/lib/utils/messageBuilder.d.ts +25 -0
- package/dist/lib/utils/messageBuilder.js +33 -12
- package/dist/lib/utils/multimodalOptionsBuilder.d.ts +5 -1
- package/dist/lib/utils/multimodalOptionsBuilder.js +8 -1
- package/dist/providers/googleVertex/client.d.ts +20 -0
- package/dist/providers/googleVertex/client.js +39 -15
- package/dist/proxy/modelRouter.d.ts +10 -0
- package/dist/proxy/modelRouter.js +17 -0
- package/dist/proxy/proxyConfig.js +46 -0
- package/dist/proxy/rollingWorkerSupervisor.d.ts +1 -0
- package/dist/proxy/rollingWorkerSupervisor.js +41 -15
- package/dist/proxy/routingPolicy.d.ts +4 -2
- package/dist/proxy/routingPolicy.js +8 -5
- package/dist/proxy/runtimeConfig.js +2 -0
- package/dist/server/routes/claudeProxyRoutes.d.ts +52 -1
- package/dist/server/routes/claudeProxyRoutes.js +467 -221
- package/dist/server/routes/openaiProxyRoutes.js +1 -1
- package/dist/types/proxy.d.ts +26 -0
- package/dist/types/subscription.d.ts +4 -0
- package/dist/utils/messageBuilder.d.ts +25 -0
- package/dist/utils/messageBuilder.js +33 -12
- package/dist/utils/multimodalOptionsBuilder.d.ts +5 -1
- package/dist/utils/multimodalOptionsBuilder.js +8 -1
- package/package.json +1 -1
|
@@ -321,7 +321,7 @@ export function createOpenAIProxyRoutes(modelRouter, basePath = "", loopbackPort
|
|
|
321
321
|
model: targetModel,
|
|
322
322
|
}, requestModelRouter?.getFallbackChain() ?? [], body.model,
|
|
323
323
|
// The classifier only reads fields present on both types.
|
|
324
|
-
adapted);
|
|
324
|
+
adapted, requestModelRouter?.isAutoFallbackEnabled?.() ?? false);
|
|
325
325
|
const attempts = plan.attempts;
|
|
326
326
|
// --- Optional tracing ---
|
|
327
327
|
let tracer;
|
package/dist/types/proxy.d.ts
CHANGED
|
@@ -29,6 +29,8 @@ export type ModelRouterInterface = {
|
|
|
29
29
|
resolve(requestedModel: string): RouteResult;
|
|
30
30
|
isClaudeTarget(requestedModel: string): boolean;
|
|
31
31
|
getFallbackChain(): FallbackEntry[];
|
|
32
|
+
isAutoFallbackEnabled?(): boolean;
|
|
33
|
+
getMaxInflightPerAccount?(): number;
|
|
32
34
|
getModelMappings?: () => ModelMapping[];
|
|
33
35
|
getPassthroughModels?: () => string[];
|
|
34
36
|
};
|
|
@@ -639,6 +641,27 @@ export type AnthropicSuccessResult = {
|
|
|
639
641
|
};
|
|
640
642
|
} | {
|
|
641
643
|
response: Response | unknown;
|
|
644
|
+
holdsAccountAdmission?: boolean;
|
|
645
|
+
};
|
|
646
|
+
/** A release handle for one in-flight request admitted to an OAuth account. */
|
|
647
|
+
export type AccountAdmissionLease = {
|
|
648
|
+
release(): void;
|
|
649
|
+
};
|
|
650
|
+
/** A cancellable queued request for per-account admission capacity. */
|
|
651
|
+
export type QueuedAccountAdmission = {
|
|
652
|
+
accountKey: string;
|
|
653
|
+
promise: Promise<AccountAdmissionLease>;
|
|
654
|
+
cancel(): void;
|
|
655
|
+
};
|
|
656
|
+
/** One queued request waiting for per-account admission capacity. */
|
|
657
|
+
export type AccountAdmissionWaiter = {
|
|
658
|
+
capacity: number;
|
|
659
|
+
resolve: (lease: AccountAdmissionLease) => void;
|
|
660
|
+
};
|
|
661
|
+
/** In-process request admission state for an OAuth account. */
|
|
662
|
+
export type AccountAdmissionState = {
|
|
663
|
+
active: number;
|
|
664
|
+
waiters: AccountAdmissionWaiter[];
|
|
642
665
|
};
|
|
643
666
|
/** Result of buffering only enough upstream SSE to make a retry-safe decision. */
|
|
644
667
|
export type AnthropicStreamPreflightResult = {
|
|
@@ -669,6 +692,7 @@ export type ParsedSSEBuffer = {
|
|
|
669
692
|
};
|
|
670
693
|
export type AnthropicAuthRetryResult = {
|
|
671
694
|
response?: Response | unknown;
|
|
695
|
+
holdsAccountAdmission?: boolean;
|
|
672
696
|
continueLoop: boolean;
|
|
673
697
|
lastError: unknown;
|
|
674
698
|
authFailureMessage: string | null;
|
|
@@ -1925,6 +1949,8 @@ export type RollingManagedWorker = {
|
|
|
1925
1949
|
generation: number;
|
|
1926
1950
|
version: string;
|
|
1927
1951
|
dispose: () => void;
|
|
1952
|
+
pendingTransfers: number;
|
|
1953
|
+
drainRequested: boolean;
|
|
1928
1954
|
};
|
|
1929
1955
|
export type RollingCandidateWorker = RollingManagedWorker & {
|
|
1930
1956
|
expectedVersion: string;
|
|
@@ -908,6 +908,10 @@ export type ProxyRoutingConfig = {
|
|
|
908
908
|
strategy: "round-robin" | "fill-first";
|
|
909
909
|
modelMappings: ModelMapping[];
|
|
910
910
|
fallbackChain: FallbackEntry[];
|
|
911
|
+
/** Permit a last-resort provider chosen by the translation layer. Disabled by default. */
|
|
912
|
+
autoFallback?: boolean;
|
|
913
|
+
/** Maximum in-flight upstream requests per OAuth account. Defaults to two. */
|
|
914
|
+
maxInflightPerAccount?: number;
|
|
911
915
|
passthroughModels?: string[];
|
|
912
916
|
/** Enable quota-aware fill-first account ordering. Defaults to true. */
|
|
913
917
|
quotaRouting?: boolean;
|
|
@@ -12,6 +12,31 @@ export declare function convertToModelMessages(messages: MultimodalChatMessage[]
|
|
|
12
12
|
* Enhanced with CSV file processing support
|
|
13
13
|
*/
|
|
14
14
|
export declare function buildMessagesArray(options: TextGenerationOptions | StreamOptions): Promise<ModelMessage[]>;
|
|
15
|
+
/**
|
|
16
|
+
* Fold the `audioFiles` / `videoFiles` aliases into the unified `files` array.
|
|
17
|
+
*
|
|
18
|
+
* #284 gave audio and video their own input fields, but neither has a
|
|
19
|
+
* dedicated processor — both are meant to travel through the same
|
|
20
|
+
* auto-detecting `files` pipeline that already understands "audio"/"video"
|
|
21
|
+
* FileDetector results (see `appendDetectedFileResult`). The fold used to live
|
|
22
|
+
* inline in `buildMultimodalMessagesArray`, which meant any path that bypassed
|
|
23
|
+
* that builder never performed it and dropped the files silently: the model
|
|
24
|
+
* received the prompt alone and answered as though nothing were attached
|
|
25
|
+
* (#1259). GoogleVertex's native SDK path and `buildMultimodalOptions`
|
|
26
|
+
* (Bedrock) are both such paths, so the fold has to be callable from them.
|
|
27
|
+
*
|
|
28
|
+
* The aliases are cleared once merged, which makes the call idempotent: a
|
|
29
|
+
* provider override and the shared builder can both call this on the same
|
|
30
|
+
* options object without attaching every file twice.
|
|
31
|
+
*
|
|
32
|
+
* Mutates in place, matching `processUnifiedFilesArray` below — downstream
|
|
33
|
+
* stages all read `options.input.files`.
|
|
34
|
+
*/
|
|
35
|
+
export declare function mergeMediaFileAliases<TFile>(input: {
|
|
36
|
+
files?: Array<TFile | Buffer | string>;
|
|
37
|
+
audioFiles?: Array<Buffer | string>;
|
|
38
|
+
videoFiles?: Array<Buffer | string>;
|
|
39
|
+
}): void;
|
|
15
40
|
/**
|
|
16
41
|
* Process the unified files array with auto-detection.
|
|
17
42
|
* Handles lazy file registration, full processing, and preview injection.
|
|
@@ -777,6 +777,38 @@ function appendDetectedFileResult(result, file, options) {
|
|
|
777
777
|
logger.info(`[FileDetector] ⚠️ Unknown format (metadata extracted): ${filename}`);
|
|
778
778
|
}
|
|
779
779
|
}
|
|
780
|
+
/**
|
|
781
|
+
* Fold the `audioFiles` / `videoFiles` aliases into the unified `files` array.
|
|
782
|
+
*
|
|
783
|
+
* #284 gave audio and video their own input fields, but neither has a
|
|
784
|
+
* dedicated processor — both are meant to travel through the same
|
|
785
|
+
* auto-detecting `files` pipeline that already understands "audio"/"video"
|
|
786
|
+
* FileDetector results (see `appendDetectedFileResult`). The fold used to live
|
|
787
|
+
* inline in `buildMultimodalMessagesArray`, which meant any path that bypassed
|
|
788
|
+
* that builder never performed it and dropped the files silently: the model
|
|
789
|
+
* received the prompt alone and answered as though nothing were attached
|
|
790
|
+
* (#1259). GoogleVertex's native SDK path and `buildMultimodalOptions`
|
|
791
|
+
* (Bedrock) are both such paths, so the fold has to be callable from them.
|
|
792
|
+
*
|
|
793
|
+
* The aliases are cleared once merged, which makes the call idempotent: a
|
|
794
|
+
* provider override and the shared builder can both call this on the same
|
|
795
|
+
* options object without attaching every file twice.
|
|
796
|
+
*
|
|
797
|
+
* Mutates in place, matching `processUnifiedFilesArray` below — downstream
|
|
798
|
+
* stages all read `options.input.files`.
|
|
799
|
+
*/
|
|
800
|
+
export function mergeMediaFileAliases(input) {
|
|
801
|
+
if (!input.audioFiles?.length && !input.videoFiles?.length) {
|
|
802
|
+
return;
|
|
803
|
+
}
|
|
804
|
+
input.files = [
|
|
805
|
+
...(input.files ?? []),
|
|
806
|
+
...(input.audioFiles ?? []),
|
|
807
|
+
...(input.videoFiles ?? []),
|
|
808
|
+
];
|
|
809
|
+
input.audioFiles = undefined;
|
|
810
|
+
input.videoFiles = undefined;
|
|
811
|
+
}
|
|
780
812
|
/**
|
|
781
813
|
* Process the unified files array with auto-detection.
|
|
782
814
|
* Handles lazy file registration, full processing, and preview injection.
|
|
@@ -1115,18 +1147,7 @@ export async function buildMultimodalMessagesArray(options, provider, model) {
|
|
|
1115
1147
|
// local const so TypeScript sees the definite (non-optional) type in the
|
|
1116
1148
|
// rest of this function, avoiding 60+ "possibly undefined" errors.
|
|
1117
1149
|
const inp = options.input;
|
|
1118
|
-
|
|
1119
|
-
// through the same auto-detecting `files` pipeline that already
|
|
1120
|
-
// understands "audio"/"video" FileDetector results (see
|
|
1121
|
-
// appendDetectedFileResult), instead of silently dropping them once
|
|
1122
|
-
// detectMultimodal() routes an audio/video-only request here.
|
|
1123
|
-
if (inp.audioFiles?.length || inp.videoFiles?.length) {
|
|
1124
|
-
inp.files = [
|
|
1125
|
-
...(inp.files || []),
|
|
1126
|
-
...(inp.audioFiles || []),
|
|
1127
|
-
...(inp.videoFiles || []),
|
|
1128
|
-
];
|
|
1129
|
-
}
|
|
1150
|
+
mergeMediaFileAliases(inp);
|
|
1130
1151
|
// Compute provider-specific max PDF size once for consistent validation
|
|
1131
1152
|
const pdfConfig = PDFProcessor.getProviderConfig(provider);
|
|
1132
1153
|
const maxSize = pdfConfig
|
|
@@ -12,6 +12,8 @@ import type { StreamOptions } from "../types/index.js";
|
|
|
12
12
|
* - input.files: Auto-detected file types
|
|
13
13
|
* - input.csvFiles: CSV files for tabular data
|
|
14
14
|
* - input.pdfFiles: PDF documents (Buffer | string paths)
|
|
15
|
+
* - input.audioFiles: Audio files (Buffer | string paths)
|
|
16
|
+
* - input.videoFiles: Video files (Buffer | string paths)
|
|
15
17
|
* - csvOptions: CSV parsing options
|
|
16
18
|
* - systemPrompt: System-level instructions
|
|
17
19
|
* - conversationMessages: Chat history
|
|
@@ -23,7 +25,7 @@ import type { StreamOptions } from "../types/index.js";
|
|
|
23
25
|
* @param {string} providerName - Provider identifier (e.g., "vertex", "openai", "anthropic")
|
|
24
26
|
* @param {string} modelName - Model identifier (e.g., "gemini-2.5-flash", "gpt-4o")
|
|
25
27
|
* @returns {object} Normalized options object with:
|
|
26
|
-
* - input: { text, images, content, files, csvFiles, pdfFiles }
|
|
28
|
+
* - input: { text, images, content, files, csvFiles, pdfFiles, audioFiles, videoFiles }
|
|
27
29
|
* - csvOptions: CSV processing options
|
|
28
30
|
* - systemPrompt: System prompt string
|
|
29
31
|
* - conversationHistory: Message history array
|
|
@@ -49,6 +51,8 @@ export declare function buildMultimodalOptions(options: StreamOptions, providerN
|
|
|
49
51
|
files: (string | Buffer<ArrayBufferLike> | import("../index.js").FileWithMetadata)[] | undefined;
|
|
50
52
|
csvFiles: (string | Buffer<ArrayBufferLike>)[] | undefined;
|
|
51
53
|
pdfFiles: (string | Buffer<ArrayBufferLike>)[] | undefined;
|
|
54
|
+
audioFiles: (string | Buffer<ArrayBufferLike>)[] | undefined;
|
|
55
|
+
videoFiles: (string | Buffer<ArrayBufferLike>)[] | undefined;
|
|
52
56
|
};
|
|
53
57
|
csvOptions: import("../index.js").CSVProcessorOptions | undefined;
|
|
54
58
|
pdfOptions: {
|
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
* - input.files: Auto-detected file types
|
|
12
12
|
* - input.csvFiles: CSV files for tabular data
|
|
13
13
|
* - input.pdfFiles: PDF documents (Buffer | string paths)
|
|
14
|
+
* - input.audioFiles: Audio files (Buffer | string paths)
|
|
15
|
+
* - input.videoFiles: Video files (Buffer | string paths)
|
|
14
16
|
* - csvOptions: CSV parsing options
|
|
15
17
|
* - systemPrompt: System-level instructions
|
|
16
18
|
* - conversationMessages: Chat history
|
|
@@ -22,7 +24,7 @@
|
|
|
22
24
|
* @param {string} providerName - Provider identifier (e.g., "vertex", "openai", "anthropic")
|
|
23
25
|
* @param {string} modelName - Model identifier (e.g., "gemini-2.5-flash", "gpt-4o")
|
|
24
26
|
* @returns {object} Normalized options object with:
|
|
25
|
-
* - input: { text, images, content, files, csvFiles, pdfFiles }
|
|
27
|
+
* - input: { text, images, content, files, csvFiles, pdfFiles, audioFiles, videoFiles }
|
|
26
28
|
* - csvOptions: CSV processing options
|
|
27
29
|
* - systemPrompt: System prompt string
|
|
28
30
|
* - conversationHistory: Message history array
|
|
@@ -49,6 +51,11 @@ export function buildMultimodalOptions(options, providerName, modelName) {
|
|
|
49
51
|
files: options.input?.files,
|
|
50
52
|
csvFiles: options.input?.csvFiles,
|
|
51
53
|
pdfFiles: options.input?.pdfFiles,
|
|
54
|
+
// #1259: this is a whitelist — a field omitted here is dropped
|
|
55
|
+
// silently, and the model answers as though nothing were attached.
|
|
56
|
+
// audioFiles/videoFiles were missing, so Bedrock received neither.
|
|
57
|
+
audioFiles: options.input?.audioFiles,
|
|
58
|
+
videoFiles: options.input?.videoFiles,
|
|
52
59
|
},
|
|
53
60
|
csvOptions: options.csvOptions,
|
|
54
61
|
pdfOptions: options.pdfOptions,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juspay/neurolink",
|
|
3
|
-
"version": "10.8.
|
|
3
|
+
"version": "10.8.7",
|
|
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": {
|