@juspay/neurolink 2.1.0 → 3.0.0

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.
Files changed (39) hide show
  1. package/CHANGELOG.md +29 -9
  2. package/README.md +17 -39
  3. package/dist/cli/index.js +28 -16
  4. package/dist/lib/mcp/plugins/filesystem-mcp.d.ts +1 -1
  5. package/dist/lib/providers/agent-enhanced-provider.js +61 -53
  6. package/dist/lib/providers/amazonBedrock.js +11 -7
  7. package/dist/lib/providers/anthropic.js +13 -11
  8. package/dist/lib/providers/azureOpenAI.js +10 -10
  9. package/dist/lib/providers/googleAIStudio.js +14 -7
  10. package/dist/lib/providers/googleVertexAI.js +14 -7
  11. package/dist/lib/providers/huggingFace.js +11 -7
  12. package/dist/lib/providers/mistralAI.js +11 -7
  13. package/dist/lib/providers/ollama.js +12 -4
  14. package/dist/lib/providers/openAI.js +11 -7
  15. package/dist/lib/providers/timeout-wrapper.d.ts +2 -2
  16. package/dist/lib/providers/timeout-wrapper.js +3 -3
  17. package/dist/lib/proxy/proxy-fetch.d.ts +18 -0
  18. package/dist/lib/proxy/proxy-fetch.js +64 -0
  19. package/dist/lib/utils/timeout.d.ts +4 -4
  20. package/dist/lib/utils/timeout.js +42 -34
  21. package/dist/mcp/plugins/filesystem-mcp.d.ts +1 -1
  22. package/dist/mcp/plugins/filesystem-mcp.js +1 -1
  23. package/dist/providers/agent-enhanced-provider.js +61 -53
  24. package/dist/providers/amazonBedrock.js +11 -7
  25. package/dist/providers/anthropic.js +13 -11
  26. package/dist/providers/azureOpenAI.js +10 -10
  27. package/dist/providers/googleAIStudio.js +14 -7
  28. package/dist/providers/googleVertexAI.js +14 -7
  29. package/dist/providers/huggingFace.js +11 -7
  30. package/dist/providers/mistralAI.js +11 -7
  31. package/dist/providers/ollama.js +12 -4
  32. package/dist/providers/openAI.js +11 -7
  33. package/dist/providers/timeout-wrapper.d.ts +2 -2
  34. package/dist/providers/timeout-wrapper.js +3 -3
  35. package/dist/proxy/proxy-fetch.d.ts +18 -0
  36. package/dist/proxy/proxy-fetch.js +64 -0
  37. package/dist/utils/timeout.d.ts +4 -4
  38. package/dist/utils/timeout.js +42 -34
  39. package/package.json +2 -1
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Proxy-aware fetch implementation for AI SDK providers
3
+ * Implements the proven Vercel AI SDK proxy pattern using undici
4
+ */
5
+ /**
6
+ * Create a proxy-aware fetch function
7
+ * This implements the community-validated approach for Vercel AI SDK
8
+ */
9
+ export function createProxyFetch() {
10
+ const httpsProxy = process.env.HTTPS_PROXY || process.env.https_proxy;
11
+ const httpProxy = process.env.HTTP_PROXY || process.env.http_proxy;
12
+ // If no proxy configured, return standard fetch
13
+ if (!httpsProxy && !httpProxy) {
14
+ console.log("[Proxy Fetch] No proxy environment variables found - using standard fetch");
15
+ return fetch;
16
+ }
17
+ console.log(`[Proxy Fetch] Configuring proxy with undici ProxyAgent:`);
18
+ console.log(`[Proxy Fetch] HTTP_PROXY: ${httpProxy || "not set"}`);
19
+ console.log(`[Proxy Fetch] HTTPS_PROXY: ${httpsProxy || "not set"}`);
20
+ // Return proxy-aware fetch function
21
+ return async (input, init) => {
22
+ try {
23
+ // Dynamic import undici to avoid build issues
24
+ const undici = await import("undici");
25
+ const { ProxyAgent } = undici;
26
+ const url = typeof input === "string"
27
+ ? new URL(input)
28
+ : input instanceof URL
29
+ ? input
30
+ : new URL(input.url);
31
+ const proxyUrl = url.protocol === "https:" ? httpsProxy : httpProxy;
32
+ if (proxyUrl) {
33
+ console.log(`[Proxy Fetch] Creating ProxyAgent for ${url.hostname} via ${proxyUrl}`);
34
+ // Create ProxyAgent
35
+ const dispatcher = new ProxyAgent(proxyUrl);
36
+ // Use undici fetch with dispatcher
37
+ const response = await undici.fetch(input, {
38
+ ...init,
39
+ dispatcher: dispatcher,
40
+ });
41
+ console.log(`[Proxy Fetch] ✅ Request proxied successfully to ${url.hostname}`);
42
+ return response; // Type assertion to avoid complex type issues
43
+ }
44
+ }
45
+ catch (error) {
46
+ console.warn(`[Proxy Fetch] Proxy failed (${error.message}), falling back to direct connection`);
47
+ }
48
+ // Fallback to standard fetch
49
+ return fetch(input, init);
50
+ };
51
+ }
52
+ /**
53
+ * Get proxy status information
54
+ */
55
+ export function getProxyStatus() {
56
+ const httpsProxy = process.env.HTTPS_PROXY || process.env.https_proxy;
57
+ const httpProxy = process.env.HTTP_PROXY || process.env.http_proxy;
58
+ return {
59
+ enabled: !!(httpsProxy || httpProxy),
60
+ httpProxy: httpProxy || null,
61
+ httpsProxy: httpsProxy || null,
62
+ method: "undici-proxy-agent",
63
+ };
64
+ }
@@ -39,7 +39,7 @@ export declare const DEFAULT_TIMEOUTS: {
39
39
  vertex: string;
40
40
  anthropic: string;
41
41
  azure: string;
42
- 'google-ai': string;
42
+ "google-ai": string;
43
43
  huggingface: string;
44
44
  ollama: string;
45
45
  mistral: string;
@@ -57,7 +57,7 @@ export declare const DEFAULT_TIMEOUTS: {
57
57
  * @param operation - Operation type (generate or stream)
58
58
  * @returns Default timeout string
59
59
  */
60
- export declare function getDefaultTimeout(provider: string, operation?: 'generate' | 'stream'): string;
60
+ export declare function getDefaultTimeout(provider: string, operation?: "generate" | "stream"): string;
61
61
  /**
62
62
  * Create a timeout promise that rejects after specified duration
63
63
  * @param timeout - Timeout duration
@@ -65,5 +65,5 @@ export declare function getDefaultTimeout(provider: string, operation?: 'generat
65
65
  * @param operation - Operation type for error message
66
66
  * @returns Promise that rejects with TimeoutError
67
67
  */
68
- export declare function createTimeoutPromise(timeout: number | string | undefined, provider: string, operation: 'generate' | 'stream'): Promise<never> | null;
69
- export { createTimeoutController } from '../providers/timeout-wrapper.js';
68
+ export declare function createTimeoutPromise(timeout: number | string | undefined, provider: string, operation: "generate" | "stream"): Promise<never> | null;
69
+ export { createTimeoutController } from "../providers/timeout-wrapper.js";
@@ -16,9 +16,9 @@ export class TimeoutError extends Error {
16
16
  this.timeout = timeout;
17
17
  this.provider = provider;
18
18
  this.operation = operation;
19
- this.name = 'TimeoutError';
19
+ this.name = "TimeoutError";
20
20
  // Maintains proper stack trace for where error was thrown
21
- if (typeof Error.captureStackTrace === 'function') {
21
+ if (typeof Error.captureStackTrace === "function") {
22
22
  Error.captureStackTrace(this, TimeoutError);
23
23
  }
24
24
  }
@@ -37,15 +37,16 @@ export class TimeoutError extends Error {
37
37
  * - parseTimeout(undefined) => undefined
38
38
  */
39
39
  export function parseTimeout(timeout) {
40
- if (timeout === undefined)
40
+ if (timeout === undefined) {
41
41
  return undefined;
42
- if (typeof timeout === 'number') {
42
+ }
43
+ if (typeof timeout === "number") {
43
44
  if (timeout <= 0) {
44
45
  throw new Error(`Timeout must be positive, got: ${timeout}`);
45
46
  }
46
47
  return timeout; // Assume milliseconds
47
48
  }
48
- if (typeof timeout === 'string') {
49
+ if (typeof timeout === "string") {
49
50
  // Match number (including decimals) followed by optional unit
50
51
  const match = timeout.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);
51
52
  if (!match) {
@@ -55,13 +56,18 @@ export function parseTimeout(timeout) {
55
56
  if (value <= 0) {
56
57
  throw new Error(`Timeout must be positive, got: ${value}`);
57
58
  }
58
- const unit = match[2] || 'ms';
59
+ const unit = match[2] || "ms";
59
60
  switch (unit) {
60
- case 'ms': return value;
61
- case 's': return value * 1000;
62
- case 'm': return value * 60 * 1000;
63
- case 'h': return value * 60 * 60 * 1000;
64
- default: return value; // Should never reach here due to regex
61
+ case "ms":
62
+ return value;
63
+ case "s":
64
+ return value * 1000;
65
+ case "m":
66
+ return value * 60 * 1000;
67
+ case "h":
68
+ return value * 60 * 60 * 1000;
69
+ default:
70
+ return value; // Should never reach here due to regex
65
71
  }
66
72
  }
67
73
  throw new Error(`Invalid timeout type: ${typeof timeout}`);
@@ -70,25 +76,25 @@ export function parseTimeout(timeout) {
70
76
  * Default timeout configurations for different providers and operations
71
77
  */
72
78
  export const DEFAULT_TIMEOUTS = {
73
- global: '30s', // Default for all providers
74
- streaming: '2m', // Longer timeout for streaming operations
79
+ global: "30s", // Default for all providers
80
+ streaming: "2m", // Longer timeout for streaming operations
75
81
  providers: {
76
- openai: '30s', // OpenAI typically responds quickly
77
- bedrock: '45s', // AWS can be slower, especially for cold starts
78
- vertex: '60s', // Google Cloud can be slower
79
- anthropic: '30s', // Direct Anthropic API is fast
80
- azure: '30s', // Azure OpenAI similar to OpenAI
81
- 'google-ai': '30s', // Google AI Studio is fast
82
- huggingface: '2m', // Open source models vary significantly
83
- ollama: '5m', // Local models need more time, especially large ones
84
- mistral: '45s' // Mistral AI moderate speed
82
+ openai: "30s", // OpenAI typically responds quickly
83
+ bedrock: "45s", // AWS can be slower, especially for cold starts
84
+ vertex: "60s", // Google Cloud can be slower
85
+ anthropic: "30s", // Direct Anthropic API is fast
86
+ azure: "30s", // Azure OpenAI similar to OpenAI
87
+ "google-ai": "30s", // Google AI Studio is fast
88
+ huggingface: "2m", // Open source models vary significantly
89
+ ollama: "5m", // Local models need more time, especially large ones
90
+ mistral: "45s", // Mistral AI moderate speed
85
91
  },
86
92
  tools: {
87
- default: '10s', // Default timeout for MCP tool execution
88
- filesystem: '5s', // File operations should be quick
89
- network: '30s', // Network requests might take longer
90
- computation: '2m' // Heavy computation tools need more time
91
- }
93
+ default: "10s", // Default timeout for MCP tool execution
94
+ filesystem: "5s", // File operations should be quick
95
+ network: "30s", // Network requests might take longer
96
+ computation: "2m", // Heavy computation tools need more time
97
+ },
92
98
  };
93
99
  /**
94
100
  * Get default timeout for a specific provider
@@ -96,13 +102,12 @@ export const DEFAULT_TIMEOUTS = {
96
102
  * @param operation - Operation type (generate or stream)
97
103
  * @returns Default timeout string
98
104
  */
99
- export function getDefaultTimeout(provider, operation = 'generate') {
100
- if (operation === 'stream') {
105
+ export function getDefaultTimeout(provider, operation = "generate") {
106
+ if (operation === "stream") {
101
107
  return DEFAULT_TIMEOUTS.streaming;
102
108
  }
103
- const providerKey = provider.toLowerCase().replace('_', '-');
104
- return DEFAULT_TIMEOUTS.providers[providerKey]
105
- || DEFAULT_TIMEOUTS.global;
109
+ const providerKey = provider.toLowerCase().replace("_", "-");
110
+ return (DEFAULT_TIMEOUTS.providers[providerKey] || DEFAULT_TIMEOUTS.global);
106
111
  }
107
112
  /**
108
113
  * Create a timeout promise that rejects after specified duration
@@ -121,10 +126,13 @@ export function createTimeoutPromise(timeout, provider, operation) {
121
126
  reject(new TimeoutError(`${provider} ${operation} operation timed out after ${timeout}`, timeoutMs, provider, operation));
122
127
  }, timeoutMs);
123
128
  // Unref the timer so it doesn't keep the process alive (Node.js only)
124
- if (typeof timer === 'object' && timer && 'unref' in timer && typeof timer.unref === 'function') {
129
+ if (typeof timer === "object" &&
130
+ timer &&
131
+ "unref" in timer &&
132
+ typeof timer.unref === "function") {
125
133
  timer.unref();
126
134
  }
127
135
  });
128
136
  }
129
137
  // Re-export createTimeoutController from timeout-wrapper for convenience
130
- export { createTimeoutController } from '../providers/timeout-wrapper.js';
138
+ export { createTimeoutController } from "../providers/timeout-wrapper.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juspay/neurolink",
3
- "version": "2.1.0",
3
+ "version": "3.0.0",
4
4
  "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 9 major providers: OpenAI, Anthropic, Google AI, AWS Bedrock, Azure, Hugging Face, Ollama, and Mistral AI.",
5
5
  "author": {
6
6
  "name": "Juspay Technologies",
@@ -138,6 +138,7 @@
138
138
  "dotenv": "^16.5.0",
139
139
  "express": "^5.1.0",
140
140
  "inquirer": "^9.2.15",
141
+ "undici": "^6.6.2",
141
142
  "ora": "^7.0.1",
142
143
  "playwright": "^1.52.0",
143
144
  "uuid": "^11.1.0",