@juspay/neurolink 10.7.1 → 10.8.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 (34) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/adapters/replicate/predictionLifecycle.d.ts +1 -1
  3. package/dist/adapters/replicate/predictionLifecycle.js +50 -45
  4. package/dist/agent/directTools.d.ts +2 -2
  5. package/dist/browser/neurolink.min.js +373 -373
  6. package/dist/core/baseProvider.d.ts +1 -0
  7. package/dist/core/baseProvider.js +74 -11
  8. package/dist/core/modules/TelemetryHandler.d.ts +5 -1
  9. package/dist/core/modules/TelemetryHandler.js +20 -0
  10. package/dist/lib/adapters/replicate/predictionLifecycle.d.ts +1 -1
  11. package/dist/lib/adapters/replicate/predictionLifecycle.js +50 -45
  12. package/dist/lib/core/baseProvider.d.ts +1 -0
  13. package/dist/lib/core/baseProvider.js +74 -11
  14. package/dist/lib/core/modules/TelemetryHandler.d.ts +5 -1
  15. package/dist/lib/core/modules/TelemetryHandler.js +20 -0
  16. package/dist/lib/mcp/httpRateLimiter.js +14 -21
  17. package/dist/lib/types/generate.d.ts +16 -0
  18. package/dist/lib/utils/errorHandling.d.ts +2 -0
  19. package/dist/lib/utils/errorHandling.js +2 -0
  20. package/dist/lib/utils/pdfProcessor.js +2 -2
  21. package/dist/lib/utils/providerRetry.d.ts +5 -1
  22. package/dist/lib/utils/providerRetry.js +34 -8
  23. package/dist/lib/utils/retryAfter.d.ts +7 -0
  24. package/dist/lib/utils/retryAfter.js +44 -0
  25. package/dist/mcp/httpRateLimiter.js +14 -21
  26. package/dist/types/generate.d.ts +16 -0
  27. package/dist/utils/errorHandling.d.ts +2 -0
  28. package/dist/utils/errorHandling.js +2 -0
  29. package/dist/utils/pdfProcessor.js +2 -2
  30. package/dist/utils/providerRetry.d.ts +5 -1
  31. package/dist/utils/providerRetry.js +34 -8
  32. package/dist/utils/retryAfter.d.ts +7 -0
  33. package/dist/utils/retryAfter.js +43 -0
  34. package/package.json +3 -2
package/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ## [10.8.0](https://github.com/juspay/neurolink/compare/v10.7.1...v10.8.0) (2026-07-30)
2
+
3
+ ### Features
4
+
5
+ - **(tts):** expose synthesis failure metadata and telemetry ([2ee39c2](https://github.com/juspay/neurolink/commit/2ee39c2b174356eef1c610578d9c511d3566d62c))
6
+
7
+ ### Bug Fixes
8
+
9
+ - **(core):** honor Retry-After hints and add a no-hint retry floor ([f12984c](https://github.com/juspay/neurolink/commit/f12984c48f29da11bfb72b33ec99366ae45f43df))
10
+ - **(sdk):** correct litellm PDF supportsNative config ([#1009](https://github.com/juspay/neurolink/issues/1009)) ([8ab56d4](https://github.com/juspay/neurolink/commit/8ab56d44684a69abc591f1c4ab3c9e0e03927a6b))
11
+
1
12
  ## [10.7.1](https://github.com/juspay/neurolink/compare/v10.7.0...v10.7.1) (2026-07-29)
2
13
 
3
14
  ### Bug Fixes
@@ -18,7 +18,7 @@ import type { ReplicateAuth, ReplicateCreatePredictionInput, ReplicatePollOption
18
18
  * Submit a Replicate prediction. Uses `Prefer: wait=60` so quick
19
19
  * predictions complete in the initial POST and skip polling entirely.
20
20
  */
21
- export declare function createPrediction(auth: ReplicateAuth, input: ReplicateCreatePredictionInput): Promise<ReplicatePrediction>;
21
+ export declare function createPrediction(auth: ReplicateAuth, input: ReplicateCreatePredictionInput, sleep?: (delayMs: number) => Promise<void>): Promise<ReplicatePrediction>;
22
22
  /**
23
23
  * Poll a Replicate prediction until it reaches a terminal status
24
24
  * (succeeded / failed / canceled) or the total timeout elapses.
@@ -17,6 +17,8 @@ import { ErrorCategory, ErrorSeverity } from "../../constants/enums.js";
17
17
  import { logger } from "../../utils/logger.js";
18
18
  import { NeuroLinkError, ERROR_CODES } from "../../utils/errorHandling.js";
19
19
  import { sanitizeForLog } from "../../utils/logSanitize.js";
20
+ import { withProviderRetry } from "../../utils/providerRetry.js";
21
+ import { parseRetryAfterMs } from "../../utils/retryAfter.js";
20
22
  import { safeDownload } from "../../utils/safeFetch.js";
21
23
  import { MAX_VIDEO_BYTES } from "../../utils/sizeGuard.js";
22
24
  // The submit path sends `Prefer: wait=60`, so Replicate can legitimately
@@ -31,7 +33,7 @@ const DEFAULT_TOTAL_TIMEOUT_MS = 5 * 60_000;
31
33
  * Submit a Replicate prediction. Uses `Prefer: wait=60` so quick
32
34
  * predictions complete in the initial POST and skip polling entirely.
33
35
  */
34
- export async function createPrediction(auth, input) {
36
+ export async function createPrediction(auth, input, sleep) {
35
37
  const baseUrl = auth.baseUrl ?? "https://api.replicate.com";
36
38
  const [modelPath, version] = input.model.split(":", 2);
37
39
  const endpoint = version
@@ -46,51 +48,53 @@ export async function createPrediction(auth, input) {
46
48
  if (input.webhookEventsFilter && input.webhookEventsFilter.length > 0) {
47
49
  body.webhook_events_filter = input.webhookEventsFilter;
48
50
  }
49
- const controller = new AbortController();
50
- const timeoutId = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
51
- let response;
52
- try {
53
- response = await fetch(endpoint, {
54
- method: "POST",
55
- headers: {
56
- Authorization: `Token ${auth.apiToken}`,
57
- "Content-Type": "application/json",
58
- Prefer: "wait=60",
59
- },
60
- body: JSON.stringify(body),
61
- signal: controller.signal,
62
- });
63
- }
64
- catch (err) {
65
- if (err instanceof NeuroLinkError) {
66
- throw err;
67
- }
68
- if (err instanceof Error && err.name === "AbortError") {
69
- throw new NeuroLinkError({
70
- code: ERROR_CODES.OPERATION_ABORTED,
71
- message: `Replicate predictions submit timed out after ${REQUEST_TIMEOUT_MS / 1000}s`,
72
- category: ErrorCategory.TIMEOUT,
73
- severity: ErrorSeverity.HIGH,
74
- retriable: true,
75
- originalError: err,
51
+ return withProviderRetry(async () => {
52
+ const controller = new AbortController();
53
+ const timeoutId = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
54
+ try {
55
+ const response = await fetch(endpoint, {
56
+ method: "POST",
57
+ headers: {
58
+ Authorization: `Token ${auth.apiToken}`,
59
+ "Content-Type": "application/json",
60
+ Prefer: "wait=60",
61
+ },
62
+ body: JSON.stringify(body),
63
+ signal: controller.signal,
76
64
  });
65
+ if (!response.ok) {
66
+ const raw = await response.text();
67
+ throw new NeuroLinkError({
68
+ code: ERROR_CODES.PROVIDER_NOT_AVAILABLE,
69
+ message: `Replicate predictions submit failed: ${response.status} — ${sanitizeForLog(raw, 500)}`,
70
+ category: ErrorCategory.NETWORK,
71
+ severity: ErrorSeverity.HIGH,
72
+ retriable: response.status >= 500 || response.status === 429,
73
+ retryAfterMs: parseRetryAfterMs(response.headers),
74
+ });
75
+ }
76
+ return (await response.json());
77
77
  }
78
- throw err;
79
- }
80
- finally {
81
- clearTimeout(timeoutId);
82
- }
83
- if (!response.ok) {
84
- const raw = await response.text();
85
- throw new NeuroLinkError({
86
- code: ERROR_CODES.PROVIDER_NOT_AVAILABLE,
87
- message: `Replicate predictions submit failed: ${response.status} — ${sanitizeForLog(raw, 500)}`,
88
- category: ErrorCategory.NETWORK,
89
- severity: ErrorSeverity.HIGH,
90
- retriable: response.status >= 500,
91
- });
92
- }
93
- return (await response.json());
78
+ catch (error) {
79
+ if (error instanceof NeuroLinkError) {
80
+ throw error;
81
+ }
82
+ if (error instanceof Error && error.name === "AbortError") {
83
+ throw new NeuroLinkError({
84
+ code: ERROR_CODES.OPERATION_ABORTED,
85
+ message: `Replicate predictions submit timed out after ${REQUEST_TIMEOUT_MS / 1000}s`,
86
+ category: ErrorCategory.TIMEOUT,
87
+ severity: ErrorSeverity.HIGH,
88
+ retriable: true,
89
+ originalError: error,
90
+ });
91
+ }
92
+ throw error;
93
+ }
94
+ finally {
95
+ clearTimeout(timeoutId);
96
+ }
97
+ }, undefined, "Replicate prediction submission", sleep);
94
98
  }
95
99
  /**
96
100
  * Poll a Replicate prediction until it reaches a terminal status
@@ -164,7 +168,8 @@ export async function pollPrediction(auth, predictionId, options = {}) {
164
168
  message: `Replicate poll failed: ${response.status} — ${sanitizeForLog(raw, 500)}`,
165
169
  category: ErrorCategory.NETWORK,
166
170
  severity: ErrorSeverity.HIGH,
167
- retriable: response.status >= 500,
171
+ retriable: response.status >= 500 || response.status === 429,
172
+ retryAfterMs: parseRetryAfterMs(response.headers),
168
173
  });
169
174
  }
170
175
  const pred = (await response.json());
@@ -104,7 +104,7 @@ export declare const directAgentTools: {
104
104
  writeFile: Tool<{
105
105
  path: string;
106
106
  content: string;
107
- mode: "create" | "overwrite" | "append";
107
+ mode: "create" | "append" | "overwrite";
108
108
  }, {
109
109
  success: boolean;
110
110
  error: string;
@@ -115,7 +115,7 @@ export declare const directAgentTools: {
115
115
  } | {
116
116
  success: boolean;
117
117
  path: string;
118
- mode: "create" | "overwrite" | "append";
118
+ mode: "create" | "append" | "overwrite";
119
119
  size: number;
120
120
  written: number;
121
121
  error?: undefined;