@rulvar/bridge-ai-sdk 1.0.0 → 1.2.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/dist/index.d.ts +5 -6
- package/dist/index.js +15 -18
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -10,8 +10,8 @@ interface BridgeAiSdkOptions {
|
|
|
10
10
|
*/
|
|
11
11
|
id?: string;
|
|
12
12
|
/**
|
|
13
|
-
* Provider family for provider-raw retention and projection
|
|
14
|
-
*
|
|
13
|
+
* Provider family for provider-raw retention and projection. Defaults
|
|
14
|
+
* to the wrapped model's `provider` string, so
|
|
15
15
|
* two bridged models of one provider share retained blocks.
|
|
16
16
|
*/
|
|
17
17
|
provider?: string;
|
|
@@ -19,8 +19,8 @@ interface BridgeAiSdkOptions {
|
|
|
19
19
|
caps?: (model: string) => ModelCaps | Partial<ModelCaps>;
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
|
-
* Wraps a Vercel AI SDK LanguageModelV4 as a ProviderAdapter
|
|
23
|
-
*
|
|
22
|
+
* Wraps a Vercel AI SDK LanguageModelV4 as a ProviderAdapter. The bridge
|
|
23
|
+
* MUST check specificationVersion at runtime and
|
|
24
24
|
* fail with a typed ConfigError on mismatch. The published interface names
|
|
25
25
|
* the version V4; the wire literal carried by @ai-sdk/provider ^4 is 'v4'.
|
|
26
26
|
*/
|
|
@@ -29,8 +29,7 @@ declare function bridgeAiSdk(model: LanguageModelV4, options?: BridgeAiSdkOption
|
|
|
29
29
|
* Projects a thrown value from the wrapped model into a typed WireError.
|
|
30
30
|
* APICallError carries the provider's status and headers: 429 surfaces as
|
|
31
31
|
* a retryable rate-limit with retryAfterMs; 5xx and status-less network
|
|
32
|
-
* failures are retryable transport; other statuses are terminal transport
|
|
33
|
-
* (docs/04, section 2.2).
|
|
32
|
+
* failures are retryable transport; other statuses are terminal transport.
|
|
34
33
|
*/
|
|
35
34
|
declare function aiSdkErrorToWire(error: unknown): WireError;
|
|
36
35
|
//#endregion
|
package/dist/index.js
CHANGED
|
@@ -6,17 +6,16 @@ import { ConfigError, createCanonicalIdMinter } from "@rulvar/core";
|
|
|
6
6
|
* as a ProviderAdapter for the long tail of providers (Google, Bedrock,
|
|
7
7
|
* Vertex) without coupling the core to the ai-sdk release cycle.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
9
|
+
* Adapter contract: https://docs.rulvar.com/guide/adapter-authors
|
|
10
10
|
* This is documented as the highest-churn package in the set: it tracks the
|
|
11
|
-
* @ai-sdk/provider major line (^4
|
|
12
|
-
*
|
|
13
|
-
* provider-package major cannot mis-wire silently.
|
|
11
|
+
* @ai-sdk/provider major line (^4) and checks specificationVersion at
|
|
12
|
+
* runtime so a transitive provider-package major cannot mis-wire silently.
|
|
14
13
|
*/
|
|
15
14
|
/**
|
|
16
15
|
* Conservative capability set for a model the bridge cannot introspect:
|
|
17
16
|
* the LanguageModelV4 interface exposes no capability discovery, so the
|
|
18
|
-
* defaults mirror the openaiCompatible factory posture
|
|
19
|
-
*
|
|
17
|
+
* defaults mirror the openaiCompatible factory posture except
|
|
18
|
+
* structuredOutput, where responseFormat json IS the V4-native
|
|
20
19
|
* mechanism every ai-sdk provider accepts. Callers SHOULD supply caps for
|
|
21
20
|
* anything beyond this.
|
|
22
21
|
*/
|
|
@@ -30,8 +29,8 @@ const CONSERVATIVE_BRIDGE_CAPS = {
|
|
|
30
29
|
};
|
|
31
30
|
/**
|
|
32
31
|
* Canonical effort to V4 reasoning effort. Canonical 'max' has no V4
|
|
33
|
-
* equivalent and downmaps to 'xhigh' (the documented lossy downmap
|
|
34
|
-
*
|
|
32
|
+
* equivalent and downmaps to 'xhigh' (the documented lossy downmap
|
|
33
|
+
* pattern); the downmap is recorded in providerMetadata.
|
|
35
34
|
* Identity always keeps the requested canonical effort.
|
|
36
35
|
*/
|
|
37
36
|
const EFFORT_TO_V4 = {
|
|
@@ -44,8 +43,7 @@ const EFFORT_TO_V4 = {
|
|
|
44
43
|
/**
|
|
45
44
|
* Keys of the bridge's providerOptions namespace that would contradict a
|
|
46
45
|
* canonical ChatRequest field. Canonical fields always win; a namespaced
|
|
47
|
-
* option silently contradicting one is a typed ConfigError
|
|
48
|
-
* section 1.8).
|
|
46
|
+
* option silently contradicting one is a typed ConfigError.
|
|
49
47
|
*/
|
|
50
48
|
const CANONICAL_CONFLICT_KEYS = [
|
|
51
49
|
"prompt",
|
|
@@ -69,7 +67,7 @@ const LIFTED_OPTION_KEYS = [
|
|
|
69
67
|
];
|
|
70
68
|
/**
|
|
71
69
|
* Bijective map between engine-minted CanonicalIds and the wrapped
|
|
72
|
-
* provider's wire tool-call ids
|
|
70
|
+
* provider's wire tool-call ids. V4 accepts
|
|
73
71
|
* arbitrary strings as toolCallId, so a canonical id minted outside this
|
|
74
72
|
* provider is used verbatim as its own wire id.
|
|
75
73
|
*/
|
|
@@ -97,8 +95,8 @@ var BridgeIdMap = class {
|
|
|
97
95
|
}
|
|
98
96
|
};
|
|
99
97
|
/**
|
|
100
|
-
* Wraps a Vercel AI SDK LanguageModelV4 as a ProviderAdapter
|
|
101
|
-
*
|
|
98
|
+
* Wraps a Vercel AI SDK LanguageModelV4 as a ProviderAdapter. The bridge
|
|
99
|
+
* MUST check specificationVersion at runtime and
|
|
102
100
|
* fail with a typed ConfigError on mismatch. The published interface names
|
|
103
101
|
* the version V4; the wire literal carried by @ai-sdk/provider ^4 is 'v4'.
|
|
104
102
|
*/
|
|
@@ -292,7 +290,7 @@ function mapMessages(messages, context) {
|
|
|
292
290
|
/**
|
|
293
291
|
* Transforms a retained stream part (shipped through finish
|
|
294
292
|
* providerMetadata retainedParts and lifted into a provider-raw part by
|
|
295
|
-
* the runtime
|
|
293
|
+
* the runtime) back into its V4 prompt-part shape.
|
|
296
294
|
* Response-side providerMetadata becomes prompt-side providerOptions.
|
|
297
295
|
*/
|
|
298
296
|
function reinsertRetained(block) {
|
|
@@ -580,8 +578,8 @@ function mapFinishReason(reason, adapterId) {
|
|
|
580
578
|
}
|
|
581
579
|
/**
|
|
582
580
|
* Normalizes V4 nested usage to the flat Usage under the Usage invariant:
|
|
583
|
-
* inputTokens is the FULL prompt including cache reads and writes
|
|
584
|
-
*
|
|
581
|
+
* inputTokens is the FULL prompt including cache reads and writes.
|
|
582
|
+
* When the provider's total disagrees with the
|
|
585
583
|
* component sum, the larger value wins so the invariant holds by
|
|
586
584
|
* construction.
|
|
587
585
|
*/
|
|
@@ -617,8 +615,7 @@ function parseToolArgs(input) {
|
|
|
617
615
|
* Projects a thrown value from the wrapped model into a typed WireError.
|
|
618
616
|
* APICallError carries the provider's status and headers: 429 surfaces as
|
|
619
617
|
* a retryable rate-limit with retryAfterMs; 5xx and status-less network
|
|
620
|
-
* failures are retryable transport; other statuses are terminal transport
|
|
621
|
-
* (docs/04, section 2.2).
|
|
618
|
+
* failures are retryable transport; other statuses are terminal transport.
|
|
622
619
|
*/
|
|
623
620
|
function aiSdkErrorToWire(error) {
|
|
624
621
|
const record = error;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rulvar/bridge-ai-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "rulvar bridge adapter wrapping any Vercel AI SDK LanguageModelV4 as a ProviderAdapter.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@ai-sdk/provider": "^4.0.0",
|
|
26
|
-
"@rulvar/core": "1.
|
|
26
|
+
"@rulvar/core": "1.2.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@ai-sdk/google": "^4.0.0",
|