@jaypie/llm 1.3.9 → 1.3.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/Llm.d.ts +19 -11
- package/dist/cjs/constants.d.ts +53 -4
- package/dist/cjs/errors/LlmError.d.ts +62 -0
- package/dist/cjs/errors/toLlmError.d.ts +11 -0
- package/dist/cjs/index.cjs +739 -177
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +177 -19
- package/dist/cjs/index.d.ts +5 -1
- package/dist/cjs/operate/adapters/AnthropicAdapter.d.ts +3 -2
- package/dist/cjs/operate/adapters/BedrockAdapter.d.ts +1 -1
- package/dist/cjs/operate/adapters/GoogleAdapter.d.ts +1 -1
- package/dist/cjs/operate/adapters/OpenAiAdapter.d.ts +7 -1
- package/dist/cjs/operate/adapters/OpenRouterAdapter.d.ts +5 -1
- package/dist/cjs/operate/adapters/XaiAdapter.d.ts +11 -1
- package/dist/cjs/operate/retry/RetryExecutor.d.ts +13 -0
- package/dist/cjs/operate/types.d.ts +15 -1
- package/dist/cjs/providers/google/types.d.ts +5 -0
- package/dist/cjs/types/LlmProvider.interface.d.ts +18 -0
- package/dist/cjs/util/classifyProviderError.d.ts +13 -0
- package/dist/cjs/util/effort.d.ts +42 -0
- package/dist/cjs/util/resolveModelChain.d.ts +17 -0
- package/dist/esm/Llm.d.ts +19 -11
- package/dist/esm/constants.d.ts +53 -4
- package/dist/esm/errors/LlmError.d.ts +62 -0
- package/dist/esm/errors/toLlmError.d.ts +11 -0
- package/dist/esm/index.d.ts +177 -19
- package/dist/esm/index.js +705 -148
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/operate/adapters/AnthropicAdapter.d.ts +3 -2
- package/dist/esm/operate/adapters/BedrockAdapter.d.ts +1 -1
- package/dist/esm/operate/adapters/GoogleAdapter.d.ts +1 -1
- package/dist/esm/operate/adapters/OpenAiAdapter.d.ts +7 -1
- package/dist/esm/operate/adapters/OpenRouterAdapter.d.ts +5 -1
- package/dist/esm/operate/adapters/XaiAdapter.d.ts +11 -1
- package/dist/esm/operate/retry/RetryExecutor.d.ts +13 -0
- package/dist/esm/operate/types.d.ts +15 -1
- package/dist/esm/providers/google/types.d.ts +5 -0
- package/dist/esm/types/LlmProvider.interface.d.ts +18 -0
- package/dist/esm/util/classifyProviderError.d.ts +13 -0
- package/dist/esm/util/effort.d.ts +42 -0
- package/dist/esm/util/resolveModelChain.d.ts +17 -0
- package/package.json +1 -1
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,7 +1,25 @@
|
|
|
1
1
|
import * as _jaypie_types from '@jaypie/types';
|
|
2
2
|
import { JsonObject, AnyValue, NaturalMap, NaturalSchema, JsonReturn } from '@jaypie/types';
|
|
3
3
|
import { z } from 'zod/v4';
|
|
4
|
+
import { JaypieError } from '@jaypie/errors';
|
|
4
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Provider-neutral reasoning-effort levels — a five-point relative scale that
|
|
8
|
+
* deliberately borrows no provider's vocabulary. Each adapter translates these
|
|
9
|
+
* to its provider's native control (OpenAI `reasoning.effort`, Anthropic
|
|
10
|
+
* `output_config.effort`, Gemini `thinkingLevel`/`thinkingBudget`, Grok
|
|
11
|
+
* `reasoning_effort`, OpenRouter `reasoning.effort`), spreading the scale across
|
|
12
|
+
* the provider's available range. Omitting `effort` leaves the provider default
|
|
13
|
+
* untouched, so it is safe to set across a fallback chain.
|
|
14
|
+
*/
|
|
15
|
+
declare const EFFORT: {
|
|
16
|
+
readonly LOWEST: "lowest";
|
|
17
|
+
readonly LOW: "low";
|
|
18
|
+
readonly MEDIUM: "medium";
|
|
19
|
+
readonly HIGH: "high";
|
|
20
|
+
readonly HIGHEST: "highest";
|
|
21
|
+
};
|
|
22
|
+
type LlmEffort = (typeof EFFORT)[keyof typeof EFFORT];
|
|
5
23
|
declare const MODEL: {
|
|
6
24
|
FABLE: string;
|
|
7
25
|
OPUS: string;
|
|
@@ -11,13 +29,26 @@ declare const MODEL: {
|
|
|
11
29
|
GEMINI_FLASH: string;
|
|
12
30
|
GEMINI_FLASH_LITE: string;
|
|
13
31
|
GEMINI_PRO: string;
|
|
32
|
+
SOL: string;
|
|
33
|
+
TERRA: string;
|
|
34
|
+
LUNA: string;
|
|
35
|
+
/** @deprecated use MODEL.SOL (gpt-5.6-sol) */
|
|
14
36
|
GPT: string;
|
|
37
|
+
/** @deprecated use MODEL.TERRA (gpt-5.6-terra) */
|
|
15
38
|
GPT_MINI: string;
|
|
39
|
+
/** @deprecated use MODEL.LUNA (gpt-5.6-luna) */
|
|
16
40
|
GPT_NANO: string;
|
|
17
41
|
GROK: string;
|
|
42
|
+
OPENROUTER: {
|
|
43
|
+
GLM: string;
|
|
44
|
+
LUNA: string;
|
|
45
|
+
SONNET: string;
|
|
46
|
+
};
|
|
18
47
|
};
|
|
19
48
|
declare const PROVIDER: {
|
|
20
49
|
readonly BEDROCK: {
|
|
50
|
+
readonly DEFAULT: "amazon.nova-pro-v1:0";
|
|
51
|
+
/** @deprecated Size tiers are retired in 2.0. Use PROVIDER.BEDROCK.DEFAULT. */
|
|
21
52
|
readonly MODEL: {
|
|
22
53
|
readonly DEFAULT: "amazon.nova-lite-v1:0";
|
|
23
54
|
readonly LARGE: "amazon.nova-pro-v1:0";
|
|
@@ -29,16 +60,18 @@ declare const PROVIDER: {
|
|
|
29
60
|
readonly REGION: "AWS_REGION";
|
|
30
61
|
};
|
|
31
62
|
readonly ANTHROPIC: {
|
|
63
|
+
readonly DEFAULT: string;
|
|
32
64
|
readonly MAX_TOKENS: {
|
|
33
65
|
readonly DEFAULT: 16384;
|
|
34
66
|
};
|
|
67
|
+
/** @deprecated Size tiers are retired in 2.0. Use PROVIDER.ANTHROPIC.DEFAULT, or pick a specific model from MODEL.*. */
|
|
35
68
|
readonly MODEL: {
|
|
36
69
|
readonly DEFAULT: "claude-sonnet-4-6";
|
|
37
70
|
readonly LARGE: "claude-opus-4-8";
|
|
38
71
|
readonly SMALL: "claude-sonnet-4-6";
|
|
39
72
|
readonly TINY: "claude-haiku-4-5";
|
|
40
73
|
};
|
|
41
|
-
readonly MODEL_MATCH_WORDS: readonly ["anthropic", "claude", "haiku", "opus", "sonnet"];
|
|
74
|
+
readonly MODEL_MATCH_WORDS: readonly ["anthropic", "claude", "fable", "haiku", "mythos", "opus", "sonnet"];
|
|
42
75
|
readonly NAME: "anthropic";
|
|
43
76
|
readonly PROMPT: {
|
|
44
77
|
readonly AI: "\n\nAssistant:";
|
|
@@ -55,6 +88,8 @@ declare const PROVIDER: {
|
|
|
55
88
|
};
|
|
56
89
|
/** @deprecated Use PROVIDER.GOOGLE — "Google" is the provider; Gemini is the model family */
|
|
57
90
|
readonly GEMINI: {
|
|
91
|
+
readonly DEFAULT: string;
|
|
92
|
+
/** @deprecated Size tiers are retired in 2.0. Use PROVIDER.GOOGLE.DEFAULT, or pick a specific model from MODEL.*. */
|
|
58
93
|
readonly MODEL: {
|
|
59
94
|
readonly DEFAULT: "gemini-3.1-pro-preview";
|
|
60
95
|
readonly LARGE: "gemini-3.1-pro-preview";
|
|
@@ -69,6 +104,8 @@ declare const PROVIDER: {
|
|
|
69
104
|
};
|
|
70
105
|
};
|
|
71
106
|
readonly GOOGLE: {
|
|
107
|
+
readonly DEFAULT: string;
|
|
108
|
+
/** @deprecated Size tiers are retired in 2.0. Use PROVIDER.GOOGLE.DEFAULT, or pick a specific model from MODEL.*. */
|
|
72
109
|
readonly MODEL: {
|
|
73
110
|
readonly DEFAULT: "gemini-3.1-pro-preview";
|
|
74
111
|
readonly LARGE: "gemini-3.1-pro-preview";
|
|
@@ -83,16 +120,20 @@ declare const PROVIDER: {
|
|
|
83
120
|
};
|
|
84
121
|
};
|
|
85
122
|
readonly OPENAI: {
|
|
123
|
+
readonly DEFAULT: string;
|
|
124
|
+
/** @deprecated Size tiers are retired in 2.0. Use PROVIDER.OPENAI.DEFAULT, or pick a specific model from MODEL.*. */
|
|
86
125
|
readonly MODEL: {
|
|
87
126
|
readonly DEFAULT: "gpt-5.4";
|
|
88
127
|
readonly LARGE: "gpt-5.5";
|
|
89
128
|
readonly SMALL: "gpt-5.4-mini";
|
|
90
129
|
readonly TINY: "gpt-5.4-nano";
|
|
91
130
|
};
|
|
92
|
-
readonly MODEL_MATCH_WORDS: readonly ["openai", "
|
|
131
|
+
readonly MODEL_MATCH_WORDS: readonly ["gpt", "luna", "openai", "sol", "terra", RegExp];
|
|
93
132
|
readonly NAME: "openai";
|
|
94
133
|
};
|
|
95
134
|
readonly OPENROUTER: {
|
|
135
|
+
readonly DEFAULT: string;
|
|
136
|
+
/** @deprecated Size tiers are retired in 2.0. Use PROVIDER.OPENROUTER.DEFAULT, or pick a specific route from MODEL.OPENROUTER.*. */
|
|
96
137
|
readonly MODEL: {
|
|
97
138
|
readonly DEFAULT: "anthropic/claude-sonnet-4-6";
|
|
98
139
|
readonly LARGE: "anthropic/claude-opus-4-8";
|
|
@@ -111,6 +152,8 @@ declare const PROVIDER: {
|
|
|
111
152
|
readonly XAI: {
|
|
112
153
|
readonly API_KEY: "XAI_API_KEY";
|
|
113
154
|
readonly BASE_URL: "https://api.x.ai/v1";
|
|
155
|
+
readonly DEFAULT: string;
|
|
156
|
+
/** @deprecated Size tiers are retired in 2.0. Use PROVIDER.XAI.DEFAULT, or pick a specific model from MODEL.*. */
|
|
114
157
|
readonly MODEL: {
|
|
115
158
|
readonly DEFAULT: "grok-latest";
|
|
116
159
|
readonly LARGE: "grok-latest";
|
|
@@ -123,6 +166,7 @@ declare const PROVIDER: {
|
|
|
123
166
|
};
|
|
124
167
|
type LlmProviderName = typeof PROVIDER.ANTHROPIC.NAME | typeof PROVIDER.BEDROCK.NAME | typeof PROVIDER.GOOGLE.NAME | typeof PROVIDER.OPENAI.NAME | typeof PROVIDER.OPENROUTER.NAME | typeof PROVIDER.XAI.NAME;
|
|
125
168
|
declare const DEFAULT: {
|
|
169
|
+
/** @deprecated Size tiers are retired in 2.0. Use DEFAULT.PROVIDER.DEFAULT, or pick a specific model from MODEL.*. */
|
|
126
170
|
readonly MODEL: {
|
|
127
171
|
readonly BASE: "gpt-5.4";
|
|
128
172
|
readonly LARGE: "gpt-5.5";
|
|
@@ -130,16 +174,22 @@ declare const DEFAULT: {
|
|
|
130
174
|
readonly TINY: "gpt-5.4-nano";
|
|
131
175
|
};
|
|
132
176
|
readonly PROVIDER: {
|
|
177
|
+
readonly DEFAULT: string;
|
|
178
|
+
/** @deprecated Size tiers are retired in 2.0. Use PROVIDER.OPENAI.DEFAULT, or pick a specific model from MODEL.*. */
|
|
133
179
|
readonly MODEL: {
|
|
134
180
|
readonly DEFAULT: "gpt-5.4";
|
|
135
181
|
readonly LARGE: "gpt-5.5";
|
|
136
182
|
readonly SMALL: "gpt-5.4-mini";
|
|
137
183
|
readonly TINY: "gpt-5.4-nano";
|
|
138
184
|
};
|
|
139
|
-
readonly MODEL_MATCH_WORDS: readonly ["openai", "
|
|
185
|
+
readonly MODEL_MATCH_WORDS: readonly ["gpt", "luna", "openai", "sol", "terra", RegExp];
|
|
140
186
|
readonly NAME: "openai";
|
|
141
187
|
};
|
|
142
188
|
};
|
|
189
|
+
/**
|
|
190
|
+
* @deprecated Size-tier catalogs are retired in 2.0. Pick specific models from
|
|
191
|
+
* MODEL.* (grouped by provider via MODEL_MATCH_WORDS / determineModelProvider).
|
|
192
|
+
*/
|
|
143
193
|
declare const ALL: {
|
|
144
194
|
readonly BASE: readonly ["claude-sonnet-4-6", "gemini-3.1-pro-preview", "gpt-5.4", "grok-latest"];
|
|
145
195
|
readonly COMBINED: readonly ("claude-opus-4-8" | "claude-haiku-4-5" | "gemini-3.5-flash" | "gemini-3.1-flash-lite" | "gemini-3.1-pro-preview" | "gpt-5.5" | "gpt-5.4-mini" | "gpt-5.4-nano" | "grok-latest" | "claude-sonnet-4-6" | "gpt-5.4" | "grok-4-1-fast-reasoning" | "grok-4-1-fast-non-reasoning")[];
|
|
@@ -150,12 +200,14 @@ declare const ALL: {
|
|
|
150
200
|
|
|
151
201
|
declare const constants_ALL: typeof ALL;
|
|
152
202
|
declare const constants_DEFAULT: typeof DEFAULT;
|
|
203
|
+
declare const constants_EFFORT: typeof EFFORT;
|
|
204
|
+
type constants_LlmEffort = LlmEffort;
|
|
153
205
|
type constants_LlmProviderName = LlmProviderName;
|
|
154
206
|
declare const constants_MODEL: typeof MODEL;
|
|
155
207
|
declare const constants_PROVIDER: typeof PROVIDER;
|
|
156
208
|
declare namespace constants {
|
|
157
|
-
export { constants_ALL as ALL, constants_DEFAULT as DEFAULT, constants_MODEL as MODEL, constants_PROVIDER as PROVIDER };
|
|
158
|
-
export type { constants_LlmProviderName as LlmProviderName };
|
|
209
|
+
export { constants_ALL as ALL, constants_DEFAULT as DEFAULT, constants_EFFORT as EFFORT, constants_MODEL as MODEL, constants_PROVIDER as PROVIDER };
|
|
210
|
+
export type { constants_LlmEffort as LlmEffort, constants_LlmProviderName as LlmProviderName };
|
|
159
211
|
}
|
|
160
212
|
|
|
161
213
|
interface LlmTool {
|
|
@@ -273,7 +325,7 @@ declare enum LlmResponseStatus {
|
|
|
273
325
|
Incomplete = "incomplete",
|
|
274
326
|
InProgress = "in_progress"
|
|
275
327
|
}
|
|
276
|
-
interface LlmError {
|
|
328
|
+
interface LlmError$1 {
|
|
277
329
|
detail?: string;
|
|
278
330
|
status: number | string;
|
|
279
331
|
title: string;
|
|
@@ -461,6 +513,14 @@ interface LlmProgressEvent {
|
|
|
461
513
|
type LlmProgressCallback = (event: LlmProgressEvent) => unknown | Promise<unknown>;
|
|
462
514
|
interface LlmOperateOptions {
|
|
463
515
|
data?: NaturalMap;
|
|
516
|
+
/**
|
|
517
|
+
* Provider-neutral reasoning effort (lowest | low | medium | high | highest).
|
|
518
|
+
* Each provider translates it to its native control, spreading the scale
|
|
519
|
+
* across the provider's range; omitting it leaves the provider default
|
|
520
|
+
* untouched, so it is safe across a fallback chain. Providers without
|
|
521
|
+
* reasoning control ignore it.
|
|
522
|
+
*/
|
|
523
|
+
effort?: LlmEffort;
|
|
464
524
|
explain?: boolean;
|
|
465
525
|
/** Chain of fallback providers to try if primary fails. Set to false to disable instance-level fallback. */
|
|
466
526
|
fallback?: LlmFallbackConfig[] | false;
|
|
@@ -534,6 +594,15 @@ interface LlmOperateOptions {
|
|
|
534
594
|
turns?: boolean | number;
|
|
535
595
|
user?: string;
|
|
536
596
|
}
|
|
597
|
+
/**
|
|
598
|
+
* A single model name, or a preference-ordered array of model names.
|
|
599
|
+
* An array is interpreted as a fallback chain: index 0 is primary, later
|
|
600
|
+
* entries are tried in order when earlier ones fail (provider auto-detected
|
|
601
|
+
* per entry). Accepted by the `Llm` constructor and static/instance
|
|
602
|
+
* `operate`/`send`/`stream` methods; normalized to a scalar model plus a
|
|
603
|
+
* derived fallback chain before reaching providers.
|
|
604
|
+
*/
|
|
605
|
+
type LlmModelOption = string | string[];
|
|
537
606
|
interface LlmOptions {
|
|
538
607
|
apiKey?: string;
|
|
539
608
|
/** Chain of fallback providers to try if primary fails */
|
|
@@ -551,7 +620,7 @@ interface LlmUsageItem {
|
|
|
551
620
|
type LlmUsage = LlmUsageItem[];
|
|
552
621
|
interface LlmOperateResponse {
|
|
553
622
|
content?: string | JsonObject;
|
|
554
|
-
error?: LlmError;
|
|
623
|
+
error?: LlmError$1;
|
|
555
624
|
/** Number of providers attempted (1 = primary only, >1 = fallback(s) used) */
|
|
556
625
|
fallbackAttempts?: number;
|
|
557
626
|
/** Whether a fallback provider was used instead of the primary */
|
|
@@ -577,9 +646,13 @@ declare class Llm implements LlmProvider {
|
|
|
577
646
|
private _llm;
|
|
578
647
|
private _options;
|
|
579
648
|
private _provider;
|
|
580
|
-
constructor(providerName?: LlmProviderName | string, options?: LlmOptions
|
|
649
|
+
constructor(providerName?: LlmProviderName | string, options?: Omit<LlmOptions, "model"> & {
|
|
650
|
+
model?: LlmModelOption;
|
|
651
|
+
});
|
|
581
652
|
private createProvider;
|
|
582
|
-
send(message: string, options?: LlmMessageOptions
|
|
653
|
+
send(message: string, options?: Omit<LlmMessageOptions, "model"> & {
|
|
654
|
+
model?: LlmModelOption;
|
|
655
|
+
}): Promise<string | JsonObject>;
|
|
583
656
|
/**
|
|
584
657
|
* Resolves the fallback chain from instance config and per-call options.
|
|
585
658
|
* Per-call options take precedence over instance config.
|
|
@@ -590,23 +663,27 @@ declare class Llm implements LlmProvider {
|
|
|
590
663
|
* Creates a fallback Llm instance lazily when needed.
|
|
591
664
|
*/
|
|
592
665
|
private createFallbackInstance;
|
|
593
|
-
operate(input: string | LlmHistory | LlmInputMessage | LlmOperateInput, options?: LlmOperateOptions
|
|
594
|
-
|
|
595
|
-
|
|
666
|
+
operate(input: string | LlmHistory | LlmInputMessage | LlmOperateInput, options?: Omit<LlmOperateOptions, "model"> & {
|
|
667
|
+
model?: LlmModelOption;
|
|
668
|
+
}): Promise<LlmOperateResponse>;
|
|
669
|
+
stream(input: string | LlmHistory | LlmInputMessage | LlmOperateInput, options?: Omit<LlmOperateOptions, "model"> & {
|
|
670
|
+
model?: LlmModelOption;
|
|
671
|
+
}): AsyncIterable<LlmStreamChunk>;
|
|
672
|
+
static send(message: string, options?: Omit<LlmMessageOptions, "model"> & {
|
|
596
673
|
llm?: LlmProviderName;
|
|
597
674
|
apiKey?: string;
|
|
598
|
-
model?: string;
|
|
675
|
+
model?: string | string[];
|
|
599
676
|
}): Promise<string | JsonObject>;
|
|
600
|
-
static operate(input: string | LlmHistory | LlmInputMessage | LlmOperateInput, options?: LlmOperateOptions & {
|
|
677
|
+
static operate(input: string | LlmHistory | LlmInputMessage | LlmOperateInput, options?: Omit<LlmOperateOptions, "model"> & {
|
|
601
678
|
apiKey?: string;
|
|
602
679
|
fallback?: LlmFallbackConfig[] | false;
|
|
603
680
|
llm?: LlmProviderName;
|
|
604
|
-
model?: string;
|
|
681
|
+
model?: string | string[];
|
|
605
682
|
}): Promise<LlmOperateResponse>;
|
|
606
|
-
static stream(input: string | LlmHistory | LlmInputMessage | LlmOperateInput, options?: LlmOperateOptions & {
|
|
683
|
+
static stream(input: string | LlmHistory | LlmInputMessage | LlmOperateInput, options?: Omit<LlmOperateOptions, "model"> & {
|
|
607
684
|
llm?: LlmProviderName;
|
|
608
685
|
apiKey?: string;
|
|
609
|
-
model?: string;
|
|
686
|
+
model?: string | string[];
|
|
610
687
|
}): AsyncIterable<LlmStreamChunk>;
|
|
611
688
|
}
|
|
612
689
|
|
|
@@ -637,6 +714,87 @@ declare class JaypieToolkit extends Toolkit {
|
|
|
637
714
|
}
|
|
638
715
|
declare const toolkit: JaypieToolkit;
|
|
639
716
|
|
|
717
|
+
/**
|
|
718
|
+
* Categories of errors for retry logic
|
|
719
|
+
*/
|
|
720
|
+
declare enum ErrorCategory {
|
|
721
|
+
/** Error is transient and can be retried */
|
|
722
|
+
Retryable = "retryable",
|
|
723
|
+
/** Error is due to short-term rate limiting (retry after a delay) */
|
|
724
|
+
RateLimit = "rate_limit",
|
|
725
|
+
/**
|
|
726
|
+
* Provider quota is exhausted or the account cannot be billed
|
|
727
|
+
* (insufficient funds, daily quota, plan limit). Terminal and actionable —
|
|
728
|
+
* retrying within the request budget will not help.
|
|
729
|
+
*/
|
|
730
|
+
Quota = "quota",
|
|
731
|
+
/** Error cannot be recovered from */
|
|
732
|
+
Unrecoverable = "unrecoverable",
|
|
733
|
+
/** Error type is unknown */
|
|
734
|
+
Unknown = "unknown"
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
interface LlmErrorOptions {
|
|
738
|
+
/** Provider name that produced the error (e.g. "anthropic", "google") */
|
|
739
|
+
provider?: string;
|
|
740
|
+
/** Model in use when the error occurred */
|
|
741
|
+
model?: string;
|
|
742
|
+
/** Milliseconds to wait before retrying, when the provider suggests one */
|
|
743
|
+
retryAfterMs?: number;
|
|
744
|
+
/** The original provider error, preserved for inspection */
|
|
745
|
+
cause?: unknown;
|
|
746
|
+
}
|
|
747
|
+
/**
|
|
748
|
+
* Normalized, provider-agnostic LLM error. Thrown by the operate/stream retry
|
|
749
|
+
* layer when a request cannot be completed, so consumers can `catch` a stable
|
|
750
|
+
* type regardless of which provider failed. Extends {@link JaypieError} so
|
|
751
|
+
* `isJaypieError()` and `.status` continue to work; the original provider error
|
|
752
|
+
* is preserved on `.cause`.
|
|
753
|
+
*/
|
|
754
|
+
declare class LlmError extends JaypieError {
|
|
755
|
+
readonly category: ErrorCategory;
|
|
756
|
+
readonly provider?: string;
|
|
757
|
+
readonly model?: string;
|
|
758
|
+
readonly retryAfterMs?: number;
|
|
759
|
+
readonly cause?: unknown;
|
|
760
|
+
constructor(message: string, category: ErrorCategory, { status, title, provider, model, retryAfterMs, cause, }?: LlmErrorOptions & {
|
|
761
|
+
status?: number;
|
|
762
|
+
title?: string;
|
|
763
|
+
});
|
|
764
|
+
}
|
|
765
|
+
/**
|
|
766
|
+
* Short-term rate limiting (per-minute 429). Terminal within the request
|
|
767
|
+
* budget; `retryAfterMs` carries the provider's suggested wait when available.
|
|
768
|
+
*/
|
|
769
|
+
declare class LlmRateLimitError extends LlmError {
|
|
770
|
+
constructor(message: string, options?: LlmErrorOptions);
|
|
771
|
+
}
|
|
772
|
+
/**
|
|
773
|
+
* Provider quota is exhausted or the account cannot be billed. Terminal and
|
|
774
|
+
* actionable. `reason` distinguishes an exhausted usage quota from insufficient
|
|
775
|
+
* funds.
|
|
776
|
+
*/
|
|
777
|
+
declare class LlmQuotaError extends LlmError {
|
|
778
|
+
readonly reason: "quota" | "billing";
|
|
779
|
+
constructor(message: string, { reason, ...options }?: LlmErrorOptions & {
|
|
780
|
+
reason?: "quota" | "billing";
|
|
781
|
+
});
|
|
782
|
+
}
|
|
783
|
+
/**
|
|
784
|
+
* The request cannot be recovered from (bad request, authentication,
|
|
785
|
+
* permission, not found). Terminal.
|
|
786
|
+
*/
|
|
787
|
+
declare class LlmUnrecoverableError extends LlmError {
|
|
788
|
+
constructor(message: string, options?: LlmErrorOptions);
|
|
789
|
+
}
|
|
790
|
+
/**
|
|
791
|
+
* A transient or unknown error survived the retry budget. Terminal only because
|
|
792
|
+
* retries were exhausted; the underlying condition may succeed later.
|
|
793
|
+
*/
|
|
794
|
+
declare class LlmTransientError extends LlmError {
|
|
795
|
+
constructor(message: string, options?: LlmErrorOptions);
|
|
796
|
+
}
|
|
797
|
+
|
|
640
798
|
/**
|
|
641
799
|
* Extracts reasoning text from LLM history items.
|
|
642
800
|
*
|
|
@@ -739,5 +897,5 @@ declare class XaiProvider implements LlmProvider {
|
|
|
739
897
|
stream(input: string | LlmHistory | LlmInputMessage, options?: LlmOperateOptions): AsyncIterable<LlmStreamChunk>;
|
|
740
898
|
}
|
|
741
899
|
|
|
742
|
-
export { BedrockProvider, GoogleProvider as GeminiProvider, GoogleProvider, JaypieToolkit, constants as LLM, Llm, LlmMessageRole, LlmMessageType, LlmProgressEventType, LlmStreamChunkType, OpenRouterProvider, Toolkit, XaiProvider, extractReasoning, isLlmOperateInput, isLlmOperateInputContent, isLlmOperateInputFile, isLlmOperateInputImage, jsonSchemaToNaturalSchema, naturalSchemaToJsonSchema, toolkit, tools };
|
|
743
|
-
export type { LlmFallbackConfig, LlmHistory, LlmInputContent, LlmInputContentFile, LlmInputContentImage, LlmInputContentText, LlmInputMessage, LlmMessageOptions, LlmOperateInput, LlmOperateInputContent, LlmOperateInputFile, LlmOperateInputImage, LlmOperateOptions, LlmOperateResponse, LlmOptions, LlmProgressCallback, LlmProgressEvent, LlmProgressToolCall, LlmProvider, LlmStreamChunk, LlmStreamChunkDone, LlmStreamChunkError, LlmStreamChunkText, LlmStreamChunkToolCall, LlmStreamChunkToolResult, LlmTool };
|
|
900
|
+
export { BedrockProvider, ErrorCategory, GoogleProvider as GeminiProvider, GoogleProvider, JaypieToolkit, constants as LLM, Llm, LlmError, LlmMessageRole, LlmMessageType, LlmProgressEventType, LlmQuotaError, LlmRateLimitError, LlmStreamChunkType, LlmTransientError, LlmUnrecoverableError, OpenRouterProvider, Toolkit, XaiProvider, extractReasoning, isLlmOperateInput, isLlmOperateInputContent, isLlmOperateInputFile, isLlmOperateInputImage, jsonSchemaToNaturalSchema, naturalSchemaToJsonSchema, toolkit, tools };
|
|
901
|
+
export type { LlmEffort, LlmErrorOptions, LlmFallbackConfig, LlmHistory, LlmInputContent, LlmInputContentFile, LlmInputContentImage, LlmInputContentText, LlmInputMessage, LlmMessageOptions, LlmModelOption, LlmOperateInput, LlmOperateInputContent, LlmOperateInputFile, LlmOperateInputImage, LlmOperateOptions, LlmOperateResponse, LlmOptions, LlmProgressCallback, LlmProgressEvent, LlmProgressToolCall, LlmProvider, LlmStreamChunk, LlmStreamChunkDone, LlmStreamChunkError, LlmStreamChunkText, LlmStreamChunkToolCall, LlmStreamChunkToolResult, LlmTool };
|