import * as z from "zod"; import { Id } from "./ids.js"; import { MediaJobStatusSchema, MediaOperationSchema, MediaOutputSchema } from "./media.js"; /** Operations a user starts from a media card (export, transcribe, edit); generation goes through a bot. */ export const MediaCardOperationSchema = z.enum(["edit_image", "export_video", "transcribe"]); export type MediaCardOperation = z.infer; export const MediaJobStartInputSchema = z .object({ /** The conversation, like other thread procedures: a bot chat or a group. */ botId: Id.optional(), groupId: Id.optional(), /** The message the action came from; its bot posts the new card. */ messageId: Id, operation: MediaCardOperationSchema, /** The operation's input; validated by the operation. */ input: z.record(z.string(), z.unknown()), }) .refine((input) => Boolean(input.botId) !== Boolean(input.groupId), { message: "Pass botId or groupId", }); export type MediaJobStartInput = z.infer; export const MediaJobSnapshotSchema = z.object({ id: Id, operation: MediaOperationSchema, status: MediaJobStatusSchema, title: z.string(), progress: z.number().min(0).max(1).nullable(), error: z.string().nullable(), outputs: z.array(MediaOutputSchema), }); export type MediaJobSnapshotDto = z.infer; export const MediaJobStartOutputSchema = z.object({ jobId: Id, messageId: Id }); /** Which media operations the actor's space can run now, so cards offer only those. */ export const MediaCapabilitiesSchema = z.record(MediaOperationSchema, z.boolean());