3c9b65d982
- Nuxt 4 + Nuxt UI 4 + AI SDK 7 + Drizzle/SQLite - 主编规划大纲与章节简报、选派作家;作家流式写入章节文件并实时推送前端 - 逐章确认模式(默认)与自动模式;摘要与故事记忆 - 酒馆角色卡(PNG/JSON,V1-V3)与世界书导入 - 自定义最高优先级系统提示词、审稿/修改/多版本、任务日志与提示词检视 - 模拟 LLM 服务与端到端测试脚本 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
import { asc } from 'drizzle-orm'
|
|
import { z } from 'zod'
|
|
import { DEFAULT_REQUIREMENTS, DEFAULT_SETTINGS, EMPTY_MEMORY } from '#shared/types'
|
|
|
|
const schema = z.object({
|
|
title: z.string().min(1),
|
|
description: z.string().default('')
|
|
})
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
const body = await readJson(event, schema)
|
|
const db = useDb()
|
|
const id = newId()
|
|
const firstModel = db.select().from(tables.models).orderBy(asc(tables.models.createdAt)).get()
|
|
const modelId = firstModel?.id ?? null
|
|
db.transaction((tx) => {
|
|
tx.insert(tables.projects).values({
|
|
id,
|
|
title: body.title,
|
|
description: body.description,
|
|
requirements: { ...DEFAULT_REQUIREMENTS },
|
|
settings: { ...DEFAULT_SETTINGS },
|
|
memory: structuredClone(EMPTY_MEMORY)
|
|
}).run()
|
|
tx.insert(tables.agents).values([
|
|
{ id: newId(), projectId: id, role: 'editor', name: '主编', modelId },
|
|
{ id: newId(), projectId: id, role: 'summarizer', name: '摘要员', modelId },
|
|
{ id: newId(), projectId: id, role: 'writer', name: '作家·默认', modelId, styleNotes: '通用叙事' }
|
|
]).run()
|
|
})
|
|
return { id }
|
|
})
|