@providerkit/core 0.29.1 → 0.31.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/README.md +58 -9
- package/THIRD_PARTY_NOTICES +144 -0
- package/dist/auth/chatgpt-models.js.map +1 -1
- package/dist/auth/oauth.d.ts.map +1 -1
- package/dist/auth/oauth.js.map +1 -1
- package/dist/capability.js.map +1 -1
- package/dist/context.d.ts +4 -3
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +19 -5
- package/dist/context.js.map +1 -1
- package/dist/decisions.js.map +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +29 -2
- package/dist/errors.js.map +1 -1
- package/dist/fallback.d.ts +3 -0
- package/dist/fallback.d.ts.map +1 -1
- package/dist/fallback.js +9 -5
- package/dist/fallback.js.map +1 -1
- package/dist/gate.js.map +1 -1
- package/dist/hosted/anthropic.d.ts +30 -0
- package/dist/hosted/anthropic.d.ts.map +1 -0
- package/dist/hosted/anthropic.js +465 -0
- package/dist/hosted/anthropic.js.map +1 -0
- package/dist/hosted/gemini.d.ts +22 -0
- package/dist/hosted/gemini.d.ts.map +1 -0
- package/dist/hosted/gemini.js +440 -0
- package/dist/hosted/gemini.js.map +1 -0
- package/dist/hosted/openai.d.ts +33 -0
- package/dist/hosted/openai.d.ts.map +1 -0
- package/dist/hosted/openai.js +107 -0
- package/dist/hosted/openai.js.map +1 -0
- package/dist/hosted/responses.d.ts +28 -0
- package/dist/hosted/responses.d.ts.map +1 -0
- package/dist/hosted/responses.js +358 -0
- package/dist/hosted/responses.js.map +1 -0
- package/dist/hosted/shared.d.ts +107 -0
- package/dist/hosted/shared.d.ts.map +1 -0
- package/dist/hosted/shared.js +264 -0
- package/dist/hosted/shared.js.map +1 -0
- package/dist/hosted/types.d.ts +191 -0
- package/dist/hosted/types.d.ts.map +1 -0
- package/dist/hosted/types.js +10 -0
- package/dist/hosted/types.js.map +1 -0
- package/dist/hosted.d.ts +33 -0
- package/dist/hosted.d.ts.map +1 -0
- package/dist/hosted.js +61 -0
- package/dist/hosted.js.map +1 -0
- package/dist/index.d.ts +8 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -7
- package/dist/index.js.map +1 -1
- package/dist/key-pool.d.ts.map +1 -1
- package/dist/key-pool.js.map +1 -1
- package/dist/presets.d.ts +36 -5
- package/dist/presets.d.ts.map +1 -1
- package/dist/presets.js +32 -8
- package/dist/presets.js.map +1 -1
- package/dist/providers/anthropic.d.ts +75 -1
- package/dist/providers/anthropic.d.ts.map +1 -1
- package/dist/providers/anthropic.js +207 -135
- package/dist/providers/anthropic.js.map +1 -1
- package/dist/providers/deepgram-transcription.d.ts +24 -0
- package/dist/providers/deepgram-transcription.d.ts.map +1 -0
- package/dist/providers/deepgram-transcription.js +84 -0
- package/dist/providers/deepgram-transcription.js.map +1 -0
- package/dist/providers/factory.d.ts +10 -0
- package/dist/providers/factory.d.ts.map +1 -1
- package/dist/providers/factory.js +31 -23
- package/dist/providers/factory.js.map +1 -1
- package/dist/providers/gemini.d.ts +123 -1
- package/dist/providers/gemini.d.ts.map +1 -1
- package/dist/providers/gemini.js +114 -54
- package/dist/providers/gemini.js.map +1 -1
- package/dist/providers/hosted-codecs.d.ts +10 -0
- package/dist/providers/hosted-codecs.d.ts.map +1 -0
- package/dist/providers/hosted-codecs.js +8 -0
- package/dist/providers/hosted-codecs.js.map +1 -0
- package/dist/providers/openai-transcription.d.ts +21 -0
- package/dist/providers/openai-transcription.d.ts.map +1 -0
- package/dist/providers/openai-transcription.js +144 -0
- package/dist/providers/openai-transcription.js.map +1 -0
- package/dist/providers/openai.d.ts +69 -0
- package/dist/providers/openai.d.ts.map +1 -1
- package/dist/providers/openai.js +38 -14
- package/dist/providers/openai.js.map +1 -1
- package/dist/providers/responses.d.ts +123 -0
- package/dist/providers/responses.d.ts.map +1 -1
- package/dist/providers/responses.js +57 -22
- package/dist/providers/responses.js.map +1 -1
- package/dist/providers/speech-factory.js.map +1 -1
- package/dist/providers/transcription-factory.d.ts +30 -0
- package/dist/providers/transcription-factory.d.ts.map +1 -0
- package/dist/providers/transcription-factory.js +38 -0
- package/dist/providers/transcription-factory.js.map +1 -0
- package/dist/registry.d.ts +3 -0
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +8 -4
- package/dist/registry.js.map +1 -1
- package/dist/retry.js.map +1 -1
- package/dist/speech-core.d.ts +2 -17
- package/dist/speech-core.d.ts.map +1 -1
- package/dist/speech-core.js +10 -50
- package/dist/speech-core.js.map +1 -1
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js.map +1 -1
- package/dist/transcription-core.d.ts +146 -0
- package/dist/transcription-core.d.ts.map +1 -0
- package/dist/transcription-core.js +193 -0
- package/dist/transcription-core.js.map +1 -0
- package/dist/transcription.d.ts +7 -0
- package/dist/transcription.d.ts.map +1 -0
- package/dist/transcription.js +12 -0
- package/dist/transcription.js.map +1 -0
- package/dist/transport.d.ts +26 -0
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +57 -2
- package/dist/transport.js.map +1 -1
- package/dist/turn.d.ts +10 -1
- package/dist/turn.d.ts.map +1 -1
- package/dist/turn.js +53 -1
- package/dist/turn.js.map +1 -1
- package/dist/types.d.ts +51 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/usage.d.ts +10 -1
- package/dist/usage.d.ts.map +1 -1
- package/dist/usage.js +40 -2
- package/dist/usage.js.map +1 -1
- package/dist/watchdog.d.ts +6 -0
- package/dist/watchdog.d.ts.map +1 -1
- package/dist/watchdog.js +10 -2
- package/dist/watchdog.js.map +1 -1
- package/package.json +14 -5
- package/src/context.ts +21 -5
- package/src/errors.ts +35 -2
- package/src/fallback.ts +21 -6
- package/src/hosted/anthropic.ts +512 -0
- package/src/hosted/gemini.ts +510 -0
- package/src/hosted/openai.ts +137 -0
- package/src/hosted/responses.ts +420 -0
- package/src/hosted/shared.ts +341 -0
- package/src/hosted/types.ts +214 -0
- package/src/hosted.ts +101 -0
- package/src/index.ts +64 -7
- package/src/presets.ts +54 -8
- package/src/providers/anthropic.ts +252 -143
- package/src/providers/deepgram-transcription.ts +109 -0
- package/src/providers/factory.ts +127 -82
- package/src/providers/gemini.ts +184 -60
- package/src/providers/hosted-codecs.ts +29 -0
- package/src/providers/openai-transcription.ts +177 -0
- package/src/providers/openai.ts +52 -15
- package/src/providers/responses.ts +93 -24
- package/src/providers/transcription-factory.ts +68 -0
- package/src/registry.ts +14 -4
- package/src/speech-core.ts +9 -47
- package/src/transcription-core.ts +345 -0
- package/src/transcription.ts +24 -0
- package/src/transport.ts +77 -3
- package/src/turn.ts +55 -1
- package/src/types.ts +62 -1
- package/src/usage.ts +32 -2
- package/src/watchdog.ts +12 -2
package/dist/watchdog.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watchdog.js","sourceRoot":"","sources":["../src/watchdog.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,8BAA8B;AAC9B,EAAE;AACF,uBAAuB;AACvB,EAAE;AACF,+EAA+E;AAC/E,6EAA6E;AAC7E,+EAA+E;AAC/E,wEAAwE;AACxE,EAAE;AACF,6EAA6E;AAC7E,EAAE;AACF,uEAAuE;AACvE,2EAA2E;AAC3E,wEAAwE;AACxE,gFAAgF;AAChF,8EAA8E;AAC9E,6EAA6E;AAC7E,wEAAwE;AACxE,8EAA8E;AAC9E,+EAA+E;AAC/E,8EAA8E;AAC9E,2EAA2E;AAC3E,gEAAgE;AAChE,EAAE;AACF,6EAA6E;AAC7E,iEAAiE;AACjE,8EAA8E;AAC9E,0EAA0E;AAC1E,4EAA4E;AAC5E,2EAA2E;AAC3E,0EAA0E;AAC1E,8EAA8E;AAC9E,sDAAsD;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAU5C;sBACsB;AACtB,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC;AAErC;2DAC2D;AAC3D,MAAM,CA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M;oBACnB,UAAU,EAAE,IAAI,CAAC,UAAU;oBAC3B,MAAM,EAAE,UAAU,CAAC,MAAM;iBAC1B,CAAC,CAAC;gBACH,MAAM,cAAc,GAAG,UAAU,CAAC,UAAU,CAAC;gBAC7C,MAAM,MAAM,GAAG,QAAQ,CAAC,YAAY,CAAC,QAAQ,EAAE,KAAK,EAAE;oBACpD,GAAG,UAAU;oBACb,MAAM,EAAE,KAAK,CAAC,MAAM;oBACpB,UAAU,EAAE,GAAG,EAAE;wBACf,KAAK,CAAC,WAAW,EAAE,CAAC;wBACpB,cAAc,EAAE,EAAE,CAAC;oBACrB,CAAC;iBACF,CAAC,CAAC;gBACH,IAAI,QAAQ,GAAG,KAAK,CAAC;gBACrB,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,WAAW,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,CAAC;oBACrD,kEAAkE;oBAClE,sDAAsD;oBACtD,IAAI,CAAC,QAAQ,EAAE,CAAC;wBACd,QAAQ,GAAG,IAAI,CAAC;wBAChB,IAAI,CAAC,YAAY,EAAE,CAAC,KAAK,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC,CAAC;oBACjD,CAAC;oBACD,MAAM,KAAK,CAAC;gBACd,CAAC;YACH,CAAC;YAED,OAAO,IAAI,CAAC,cAAc,KAAK,KAAK;gBAClC,CAAC,CAAC,OAAO,EAAE;gBACX,CAAC,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE;oBACrC,eAAe,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,KAAK,MAAM;iBAClD,CAAC,CAAC;QACT,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@providerkit/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.31.0",
|
|
4
4
|
"description": "The layer under your agent loop: one seam for every LLM provider, plus the failure handling you only learn in production.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -10,6 +10,10 @@
|
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
11
11
|
"default": "./dist/index.js"
|
|
12
12
|
},
|
|
13
|
+
"./hosted": {
|
|
14
|
+
"types": "./dist/hosted.d.ts",
|
|
15
|
+
"default": "./dist/hosted.js"
|
|
16
|
+
},
|
|
13
17
|
"./zod": {
|
|
14
18
|
"types": "./dist/zod.d.ts",
|
|
15
19
|
"default": "./dist/zod.js"
|
|
@@ -22,6 +26,10 @@
|
|
|
22
26
|
"types": "./dist/speech.d.ts",
|
|
23
27
|
"default": "./dist/speech.js"
|
|
24
28
|
},
|
|
29
|
+
"./transcription": {
|
|
30
|
+
"types": "./dist/transcription.d.ts",
|
|
31
|
+
"default": "./dist/transcription.js"
|
|
32
|
+
},
|
|
25
33
|
"./auth": {
|
|
26
34
|
"types": "./dist/auth/index.d.ts",
|
|
27
35
|
"default": "./dist/auth/index.js"
|
|
@@ -32,7 +40,8 @@
|
|
|
32
40
|
"dist",
|
|
33
41
|
"src",
|
|
34
42
|
"README.md",
|
|
35
|
-
"LICENSE"
|
|
43
|
+
"LICENSE",
|
|
44
|
+
"THIRD_PARTY_NOTICES"
|
|
36
45
|
],
|
|
37
46
|
"sideEffects": false,
|
|
38
47
|
"engines": {
|
|
@@ -57,8 +66,8 @@
|
|
|
57
66
|
"typecheck": "tsc --noEmit && tsc -p test && tsc -p scripts",
|
|
58
67
|
"test": "vitest run",
|
|
59
68
|
"test:watch": "vitest",
|
|
60
|
-
"lint": "
|
|
61
|
-
"format": "
|
|
69
|
+
"lint": "oxlint -c ../.oxlintrc.json src test",
|
|
70
|
+
"format": "oxfmt",
|
|
62
71
|
"check:presets": "bun run scripts/refresh-presets.ts",
|
|
63
72
|
"probe:model": "bun run scripts/probe-model.ts",
|
|
64
73
|
"probe:speech": "bun run scripts/probe-speech.ts",
|
|
@@ -80,7 +89,7 @@
|
|
|
80
89
|
},
|
|
81
90
|
"devDependencies": {
|
|
82
91
|
"@types/node": "^24.13.3",
|
|
83
|
-
"typescript": "^
|
|
92
|
+
"typescript": "^7.0.2",
|
|
84
93
|
"vitest": "^4.1.2",
|
|
85
94
|
"zod": "^4.3.6"
|
|
86
95
|
},
|
package/src/context.ts
CHANGED
|
@@ -34,15 +34,30 @@ function textOf(message: ChatMessage): string {
|
|
|
34
34
|
return typeof message.content === "string" ? message.content : "";
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
/** What one message costs to re-send: its words, its reasoning,
|
|
38
|
-
* arguments of any calls it made. */
|
|
37
|
+
/** What one message costs to re-send: its words, its reasoning, the
|
|
38
|
+
* arguments of any calls it made, and the hosted items it replays. */
|
|
39
39
|
export function messageTokens(message: ChatMessage): number {
|
|
40
40
|
const extra =
|
|
41
41
|
message.role === "assistant"
|
|
42
42
|
? (message.reasoning ?? "") +
|
|
43
43
|
(message.toolCalls?.map((call) => call.name + call.arguments).join("") ?? "")
|
|
44
44
|
: "";
|
|
45
|
-
return
|
|
45
|
+
return (
|
|
46
|
+
estimateTokens(textOf(message) + extra) + reasoningItemTokens(message) + hostedTokens(message)
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The search results, fetched pages and code output a message replays, which
|
|
52
|
+
* the provider reads again on every send.
|
|
53
|
+
*
|
|
54
|
+
* ponytail: counted as JSON at four characters a token, which overcounts the
|
|
55
|
+
* base64 in an encrypted search result by about a third. Folding a turn early
|
|
56
|
+
* costs a cheap call; the upgrade is the provider's own count.
|
|
57
|
+
*/
|
|
58
|
+
function hostedTokens(message: ChatMessage): number {
|
|
59
|
+
if (message.role !== "assistant" || !message.hostedItems) return 0;
|
|
60
|
+
return estimateTokens(JSON.stringify(message.hostedItems.items));
|
|
46
61
|
}
|
|
47
62
|
|
|
48
63
|
/**
|
|
@@ -221,7 +236,8 @@ function orphanNote(result: ToolResult): ChatMessage {
|
|
|
221
236
|
* random fallback.
|
|
222
237
|
* - An assistant message with no calls and only whitespace is dropped, as if
|
|
223
238
|
* it were never there, so a placeholder saved before the tools ran orphans
|
|
224
|
-
* nothing.
|
|
239
|
+
* nothing. One that carries hosted items is kept: the vendor's search or
|
|
240
|
+
* code run is still the record of that turn, text or not.
|
|
225
241
|
*
|
|
226
242
|
* No side effects, and the same input always gives the same bytes: a span's
|
|
227
243
|
* output and every id depend only on what came before, so repairing a longer
|
|
@@ -259,7 +275,7 @@ export function repairHistory(
|
|
|
259
275
|
for (const [index, message] of messages.entries()) {
|
|
260
276
|
if (message.role === "assistant") {
|
|
261
277
|
const calls = message.toolCalls ?? [];
|
|
262
|
-
if (calls.length === 0 && !message.content.trim()) continue;
|
|
278
|
+
if (calls.length === 0 && !message.content.trim() && !message.hostedItems) continue;
|
|
263
279
|
close();
|
|
264
280
|
if (calls.length === 0) {
|
|
265
281
|
out.push(message);
|
package/src/errors.ts
CHANGED
|
@@ -466,6 +466,33 @@ const MODEL_PATTERNS: readonly RegExp[] = [
|
|
|
466
466
|
// another model in the chain can serve it, so this is `model`, not `invalid`.
|
|
467
467
|
/Privacy settings to use it/i,
|
|
468
468
|
/no endpoints found matching your data policy/i,
|
|
469
|
+
// Deepgram answers 403 `INSUFFICIENT_PERMISSIONS`, "Project does not have access to the
|
|
470
|
+
// requested model." On status alone that is a wrong key, but the key is fine: another model is
|
|
471
|
+
// the fix (its errors page, read 2026-11-11).
|
|
472
|
+
/does not have access to the requested model/i,
|
|
473
|
+
];
|
|
474
|
+
|
|
475
|
+
/** An optional model id after the word "model", quoted or not: "model `gpt-4`", "Model mimo-v2.5". */
|
|
476
|
+
const MODEL_ID = String.raw`(?:\s+[\x60'"\\]*[\w./:@-]+[\x60'"\\]*)?`;
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* A model the vendor has retired. OpenCode Go answers HTTP 410 `ModelDeprecated`, "Model
|
|
480
|
+
* mimo-v2.5 has been deprecated. Use mimo-v2.6-flash instead" (measured 2026-11-11). Read as
|
|
481
|
+
* `invalid` it had no fallback cooldown, so the pool threw instead of moving on, and one retired
|
|
482
|
+
* id in a rotation ended the whole chain the day the models ahead of it were spent. The fix is
|
|
483
|
+
* another model. Each wording names the model, so a deprecated PARAMETER stays `invalid`.
|
|
484
|
+
*/
|
|
485
|
+
const RETIRED_MODEL_PATTERNS: readonly RegExp[] = [
|
|
486
|
+
/\bmodel[_\s-]?(?:deprecated|retired|decommissioned)\b/i,
|
|
487
|
+
new RegExp(
|
|
488
|
+
String.raw`\bmodel\b${MODEL_ID}\s+(?:has\s+been|was|is(?:\s+now)?)\s+(?:deprecated|retired|removed|decommissioned|discontinued|sunset)\b`,
|
|
489
|
+
"i",
|
|
490
|
+
),
|
|
491
|
+
new RegExp(
|
|
492
|
+
String.raw`\bmodel\b${MODEL_ID}\s+is\s+no\s+longer\s+(?:available|supported|served)\b`,
|
|
493
|
+
"i",
|
|
494
|
+
),
|
|
495
|
+
/\b(?:deprecated|retired|decommissioned|discontinued) model\b/i,
|
|
469
496
|
];
|
|
470
497
|
|
|
471
498
|
const AUTH_PATTERNS: readonly RegExp[] = [
|
|
@@ -600,9 +627,15 @@ export function classify(err: unknown, status?: number, body?: string): ErrorKin
|
|
|
600
627
|
if (clientError && matches(ENTITLEMENT_PATTERNS, text)) return "entitlement";
|
|
601
628
|
if (clientError && matches(QUOTA_PATTERNS, text)) return "quota";
|
|
602
629
|
if (matches(MODEL_PATTERNS, text)) return "model";
|
|
603
|
-
if (
|
|
630
|
+
if (matches(AUTH_PATTERNS, text)) return "auth";
|
|
631
|
+
// Below every body family invariant 3 orders, and above the statuses: a body that names the key
|
|
632
|
+
// is about the key, and a 403 that names a retired model is about the model. Not on a 5xx,
|
|
633
|
+
// where "no longer available" is an outage, and an hour's bench would be the wrong fix.
|
|
634
|
+
if (clientError && matches(RETIRED_MODEL_PATTERNS, text)) return "model";
|
|
635
|
+
if (code === 401 || code === 403) return "auth";
|
|
604
636
|
if (code === 402) return "quota";
|
|
605
|
-
|
|
637
|
+
// 410 Gone: the id existed and was withdrawn. Another model is the fix, as for a 404.
|
|
638
|
+
if (code === 404 || code === 410) return "model";
|
|
606
639
|
if (code === 429) return "rate";
|
|
607
640
|
if (matches(CONTENT_PATTERNS, text)) return "content";
|
|
608
641
|
// 529 is Anthropic's own "overloaded". 409 is how several gateways say
|
package/src/fallback.ts
CHANGED
|
@@ -10,7 +10,8 @@ import type { ProviderPresetId } from "./presets.ts";
|
|
|
10
10
|
import { sleep } from "./retry.ts";
|
|
11
11
|
import type { Provider, ProviderChunk, StreamOptions } from "./types.ts";
|
|
12
12
|
import { STREAM_PROGRESS_MS, withWatchdog, type WatchdogOptions } from "./watchdog.ts";
|
|
13
|
-
import {
|
|
13
|
+
import { presetProvider, type PresetProviderConfig } from "./providers/factory.ts";
|
|
14
|
+
import type { HostedCodecs } from "./providers/hosted-codecs.ts";
|
|
14
15
|
|
|
15
16
|
/** Retry intervals when the server supplies no deadline, not estimates of when
|
|
16
17
|
* it will recover. A server deadline always wins over these defaults. */
|
|
@@ -70,15 +71,20 @@ export type FallbackCandidate = Provider | FallbackSpec;
|
|
|
70
71
|
function resolveFallback(
|
|
71
72
|
candidate: FallbackCandidate,
|
|
72
73
|
inheritedWatchdog?: WatchdogOptions,
|
|
74
|
+
codecs?: HostedCodecs,
|
|
73
75
|
): Provider {
|
|
74
76
|
if (typeof candidate === "object" && candidate !== null && "createStream" in candidate) {
|
|
75
77
|
return inheritedWatchdog ? withWatchdog(candidate, inheritedWatchdog) : candidate;
|
|
76
78
|
}
|
|
77
79
|
const { preset, watchdog = inheritedWatchdog, ...config } = candidate;
|
|
78
|
-
return
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
return presetProvider(
|
|
81
|
+
preset,
|
|
82
|
+
{
|
|
83
|
+
...config,
|
|
84
|
+
...(watchdog ? { watchdog } : {}),
|
|
85
|
+
},
|
|
86
|
+
codecs,
|
|
87
|
+
);
|
|
82
88
|
}
|
|
83
89
|
|
|
84
90
|
/** Standard options that any provider config can accept to configure fallbacks inline. */
|
|
@@ -102,13 +108,22 @@ export interface ProviderFallbackConfig {
|
|
|
102
108
|
export function withConfiguredFallbacks(
|
|
103
109
|
primary: Provider,
|
|
104
110
|
config?: ProviderFallbackConfig,
|
|
111
|
+
): Provider {
|
|
112
|
+
return configuredFallbacks(primary, config);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** @internal Keeps opt-in codecs on nested preset fallbacks. */
|
|
116
|
+
export function configuredFallbacks(
|
|
117
|
+
primary: Provider,
|
|
118
|
+
config?: ProviderFallbackConfig,
|
|
119
|
+
codecs?: HostedCodecs,
|
|
105
120
|
): Provider {
|
|
106
121
|
const watchedPrimary = config?.watchdog ? withWatchdog(primary, config.watchdog) : primary;
|
|
107
122
|
if (!config?.fallbacks || config.fallbacks.length === 0) return watchedPrimary;
|
|
108
123
|
return withFallbackProviders(
|
|
109
124
|
[
|
|
110
125
|
watchedPrimary,
|
|
111
|
-
...config.fallbacks.map((candidate) => resolveFallback(candidate, config.watchdog)),
|
|
126
|
+
...config.fallbacks.map((candidate) => resolveFallback(candidate, config.watchdog, codecs)),
|
|
112
127
|
],
|
|
113
128
|
config.fallbackOptions,
|
|
114
129
|
);
|