@juspay/neurolink 10.12.6 → 10.12.8
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 +451 -451
- package/dist/cli/commands/proxyAnalyze.js +7 -0
- package/dist/lib/providers/googleVertex/client.js +9 -1
- package/dist/lib/proxy/accountQuotaRefreshCoordinator.d.ts +19 -0
- package/dist/lib/proxy/accountQuotaRefreshCoordinator.js +105 -0
- package/dist/lib/proxy/accountUsage.d.ts +5 -5
- package/dist/lib/proxy/accountUsage.js +5 -5
- package/dist/lib/proxy/providerTransportCoordinator.d.ts +17 -0
- package/dist/lib/proxy/providerTransportCoordinator.js +156 -0
- package/dist/lib/proxy/proxyAnalysis.js +59 -0
- package/dist/lib/proxy/routingEvidence.d.ts +1 -1
- package/dist/lib/proxy/routingEvidence.js +3 -0
- package/dist/lib/server/routes/claudeProxyRoutes.d.ts +12 -4
- package/dist/lib/server/routes/claudeProxyRoutes.js +319 -69
- package/dist/lib/types/proxy.d.ts +79 -0
- package/dist/lib/utils/messageBuilder.js +12 -0
- package/dist/providers/googleVertex/client.js +9 -1
- package/dist/proxy/accountQuotaRefreshCoordinator.d.ts +19 -0
- package/dist/proxy/accountQuotaRefreshCoordinator.js +104 -0
- package/dist/proxy/accountUsage.d.ts +5 -5
- package/dist/proxy/accountUsage.js +5 -5
- package/dist/proxy/providerTransportCoordinator.d.ts +17 -0
- package/dist/proxy/providerTransportCoordinator.js +155 -0
- package/dist/proxy/proxyAnalysis.js +59 -0
- package/dist/proxy/routingEvidence.d.ts +1 -1
- package/dist/proxy/routingEvidence.js +3 -0
- package/dist/server/routes/claudeProxyRoutes.d.ts +12 -4
- package/dist/server/routes/claudeProxyRoutes.js +319 -69
- package/dist/types/proxy.d.ts +79 -0
- package/dist/utils/messageBuilder.js +12 -0
- package/package.json +3 -2
package/dist/types/proxy.d.ts
CHANGED
|
@@ -430,6 +430,21 @@ export type ProxyAccountRoutingStrategy = (typeof PROXY_ACCOUNT_ROUTING_STRATEGI
|
|
|
430
430
|
export type ProxyAccountRoutingMode = (typeof PROXY_ACCOUNT_ROUTING_MODES)[number];
|
|
431
431
|
export type ProxyAccountRoutingReason = (typeof PROXY_ACCOUNT_ROUTING_REASONS)[number];
|
|
432
432
|
export type ProxyAccountType = (typeof PROXY_ACCOUNT_TYPES)[number];
|
|
433
|
+
export type ProxyQuotaFreshness = "unknown" | "fresh" | "stale_known" | "refresh_due";
|
|
434
|
+
export type ProxyQuotaRefreshReason = "startup_unknown" | "handoff_prewarm" | "ambiguous_snapshot" | "manual";
|
|
435
|
+
export type ProxyQuotaSaturationKind = "none" | "soft" | "hard";
|
|
436
|
+
export type ProxyTransportScope = "shared_provider_transport" | "connection_transport" | "account_specific";
|
|
437
|
+
export type ProxyNetworkTransportScope = Exclude<ProxyTransportScope, "account_specific">;
|
|
438
|
+
export type ProxyProviderTransportProbeOutcome = "recovered" | "failed" | "abandoned";
|
|
439
|
+
export type ProxyProviderTransportPermit = {
|
|
440
|
+
allowed: true;
|
|
441
|
+
probe: boolean;
|
|
442
|
+
generation: number;
|
|
443
|
+
} | {
|
|
444
|
+
allowed: false;
|
|
445
|
+
errorCode: string | null;
|
|
446
|
+
transportScope: ProxyNetworkTransportScope;
|
|
447
|
+
};
|
|
433
448
|
export type ProxyAccountRoutingCandidate = {
|
|
434
449
|
account: string;
|
|
435
450
|
accountType: ProxyAccountType;
|
|
@@ -440,6 +455,15 @@ export type ProxyAccountRoutingCandidate = {
|
|
|
440
455
|
saturated: boolean;
|
|
441
456
|
quotaObserved: boolean;
|
|
442
457
|
quotaStale: boolean;
|
|
458
|
+
quotaFreshness?: ProxyQuotaFreshness;
|
|
459
|
+
refreshNeeded?: boolean;
|
|
460
|
+
refreshReason?: ProxyQuotaRefreshReason | null;
|
|
461
|
+
refreshInFlight?: boolean;
|
|
462
|
+
lastRefreshAttemptAt?: number | null;
|
|
463
|
+
lastRefreshSuccessAt?: number | null;
|
|
464
|
+
nextRefreshEligibleAt?: number | null;
|
|
465
|
+
saturationKind?: ProxyQuotaSaturationKind;
|
|
466
|
+
softLimitOverrideReason?: "overage" | "weekly_expiry" | null;
|
|
443
467
|
quotaLastUpdated: number | null;
|
|
444
468
|
quotaAgeMs: number | null;
|
|
445
469
|
coolingActive: boolean;
|
|
@@ -478,7 +502,17 @@ export type ProxyAccountSortMetrics = {
|
|
|
478
502
|
usable: boolean;
|
|
479
503
|
saturated: boolean;
|
|
480
504
|
hasQuota: boolean;
|
|
505
|
+
quotaEvidenceRank: number;
|
|
481
506
|
quotaStale: boolean;
|
|
507
|
+
quotaFreshness: ProxyQuotaFreshness;
|
|
508
|
+
refreshNeeded: boolean;
|
|
509
|
+
refreshReason: ProxyQuotaRefreshReason | null;
|
|
510
|
+
refreshInFlight: boolean;
|
|
511
|
+
lastRefreshAttemptAt: number | null;
|
|
512
|
+
lastRefreshSuccessAt: number | null;
|
|
513
|
+
nextRefreshEligibleAt: number | null;
|
|
514
|
+
saturationKind: ProxyQuotaSaturationKind;
|
|
515
|
+
softLimitOverrideReason: "overage" | "weekly_expiry" | null;
|
|
482
516
|
quotaLastUpdated: number | null;
|
|
483
517
|
quotaAgeMs: number | null;
|
|
484
518
|
coolingActive: boolean;
|
|
@@ -514,6 +548,8 @@ export type RequestLogEntry = {
|
|
|
514
548
|
errorMessage?: string;
|
|
515
549
|
/** Low-level transport code such as ETIMEDOUT or EADDRNOTAVAIL. */
|
|
516
550
|
errorCode?: string;
|
|
551
|
+
/** Whether changing credentials can affect this transport failure. */
|
|
552
|
+
transportScope?: ProxyTransportScope;
|
|
517
553
|
inputTokens?: number;
|
|
518
554
|
outputTokens?: number;
|
|
519
555
|
cacheCreationTokens?: number;
|
|
@@ -545,6 +581,8 @@ export type RequestAttemptLogEntry = {
|
|
|
545
581
|
errorMessage?: string;
|
|
546
582
|
/** Low-level transport code such as ETIMEDOUT or EADDRNOTAVAIL. */
|
|
547
583
|
errorCode?: string;
|
|
584
|
+
/** Whether changing credentials can affect this transport failure. */
|
|
585
|
+
transportScope?: ProxyTransportScope;
|
|
548
586
|
/** Whether this failed attempt may be retried without changing the request. */
|
|
549
587
|
retryable?: boolean;
|
|
550
588
|
/** Distinguishes short-lived admission throttles from exhausted quota windows. */
|
|
@@ -579,11 +617,15 @@ export type ClaudeFinalRequestLogger = (status: number, accountLabel: string, ac
|
|
|
579
617
|
outputTokens?: number;
|
|
580
618
|
cacheCreationTokens?: number;
|
|
581
619
|
cacheReadTokens?: number;
|
|
620
|
+
errorCode?: string;
|
|
621
|
+
transportScope?: ProxyTransportScope;
|
|
582
622
|
}) => void;
|
|
583
623
|
export type ClaudeLoggedErrorBuilder = (status: number, message: string, errorType?: string, extra?: {
|
|
584
624
|
account?: string;
|
|
585
625
|
accountType?: string;
|
|
586
626
|
attempt?: number;
|
|
627
|
+
errorCode?: string;
|
|
628
|
+
transportScope?: ProxyTransportScope;
|
|
587
629
|
}) => ClaudeErrorResponse;
|
|
588
630
|
export type ClaudeRequestRuntimeContext = {
|
|
589
631
|
tracer?: ProxyTracer;
|
|
@@ -603,6 +645,7 @@ export type AnthropicAttemptLogger = (status: number, errorType?: string, errorM
|
|
|
603
645
|
retryable?: boolean;
|
|
604
646
|
/** Low-level transport code such as ETIMEDOUT or EADDRNOTAVAIL. */
|
|
605
647
|
errorCode?: string;
|
|
648
|
+
transportScope?: ProxyTransportScope;
|
|
606
649
|
rateLimitKind?: "transient" | "quota";
|
|
607
650
|
cooldownReason?: "transient" | "session" | "weekly" | "unified";
|
|
608
651
|
/** Override for nested retries whose attempt starts after this logger. */
|
|
@@ -624,6 +667,8 @@ export type AnthropicLoopState = {
|
|
|
624
667
|
authCooldownMessage: string | null;
|
|
625
668
|
fallbackFailureMessage?: string;
|
|
626
669
|
attemptNumber: number;
|
|
670
|
+
lastTransportErrorCode?: string;
|
|
671
|
+
lastTransportScope?: ProxyNetworkTransportScope;
|
|
627
672
|
};
|
|
628
673
|
export type AnthropicUpstreamBody = {
|
|
629
674
|
bodyStr: string;
|
|
@@ -765,6 +810,8 @@ export type TransientRateLimitRetryBudget = {
|
|
|
765
810
|
export type AnthropicUpstreamFetchResult = {
|
|
766
811
|
continueLoop: boolean;
|
|
767
812
|
retrySameAccount?: boolean;
|
|
813
|
+
transportScope?: ProxyNetworkTransportScope;
|
|
814
|
+
errorCode?: string;
|
|
768
815
|
/** When set, the caller should wait this many ms before retrying (from upstream retry-after). */
|
|
769
816
|
retryAfterMs?: number;
|
|
770
817
|
/** Set on a genuine 429: how long / why to cool this account before rotating. */
|
|
@@ -1033,6 +1080,35 @@ export type AccountUsageFetchResult = {
|
|
|
1033
1080
|
error: string;
|
|
1034
1081
|
status?: number;
|
|
1035
1082
|
};
|
|
1083
|
+
export type ProxyQuotaRefreshRuntimeState = {
|
|
1084
|
+
inFlight: boolean;
|
|
1085
|
+
lastAttemptAt?: number;
|
|
1086
|
+
lastSuccessAt?: number;
|
|
1087
|
+
nextEligibleAt?: number;
|
|
1088
|
+
consecutiveFailures: number;
|
|
1089
|
+
lastFailureReason?: string;
|
|
1090
|
+
lastCompletedTrigger?: string;
|
|
1091
|
+
coalesced: number;
|
|
1092
|
+
};
|
|
1093
|
+
export type ProxyQuotaRefreshMetrics = {
|
|
1094
|
+
attempted: number;
|
|
1095
|
+
succeeded: number;
|
|
1096
|
+
failed: number;
|
|
1097
|
+
coalesced: number;
|
|
1098
|
+
backoffSuppressed: number;
|
|
1099
|
+
triggerDeduplicated: number;
|
|
1100
|
+
};
|
|
1101
|
+
export type ProxyQuotaRefreshRunResult = {
|
|
1102
|
+
kind: "completed";
|
|
1103
|
+
result: AccountUsageFetchResult;
|
|
1104
|
+
/** Lower bound for the freshness of the returned usage snapshot. */
|
|
1105
|
+
startedAt: number;
|
|
1106
|
+
} | {
|
|
1107
|
+
kind: "backoff";
|
|
1108
|
+
nextEligibleAt: number;
|
|
1109
|
+
} | {
|
|
1110
|
+
kind: "not_due";
|
|
1111
|
+
};
|
|
1036
1112
|
/** Per-account result inside a GET /limits response. */
|
|
1037
1113
|
export type ProxyLimitsAccountResult = {
|
|
1038
1114
|
/** Account label (quota-store key). */
|
|
@@ -1053,6 +1129,8 @@ export type ProxyLimitsRefreshResponse = {
|
|
|
1053
1129
|
/** True when served from stored state without contacting Anthropic. */
|
|
1054
1130
|
snapshot: boolean;
|
|
1055
1131
|
results: ProxyLimitsAccountResult[];
|
|
1132
|
+
/** Process-local refresh activity; contains no credentials or response body. */
|
|
1133
|
+
refreshMetrics?: ProxyQuotaRefreshMetrics;
|
|
1056
1134
|
};
|
|
1057
1135
|
/**
|
|
1058
1136
|
* Provenance of the quota numbers attached to a single proxy response.
|
|
@@ -1518,6 +1596,7 @@ export type ProxyAnalysisReport = {
|
|
|
1518
1596
|
errors: number;
|
|
1519
1597
|
errorTypes: Record<string, number>;
|
|
1520
1598
|
errorCodes: Record<string, number>;
|
|
1599
|
+
transportScopes: Record<string, number>;
|
|
1521
1600
|
};
|
|
1522
1601
|
rateLimits: {
|
|
1523
1602
|
attemptRateLimits: number;
|
|
@@ -1073,6 +1073,18 @@ export async function processUnifiedFilesArray(options, maxSize, provider) {
|
|
|
1073
1073
|
options.systemPrompt = existingSystem
|
|
1074
1074
|
? `${existingSystem}${filePromptAugmentation}`
|
|
1075
1075
|
: filePromptAugmentation.trim();
|
|
1076
|
+
// Keep options.prompt in sync with the enriched input.text.
|
|
1077
|
+
// neurolink.ts snapshots `prompt: options.input?.text` at baseOptions
|
|
1078
|
+
// creation — BEFORE this function appends file content — and some
|
|
1079
|
+
// native paths (executeNativeAnthropicGenerate historically) read
|
|
1080
|
+
// `options.prompt` first. Leaving the stale snapshot in place means
|
|
1081
|
+
// every appended file is silently dropped on those paths and the model
|
|
1082
|
+
// answers "no file attached". Same dual-write processCSVFilesForNativeSDK
|
|
1083
|
+
// already documents for exactly this trap.
|
|
1084
|
+
const promptCarrier = options;
|
|
1085
|
+
if (typeof promptCarrier.prompt === "string") {
|
|
1086
|
+
promptCarrier.prompt = inp2.text;
|
|
1087
|
+
}
|
|
1076
1088
|
}
|
|
1077
1089
|
});
|
|
1078
1090
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juspay/neurolink",
|
|
3
|
-
"version": "10.12.
|
|
3
|
+
"version": "10.12.8",
|
|
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": {
|
|
@@ -146,6 +146,7 @@
|
|
|
146
146
|
"test:anthropic-structured": "npx tsx test/continuous-test-suite-anthropic-structured-tools.ts",
|
|
147
147
|
"test:sagemaker-tools": "npx tsx test/continuous-test-suite-sagemaker-tools.ts",
|
|
148
148
|
"test:anthropic-multimodal": "npx tsx test/continuous-test-suite-anthropic-multimodal.ts",
|
|
149
|
+
"test:unified-files-prompt-sync": "npx tsx test/continuous-test-suite-unified-files-prompt-sync.ts",
|
|
149
150
|
"test:excel-interop": "npx tsx test/continuous-test-suite-excel-interop.ts",
|
|
150
151
|
"test:envguard": "npx tsx test/helpers/envGuard.test.ts",
|
|
151
152
|
"test:tool-routing-cli": "npx tsx test/continuous-test-suite-tool-routing-flags.ts && npx tsx test/continuous-test-suite-tool-routing-cli.ts",
|
|
@@ -163,7 +164,7 @@
|
|
|
163
164
|
"test:system-messages": "npx tsx test/continuous-test-suite-system-messages.ts",
|
|
164
165
|
"test:test-stubs": "npx tsx test/continuous-test-suite-test-stubs.ts",
|
|
165
166
|
"test:tool-routing-semantic": "npx tsx test/continuous-test-suite-tool-routing-semantic.ts",
|
|
166
|
-
"test:unit": "pnpm run test:envguard && pnpm run test:bugfixes && pnpm run test:file-detector-extension && pnpm run test:file-detector-magic-bytes && pnpm run test:mcp:infra && pnpm run test:mcp:bash && pnpm run test:mcp:limits && pnpm run test:mcp:spans && pnpm run test:autoresearch:redis && pnpm run test:tool-routing && pnpm run test:tool-routing-cli && pnpm run test:tool-dedup && pnpm run test:model-pool && pnpm run test:litellm-context && pnpm run test:dedup-execute-map && pnpm run test:step-budget-guard && pnpm run test:agent-plumbing && pnpm run test:tool-execution-recorder && pnpm run test:proxy-terminal-errors && pnpm run test:proxy-usage-refresh && pnpm run test:system-messages && pnpm run test:tool-routing-semantic && pnpm run test:anthropic-tools-policy && pnpm run test:anthropic-structured && pnpm run test:sagemaker-tools && pnpm run test:anthropic-multimodal && pnpm run test:excel-interop && pnpm run test:model-capabilities && pnpm run test:agent-runtime:vitest && pnpm run test:agent-delegation && pnpm run test:retry-after:vitest && pnpm run test:sampling-params && pnpm run test:structured-recovery && pnpm run test:prompt-redaction && pnpm run test:mcp-result-cache && pnpm run test:test-stubs && pnpm run test:model-not-found-retryable && pnpm run test:websearch-grounding && pnpm run test:archive:security && pnpm run test:office:security && pnpm run test:proxy:vitest",
|
|
167
|
+
"test:unit": "pnpm run test:envguard && pnpm run test:bugfixes && pnpm run test:file-detector-extension && pnpm run test:file-detector-magic-bytes && pnpm run test:mcp:infra && pnpm run test:mcp:bash && pnpm run test:mcp:limits && pnpm run test:mcp:spans && pnpm run test:autoresearch:redis && pnpm run test:tool-routing && pnpm run test:tool-routing-cli && pnpm run test:tool-dedup && pnpm run test:model-pool && pnpm run test:litellm-context && pnpm run test:dedup-execute-map && pnpm run test:step-budget-guard && pnpm run test:agent-plumbing && pnpm run test:tool-execution-recorder && pnpm run test:proxy-terminal-errors && pnpm run test:proxy-usage-refresh && pnpm run test:system-messages && pnpm run test:tool-routing-semantic && pnpm run test:anthropic-tools-policy && pnpm run test:anthropic-structured && pnpm run test:sagemaker-tools && pnpm run test:anthropic-multimodal && pnpm run test:unified-files-prompt-sync && pnpm run test:excel-interop && pnpm run test:model-capabilities && pnpm run test:agent-runtime:vitest && pnpm run test:agent-delegation && pnpm run test:retry-after:vitest && pnpm run test:sampling-params && pnpm run test:structured-recovery && pnpm run test:prompt-redaction && pnpm run test:mcp-result-cache && pnpm run test:test-stubs && pnpm run test:model-not-found-retryable && pnpm run test:websearch-grounding && pnpm run test:archive:security && pnpm run test:office:security && pnpm run test:proxy:vitest",
|
|
167
168
|
"// CI tier — live providers, runs only when API keys are present (test:credentials and test:dynamic make real provider calls when keys are set, so they live here, not in test:unit)": "",
|
|
168
169
|
"test:live": "pnpm run test:providers && pnpm run test:mcp:http && pnpm run test:mcp:sdk && pnpm run test:mcp:cli && pnpm run test:observability && pnpm run test:context && pnpm run test:memory && pnpm run test:tool-reliability && pnpm run test:evaluation && pnpm run test:autoresearch && pnpm run test:credentials && pnpm run test:dynamic",
|
|
169
170
|
"// CI tier — product output (image/video/TTS/PPT) — costs $$ per run": "",
|