@juspay/neurolink 9.67.0 → 9.67.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.
@@ -366,12 +366,13 @@ const createVertexSettings = async (region) => {
366
366
  return baseSettings;
367
367
  };
368
368
  // Create Anthropic-specific Vertex settings for native @anthropic-ai/vertex-sdk
369
- const createVertexAnthropicSettings = async (region) => {
369
+ const createVertexAnthropicSettings = async (region, timeoutMs) => {
370
370
  const location = region || getVertexLocation();
371
371
  const project = getVertexProjectId();
372
372
  return {
373
373
  projectId: project,
374
374
  region: location,
375
+ ...(timeoutMs !== undefined && { timeout: timeoutMs }),
375
376
  };
376
377
  };
377
378
  // Helper function to determine if a model is an Anthropic model
@@ -2032,9 +2033,9 @@ export class GoogleVertexProvider extends BaseProvider {
2032
2033
  /**
2033
2034
  * Create native AnthropicVertex client for Claude models
2034
2035
  */
2035
- async createAnthropicVertexClient() {
2036
+ async createAnthropicVertexClient(timeoutMs) {
2036
2037
  const mod = await getAnthropicVertexModule();
2037
- const settings = await createVertexAnthropicSettings(this.location);
2038
+ const settings = await createVertexAnthropicSettings(this.location, timeoutMs);
2038
2039
  return new mod.AnthropicVertex(settings);
2039
2040
  }
2040
2041
  /**
@@ -2042,9 +2043,10 @@ export class GoogleVertexProvider extends BaseProvider {
2042
2043
  * This bypasses @ai-sdk/google-vertex completely and uses Anthropic's native SDK
2043
2044
  */
2044
2045
  async executeNativeAnthropicStream(options) {
2045
- const client = await this.createAnthropicVertexClient();
2046
2046
  const modelName = options.model || this.modelName || "claude-sonnet-4-5@20250929";
2047
2047
  const startTime = Date.now();
2048
+ const streamTimeoutMs = parseTimeout(options.timeout) ?? 300_000;
2049
+ const client = await this.createAnthropicVertexClient(streamTimeoutMs);
2048
2050
  logger.debug("[GoogleVertex] Using native @anthropic-ai/vertex-sdk for Claude stream", {
2049
2051
  model: modelName,
2050
2052
  project: this.projectId,
@@ -2336,7 +2338,6 @@ export class GoogleVertexProvider extends BaseProvider {
2336
2338
  // abort the stream after the configured timeout so a stalled
2337
2339
  // Vertex/Anthropic endpoint can't hang forever. options.timeout wins
2338
2340
  // if set; otherwise 5 min — generous for tool-heavy turns.
2339
- const streamTimeoutMs = parseTimeout(options.timeout) ?? 300_000;
2340
2341
  const streamTimeoutHandle = setTimeout(() => {
2341
2342
  logger.warn(`[GoogleVertex] Anthropic stream exceeded ${streamTimeoutMs}ms — aborting`);
2342
2343
  abortHandler();
@@ -2560,9 +2561,10 @@ export class GoogleVertexProvider extends BaseProvider {
2560
2561
  * Execute generate using native @anthropic-ai/vertex-sdk for Claude models on Vertex AI
2561
2562
  */
2562
2563
  async executeNativeAnthropicGenerate(options) {
2563
- const client = await this.createAnthropicVertexClient();
2564
2564
  const modelName = options.model || this.modelName || "claude-sonnet-4-5@20250929";
2565
2565
  const startTime = Date.now();
2566
+ const generateTimeoutMs = parseTimeout(options.timeout) ?? 300_000;
2567
+ const client = await this.createAnthropicVertexClient(generateTimeoutMs);
2566
2568
  logger.debug("[GoogleVertex] Using native @anthropic-ai/vertex-sdk for Claude generate", {
2567
2569
  model: modelName,
2568
2570
  project: this.projectId,
@@ -2826,7 +2828,6 @@ export class GoogleVertexProvider extends BaseProvider {
2826
2828
  // Bound the SDK wait so a stalled Vertex/Anthropic call can't hang
2827
2829
  // generate forever. options.timeout wins if set, otherwise default
2828
2830
  // to 5 min — generous for tool-heavy turns.
2829
- const generateTimeoutMs = parseTimeout(options.timeout) ?? 300_000;
2830
2831
  const response = await withTimeout(client.messages.create({
2831
2832
  ...requestParams,
2832
2833
  messages: currentMessages,
@@ -1,15 +1,15 @@
1
- import type { ZodType } from "zod";
2
1
  import type { AIProviderName } from "../constants/enums.js";
3
2
  import { BaseProvider } from "../core/baseProvider.js";
4
- import type { StreamOptions, StreamResult } from "../types/index.js";
5
- import type { LanguageModel, Schema } from "../types/index.js";
3
+ import type { LanguageModel, Schema, StreamOptions, StreamResult, ZodUnknownSchema } from "../types/index.js";
6
4
  /**
7
- * LiteLLM Provider - BaseProvider Implementation
8
- * Provides access to 100+ models via LiteLLM proxy server
5
+ * LiteLLM Provider direct HTTP, no AI SDK. Talks to a LiteLLM proxy
6
+ * server (or any deployment that speaks OpenAI chat-completions + the
7
+ * `/v1/models` and `/v1/embeddings` endpoints).
9
8
  */
10
9
  export declare class LiteLLMProvider extends BaseProvider {
11
- private model;
10
+ private config;
12
11
  private credentials?;
12
+ private resolvedModel?;
13
13
  private static modelsCache;
14
14
  private static modelsCacheTime;
15
15
  private static readonly MODELS_CACHE_DURATION;
@@ -20,38 +20,45 @@ export declare class LiteLLMProvider extends BaseProvider {
20
20
  protected getProviderName(): AIProviderName;
21
21
  protected getDefaultModel(): string;
22
22
  /**
23
- * Returns the Vercel AI SDK model instance for LiteLLM
23
+ * Abstract from BaseProvider used by the parent's generate() path which
24
+ * still goes through `generateText`. Returns a thin LanguageModelV3-shaped
25
+ * object that delegates to the same HTTP helpers used by executeStream.
24
26
  */
25
- protected getAISDKModel(): LanguageModel;
26
- formatProviderError(error: unknown): Error;
27
+ protected getAISDKModel(): Promise<LanguageModel>;
28
+ private resolveModelName;
27
29
  /**
28
- * LiteLLM supports tools for compatible models
30
+ * Returns a minimal V3-shaped model. Only used by BaseProvider's
31
+ * `generate()` non-streaming path which still relies on the parent's
32
+ * `generateText`. The streaming path bypasses this entirely.
29
33
  */
34
+ private buildDelegatingModel;
35
+ formatProviderError(error: unknown): Error;
30
36
  supportsTools(): boolean;
31
37
  /**
32
- * Provider-specific streaming implementation
33
- * Note: This is only used when tools are disabled
38
+ * Streaming path — drives the LiteLLM proxy directly. No streamText, no
39
+ * AI SDK orchestrator. Tool calls, multi-step loops, telemetry, abort
40
+ * handling all inline. OTel span captures gen_ai.system + cost.
34
41
  */
35
- protected executeStream(options: StreamOptions, analysisSchema?: ZodType | Schema<unknown>): Promise<StreamResult>;
36
- private createLiteLLMTransformedStream;
42
+ protected executeStream(options: StreamOptions, _analysisSchema?: ZodUnknownSchema | Schema<unknown>): Promise<StreamResult>;
43
+ private runStreamLoop;
44
+ private streamOneStep;
45
+ private executeToolBatch;
37
46
  /**
38
- * Generate an embedding for a single text input
39
- * Uses the LiteLLM proxy with OpenAI-compatible embedding API
47
+ * Generate an embedding for a single text input via native /v1/embeddings.
40
48
  */
41
49
  embed(text: string, modelName?: string): Promise<number[]>;
42
50
  /**
43
- * Generate embeddings for multiple text inputs
44
- * Uses the LiteLLM proxy with OpenAI-compatible embedding API
51
+ * Generate embeddings for multiple text inputs via native /v1/embeddings.
45
52
  */
46
53
  embedMany(texts: string[], modelName?: string): Promise<number[][]>;
54
+ private callEmbeddings;
47
55
  /**
48
- * Get available models from LiteLLM proxy server
49
- * Dynamically fetches from /v1/models endpoint with caching and fallback
56
+ * Get available models from LiteLLM proxy `/v1/models` endpoint.
57
+ * Caches results for 10 minutes; falls back to env-driven list or a
58
+ * minimal safe default if the API fetch fails.
50
59
  */
51
60
  getAvailableModels(): Promise<string[]>;
52
- /**
53
- * Fetch available models from LiteLLM proxy /v1/models endpoint
54
- * @private
55
- */
61
+ getFirstAvailableModel(): Promise<string>;
62
+ private getFallbackModels;
56
63
  private fetchModelsFromAPI;
57
64
  }