import { Type, type Static } from "@sinclair/typebox"; function stringEnum( values: T, options: { description?: string; default?: T[number] } = {}, ) { return Type.Unsafe({ type: "string", enum: [...values], ...options }); } const ACTION_VALUES = ["get", "list", "recent"] as const; const SORT_VALUES = ["ByCreateTimeAsc", "ByCreateTimeDesc"] as const; export const QiaoqiaoMessageSchema = Type.Object({ action: stringEnum(ACTION_VALUES, { description: "Action to perform: get (single message), list (messages in one chat), recent (latest messages across chats).", }), message_id: Type.Optional( Type.String({ description: "Qiaoqiao message ID (e.g. om_xxx). Required for action=get.", }), ), chat_id: Type.Optional( Type.String({ description: "Chat or peer identifier used by the agent message API. Supports internal user ID or qiaoqiaoId. Omit to use the current conversation context when available.", }), ), page_size: Type.Optional( Type.Integer({ description: "Number of messages to fetch for action=list (default: 10, max: 50).", minimum: 1, maximum: 50, default: 10, }), ), limit: Type.Optional( Type.Integer({ description: "Number of messages to fetch for action=recent (default: 50, max: 100).", minimum: 1, maximum: 100, default: 50, }), ), sort_type: Type.Optional( stringEnum(SORT_VALUES, { description: "Sort order for action=list. Default: ByCreateTimeDesc (newest first).", default: "ByCreateTimeDesc", }), ), start_time: Type.Optional( Type.String({ description: "Start of time range for action=list. Supports ISO datetime or Unix timestamp.", }), ), end_time: Type.Optional( Type.String({ description: "End of time range for action=list. Supports ISO datetime or Unix timestamp.", }), ), }); export type QiaoqiaoMessageParams = Static;