@juspay/neurolink
Version:
The pipe layer of an AI nervous system: one interface connecting provider neurons to your application, across three inference types — generate, stream and decide. `decide` returns typed, calibrated judgements from a non-generative model (~400ms, ~$0.00002
53 lines (52 loc) • 2.6 kB
TypeScript
/**
* CLI Input Validation Utilities
*
* Validates multimodal file flags (--image/--csv/--pdf/--video/--file), the
* batch `<promptsFile>` positional, and --csv-max-rows before a
* generate/stream/batch run starts, so bad input fails fast with a clear
* message instead of surfacing deep inside provider calls. Exported as
* standalone functions (rather than private statics on CLICommandFactory)
* so callers — including tests — can import and invoke them directly,
* without reaching into the class via an `unknown` cast.
*/
/**
* Soft (warn-only) size thresholds for CLI multimodal flags. Intentionally
* defined here rather than reusing `lib/processors/config/sizeLimits.ts`'s
* hard processor caps (e.g. PDF's 100MB hard limit): reusing those names/
* values would couple the CLI layer to processor internals across the
* CLI/SDK boundary, and would blur the line between a soft "this may be
* slow" warning and the actual hard cap the processor enforces.
*/
export declare const CLI_SOFT_LIMITS_MB: {
readonly IMAGE_MAX_MB: 10;
readonly CSV_MAX_MB: 50;
readonly PDF_MAX_MB: 100;
readonly PDF_SOFT_MAX_MB: 50;
readonly VIDEO_MAX_MB: 500;
};
/**
* Validate --image/--csv/--pdf/--video/--file inputs before a CLI run
* starts: every local path (including `file://` URLs) must exist, must not
* be a directory, and — for the flags with a soft limit — triggers a size
* warning above the threshold. Genuine http(s)/data: URLs skip both
* existence and size checks (#319).
*/
export declare function validateCliInputFiles(argv: Record<string, unknown>): void;
/**
* #291: validate the batch `<promptsFile>` positional through the same
* aggregated-error-friendly path as the multimodal flags above (not found /
* unreadable / directory / malformed `file://` URL), instead of a raw
* existsSync+readFileSync that throws an unfriendly EISDIR when pointed at
* a directory. The `<file>` label (rather than `--file`) keeps the message
* from being confused with the `--file` flag, which batch doesn't register
* at all (see `createBatchCommand`). Returns the resolved local path for
* the caller to read.
*/
export declare function validatePromptsFilePath(rawPath: string): string;
/**
* #310: validate --csv-max-rows is a positive integer in the range
* 1-100000, matching the documented option range (the value previously
* flowed through silently, or — above 100000 — only warned instead of
* being rejected, contradicting the documented hard range).
*/
export declare function validateCsvMaxRows(argv: Record<string, unknown>): void;