@juspay/neurolink 9.61.1 → 9.61.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.
@@ -301,12 +301,18 @@ export class MCPToolRegistry extends MCPRegistry {
301
301
  span.setAttribute("tool.arguments_size", argsStr.length);
302
302
  // HITL Safety Check: Request confirmation if required
303
303
  let finalArgs = args;
304
- if (this.hitlManager && this.hitlManager.isEnabled()) {
304
+ const HITLState = context?.hitlState;
305
+ if (!HITLState?.triggered &&
306
+ this.hitlManager &&
307
+ this.hitlManager.isEnabled()) {
305
308
  const requiresConfirmation = this.hitlManager.requiresConfirmation(toolName, args);
306
309
  if (requiresConfirmation) {
307
310
  registryLogger.info(`Tool '${toolName}' requires HITL confirmation`);
308
311
  span.addEvent("tool.hitl_requested");
309
312
  try {
313
+ if (HITLState) {
314
+ HITLState.triggered = true;
315
+ }
310
316
  const confirmationResult = await this.hitlManager.requestConfirmation(toolName, args, {
311
317
  serverId: tool.serverId,
312
318
  sessionId: execContext.sessionId,
@@ -7199,6 +7199,7 @@ Current user's request: ${currentInput}`;
7199
7199
  inputSize: inputStr.length,
7200
7200
  truncatedInput: inputStr.length > 2048 ? inputStr.substring(0, 2048) : inputStr,
7201
7201
  options,
7202
+ hitlState: { triggered: false },
7202
7203
  };
7203
7204
  }
7204
7205
  async executeToolWithSpan(toolName, params, options, executionContext, toolSpan) {
@@ -7305,7 +7306,7 @@ Current user's request: ${currentInput}`;
7305
7306
  circuitBreakerState: prepared.circuitBreaker.getState(),
7306
7307
  });
7307
7308
  const result = await prepared.circuitBreaker.execute(async () => {
7308
- return withRetry(async () => withTimeout(this.executeToolInternal(toolName, params, prepared.finalOptions), prepared.finalOptions.timeout, ErrorFactory.toolTimeout(toolName, prepared.finalOptions.timeout)), {
7309
+ return withRetry(async () => withTimeout(this.executeToolInternal(toolName, params, prepared.finalOptions, executionContext.hitlState), prepared.finalOptions.timeout, ErrorFactory.toolTimeout(toolName, prepared.finalOptions.timeout)), {
7309
7310
  maxAttempts: prepared.finalOptions.maxRetries + 1,
7310
7311
  delayMs: prepared.finalOptions.retryDelayMs,
7311
7312
  isRetriable: isRetriableError,
@@ -7526,7 +7527,7 @@ Current user's request: ${currentInput}`;
7526
7527
  * - Annotations: skip cache for destructive tools, retry safe tools on failure
7527
7528
  * - Middleware: apply global middleware chain before execution
7528
7529
  */
7529
- async executeToolInternal(toolName, params, options) {
7530
+ async executeToolInternal(toolName, params, options, HITLState) {
7530
7531
  const functionTag = "NeuroLink.executeToolInternal";
7531
7532
  // === MCP ENHANCEMENT: Infer annotations for cache/retry decisions ===
7532
7533
  const toolAnnotations = this.getToolAnnotationsForExecution(toolName);
@@ -7645,6 +7646,7 @@ Current user's request: ${currentInput}`;
7645
7646
  const context = {
7646
7647
  ...storedContext,
7647
7648
  ...passedAuthContext,
7649
+ hitlState: HITLState,
7648
7650
  };
7649
7651
  logger.debug(`[Using merged context for unified registry tool:`, {
7650
7652
  toolName,
@@ -232,3 +232,6 @@ export type HITLManager = {
232
232
  on(event: string, listener: (...args: unknown[]) => void): HITLManager;
233
233
  emit(event: string, ...args: unknown[]): boolean;
234
234
  };
235
+ export type HITLExecutionState = {
236
+ triggered: boolean;
237
+ };
@@ -9,6 +9,7 @@ import type { StandardRecord, StringArray, ZodUnknownSchema } from "./aliases.js
9
9
  import type { ValidationError } from "../utils/parameterValidation.js";
10
10
  import type { MCPToolAnnotations } from "./mcp.js";
11
11
  import type { Logger } from "./utilities.js";
12
+ import type { HITLExecutionState } from "./hitl.js";
12
13
  /**
13
14
  * Commonly used Zod schema type aliases for cleaner type declarations
14
15
  */
@@ -48,6 +49,7 @@ export type ExecutionContext<T = StandardRecord> = {
48
49
  timeoutMs?: number;
49
50
  maxRetries?: number;
50
51
  startTime?: number;
52
+ hitlState?: HITLExecutionState;
51
53
  };
52
54
  /**
53
55
  * Cache configuration options
@@ -5,6 +5,7 @@
5
5
  import { ErrorCategory, ErrorSeverity } from "../constants/enums.js";
6
6
  import { logger } from "./logger.js";
7
7
  import { CircuitBreakerOpenError } from "../types/index.js";
8
+ import { HITLTimeoutError } from "../hitl/hitlErrors.js";
8
9
  // Error codes for different scenarios
9
10
  export const ERROR_CODES = {
10
11
  // Tool errors
@@ -950,6 +951,9 @@ export function isRetriableError(error) {
950
951
  if (error instanceof NeuroLinkError) {
951
952
  return error.retriable;
952
953
  }
954
+ if (error instanceof HITLTimeoutError) {
955
+ return false;
956
+ }
953
957
  // Check for common retriable error patterns
954
958
  const retriablePatterns = [
955
959
  /timeout/i,
@@ -301,12 +301,18 @@ export class MCPToolRegistry extends MCPRegistry {
301
301
  span.setAttribute("tool.arguments_size", argsStr.length);
302
302
  // HITL Safety Check: Request confirmation if required
303
303
  let finalArgs = args;
304
- if (this.hitlManager && this.hitlManager.isEnabled()) {
304
+ const HITLState = context?.hitlState;
305
+ if (!HITLState?.triggered &&
306
+ this.hitlManager &&
307
+ this.hitlManager.isEnabled()) {
305
308
  const requiresConfirmation = this.hitlManager.requiresConfirmation(toolName, args);
306
309
  if (requiresConfirmation) {
307
310
  registryLogger.info(`Tool '${toolName}' requires HITL confirmation`);
308
311
  span.addEvent("tool.hitl_requested");
309
312
  try {
313
+ if (HITLState) {
314
+ HITLState.triggered = true;
315
+ }
310
316
  const confirmationResult = await this.hitlManager.requestConfirmation(toolName, args, {
311
317
  serverId: tool.serverId,
312
318
  sessionId: execContext.sessionId,
package/dist/neurolink.js CHANGED
@@ -7199,6 +7199,7 @@ Current user's request: ${currentInput}`;
7199
7199
  inputSize: inputStr.length,
7200
7200
  truncatedInput: inputStr.length > 2048 ? inputStr.substring(0, 2048) : inputStr,
7201
7201
  options,
7202
+ hitlState: { triggered: false },
7202
7203
  };
7203
7204
  }
7204
7205
  async executeToolWithSpan(toolName, params, options, executionContext, toolSpan) {
@@ -7305,7 +7306,7 @@ Current user's request: ${currentInput}`;
7305
7306
  circuitBreakerState: prepared.circuitBreaker.getState(),
7306
7307
  });
7307
7308
  const result = await prepared.circuitBreaker.execute(async () => {
7308
- return withRetry(async () => withTimeout(this.executeToolInternal(toolName, params, prepared.finalOptions), prepared.finalOptions.timeout, ErrorFactory.toolTimeout(toolName, prepared.finalOptions.timeout)), {
7309
+ return withRetry(async () => withTimeout(this.executeToolInternal(toolName, params, prepared.finalOptions, executionContext.hitlState), prepared.finalOptions.timeout, ErrorFactory.toolTimeout(toolName, prepared.finalOptions.timeout)), {
7309
7310
  maxAttempts: prepared.finalOptions.maxRetries + 1,
7310
7311
  delayMs: prepared.finalOptions.retryDelayMs,
7311
7312
  isRetriable: isRetriableError,
@@ -7526,7 +7527,7 @@ Current user's request: ${currentInput}`;
7526
7527
  * - Annotations: skip cache for destructive tools, retry safe tools on failure
7527
7528
  * - Middleware: apply global middleware chain before execution
7528
7529
  */
7529
- async executeToolInternal(toolName, params, options) {
7530
+ async executeToolInternal(toolName, params, options, HITLState) {
7530
7531
  const functionTag = "NeuroLink.executeToolInternal";
7531
7532
  // === MCP ENHANCEMENT: Infer annotations for cache/retry decisions ===
7532
7533
  const toolAnnotations = this.getToolAnnotationsForExecution(toolName);
@@ -7645,6 +7646,7 @@ Current user's request: ${currentInput}`;
7645
7646
  const context = {
7646
7647
  ...storedContext,
7647
7648
  ...passedAuthContext,
7649
+ hitlState: HITLState,
7648
7650
  };
7649
7651
  logger.debug(`[Using merged context for unified registry tool:`, {
7650
7652
  toolName,
@@ -232,3 +232,6 @@ export type HITLManager = {
232
232
  on(event: string, listener: (...args: unknown[]) => void): HITLManager;
233
233
  emit(event: string, ...args: unknown[]): boolean;
234
234
  };
235
+ export type HITLExecutionState = {
236
+ triggered: boolean;
237
+ };
@@ -9,6 +9,7 @@ import type { StandardRecord, StringArray, ZodUnknownSchema } from "./aliases.js
9
9
  import type { ValidationError } from "../utils/parameterValidation.js";
10
10
  import type { MCPToolAnnotations } from "./mcp.js";
11
11
  import type { Logger } from "./utilities.js";
12
+ import type { HITLExecutionState } from "./hitl.js";
12
13
  /**
13
14
  * Commonly used Zod schema type aliases for cleaner type declarations
14
15
  */
@@ -48,6 +49,7 @@ export type ExecutionContext<T = StandardRecord> = {
48
49
  timeoutMs?: number;
49
50
  maxRetries?: number;
50
51
  startTime?: number;
52
+ hitlState?: HITLExecutionState;
51
53
  };
52
54
  /**
53
55
  * Cache configuration options
@@ -5,6 +5,7 @@
5
5
  import { ErrorCategory, ErrorSeverity } from "../constants/enums.js";
6
6
  import { logger } from "./logger.js";
7
7
  import { CircuitBreakerOpenError } from "../types/index.js";
8
+ import { HITLTimeoutError } from "../hitl/hitlErrors.js";
8
9
  // Error codes for different scenarios
9
10
  export const ERROR_CODES = {
10
11
  // Tool errors
@@ -950,6 +951,9 @@ export function isRetriableError(error) {
950
951
  if (error instanceof NeuroLinkError) {
951
952
  return error.retriable;
952
953
  }
954
+ if (error instanceof HITLTimeoutError) {
955
+ return false;
956
+ }
953
957
  // Check for common retriable error patterns
954
958
  const retriablePatterns = [
955
959
  /timeout/i,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juspay/neurolink",
3
- "version": "9.61.1",
3
+ "version": "9.61.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": {
@@ -89,7 +89,8 @@
89
89
  "test:proxy": "npx tsx test/continuous-test-suite-proxy.ts",
90
90
  "test:bugfixes": "npx tsx test/continuous-test-suite-bugfixes.ts",
91
91
  "test:workflow": "npx tsx test/continuous-test-suite-workflow.ts",
92
- "test:ci": "pnpm run test && pnpm run test:client",
92
+ "test:hitl": "npx tsx test/continuous-test-suite-hitl.ts",
93
+ "test:ci": "pnpm run test && pnpm run test:client && pnpm run test:hitl",
93
94
  "test:performance": "tsx tools/testing/performanceMonitor.ts",
94
95
  "// Content Generation (Cross-platform JS)": "",
95
96
  "content:videos": "tsx tools/converted-scripts/generateAllVideos.ts",