@ai-sdk/amazon-bedrock 3.0.115 → 3.0.117

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.mjs CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  } from "@ai-sdk/provider-utils";
9
9
 
10
10
  // src/version.ts
11
- var VERSION = true ? "3.0.115" : "0.0.0-test";
11
+ var VERSION = true ? "3.0.117" : "0.0.0-test";
12
12
 
13
13
  // src/bedrock-provider.ts
14
14
  import { anthropicTools as anthropicTools2 } from "@ai-sdk/anthropic/internal";
@@ -145,17 +145,20 @@ function createBedrockEventStreamDecoder(body, processEvent) {
145
145
  if (buffer.length < totalLength) {
146
146
  break;
147
147
  }
148
- try {
149
- const subView = buffer.subarray(0, totalLength);
150
- const decoded = codec.decode(subView);
151
- buffer = buffer.slice(totalLength);
152
- const messageType = (_a = decoded.headers[":message-type"]) == null ? void 0 : _a.value;
153
- const eventType = (_b = decoded.headers[":event-type"]) == null ? void 0 : _b.value;
154
- const data = textDecoder.decode(decoded.body);
155
- await processEvent({ messageType, eventType, data }, controller);
156
- } catch (e) {
157
- break;
158
- }
148
+ const subView = buffer.subarray(0, totalLength);
149
+ const decoded = codec.decode(subView);
150
+ buffer = buffer.slice(totalLength);
151
+ const messageType = (_a = decoded.headers[":message-type"]) == null ? void 0 : _a.value;
152
+ const eventType = (_b = decoded.headers[":event-type"]) == null ? void 0 : _b.value;
153
+ const data = textDecoder.decode(decoded.body);
154
+ await processEvent({ messageType, eventType, data }, controller);
155
+ }
156
+ },
157
+ flush() {
158
+ if (buffer.length > 0) {
159
+ throw new Error(
160
+ `Incomplete Amazon Bedrock event-stream frame: ${buffer.length} buffered bytes remain at end of stream.`
161
+ );
159
162
  }
160
163
  }
161
164
  })
@@ -602,7 +605,7 @@ async function convertToBedrockChatMessages(prompt) {
602
605
  toolUse: {
603
606
  toolUseId: part.toolCallId,
604
607
  name: sanitizeToolName(part.toolName),
605
- input: part.input
608
+ input: toBedrockToolInput(part.input)
606
609
  }
607
610
  });
608
611
  break;
@@ -624,6 +627,9 @@ async function convertToBedrockChatMessages(prompt) {
624
627
  }
625
628
  return { system, messages };
626
629
  }
630
+ function toBedrockToolInput(input) {
631
+ return typeof input === "object" && input !== null && !Array.isArray(input) ? input : { rawInvalidInput: input };
632
+ }
627
633
  function getBedrockImageFormat(mimeType) {
628
634
  if (!mimeType) {
629
635
  throw new UnsupportedFunctionalityError2({