@juspay/neurolink 11.24.1 → 11.24.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.
@@ -3337,6 +3337,55 @@ export class GoogleVertexProvider extends BaseProvider {
3337
3337
  const contextGuard = createContextGuard(getContextWindowSize("vertex", modelName));
3338
3338
  const failedTools = new Map();
3339
3339
  try {
3340
+ // Restores the per-tool observation the hand-rolled dispatch had.
3341
+ // The execution runs INSIDE the span's context so spans the tool opens
3342
+ // itself nest under this call rather than dangling beside the turn, and
3343
+ // the settled RESULT is inspected — an MCP tool reports failure in its
3344
+ // payload, so an observation that only watches for throws records a
3345
+ // failed call as successful.
3346
+ //
3347
+ // Stream path only: the generate twin never had per-tool spans, and
3348
+ // giving it them here would be behaviour GAINED under cover of a
3349
+ // migration. Shared with resolveToolOnMiss below: the old dispatch
3350
+ // opened the span before the executor lookup, so a tool hydrated
3351
+ // mid-turn was observed exactly like one declared up front.
3352
+ const withToolSpan = (toolCallName, run) => {
3353
+ const toolSpan = tracers.mcp.startSpan("ai.toolCall", {
3354
+ kind: SpanKind.INTERNAL,
3355
+ attributes: {
3356
+ [LANGFUSE_ATTR.OBSERVATION_TYPE]: "tool",
3357
+ [ATTR.GEN_AI_TOOL_NAME]: toolCallName,
3358
+ "ai.toolCall.name": toolCallName,
3359
+ },
3360
+ }, turnContext);
3361
+ const finish = (output, errorMessage) => {
3362
+ toolSpan.setAttribute("ai.toolCall.result", spanJsonAttribute(output));
3363
+ toolSpan.setAttribute(LANGFUSE_ATTR.OBSERVATION_OUTPUT, spanJsonAttribute(output));
3364
+ if (errorMessage) {
3365
+ toolSpan.setAttribute(LANGFUSE_ATTR.OBSERVATION_LEVEL, "ERROR");
3366
+ toolSpan.setAttribute(LANGFUSE_ATTR.OBSERVATION_STATUS_MESSAGE, errorMessage);
3367
+ toolSpan.setStatus({
3368
+ code: SpanStatusCode.ERROR,
3369
+ message: errorMessage,
3370
+ });
3371
+ }
3372
+ else {
3373
+ toolSpan.setStatus({ code: SpanStatusCode.OK });
3374
+ }
3375
+ toolSpan.end();
3376
+ };
3377
+ return otelContext.with(otelTrace.setSpan(turnContext, toolSpan), async () => {
3378
+ try {
3379
+ const result = await run();
3380
+ finish(result, extractMcpToolErrorMessage(result));
3381
+ return result;
3382
+ }
3383
+ catch (error) {
3384
+ finish({ error: true }, error instanceof Error ? error.message : String(error));
3385
+ throw error;
3386
+ }
3387
+ });
3388
+ };
3340
3389
  // Executors handed to the engine, taken through the turn's
3341
3390
  // DedupExecuteMap so an identical repeated call is answered from the
3342
3391
  // per-turn cache rather than run again (BZ-3327). `.get()` returns the
@@ -3358,53 +3407,7 @@ export class GoogleVertexProvider extends BaseProvider {
3358
3407
  toolTimeoutMs: toolExecTimeoutMs,
3359
3408
  abortSignal: internalAbort.signal,
3360
3409
  onProgress: () => turnClock.noteProgress(),
3361
- // Restores the per-tool observation the hand-rolled dispatch had.
3362
- // The execution runs INSIDE the span's context so spans the tool opens
3363
- // itself nest under this call rather than dangling beside the turn, and
3364
- // the settled RESULT is inspected — an MCP tool reports failure in its
3365
- // payload, so an observation that only watches for throws records a
3366
- // failed call as successful.
3367
- //
3368
- // Stream path only: the generate twin never had per-tool spans, and
3369
- // giving it them here would be behaviour GAINED under cover of a
3370
- // migration.
3371
- withToolSpan: (toolCallName, run) => {
3372
- const toolSpan = tracers.mcp.startSpan("ai.toolCall", {
3373
- kind: SpanKind.INTERNAL,
3374
- attributes: {
3375
- [LANGFUSE_ATTR.OBSERVATION_TYPE]: "tool",
3376
- [ATTR.GEN_AI_TOOL_NAME]: toolCallName,
3377
- "ai.toolCall.name": toolCallName,
3378
- },
3379
- }, turnContext);
3380
- const finish = (output, errorMessage) => {
3381
- toolSpan.setAttribute("ai.toolCall.result", spanJsonAttribute(output));
3382
- toolSpan.setAttribute(LANGFUSE_ATTR.OBSERVATION_OUTPUT, spanJsonAttribute(output));
3383
- if (errorMessage) {
3384
- toolSpan.setAttribute(LANGFUSE_ATTR.OBSERVATION_LEVEL, "ERROR");
3385
- toolSpan.setAttribute(LANGFUSE_ATTR.OBSERVATION_STATUS_MESSAGE, errorMessage);
3386
- toolSpan.setStatus({
3387
- code: SpanStatusCode.ERROR,
3388
- message: errorMessage,
3389
- });
3390
- }
3391
- else {
3392
- toolSpan.setStatus({ code: SpanStatusCode.OK });
3393
- }
3394
- toolSpan.end();
3395
- };
3396
- return otelContext.with(otelTrace.setSpan(turnContext, toolSpan), async () => {
3397
- try {
3398
- const result = await run();
3399
- finish(result, extractMcpToolErrorMessage(result));
3400
- return result;
3401
- }
3402
- catch (error) {
3403
- finish({ error: true }, error instanceof Error ? error.message : String(error));
3404
- throw error;
3405
- }
3406
- });
3407
- },
3410
+ withToolSpan,
3408
3411
  }),
3409
3412
  };
3410
3413
  }
@@ -3538,6 +3541,10 @@ export class GoogleVertexProvider extends BaseProvider {
3538
3541
  toolTimeoutMs: toolExecTimeoutMs,
3539
3542
  abortSignal: internalAbort.signal,
3540
3543
  onProgress: () => turnClock.noteProgress(),
3544
+ // Same observation as an up-front executor: the hand-rolled
3545
+ // dispatch spanned at the call, after the executor lookup, so
3546
+ // a hydrated tool was never the one unobserved call in a turn.
3547
+ withToolSpan,
3541
3548
  }),
3542
3549
  };
3543
3550
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juspay/neurolink",
3
- "version": "11.24.1",
3
+ "version": "11.24.2",
4
4
  "packageManager": "pnpm@10.15.1",
5
5
  "description": "TypeScript AI SDK with 24+ LLM providers behind one consistent API. MCP-native (connect any MCP server), voice TTS/STT/realtime, RAG, agents, memory, context compaction. OpenAI · Anthropic · Gemini · Bedrock · Azure · Ollama · DeepSeek · NVIDIA NIM and more.",
6
6
  "author": {