import { z } from 'zod' const schema = z.object({ /** 指定作家;不传则使用章节已指派的作家 */ writerAgentId: z.string().nullable().optional(), /** 修改意见 */ feedback: z.string().optional(), /** true:在当前版本基础上按意见修改;false:重新写一版 */ revise: z.boolean().optional() }) export default defineEventHandler(async (event) => { const chapter = getChapter(param(event)) const body = await readJson(event, schema) if (body.revise && !chapter.activeVersionId) throw createError({ statusCode: 400, message: '本章还没有可修改的版本' }) runExclusive(chapter.projectId, `第${chapter.index}章写作`, signal => writeChapter(chapter.projectId, chapter.id, signal, body)) return { started: true } })