@juspay/neurolink 10.4.2 → 10.4.4
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/auth/tokenStore.d.ts +7 -0
- package/dist/auth/tokenStore.js +54 -0
- package/dist/browser/neurolink.min.js +377 -380
- package/dist/cli/commands/proxy.d.ts +2 -1
- package/dist/cli/commands/proxy.js +290 -63
- package/dist/cli/commands/proxyAnalyze.js +10 -1
- package/dist/lib/auth/tokenStore.d.ts +7 -0
- package/dist/lib/auth/tokenStore.js +54 -0
- package/dist/lib/proxy/proxyAnalysis.js +136 -12
- package/dist/lib/proxy/proxyTranslationEngine.d.ts +1 -0
- package/dist/lib/proxy/proxyTranslationEngine.js +56 -12
- package/dist/lib/proxy/rawStreamCapture.js +47 -1
- package/dist/lib/proxy/requestLogger.d.ts +2 -0
- package/dist/lib/proxy/requestLogger.js +72 -13
- package/dist/lib/proxy/rollingProxyServer.js +79 -8
- package/dist/lib/proxy/rollingWorkerProcess.js +20 -15
- package/dist/lib/proxy/rollingWorkerProtocol.js +3 -0
- package/dist/lib/proxy/rollingWorkerSupervisor.d.ts +1 -0
- package/dist/lib/proxy/rollingWorkerSupervisor.js +31 -11
- package/dist/lib/proxy/runtimeConfig.d.ts +1 -0
- package/dist/lib/proxy/runtimeConfig.js +20 -5
- package/dist/lib/proxy/socketWorkerRuntime.js +41 -13
- package/dist/lib/proxy/sseInterceptor.js +47 -1
- package/dist/lib/proxy/tokenRefresh.d.ts +6 -0
- package/dist/lib/proxy/tokenRefresh.js +70 -15
- package/dist/lib/proxy/usageStats.d.ts +25 -3
- package/dist/lib/proxy/usageStats.js +546 -55
- package/dist/lib/server/routes/claudeProxyRoutes.d.ts +2 -0
- package/dist/lib/server/routes/claudeProxyRoutes.js +261 -297
- package/dist/lib/types/proxy.d.ts +90 -1
- package/dist/proxy/proxyAnalysis.js +136 -12
- package/dist/proxy/proxyTranslationEngine.d.ts +1 -0
- package/dist/proxy/proxyTranslationEngine.js +56 -12
- package/dist/proxy/rawStreamCapture.js +47 -1
- package/dist/proxy/requestLogger.d.ts +2 -0
- package/dist/proxy/requestLogger.js +72 -13
- package/dist/proxy/rollingProxyServer.js +79 -8
- package/dist/proxy/rollingWorkerProcess.js +20 -15
- package/dist/proxy/rollingWorkerProtocol.js +3 -0
- package/dist/proxy/rollingWorkerSupervisor.d.ts +1 -0
- package/dist/proxy/rollingWorkerSupervisor.js +31 -11
- package/dist/proxy/runtimeConfig.d.ts +1 -0
- package/dist/proxy/runtimeConfig.js +20 -5
- package/dist/proxy/socketWorkerRuntime.js +41 -13
- package/dist/proxy/sseInterceptor.js +47 -1
- package/dist/proxy/tokenRefresh.d.ts +6 -0
- package/dist/proxy/tokenRefresh.js +70 -15
- package/dist/proxy/usageStats.d.ts +25 -3
- package/dist/proxy/usageStats.js +546 -55
- package/dist/server/routes/claudeProxyRoutes.d.ts +2 -0
- package/dist/server/routes/claudeProxyRoutes.js +261 -297
- package/dist/types/proxy.d.ts +90 -1
- package/package.json +1 -1
package/dist/types/proxy.d.ts
CHANGED
|
@@ -671,6 +671,29 @@ export type AnthropicUpstreamFetchResult = {
|
|
|
671
671
|
sawNetworkError: boolean;
|
|
672
672
|
upstreamSpan?: Span;
|
|
673
673
|
};
|
|
674
|
+
export type ProxyTerminalErrorCategory = "authentication" | "client_cancelled" | "fallback_exhausted" | "invalid_request" | "proxy_error" | "rate_limit" | "stream_error" | "unclassified" | "upstream_error" | "other";
|
|
675
|
+
/** Compact, redacted terminal failure retained independently of body logs. */
|
|
676
|
+
export type ProxyTerminalErrorSummary = {
|
|
677
|
+
id: string;
|
|
678
|
+
at: number;
|
|
679
|
+
status: number;
|
|
680
|
+
category: ProxyTerminalErrorCategory;
|
|
681
|
+
requestId?: string;
|
|
682
|
+
account?: string;
|
|
683
|
+
accountType?: string;
|
|
684
|
+
errorType?: string;
|
|
685
|
+
errorCode?: string;
|
|
686
|
+
terminalOutcome?: string;
|
|
687
|
+
message?: string;
|
|
688
|
+
};
|
|
689
|
+
/** Optional terminal context supplied when a final request error is recorded. */
|
|
690
|
+
export type ProxyTerminalErrorDetails = {
|
|
691
|
+
requestId?: string;
|
|
692
|
+
errorType?: string;
|
|
693
|
+
errorCode?: string;
|
|
694
|
+
terminalOutcome?: string;
|
|
695
|
+
message?: string;
|
|
696
|
+
};
|
|
674
697
|
export type AccountStats = {
|
|
675
698
|
label: string;
|
|
676
699
|
type: string;
|
|
@@ -700,6 +723,19 @@ export type ProxyStats = {
|
|
|
700
723
|
totalQuotaRateLimits: number;
|
|
701
724
|
accounts: Record<string, AccountStats>;
|
|
702
725
|
};
|
|
726
|
+
/** Bounded terminal-error state stored separately from counters and body logs. */
|
|
727
|
+
export type ProxyTerminalErrorJournal = {
|
|
728
|
+
startedAt: number;
|
|
729
|
+
totalErrors: number;
|
|
730
|
+
counts: Record<ProxyTerminalErrorCategory, number>;
|
|
731
|
+
recent: ProxyTerminalErrorSummary[];
|
|
732
|
+
};
|
|
733
|
+
export type ProxyUsageStatsSnapshot = {
|
|
734
|
+
stats: ProxyStats;
|
|
735
|
+
statsVersion: number;
|
|
736
|
+
terminalErrors: ProxyTerminalErrorJournal;
|
|
737
|
+
terminalErrorsVersion: number;
|
|
738
|
+
};
|
|
703
739
|
/** Durability and reconciliation state for the proxy usage counters. */
|
|
704
740
|
export type ProxyStatsPersistenceStatus = {
|
|
705
741
|
enabled: boolean;
|
|
@@ -712,6 +748,14 @@ export type ProxyStatsPersistenceStatus = {
|
|
|
712
748
|
lastReconciledAt: number | null;
|
|
713
749
|
lastRecoveryAt: number | null;
|
|
714
750
|
lastError: string | null;
|
|
751
|
+
terminalErrorsFilePath?: string | null;
|
|
752
|
+
terminalErrorsRevision?: number;
|
|
753
|
+
terminalErrorsPending?: number;
|
|
754
|
+
terminalErrorsInFlight?: number;
|
|
755
|
+
terminalErrorsUnpersisted?: number;
|
|
756
|
+
terminalErrorsLastFlushedAt?: number | null;
|
|
757
|
+
terminalErrorsLastRecoveryAt?: number | null;
|
|
758
|
+
terminalErrorsLastError?: string | null;
|
|
715
759
|
};
|
|
716
760
|
/** Versioned on-disk snapshot shared by overlapping proxy workers. */
|
|
717
761
|
export type PersistedProxyStatsSnapshot = {
|
|
@@ -720,6 +764,13 @@ export type PersistedProxyStatsSnapshot = {
|
|
|
720
764
|
updatedAt: number;
|
|
721
765
|
stats: ProxyStats;
|
|
722
766
|
};
|
|
767
|
+
/** Versioned terminal-error snapshot isolated from rolling-worker counter writes. */
|
|
768
|
+
export type PersistedProxyTerminalErrorSnapshot = {
|
|
769
|
+
schemaVersion: 1;
|
|
770
|
+
revision: number;
|
|
771
|
+
updatedAt: number;
|
|
772
|
+
journal: ProxyTerminalErrorJournal;
|
|
773
|
+
};
|
|
723
774
|
/** Ownership metadata for the proxy statistics cross-process lock. */
|
|
724
775
|
export type ProxyStatsLockOwner = {
|
|
725
776
|
token: string;
|
|
@@ -729,6 +780,7 @@ export type ProxyStatsLockOwner = {
|
|
|
729
780
|
/** Construction options for an isolated proxy statistics store. */
|
|
730
781
|
export type ProxyUsageStatsStoreOptions = {
|
|
731
782
|
filePath?: string;
|
|
783
|
+
terminalErrorsFilePath?: string;
|
|
732
784
|
flushIntervalMs?: number;
|
|
733
785
|
lockTimeoutMs?: number;
|
|
734
786
|
staleLockMs?: number;
|
|
@@ -1121,6 +1173,7 @@ export type ProxyAnalysisAccount = {
|
|
|
1121
1173
|
unclassifiedRateLimits: number;
|
|
1122
1174
|
};
|
|
1123
1175
|
/** Offline report generated from proxy request, attempt, and lifecycle logs. */
|
|
1176
|
+
export type ProxyAnalysisStreamName = "lifecycle" | "requests" | "attempts" | "debug";
|
|
1124
1177
|
export type ProxyAnalysisReport = {
|
|
1125
1178
|
generatedAt: string;
|
|
1126
1179
|
since: string;
|
|
@@ -1129,6 +1182,7 @@ export type ProxyAnalysisReport = {
|
|
|
1129
1182
|
lifecycle: number;
|
|
1130
1183
|
requests: number;
|
|
1131
1184
|
attempts: number;
|
|
1185
|
+
debug: number;
|
|
1132
1186
|
};
|
|
1133
1187
|
coverage: {
|
|
1134
1188
|
lifecycle: boolean;
|
|
@@ -1143,6 +1197,20 @@ export type ProxyAnalysisReport = {
|
|
|
1143
1197
|
unsupportedLifecycleLines: number;
|
|
1144
1198
|
lifecycleSequenceGaps: number;
|
|
1145
1199
|
lifecycleSequenceDuplicates: number;
|
|
1200
|
+
streams: Record<ProxyAnalysisStreamName, {
|
|
1201
|
+
observedFrom: string | null;
|
|
1202
|
+
observedTo: string | null;
|
|
1203
|
+
startsAtOrBeforeRequestedWindow: boolean;
|
|
1204
|
+
}>;
|
|
1205
|
+
bodyArtifacts: {
|
|
1206
|
+
capturesIndexed: number;
|
|
1207
|
+
artifactsReferenced: number;
|
|
1208
|
+
artifactsPresent: number;
|
|
1209
|
+
artifactsMissing: number;
|
|
1210
|
+
invalidPaths: number;
|
|
1211
|
+
writeFailures: number;
|
|
1212
|
+
truncatedCaptures: number;
|
|
1213
|
+
};
|
|
1146
1214
|
};
|
|
1147
1215
|
lifecycle: {
|
|
1148
1216
|
accepted: number;
|
|
@@ -1392,6 +1460,7 @@ export type StoredBodyArtifact = {
|
|
|
1392
1460
|
storedFileBytes?: number;
|
|
1393
1461
|
redactedBody?: string;
|
|
1394
1462
|
bodyTruncated?: boolean;
|
|
1463
|
+
bodyWriteFailed?: boolean;
|
|
1395
1464
|
};
|
|
1396
1465
|
/** File the proxy logger tracks for rotation and cleanup. */
|
|
1397
1466
|
export type ManagedLogFile = {
|
|
@@ -1653,6 +1722,11 @@ export type ProxyWorkerStatusMessage = {
|
|
|
1653
1722
|
generation: number;
|
|
1654
1723
|
pid: number;
|
|
1655
1724
|
socketId: string;
|
|
1725
|
+
} | {
|
|
1726
|
+
type: "proxy-worker:replacement-requested";
|
|
1727
|
+
generation: number;
|
|
1728
|
+
pid: number;
|
|
1729
|
+
reason: "environment";
|
|
1656
1730
|
};
|
|
1657
1731
|
export type ProxyWorkerSocketMessage = {
|
|
1658
1732
|
type: "proxy-worker:socket";
|
|
@@ -1661,6 +1735,8 @@ export type ProxyWorkerSocketMessage = {
|
|
|
1661
1735
|
};
|
|
1662
1736
|
export type ProxyWorkerIpcMessage = ProxyWorkerControlMessage | ProxyWorkerStatusMessage | ProxyWorkerSocketMessage;
|
|
1663
1737
|
export type TransferableProxySocket = Pick<import("node:net").Socket, "destroy" | "end" | "pause" | "resume" | "once">;
|
|
1738
|
+
/** A transferred socket whose temporary handoff listeners can be detached. */
|
|
1739
|
+
export type DetachableTransferableProxySocket = TransferableProxySocket & Pick<import("node:net").Socket, "off">;
|
|
1664
1740
|
export type RollingWorkerHandle = {
|
|
1665
1741
|
pid: number;
|
|
1666
1742
|
sendControl: (message: ProxyWorkerControlMessage) => void;
|
|
@@ -1714,6 +1790,11 @@ export type RollingWorkerSupervisorOptions = {
|
|
|
1714
1790
|
socketQueueTimeoutMs?: number;
|
|
1715
1791
|
shutdownTimeoutMs?: number;
|
|
1716
1792
|
onStateChange?: (snapshot: RollingWorkerSupervisorSnapshot) => void;
|
|
1793
|
+
onReplacementRequested?: (request: {
|
|
1794
|
+
generation: number;
|
|
1795
|
+
pid: number;
|
|
1796
|
+
reason: "environment";
|
|
1797
|
+
}) => void;
|
|
1717
1798
|
log?: (message: string) => void;
|
|
1718
1799
|
};
|
|
1719
1800
|
export type RollingProxyServerOptions = {
|
|
@@ -1854,6 +1935,7 @@ export type ProxyRuntimeConfigReloadResult = {
|
|
|
1854
1935
|
applied: boolean;
|
|
1855
1936
|
changed: boolean;
|
|
1856
1937
|
generation: number;
|
|
1938
|
+
environmentChanged?: boolean;
|
|
1857
1939
|
error?: string;
|
|
1858
1940
|
};
|
|
1859
1941
|
/** Safe runtime configuration diagnostics exposed through proxy status. */
|
|
@@ -1921,6 +2003,11 @@ export type StatusStats = {
|
|
|
1921
2003
|
totalRateLimits: number;
|
|
1922
2004
|
totalTransientRateLimits?: number;
|
|
1923
2005
|
totalQuotaRateLimits?: number;
|
|
2006
|
+
terminalErrors?: ProxyTerminalErrorJournal;
|
|
2007
|
+
lastTerminalError?: ProxyTerminalErrorSummary | null;
|
|
2008
|
+
terminalErrorDetailsComparable?: boolean;
|
|
2009
|
+
terminalErrorDetailsMissing?: number;
|
|
2010
|
+
terminalErrorDetailsExcess?: number;
|
|
1924
2011
|
accounts?: {
|
|
1925
2012
|
label: string;
|
|
1926
2013
|
type: string;
|
|
@@ -1933,7 +2020,9 @@ export type StatusStats = {
|
|
|
1933
2020
|
transientRateLimits?: number;
|
|
1934
2021
|
quotaRateLimits?: number;
|
|
1935
2022
|
cooling: boolean;
|
|
1936
|
-
|
|
2023
|
+
allowed?: boolean;
|
|
2024
|
+
expired?: boolean;
|
|
2025
|
+
status?: "active" | "cooling" | "disabled" | "expired" | "excluded" | "removed" | "internal" | "unattributed";
|
|
1937
2026
|
}[];
|
|
1938
2027
|
persistence?: ProxyStatsPersistenceStatus;
|
|
1939
2028
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juspay/neurolink",
|
|
3
|
-
"version": "10.4.
|
|
3
|
+
"version": "10.4.4",
|
|
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": {
|