@ai-sdk/amazon-bedrock 3.0.0-alpha.8 → 3.0.0-beta.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,91 @@
1
1
  # @ai-sdk/amazon-bedrock
2
2
 
3
+ ## 3.0.0-beta.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [742b7be]
8
+ - Updated dependencies [7cddb72]
9
+ - Updated dependencies [ccce59b]
10
+ - Updated dependencies [e2b9e4b]
11
+ - Updated dependencies [45c1ea2]
12
+ - Updated dependencies [e025824]
13
+ - Updated dependencies [0d06df6]
14
+ - Updated dependencies [472524a]
15
+ - Updated dependencies [dd3ff01]
16
+ - Updated dependencies [7435eb5]
17
+ - Updated dependencies [cb68df0]
18
+ - Updated dependencies [bfdca8d]
19
+ - Updated dependencies [44f4aba]
20
+ - Updated dependencies [023ba40]
21
+ - Updated dependencies [5e57fae]
22
+ - Updated dependencies [71f938d]
23
+ - Updated dependencies [28a5ed5]
24
+ - @ai-sdk/provider@2.0.0-beta.1
25
+ - @ai-sdk/provider-utils@3.0.0-beta.1
26
+
27
+ ## 3.0.0-alpha.15
28
+
29
+ ### Patch Changes
30
+
31
+ - Updated dependencies [48d257a]
32
+ - Updated dependencies [8ba77a7]
33
+ - @ai-sdk/provider@2.0.0-alpha.15
34
+ - @ai-sdk/provider-utils@3.0.0-alpha.15
35
+
36
+ ## 3.0.0-alpha.14
37
+
38
+ ### Patch Changes
39
+
40
+ - Updated dependencies [b5da06a]
41
+ - Updated dependencies [63f9e9b]
42
+ - Updated dependencies [2e13791]
43
+ - @ai-sdk/provider@2.0.0-alpha.14
44
+ - @ai-sdk/provider-utils@3.0.0-alpha.14
45
+
46
+ ## 3.0.0-alpha.13
47
+
48
+ ### Patch Changes
49
+
50
+ - Updated dependencies [68ecf2f]
51
+ - @ai-sdk/provider@2.0.0-alpha.13
52
+ - @ai-sdk/provider-utils@3.0.0-alpha.13
53
+
54
+ ## 3.0.0-alpha.12
55
+
56
+ ### Patch Changes
57
+
58
+ - e2aceaf: feat: add raw chunk support
59
+ - Updated dependencies [e2aceaf]
60
+ - @ai-sdk/provider@2.0.0-alpha.12
61
+ - @ai-sdk/provider-utils@3.0.0-alpha.12
62
+
63
+ ## 3.0.0-alpha.11
64
+
65
+ ### Patch Changes
66
+
67
+ - d546725: fix(provider/amazon-bedrock): use consistent document names for prompt cache effectiveness
68
+ - Updated dependencies [c1e6647]
69
+ - @ai-sdk/provider@2.0.0-alpha.11
70
+ - @ai-sdk/provider-utils@3.0.0-alpha.11
71
+
72
+ ## 3.0.0-alpha.10
73
+
74
+ ### Patch Changes
75
+
76
+ - Updated dependencies [c4df419]
77
+ - @ai-sdk/provider@2.0.0-alpha.10
78
+ - @ai-sdk/provider-utils@3.0.0-alpha.10
79
+
80
+ ## 3.0.0-alpha.9
81
+
82
+ ### Patch Changes
83
+
84
+ - c87b7e4: feat (provider/amazon-bedrock): add Claude 4 model ids (claude-sonnet-4-20250514-v1:0, claude-opus-4-20250514-v1:0)
85
+ - Updated dependencies [811dff3]
86
+ - @ai-sdk/provider@2.0.0-alpha.9
87
+ - @ai-sdk/provider-utils@3.0.0-alpha.9
88
+
3
89
  ## 3.0.0-alpha.8
4
90
 
5
91
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -2,7 +2,7 @@ import { ProviderV2, LanguageModelV2, EmbeddingModelV2, ImageModelV2 } from '@ai
2
2
  import { FetchFunction } from '@ai-sdk/provider-utils';
3
3
  import { z } from 'zod';
4
4
 
5
- type BedrockChatModelId = 'amazon.titan-tg1-large' | 'amazon.titan-text-express-v1' | 'anthropic.claude-v2' | 'anthropic.claude-v2:1' | 'anthropic.claude-instant-v1' | 'anthropic.claude-3-7-sonnet-20250219-v1:0' | 'anthropic.claude-3-5-sonnet-20240620-v1:0' | 'anthropic.claude-3-5-sonnet-20241022-v2:0' | 'anthropic.claude-3-5-haiku-20241022-v1:0' | 'anthropic.claude-3-sonnet-20240229-v1:0' | 'anthropic.claude-3-haiku-20240307-v1:0' | 'anthropic.claude-3-opus-20240229-v1:0' | 'cohere.command-text-v14' | 'cohere.command-light-text-v14' | 'cohere.command-r-v1:0' | 'cohere.command-r-plus-v1:0' | 'meta.llama3-70b-instruct-v1:0' | 'meta.llama3-8b-instruct-v1:0' | 'meta.llama3-1-405b-instruct-v1:0' | 'meta.llama3-1-70b-instruct-v1:0' | 'meta.llama3-1-8b-instruct-v1:0' | 'meta.llama3-2-11b-instruct-v1:0' | 'meta.llama3-2-1b-instruct-v1:0' | 'meta.llama3-2-3b-instruct-v1:0' | 'meta.llama3-2-90b-instruct-v1:0' | 'mistral.mistral-7b-instruct-v0:2' | 'mistral.mixtral-8x7b-instruct-v0:1' | 'mistral.mistral-large-2402-v1:0' | 'mistral.mistral-small-2402-v1:0' | 'amazon.titan-text-express-v1' | 'amazon.titan-text-lite-v1' | (string & {});
5
+ type BedrockChatModelId = 'amazon.titan-tg1-large' | 'amazon.titan-text-express-v1' | 'anthropic.claude-v2' | 'anthropic.claude-v2:1' | 'anthropic.claude-instant-v1' | 'anthropic.claude-sonnet-4-20250514-v1:0' | 'anthropic.claude-opus-4-20250514-v1:0' | 'anthropic.claude-3-7-sonnet-20250219-v1:0' | 'anthropic.claude-3-5-sonnet-20240620-v1:0' | 'anthropic.claude-3-5-sonnet-20241022-v2:0' | 'anthropic.claude-3-5-haiku-20241022-v1:0' | 'anthropic.claude-3-sonnet-20240229-v1:0' | 'anthropic.claude-3-haiku-20240307-v1:0' | 'anthropic.claude-3-opus-20240229-v1:0' | 'cohere.command-text-v14' | 'cohere.command-light-text-v14' | 'cohere.command-r-v1:0' | 'cohere.command-r-plus-v1:0' | 'meta.llama3-70b-instruct-v1:0' | 'meta.llama3-8b-instruct-v1:0' | 'meta.llama3-1-405b-instruct-v1:0' | 'meta.llama3-1-70b-instruct-v1:0' | 'meta.llama3-1-8b-instruct-v1:0' | 'meta.llama3-2-11b-instruct-v1:0' | 'meta.llama3-2-1b-instruct-v1:0' | 'meta.llama3-2-3b-instruct-v1:0' | 'meta.llama3-2-90b-instruct-v1:0' | 'mistral.mistral-7b-instruct-v0:2' | 'mistral.mixtral-8x7b-instruct-v0:1' | 'mistral.mistral-large-2402-v1:0' | 'mistral.mistral-small-2402-v1:0' | 'amazon.titan-text-express-v1' | 'amazon.titan-text-lite-v1' | (string & {});
6
6
  declare const bedrockProviderOptions: z.ZodObject<{
7
7
  /**
8
8
  * Additional inference parameters that the model supports,
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import { ProviderV2, LanguageModelV2, EmbeddingModelV2, ImageModelV2 } from '@ai
2
2
  import { FetchFunction } from '@ai-sdk/provider-utils';
3
3
  import { z } from 'zod';
4
4
 
5
- type BedrockChatModelId = 'amazon.titan-tg1-large' | 'amazon.titan-text-express-v1' | 'anthropic.claude-v2' | 'anthropic.claude-v2:1' | 'anthropic.claude-instant-v1' | 'anthropic.claude-3-7-sonnet-20250219-v1:0' | 'anthropic.claude-3-5-sonnet-20240620-v1:0' | 'anthropic.claude-3-5-sonnet-20241022-v2:0' | 'anthropic.claude-3-5-haiku-20241022-v1:0' | 'anthropic.claude-3-sonnet-20240229-v1:0' | 'anthropic.claude-3-haiku-20240307-v1:0' | 'anthropic.claude-3-opus-20240229-v1:0' | 'cohere.command-text-v14' | 'cohere.command-light-text-v14' | 'cohere.command-r-v1:0' | 'cohere.command-r-plus-v1:0' | 'meta.llama3-70b-instruct-v1:0' | 'meta.llama3-8b-instruct-v1:0' | 'meta.llama3-1-405b-instruct-v1:0' | 'meta.llama3-1-70b-instruct-v1:0' | 'meta.llama3-1-8b-instruct-v1:0' | 'meta.llama3-2-11b-instruct-v1:0' | 'meta.llama3-2-1b-instruct-v1:0' | 'meta.llama3-2-3b-instruct-v1:0' | 'meta.llama3-2-90b-instruct-v1:0' | 'mistral.mistral-7b-instruct-v0:2' | 'mistral.mixtral-8x7b-instruct-v0:1' | 'mistral.mistral-large-2402-v1:0' | 'mistral.mistral-small-2402-v1:0' | 'amazon.titan-text-express-v1' | 'amazon.titan-text-lite-v1' | (string & {});
5
+ type BedrockChatModelId = 'amazon.titan-tg1-large' | 'amazon.titan-text-express-v1' | 'anthropic.claude-v2' | 'anthropic.claude-v2:1' | 'anthropic.claude-instant-v1' | 'anthropic.claude-sonnet-4-20250514-v1:0' | 'anthropic.claude-opus-4-20250514-v1:0' | 'anthropic.claude-3-7-sonnet-20250219-v1:0' | 'anthropic.claude-3-5-sonnet-20240620-v1:0' | 'anthropic.claude-3-5-sonnet-20241022-v2:0' | 'anthropic.claude-3-5-haiku-20241022-v1:0' | 'anthropic.claude-3-sonnet-20240229-v1:0' | 'anthropic.claude-3-haiku-20240307-v1:0' | 'anthropic.claude-3-opus-20240229-v1:0' | 'cohere.command-text-v14' | 'cohere.command-light-text-v14' | 'cohere.command-r-v1:0' | 'cohere.command-r-plus-v1:0' | 'meta.llama3-70b-instruct-v1:0' | 'meta.llama3-8b-instruct-v1:0' | 'meta.llama3-1-405b-instruct-v1:0' | 'meta.llama3-1-70b-instruct-v1:0' | 'meta.llama3-1-8b-instruct-v1:0' | 'meta.llama3-2-11b-instruct-v1:0' | 'meta.llama3-2-1b-instruct-v1:0' | 'meta.llama3-2-3b-instruct-v1:0' | 'meta.llama3-2-90b-instruct-v1:0' | 'mistral.mistral-7b-instruct-v0:2' | 'mistral.mixtral-8x7b-instruct-v0:1' | 'mistral.mistral-large-2402-v1:0' | 'mistral.mistral-small-2402-v1:0' | 'amazon.titan-text-express-v1' | 'amazon.titan-text-lite-v1' | (string & {});
6
6
  declare const bedrockProviderOptions: z.ZodObject<{
7
7
  /**
8
8
  * Additional inference parameters that the model supports,
package/dist/index.js CHANGED
@@ -166,7 +166,7 @@ function prepareTools({
166
166
  name: tool.name,
167
167
  description: tool.description,
168
168
  inputSchema: {
169
- json: tool.parameters
169
+ json: tool.inputSchema
170
170
  }
171
171
  }
172
172
  });
@@ -215,7 +215,6 @@ function prepareTools({
215
215
  // src/convert-to-bedrock-chat-messages.ts
216
216
  var import_provider3 = require("@ai-sdk/provider");
217
217
  var import_provider_utils2 = require("@ai-sdk/provider-utils");
218
- var generateFileId = (0, import_provider_utils2.createIdGenerator)({ prefix: "file", size: 16 });
219
218
  function getCachePoint(providerMetadata) {
220
219
  var _a;
221
220
  return (_a = providerMetadata == null ? void 0 : providerMetadata.bedrock) == null ? void 0 : _a.cachePoint;
@@ -225,6 +224,8 @@ async function convertToBedrockChatMessages(prompt) {
225
224
  const blocks = groupIntoBlocks(prompt);
226
225
  let system = [];
227
226
  const messages = [];
227
+ let documentCounter = 0;
228
+ const generateDocumentName = () => `document-${++documentCounter}`;
228
229
  for (let i = 0; i < blocks.length; i++) {
229
230
  const block = blocks[i];
230
231
  const isLastBlock = i === blocks.length - 1;
@@ -279,7 +280,7 @@ async function convertToBedrockChatMessages(prompt) {
279
280
  format: (_d = (_c = part.mediaType) == null ? void 0 : _c.split(
280
281
  "/"
281
282
  )) == null ? void 0 : _d[1],
282
- name: generateFileId(),
283
+ name: generateDocumentName(),
283
284
  source: { bytes: (0, import_provider_utils2.convertToBase64)(part.data) }
284
285
  }
285
286
  });
@@ -291,36 +292,49 @@ async function convertToBedrockChatMessages(prompt) {
291
292
  break;
292
293
  }
293
294
  case "tool": {
294
- for (let i2 = 0; i2 < content.length; i2++) {
295
- const part = content[i2];
296
- const toolResultContent = part.content != void 0 ? part.content.map((part2) => {
297
- switch (part2.type) {
298
- case "text":
299
- return {
300
- text: part2.text
301
- };
302
- case "image":
303
- if (!part2.mediaType) {
304
- throw new Error(
305
- "Image mime type is required in tool result part content"
306
- );
307
- }
308
- const format = part2.mediaType.split("/")[1];
309
- if (!isBedrockImageFormat(format)) {
310
- throw new Error(
311
- `Unsupported image format: ${format}`
312
- );
313
- }
314
- return {
315
- image: {
316
- format,
317
- source: {
318
- bytes: part2.data
295
+ for (const part of content) {
296
+ let toolResultContent;
297
+ const output = part.output;
298
+ switch (output.type) {
299
+ case "content": {
300
+ toolResultContent = output.value.map((contentPart) => {
301
+ switch (contentPart.type) {
302
+ case "text":
303
+ return { text: contentPart.text };
304
+ case "media":
305
+ if (!contentPart.mediaType.startsWith("image/")) {
306
+ throw new import_provider3.UnsupportedFunctionalityError({
307
+ functionality: `media type: ${contentPart.mediaType}`
308
+ });
319
309
  }
320
- }
321
- };
310
+ const format = contentPart.mediaType.split("/")[1];
311
+ if (!isBedrockImageFormat(format)) {
312
+ throw new import_provider3.UnsupportedFunctionalityError({
313
+ functionality: `media type: ${contentPart.mediaType}`
314
+ });
315
+ }
316
+ return {
317
+ image: {
318
+ format,
319
+ source: { bytes: contentPart.data }
320
+ }
321
+ };
322
+ }
323
+ });
324
+ break;
322
325
  }
323
- }) : [{ text: JSON.stringify(part.result) }];
326
+ case "text":
327
+ case "error-text":
328
+ toolResultContent = [{ text: output.value }];
329
+ break;
330
+ case "json":
331
+ case "error-json":
332
+ default:
333
+ toolResultContent = [
334
+ { text: JSON.stringify(output.value) }
335
+ ];
336
+ break;
337
+ }
324
338
  bedrockContent.push({
325
339
  toolResult: {
326
340
  toolUseId: part.toolCallId,
@@ -409,7 +423,7 @@ async function convertToBedrockChatMessages(prompt) {
409
423
  toolUse: {
410
424
  toolUseId: part.toolCallId,
411
425
  name: part.toolName,
412
- input: part.args
426
+ input: part.input
413
427
  }
414
428
  });
415
429
  break;
@@ -678,10 +692,9 @@ var BedrockChatLanguageModel = class {
678
692
  if (part.toolUse) {
679
693
  content.push({
680
694
  type: "tool-call",
681
- toolCallType: "function",
682
695
  toolCallId: (_c = (_b = part.toolUse) == null ? void 0 : _b.toolUseId) != null ? _c : this.config.generateId(),
683
696
  toolName: (_e = (_d = part.toolUse) == null ? void 0 : _d.name) != null ? _e : `tool-${this.config.generateId()}`,
684
- args: JSON.stringify((_g = (_f = part.toolUse) == null ? void 0 : _f.input) != null ? _g : "")
697
+ input: JSON.stringify((_g = (_f = part.toolUse) == null ? void 0 : _f.input) != null ? _g : "")
685
698
  });
686
699
  }
687
700
  }
@@ -739,7 +752,7 @@ var BedrockChatLanguageModel = class {
739
752
  totalTokens: void 0
740
753
  };
741
754
  let providerMetadata = void 0;
742
- const toolCallContentBlocks = {};
755
+ const contentBlocks = {};
743
756
  return {
744
757
  stream: response.pipeThrough(
745
758
  new TransformStream({
@@ -747,11 +760,14 @@ var BedrockChatLanguageModel = class {
747
760
  controller.enqueue({ type: "stream-start", warnings });
748
761
  },
749
762
  transform(chunk, controller) {
750
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
763
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
751
764
  function enqueueError(bedrockError) {
752
765
  finishReason = "error";
753
766
  controller.enqueue({ type: "error", error: bedrockError });
754
767
  }
768
+ if (options.includeRawChunks) {
769
+ controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
770
+ }
755
771
  if (!chunk.success) {
756
772
  enqueueError(chunk.error);
757
773
  return;
@@ -800,78 +816,126 @@ var BedrockChatLanguageModel = class {
800
816
  };
801
817
  }
802
818
  }
803
- if (((_j = value.contentBlockDelta) == null ? void 0 : _j.delta) && "text" in value.contentBlockDelta.delta && value.contentBlockDelta.delta.text) {
819
+ if (((_j = value.contentBlockStart) == null ? void 0 : _j.contentBlockIndex) != null && !((_l = (_k = value.contentBlockStart) == null ? void 0 : _k.start) == null ? void 0 : _l.toolUse)) {
820
+ const blockIndex = value.contentBlockStart.contentBlockIndex;
821
+ contentBlocks[blockIndex] = { type: "text" };
822
+ controller.enqueue({
823
+ type: "text-start",
824
+ id: String(blockIndex)
825
+ });
826
+ }
827
+ if (((_m = value.contentBlockDelta) == null ? void 0 : _m.delta) && "text" in value.contentBlockDelta.delta && value.contentBlockDelta.delta.text) {
828
+ const blockIndex = value.contentBlockDelta.contentBlockIndex || 0;
829
+ if (contentBlocks[blockIndex] == null) {
830
+ contentBlocks[blockIndex] = { type: "text" };
831
+ controller.enqueue({
832
+ type: "text-start",
833
+ id: String(blockIndex)
834
+ });
835
+ }
804
836
  controller.enqueue({
805
- type: "text",
806
- text: value.contentBlockDelta.delta.text
837
+ type: "text-delta",
838
+ id: String(blockIndex),
839
+ delta: value.contentBlockDelta.delta.text
807
840
  });
808
841
  }
809
- if (((_k = value.contentBlockDelta) == null ? void 0 : _k.delta) && "reasoningContent" in value.contentBlockDelta.delta && value.contentBlockDelta.delta.reasoningContent) {
842
+ if (((_n = value.contentBlockStop) == null ? void 0 : _n.contentBlockIndex) != null) {
843
+ const blockIndex = value.contentBlockStop.contentBlockIndex;
844
+ const contentBlock = contentBlocks[blockIndex];
845
+ if (contentBlock != null) {
846
+ if (contentBlock.type === "reasoning") {
847
+ controller.enqueue({
848
+ type: "reasoning-end",
849
+ id: String(blockIndex)
850
+ });
851
+ } else if (contentBlock.type === "text") {
852
+ controller.enqueue({
853
+ type: "text-end",
854
+ id: String(blockIndex)
855
+ });
856
+ } else if (contentBlock.type === "tool-call") {
857
+ controller.enqueue({
858
+ type: "tool-input-end",
859
+ id: contentBlock.toolCallId
860
+ });
861
+ controller.enqueue({
862
+ type: "tool-call",
863
+ toolCallId: contentBlock.toolCallId,
864
+ toolName: contentBlock.toolName,
865
+ input: contentBlock.jsonText
866
+ });
867
+ }
868
+ delete contentBlocks[blockIndex];
869
+ }
870
+ }
871
+ if (((_o = value.contentBlockDelta) == null ? void 0 : _o.delta) && "reasoningContent" in value.contentBlockDelta.delta && value.contentBlockDelta.delta.reasoningContent) {
872
+ const blockIndex = value.contentBlockDelta.contentBlockIndex || 0;
810
873
  const reasoningContent = value.contentBlockDelta.delta.reasoningContent;
811
874
  if ("text" in reasoningContent && reasoningContent.text) {
875
+ if (contentBlocks[blockIndex] == null) {
876
+ contentBlocks[blockIndex] = { type: "reasoning" };
877
+ controller.enqueue({
878
+ type: "reasoning-start",
879
+ id: String(blockIndex)
880
+ });
881
+ }
812
882
  controller.enqueue({
813
- type: "reasoning",
814
- text: reasoningContent.text
883
+ type: "reasoning-delta",
884
+ id: String(blockIndex),
885
+ delta: reasoningContent.text
815
886
  });
816
887
  } else if ("signature" in reasoningContent && reasoningContent.signature) {
817
888
  controller.enqueue({
818
- type: "reasoning",
819
- text: "",
889
+ type: "reasoning-delta",
890
+ id: String(blockIndex),
891
+ delta: "",
820
892
  providerMetadata: {
821
893
  bedrock: {
822
894
  signature: reasoningContent.signature
823
895
  }
824
896
  }
825
897
  });
826
- controller.enqueue({ type: "reasoning-part-finish" });
827
898
  } else if ("data" in reasoningContent && reasoningContent.data) {
828
899
  controller.enqueue({
829
- type: "reasoning",
830
- text: "",
900
+ type: "reasoning-delta",
901
+ id: String(blockIndex),
902
+ delta: "",
831
903
  providerMetadata: {
832
904
  bedrock: {
833
905
  redactedData: reasoningContent.data
834
906
  }
835
907
  }
836
908
  });
837
- controller.enqueue({ type: "reasoning-part-finish" });
838
909
  }
839
910
  }
840
911
  const contentBlockStart = value.contentBlockStart;
841
- if (((_l = contentBlockStart == null ? void 0 : contentBlockStart.start) == null ? void 0 : _l.toolUse) != null) {
912
+ if (((_p = contentBlockStart == null ? void 0 : contentBlockStart.start) == null ? void 0 : _p.toolUse) != null) {
842
913
  const toolUse = contentBlockStart.start.toolUse;
843
- toolCallContentBlocks[contentBlockStart.contentBlockIndex] = {
914
+ const blockIndex = contentBlockStart.contentBlockIndex;
915
+ contentBlocks[blockIndex] = {
916
+ type: "tool-call",
844
917
  toolCallId: toolUse.toolUseId,
845
918
  toolName: toolUse.name,
846
919
  jsonText: ""
847
920
  };
848
- }
849
- const contentBlockDelta = value.contentBlockDelta;
850
- if ((contentBlockDelta == null ? void 0 : contentBlockDelta.delta) && "toolUse" in contentBlockDelta.delta && contentBlockDelta.delta.toolUse) {
851
- const contentBlock = toolCallContentBlocks[contentBlockDelta.contentBlockIndex];
852
- const delta = (_m = contentBlockDelta.delta.toolUse.input) != null ? _m : "";
853
921
  controller.enqueue({
854
- type: "tool-call-delta",
855
- toolCallType: "function",
856
- toolCallId: contentBlock.toolCallId,
857
- toolName: contentBlock.toolName,
858
- argsTextDelta: delta
922
+ type: "tool-input-start",
923
+ id: toolUse.toolUseId,
924
+ toolName: toolUse.name
859
925
  });
860
- contentBlock.jsonText += delta;
861
926
  }
862
- const contentBlockStop = value.contentBlockStop;
863
- if (contentBlockStop != null) {
864
- const index = contentBlockStop.contentBlockIndex;
865
- const contentBlock = toolCallContentBlocks[index];
866
- if (contentBlock != null) {
927
+ const contentBlockDelta = value.contentBlockDelta;
928
+ if ((contentBlockDelta == null ? void 0 : contentBlockDelta.delta) && "toolUse" in contentBlockDelta.delta && contentBlockDelta.delta.toolUse) {
929
+ const blockIndex = contentBlockDelta.contentBlockIndex;
930
+ const contentBlock = contentBlocks[blockIndex];
931
+ if ((contentBlock == null ? void 0 : contentBlock.type) === "tool-call") {
932
+ const delta = (_q = contentBlockDelta.delta.toolUse.input) != null ? _q : "";
867
933
  controller.enqueue({
868
- type: "tool-call",
869
- toolCallType: "function",
870
- toolCallId: contentBlock.toolCallId,
871
- toolName: contentBlock.toolName,
872
- args: contentBlock.jsonText
934
+ type: "tool-input-delta",
935
+ id: contentBlock.toolCallId,
936
+ delta
873
937
  });
874
- delete toolCallContentBlocks[index];
938
+ contentBlock.jsonText += delta;
875
939
  }
876
940
  }
877
941
  },