@juspay/neurolink 9.51.1 → 9.51.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.
@@ -4,7 +4,7 @@ import { stepCountIs, streamText } from "ai";
4
4
  import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync, } from "fs";
5
5
  import { homedir } from "os";
6
6
  import { join } from "path";
7
- import { ANTHROPIC_TOKEN_URL, CLAUDE_CLI_USER_AGENT, CLAUDE_CODE_CLIENT_ID, } from "../auth/anthropicOAuth.js";
7
+ import { ANTHROPIC_TOKEN_URL, CLAUDE_CLI_USER_AGENT, CLAUDE_CODE_CLIENT_ID, CLAUDE_CODE_OAUTH_BETAS, } from "../auth/anthropicOAuth.js";
8
8
  import { AnthropicModels, TOKEN_EXPIRY_BUFFER_MS, } from "../constants/enums.js";
9
9
  import { BaseProvider } from "../core/baseProvider.js";
10
10
  import { DEFAULT_MAX_STEPS } from "../core/constants.js";
@@ -310,6 +310,9 @@ export class AnthropicProvider extends BaseProvider {
310
310
  anthropic = createAnthropic({
311
311
  apiKey: apiKeyToUse,
312
312
  headers,
313
+ ...(process.env.ANTHROPIC_BASE_URL && {
314
+ baseURL: process.env.ANTHROPIC_BASE_URL,
315
+ }),
313
316
  fetch: createProxyFetch(),
314
317
  });
315
318
  logger.debug("Anthropic Provider initialized with API key", {
@@ -354,9 +357,23 @@ export class AnthropicProvider extends BaseProvider {
354
357
  */
355
358
  getAuthHeaders() {
356
359
  const headers = {};
357
- // Add beta headers if enabled
360
+ // When routing through proxy (ANTHROPIC_BASE_URL set), use the full
361
+ // OAuth beta set so the proxy forwards them upstream. Without these,
362
+ // Anthropic treats the request with tighter non-subscription rate limits.
363
+ const usingProxy = !!process.env.ANTHROPIC_BASE_URL;
358
364
  if (this.enableBetaFeatures) {
359
- headers["anthropic-beta"] = ANTHROPIC_BETA_HEADERS["anthropic-beta"];
365
+ if (usingProxy) {
366
+ headers["anthropic-beta"] = [
367
+ ...CLAUDE_CODE_OAUTH_BETAS,
368
+ "fine-grained-tool-streaming-2025-05-14",
369
+ "context-1m-2025-08-07",
370
+ "interleaved-thinking-2025-05-14",
371
+ "redact-thinking-2026-02-12",
372
+ ].join(",");
373
+ }
374
+ else {
375
+ headers["anthropic-beta"] = ANTHROPIC_BETA_HEADERS["anthropic-beta"];
376
+ }
360
377
  }
361
378
  // Add subscription-specific headers if applicable
362
379
  if (this.subscriptionTier !== "api") {
@@ -2,7 +2,7 @@ const STREAMING_CONVERSATIONAL_TOOL_THRESHOLD = 4;
2
2
  const STRONG_TOOL_FIDELITY_THRESHOLD = 8;
3
3
  const HIGH_TOOL_COUNT_THRESHOLD = 24;
4
4
  const DEFAULT_COOLDOWN_FLOOR_MS = 1_000;
5
- const HIGH_TOOL_COUNT_COOLDOWN_FLOOR_MS = 120_000;
5
+ const HIGH_TOOL_COUNT_COOLDOWN_FLOOR_MS = 10_000;
6
6
  const HIGH_FIDELITY_COOLDOWN_FLOOR_MS = 300_000;
7
7
  export function inferClaudeProxyModelTier(modelName) {
8
8
  const normalized = modelName.toLowerCase();
@@ -221,10 +221,15 @@ export function applyRateLimitCooldownScope(args) {
221
221
  const rcBackoffLevels = args.state.requestClassBackoffLevels ?? {};
222
222
  const mtBackoffLevels = args.state.modelTierBackoffLevels ?? {};
223
223
  const scopedBackoffLevel = Math.max(rcBackoffLevels[requestClassKey] ?? 0, mtBackoffLevels[modelTierKey] ?? 0);
224
- const floorMs = args.profile.modelTier === "opus" || args.profile.requiresStrongToolFidelity
225
- ? HIGH_FIDELITY_COOLDOWN_FLOOR_MS
226
- : args.profile.isHighToolCountNonStream
227
- ? HIGH_TOOL_COUNT_COOLDOWN_FLOOR_MS
224
+ // High-tool-count-non-stream gets its own (lower) floor so that requests
225
+ // recover faster once proper OAuth betas are forwarded. Check it first
226
+ // because every >=24-tool request also satisfies requiresStrongToolFidelity
227
+ // (threshold 8), which would otherwise shadow this branch.
228
+ const floorMs = args.profile.isHighToolCountNonStream
229
+ ? HIGH_TOOL_COUNT_COOLDOWN_FLOOR_MS
230
+ : args.profile.modelTier === "opus" ||
231
+ args.profile.requiresStrongToolFidelity
232
+ ? HIGH_FIDELITY_COOLDOWN_FLOOR_MS
228
233
  : DEFAULT_COOLDOWN_FLOOR_MS;
229
234
  const baseCooldownMs = Math.max(args.retryAfterMs ?? 0, floorMs);
230
235
  const backoffMs = Math.min(baseCooldownMs * 2 ** scopedBackoffLevel, args.capMs);
@@ -4,7 +4,7 @@ import { stepCountIs, streamText } from "ai";
4
4
  import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync, } from "fs";
5
5
  import { homedir } from "os";
6
6
  import { join } from "path";
7
- import { ANTHROPIC_TOKEN_URL, CLAUDE_CLI_USER_AGENT, CLAUDE_CODE_CLIENT_ID, } from "../auth/anthropicOAuth.js";
7
+ import { ANTHROPIC_TOKEN_URL, CLAUDE_CLI_USER_AGENT, CLAUDE_CODE_CLIENT_ID, CLAUDE_CODE_OAUTH_BETAS, } from "../auth/anthropicOAuth.js";
8
8
  import { AnthropicModels, TOKEN_EXPIRY_BUFFER_MS, } from "../constants/enums.js";
9
9
  import { BaseProvider } from "../core/baseProvider.js";
10
10
  import { DEFAULT_MAX_STEPS } from "../core/constants.js";
@@ -310,6 +310,9 @@ export class AnthropicProvider extends BaseProvider {
310
310
  anthropic = createAnthropic({
311
311
  apiKey: apiKeyToUse,
312
312
  headers,
313
+ ...(process.env.ANTHROPIC_BASE_URL && {
314
+ baseURL: process.env.ANTHROPIC_BASE_URL,
315
+ }),
313
316
  fetch: createProxyFetch(),
314
317
  });
315
318
  logger.debug("Anthropic Provider initialized with API key", {
@@ -354,9 +357,23 @@ export class AnthropicProvider extends BaseProvider {
354
357
  */
355
358
  getAuthHeaders() {
356
359
  const headers = {};
357
- // Add beta headers if enabled
360
+ // When routing through proxy (ANTHROPIC_BASE_URL set), use the full
361
+ // OAuth beta set so the proxy forwards them upstream. Without these,
362
+ // Anthropic treats the request with tighter non-subscription rate limits.
363
+ const usingProxy = !!process.env.ANTHROPIC_BASE_URL;
358
364
  if (this.enableBetaFeatures) {
359
- headers["anthropic-beta"] = ANTHROPIC_BETA_HEADERS["anthropic-beta"];
365
+ if (usingProxy) {
366
+ headers["anthropic-beta"] = [
367
+ ...CLAUDE_CODE_OAUTH_BETAS,
368
+ "fine-grained-tool-streaming-2025-05-14",
369
+ "context-1m-2025-08-07",
370
+ "interleaved-thinking-2025-05-14",
371
+ "redact-thinking-2026-02-12",
372
+ ].join(",");
373
+ }
374
+ else {
375
+ headers["anthropic-beta"] = ANTHROPIC_BETA_HEADERS["anthropic-beta"];
376
+ }
360
377
  }
361
378
  // Add subscription-specific headers if applicable
362
379
  if (this.subscriptionTier !== "api") {
@@ -2,7 +2,7 @@ const STREAMING_CONVERSATIONAL_TOOL_THRESHOLD = 4;
2
2
  const STRONG_TOOL_FIDELITY_THRESHOLD = 8;
3
3
  const HIGH_TOOL_COUNT_THRESHOLD = 24;
4
4
  const DEFAULT_COOLDOWN_FLOOR_MS = 1_000;
5
- const HIGH_TOOL_COUNT_COOLDOWN_FLOOR_MS = 120_000;
5
+ const HIGH_TOOL_COUNT_COOLDOWN_FLOOR_MS = 10_000;
6
6
  const HIGH_FIDELITY_COOLDOWN_FLOOR_MS = 300_000;
7
7
  export function inferClaudeProxyModelTier(modelName) {
8
8
  const normalized = modelName.toLowerCase();
@@ -221,10 +221,15 @@ export function applyRateLimitCooldownScope(args) {
221
221
  const rcBackoffLevels = args.state.requestClassBackoffLevels ?? {};
222
222
  const mtBackoffLevels = args.state.modelTierBackoffLevels ?? {};
223
223
  const scopedBackoffLevel = Math.max(rcBackoffLevels[requestClassKey] ?? 0, mtBackoffLevels[modelTierKey] ?? 0);
224
- const floorMs = args.profile.modelTier === "opus" || args.profile.requiresStrongToolFidelity
225
- ? HIGH_FIDELITY_COOLDOWN_FLOOR_MS
226
- : args.profile.isHighToolCountNonStream
227
- ? HIGH_TOOL_COUNT_COOLDOWN_FLOOR_MS
224
+ // High-tool-count-non-stream gets its own (lower) floor so that requests
225
+ // recover faster once proper OAuth betas are forwarded. Check it first
226
+ // because every >=24-tool request also satisfies requiresStrongToolFidelity
227
+ // (threshold 8), which would otherwise shadow this branch.
228
+ const floorMs = args.profile.isHighToolCountNonStream
229
+ ? HIGH_TOOL_COUNT_COOLDOWN_FLOOR_MS
230
+ : args.profile.modelTier === "opus" ||
231
+ args.profile.requiresStrongToolFidelity
232
+ ? HIGH_FIDELITY_COOLDOWN_FLOOR_MS
228
233
  : DEFAULT_COOLDOWN_FLOOR_MS;
229
234
  const baseCooldownMs = Math.max(args.retryAfterMs ?? 0, floorMs);
230
235
  const backoffMs = Math.min(baseCooldownMs * 2 ** scopedBackoffLevel, args.capMs);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juspay/neurolink",
3
- "version": "9.51.1",
3
+ "version": "9.51.2",
4
4
  "packageManager": "pnpm@10.15.1",
5
5
  "description": "Universal AI Development Platform with working MCP integration, multi-provider support, and professional CLI. Built-in tools operational, 58+ external MCP servers discoverable. Connect to filesystem, GitHub, database operations, and more. Build, test, and deploy AI applications with 13 providers: OpenAI, Anthropic, Google AI, AWS Bedrock, Azure, Hugging Face, Ollama, and Mistral AI.",
6
6
  "author": {