@juspay/neurolink 12.25.4 → 12.25.5

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.
@@ -18,7 +18,7 @@ import { logger } from "../../utils/logger.js";
18
18
  import { drainDetachedPump } from "../../utils/drainDetachedPump.js";
19
19
  import { ANTHROPIC_ELISION_NOTE, planAnthropicLoopReclaim, previewAnthropicToolResultText, } from "../../context/anthropicLoopGuard.js";
20
20
  import { getAvailableInputTokens } from "../../constants/contextWindows.js";
21
- import { estimateTokens } from "../../utils/tokenEstimation.js";
21
+ import { estimateTokens, serializeForEstimate, } from "../../utils/tokenEstimation.js";
22
22
  import { redactUrlCredentials } from "../../utils/logSanitize.js";
23
23
  import { ANTHROPIC_MAX_CACHE_BREAKPOINTS, applyAnthropicHistoryCacheBreakpoints, countAnthropicCacheMarkers, } from "../../utils/anthropicCacheBreakpoints.js";
24
24
  import { calculateCost } from "../../utils/pricing.js";
@@ -47,6 +47,7 @@ import { createStreamChannel } from "../../core/streamChannel.js";
47
47
  import { toNativeToolDeclarations } from "../../core/nativeToolFormat.js";
48
48
  import { ANTHROPIC_BETA_HEADERS } from "./constants.js";
49
49
  import { cacheControlOf, withLastToolCacheBreakpoint } from "./cacheControl.js";
50
+ import { createNativeGenerateGuard } from "../../context/nativeGenerateGuard.js";
50
51
  import { appendFinalResultInstruction, appendFinalResultTool, FINAL_RESULT_TOOL_NAME, } from "./structuredOutput.js";
51
52
  // AnthropicProviderConfig is imported from types/providers.ts
52
53
  // Re-export for backward compatibility
@@ -1527,6 +1528,21 @@ export class AnthropicProvider extends BaseProvider {
1527
1528
  const toolExecutionSummaries = [];
1528
1529
  const loop = await runNativeGenerateLoop({
1529
1530
  doGenerate,
1531
+ ...createNativeGenerateGuard({
1532
+ provider: "anthropic",
1533
+ availableInputTokens: getAvailableInputTokens("anthropic", modelId, options.maxTokens ?? undefined),
1534
+ // Runs on every step of the generate loop, so a cyclic or
1535
+ // oversized tool schema must not throw the turn away. Shares the
1536
+ // estimator's own serializer, matching the OpenAI-compatible
1537
+ // native guard's wiring: its fallback over-reports, which makes
1538
+ // the guard fire rather than silently size the overhead at
1539
+ // nothing.
1540
+ getFixedOverheadTokens: () => estimateTokens(serializeForEstimate({
1541
+ tools: v3Tools,
1542
+ responseFormat,
1543
+ providerOptions,
1544
+ }), "anthropic"),
1545
+ }),
1530
1546
  conversation,
1531
1547
  ...(hasTools ? { tools: v3Tools } : {}),
1532
1548
  toolsRecord,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juspay/neurolink",
3
- "version": "12.25.4",
3
+ "version": "12.25.5",
4
4
  "packageManager": "pnpm@10.15.1",
5
5
  "description": "The pipe layer of an AI nervous system: one interface connecting provider neurons to your application, across three inference types — generate, stream and decide. `decide` returns typed, calibrated judgements from a non-generative model (~400ms, ~$0.00002/call) for routing, tool selection and context budgeting. MCP-native (4 transports), voice TTS/STT/realtime, RAG, agents, memory, compaction, 9 observability exporters. OpenAI · Anthropic · Gemini · Bedrock · Azure · Ollama · TypeSafe Jev and more.",
6
6
  "author": {
@@ -124,6 +124,7 @@
124
124
  "test:mcp:spans": "pnpm exec tsx test/continuous-test-suite-mcp-spans.ts",
125
125
  "test:mcp:infra": "pnpm exec tsx test/continuous-test-suite-mcp-infra.ts",
126
126
  "test:vendor-recovery": "pnpm exec tsx test/continuous-test-suite-native-vendor-recovery.ts",
127
+ "test:anthropic-generate-guard": "pnpm exec tsx test/continuous-test-suite-anthropic-generate-guard.ts",
127
128
  "test:browser-bundle": "pnpm exec tsx test/continuous-test-suite-browser-bundle.ts",
128
129
  "test:providers-mocked": "pnpm exec tsx test/continuous-test-suite-providers-mocked.ts",
129
130
  "scaffold:provider": "pnpm exec tsx tools/scaffold-provider.ts",