@juspay/neurolink 9.57.0 → 9.58.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 +12 -0
- package/dist/browser/neurolink.min.js +285 -285
- package/dist/constants/enums.d.ts +8 -1
- package/dist/constants/enums.js +7 -0
- package/dist/lib/constants/enums.d.ts +8 -1
- package/dist/lib/constants/enums.js +7 -0
- package/dist/lib/neurolink.d.ts +41 -2
- package/dist/lib/neurolink.js +386 -38
- package/dist/lib/types/config.d.ts +23 -0
- package/dist/lib/types/generate.d.ts +13 -0
- package/dist/lib/types/stream.d.ts +13 -0
- package/dist/lib/utils/conversationMemory.d.ts +10 -0
- package/dist/lib/utils/conversationMemory.js +185 -1
- package/dist/lib/utils/errorHandling.d.ts +13 -0
- package/dist/lib/utils/errorHandling.js +31 -0
- package/dist/neurolink.d.ts +41 -2
- package/dist/neurolink.js +386 -38
- package/dist/types/config.d.ts +23 -0
- package/dist/types/generate.d.ts +13 -0
- package/dist/types/stream.d.ts +13 -0
- package/dist/utils/conversationMemory.d.ts +10 -0
- package/dist/utils/conversationMemory.js +185 -1
- package/dist/utils/errorHandling.d.ts +13 -0
- package/dist/utils/errorHandling.js +31 -0
- package/package.json +2 -1
|
@@ -594,7 +594,14 @@ export declare enum ErrorCategory {
|
|
|
594
594
|
PERMISSION = "permission",
|
|
595
595
|
CONFIGURATION = "configuration",
|
|
596
596
|
EXECUTION = "execution",
|
|
597
|
-
SYSTEM = "system"
|
|
597
|
+
SYSTEM = "system",
|
|
598
|
+
/**
|
|
599
|
+
* Caller-initiated cancellation via AbortSignal. Distinct from system errors
|
|
600
|
+
* — represents a user/control-plane decision, not a SDK or provider failure.
|
|
601
|
+
* Consumers can branch on this category to differentiate "user cancelled"
|
|
602
|
+
* from "server error" without resorting to message-string matching.
|
|
603
|
+
*/
|
|
604
|
+
ABORT = "abort"
|
|
598
605
|
}
|
|
599
606
|
export declare enum ErrorSeverity {
|
|
600
607
|
LOW = "low",
|
package/dist/constants/enums.js
CHANGED
|
@@ -812,6 +812,13 @@ export var ErrorCategory;
|
|
|
812
812
|
ErrorCategory["CONFIGURATION"] = "configuration";
|
|
813
813
|
ErrorCategory["EXECUTION"] = "execution";
|
|
814
814
|
ErrorCategory["SYSTEM"] = "system";
|
|
815
|
+
/**
|
|
816
|
+
* Caller-initiated cancellation via AbortSignal. Distinct from system errors
|
|
817
|
+
* — represents a user/control-plane decision, not a SDK or provider failure.
|
|
818
|
+
* Consumers can branch on this category to differentiate "user cancelled"
|
|
819
|
+
* from "server error" without resorting to message-string matching.
|
|
820
|
+
*/
|
|
821
|
+
ErrorCategory["ABORT"] = "abort";
|
|
815
822
|
})(ErrorCategory || (ErrorCategory = {}));
|
|
816
823
|
// Error severity levels
|
|
817
824
|
export var ErrorSeverity;
|
|
@@ -594,7 +594,14 @@ export declare enum ErrorCategory {
|
|
|
594
594
|
PERMISSION = "permission",
|
|
595
595
|
CONFIGURATION = "configuration",
|
|
596
596
|
EXECUTION = "execution",
|
|
597
|
-
SYSTEM = "system"
|
|
597
|
+
SYSTEM = "system",
|
|
598
|
+
/**
|
|
599
|
+
* Caller-initiated cancellation via AbortSignal. Distinct from system errors
|
|
600
|
+
* — represents a user/control-plane decision, not a SDK or provider failure.
|
|
601
|
+
* Consumers can branch on this category to differentiate "user cancelled"
|
|
602
|
+
* from "server error" without resorting to message-string matching.
|
|
603
|
+
*/
|
|
604
|
+
ABORT = "abort"
|
|
598
605
|
}
|
|
599
606
|
export declare enum ErrorSeverity {
|
|
600
607
|
LOW = "low",
|
|
@@ -812,6 +812,13 @@ export var ErrorCategory;
|
|
|
812
812
|
ErrorCategory["CONFIGURATION"] = "configuration";
|
|
813
813
|
ErrorCategory["EXECUTION"] = "execution";
|
|
814
814
|
ErrorCategory["SYSTEM"] = "system";
|
|
815
|
+
/**
|
|
816
|
+
* Caller-initiated cancellation via AbortSignal. Distinct from system errors
|
|
817
|
+
* — represents a user/control-plane decision, not a SDK or provider failure.
|
|
818
|
+
* Consumers can branch on this category to differentiate "user cancelled"
|
|
819
|
+
* from "server error" without resorting to message-string matching.
|
|
820
|
+
*/
|
|
821
|
+
ErrorCategory["ABORT"] = "abort";
|
|
815
822
|
})(ErrorCategory || (ErrorCategory = {}));
|
|
816
823
|
// Error severity levels
|
|
817
824
|
export var ErrorSeverity;
|
package/dist/lib/neurolink.d.ts
CHANGED
|
@@ -60,6 +60,7 @@ export declare class NeuroLink {
|
|
|
60
60
|
private pendingAuthConfig?;
|
|
61
61
|
private authInitPromise?;
|
|
62
62
|
private credentials?;
|
|
63
|
+
private readonly fallbackConfig;
|
|
63
64
|
/**
|
|
64
65
|
* Merge instance-level credentials with per-call credentials.
|
|
65
66
|
*
|
|
@@ -541,6 +542,21 @@ export declare class NeuroLink {
|
|
|
541
542
|
* @since 1.0.0
|
|
542
543
|
*/
|
|
543
544
|
generate(optionsOrPrompt: GenerateOptions | DynamicOptions | string): Promise<GenerateResult>;
|
|
545
|
+
/**
|
|
546
|
+
* Curator P2-3: wraps a generate/stream call with the fallback
|
|
547
|
+
* orchestration (`providerFallback` callback + `modelChain` walker).
|
|
548
|
+
*
|
|
549
|
+
* On a model-access-denied error from the inner call:
|
|
550
|
+
* 1. Resolve the effective callback (per-call > instance > synthesised
|
|
551
|
+
* from modelChain) and the effective chain (per-call > instance).
|
|
552
|
+
* 2. Walk attempts: invoke callback (or pop next chain entry) → emit
|
|
553
|
+
* `model.fallback` event → re-call inner with the new {provider,
|
|
554
|
+
* model}.
|
|
555
|
+
* 3. Stop on first success, on a callback returning null, or after
|
|
556
|
+
* exhausting the chain (throw the most recent error).
|
|
557
|
+
*/
|
|
558
|
+
private runWithFallbackOrchestration;
|
|
559
|
+
private attemptInner;
|
|
544
560
|
private executeGenerateWithMetricsContext;
|
|
545
561
|
private executeGenerateRequest;
|
|
546
562
|
private prepareGenerateRequest;
|
|
@@ -697,6 +713,25 @@ export declare class NeuroLink {
|
|
|
697
713
|
* @throws {Error} When conversation memory operations fail (if enabled)
|
|
698
714
|
*/
|
|
699
715
|
stream(options: StreamOptions | DynamicOptions): Promise<StreamResult>;
|
|
716
|
+
/**
|
|
717
|
+
* Curator P2-3 / Reviewer Finding #2: stream-fallback that also covers
|
|
718
|
+
* errors thrown during async iteration (e.g. LiteLLM throwing inside
|
|
719
|
+
* `createLiteLLMTransformedStream`). The standard
|
|
720
|
+
* `runWithFallbackOrchestration` only catches errors thrown while the
|
|
721
|
+
* `StreamResult` is being created — once we hand the iterator back to
|
|
722
|
+
* the caller, errors raised during consumption used to bypass
|
|
723
|
+
* `providerFallback` / `modelChain`.
|
|
724
|
+
*
|
|
725
|
+
* This wrapper runs the orchestration to get an initial StreamResult,
|
|
726
|
+
* then wraps `result.stream` so that:
|
|
727
|
+
* - chunks are forwarded transparently while consumption succeeds
|
|
728
|
+
* - if iteration throws a model-access-denied error AND no chunks
|
|
729
|
+
* have been yielded yet, we resolve the next fallback target,
|
|
730
|
+
* emit `model.fallback`, and recurse
|
|
731
|
+
* - if chunks were already yielded, the error propagates (mid-stream
|
|
732
|
+
* recovery isn't safe — the consumer has half a response)
|
|
733
|
+
*/
|
|
734
|
+
private streamWithIterationFallback;
|
|
700
735
|
private executeStreamRequest;
|
|
701
736
|
private validateStreamRequestOptions;
|
|
702
737
|
private maybeHandleWorkflowStreamRequest;
|
|
@@ -881,8 +916,12 @@ export declare class NeuroLink {
|
|
|
881
916
|
* **Generation Events:**
|
|
882
917
|
* - `generation:start` - Fired when text generation begins
|
|
883
918
|
* - `{ provider: string, timestamp: number }`
|
|
884
|
-
* - `generation:end` - Fired when text generation completes
|
|
885
|
-
* - `{ provider: string, responseTime: number, toolsUsed?: string[], timestamp: number }`
|
|
919
|
+
* - `generation:end` - Fired when text generation completes (or fails / is aborted)
|
|
920
|
+
* - `{ provider: string, responseTime: number, toolsUsed?: string[], timestamp: number, success?: boolean, aborted?: boolean, error?: string }`
|
|
921
|
+
* - `success` is `false` for both failures and client aborts; `aborted: true`
|
|
922
|
+
* distinguishes the latter so consumers can route cancellations
|
|
923
|
+
* differently from real errors. Pipeline B's metrics span maps
|
|
924
|
+
* `aborted: true` events to `SpanStatus.WARNING` (not ERROR).
|
|
886
925
|
*
|
|
887
926
|
* **Streaming Events:**
|
|
888
927
|
* - `stream:start` - Fired when streaming begins
|