@juspay/neurolink 9.41.0 → 9.42.1
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 +8 -0
- package/README.md +7 -1
- package/dist/auth/anthropicOAuth.d.ts +18 -3
- package/dist/auth/anthropicOAuth.js +149 -4
- package/dist/auth/providers/firebase.js +5 -1
- package/dist/auth/providers/jwt.js +5 -1
- package/dist/auth/providers/workos.js +5 -1
- package/dist/auth/sessionManager.d.ts +1 -1
- package/dist/auth/sessionManager.js +58 -27
- package/dist/browser/neurolink.min.js +354 -334
- package/dist/cli/commands/mcp.d.ts +6 -0
- package/dist/cli/commands/mcp.js +188 -181
- package/dist/cli/commands/proxy.d.ts +2 -1
- package/dist/cli/commands/proxy.js +713 -431
- package/dist/cli/commands/task.js +3 -0
- package/dist/cli/factories/commandFactory.d.ts +2 -0
- package/dist/cli/factories/commandFactory.js +38 -0
- package/dist/cli/parser.js +4 -3
- package/dist/client/aiSdkAdapter.js +3 -0
- package/dist/client/streamingClient.js +30 -10
- package/dist/core/baseProvider.d.ts +6 -1
- package/dist/core/baseProvider.js +208 -230
- package/dist/core/factory.d.ts +3 -0
- package/dist/core/factory.js +138 -188
- package/dist/core/modules/GenerationHandler.js +3 -2
- package/dist/core/redisConversationMemoryManager.js +7 -3
- package/dist/evaluation/BatchEvaluator.js +4 -1
- package/dist/evaluation/hooks/observabilityHooks.js +5 -3
- package/dist/evaluation/pipeline/evaluationPipeline.d.ts +3 -2
- package/dist/evaluation/pipeline/evaluationPipeline.js +24 -9
- package/dist/evaluation/pipeline/strategies/batchStrategy.js +6 -3
- package/dist/evaluation/pipeline/strategies/samplingStrategy.js +18 -10
- package/dist/evaluation/scorers/scorerRegistry.d.ts +3 -0
- package/dist/evaluation/scorers/scorerRegistry.js +353 -282
- package/dist/lib/auth/anthropicOAuth.d.ts +18 -3
- package/dist/lib/auth/anthropicOAuth.js +149 -4
- package/dist/lib/auth/providers/firebase.js +5 -1
- package/dist/lib/auth/providers/jwt.js +5 -1
- package/dist/lib/auth/providers/workos.js +5 -1
- package/dist/lib/auth/sessionManager.d.ts +1 -1
- package/dist/lib/auth/sessionManager.js +58 -27
- package/dist/lib/client/aiSdkAdapter.js +3 -0
- package/dist/lib/client/streamingClient.js +30 -10
- package/dist/lib/core/baseProvider.d.ts +6 -1
- package/dist/lib/core/baseProvider.js +208 -230
- package/dist/lib/core/factory.d.ts +3 -0
- package/dist/lib/core/factory.js +138 -188
- package/dist/lib/core/modules/GenerationHandler.js +3 -2
- package/dist/lib/core/redisConversationMemoryManager.js +7 -3
- package/dist/lib/evaluation/BatchEvaluator.js +4 -1
- package/dist/lib/evaluation/hooks/observabilityHooks.js +5 -3
- package/dist/lib/evaluation/pipeline/evaluationPipeline.d.ts +3 -2
- package/dist/lib/evaluation/pipeline/evaluationPipeline.js +24 -9
- package/dist/lib/evaluation/pipeline/strategies/batchStrategy.js +6 -3
- package/dist/lib/evaluation/pipeline/strategies/samplingStrategy.js +18 -10
- package/dist/lib/evaluation/scorers/scorerRegistry.d.ts +3 -0
- package/dist/lib/evaluation/scorers/scorerRegistry.js +353 -282
- package/dist/lib/mcp/toolRegistry.d.ts +2 -0
- package/dist/lib/mcp/toolRegistry.js +32 -31
- package/dist/lib/neurolink.d.ts +41 -2
- package/dist/lib/neurolink.js +1616 -1681
- package/dist/lib/observability/otelBridge.d.ts +2 -2
- package/dist/lib/observability/otelBridge.js +12 -3
- package/dist/lib/providers/amazonBedrock.js +2 -4
- package/dist/lib/providers/anthropic.d.ts +9 -5
- package/dist/lib/providers/anthropic.js +19 -14
- package/dist/lib/providers/anthropicBaseProvider.d.ts +3 -3
- package/dist/lib/providers/anthropicBaseProvider.js +5 -4
- package/dist/lib/providers/azureOpenai.d.ts +1 -1
- package/dist/lib/providers/azureOpenai.js +5 -4
- package/dist/lib/providers/googleAiStudio.js +30 -6
- package/dist/lib/providers/googleVertex.d.ts +10 -0
- package/dist/lib/providers/googleVertex.js +437 -423
- package/dist/lib/providers/huggingFace.d.ts +3 -3
- package/dist/lib/providers/huggingFace.js +6 -8
- package/dist/lib/providers/litellm.d.ts +1 -0
- package/dist/lib/providers/litellm.js +76 -55
- package/dist/lib/providers/mistral.js +2 -1
- package/dist/lib/providers/ollama.js +93 -23
- package/dist/lib/providers/openAI.d.ts +2 -0
- package/dist/lib/providers/openAI.js +141 -141
- package/dist/lib/providers/openRouter.js +2 -1
- package/dist/lib/providers/openaiCompatible.d.ts +4 -4
- package/dist/lib/providers/openaiCompatible.js +4 -4
- package/dist/lib/proxy/claudeFormat.d.ts +3 -2
- package/dist/lib/proxy/claudeFormat.js +27 -14
- package/dist/lib/proxy/cloaking/plugins/sessionIdentity.d.ts +2 -6
- package/dist/lib/proxy/cloaking/plugins/sessionIdentity.js +9 -33
- package/dist/lib/proxy/modelRouter.js +3 -0
- package/dist/lib/proxy/oauthFetch.d.ts +1 -1
- package/dist/lib/proxy/oauthFetch.js +289 -316
- package/dist/lib/proxy/proxyConfig.js +46 -24
- package/dist/lib/proxy/proxyEnv.d.ts +19 -0
- package/dist/lib/proxy/proxyEnv.js +73 -0
- package/dist/lib/proxy/proxyFetch.js +291 -217
- package/dist/lib/proxy/proxyTracer.d.ts +133 -0
- package/dist/lib/proxy/proxyTracer.js +645 -0
- package/dist/lib/proxy/rawStreamCapture.d.ts +10 -0
- package/dist/lib/proxy/rawStreamCapture.js +83 -0
- package/dist/lib/proxy/requestLogger.d.ts +32 -5
- package/dist/lib/proxy/requestLogger.js +503 -47
- package/dist/lib/proxy/sseInterceptor.d.ts +97 -0
- package/dist/lib/proxy/sseInterceptor.js +427 -0
- package/dist/lib/proxy/usageStats.d.ts +4 -3
- package/dist/lib/proxy/usageStats.js +25 -12
- package/dist/lib/rag/chunkers/MarkdownChunker.js +13 -5
- package/dist/lib/rag/chunking/markdownChunker.js +15 -6
- package/dist/lib/server/routes/claudeProxyRoutes.d.ts +17 -3
- package/dist/lib/server/routes/claudeProxyRoutes.js +3032 -1349
- package/dist/lib/services/server/ai/observability/instrumentation.d.ts +7 -1
- package/dist/lib/services/server/ai/observability/instrumentation.js +337 -161
- package/dist/lib/tasks/backends/bullmqBackend.d.ts +1 -0
- package/dist/lib/tasks/backends/bullmqBackend.js +35 -22
- package/dist/lib/tasks/store/redisTaskStore.d.ts +1 -0
- package/dist/lib/tasks/store/redisTaskStore.js +54 -39
- package/dist/lib/tasks/taskManager.d.ts +5 -0
- package/dist/lib/tasks/taskManager.js +158 -30
- package/dist/lib/telemetry/index.d.ts +2 -1
- package/dist/lib/telemetry/index.js +2 -1
- package/dist/lib/telemetry/telemetryService.d.ts +3 -0
- package/dist/lib/telemetry/telemetryService.js +69 -5
- package/dist/lib/types/cli.d.ts +10 -0
- package/dist/lib/types/proxyTypes.d.ts +160 -5
- package/dist/lib/types/streamTypes.d.ts +25 -3
- package/dist/lib/utils/messageBuilder.js +3 -2
- package/dist/lib/utils/providerHealth.d.ts +19 -0
- package/dist/lib/utils/providerHealth.js +279 -33
- package/dist/lib/utils/providerUtils.js +17 -22
- package/dist/lib/utils/toolChoice.d.ts +4 -0
- package/dist/lib/utils/toolChoice.js +7 -0
- package/dist/mcp/toolRegistry.d.ts +2 -0
- package/dist/mcp/toolRegistry.js +32 -31
- package/dist/neurolink.d.ts +41 -2
- package/dist/neurolink.js +1616 -1681
- package/dist/observability/otelBridge.d.ts +2 -2
- package/dist/observability/otelBridge.js +12 -3
- package/dist/providers/amazonBedrock.js +2 -4
- package/dist/providers/anthropic.d.ts +9 -5
- package/dist/providers/anthropic.js +19 -14
- package/dist/providers/anthropicBaseProvider.d.ts +3 -3
- package/dist/providers/anthropicBaseProvider.js +5 -4
- package/dist/providers/azureOpenai.d.ts +1 -1
- package/dist/providers/azureOpenai.js +5 -4
- package/dist/providers/googleAiStudio.js +30 -6
- package/dist/providers/googleVertex.d.ts +10 -0
- package/dist/providers/googleVertex.js +437 -423
- package/dist/providers/huggingFace.d.ts +3 -3
- package/dist/providers/huggingFace.js +6 -7
- package/dist/providers/litellm.d.ts +1 -0
- package/dist/providers/litellm.js +76 -55
- package/dist/providers/mistral.js +2 -1
- package/dist/providers/ollama.js +93 -23
- package/dist/providers/openAI.d.ts +2 -0
- package/dist/providers/openAI.js +141 -141
- package/dist/providers/openRouter.js +2 -1
- package/dist/providers/openaiCompatible.d.ts +4 -4
- package/dist/providers/openaiCompatible.js +4 -3
- package/dist/proxy/claudeFormat.d.ts +3 -2
- package/dist/proxy/claudeFormat.js +27 -14
- package/dist/proxy/cloaking/plugins/sessionIdentity.d.ts +2 -6
- package/dist/proxy/cloaking/plugins/sessionIdentity.js +9 -33
- package/dist/proxy/modelRouter.js +3 -0
- package/dist/proxy/oauthFetch.d.ts +1 -1
- package/dist/proxy/oauthFetch.js +289 -316
- package/dist/proxy/proxyConfig.js +46 -24
- package/dist/proxy/proxyEnv.d.ts +19 -0
- package/dist/proxy/proxyEnv.js +72 -0
- package/dist/proxy/proxyFetch.js +291 -217
- package/dist/proxy/proxyTracer.d.ts +133 -0
- package/dist/proxy/proxyTracer.js +644 -0
- package/dist/proxy/rawStreamCapture.d.ts +10 -0
- package/dist/proxy/rawStreamCapture.js +82 -0
- package/dist/proxy/requestLogger.d.ts +32 -5
- package/dist/proxy/requestLogger.js +503 -47
- package/dist/proxy/sseInterceptor.d.ts +97 -0
- package/dist/proxy/sseInterceptor.js +426 -0
- package/dist/proxy/usageStats.d.ts +4 -3
- package/dist/proxy/usageStats.js +25 -12
- package/dist/rag/chunkers/MarkdownChunker.js +13 -5
- package/dist/rag/chunking/markdownChunker.js +15 -6
- package/dist/server/routes/claudeProxyRoutes.d.ts +17 -3
- package/dist/server/routes/claudeProxyRoutes.js +3032 -1349
- package/dist/services/server/ai/observability/instrumentation.d.ts +7 -1
- package/dist/services/server/ai/observability/instrumentation.js +337 -161
- package/dist/tasks/backends/bullmqBackend.d.ts +1 -0
- package/dist/tasks/backends/bullmqBackend.js +35 -22
- package/dist/tasks/store/redisTaskStore.d.ts +1 -0
- package/dist/tasks/store/redisTaskStore.js +54 -39
- package/dist/tasks/taskManager.d.ts +5 -0
- package/dist/tasks/taskManager.js +158 -30
- package/dist/telemetry/index.d.ts +2 -1
- package/dist/telemetry/index.js +2 -1
- package/dist/telemetry/telemetryService.d.ts +3 -0
- package/dist/telemetry/telemetryService.js +69 -5
- package/dist/types/cli.d.ts +10 -0
- package/dist/types/proxyTypes.d.ts +160 -5
- package/dist/types/streamTypes.d.ts +25 -3
- package/dist/utils/messageBuilder.js +3 -2
- package/dist/utils/providerHealth.d.ts +19 -0
- package/dist/utils/providerHealth.js +279 -33
- package/dist/utils/providerUtils.js +18 -22
- package/dist/utils/toolChoice.d.ts +4 -0
- package/dist/utils/toolChoice.js +6 -0
- package/docs/assets/dashboards/neurolink-proxy-observability-dashboard.json +6609 -0
- package/docs/changelog.md +252 -0
- package/package.json +19 -2
- package/scripts/observability/check-proxy-telemetry.mjs +235 -0
- package/scripts/observability/docker-compose.proxy-observability.yaml +55 -0
- package/scripts/observability/import-openobserve-dashboard.mjs +240 -0
- package/scripts/observability/manage-local-openobserve.sh +215 -0
- package/scripts/observability/otel-collector.proxy-observability.yaml +78 -0
- package/scripts/observability/proxy-observability.env.example +23 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/** Maximum bytes to capture before stopping accumulation (1 MB). */
|
|
2
|
+
const MAX_CAPTURE_BYTES = 1024 * 1024;
|
|
3
|
+
const TRUNCATION_MARKER = "\n...[TRUNCATED]";
|
|
4
|
+
export function createRawStreamCapture() {
|
|
5
|
+
const decoder = new TextDecoder();
|
|
6
|
+
const chunks = [];
|
|
7
|
+
let totalBytes = 0;
|
|
8
|
+
let capturedBytes = 0;
|
|
9
|
+
let truncated = false;
|
|
10
|
+
let resolved = false;
|
|
11
|
+
let resolveCapture;
|
|
12
|
+
const capture = new Promise((resolve) => {
|
|
13
|
+
resolveCapture = resolve;
|
|
14
|
+
});
|
|
15
|
+
function settle() {
|
|
16
|
+
if (resolved) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
resolved = true;
|
|
20
|
+
const finalChunk = decoder.decode();
|
|
21
|
+
if (finalChunk) {
|
|
22
|
+
if (capturedBytes < MAX_CAPTURE_BYTES) {
|
|
23
|
+
const remainingBytes = MAX_CAPTURE_BYTES - capturedBytes;
|
|
24
|
+
chunks.push(finalChunk.slice(0, remainingBytes));
|
|
25
|
+
capturedBytes += Math.min(finalChunk.length, remainingBytes);
|
|
26
|
+
}
|
|
27
|
+
else if (!truncated) {
|
|
28
|
+
chunks.push(TRUNCATION_MARKER);
|
|
29
|
+
truncated = true;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
resolveCapture({
|
|
33
|
+
totalBytes,
|
|
34
|
+
text: chunks.join(""),
|
|
35
|
+
truncated,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
const transform = new TransformStream({
|
|
39
|
+
transform(chunk, controller) {
|
|
40
|
+
controller.enqueue(chunk);
|
|
41
|
+
totalBytes += chunk.byteLength;
|
|
42
|
+
if (capturedBytes < MAX_CAPTURE_BYTES) {
|
|
43
|
+
const decoded = decoder.decode(chunk, { stream: true });
|
|
44
|
+
const remainingBytes = MAX_CAPTURE_BYTES - capturedBytes;
|
|
45
|
+
const slice = decoded.slice(0, remainingBytes);
|
|
46
|
+
chunks.push(slice);
|
|
47
|
+
capturedBytes += Math.min(decoded.length, remainingBytes);
|
|
48
|
+
if (decoded.length > remainingBytes && !truncated) {
|
|
49
|
+
chunks.push(TRUNCATION_MARKER);
|
|
50
|
+
truncated = true;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else if (!truncated) {
|
|
54
|
+
chunks.push(TRUNCATION_MARKER);
|
|
55
|
+
truncated = true;
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
flush() {
|
|
59
|
+
settle();
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
const innerWriter = transform.writable.getWriter();
|
|
63
|
+
const writable = new WritableStream({
|
|
64
|
+
write(chunk) {
|
|
65
|
+
return innerWriter.write(chunk);
|
|
66
|
+
},
|
|
67
|
+
close() {
|
|
68
|
+
return innerWriter.close();
|
|
69
|
+
},
|
|
70
|
+
abort(reason) {
|
|
71
|
+
settle();
|
|
72
|
+
return innerWriter.abort(reason);
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
return {
|
|
76
|
+
stream: {
|
|
77
|
+
readable: transform.readable,
|
|
78
|
+
writable,
|
|
79
|
+
},
|
|
80
|
+
capture,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=rawStreamCapture.js.map
|
|
@@ -1,18 +1,44 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Proxy Request Logger
|
|
3
3
|
* Logs proxy request/response metadata to a rotating log file.
|
|
4
|
+
* Also emits OTLP log records to OpenObserve (or any OTLP-compatible backend)
|
|
5
|
+
* when a LoggerProvider is configured via OpenTelemetry instrumentation.
|
|
4
6
|
* Useful for debugging and auditing proxy traffic.
|
|
5
7
|
*/
|
|
6
|
-
import type { RequestLogEntry } from "../types/index.js";
|
|
8
|
+
import type { RequestAttemptLogEntry, RequestLogEntry } from "../types/index.js";
|
|
7
9
|
export declare function initRequestLogger(enabled?: boolean): void;
|
|
8
10
|
export declare function logRequest(entry: RequestLogEntry): Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* Log an upstream attempt separately from the final request outcome.
|
|
13
|
+
* Attempt logs are local-only and must not pollute the final request summary
|
|
14
|
+
* or OTLP-derived dashboard panels.
|
|
15
|
+
*/
|
|
16
|
+
export declare function logRequestAttempt(entry: RequestAttemptLogEntry): Promise<void>;
|
|
9
17
|
export declare function getLogDir(): string | null;
|
|
18
|
+
type ProxyBodyCaptureEntry = {
|
|
19
|
+
timestamp: string;
|
|
20
|
+
requestId: string;
|
|
21
|
+
phase: string;
|
|
22
|
+
model: string;
|
|
23
|
+
stream: boolean;
|
|
24
|
+
headers?: Record<string, string>;
|
|
25
|
+
body?: unknown;
|
|
26
|
+
bodySize?: number;
|
|
27
|
+
contentType?: string;
|
|
28
|
+
responseStatus?: number;
|
|
29
|
+
durationMs?: number;
|
|
30
|
+
account?: string;
|
|
31
|
+
accountType?: string;
|
|
32
|
+
attempt?: number;
|
|
33
|
+
traceId?: string;
|
|
34
|
+
spanId?: string;
|
|
35
|
+
metadata?: Record<string, unknown>;
|
|
36
|
+
};
|
|
37
|
+
export declare function logBodyCapture(entry: ProxyBodyCaptureEntry): Promise<void>;
|
|
10
38
|
/**
|
|
11
39
|
* Log the FULL raw request and response for debugging.
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* Sensitive headers and body fields are redacted before writing.
|
|
40
|
+
* Legacy helper kept for compatibility. New call sites should prefer
|
|
41
|
+
* logBodyCapture() so each phase can be indexed and persisted separately.
|
|
16
42
|
*/
|
|
17
43
|
export declare function logFullRequestResponse(entry: {
|
|
18
44
|
timestamp: string;
|
|
@@ -48,3 +74,4 @@ export declare function logStreamError(entry: {
|
|
|
48
74
|
* Non-fatal — proxy keeps working even if cleanup fails.
|
|
49
75
|
*/
|
|
50
76
|
export declare function cleanupLogs(maxAgeDays?: number, maxSizeMb?: number): void;
|
|
77
|
+
export {};
|