@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.
- package/CHANGELOG.md +11 -0
- package/dist/adapters/replicate/predictionLifecycle.d.ts +1 -1
- package/dist/adapters/replicate/predictionLifecycle.js +50 -45
- package/dist/agent/directTools.d.ts +2 -2
- package/dist/browser/neurolink.min.js +373 -373
- package/dist/core/baseProvider.d.ts +1 -0
- package/dist/core/baseProvider.js +74 -11
- package/dist/core/modules/TelemetryHandler.d.ts +5 -1
- package/dist/core/modules/TelemetryHandler.js +20 -0
- package/dist/lib/adapters/replicate/predictionLifecycle.d.ts +1 -1
- package/dist/lib/adapters/replicate/predictionLifecycle.js +50 -45
- package/dist/lib/core/baseProvider.d.ts +1 -0
- package/dist/lib/core/baseProvider.js +74 -11
- package/dist/lib/core/modules/TelemetryHandler.d.ts +5 -1
- package/dist/lib/core/modules/TelemetryHandler.js +20 -0
- package/dist/lib/mcp/httpRateLimiter.js +14 -21
- package/dist/lib/types/generate.d.ts +16 -0
- package/dist/lib/utils/errorHandling.d.ts +2 -0
- package/dist/lib/utils/errorHandling.js +2 -0
- package/dist/lib/utils/pdfProcessor.js +2 -2
- package/dist/lib/utils/providerRetry.d.ts +5 -1
- package/dist/lib/utils/providerRetry.js +34 -8
- package/dist/lib/utils/retryAfter.d.ts +7 -0
- package/dist/lib/utils/retryAfter.js +44 -0
- package/dist/mcp/httpRateLimiter.js +14 -21
- package/dist/types/generate.d.ts +16 -0
- package/dist/utils/errorHandling.d.ts +2 -0
- package/dist/utils/errorHandling.js +2 -0
- package/dist/utils/pdfProcessor.js +2 -2
- package/dist/utils/providerRetry.d.ts +5 -1
- package/dist/utils/providerRetry.js +34 -8
- package/dist/utils/retryAfter.d.ts +7 -0
- package/dist/utils/retryAfter.js +43 -0
- 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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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" | "
|
|
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" | "
|
|
118
|
+
mode: "create" | "append" | "overwrite";
|
|
119
119
|
size: number;
|
|
120
120
|
written: number;
|
|
121
121
|
error?: undefined;
|