@juspay/neurolink 9.0.0 → 9.0.1
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 +6 -0
- package/dist/lib/types/fileTypes.d.ts +5 -0
- package/dist/lib/utils/errorHandling.d.ts +5 -0
- package/dist/lib/utils/errorHandling.js +32 -0
- package/dist/lib/utils/pdfProcessor.js +10 -2
- package/dist/types/fileTypes.d.ts +5 -0
- package/dist/utils/errorHandling.d.ts +5 -0
- package/dist/utils/errorHandling.js +32 -0
- package/dist/utils/pdfProcessor.js +10 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## [9.0.1](https://github.com/juspay/neurolink/compare/v9.0.0...v9.0.1) (2026-02-03)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
- **(pdf-processor):** enforce page limits by default with actionable alternatives ([35576aa](https://github.com/juspay/neurolink/commit/35576aa210b5a9a0bce8e6c5df041351905f0c96))
|
|
6
|
+
|
|
1
7
|
## [9.0.0](https://github.com/juspay/neurolink/compare/v8.43.0...v9.0.0) (2026-02-03)
|
|
2
8
|
|
|
3
9
|
### ⚠ BREAKING CHANGES
|
|
@@ -105,6 +105,11 @@ export type PDFProcessorOptions = {
|
|
|
105
105
|
model?: string;
|
|
106
106
|
maxSizeMB?: number;
|
|
107
107
|
bedrockApiMode?: "converse" | "invokeModel";
|
|
108
|
+
/**
|
|
109
|
+
* Whether to enforce page limits by throwing an error (default: true)
|
|
110
|
+
* Set to false to bypass limit enforcement (logs warning instead)
|
|
111
|
+
*/
|
|
112
|
+
enforceLimits?: boolean;
|
|
108
113
|
};
|
|
109
114
|
/**
|
|
110
115
|
* Audio provider configuration for transcription services
|
|
@@ -32,6 +32,7 @@ export declare const ERROR_CODES: {
|
|
|
32
32
|
readonly IMAGE_TOO_LARGE: "IMAGE_TOO_LARGE";
|
|
33
33
|
readonly IMAGE_TOO_SMALL: "IMAGE_TOO_SMALL";
|
|
34
34
|
readonly INVALID_IMAGE_FORMAT: "INVALID_IMAGE_FORMAT";
|
|
35
|
+
readonly PDF_PAGE_LIMIT_EXCEEDED: "PDF_PAGE_LIMIT_EXCEEDED";
|
|
35
36
|
readonly RATE_LIMITER_QUEUE_FULL: "RATE_LIMITER_QUEUE_FULL";
|
|
36
37
|
readonly RATE_LIMITER_QUEUE_TIMEOUT: "RATE_LIMITER_QUEUE_TIMEOUT";
|
|
37
38
|
readonly RATE_LIMITER_RESET: "RATE_LIMITER_RESET";
|
|
@@ -149,6 +150,10 @@ export declare class ErrorFactory {
|
|
|
149
150
|
* Create an invalid image type error
|
|
150
151
|
*/
|
|
151
152
|
static invalidImageType(): NeuroLinkError;
|
|
153
|
+
/**
|
|
154
|
+
* Create a PDF page limit exceeded error
|
|
155
|
+
*/
|
|
156
|
+
static pdfPageLimitExceeded(estimatedPages: number, maxPages: number, provider: string): NeuroLinkError;
|
|
152
157
|
/**
|
|
153
158
|
* Create an image too large error
|
|
154
159
|
*/
|
|
@@ -40,6 +40,8 @@ export const ERROR_CODES = {
|
|
|
40
40
|
IMAGE_TOO_LARGE: "IMAGE_TOO_LARGE",
|
|
41
41
|
IMAGE_TOO_SMALL: "IMAGE_TOO_SMALL",
|
|
42
42
|
INVALID_IMAGE_FORMAT: "INVALID_IMAGE_FORMAT",
|
|
43
|
+
// PDF validation errors
|
|
44
|
+
PDF_PAGE_LIMIT_EXCEEDED: "PDF_PAGE_LIMIT_EXCEEDED",
|
|
43
45
|
// Rate limiter errors
|
|
44
46
|
RATE_LIMITER_QUEUE_FULL: "RATE_LIMITER_QUEUE_FULL",
|
|
45
47
|
RATE_LIMITER_QUEUE_TIMEOUT: "RATE_LIMITER_QUEUE_TIMEOUT",
|
|
@@ -417,6 +419,36 @@ export class ErrorFactory {
|
|
|
417
419
|
},
|
|
418
420
|
});
|
|
419
421
|
}
|
|
422
|
+
// ============================================================================
|
|
423
|
+
// PDF VALIDATION ERRORS
|
|
424
|
+
// ============================================================================
|
|
425
|
+
/**
|
|
426
|
+
* Create a PDF page limit exceeded error
|
|
427
|
+
*/
|
|
428
|
+
static pdfPageLimitExceeded(estimatedPages, maxPages, provider) {
|
|
429
|
+
const alternatives = [
|
|
430
|
+
`Split the PDF into smaller files (max ${maxPages} pages each)`,
|
|
431
|
+
"Extract only the pages you need using a PDF editor",
|
|
432
|
+
"For large files, consider Google AI Studio which supports up to 2000MB file size (though page limits still apply)",
|
|
433
|
+
"Convert specific pages to images manually before processing",
|
|
434
|
+
"Bypass this limit with { enforceLimits: false } (not recommended - may cause API errors or unexpected costs)",
|
|
435
|
+
];
|
|
436
|
+
return new NeuroLinkError({
|
|
437
|
+
code: ERROR_CODES.PDF_PAGE_LIMIT_EXCEEDED,
|
|
438
|
+
message: `PDF page limit exceeded: ${estimatedPages} pages detected, but ${provider} supports maximum ${maxPages} pages.\n\n` +
|
|
439
|
+
`Alternatives:\n` +
|
|
440
|
+
alternatives.map((alt, i) => `${i + 1}. ${alt}`).join("\n"),
|
|
441
|
+
category: ErrorCategory.VALIDATION,
|
|
442
|
+
severity: ErrorSeverity.MEDIUM,
|
|
443
|
+
retriable: false,
|
|
444
|
+
context: {
|
|
445
|
+
estimatedPages,
|
|
446
|
+
maxPages,
|
|
447
|
+
provider,
|
|
448
|
+
alternatives,
|
|
449
|
+
},
|
|
450
|
+
});
|
|
451
|
+
}
|
|
420
452
|
/**
|
|
421
453
|
* Create an image too large error
|
|
422
454
|
*/
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { PDF_LIMITS } from "../core/constants.js";
|
|
11
11
|
import { logger } from "./logger.js";
|
|
12
|
+
import { ErrorFactory } from "./errorHandling.js";
|
|
12
13
|
/**
|
|
13
14
|
* Provider configurations for PDF handling
|
|
14
15
|
*
|
|
@@ -150,8 +151,15 @@ export class PDFProcessor {
|
|
|
150
151
|
}
|
|
151
152
|
const metadata = this.extractBasicMetadata(content);
|
|
152
153
|
if (metadata.estimatedPages && metadata.estimatedPages > config.maxPages) {
|
|
153
|
-
|
|
154
|
-
|
|
154
|
+
const enforceLimits = options?.enforceLimits !== false;
|
|
155
|
+
if (enforceLimits) {
|
|
156
|
+
throw ErrorFactory.pdfPageLimitExceeded(metadata.estimatedPages, config.maxPages, provider);
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
logger.warn(`[PDF] ⚠️ LIMIT BYPASS: Processing ${metadata.estimatedPages}-page PDF despite ${config.maxPages}-page limit for ${provider}. ` +
|
|
160
|
+
`This may cause API rejection, token errors, or unexpected costs. ` +
|
|
161
|
+
`Consider splitting the PDF or using a different provider.`);
|
|
162
|
+
}
|
|
155
163
|
}
|
|
156
164
|
if (provider === "bedrock" && options?.bedrockApiMode === "converse") {
|
|
157
165
|
logger.info("[PDF] Using Bedrock Converse API. " +
|
|
@@ -105,6 +105,11 @@ export type PDFProcessorOptions = {
|
|
|
105
105
|
model?: string;
|
|
106
106
|
maxSizeMB?: number;
|
|
107
107
|
bedrockApiMode?: "converse" | "invokeModel";
|
|
108
|
+
/**
|
|
109
|
+
* Whether to enforce page limits by throwing an error (default: true)
|
|
110
|
+
* Set to false to bypass limit enforcement (logs warning instead)
|
|
111
|
+
*/
|
|
112
|
+
enforceLimits?: boolean;
|
|
108
113
|
};
|
|
109
114
|
/**
|
|
110
115
|
* Audio provider configuration for transcription services
|
|
@@ -32,6 +32,7 @@ export declare const ERROR_CODES: {
|
|
|
32
32
|
readonly IMAGE_TOO_LARGE: "IMAGE_TOO_LARGE";
|
|
33
33
|
readonly IMAGE_TOO_SMALL: "IMAGE_TOO_SMALL";
|
|
34
34
|
readonly INVALID_IMAGE_FORMAT: "INVALID_IMAGE_FORMAT";
|
|
35
|
+
readonly PDF_PAGE_LIMIT_EXCEEDED: "PDF_PAGE_LIMIT_EXCEEDED";
|
|
35
36
|
readonly RATE_LIMITER_QUEUE_FULL: "RATE_LIMITER_QUEUE_FULL";
|
|
36
37
|
readonly RATE_LIMITER_QUEUE_TIMEOUT: "RATE_LIMITER_QUEUE_TIMEOUT";
|
|
37
38
|
readonly RATE_LIMITER_RESET: "RATE_LIMITER_RESET";
|
|
@@ -149,6 +150,10 @@ export declare class ErrorFactory {
|
|
|
149
150
|
* Create an invalid image type error
|
|
150
151
|
*/
|
|
151
152
|
static invalidImageType(): NeuroLinkError;
|
|
153
|
+
/**
|
|
154
|
+
* Create a PDF page limit exceeded error
|
|
155
|
+
*/
|
|
156
|
+
static pdfPageLimitExceeded(estimatedPages: number, maxPages: number, provider: string): NeuroLinkError;
|
|
152
157
|
/**
|
|
153
158
|
* Create an image too large error
|
|
154
159
|
*/
|
|
@@ -40,6 +40,8 @@ export const ERROR_CODES = {
|
|
|
40
40
|
IMAGE_TOO_LARGE: "IMAGE_TOO_LARGE",
|
|
41
41
|
IMAGE_TOO_SMALL: "IMAGE_TOO_SMALL",
|
|
42
42
|
INVALID_IMAGE_FORMAT: "INVALID_IMAGE_FORMAT",
|
|
43
|
+
// PDF validation errors
|
|
44
|
+
PDF_PAGE_LIMIT_EXCEEDED: "PDF_PAGE_LIMIT_EXCEEDED",
|
|
43
45
|
// Rate limiter errors
|
|
44
46
|
RATE_LIMITER_QUEUE_FULL: "RATE_LIMITER_QUEUE_FULL",
|
|
45
47
|
RATE_LIMITER_QUEUE_TIMEOUT: "RATE_LIMITER_QUEUE_TIMEOUT",
|
|
@@ -417,6 +419,36 @@ export class ErrorFactory {
|
|
|
417
419
|
},
|
|
418
420
|
});
|
|
419
421
|
}
|
|
422
|
+
// ============================================================================
|
|
423
|
+
// PDF VALIDATION ERRORS
|
|
424
|
+
// ============================================================================
|
|
425
|
+
/**
|
|
426
|
+
* Create a PDF page limit exceeded error
|
|
427
|
+
*/
|
|
428
|
+
static pdfPageLimitExceeded(estimatedPages, maxPages, provider) {
|
|
429
|
+
const alternatives = [
|
|
430
|
+
`Split the PDF into smaller files (max ${maxPages} pages each)`,
|
|
431
|
+
"Extract only the pages you need using a PDF editor",
|
|
432
|
+
"For large files, consider Google AI Studio which supports up to 2000MB file size (though page limits still apply)",
|
|
433
|
+
"Convert specific pages to images manually before processing",
|
|
434
|
+
"Bypass this limit with { enforceLimits: false } (not recommended - may cause API errors or unexpected costs)",
|
|
435
|
+
];
|
|
436
|
+
return new NeuroLinkError({
|
|
437
|
+
code: ERROR_CODES.PDF_PAGE_LIMIT_EXCEEDED,
|
|
438
|
+
message: `PDF page limit exceeded: ${estimatedPages} pages detected, but ${provider} supports maximum ${maxPages} pages.\n\n` +
|
|
439
|
+
`Alternatives:\n` +
|
|
440
|
+
alternatives.map((alt, i) => `${i + 1}. ${alt}`).join("\n"),
|
|
441
|
+
category: ErrorCategory.VALIDATION,
|
|
442
|
+
severity: ErrorSeverity.MEDIUM,
|
|
443
|
+
retriable: false,
|
|
444
|
+
context: {
|
|
445
|
+
estimatedPages,
|
|
446
|
+
maxPages,
|
|
447
|
+
provider,
|
|
448
|
+
alternatives,
|
|
449
|
+
},
|
|
450
|
+
});
|
|
451
|
+
}
|
|
420
452
|
/**
|
|
421
453
|
* Create an image too large error
|
|
422
454
|
*/
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { PDF_LIMITS } from "../core/constants.js";
|
|
11
11
|
import { logger } from "./logger.js";
|
|
12
|
+
import { ErrorFactory } from "./errorHandling.js";
|
|
12
13
|
/**
|
|
13
14
|
* Provider configurations for PDF handling
|
|
14
15
|
*
|
|
@@ -150,8 +151,15 @@ export class PDFProcessor {
|
|
|
150
151
|
}
|
|
151
152
|
const metadata = this.extractBasicMetadata(content);
|
|
152
153
|
if (metadata.estimatedPages && metadata.estimatedPages > config.maxPages) {
|
|
153
|
-
|
|
154
|
-
|
|
154
|
+
const enforceLimits = options?.enforceLimits !== false;
|
|
155
|
+
if (enforceLimits) {
|
|
156
|
+
throw ErrorFactory.pdfPageLimitExceeded(metadata.estimatedPages, config.maxPages, provider);
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
logger.warn(`[PDF] ⚠️ LIMIT BYPASS: Processing ${metadata.estimatedPages}-page PDF despite ${config.maxPages}-page limit for ${provider}. ` +
|
|
160
|
+
`This may cause API rejection, token errors, or unexpected costs. ` +
|
|
161
|
+
`Consider splitting the PDF or using a different provider.`);
|
|
162
|
+
}
|
|
155
163
|
}
|
|
156
164
|
if (provider === "bedrock" && options?.bedrockApiMode === "converse") {
|
|
157
165
|
logger.info("[PDF] Using Bedrock Converse API. " +
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juspay/neurolink",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.1",
|
|
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 13 providers: OpenAI, Anthropic, Google AI, AWS Bedrock, Azure, Hugging Face, Ollama, and Mistral AI.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Juspay Technologies",
|