ai 4.1.48 → 4.1.49

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
@@ -6135,7 +6135,7 @@ function appendResponseMessages({
6135
6135
  const lastMessage = clonedMessages[clonedMessages.length - 1];
6136
6136
  const isLastMessageAssistant = lastMessage.role === "assistant";
6137
6137
  switch (role) {
6138
- case "assistant":
6138
+ case "assistant": {
6139
6139
  let getToolInvocations2 = function(step) {
6140
6140
  return (typeof message.content === "string" ? [] : message.content.filter((part) => part.type === "tool-call")).map((call) => ({
6141
6141
  state: "call",
@@ -6146,19 +6146,74 @@ function appendResponseMessages({
6146
6146
  }));
6147
6147
  };
6148
6148
  var getToolInvocations = getToolInvocations2;
6149
- const textContent = typeof message.content === "string" ? message.content : message.content.filter((part) => part.type === "text").map((part) => part.text).join("");
6149
+ const parts = [];
6150
+ let textContent = "";
6151
+ let reasoningTextContent = void 0;
6152
+ if (typeof message.content === "string") {
6153
+ textContent = message.content;
6154
+ parts.push({
6155
+ type: "text",
6156
+ text: message.content
6157
+ });
6158
+ } else {
6159
+ let reasoningPart = void 0;
6160
+ for (const part of message.content) {
6161
+ switch (part.type) {
6162
+ case "text": {
6163
+ reasoningPart = void 0;
6164
+ textContent += part.text;
6165
+ parts.push({
6166
+ type: "text",
6167
+ text: part.text
6168
+ });
6169
+ break;
6170
+ }
6171
+ case "reasoning": {
6172
+ if (reasoningPart == null) {
6173
+ reasoningPart = {
6174
+ type: "reasoning",
6175
+ reasoning: "",
6176
+ details: []
6177
+ };
6178
+ parts.push(reasoningPart);
6179
+ }
6180
+ reasoningTextContent = (reasoningTextContent != null ? reasoningTextContent : "") + part.text;
6181
+ reasoningPart.reasoning += part.text;
6182
+ reasoningPart.details.push({
6183
+ type: "text",
6184
+ text: part.text,
6185
+ signature: part.signature
6186
+ });
6187
+ break;
6188
+ }
6189
+ case "redacted-reasoning": {
6190
+ if (reasoningPart == null) {
6191
+ reasoningPart = {
6192
+ type: "reasoning",
6193
+ reasoning: "",
6194
+ details: []
6195
+ };
6196
+ parts.push(reasoningPart);
6197
+ }
6198
+ reasoningPart.details.push({
6199
+ type: "redacted",
6200
+ data: part.data
6201
+ });
6202
+ break;
6203
+ }
6204
+ case "tool-call":
6205
+ break;
6206
+ }
6207
+ }
6208
+ }
6150
6209
  if (isLastMessageAssistant) {
6151
6210
  const maxStep = extractMaxToolInvocationStep(
6152
6211
  lastMessage.toolInvocations
6153
6212
  );
6154
6213
  (_a16 = lastMessage.parts) != null ? _a16 : lastMessage.parts = [];
6155
6214
  lastMessage.content = textContent;
6156
- if (textContent.length > 0) {
6157
- lastMessage.parts.push({
6158
- type: "text",
6159
- text: textContent
6160
- });
6161
- }
6215
+ lastMessage.reasoning = reasoningTextContent;
6216
+ lastMessage.parts.push(...parts);
6162
6217
  lastMessage.toolInvocations = [
6163
6218
  ...(_b = lastMessage.toolInvocations) != null ? _b : [],
6164
6219
  ...getToolInvocations2(maxStep === void 0 ? 0 : maxStep + 1)
@@ -6176,9 +6231,10 @@ function appendResponseMessages({
6176
6231
  createdAt: currentDate(),
6177
6232
  // generate a createdAt date for the message, will be overridden by the client
6178
6233
  content: textContent,
6234
+ reasoning: reasoningTextContent,
6179
6235
  toolInvocations: getToolInvocations2(0),
6180
6236
  parts: [
6181
- ...textContent.length > 0 ? [{ type: "text", text: textContent }] : [],
6237
+ ...parts,
6182
6238
  ...getToolInvocations2(0).map((call) => ({
6183
6239
  type: "tool-invocation",
6184
6240
  toolInvocation: call
@@ -6187,6 +6243,7 @@ function appendResponseMessages({
6187
6243
  });
6188
6244
  }
6189
6245
  break;
6246
+ }
6190
6247
  case "tool": {
6191
6248
  (_c = lastMessage.toolInvocations) != null ? _c : lastMessage.toolInvocations = [];
6192
6249
  if (lastMessage.role !== "assistant") {