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/dist/index.mjs CHANGED
@@ -9099,6 +9099,7 @@ var AbstractChat = class {
9099
9099
  body
9100
9100
  });
9101
9101
  if (reconnect == null) {
9102
+ this.setStatus({ status: "ready" });
9102
9103
  return;
9103
9104
  }
9104
9105
  stream = reconnect;
@@ -9191,9 +9192,17 @@ function convertToModelMessages(messages, options) {
9191
9192
  for (const message of messages) {
9192
9193
  switch (message.role) {
9193
9194
  case "system": {
9195
+ const textParts = message.parts.filter((part) => part.type === "text");
9196
+ const providerMetadata = textParts.reduce((acc, part) => {
9197
+ if (part.providerMetadata != null) {
9198
+ return { ...acc, ...part.providerMetadata };
9199
+ }
9200
+ return acc;
9201
+ }, {});
9194
9202
  modelMessages.push({
9195
9203
  role: "system",
9196
- content: message.parts.map((part) => part.type === "text" ? part.text : "").join("")
9204
+ content: textParts.map((part) => part.text).join(""),
9205
+ ...Object.keys(providerMetadata).length > 0 ? { providerOptions: providerMetadata } : {}
9197
9206
  });
9198
9207
  break;
9199
9208
  }
@@ -9380,7 +9389,7 @@ function lastAssistantMessageIsCompleteWithToolCalls({
9380
9389
  const lastStepStartIndex = message.parts.reduce((lastIndex, part, index) => {
9381
9390
  return part.type === "step-start" ? index : lastIndex;
9382
9391
  }, -1);
9383
- const lastStepToolInvocations = message.parts.slice(lastStepStartIndex + 1).filter(isToolUIPart);
9392
+ const lastStepToolInvocations = message.parts.slice(lastStepStartIndex + 1).filter((part) => isToolUIPart(part) || part.type === "dynamic-tool");
9384
9393
  return lastStepToolInvocations.length > 0 && lastStepToolInvocations.every((part) => part.state === "output-available");
9385
9394
  }
9386
9395