ai 5.0.0-canary.15 → 5.0.0-canary.16

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.
@@ -314,7 +314,7 @@ interface Attachment {
314
314
  /**
315
315
  * AI SDK UI Messages. They are used in the client and to communicate between the frontend and the API routes.
316
316
  */
317
- interface Message {
317
+ interface UIMessage {
318
318
  /**
319
319
  A unique identifier for the message.
320
320
  */
@@ -328,32 +328,26 @@ interface Message {
328
328
  */
329
329
  content: string;
330
330
  /**
331
- * Additional attachments to be sent along with the message.
331
+ Additional attachments to be sent along with the message.
332
332
  */
333
333
  experimental_attachments?: Attachment[];
334
334
  /**
335
- The 'data' role is deprecated.
335
+ The role of the message.
336
336
  */
337
- role: 'system' | 'user' | 'assistant' | 'data';
337
+ role: 'system' | 'user' | 'assistant';
338
338
  /**
339
- * Additional message-specific information added on the server via StreamData
339
+ Additional message-specific information added on the server via StreamData
340
340
  */
341
341
  annotations?: JSONValue$1[] | undefined;
342
342
  /**
343
- Tool invocations (that can be tool calls or tool results, depending on whether or not the invocation has finished)
344
- that the assistant made as part of this message.
343
+ The parts of the message. Use this for rendering the message in the UI.
345
344
 
346
- @deprecated Use `parts` instead.
345
+ Assistant messages can have text, reasoning and tool invocation parts.
346
+ User messages can have text parts.
347
347
  */
348
- toolInvocations?: Array<ToolInvocation>;
349
- /**
350
- * The parts of the message. Use this for rendering the message in the UI.
351
- *
352
- * Assistant messages can have text, reasoning and tool invocation parts.
353
- * User messages can have text parts.
354
- */
355
- parts?: Array<TextUIPart | ReasoningUIPart | ToolInvocationUIPart | SourceUIPart | FileUIPart | StepStartUIPart>;
348
+ parts: Array<UIMessagePart>;
356
349
  }
350
+ type UIMessagePart = TextUIPart | ReasoningUIPart | ToolInvocationUIPart | SourceUIPart | FileUIPart | StepStartUIPart;
357
351
  /**
358
352
  * A text part of a message.
359
353
  */
@@ -372,7 +366,7 @@ type ReasoningUIPart = {
372
366
  /**
373
367
  * The reasoning text.
374
368
  */
375
- reasoning: string;
369
+ text: string;
376
370
  /**
377
371
  * The provider metadata.
378
372
  */
@@ -603,7 +597,7 @@ type Prompt = {
603
597
  /**
604
598
  A list of messages. You can either use `prompt` or `messages` but not both.
605
599
  */
606
- messages?: Array<CoreMessage> | Array<Omit<Message, 'id'>>;
600
+ messages?: Array<CoreMessage> | Array<Omit<UIMessage, 'id'>>;
607
601
  };
608
602
 
609
603
  type StandardizedPrompt = {
@@ -314,7 +314,7 @@ interface Attachment {
314
314
  /**
315
315
  * AI SDK UI Messages. They are used in the client and to communicate between the frontend and the API routes.
316
316
  */
317
- interface Message {
317
+ interface UIMessage {
318
318
  /**
319
319
  A unique identifier for the message.
320
320
  */
@@ -328,32 +328,26 @@ interface Message {
328
328
  */
329
329
  content: string;
330
330
  /**
331
- * Additional attachments to be sent along with the message.
331
+ Additional attachments to be sent along with the message.
332
332
  */
333
333
  experimental_attachments?: Attachment[];
334
334
  /**
335
- The 'data' role is deprecated.
335
+ The role of the message.
336
336
  */
337
- role: 'system' | 'user' | 'assistant' | 'data';
337
+ role: 'system' | 'user' | 'assistant';
338
338
  /**
339
- * Additional message-specific information added on the server via StreamData
339
+ Additional message-specific information added on the server via StreamData
340
340
  */
341
341
  annotations?: JSONValue$1[] | undefined;
342
342
  /**
343
- Tool invocations (that can be tool calls or tool results, depending on whether or not the invocation has finished)
344
- that the assistant made as part of this message.
343
+ The parts of the message. Use this for rendering the message in the UI.
345
344
 
346
- @deprecated Use `parts` instead.
345
+ Assistant messages can have text, reasoning and tool invocation parts.
346
+ User messages can have text parts.
347
347
  */
348
- toolInvocations?: Array<ToolInvocation>;
349
- /**
350
- * The parts of the message. Use this for rendering the message in the UI.
351
- *
352
- * Assistant messages can have text, reasoning and tool invocation parts.
353
- * User messages can have text parts.
354
- */
355
- parts?: Array<TextUIPart | ReasoningUIPart | ToolInvocationUIPart | SourceUIPart | FileUIPart | StepStartUIPart>;
348
+ parts: Array<UIMessagePart>;
356
349
  }
350
+ type UIMessagePart = TextUIPart | ReasoningUIPart | ToolInvocationUIPart | SourceUIPart | FileUIPart | StepStartUIPart;
357
351
  /**
358
352
  * A text part of a message.
359
353
  */
@@ -372,7 +366,7 @@ type ReasoningUIPart = {
372
366
  /**
373
367
  * The reasoning text.
374
368
  */
375
- reasoning: string;
369
+ text: string;
376
370
  /**
377
371
  * The provider metadata.
378
372
  */
@@ -603,7 +597,7 @@ type Prompt = {
603
597
  /**
604
598
  A list of messages. You can either use `prompt` or `messages` but not both.
605
599
  */
606
- messages?: Array<CoreMessage> | Array<Omit<Message, 'id'>>;
600
+ messages?: Array<CoreMessage> | Array<Omit<UIMessage, 'id'>>;
607
601
  };
608
602
 
609
603
  type StandardizedPrompt = {
@@ -311,7 +311,7 @@ function convertToCoreMessages(messages, options) {
311
311
  case "reasoning": {
312
312
  content2.push({
313
313
  type: "reasoning",
314
- text: part.reasoning,
314
+ text: part.text,
315
315
  providerOptions: part.providerMetadata
316
316
  });
317
317
  break;
@@ -401,73 +401,11 @@ function convertToCoreMessages(messages, options) {
401
401
  processBlock2();
402
402
  break;
403
403
  }
404
- const toolInvocations = message.toolInvocations;
405
- if (toolInvocations == null || toolInvocations.length === 0) {
406
- coreMessages.push({ role: "assistant", content });
407
- break;
408
- }
409
- const maxStep = toolInvocations.reduce((max, toolInvocation) => {
410
- var _a8;
411
- return Math.max(max, (_a8 = toolInvocation.step) != null ? _a8 : 0);
412
- }, 0);
413
- for (let i2 = 0; i2 <= maxStep; i2++) {
414
- const stepInvocations = toolInvocations.filter(
415
- (toolInvocation) => {
416
- var _a8;
417
- return ((_a8 = toolInvocation.step) != null ? _a8 : 0) === i2;
418
- }
419
- );
420
- if (stepInvocations.length === 0) {
421
- continue;
422
- }
423
- coreMessages.push({
424
- role: "assistant",
425
- content: [
426
- ...isLastMessage && content && i2 === 0 ? [{ type: "text", text: content }] : [],
427
- ...stepInvocations.map(
428
- ({ toolCallId, toolName, args }) => ({
429
- type: "tool-call",
430
- toolCallId,
431
- toolName,
432
- args
433
- })
434
- )
435
- ]
436
- });
437
- coreMessages.push({
438
- role: "tool",
439
- content: stepInvocations.map((toolInvocation) => {
440
- if (!("result" in toolInvocation)) {
441
- throw new MessageConversionError({
442
- originalMessage: message,
443
- message: "ToolInvocation must have a result: " + JSON.stringify(toolInvocation)
444
- });
445
- }
446
- const { toolCallId, toolName, result } = toolInvocation;
447
- const tool = tools[toolName];
448
- return (tool == null ? void 0 : tool.experimental_toToolResultContent) != null ? {
449
- type: "tool-result",
450
- toolCallId,
451
- toolName,
452
- result: tool.experimental_toToolResultContent(result),
453
- experimental_content: tool.experimental_toToolResultContent(result)
454
- } : {
455
- type: "tool-result",
456
- toolCallId,
457
- toolName,
458
- result
459
- };
460
- })
461
- });
462
- }
463
404
  if (content && !isLastMessage) {
464
405
  coreMessages.push({ role: "assistant", content });
465
406
  }
466
407
  break;
467
408
  }
468
- case "data": {
469
- break;
470
- }
471
409
  default: {
472
410
  const _exhaustiveCheck = role;
473
411
  throw new MessageConversionError({