@jaypie/llm 1.2.9 → 1.2.10
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/dist/cjs/index.cjs +185 -23
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/operate/StreamLoop.d.ts +3 -0
- package/dist/cjs/operate/retry/index.d.ts +1 -0
- package/dist/cjs/operate/retry/isTransientNetworkError.d.ts +18 -0
- package/dist/esm/index.js +185 -23
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/operate/StreamLoop.d.ts +3 -0
- package/dist/esm/operate/retry/index.d.ts +1 -0
- package/dist/esm/operate/retry/isTransientNetworkError.d.ts +18 -0
- package/package.json +1 -1
|
@@ -3,11 +3,13 @@ import { LlmStreamChunk } from "../types/LlmStreamChunk.interface.js";
|
|
|
3
3
|
import { ProviderAdapter } from "./adapters/ProviderAdapter.interface.js";
|
|
4
4
|
import { HookRunner } from "./hooks/index.js";
|
|
5
5
|
import { InputProcessor } from "./input/index.js";
|
|
6
|
+
import { RetryPolicy } from "./retry/index.js";
|
|
6
7
|
export interface StreamLoopConfig {
|
|
7
8
|
adapter: ProviderAdapter;
|
|
8
9
|
client: unknown;
|
|
9
10
|
hookRunner?: HookRunner;
|
|
10
11
|
inputProcessor?: InputProcessor;
|
|
12
|
+
retryPolicy?: RetryPolicy;
|
|
11
13
|
}
|
|
12
14
|
/**
|
|
13
15
|
* StreamLoop implements streaming multi-turn conversation loop.
|
|
@@ -19,6 +21,7 @@ export declare class StreamLoop {
|
|
|
19
21
|
private readonly client;
|
|
20
22
|
private readonly hookRunnerInstance;
|
|
21
23
|
private readonly inputProcessorInstance;
|
|
24
|
+
private readonly retryPolicy;
|
|
22
25
|
constructor(config: StreamLoopConfig);
|
|
23
26
|
/**
|
|
24
27
|
* Execute the streaming loop for multi-turn conversations with tool calling.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { DEFAULT_BACKOFF_FACTOR, DEFAULT_INITIAL_DELAY_MS, DEFAULT_MAX_DELAY_MS, DEFAULT_MAX_RETRIES, defaultRetryPolicy, MAX_RETRIES_ABSOLUTE_LIMIT, RetryPolicy, } from "./RetryPolicy.js";
|
|
2
2
|
export type { RetryPolicyConfig } from "./RetryPolicy.js";
|
|
3
|
+
export { isTransientNetworkError } from "./isTransientNetworkError.js";
|
|
3
4
|
export { RetryExecutor } from "./RetryExecutor.js";
|
|
4
5
|
export type { ErrorClassifier, ExecuteOptions, RetryContext, RetryExecutorConfig, } from "./RetryExecutor.js";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transient network error detection utility.
|
|
3
|
+
*
|
|
4
|
+
* Detects low-level Node.js/undici network errors that indicate
|
|
5
|
+
* a temporary network issue (not a provider API error).
|
|
6
|
+
* These errors should always be retried.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Detect transient network errors by inspecting the error and its cause chain.
|
|
10
|
+
*
|
|
11
|
+
* Undici (Node.js fetch) wraps low-level errors like ECONNRESET inside
|
|
12
|
+
* `TypeError: terminated`. This function recursively walks `error.cause`
|
|
13
|
+
* to detect these wrapped errors.
|
|
14
|
+
*
|
|
15
|
+
* @param error - The error to inspect
|
|
16
|
+
* @returns true if the error (or any cause in its chain) is a transient network error
|
|
17
|
+
*/
|
|
18
|
+
export declare function isTransientNetworkError(error: unknown): boolean;
|