ai 5.0.85 → 5.0.87

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,20 @@
1
1
  # ai
2
2
 
3
+ ## 5.0.87
4
+
5
+ ### Patch Changes
6
+
7
+ - 51aa5de: backport: test server
8
+ - Updated dependencies [51aa5de]
9
+ - @ai-sdk/provider-utils@3.0.16
10
+ - @ai-sdk/gateway@2.0.6
11
+
12
+ ## 5.0.86
13
+
14
+ ### Patch Changes
15
+
16
+ - 0f92046: fix(ui): Don't resend messages for providerExecuted tools in lastAssistantMessageIsCompleteWithToolCalls and lastAssistantMessageIsCompleteWithApprovalResponses
17
+
3
18
  ## 5.0.85
4
19
 
5
20
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1537,7 +1537,14 @@ declare function isDataUIPart<DATA_TYPES extends UIDataTypes>(part: UIMessagePar
1537
1537
  * UI components for the tool.
1538
1538
  */
1539
1539
  type UIToolInvocation<TOOL extends UITool | Tool> = {
1540
+ /**
1541
+ * ID of the tool call.
1542
+ */
1540
1543
  toolCallId: string;
1544
+ /**
1545
+ * Whether the tool call was executed by the provider.
1546
+ */
1547
+ providerExecuted?: boolean;
1541
1548
  } & ({
1542
1549
  state: 'input-streaming';
1543
1550
  input: DeepPartial<asUITool<TOOL>['input']> | undefined;
@@ -1575,8 +1582,19 @@ type ToolUIPart<TOOLS extends UITools = UITools> = ValueOf<{
1575
1582
  }>;
1576
1583
  type DynamicToolUIPart = {
1577
1584
  type: 'dynamic-tool';
1585
+ /**
1586
+ * Name of the tool that is being called.
1587
+ */
1578
1588
  toolName: string;
1589
+ /**
1590
+ * ID of the tool call.
1591
+ */
1579
1592
  toolCallId: string;
1593
+ title?: string;
1594
+ /**
1595
+ * Whether the tool call was executed by the provider.
1596
+ */
1597
+ providerExecuted?: boolean;
1580
1598
  } & ({
1581
1599
  state: 'input-streaming';
1582
1600
  input: unknown | undefined;
package/dist/index.d.ts CHANGED
@@ -1537,7 +1537,14 @@ declare function isDataUIPart<DATA_TYPES extends UIDataTypes>(part: UIMessagePar
1537
1537
  * UI components for the tool.
1538
1538
  */
1539
1539
  type UIToolInvocation<TOOL extends UITool | Tool> = {
1540
+ /**
1541
+ * ID of the tool call.
1542
+ */
1540
1543
  toolCallId: string;
1544
+ /**
1545
+ * Whether the tool call was executed by the provider.
1546
+ */
1547
+ providerExecuted?: boolean;
1541
1548
  } & ({
1542
1549
  state: 'input-streaming';
1543
1550
  input: DeepPartial<asUITool<TOOL>['input']> | undefined;
@@ -1575,8 +1582,19 @@ type ToolUIPart<TOOLS extends UITools = UITools> = ValueOf<{
1575
1582
  }>;
1576
1583
  type DynamicToolUIPart = {
1577
1584
  type: 'dynamic-tool';
1585
+ /**
1586
+ * Name of the tool that is being called.
1587
+ */
1578
1588
  toolName: string;
1589
+ /**
1590
+ * ID of the tool call.
1591
+ */
1579
1592
  toolCallId: string;
1593
+ title?: string;
1594
+ /**
1595
+ * Whether the tool call was executed by the provider.
1596
+ */
1597
+ providerExecuted?: boolean;
1580
1598
  } & ({
1581
1599
  state: 'input-streaming';
1582
1600
  input: unknown | undefined;
package/dist/index.js CHANGED
@@ -764,7 +764,7 @@ function detectMediaType({
764
764
  var import_provider_utils2 = require("@ai-sdk/provider-utils");
765
765
 
766
766
  // src/version.ts
767
- var VERSION = true ? "5.0.85" : "0.0.0-test";
767
+ var VERSION = true ? "5.0.87" : "0.0.0-test";
768
768
 
769
769
  // src/util/download/download.ts
770
770
  var download = async ({ url }) => {
@@ -3563,7 +3563,7 @@ function processUIMessageStream({
3563
3563
  }
3564
3564
  }
3565
3565
  function updateDynamicToolPart(options) {
3566
- var _a17;
3566
+ var _a17, _b2;
3567
3567
  const part = state.message.parts.find(
3568
3568
  (part2) => part2.type === "dynamic-tool" && part2.toolCallId === options.toolCallId
3569
3569
  );
@@ -3577,6 +3577,7 @@ function processUIMessageStream({
3577
3577
  anyPart.errorText = anyOptions.errorText;
3578
3578
  anyPart.rawInput = (_a17 = anyOptions.rawInput) != null ? _a17 : anyPart.rawInput;
3579
3579
  anyPart.preliminary = anyOptions.preliminary;
3580
+ anyPart.providerExecuted = (_b2 = anyOptions.providerExecuted) != null ? _b2 : part.providerExecuted;
3580
3581
  if (anyOptions.providerMetadata != null && part.state === "input-available") {
3581
3582
  part.callProviderMetadata = anyOptions.providerMetadata;
3582
3583
  }
@@ -3590,6 +3591,7 @@ function processUIMessageStream({
3590
3591
  output: anyOptions.output,
3591
3592
  errorText: anyOptions.errorText,
3592
3593
  preliminary: anyOptions.preliminary,
3594
+ providerExecuted: anyOptions.providerExecuted,
3593
3595
  ...anyOptions.providerMetadata != null ? { callProviderMetadata: anyOptions.providerMetadata } : {}
3594
3596
  });
3595
3597
  }
@@ -3706,7 +3708,8 @@ function processUIMessageStream({
3706
3708
  toolCallId: chunk.toolCallId,
3707
3709
  toolName: chunk.toolName,
3708
3710
  state: "input-streaming",
3709
- input: void 0
3711
+ input: void 0,
3712
+ providerExecuted: chunk.providerExecuted
3710
3713
  });
3711
3714
  } else {
3712
3715
  updateToolPart({
@@ -3751,6 +3754,7 @@ function processUIMessageStream({
3751
3754
  toolName: chunk.toolName,
3752
3755
  state: "input-available",
3753
3756
  input: chunk.input,
3757
+ providerExecuted: chunk.providerExecuted,
3754
3758
  providerMetadata: chunk.providerMetadata
3755
3759
  });
3756
3760
  } else {
@@ -3779,6 +3783,7 @@ function processUIMessageStream({
3779
3783
  state: "output-error",
3780
3784
  input: chunk.input,
3781
3785
  errorText: chunk.errorText,
3786
+ providerExecuted: chunk.providerExecuted,
3782
3787
  providerMetadata: chunk.providerMetadata
3783
3788
  });
3784
3789
  } else {
@@ -3834,7 +3839,8 @@ function processUIMessageStream({
3834
3839
  toolName: toolInvocation.toolName,
3835
3840
  state: "output-error",
3836
3841
  input: toolInvocation.input,
3837
- errorText: chunk.errorText
3842
+ errorText: chunk.errorText,
3843
+ providerExecuted: chunk.providerExecuted
3838
3844
  });
3839
3845
  } else {
3840
3846
  const toolInvocation = getToolInvocation(chunk.toolCallId);
@@ -3844,7 +3850,8 @@ function processUIMessageStream({
3844
3850
  state: "output-error",
3845
3851
  input: toolInvocation.input,
3846
3852
  rawInput: toolInvocation.rawInput,
3847
- errorText: chunk.errorText
3853
+ errorText: chunk.errorText,
3854
+ providerExecuted: chunk.providerExecuted
3848
3855
  });
3849
3856
  }
3850
3857
  write();
@@ -9490,7 +9497,7 @@ function lastAssistantMessageIsCompleteWithToolCalls({
9490
9497
  const lastStepStartIndex = message.parts.reduce((lastIndex, part, index) => {
9491
9498
  return part.type === "step-start" ? index : lastIndex;
9492
9499
  }, -1);
9493
- const lastStepToolInvocations = message.parts.slice(lastStepStartIndex + 1).filter(isToolOrDynamicToolUIPart);
9500
+ const lastStepToolInvocations = message.parts.slice(lastStepStartIndex + 1).filter(isToolOrDynamicToolUIPart).filter((part) => !part.providerExecuted);
9494
9501
  return lastStepToolInvocations.length > 0 && lastStepToolInvocations.every(
9495
9502
  (part) => part.state === "output-available" || part.state === "output-error"
9496
9503
  );
@@ -9592,6 +9599,7 @@ var uiMessagesSchema = (0, import_provider_utils32.lazyValidator)(
9592
9599
  toolCallId: import_v48.z.string(),
9593
9600
  state: import_v48.z.literal("input-streaming"),
9594
9601
  input: import_v48.z.unknown().optional(),
9602
+ providerExecuted: import_v48.z.boolean().optional(),
9595
9603
  output: import_v48.z.never().optional(),
9596
9604
  errorText: import_v48.z.never().optional()
9597
9605
  }),
@@ -9601,6 +9609,7 @@ var uiMessagesSchema = (0, import_provider_utils32.lazyValidator)(
9601
9609
  toolCallId: import_v48.z.string(),
9602
9610
  state: import_v48.z.literal("input-available"),
9603
9611
  input: import_v48.z.unknown(),
9612
+ providerExecuted: import_v48.z.boolean().optional(),
9604
9613
  output: import_v48.z.never().optional(),
9605
9614
  errorText: import_v48.z.never().optional(),
9606
9615
  callProviderMetadata: providerMetadataSchema.optional()
@@ -9611,6 +9620,7 @@ var uiMessagesSchema = (0, import_provider_utils32.lazyValidator)(
9611
9620
  toolCallId: import_v48.z.string(),
9612
9621
  state: import_v48.z.literal("output-available"),
9613
9622
  input: import_v48.z.unknown(),
9623
+ providerExecuted: import_v48.z.boolean().optional(),
9614
9624
  output: import_v48.z.unknown(),
9615
9625
  errorText: import_v48.z.never().optional(),
9616
9626
  callProviderMetadata: providerMetadataSchema.optional(),
@@ -9622,6 +9632,7 @@ var uiMessagesSchema = (0, import_provider_utils32.lazyValidator)(
9622
9632
  toolCallId: import_v48.z.string(),
9623
9633
  state: import_v48.z.literal("output-error"),
9624
9634
  input: import_v48.z.unknown(),
9635
+ providerExecuted: import_v48.z.boolean().optional(),
9625
9636
  output: import_v48.z.never().optional(),
9626
9637
  errorText: import_v48.z.string(),
9627
9638
  callProviderMetadata: providerMetadataSchema.optional()