// 重置 book 43 并重新触发生成 const { PrismaClient } = require('@prisma/client'); const { langGraphGenerator } = require('./dist/modules/book-generator'); const p = new PrismaClient(); (async () => { // 1. 重置状态 const book = await p.book.update({ where: { id: 43 }, data: { genStage: 'draft', failedStage: null, errorMsg: null, progress: 0, totalChapters: 0, }, }); console.log('=== book 43 重置成功 ==='); console.log('id:', book.id, 'title:', book.title); console.log('userId:', book.userId, 'bookScale:', book.bookScale, 'description:', (book.description || '').substring(0, 80)); // 2. 触发 LangGraph 生成 console.log('\n=== 触发 LangGraph 生成 ==='); langGraphGenerator .generate( '43', book.description || book.title, book.bookScale || '1000', undefined, // genLevel 自动判断 book.userId, ) .then(() => console.log('✅ langGraphGenerator 启动成功')) .catch((err) => console.error('❌ langGraphGenerator 启动失败:', err.message)); // 不 await,让它在后台跑 console.log('已触发,等待 5 秒...'); await new Promise(r => setTimeout(r, 5000)); // 3. 看状态 const after = await p.book.findUnique({ where: { id: 43 }, select: { genStage: true, progress: true, errorMsg: true, failedStage: true, totalChapters: true }, }); console.log('\n=== 5秒后 book 43 状态 ==='); console.log(JSON.stringify(after, null, 2)); await p.$disconnect(); process.exit(0); })();