@jaypie/llm 1.2.10 → 1.2.11
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 +18 -9
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/operate/adapters/OpenRouterAdapter.d.ts +2 -2
- package/dist/cjs/operate/adapters/ProviderAdapter.interface.d.ts +5 -3
- package/dist/cjs/operate/retry/RetryExecutor.d.ts +6 -3
- package/dist/esm/index.js +18 -9
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/operate/adapters/OpenRouterAdapter.d.ts +2 -2
- package/dist/esm/operate/adapters/ProviderAdapter.interface.d.ts +5 -3
- package/dist/esm/operate/retry/RetryExecutor.d.ts +6 -3
- package/package.json +1 -1
|
@@ -88,8 +88,8 @@ export declare class OpenRouterAdapter extends BaseProviderAdapter {
|
|
|
88
88
|
buildRequest(request: OperateRequest): OpenRouterRequest;
|
|
89
89
|
formatTools(toolkit: Toolkit, outputSchema?: JsonObject): ProviderToolDefinition[];
|
|
90
90
|
formatOutputSchema(schema: JsonObject | NaturalSchema | z.ZodType): JsonObject;
|
|
91
|
-
executeRequest(client: unknown, request: unknown): Promise<OpenRouterResponse>;
|
|
92
|
-
executeStreamRequest(client: unknown, request: unknown): AsyncIterable<LlmStreamChunk>;
|
|
91
|
+
executeRequest(client: unknown, request: unknown, signal?: AbortSignal): Promise<OpenRouterResponse>;
|
|
92
|
+
executeStreamRequest(client: unknown, request: unknown, signal?: AbortSignal): AsyncIterable<LlmStreamChunk>;
|
|
93
93
|
parseResponse(response: unknown, _options?: LlmOperateOptions): ParsedResponse;
|
|
94
94
|
extractToolCalls(response: unknown): StandardToolCall[];
|
|
95
95
|
extractUsage(response: unknown, model: string): LlmUsageItem;
|
|
@@ -47,17 +47,19 @@ export interface ProviderAdapter {
|
|
|
47
47
|
*
|
|
48
48
|
* @param client - The provider's SDK client instance
|
|
49
49
|
* @param request - Provider-specific request object (from buildRequest)
|
|
50
|
+
* @param signal - Optional AbortSignal to cancel the request on retry
|
|
50
51
|
* @returns Raw provider response
|
|
51
52
|
*/
|
|
52
|
-
executeRequest(client: unknown, request: unknown): Promise<unknown>;
|
|
53
|
+
executeRequest(client: unknown, request: unknown, signal?: AbortSignal): Promise<unknown>;
|
|
53
54
|
/**
|
|
54
55
|
* Execute a streaming API request to the provider
|
|
55
56
|
*
|
|
56
57
|
* @param client - The provider's SDK client instance
|
|
57
58
|
* @param request - Provider-specific request object (from buildRequest)
|
|
59
|
+
* @param signal - Optional AbortSignal to cancel the request on retry
|
|
58
60
|
* @returns AsyncIterable of stream chunks
|
|
59
61
|
*/
|
|
60
|
-
executeStreamRequest?(client: unknown, request: unknown): AsyncIterable<LlmStreamChunk>;
|
|
62
|
+
executeStreamRequest?(client: unknown, request: unknown, signal?: AbortSignal): AsyncIterable<LlmStreamChunk>;
|
|
61
63
|
/**
|
|
62
64
|
* Parse a provider response into standardized format
|
|
63
65
|
*
|
|
@@ -158,7 +160,7 @@ export declare abstract class BaseProviderAdapter implements ProviderAdapter {
|
|
|
158
160
|
abstract buildRequest(request: OperateRequest): unknown;
|
|
159
161
|
abstract formatTools(toolkit: Toolkit, outputSchema?: JsonObject): ProviderToolDefinition[];
|
|
160
162
|
abstract formatOutputSchema(schema: JsonObject | NaturalSchema | z.ZodType): JsonObject;
|
|
161
|
-
abstract executeRequest(client: unknown, request: unknown): Promise<unknown>;
|
|
163
|
+
abstract executeRequest(client: unknown, request: unknown, signal?: AbortSignal): Promise<unknown>;
|
|
162
164
|
abstract parseResponse(response: unknown, options?: LlmOperateOptions): ParsedResponse;
|
|
163
165
|
abstract extractToolCalls(response: unknown): StandardToolCall[];
|
|
164
166
|
abstract extractUsage(response: unknown, model: string): LlmUsageItem;
|
|
@@ -28,12 +28,15 @@ export declare class RetryExecutor {
|
|
|
28
28
|
private readonly errorClassifier;
|
|
29
29
|
constructor(config: RetryExecutorConfig);
|
|
30
30
|
/**
|
|
31
|
-
* Execute an operation with retry logic
|
|
31
|
+
* Execute an operation with retry logic.
|
|
32
|
+
* Each attempt receives an AbortSignal. On failure, the signal is aborted
|
|
33
|
+
* before sleeping — this kills lingering socket callbacks from the previous
|
|
34
|
+
* request and prevents stale async errors from escaping the retry loop.
|
|
32
35
|
*
|
|
33
|
-
* @param operation - The async operation to execute
|
|
36
|
+
* @param operation - The async operation to execute (receives AbortSignal)
|
|
34
37
|
* @param options - Execution options including context and hooks
|
|
35
38
|
* @returns The result of the operation
|
|
36
39
|
* @throws BadGatewayError if all retries are exhausted or error is not retryable
|
|
37
40
|
*/
|
|
38
|
-
execute<T>(operation: () => Promise<T
|
|
41
|
+
execute<T>(operation: ((signal: AbortSignal) => Promise<T>) | (() => Promise<T>), options: ExecuteOptions): Promise<T>;
|
|
39
42
|
}
|