import type { InferUITool, UIMessage } from "ai"; import { z } from "zod"; import type { ArtifactKind } from "@/components/artifact"; import type { createDocument } from "./ai/tools/create-document"; import type { getWeather } from "./ai/tools/get-weather"; import type { requestSuggestions } from "./ai/tools/request-suggestions"; import type { updateDocument } from "./ai/tools/update-document"; import type { Suggestion } from "./db/schema"; import type { AppUsage } from "./usage"; export type DataPart = { type: "append-message"; message: string }; export const messageMetadataSchema = z.object({ createdAt: z.string(), }); export type MessageMetadata = z.infer; type weatherTool = InferUITool; type createDocumentTool = InferUITool>; type updateDocumentTool = InferUITool>; type requestSuggestionsTool = InferUITool< ReturnType >; export type ChatTools = { getWeather: weatherTool; createDocument: createDocumentTool; updateDocument: updateDocumentTool; requestSuggestions: requestSuggestionsTool; }; export type CustomUIDataTypes = { textDelta: string; imageDelta: string; sheetDelta: string; codeDelta: string; suggestion: Suggestion; appendMessage: string; id: string; title: string; kind: ArtifactKind; clear: null; finish: null; usage: AppUsage; }; export type ChatMessage = UIMessage< MessageMetadata, CustomUIDataTypes, ChatTools >; export type Attachment = { name: string; url: string; contentType: string; };