This project helps migrate UI message data from Vercel AI SDK v4 to v5.
pnpm installRuns the example converter that validates a v4 message and converts it to v5.
pnpm convertYou should see the parsed v4 object followed by the converted v5 object logged to the console.
import { convertV4MessageToV5, V5UIMessageSchema } from "./src/schema";
// v4Message: your v4 UI message object
const v5Maybe = convertV4MessageToV5(v4Message);
if (v5Maybe) {
const v5 = V5UIMessageSchema.parse(v5Maybe); // validate
// persist or use v5
}Please customize this to your need, there are areas that I skipped in the file because the fields were deprecated and did not apply to me. I included most use cases and as 1-to-1 as possible but may have forgot some. Hopefully this helps you in some way : )