@juspay/neurolink 9.80.2 → 9.80.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/browser/neurolink.min.js +355 -351
- package/dist/context/stages/structuredSummarizer.js +15 -4
- package/dist/core/modules/GenerationHandler.js +28 -10
- package/dist/core/modules/structuredOutputPolicy.d.ts +19 -0
- package/dist/core/modules/structuredOutputPolicy.js +26 -0
- package/dist/lib/context/stages/structuredSummarizer.js +15 -4
- package/dist/lib/core/modules/GenerationHandler.js +28 -10
- package/dist/lib/core/modules/structuredOutputPolicy.d.ts +19 -0
- package/dist/lib/core/modules/structuredOutputPolicy.js +26 -0
- package/dist/lib/mcp/externalServerManager.js +21 -6
- package/dist/lib/mcp/mcpClientFactory.js +5 -1
- package/dist/lib/neurolink.js +58 -25
- package/dist/lib/providers/googleVertex.d.ts +11 -0
- package/dist/lib/providers/googleVertex.js +706 -38
- package/dist/lib/types/generate.d.ts +13 -0
- package/dist/lib/types/stream.d.ts +1 -0
- package/dist/lib/utils/conversationMemory.js +19 -8
- package/dist/lib/utils/logSanitize.d.ts +26 -0
- package/dist/lib/utils/logSanitize.js +56 -0
- package/dist/mcp/externalServerManager.js +21 -6
- package/dist/mcp/mcpClientFactory.js +5 -1
- package/dist/neurolink.js +58 -25
- package/dist/providers/googleVertex.d.ts +11 -0
- package/dist/providers/googleVertex.js +706 -38
- package/dist/types/generate.d.ts +13 -0
- package/dist/types/stream.d.ts +1 -0
- package/dist/utils/conversationMemory.js +19 -8
- package/dist/utils/logSanitize.d.ts +26 -0
- package/dist/utils/logSanitize.js +56 -0
- package/package.json +2 -1
package/dist/types/generate.d.ts
CHANGED
|
@@ -296,6 +296,19 @@ export type GenerateOptions = {
|
|
|
296
296
|
* ```
|
|
297
297
|
*/
|
|
298
298
|
enabledToolNames?: string[];
|
|
299
|
+
/**
|
|
300
|
+
* Request timeout (e.g. 30000, '30s', '2m').
|
|
301
|
+
*
|
|
302
|
+
* PER-STEP semantics in agentic loops: on providers that run a native
|
|
303
|
+
* multi-step tool loop (Vertex Gemini / Vertex Claude), this bounds EACH
|
|
304
|
+
* model call in the loop, not the whole turn — a tool-heavy turn may run
|
|
305
|
+
* far longer than this value in total. Size it for the slowest single
|
|
306
|
+
* step (default 300s), and use `abortSignal` for a total-turn deadline.
|
|
307
|
+
*
|
|
308
|
+
* When set explicitly, a step timeout is surfaced immediately instead of
|
|
309
|
+
* burning internal retries/fallbacks that would re-run the same
|
|
310
|
+
* provider+model with the same doomed budget.
|
|
311
|
+
*/
|
|
299
312
|
timeout?: number | string;
|
|
300
313
|
/** AbortSignal for external cancellation of the AI call */
|
|
301
314
|
abortSignal?: AbortSignal;
|
package/dist/types/stream.d.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { SpanKind, SpanStatusCode } from "@opentelemetry/api";
|
|
6
6
|
import { tracers } from "../telemetry/tracers.js";
|
|
7
7
|
import { withTimeout } from "./errorHandling.js";
|
|
8
|
+
import { safeDebugSerialize, sanitizeRecord } from "./logSanitize.js";
|
|
8
9
|
import { DEFAULT_FALLBACK_THRESHOLD, getConversationMemoryDefaults, MEMORY_THRESHOLD_PERCENTAGE, } from "../config/conversationMemory.js";
|
|
9
10
|
import { getAvailableInputTokens } from "../constants/contextWindows.js";
|
|
10
11
|
import { buildSummarizationPrompt } from "../context/prompts/summarizationPrompt.js";
|
|
@@ -106,20 +107,30 @@ export function applyConversationMemoryDefaults(userConfig) {
|
|
|
106
107
|
* Get conversation history as message array, summarizing if needed.
|
|
107
108
|
*/
|
|
108
109
|
export async function getConversationMessages(conversationMemory, options) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
110
|
+
// Logger Guard: options carries the full conversation history + tool
|
|
111
|
+
// outputs; eager JSON.stringify of it can throw RangeError: Invalid string
|
|
112
|
+
// length and abort the turn. Serialize lazily, bounded, never-throwing,
|
|
113
|
+
// and redacted (sanitizeRecord strips credential/PII keys).
|
|
114
|
+
if (logger.shouldLog("debug")) {
|
|
115
|
+
logger.debug("[conversationMemoryUtils] getConversationMessages called", {
|
|
116
|
+
hasMemory: !!conversationMemory,
|
|
117
|
+
memoryType: conversationMemory?.constructor?.name || "NONE",
|
|
118
|
+
hasContext: !!options.context,
|
|
119
|
+
enableSummarization: options.enableSummarization ?? false,
|
|
120
|
+
options: safeDebugSerialize(sanitizeRecord(options)),
|
|
121
|
+
});
|
|
122
|
+
}
|
|
116
123
|
if (!conversationMemory || !options.context) {
|
|
117
124
|
logger.warn("[conversationMemoryUtils] No memory or context, returning empty messages", {
|
|
118
125
|
hasMemory: !!conversationMemory,
|
|
119
126
|
memoryType: conversationMemory?.constructor?.name || "NONE",
|
|
120
127
|
hasContext: !!options.context,
|
|
121
128
|
enableSummarization: options.enableSummarization ?? false,
|
|
122
|
-
options
|
|
129
|
+
// The options dump is debug-grade detail — don't pay for (or leak)
|
|
130
|
+
// the serialization on every memory-disabled call at warn level.
|
|
131
|
+
...(logger.shouldLog("debug")
|
|
132
|
+
? { options: safeDebugSerialize(sanitizeRecord(options)) }
|
|
133
|
+
: {}),
|
|
123
134
|
});
|
|
124
135
|
return [];
|
|
125
136
|
}
|
|
@@ -26,6 +26,32 @@
|
|
|
26
26
|
* @param maxLen - Maximum number of characters to keep (default 500).
|
|
27
27
|
*/
|
|
28
28
|
export declare function sanitizeForLog(text: string, maxLen?: number): string;
|
|
29
|
+
/**
|
|
30
|
+
* Stringify non-string message/tool content without ever throwing.
|
|
31
|
+
* JSON.stringify on a giant multimodal/tool-result payload can exceed V8's
|
|
32
|
+
* maximum string length and throw `RangeError: Invalid string length` — a
|
|
33
|
+
* generation turn must degrade to a placeholder, not abort, when that
|
|
34
|
+
* happens. Shared by the SDK core and providers (single source of truth).
|
|
35
|
+
*/
|
|
36
|
+
export declare function stringifyContentSafe(content: unknown): string;
|
|
37
|
+
/**
|
|
38
|
+
* Serialize an arbitrary value for a debug log without ever throwing or
|
|
39
|
+
* producing an unbounded string.
|
|
40
|
+
*
|
|
41
|
+
* `JSON.stringify` on a full options object (conversation history + tool
|
|
42
|
+
* outputs) can exceed V8's maximum string length and throw
|
|
43
|
+
* `RangeError: Invalid string length`, which — when evaluated eagerly inside
|
|
44
|
+
* a logger call — aborts the surrounding generation turn (observed in
|
|
45
|
+
* production). This helper caps the output and converts any stringify
|
|
46
|
+
* failure (RangeError, circular structure, BigInt, …) into a placeholder.
|
|
47
|
+
*
|
|
48
|
+
* Callers MUST still gate on `logger.shouldLog("debug")` per the Logger
|
|
49
|
+
* Guard rule — this helper makes serialization safe, not free.
|
|
50
|
+
*
|
|
51
|
+
* @param value - Arbitrary value to serialize.
|
|
52
|
+
* @param maxLen - Maximum number of characters to keep (default 10 000).
|
|
53
|
+
*/
|
|
54
|
+
export declare function safeDebugSerialize(value: unknown, maxLen?: number): string;
|
|
29
55
|
/**
|
|
30
56
|
* Strip embedded `user:pass@` credentials from a URL's authority component
|
|
31
57
|
* before logging it or surfacing it in a user-facing error.
|
|
@@ -74,6 +74,13 @@ const SENSITIVE_OBJECT_KEYS = [
|
|
|
74
74
|
"oauth",
|
|
75
75
|
"oauthToken",
|
|
76
76
|
"credentials",
|
|
77
|
+
"authContext",
|
|
78
|
+
"authToken",
|
|
79
|
+
"sessionToken",
|
|
80
|
+
"serviceAccountKey",
|
|
81
|
+
"secretAccessKey",
|
|
82
|
+
// PII, not a secret — but it has no business in debug log dumps.
|
|
83
|
+
"userEmail",
|
|
77
84
|
];
|
|
78
85
|
/**
|
|
79
86
|
* Truncate `text` to `maxLen` chars then replace embedded secrets with `***`.
|
|
@@ -91,6 +98,55 @@ export function sanitizeForLog(text, maxLen = 500) {
|
|
|
91
98
|
}
|
|
92
99
|
return text.slice(0, maxLen).replace(SECRET_PATTERN, "***");
|
|
93
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Stringify non-string message/tool content without ever throwing.
|
|
103
|
+
* JSON.stringify on a giant multimodal/tool-result payload can exceed V8's
|
|
104
|
+
* maximum string length and throw `RangeError: Invalid string length` — a
|
|
105
|
+
* generation turn must degrade to a placeholder, not abort, when that
|
|
106
|
+
* happens. Shared by the SDK core and providers (single source of truth).
|
|
107
|
+
*/
|
|
108
|
+
export function stringifyContentSafe(content) {
|
|
109
|
+
if (typeof content === "string") {
|
|
110
|
+
return content;
|
|
111
|
+
}
|
|
112
|
+
try {
|
|
113
|
+
return JSON.stringify(content) ?? String(content);
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
return "[content too large to serialize]";
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Serialize an arbitrary value for a debug log without ever throwing or
|
|
121
|
+
* producing an unbounded string.
|
|
122
|
+
*
|
|
123
|
+
* `JSON.stringify` on a full options object (conversation history + tool
|
|
124
|
+
* outputs) can exceed V8's maximum string length and throw
|
|
125
|
+
* `RangeError: Invalid string length`, which — when evaluated eagerly inside
|
|
126
|
+
* a logger call — aborts the surrounding generation turn (observed in
|
|
127
|
+
* production). This helper caps the output and converts any stringify
|
|
128
|
+
* failure (RangeError, circular structure, BigInt, …) into a placeholder.
|
|
129
|
+
*
|
|
130
|
+
* Callers MUST still gate on `logger.shouldLog("debug")` per the Logger
|
|
131
|
+
* Guard rule — this helper makes serialization safe, not free.
|
|
132
|
+
*
|
|
133
|
+
* @param value - Arbitrary value to serialize.
|
|
134
|
+
* @param maxLen - Maximum number of characters to keep (default 10 000).
|
|
135
|
+
*/
|
|
136
|
+
export function safeDebugSerialize(value, maxLen = 10_000) {
|
|
137
|
+
try {
|
|
138
|
+
const json = JSON.stringify(value);
|
|
139
|
+
if (json === undefined) {
|
|
140
|
+
return String(value);
|
|
141
|
+
}
|
|
142
|
+
return json.length > maxLen
|
|
143
|
+
? `${json.slice(0, maxLen)}…[truncated ${json.length - maxLen} chars]`
|
|
144
|
+
: json;
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
return `[unserializable: ${error instanceof Error ? error.message : String(error)}]`;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
94
150
|
/**
|
|
95
151
|
* Strip embedded `user:pass@` credentials from a URL's authority component
|
|
96
152
|
* before logging it or surfacing it in a user-facing error.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juspay/neurolink",
|
|
3
|
-
"version": "9.80.
|
|
3
|
+
"version": "9.80.4",
|
|
4
4
|
"packageManager": "pnpm@10.15.1",
|
|
5
5
|
"description": "Universal AI Development Platform with working MCP integration, multi-provider support, voice (TTS/STT/realtime), and professional CLI. 58+ external MCP servers discoverable, multimodal file processing, RAG pipelines. Build, test, and deploy AI applications with 21+ providers: OpenAI, Anthropic, Google AI Studio, Google Vertex, AWS Bedrock, Azure OpenAI, Mistral, LiteLLM, SageMaker, Hugging Face, Ollama, OpenAI-compatible, OpenRouter, DeepSeek, NVIDIA NIM, LM Studio, llama.cpp, plus voice (OpenAI TTS, ElevenLabs, Deepgram, Azure Speech).",
|
|
6
6
|
"author": {
|
|
@@ -96,6 +96,7 @@
|
|
|
96
96
|
"test:tool-reliability": "npx tsx test/continuous-test-suite-tool-reliability.ts",
|
|
97
97
|
"test:google-native": "npx tsx test/continuous-test-suite-google-native.ts",
|
|
98
98
|
"test:gemini-abort": "npx tsx test/continuous-test-suite-gemini-abort.ts",
|
|
99
|
+
"test:anthropic-cap": "npx tsx test/continuous-test-suite-anthropic-cap.ts",
|
|
99
100
|
"test:tts": "npx tsx test/continuous-test-suite-tts.ts",
|
|
100
101
|
"test:voice": "npx tsx test/continuous-test-suite-voice.ts",
|
|
101
102
|
"test:voice-server": "npx tsx test/continuous-test-suite-voice-server.ts",
|