@juspay/neurolink 9.80.0 → 9.80.2
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 +349 -349
- package/dist/core/constants.d.ts +2 -0
- package/dist/core/constants.js +2 -0
- package/dist/lib/core/constants.d.ts +2 -0
- package/dist/lib/core/constants.js +2 -0
- package/dist/lib/providers/googleNativeGemini3.d.ts +20 -2
- package/dist/lib/providers/googleNativeGemini3.js +37 -4
- package/dist/lib/providers/googleVertex.d.ts +5 -2
- package/dist/lib/providers/googleVertex.js +786 -518
- package/dist/providers/googleNativeGemini3.d.ts +20 -2
- package/dist/providers/googleNativeGemini3.js +37 -4
- package/dist/providers/googleVertex.d.ts +5 -2
- package/dist/providers/googleVertex.js +786 -518
- package/package.json +2 -1
package/dist/core/constants.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ export declare const DEFAULT_TEMPERATURE = 0.7;
|
|
|
21
21
|
export declare const DEFAULT_TIMEOUT = 60000;
|
|
22
22
|
export declare const DEFAULT_MAX_STEPS = 200;
|
|
23
23
|
export declare const DEFAULT_TOOL_MAX_RETRIES = 2;
|
|
24
|
+
/** Defensive wall-clock ceiling for a native Gemini-3 agentic turn (generate + stream). */
|
|
25
|
+
export declare const DEFAULT_GEMINI_STREAM_TIMEOUT_MS = 300000;
|
|
24
26
|
export declare const TOOL_STORAGE_TIMEOUT_MS = 5000;
|
|
25
27
|
export declare const STEP_LIMITS: {
|
|
26
28
|
min: number;
|
package/dist/core/constants.js
CHANGED
|
@@ -107,6 +107,8 @@ export const DEFAULT_TEMPERATURE = 0.7;
|
|
|
107
107
|
export const DEFAULT_TIMEOUT = 60000;
|
|
108
108
|
export const DEFAULT_MAX_STEPS = 200;
|
|
109
109
|
export const DEFAULT_TOOL_MAX_RETRIES = 2; // Maximum retries per tool before permanently failing
|
|
110
|
+
/** Defensive wall-clock ceiling for a native Gemini-3 agentic turn (generate + stream). */
|
|
111
|
+
export const DEFAULT_GEMINI_STREAM_TIMEOUT_MS = 300_000;
|
|
110
112
|
// Fire-and-forget tool storage writes (Redis). 5s is generous for a single
|
|
111
113
|
// Redis write; if breached, the .catch logs a warning.
|
|
112
114
|
export const TOOL_STORAGE_TIMEOUT_MS = 5000;
|
|
@@ -21,6 +21,8 @@ export declare const DEFAULT_TEMPERATURE = 0.7;
|
|
|
21
21
|
export declare const DEFAULT_TIMEOUT = 60000;
|
|
22
22
|
export declare const DEFAULT_MAX_STEPS = 200;
|
|
23
23
|
export declare const DEFAULT_TOOL_MAX_RETRIES = 2;
|
|
24
|
+
/** Defensive wall-clock ceiling for a native Gemini-3 agentic turn (generate + stream). */
|
|
25
|
+
export declare const DEFAULT_GEMINI_STREAM_TIMEOUT_MS = 300000;
|
|
24
26
|
export declare const TOOL_STORAGE_TIMEOUT_MS = 5000;
|
|
25
27
|
export declare const STEP_LIMITS: {
|
|
26
28
|
min: number;
|
|
@@ -107,6 +107,8 @@ export const DEFAULT_TEMPERATURE = 0.7;
|
|
|
107
107
|
export const DEFAULT_TIMEOUT = 60000;
|
|
108
108
|
export const DEFAULT_MAX_STEPS = 200;
|
|
109
109
|
export const DEFAULT_TOOL_MAX_RETRIES = 2; // Maximum retries per tool before permanently failing
|
|
110
|
+
/** Defensive wall-clock ceiling for a native Gemini-3 agentic turn (generate + stream). */
|
|
111
|
+
export const DEFAULT_GEMINI_STREAM_TIMEOUT_MS = 300_000;
|
|
110
112
|
// Fire-and-forget tool storage writes (Redis). 5s is generous for a single
|
|
111
113
|
// Redis write; if breached, the .catch logs a warning.
|
|
112
114
|
export const TOOL_STORAGE_TIMEOUT_MS = 5000;
|
|
@@ -195,12 +195,30 @@ export declare function executeNativeToolCalls(logLabel: string, stepFunctionCal
|
|
|
195
195
|
originalNameMap?: Map<string, string>;
|
|
196
196
|
}): Promise<NativeFunctionResponse[]>;
|
|
197
197
|
/**
|
|
198
|
-
* Handle maxSteps termination by producing a final
|
|
199
|
-
*
|
|
198
|
+
* Handle maxSteps termination by producing a final answer when the model was
|
|
199
|
+
* still calling tools as the step limit was reached.
|
|
200
|
+
*
|
|
201
|
+
* Resolution order (always returns a non-empty string): the caller's
|
|
202
|
+
* `finalText` if present; else the `lastStepText` gathered from the final step;
|
|
203
|
+
* else a graceful, user-facing cap message from {@link buildToolLoopCapMessage}
|
|
204
|
+
* — which replaced the legacy bracketed step-limit placeholder string.
|
|
200
205
|
*
|
|
201
206
|
* @param logLabel - Label for log messages (e.g. "[GoogleAIStudio]" or "[GoogleVertex]")
|
|
207
|
+
* @returns The resolved final answer text (never the legacy placeholder).
|
|
202
208
|
*/
|
|
203
209
|
export declare function handleMaxStepsTermination(logLabel: string, step: number, maxSteps: number, finalText: string, lastStepText: string): string;
|
|
210
|
+
/**
|
|
211
|
+
* Detect whether an error represents an abort/cancellation (from an
|
|
212
|
+
* AbortSignal firing during a fetch/stream drain). Used by the native
|
|
213
|
+
* Gemini-3 agentic loops to break gracefully rather than re-throw.
|
|
214
|
+
*/
|
|
215
|
+
export declare function isAbortError(error: unknown): boolean;
|
|
216
|
+
/**
|
|
217
|
+
* Build a graceful, user-facing message for when a single agentic turn hits
|
|
218
|
+
* the step cap (or is aborted mid-turn) without producing a final answer.
|
|
219
|
+
* Replaces the legacy bracketed "Tool execution limit reached" placeholder.
|
|
220
|
+
*/
|
|
221
|
+
export declare function buildToolLoopCapMessage(maxSteps: number, toolCallCount: number): string;
|
|
204
222
|
/**
|
|
205
223
|
* Push model response parts to conversation history, preserving thoughtSignature
|
|
206
224
|
* for Gemini 3 multi-turn tool calling.
|
|
@@ -795,20 +795,53 @@ export async function executeNativeToolCalls(logLabel, stepFunctionCalls, execut
|
|
|
795
795
|
return functionResponses;
|
|
796
796
|
}
|
|
797
797
|
/**
|
|
798
|
-
* Handle maxSteps termination by producing a final
|
|
799
|
-
*
|
|
798
|
+
* Handle maxSteps termination by producing a final answer when the model was
|
|
799
|
+
* still calling tools as the step limit was reached.
|
|
800
|
+
*
|
|
801
|
+
* Resolution order (always returns a non-empty string): the caller's
|
|
802
|
+
* `finalText` if present; else the `lastStepText` gathered from the final step;
|
|
803
|
+
* else a graceful, user-facing cap message from {@link buildToolLoopCapMessage}
|
|
804
|
+
* — which replaced the legacy bracketed step-limit placeholder string.
|
|
800
805
|
*
|
|
801
806
|
* @param logLabel - Label for log messages (e.g. "[GoogleAIStudio]" or "[GoogleVertex]")
|
|
807
|
+
* @returns The resolved final answer text (never the legacy placeholder).
|
|
802
808
|
*/
|
|
803
809
|
export function handleMaxStepsTermination(logLabel, step, maxSteps, finalText, lastStepText) {
|
|
804
810
|
if (step >= maxSteps && !finalText) {
|
|
805
811
|
logger.warn(`${logLabel} Tool call loop terminated after reaching maxSteps (${maxSteps}). ` +
|
|
806
812
|
`Model was still calling tools. Using accumulated text from last step.`);
|
|
807
|
-
return
|
|
808
|
-
`[Tool execution limit reached after ${maxSteps} steps. The model continued requesting tool calls beyond the limit.]`);
|
|
813
|
+
return lastStepText || buildToolLoopCapMessage(maxSteps, 0);
|
|
809
814
|
}
|
|
810
815
|
return finalText;
|
|
811
816
|
}
|
|
817
|
+
/**
|
|
818
|
+
* Detect whether an error represents an abort/cancellation (from an
|
|
819
|
+
* AbortSignal firing during a fetch/stream drain). Used by the native
|
|
820
|
+
* Gemini-3 agentic loops to break gracefully rather than re-throw.
|
|
821
|
+
*/
|
|
822
|
+
export function isAbortError(error) {
|
|
823
|
+
if (!error) {
|
|
824
|
+
return false;
|
|
825
|
+
}
|
|
826
|
+
const e = error;
|
|
827
|
+
return (e.name === "AbortError" ||
|
|
828
|
+
(typeof e.message === "string" && /abort/i.test(e.message)) ||
|
|
829
|
+
(typeof DOMException !== "undefined" &&
|
|
830
|
+
error instanceof DOMException &&
|
|
831
|
+
e.code === 20));
|
|
832
|
+
}
|
|
833
|
+
/**
|
|
834
|
+
* Build a graceful, user-facing message for when a single agentic turn hits
|
|
835
|
+
* the step cap (or is aborted mid-turn) without producing a final answer.
|
|
836
|
+
* Replaces the legacy bracketed "Tool execution limit reached" placeholder.
|
|
837
|
+
*/
|
|
838
|
+
export function buildToolLoopCapMessage(maxSteps, toolCallCount) {
|
|
839
|
+
const calls = toolCallCount > 0
|
|
840
|
+
? `I gathered information across ${toolCallCount} tool call${toolCallCount === 1 ? "" : "s"} but `
|
|
841
|
+
: "I ";
|
|
842
|
+
return (`${calls}reached the ${maxSteps}-step limit for a single turn before I could finish. ` +
|
|
843
|
+
`Please narrow the request or break it into smaller asks and I'll continue.`);
|
|
844
|
+
}
|
|
812
845
|
/**
|
|
813
846
|
* Push model response parts to conversation history, preserving thoughtSignature
|
|
814
847
|
* for Gemini 3 multi-turn tool calling.
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { ZodType } from "zod";
|
|
2
2
|
import { AIProviderName } from "../constants/enums.js";
|
|
3
3
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
|
-
import type { EnhancedGenerateResult, TextGenerationOptions, StreamOptions, StreamResult } from "../types/index.js";
|
|
4
|
+
import type { EnhancedGenerateResult, TextGenerationOptions, StreamOptions, StreamResult, VertexAnthropicMessage, ChatMessage, MinimalChatMessage } from "../types/index.js";
|
|
5
5
|
import type { Schema, LanguageModel } from "../types/index.js";
|
|
6
|
+
export declare function buildAnthropicHistoryMessages(conversationMessages: Array<ChatMessage | MinimalChatMessage>): VertexAnthropicMessage[];
|
|
7
|
+
export declare function appendUserMessage(messages: VertexAnthropicMessage[], content: VertexAnthropicMessage["content"]): void;
|
|
6
8
|
/**
|
|
7
9
|
* Recursively strip JSON-schema fields that Vertex Gemini's function-call AND
|
|
8
10
|
* `responseSchema` (structured output) validators reject with 400
|
|
@@ -173,7 +175,8 @@ export declare class GoogleVertexProvider extends BaseProvider {
|
|
|
173
175
|
* (`final_result`) pattern was active, a trailing instruction countermands the
|
|
174
176
|
* earlier "you MUST call final_result" directive so the model answers in plain
|
|
175
177
|
* text. Never throws — returns empty text so the caller falls back to the
|
|
176
|
-
*
|
|
178
|
+
* graceful cap message (buildToolLoopCapMessage), guaranteeing no new failure
|
|
179
|
+
* path.
|
|
177
180
|
*/
|
|
178
181
|
private synthesizeFinalAnswerWithoutTools;
|
|
179
182
|
/**
|