ai 5.0.0-canary.14 → 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.
@@ -277,7 +277,7 @@ function convertToCoreMessages(messages, options) {
277
277
  case "reasoning": {
278
278
  content2.push({
279
279
  type: "reasoning",
280
- text: part.reasoning,
280
+ text: part.text,
281
281
  providerOptions: part.providerMetadata
282
282
  });
283
283
  break;
@@ -367,73 +367,11 @@ function convertToCoreMessages(messages, options) {
367
367
  processBlock2();
368
368
  break;
369
369
  }
370
- const toolInvocations = message.toolInvocations;
371
- if (toolInvocations == null || toolInvocations.length === 0) {
372
- coreMessages.push({ role: "assistant", content });
373
- break;
374
- }
375
- const maxStep = toolInvocations.reduce((max, toolInvocation) => {
376
- var _a8;
377
- return Math.max(max, (_a8 = toolInvocation.step) != null ? _a8 : 0);
378
- }, 0);
379
- for (let i2 = 0; i2 <= maxStep; i2++) {
380
- const stepInvocations = toolInvocations.filter(
381
- (toolInvocation) => {
382
- var _a8;
383
- return ((_a8 = toolInvocation.step) != null ? _a8 : 0) === i2;
384
- }
385
- );
386
- if (stepInvocations.length === 0) {
387
- continue;
388
- }
389
- coreMessages.push({
390
- role: "assistant",
391
- content: [
392
- ...isLastMessage && content && i2 === 0 ? [{ type: "text", text: content }] : [],
393
- ...stepInvocations.map(
394
- ({ toolCallId, toolName, args }) => ({
395
- type: "tool-call",
396
- toolCallId,
397
- toolName,
398
- args
399
- })
400
- )
401
- ]
402
- });
403
- coreMessages.push({
404
- role: "tool",
405
- content: stepInvocations.map((toolInvocation) => {
406
- if (!("result" in toolInvocation)) {
407
- throw new MessageConversionError({
408
- originalMessage: message,
409
- message: "ToolInvocation must have a result: " + JSON.stringify(toolInvocation)
410
- });
411
- }
412
- const { toolCallId, toolName, result } = toolInvocation;
413
- const tool = tools[toolName];
414
- return (tool == null ? void 0 : tool.experimental_toToolResultContent) != null ? {
415
- type: "tool-result",
416
- toolCallId,
417
- toolName,
418
- result: tool.experimental_toToolResultContent(result),
419
- experimental_content: tool.experimental_toToolResultContent(result)
420
- } : {
421
- type: "tool-result",
422
- toolCallId,
423
- toolName,
424
- result
425
- };
426
- })
427
- });
428
- }
429
370
  if (content && !isLastMessage) {
430
371
  coreMessages.push({ role: "assistant", content });
431
372
  }
432
373
  break;
433
374
  }
434
- case "data": {
435
- break;
436
- }
437
375
  default: {
438
376
  const _exhaustiveCheck = role;
439
377
  throw new MessageConversionError({
@@ -684,7 +622,11 @@ async function standardizePrompt({
684
622
  }
685
623
 
686
624
  // core/util/index.ts
687
- import { generateId } from "@ai-sdk/provider-utils";
625
+ import {
626
+ generateId,
627
+ jsonSchema,
628
+ asSchema
629
+ } from "@ai-sdk/provider-utils";
688
630
 
689
631
  // core/util/data-stream-parts.ts
690
632
  var textStreamPart = {
@@ -942,53 +884,6 @@ function formatDataStreamPart(type, value) {
942
884
  `;
943
885
  }
944
886
 
945
- // core/util/schema.ts
946
- import { validatorSymbol } from "@ai-sdk/provider-utils";
947
-
948
- // core/util/zod-schema.ts
949
- import zodToJsonSchema from "zod-to-json-schema";
950
- function zodSchema(zodSchema2, options) {
951
- var _a7;
952
- const useReferences = (_a7 = options == null ? void 0 : options.useReferences) != null ? _a7 : false;
953
- return jsonSchema(
954
- zodToJsonSchema(zodSchema2, {
955
- $refStrategy: useReferences ? "root" : "none",
956
- target: "jsonSchema7"
957
- // note: openai mode breaks various gemini conversions
958
- }),
959
- {
960
- validate: (value) => {
961
- const result = zodSchema2.safeParse(value);
962
- return result.success ? { success: true, value: result.data } : { success: false, error: result.error };
963
- }
964
- }
965
- );
966
- }
967
-
968
- // core/util/schema.ts
969
- var schemaSymbol = Symbol.for("vercel.ai.schema");
970
- function jsonSchema(jsonSchema2, {
971
- validate
972
- } = {}) {
973
- return {
974
- [schemaSymbol]: true,
975
- _type: void 0,
976
- // should never be used directly
977
- [validatorSymbol]: true,
978
- jsonSchema: jsonSchema2,
979
- validate
980
- };
981
- }
982
- function isSchema(value) {
983
- return typeof value === "object" && value !== null && schemaSymbol in value && value[schemaSymbol] === true && "jsonSchema" in value && "validate" in value;
984
- }
985
- function asSchema(schema) {
986
- return schema == null ? jsonSchema({
987
- properties: {},
988
- additionalProperties: false
989
- }) : isSchema(schema) ? schema : zodSchema(schema);
990
- }
991
-
992
887
  // core/util/is-non-empty-object.ts
993
888
  function isNonEmptyObject(object) {
994
889
  return object != null && Object.keys(object).length > 0;