ai 4.2.6 → 4.2.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai",
3
- "version": "4.2.6",
3
+ "version": "4.2.7",
4
4
  "description": "AI SDK by Vercel - The AI Toolkit for TypeScript and JavaScript",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -112,6 +112,7 @@
112
112
  "test:node": "vitest --config vitest.node.config.js --run",
113
113
  "test:node:watch": "vitest --config vitest.node.config.js",
114
114
  "test:node:core": "pnpm vitest --config vitest.node.config.js --run ./core/",
115
+ "test:node:core:watch": "pnpm vitest --config vitest.node.config.js ./core/",
115
116
  "test:node:util": "pnpm vitest --config vitest.node.config.js --run ./util/",
116
117
  "test:ui": "pnpm test:ui:react",
117
118
  "test:ui:react": "vitest --config vitest.ui.react.config.js --run",
@@ -1100,13 +1100,24 @@ function convertToCoreMessages(messages, options) {
1100
1100
  break;
1101
1101
  }
1102
1102
  case "user": {
1103
- coreMessages.push({
1104
- role: "user",
1105
- content: experimental_attachments ? [
1106
- { type: "text", text: content },
1107
- ...attachmentsToParts(experimental_attachments)
1108
- ] : content
1109
- });
1103
+ if (message.parts == null) {
1104
+ coreMessages.push({
1105
+ role: "user",
1106
+ content: experimental_attachments ? [
1107
+ { type: "text", text: content },
1108
+ ...attachmentsToParts(experimental_attachments)
1109
+ ] : content
1110
+ });
1111
+ } else {
1112
+ const textParts = message.parts.filter((part) => part.type === "text").map((part) => ({
1113
+ type: "text",
1114
+ text: part.text
1115
+ }));
1116
+ coreMessages.push({
1117
+ role: "user",
1118
+ content: experimental_attachments ? [...textParts, ...attachmentsToParts(experimental_attachments)] : textParts
1119
+ });
1120
+ }
1110
1121
  break;
1111
1122
  }
1112
1123
  case "assistant": {