ai 7.0.133 → 7.0.134

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,12 @@
1
1
  # ai
2
2
 
3
+ ## 7.0.134
4
+
5
+ ### Patch Changes
6
+
7
+ - 8281ec4: fix(ai): propagate async sendAutomaticallyWhen failures from tool updates
8
+ - 46c2b05: fix(ai): preserve provider-executed tool calls when resuming streams
9
+
3
10
  ## 7.0.133
4
11
 
5
12
  ### Patch Changes
package/dist/index.js CHANGED
@@ -1174,7 +1174,7 @@ function cloneValue(value) {
1174
1174
  }
1175
1175
  //#endregion
1176
1176
  //#region src/version.ts
1177
- const VERSION = "7.0.133";
1177
+ const VERSION = "7.0.134";
1178
1178
  //#endregion
1179
1179
  //#region src/util/download/download.ts
1180
1180
  /**
@@ -19793,8 +19793,8 @@ var AbstractChat = class {
19793
19793
  this.pendingApprovalMessageId = message.id;
19794
19794
  }
19795
19795
  if (this.activeResponse) this.activeResponse.state.message.parts = this.activeResponse.state.message.parts.map(updatePart);
19796
- if (this.status !== "streaming" && this.status !== "submitted" && this.sendAutomaticallyWhen) this.shouldSendAutomatically().then((shouldSend) => {
19797
- if (shouldSend) {
19796
+ if (this.status !== "streaming" && this.status !== "submitted" && this.sendAutomaticallyWhen) {
19797
+ if (await this.shouldSendAutomatically()) {
19798
19798
  const messageId = messageIndex === -1 ? this.lastMessage?.id : messages[messageIndex].id;
19799
19799
  this.makeRequestForToolApproval({
19800
19800
  messageId,
@@ -19802,7 +19802,7 @@ var AbstractChat = class {
19802
19802
  ...options
19803
19803
  });
19804
19804
  }
19805
- });
19805
+ }
19806
19806
  });
19807
19807
  this.addToolOutput = async ({ state, toolCallId, output, errorText, options }) => this.jobExecutor.run(async () => {
19808
19808
  const messages = this.state.messages;
@@ -19835,13 +19835,13 @@ var AbstractChat = class {
19835
19835
  parts: lastMessage.parts.map(updatePart)
19836
19836
  });
19837
19837
  if (this.activeResponse) this.activeResponse.state.message.parts = this.activeResponse.state.message.parts.map(updatePart);
19838
- if (this.status !== "streaming" && this.status !== "submitted" && this.sendAutomaticallyWhen) this.shouldSendAutomatically().then((shouldSend) => {
19839
- if (shouldSend) this.makeRequest({
19838
+ if (this.status !== "streaming" && this.status !== "submitted" && this.sendAutomaticallyWhen) {
19839
+ if (await this.shouldSendAutomatically()) this.makeRequest({
19840
19840
  trigger: "submit-message",
19841
19841
  messageId: this.lastMessage?.id,
19842
19842
  ...options
19843
19843
  });
19844
- });
19844
+ }
19845
19845
  });
19846
19846
  this.addToolResult = this.addToolOutput;
19847
19847
  this.stop = async () => {
@@ -19970,7 +19970,7 @@ var AbstractChat = class {
19970
19970
  const lastMessage = this.lastMessage;
19971
19971
  const responseMessageIndex = trigger === "submit-message" && messageId != null ? this.state.messages.findIndex((message) => message.id === messageId) : this.state.messages.length - 1;
19972
19972
  const responseMessage = responseMessageIndex === -1 ? lastMessage : this.state.messages[responseMessageIndex];
19973
- const resumableResponseMessage = trigger === "resume-stream" && responseMessage?.role === "assistant" && responseMessage.parts.some((part) => isToolUIPart(part) && (part.state === "input-streaming" || part.state === "approval-responded")) ? this.state.snapshot(responseMessage) : void 0;
19973
+ const resumableResponseMessage = trigger === "resume-stream" && responseMessage?.role === "assistant" && responseMessage.parts.some((part) => isToolUIPart(part) && (part.state === "input-streaming" || part.state === "input-available" && part.providerExecuted || part.state === "approval-responded")) ? this.state.snapshot(responseMessage) : void 0;
19974
19974
  const usesEarlierAssistantMessage = responseMessageIndex !== -1 && responseMessageIndex < this.state.messages.length - 1 && responseMessage?.role === "assistant";
19975
19975
  let isAbort = false;
19976
19976
  let isDisconnect = false;