@ai-sdk/amazon-bedrock 4.0.27 → 4.0.29

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.
Files changed (39) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/anthropic/index.js +1 -1
  3. package/dist/anthropic/index.mjs +1 -1
  4. package/dist/index.js +1 -1
  5. package/dist/index.mjs +1 -1
  6. package/package.json +9 -5
  7. package/src/__fixtures__/bedrock-json-only-text-first.1.chunks.txt +0 -7
  8. package/src/__fixtures__/bedrock-json-other-tool.1.chunks.txt +0 -6
  9. package/src/__fixtures__/bedrock-json-other-tool.1.json +0 -24
  10. package/src/__fixtures__/bedrock-json-tool-text-then-weather-then-json.1.chunks.txt +0 -12
  11. package/src/__fixtures__/bedrock-json-tool-with-answer.1.json +0 -29
  12. package/src/__fixtures__/bedrock-json-tool.1.chunks.txt +0 -4
  13. package/src/__fixtures__/bedrock-json-tool.1.json +0 -35
  14. package/src/__fixtures__/bedrock-json-tool.2.chunks.txt +0 -6
  15. package/src/__fixtures__/bedrock-json-tool.2.json +0 -28
  16. package/src/__fixtures__/bedrock-json-tool.3.chunks.txt +0 -7
  17. package/src/__fixtures__/bedrock-json-tool.3.json +0 -36
  18. package/src/__fixtures__/bedrock-json-with-tool.1.chunks.txt +0 -9
  19. package/src/__fixtures__/bedrock-json-with-tool.1.json +0 -41
  20. package/src/__fixtures__/bedrock-json-with-tools.1.chunks.txt +0 -12
  21. package/src/__fixtures__/bedrock-json-with-tools.1.json +0 -50
  22. package/src/__fixtures__/bedrock-tool-call.1.chunks.txt +0 -6
  23. package/src/__fixtures__/bedrock-tool-call.1.json +0 -24
  24. package/src/__fixtures__/bedrock-tool-no-args.chunks.txt +0 -8
  25. package/src/__fixtures__/bedrock-tool-no-args.json +0 -25
  26. package/src/anthropic/bedrock-anthropic-fetch.test.ts +0 -344
  27. package/src/anthropic/bedrock-anthropic-provider.test.ts +0 -456
  28. package/src/bedrock-chat-language-model.test.ts +0 -4569
  29. package/src/bedrock-embedding-model.test.ts +0 -148
  30. package/src/bedrock-event-stream-response-handler.test.ts +0 -233
  31. package/src/bedrock-image-model.test.ts +0 -866
  32. package/src/bedrock-provider.test.ts +0 -457
  33. package/src/bedrock-sigv4-fetch.test.ts +0 -675
  34. package/src/convert-bedrock-usage.test.ts +0 -207
  35. package/src/convert-to-bedrock-chat-messages.test.ts +0 -1175
  36. package/src/inject-fetch-headers.test.ts +0 -135
  37. package/src/normalize-tool-call-id.test.ts +0 -72
  38. package/src/reranking/__fixtures__/bedrock-reranking.1.json +0 -12
  39. package/src/reranking/bedrock-reranking-model.test.ts +0 -299
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @ai-sdk/amazon-bedrock
2
2
 
3
+ ## 4.0.29
4
+
5
+ ### Patch Changes
6
+
7
+ - 4de5a1d: chore: excluded tests from src folder in npm package
8
+ - Updated dependencies [4de5a1d]
9
+ - @ai-sdk/anthropic@3.0.23
10
+ - @ai-sdk/provider@3.0.5
11
+ - @ai-sdk/provider-utils@4.0.9
12
+
13
+ ## 4.0.28
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies [8ccf04b]
18
+ - @ai-sdk/anthropic@3.0.22
19
+
3
20
  ## 4.0.27
4
21
 
5
22
  ### Patch Changes
@@ -35,7 +35,7 @@ var import_provider_utils = require("@ai-sdk/provider-utils");
35
35
  var import_aws4fetch = require("aws4fetch");
36
36
 
37
37
  // src/version.ts
38
- var VERSION = true ? "4.0.27" : "0.0.0-test";
38
+ var VERSION = true ? "4.0.29" : "0.0.0-test";
39
39
 
40
40
  // src/bedrock-sigv4-fetch.ts
41
41
  function createSigV4FetchFunction(getCredentials, fetch = globalThis.fetch) {
@@ -24,7 +24,7 @@ import {
24
24
  import { AwsV4Signer } from "aws4fetch";
25
25
 
26
26
  // src/version.ts
27
- var VERSION = true ? "4.0.27" : "0.0.0-test";
27
+ var VERSION = true ? "4.0.29" : "0.0.0-test";
28
28
 
29
29
  // src/bedrock-sigv4-fetch.ts
30
30
  function createSigV4FetchFunction(getCredentials, fetch = globalThis.fetch) {
package/dist/index.js CHANGED
@@ -1781,7 +1781,7 @@ var import_provider_utils7 = require("@ai-sdk/provider-utils");
1781
1781
  var import_aws4fetch = require("aws4fetch");
1782
1782
 
1783
1783
  // src/version.ts
1784
- var VERSION = true ? "4.0.27" : "0.0.0-test";
1784
+ var VERSION = true ? "4.0.29" : "0.0.0-test";
1785
1785
 
1786
1786
  // src/bedrock-sigv4-fetch.ts
1787
1787
  function createSigV4FetchFunction(getCredentials, fetch = globalThis.fetch) {
package/dist/index.mjs CHANGED
@@ -1798,7 +1798,7 @@ import {
1798
1798
  import { AwsV4Signer } from "aws4fetch";
1799
1799
 
1800
1800
  // src/version.ts
1801
- var VERSION = true ? "4.0.27" : "0.0.0-test";
1801
+ var VERSION = true ? "4.0.29" : "0.0.0-test";
1802
1802
 
1803
1803
  // src/bedrock-sigv4-fetch.ts
1804
1804
  function createSigV4FetchFunction(getCredentials, fetch = globalThis.fetch) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/amazon-bedrock",
3
- "version": "4.0.27",
3
+ "version": "4.0.29",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -10,6 +10,10 @@
10
10
  "dist/**/*",
11
11
  "docs/**/*",
12
12
  "src",
13
+ "!src/**/*.test.ts",
14
+ "!src/**/*.test-d.ts",
15
+ "!src/**/__snapshots__",
16
+ "!src/**/__fixtures__",
13
17
  "CHANGELOG.md",
14
18
  "README.md",
15
19
  "anthropic/index.d.ts"
@@ -34,16 +38,16 @@
34
38
  "@smithy/eventstream-codec": "^4.0.1",
35
39
  "@smithy/util-utf8": "^4.0.0",
36
40
  "aws4fetch": "^1.0.20",
37
- "@ai-sdk/anthropic": "3.0.21",
38
- "@ai-sdk/provider": "3.0.4",
39
- "@ai-sdk/provider-utils": "4.0.8"
41
+ "@ai-sdk/anthropic": "3.0.23",
42
+ "@ai-sdk/provider": "3.0.5",
43
+ "@ai-sdk/provider-utils": "4.0.9"
40
44
  },
41
45
  "devDependencies": {
42
46
  "@types/node": "20.17.24",
43
47
  "tsup": "^8.3.0",
44
48
  "typescript": "5.8.3",
45
49
  "zod": "3.25.76",
46
- "@ai-sdk/test-server": "1.0.2",
50
+ "@ai-sdk/test-server": "1.0.3",
47
51
  "@vercel/ai-tsconfig": "0.0.0"
48
52
  },
49
53
  "peerDependencies": {
@@ -1,7 +0,0 @@
1
- {"contentBlockDelta":{"contentBlockIndex":0,"delta":{"text":"Here is your data:"}}}
2
- {"contentBlockStop":{"contentBlockIndex":0}}
3
- {"contentBlockStart":{"contentBlockIndex":1,"start":{"toolUse":{"toolUseId":"json-tool-1","name":"json"}}}}
4
- {"contentBlockDelta":{"contentBlockIndex":1,"delta":{"toolUse":{"input":"{\"name\":\"John\"}"}}}}
5
- {"contentBlockStop":{"contentBlockIndex":1}}
6
- {"metadata":{"usage":{"inputTokens":100,"outputTokens":20,"totalTokens":120}}}
7
- {"messageStop":{"stopReason":"tool_use"}}
@@ -1,6 +0,0 @@
1
- {"contentBlockStart":{"contentBlockIndex":0,"start":{"toolUse":{"toolUseId":"toolu_01PQjhxo3eirCdKNvCJrKc8f","name":"get-weather"}}}}
2
- {"contentBlockDelta":{"contentBlockIndex":0,"delta":{"toolUse":{"input":"{\"location\":"}}}}
3
- {"contentBlockDelta":{"contentBlockIndex":0,"delta":{"toolUse":{"input":"\"San Francisco\"}"}}}}
4
- {"contentBlockStop":{"contentBlockIndex":0}}
5
- {"metadata":{"usage":{"inputTokens":843,"outputTokens":28,"totalTokens":871}}}
6
- {"messageStop":{"stopReason":"tool_use"}}
@@ -1,24 +0,0 @@
1
- {
2
- "output": {
3
- "message": {
4
- "role": "assistant",
5
- "content": [
6
- {
7
- "toolUse": {
8
- "toolUseId": "toolu_01PQjhxo3eirCdKNvCJrKc8f",
9
- "name": "get-weather",
10
- "input": {
11
- "location": "San Francisco"
12
- }
13
- }
14
- }
15
- ]
16
- }
17
- },
18
- "usage": {
19
- "inputTokens": 843,
20
- "outputTokens": 28,
21
- "totalTokens": 871
22
- },
23
- "stopReason": "tool_use"
24
- }
@@ -1,12 +0,0 @@
1
- {"contentBlockDelta":{"contentBlockIndex":0,"delta":{"text":"2 + 2 equals 4. Now let me check"}}}
2
- {"contentBlockDelta":{"contentBlockIndex":0,"delta":{"text":" the weather for you."}}}
3
- {"contentBlockStop":{"contentBlockIndex":0}}
4
- {"contentBlockStart":{"contentBlockIndex":1,"start":{"toolUse":{"toolUseId":"weather-tool-1","name":"weather"}}}}
5
- {"contentBlockDelta":{"contentBlockIndex":1,"delta":{"toolUse":{"input":"{\"location\":"}}}}
6
- {"contentBlockDelta":{"contentBlockIndex":1,"delta":{"toolUse":{"input":"\"San Francisco\"}"}}}}
7
- {"contentBlockStop":{"contentBlockIndex":1}}
8
- {"contentBlockStart":{"contentBlockIndex":2,"start":{"toolUse":{"toolUseId":"weather-tool-2","name":"weather"}}}}
9
- {"contentBlockDelta":{"contentBlockIndex":2,"delta":{"toolUse":{"input":"{\"location\":\"London\"}"}}}}
10
- {"contentBlockStop":{"contentBlockIndex":2}}
11
- {"metadata":{"usage":{"inputTokens":500,"outputTokens":100,"totalTokens":600}}}
12
- {"messageStop":{"stopReason":"tool_use"}}
@@ -1,29 +0,0 @@
1
- {
2
- "output": {
3
- "message": {
4
- "role": "assistant",
5
- "content": [
6
- {
7
- "type": "text",
8
- "text": "2 + 2 equals 4."
9
- },
10
- {
11
- "toolUse": {
12
- "toolUseId": "json-tool-id-123",
13
- "name": "json",
14
- "input": {
15
- "firstName": "John",
16
- "lastName": "Doe"
17
- }
18
- }
19
- }
20
- ]
21
- }
22
- },
23
- "usage": {
24
- "inputTokens": 156,
25
- "outputTokens": 35,
26
- "totalTokens": 191
27
- },
28
- "stopReason": "tool_use"
29
- }
@@ -1,4 +0,0 @@
1
- {"contentBlockStart":{"contentBlockIndex":0,"start":{"toolUse":{"toolUseId":"json-tool-id","name":"json"}}}}
2
- {"contentBlockDelta":{"contentBlockIndex":0,"delta":{"toolUse":{"input":"{\"value\":\"test\"}"}}}}
3
- {"contentBlockStop":{"contentBlockIndex":0}}
4
- {"messageStop":{"stopReason":"tool_use"}}
@@ -1,35 +0,0 @@
1
- {
2
- "output": {
3
- "message": {
4
- "role": "assistant",
5
- "content": [
6
- {
7
- "toolUse": {
8
- "toolUseId": "json-tool-id",
9
- "name": "json",
10
- "input": {
11
- "elements": [
12
- {
13
- "location": "San Francisco",
14
- "temperature": -5,
15
- "condition": "snowy"
16
- },
17
- {
18
- "location": "London",
19
- "temperature": 0,
20
- "condition": "snowy"
21
- }
22
- ]
23
- }
24
- }
25
- }
26
- ]
27
- }
28
- },
29
- "usage": {
30
- "inputTokens": 15,
31
- "outputTokens": 42,
32
- "totalTokens": 57
33
- },
34
- "stopReason": "tool_use"
35
- }
@@ -1,6 +0,0 @@
1
- {"contentBlockDelta":{"contentBlockIndex":0,"delta":{"text":"Let me generate"}}}
2
- {"contentBlockDelta":{"contentBlockIndex":0,"delta":{"text":" that JSON for you."}}}
3
- {"contentBlockStart":{"contentBlockIndex":1,"start":{"toolUse":{"toolUseId":"json-tool-id","name":"json"}}}}
4
- {"contentBlockDelta":{"contentBlockIndex":1,"delta":{"toolUse":{"input":"{\"value\":\"test\"}"}}}}
5
- {"contentBlockStop":{"contentBlockIndex":1}}
6
- {"messageStop":{"stopReason":"tool_use"}}
@@ -1,28 +0,0 @@
1
- {
2
- "output": {
3
- "message": {
4
- "role": "assistant",
5
- "content": [
6
- {
7
- "type": "text",
8
- "text": "Let me generate that JSON for you."
9
- },
10
- {
11
- "toolUse": {
12
- "toolUseId": "json-tool-id",
13
- "name": "json",
14
- "input": {
15
- "value": "test data"
16
- }
17
- }
18
- }
19
- ]
20
- }
21
- },
22
- "usage": {
23
- "inputTokens": 12,
24
- "outputTokens": 28,
25
- "totalTokens": 40
26
- },
27
- "stopReason": "tool_use"
28
- }
@@ -1,7 +0,0 @@
1
- {"contentBlockDelta":{"contentBlockIndex":0,"delta":{"text":"First text block."}}}
2
- {"contentBlockDelta":{"contentBlockIndex":1,"delta":{"text":"Second text block."}}}
3
- {"contentBlockDelta":{"contentBlockIndex":2,"delta":{"text":"Third block."}}}
4
- {"contentBlockStart":{"contentBlockIndex":3,"start":{"toolUse":{"toolUseId":"json-tool-id","name":"json"}}}}
5
- {"contentBlockDelta":{"contentBlockIndex":3,"delta":{"toolUse":{"input":"{\"result\":42}"}}}}
6
- {"contentBlockStop":{"contentBlockIndex":3}}
7
- {"messageStop":{"stopReason":"tool_use"}}
@@ -1,36 +0,0 @@
1
- {
2
- "output": {
3
- "message": {
4
- "role": "assistant",
5
- "content": [
6
- {
7
- "type": "text",
8
- "text": "First text block."
9
- },
10
- {
11
- "type": "text",
12
- "text": "Second text block."
13
- },
14
- {
15
- "type": "text",
16
- "text": "Third text block before JSON."
17
- },
18
- {
19
- "toolUse": {
20
- "toolUseId": "json-tool-id",
21
- "name": "json",
22
- "input": {
23
- "result": 42
24
- }
25
- }
26
- }
27
- ]
28
- }
29
- },
30
- "usage": {
31
- "inputTokens": 18,
32
- "outputTokens": 35,
33
- "totalTokens": 53
34
- },
35
- "stopReason": "tool_use"
36
- }
@@ -1,9 +0,0 @@
1
- {"contentBlockDelta":{"contentBlockIndex":0,"delta":{"text":"Calling a tool first."}}}
2
- {"contentBlockStart":{"contentBlockIndex":1,"start":{"toolUse":{"toolUseId":"tool-1","name":"get-weather"}}}}
3
- {"contentBlockDelta":{"contentBlockIndex":1,"delta":{"toolUse":{"input":"{\"location\":\"SF\"}"}}}}
4
- {"contentBlockStop":{"contentBlockIndex":1}}
5
- {"contentBlockDelta":{"contentBlockIndex":2,"delta":{"text":"Now JSON."}}}
6
- {"contentBlockStart":{"contentBlockIndex":3,"start":{"toolUse":{"toolUseId":"json-tool-id","name":"json"}}}}
7
- {"contentBlockDelta":{"contentBlockIndex":3,"delta":{"toolUse":{"input":"{\"result\":\"data\"}"}}}}
8
- {"contentBlockStop":{"contentBlockIndex":3}}
9
- {"messageStop":{"stopReason":"tool_use"}}
@@ -1,41 +0,0 @@
1
- {
2
- "output": {
3
- "message": {
4
- "role": "assistant",
5
- "content": [
6
- {
7
- "type": "text",
8
- "text": "Let me call a tool first."
9
- },
10
- {
11
- "toolUse": {
12
- "toolUseId": "tool-1",
13
- "name": "get-weather",
14
- "input": {
15
- "location": "SF"
16
- }
17
- }
18
- },
19
- {
20
- "type": "text",
21
- "text": "Now the JSON."
22
- },
23
- {
24
- "toolUse": {
25
- "toolUseId": "json-tool-id",
26
- "name": "json",
27
- "input": {
28
- "result": "data"
29
- }
30
- }
31
- }
32
- ]
33
- }
34
- },
35
- "usage": {
36
- "inputTokens": 22,
37
- "outputTokens": 48,
38
- "totalTokens": 70
39
- },
40
- "stopReason": "tool_use"
41
- }
@@ -1,12 +0,0 @@
1
- {"contentBlockDelta":{"contentBlockIndex":0,"delta":{"text":"Multiple tools."}}}
2
- {"contentBlockStart":{"contentBlockIndex":1,"start":{"toolUse":{"toolUseId":"tool-1","name":"tool-a"}}}}
3
- {"contentBlockDelta":{"contentBlockIndex":1,"delta":{"toolUse":{"input":"{\"a\":\"1\"}"}}}}
4
- {"contentBlockStop":{"contentBlockIndex":1}}
5
- {"contentBlockStart":{"contentBlockIndex":2,"start":{"toolUse":{"toolUseId":"tool-2","name":"tool-b"}}}}
6
- {"contentBlockDelta":{"contentBlockIndex":2,"delta":{"toolUse":{"input":"{\"b\":\"2\"}"}}}}
7
- {"contentBlockStop":{"contentBlockIndex":2}}
8
- {"contentBlockDelta":{"contentBlockIndex":3,"delta":{"text":"Final JSON."}}}
9
- {"contentBlockStart":{"contentBlockIndex":4,"start":{"toolUse":{"toolUseId":"json-tool-id","name":"json"}}}}
10
- {"contentBlockDelta":{"contentBlockIndex":4,"delta":{"toolUse":{"input":"{\"final\":\"result\"}"}}}}
11
- {"contentBlockStop":{"contentBlockIndex":4}}
12
- {"messageStop":{"stopReason":"tool_use"}}
@@ -1,50 +0,0 @@
1
- {
2
- "output": {
3
- "message": {
4
- "role": "assistant",
5
- "content": [
6
- {
7
- "type": "text",
8
- "text": "Calling multiple tools."
9
- },
10
- {
11
- "toolUse": {
12
- "toolUseId": "tool-1",
13
- "name": "tool-a",
14
- "input": {
15
- "param": "a"
16
- }
17
- }
18
- },
19
- {
20
- "toolUse": {
21
- "toolUseId": "tool-2",
22
- "name": "tool-b",
23
- "input": {
24
- "param": "b"
25
- }
26
- }
27
- },
28
- {
29
- "type": "text",
30
- "text": "Finally the JSON response."
31
- },
32
- {
33
- "toolUse": {
34
- "toolUseId": "json-tool-id",
35
- "name": "json",
36
- "input": {
37
- "final": "result"
38
- }
39
- }
40
- }
41
- ]
42
- }
43
- },
44
- "usage": {
45
- "inputTokens": 28,
46
- "outputTokens": 62,
47
- "totalTokens": 90
48
- },
49
- "stopReason": "tool_use"
50
- }
@@ -1,6 +0,0 @@
1
- {"contentBlockStart":{"contentBlockIndex":0,"start":{"toolUse":{"toolUseId":"tool-use-id","name":"test-tool"}}}}
2
- {"contentBlockDelta":{"contentBlockIndex":0,"delta":{"toolUse":{"input":"{\"value\":"}}}}
3
- {"contentBlockDelta":{"contentBlockIndex":0,"delta":{"toolUse":{"input":"\"Sparkle Day\"}"}}}}
4
- {"contentBlockStop":{"contentBlockIndex":0}}
5
- {"metadata":{"usage":{"inputTokens":125,"outputTokens":45,"totalTokens":170},"metrics":{"latencyMs":234}}}
6
- {"messageStop":{"stopReason":"tool_use"}}
@@ -1,24 +0,0 @@
1
- {
2
- "output": {
3
- "message": {
4
- "role": "assistant",
5
- "content": [
6
- {
7
- "toolUse": {
8
- "toolUseId": "tool-use-id",
9
- "name": "bash",
10
- "input": {
11
- "command": "ls -l"
12
- }
13
- }
14
- }
15
- ]
16
- }
17
- },
18
- "usage": {
19
- "inputTokens": 10,
20
- "outputTokens": 20,
21
- "totalTokens": 30
22
- },
23
- "stopReason": "tool_use"
24
- }
@@ -1,8 +0,0 @@
1
- {"contentBlockStart":{"contentBlockIndex":0,"start":{}}}
2
- {"contentBlockDelta":{"contentBlockIndex":0,"delta":{"text":"I'll update the issue list for you."}}}
3
- {"contentBlockStop":{"contentBlockIndex":0}}
4
- {"contentBlockStart":{"contentBlockIndex":1,"start":{"toolUse":{"toolUseId":"tool-use-id","name":"updateIssueList"}}}}
5
- {"contentBlockDelta":{"contentBlockIndex":1,"delta":{"toolUse":{"input":""}}}}
6
- {"contentBlockStop":{"contentBlockIndex":1}}
7
- {"metadata":{"usage":{"inputTokens":100,"outputTokens":25,"totalTokens":125},"metrics":{"latencyMs":150}}}
8
- {"messageStop":{"stopReason":"tool_use"}}
@@ -1,25 +0,0 @@
1
- {
2
- "output": {
3
- "message": {
4
- "role": "assistant",
5
- "content": [
6
- {
7
- "text": "I'll update the issue list for you."
8
- },
9
- {
10
- "toolUse": {
11
- "toolUseId": "tool-use-id",
12
- "name": "updateIssueList",
13
- "input": {}
14
- }
15
- }
16
- ]
17
- }
18
- },
19
- "usage": {
20
- "inputTokens": 100,
21
- "outputTokens": 25,
22
- "totalTokens": 125
23
- },
24
- "stopReason": "tool_use"
25
- }