ai 5.0.0 → 5.0.2

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,18 @@
1
1
  # ai
2
2
 
3
+ ## 5.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 401d73e: fix (ai): support dynamic tool calls in lastAssistantMessageIsCompleteWithToolCalls
8
+ - 69fde99: Set status to ready when reconnect stream is null
9
+
10
+ ## 5.0.1
11
+
12
+ ### Patch Changes
13
+
14
+ - 4d0c108: fix(ai/ui): convert provider metadata for system messages to model messages
15
+
3
16
  ## 5.0.0
4
17
 
5
18
  ### Major Changes
package/dist/index.js CHANGED
@@ -9138,6 +9138,7 @@ var AbstractChat = class {
9138
9138
  body
9139
9139
  });
9140
9140
  if (reconnect == null) {
9141
+ this.setStatus({ status: "ready" });
9141
9142
  return;
9142
9143
  }
9143
9144
  stream = reconnect;
@@ -9230,9 +9231,17 @@ function convertToModelMessages(messages, options) {
9230
9231
  for (const message of messages) {
9231
9232
  switch (message.role) {
9232
9233
  case "system": {
9234
+ const textParts = message.parts.filter((part) => part.type === "text");
9235
+ const providerMetadata = textParts.reduce((acc, part) => {
9236
+ if (part.providerMetadata != null) {
9237
+ return { ...acc, ...part.providerMetadata };
9238
+ }
9239
+ return acc;
9240
+ }, {});
9233
9241
  modelMessages.push({
9234
9242
  role: "system",
9235
- content: message.parts.map((part) => part.type === "text" ? part.text : "").join("")
9243
+ content: textParts.map((part) => part.text).join(""),
9244
+ ...Object.keys(providerMetadata).length > 0 ? { providerOptions: providerMetadata } : {}
9236
9245
  });
9237
9246
  break;
9238
9247
  }
@@ -9419,7 +9428,7 @@ function lastAssistantMessageIsCompleteWithToolCalls({
9419
9428
  const lastStepStartIndex = message.parts.reduce((lastIndex, part, index) => {
9420
9429
  return part.type === "step-start" ? index : lastIndex;
9421
9430
  }, -1);
9422
- const lastStepToolInvocations = message.parts.slice(lastStepStartIndex + 1).filter(isToolUIPart);
9431
+ const lastStepToolInvocations = message.parts.slice(lastStepStartIndex + 1).filter((part) => isToolUIPart(part) || part.type === "dynamic-tool");
9423
9432
  return lastStepToolInvocations.length > 0 && lastStepToolInvocations.every((part) => part.state === "output-available");
9424
9433
  }
9425
9434