ai 4.3.6 → 4.3.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/dist/index.mjs CHANGED
@@ -4008,23 +4008,36 @@ function toResponseMessages({
4008
4008
  generateMessageId
4009
4009
  }) {
4010
4010
  const responseMessages = [];
4011
- responseMessages.push({
4012
- role: "assistant",
4013
- content: [
4011
+ const content = [];
4012
+ if (reasoning.length > 0) {
4013
+ content.push(
4014
4014
  ...reasoning.map(
4015
4015
  (part) => part.type === "text" ? { ...part, type: "reasoning" } : { ...part, type: "redacted-reasoning" }
4016
- ),
4017
- // TODO language model v2: switch to order response content (instead of type-based ordering)
4016
+ )
4017
+ );
4018
+ }
4019
+ if (files.length > 0) {
4020
+ content.push(
4018
4021
  ...files.map((file) => ({
4019
4022
  type: "file",
4020
4023
  data: file.base64,
4021
4024
  mimeType: file.mimeType
4022
- })),
4023
- { type: "text", text: text2 },
4024
- ...toolCalls
4025
- ],
4026
- id: messageId
4027
- });
4025
+ }))
4026
+ );
4027
+ }
4028
+ if (text2.length > 0) {
4029
+ content.push({ type: "text", text: text2 });
4030
+ }
4031
+ if (toolCalls.length > 0) {
4032
+ content.push(...toolCalls);
4033
+ }
4034
+ if (content.length > 0) {
4035
+ responseMessages.push({
4036
+ role: "assistant",
4037
+ content,
4038
+ id: messageId
4039
+ });
4040
+ }
4028
4041
  if (toolResults.length > 0) {
4029
4042
  responseMessages.push({
4030
4043
  role: "tool",