@waterwx/dsh-novel-forge 2.1.5 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -9
- package/lib/client.js +3825 -2159
- package/lib/index.js +1935 -1300
- package/lib/types/assistant.d.ts +1 -1
- package/lib/types/client/api.d.ts +3 -1
- package/lib/types/client/llmLive.d.ts +7 -2
- package/lib/types/client/locales.d.ts +1 -0
- package/lib/types/client/panel/AuthorInbox.d.ts +23 -0
- package/lib/types/client/panel/CabinetSnapshot.d.ts +16 -0
- package/lib/types/client/panel/ChapterPlanPanel.d.ts +24 -0
- package/lib/types/client/panel/ConfirmDialog.d.ts +2 -0
- package/lib/types/client/panel/HomeHero.d.ts +60 -0
- package/lib/types/client/panel/ReviewIssueCard.d.ts +24 -0
- package/lib/types/client/panel/RunPanel.d.ts +3 -1
- package/lib/types/client/panel/Skeleton.d.ts +6 -0
- package/lib/types/client/panel/helpers.d.ts +12 -0
- package/lib/types/engine.d.ts +31 -14
- package/lib/types/llm-live.d.ts +2 -2
- package/lib/types/llm-retry.d.ts +11 -0
- package/lib/types/prompt-cache.d.ts +43 -0
- package/lib/types/prompts/adapt.d.ts +21 -0
- package/lib/types/prompts/audit.d.ts +15 -0
- package/lib/types/prompts/bible.d.ts +10 -0
- package/lib/types/prompts/catalog.d.ts +40 -0
- package/lib/types/prompts/characters.d.ts +19 -0
- package/lib/types/prompts/common.d.ts +9 -0
- package/lib/types/prompts/digest.d.ts +27 -0
- package/lib/types/prompts/facts.d.ts +26 -0
- package/lib/types/prompts/foreshadow.d.ts +10 -0
- package/lib/types/prompts/market.d.ts +18 -0
- package/lib/types/prompts/outline.d.ts +25 -0
- package/lib/types/prompts/plan.d.ts +22 -0
- package/lib/types/prompts/plotlines.d.ts +21 -0
- package/lib/types/prompts/polish.d.ts +22 -0
- package/lib/types/prompts/review.d.ts +30 -0
- package/lib/types/prompts/world.d.ts +13 -0
- package/lib/types/prompts/writing.d.ts +29 -0
- package/lib/types/protocol.d.ts +53 -2
- package/lib/types/routes.d.ts +6 -0
- package/lib/types/run-selection.d.ts +5 -2
- package/lib/types/stream-fallback.d.ts +8 -0
- package/package.json +2 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 章节记忆域:摘要 + 事实 + 时间线的抽取提示词。
|
|
3
|
+
*
|
|
4
|
+
* 三者的输入是同一份章节正文(合并调用的理由见 engine 侧注释);
|
|
5
|
+
* 提示词同域放一处,改口径时五份一起看,避免「摘要说 3-6 条、事实说 3-8 条」漂移。
|
|
6
|
+
*
|
|
7
|
+
* 本文件同时是提示词注册表的域模块之一(见 catalog.ts)。
|
|
8
|
+
*/
|
|
9
|
+
import type { PromptEntry } from './catalog.ts';
|
|
10
|
+
/** 摘要 + 事实(两件事一次出)。 */
|
|
11
|
+
export declare function summaryFactsSystemPrompt(): string;
|
|
12
|
+
/**
|
|
13
|
+
* 摘要 + 事实 + 时间线(三件事一次出)。
|
|
14
|
+
*
|
|
15
|
+
* @param wantTimeline - 关闭时间线时连 timeline 字段都不问,省掉输出 token
|
|
16
|
+
* 与模型的无用工作量。
|
|
17
|
+
*/
|
|
18
|
+
export declare function summaryFactsTimelineSystemPrompt(wantTimeline: boolean): string;
|
|
19
|
+
/** 事实抽取:本章正文 → 已确立事实(每行一条,3-6 条)。 */
|
|
20
|
+
export declare function extractFactsSystemPrompt(): string;
|
|
21
|
+
/** 时间线抽取:一章正文 → 故事时间线事件(时间/地点/在场角色/事件)。 */
|
|
22
|
+
export declare function timelineExtractSystemPrompt(): string;
|
|
23
|
+
/** 时间线复核:规则初筛之外,让模型找时序矛盾(时间倒流/瞬移/跨度不合理/季节错位)。 */
|
|
24
|
+
export declare function timelineReviewSystemPrompt(): string;
|
|
25
|
+
/** 本域提示词登记(注册表消费)。 */
|
|
26
|
+
export declare const entries: PromptEntry[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 伏笔(暗线)域:从大纲与已写信息建议值得埋设的伏笔。
|
|
3
|
+
*
|
|
4
|
+
* 本文件同时是提示词注册表的域模块之一(见 catalog.ts)。
|
|
5
|
+
*/
|
|
6
|
+
import type { PromptEntry } from './catalog.ts';
|
|
7
|
+
/** System prompt for foreshadow suggestions. */
|
|
8
|
+
export declare function foreshadowSystemPrompt(): string;
|
|
9
|
+
/** 本域提示词登记(注册表消费)。 */
|
|
10
|
+
export declare const entries: PromptEntry[];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 市场域:题材雷达(榜单信号 → 生产底座)、雷达灵感、作品简介。
|
|
3
|
+
*
|
|
4
|
+
* 三份提示词共享同一条纪律:**严禁复用榜单作品的人名/专有设定/简介句子/
|
|
5
|
+
* 完整书名**,只能提炼读者需求、爽点机制与结构机会——市场雷达是拿来
|
|
6
|
+
* 找方向的,不是拿来抄的。
|
|
7
|
+
*
|
|
8
|
+
* 本文件同时是提示词注册表的域模块之一(见 catalog.ts)。
|
|
9
|
+
*/
|
|
10
|
+
import type { PromptEntry } from './catalog.ts';
|
|
11
|
+
/** 市场雷达系统提示(分析师角色与输出纪律)。 */
|
|
12
|
+
export declare function marketRadarSystemPrompt(): string;
|
|
13
|
+
/** 雷达→灵感:基于市场信号/生产底座/创意简报,生成贴合市场的开书灵感。 */
|
|
14
|
+
export declare function marketIdeaInspirationSystemPrompt(): string;
|
|
15
|
+
/** 作品简介:面向读者的门面(卖点 + 开局钩子,不剧透)。 */
|
|
16
|
+
export declare function blurbSystemPrompt(): string;
|
|
17
|
+
/** 本域提示词登记(注册表消费)。 */
|
|
18
|
+
export declare const entries: PromptEntry[];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 开书与大纲域:创意灵感、大纲方案生成、反推总纲(两个来源)。
|
|
3
|
+
*
|
|
4
|
+
* 「反推大纲」与「大纲方案」方向相反(已写→总纲 vs 想法→方案),但同属
|
|
5
|
+
* 大纲资产的生产与再生产,放同一域。
|
|
6
|
+
*
|
|
7
|
+
* 本文件同时是提示词注册表的域模块之一(见 catalog.ts)。
|
|
8
|
+
*/
|
|
9
|
+
import type { PromptEntry } from './catalog.ts';
|
|
10
|
+
/** 创意灵感:一句话/题材 → 多方向开书灵感。 */
|
|
11
|
+
export declare function ideaInspirationSystemPrompt(): string;
|
|
12
|
+
/**
|
|
13
|
+
* 大纲方案:作者的一句「想法」→ 2-3 个方向差异明显的完整大纲。
|
|
14
|
+
*
|
|
15
|
+
* @param n - 本次要输出的方案数(1-3)。
|
|
16
|
+
*/
|
|
17
|
+
export declare function outlineCandidatesSystemPrompt(n: number): string;
|
|
18
|
+
/** 反推大纲 · 阶段一:分批为每章输出一行「事件摘要」。 */
|
|
19
|
+
export declare function reverseOutlineBatchSystemPrompt(): string;
|
|
20
|
+
/** 反推大纲 · 阶段二:各章事件摘要 → 全书总纲(Markdown)。 */
|
|
21
|
+
export declare function reverseOutlineSystemPrompt(): string;
|
|
22
|
+
/** 反推大纲 · 改编线:从拆章节选反推总纲,作为改编与续写的骨架。 */
|
|
23
|
+
export declare function reverseOutlineFromAdaptationSystemPrompt(): string;
|
|
24
|
+
/** 本域提示词登记(注册表消费)。 */
|
|
25
|
+
export declare const entries: PromptEntry[];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 规划域:分卷规划、章节规划(含续写后缀)、自动导演编排。
|
|
3
|
+
*
|
|
4
|
+
* 本文件同时是提示词注册表的域模块之一(见 catalog.ts)。
|
|
5
|
+
*/
|
|
6
|
+
import type { Volume } from '../protocol.ts';
|
|
7
|
+
import type { PromptEntry } from './catalog.ts';
|
|
8
|
+
/** System prompt for volume planning. */
|
|
9
|
+
export declare function volumeSystemPrompt(): string;
|
|
10
|
+
/** The chapter-planning prompt template. */
|
|
11
|
+
export declare function planSystemPrompt(volumes: Volume[] | undefined): string;
|
|
12
|
+
/**
|
|
13
|
+
* 续写规划的附加要求(拼在 planSystemPrompt 之后)。
|
|
14
|
+
*
|
|
15
|
+
* 与 user 侧的「续写硬性要求」分工:这里管**标题与接续的唯一性**,
|
|
16
|
+
* user 侧管「已发生事件不得重写」与全书进度感知。
|
|
17
|
+
*/
|
|
18
|
+
export declare function planContinuationSuffix(): string;
|
|
19
|
+
/** 自动导演:整本编排/节奏/风险/再平衡建议(不输出正文)。 */
|
|
20
|
+
export declare function directorSystemPrompt(): string;
|
|
21
|
+
/** 本域提示词登记(注册表消费)。 */
|
|
22
|
+
export declare const entries: PromptEntry[];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 剧情线域:建议提炼、进度刷新(批量)、健康检查、下一阶段方案。
|
|
3
|
+
*
|
|
4
|
+
* 本文件同时是提示词注册表的域模块之一(见 catalog.ts)。
|
|
5
|
+
*/
|
|
6
|
+
import type { PromptEntry } from './catalog.ts';
|
|
7
|
+
/** 建议剧情线:基于大纲/卷计划/已写章节/编年录,提炼候选线。 */
|
|
8
|
+
export declare function suggestPlotlinesSystemPrompt(): string;
|
|
9
|
+
/**
|
|
10
|
+
* 剧情线进度刷新(批量)。
|
|
11
|
+
*
|
|
12
|
+
* @param count - 本次要判断的线数。单条时问单线进度,多条时要求逐条判断、
|
|
13
|
+
* name 与输入逐字相同(用于对齐回写,见 plotline-align.ts)。
|
|
14
|
+
*/
|
|
15
|
+
export declare function refreshPlotlinesSystemPrompt(count: number): string;
|
|
16
|
+
/** 剧情健康检查:基于已写章节数/各线状态/编年录,判断是否需要新线及添加时机。 */
|
|
17
|
+
export declare function plotlineHealthSystemPrompt(): string;
|
|
18
|
+
/** 剧情方案:基于健康检查结果设计下一阶段方向与建议新线。 */
|
|
19
|
+
export declare function plotlinePlanSystemPrompt(): string;
|
|
20
|
+
/** 本域提示词登记(注册表消费)。 */
|
|
21
|
+
export declare const entries: PromptEntry[];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 润色域:整章去 AI 味润色、局部段落修订。
|
|
3
|
+
*
|
|
4
|
+
* 两者都按分层组装:润色口径与合规红线排最前(永不变),本书红线与写法
|
|
5
|
+
* 资产排后面(只随作者编辑变)——见 prompt-cache.ts。
|
|
6
|
+
*
|
|
7
|
+
* 本文件同时是提示词注册表的域模块之一(见 catalog.ts)。
|
|
8
|
+
*/
|
|
9
|
+
import type { ProjectState } from '../protocol.ts';
|
|
10
|
+
import type { PromptEntry } from './catalog.ts';
|
|
11
|
+
/** The de-AI-ify polish system prompt (with project writing assets injected). */
|
|
12
|
+
export declare function polishSystemPrompt(project: ProjectState): string;
|
|
13
|
+
/**
|
|
14
|
+
* 局部修订(只改一个自然段)的系统提示。
|
|
15
|
+
*
|
|
16
|
+
* 与整章修订的区别:不套用字数区间、不注入全书资料(大纲/资产/时间线),
|
|
17
|
+
* 只带合规红线、本书红线、反 AI 套话口径与角色卡——局部改写要的是「表达
|
|
18
|
+
* 卫生」,不是重新生成。同样按分层组装(约束口径排最前)。
|
|
19
|
+
*/
|
|
20
|
+
export declare function localRevisionSystemPrompt(project: ProjectState): string;
|
|
21
|
+
/** 本域提示词登记(注册表消费)。 */
|
|
22
|
+
export declare const entries: PromptEntry[];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 审稿域:章节审稿(九维)、修订验证、作者复盘、验证模式道藏注入。
|
|
3
|
+
*
|
|
4
|
+
* 审稿是逐章连打的动作,固定层(审稿口径 + 合规红线)排最前、本书层
|
|
5
|
+
* (道藏/资产)排后面——前缀稳定才有机会命中厂商输入缓存(见 prompt-cache.ts)。
|
|
6
|
+
*
|
|
7
|
+
* 本文件同时是提示词注册表的域模块之一(见 catalog.ts)。
|
|
8
|
+
*/
|
|
9
|
+
import type { ProjectState } from '../protocol.ts';
|
|
10
|
+
import type { PromptEntry } from './catalog.ts';
|
|
11
|
+
/** The review system prompt. */
|
|
12
|
+
export declare function reviewSystemPrompt(project: ProjectState): string;
|
|
13
|
+
/** 验证模式系统提示:修订后逐条核对原意见是否解决,只挑新增 high,不重复挑剔主观项。 */
|
|
14
|
+
export declare function verifySystemPrompt(project: ProjectState): string;
|
|
15
|
+
/**
|
|
16
|
+
* 验证模式下注入道藏。
|
|
17
|
+
*
|
|
18
|
+
* 原实现是 `JSON.stringify(project.bible).slice(0, 3000)`——有两个问题:
|
|
19
|
+
* 1. **腰斩的 JSON 不是 JSON**:`slice` 从中间切断,审稿员会看到语法残缺的
|
|
20
|
+
* 对象(字符串没闭合、数组没结尾),既浪费 token 又可能误读设定。
|
|
21
|
+
* 2. **静默截断设定**:世界规则/角色卡排在后面的字段最先被切掉,而那恰恰是
|
|
22
|
+
* 核对设定冲突最需要的部分。
|
|
23
|
+
*
|
|
24
|
+
* 改为结构化渲染 + 按「世界规则/角色/红线」分配独立预算。
|
|
25
|
+
*/
|
|
26
|
+
export declare function renderBibleForVerify(project: ProjectState): string;
|
|
27
|
+
/** Build the author-review system prompt (narrative structure, not prose). */
|
|
28
|
+
export declare function authorReviewSystemPrompt(): string;
|
|
29
|
+
/** 本域提示词登记(注册表消费)。 */
|
|
30
|
+
export declare const entries: PromptEntry[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 大世界域:结构化设定(境界体系/地理区域/势力分布)的渲染与提炼。
|
|
3
|
+
*
|
|
4
|
+
* 本文件同时是提示词注册表的域模块之一(见 catalog.ts)。
|
|
5
|
+
*/
|
|
6
|
+
import type { WorldState } from '../protocol.ts';
|
|
7
|
+
import type { PromptEntry } from './catalog.ts';
|
|
8
|
+
/** 把大世界结构化数据渲染成提示词块(境界体系按顺序强约束)。 */
|
|
9
|
+
export declare function renderWorld(world: WorldState | undefined): string;
|
|
10
|
+
/** 大世界提炼:从大纲 + 道藏生成结构化境界体系/区域/势力。 */
|
|
11
|
+
export declare function extractWorldSystemPrompt(): string;
|
|
12
|
+
/** 本域提示词登记(注册表消费)。 */
|
|
13
|
+
export declare const entries: PromptEntry[];
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 写作域:正文生成、整章修订、续写补齐的系统提示。
|
|
3
|
+
*
|
|
4
|
+
* ## 分层组装(缓存命中的纪律)
|
|
5
|
+
*
|
|
6
|
+
* 同一本书的连续多次调用里,输入的大部分是重复的,但各块的变化频率差着量级:
|
|
7
|
+
* 固定层(写作硬性要求 + 合规红线)永不变;本书层(道藏/世界/大纲/资产/槽位)
|
|
8
|
+
* 只随作者编辑变;本章层(伏笔/剧情线/骨架/时间线/张力)随创作进度逐章变。
|
|
9
|
+
* 厂商的输入缓存按**前缀**命中——顺序写死在 prompt-cache.ts,调用方只标层。
|
|
10
|
+
*
|
|
11
|
+
* 本文件同时是提示词注册表的域模块之一(见 catalog.ts)。
|
|
12
|
+
*/
|
|
13
|
+
import type { ProjectState } from '../protocol.ts';
|
|
14
|
+
import type { PromptEntry } from './catalog.ts';
|
|
15
|
+
/** Build the writing system prompt (bible + outline + active foreshadows).
|
|
16
|
+
* `targetChars` 来自每章计划(规划时快照,= 设置的每章目标字数);无则退回默认 3500。
|
|
17
|
+
* 字数区间按目标动态生成(±15%,取整到百位),避免系统提示词与设置互相冲突。
|
|
18
|
+
* `lengthRule` 可覆盖第 1 条字数要求(整章修订/改编时按原文长度为准)。 */
|
|
19
|
+
export declare function writeSystemPrompt(project: ProjectState, targetChars?: number, lengthRule?: string, beforeChapter?: number): string;
|
|
20
|
+
/** Build the rewrite system prompt (fix review issues / instructions). */
|
|
21
|
+
export declare function rewriteSystemPrompt(project: ProjectState, targetChars?: number, beforeChapter?: number): string;
|
|
22
|
+
/**
|
|
23
|
+
* 正文续写补齐的附加要求(拼在 writeSystemPrompt 之后)。
|
|
24
|
+
*
|
|
25
|
+
* 触发场景:生成的正文不足目标字数 90% 时,最多补两轮。
|
|
26
|
+
*/
|
|
27
|
+
export declare function bodyContinuationSuffix(): string;
|
|
28
|
+
/** 本域提示词登记(注册表消费)。 */
|
|
29
|
+
export declare const entries: PromptEntry[];
|
package/lib/types/protocol.d.ts
CHANGED
|
@@ -59,6 +59,8 @@ export declare const NOVEL_API: {
|
|
|
59
59
|
readonly chapterCheck: "/api/dsh-novel-forge/chapter/check";
|
|
60
60
|
/** 保存手动编辑的正文(自动备份 .bak)。 */
|
|
61
61
|
readonly chapterSave: "/api/dsh-novel-forge/chapter/save";
|
|
62
|
+
/** 补写本章计划的固定六项(目标 / 必达 / 保持 / 硬事实 / 结尾钩子 / 剧情要点)。 */
|
|
63
|
+
readonly chapterPlan: "/api/dsh-novel-forge/chapter/plan";
|
|
62
64
|
readonly assistant: "/api/dsh-novel-forge/assistant";
|
|
63
65
|
readonly assistantHistory: "/api/dsh-novel-forge/assistant-history";
|
|
64
66
|
/** 清空助手对话记录。 */
|
|
@@ -298,6 +300,8 @@ export interface ChapterPlan {
|
|
|
298
300
|
error?: string;
|
|
299
301
|
/** Output file name once generated (relative to the output dir). */
|
|
300
302
|
file?: string;
|
|
303
|
+
/** 正文写盘时间(文件 mtime,ISO)。**派生字段**:只在 /status 响应里出现,不落 novel-project.json。 */
|
|
304
|
+
writtenAt?: string;
|
|
301
305
|
/** LLM summary of the chapter (narrative memory for later chapters). */
|
|
302
306
|
summary?: string;
|
|
303
307
|
/** Latest review report (present once reviewed). */
|
|
@@ -814,6 +818,8 @@ export interface Plotline {
|
|
|
814
818
|
goal: string;
|
|
815
819
|
/** 当前进度说明(最近推进到哪)。 */
|
|
816
820
|
progress: string;
|
|
821
|
+
/** 下一目标(这条线接下来要推进到哪;作者填写,缺省表示未设定)。 */
|
|
822
|
+
nextGoal?: string;
|
|
817
823
|
/** 生命周期状态。 */
|
|
818
824
|
status: 'active' | 'paused' | 'resolved' | 'abandoned';
|
|
819
825
|
/** 关联章节号(推进/落地的章节)。 */
|
|
@@ -1057,6 +1063,40 @@ export interface ChapterSaveResponse {
|
|
|
1057
1063
|
/** 落盘的审稿报告(沿用工作区报告或保存后自动审稿)。 */
|
|
1058
1064
|
report?: ReviewReport;
|
|
1059
1065
|
}
|
|
1066
|
+
/**
|
|
1067
|
+
* POST /chapter/plan 请求:作者补写本章计划的固定六项。
|
|
1068
|
+
*
|
|
1069
|
+
* 只覆盖**传入**的字段(缺省 = 保持原值),传空串 / 空数组表示清空该项。
|
|
1070
|
+
* 这些字段原本只由规划步骤产出,作者没有入口修——但它们是生成与审稿的锚点,
|
|
1071
|
+
* AI 排偏了就必须能人工纠正,所以开放这一条最小写入路径。
|
|
1072
|
+
*/
|
|
1073
|
+
export interface ChapterPlanPatchRequest {
|
|
1074
|
+
chapterNo: number;
|
|
1075
|
+
patch: {
|
|
1076
|
+
/** 本章目标 / 义务合约(≤200 字)。 */
|
|
1077
|
+
obligation?: string;
|
|
1078
|
+
/** 本章必达项(≤4 条)。 */
|
|
1079
|
+
mustAdvance?: string[];
|
|
1080
|
+
/** 本章必须保持、不得破坏的项(≤4 条)。 */
|
|
1081
|
+
mustPreserve?: string[];
|
|
1082
|
+
/** 人物硬事实(≤6 条)。 */
|
|
1083
|
+
characterHardFacts?: string[];
|
|
1084
|
+
/** 结尾钩子要求(≤120 字)。 */
|
|
1085
|
+
endingHook?: string;
|
|
1086
|
+
/** 剧情要点(≤2000 字)。 */
|
|
1087
|
+
beats?: string;
|
|
1088
|
+
};
|
|
1089
|
+
}
|
|
1090
|
+
/** POST /chapter/plan 响应:回传合并后的章节计划,面板不必再拉一次全量 status。 */
|
|
1091
|
+
export interface ChapterPlanPatchResponse {
|
|
1092
|
+
ok: true;
|
|
1093
|
+
chapter: ChapterPlan;
|
|
1094
|
+
/**
|
|
1095
|
+
* 宿主按上限裁掉了什么(字数 / 条数超限)。本项目的不变量是**截断必须显式**:
|
|
1096
|
+
* 作者写了 6 条必达项只留下 4 条时,不能让他以为 6 条都生效了。
|
|
1097
|
+
*/
|
|
1098
|
+
notices?: string[];
|
|
1099
|
+
}
|
|
1060
1100
|
/** POST /cover 请求:上传或移除封面。 */
|
|
1061
1101
|
export interface CoverRequest {
|
|
1062
1102
|
action: 'upload' | 'remove';
|
|
@@ -1398,6 +1438,13 @@ export interface LlmTokenUsage {
|
|
|
1398
1438
|
/** 命中缓存的输入用量。 */
|
|
1399
1439
|
cacheReadTokens?: number;
|
|
1400
1440
|
}
|
|
1441
|
+
/**
|
|
1442
|
+
* LLM 实况阶段。`cancelled` = 作者关页面 / 主动中断,**不是模型失败**:
|
|
1443
|
+
* 既不计入用量账本的「失败」,也不触发备用模型(口径见 llm-retry.ts)。
|
|
1444
|
+
*/
|
|
1445
|
+
export type LlmLivePhase = 'requesting' | 'streaming' | 'completed' | 'failed' | 'cancelled';
|
|
1446
|
+
/** 一次调用结束时的阶段(进行中的两个阶段不会出现在这里)。 */
|
|
1447
|
+
export type LlmLiveFinalPhase = Extract<LlmLivePhase, 'completed' | 'failed' | 'cancelled'>;
|
|
1401
1448
|
/** LLM 实况帧:宿主 → 浏览器的 SSE 事件(每次调用一组 session_* 事件)。 */
|
|
1402
1449
|
export interface LlmLiveFrame {
|
|
1403
1450
|
type: 'session_started' | 'output_delta' | 'reasoning_delta' | 'phase_changed' | 'session_completed';
|
|
@@ -1420,8 +1467,8 @@ export interface LlmLiveFrame {
|
|
|
1420
1467
|
totalChars?: number;
|
|
1421
1468
|
/** reasoning 累计字符数。 */
|
|
1422
1469
|
totalReasoningChars?: number;
|
|
1423
|
-
/** phase_changed
|
|
1424
|
-
phase?:
|
|
1470
|
+
/** phase_changed / session_completed:阶段。 */
|
|
1471
|
+
phase?: LlmLivePhase;
|
|
1425
1472
|
/** phase_changed:阶段描述。 */
|
|
1426
1473
|
phaseMessage?: string;
|
|
1427
1474
|
/** session_completed:最终预览(截断)。 */
|
|
@@ -1447,6 +1494,8 @@ export interface LlmUsageBucket {
|
|
|
1447
1494
|
inputTokens: number;
|
|
1448
1495
|
outputTokens: number;
|
|
1449
1496
|
reasoningTokens: number;
|
|
1497
|
+
/** 命中缓存的输入用量(属于 inputTokens 的一部分,不额外相加)。 */
|
|
1498
|
+
cacheReadTokens?: number;
|
|
1450
1499
|
elapsedMs: number;
|
|
1451
1500
|
}
|
|
1452
1501
|
/** 本次运行(进程内,重启归零)的 LLM 用量汇总。 */
|
|
@@ -1457,6 +1506,8 @@ export interface LlmUsageSummary {
|
|
|
1457
1506
|
outputTokens: number;
|
|
1458
1507
|
reasoningTokens: number;
|
|
1459
1508
|
totalTokens: number;
|
|
1509
|
+
/** 命中缓存的输入用量(属于 inputTokens 的一部分,不额外相加)。 */
|
|
1510
|
+
cacheReadTokens?: number;
|
|
1460
1511
|
elapsedMs: number;
|
|
1461
1512
|
/** 供应商未上报 usage 的调用次数(用于说明数据为何不完整)。 */
|
|
1462
1513
|
callsWithoutUsage: number;
|
package/lib/types/routes.d.ts
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import type { WebRoute } from '@deepseek-ai/dsh-host-webserver';
|
|
11
11
|
import type { Context } from '@deepseek-ai/cordis';
|
|
12
|
+
import { ProductionRunner } from './run.ts';
|
|
12
13
|
import { type BibleResponse, type ConfigPatch, type ConfigResponse, type ExportResponse, type LoadOutlineResponse, type NovelConfig, type PlanResponse, type StatusResponse, type VolumesResponse } from './protocol.ts';
|
|
13
14
|
import { chapterFileName } from './engine.ts';
|
|
14
15
|
/** Route deps. */
|
|
@@ -24,6 +25,11 @@ export interface NovelRoutesDeps {
|
|
|
24
25
|
};
|
|
25
26
|
/** Loader entry id the settings section is addressed by (undefined when unknown). */
|
|
26
27
|
settingsNs?: string;
|
|
28
|
+
/**
|
|
29
|
+
* 生产单执行器单例。由宿主持有并跨 `makeRoutes` 重用 —— 见该字段在工厂内的说明。
|
|
30
|
+
* 测试可省略(内部自建一次性实例)。
|
|
31
|
+
*/
|
|
32
|
+
runner?: ProductionRunner;
|
|
27
33
|
}
|
|
28
34
|
/**
|
|
29
35
|
* Build every /api/dsh-novel-forge route.
|
|
@@ -41,11 +41,14 @@ export interface PickNextResult {
|
|
|
41
41
|
/**
|
|
42
42
|
* 选出生产单下一章要处理的章。
|
|
43
43
|
*
|
|
44
|
-
*
|
|
44
|
+
* 四种章:已 `approved` 快进;已列入 `pendingManual` 的快进(人工已接管);
|
|
45
|
+
* 连败达上限的熔断跳过;其余为下一章。
|
|
45
46
|
*
|
|
46
47
|
* @param chapters - 全书章节计划。
|
|
47
48
|
* @param currentNo - 当前章号(含)。
|
|
48
49
|
* @param endNo - 区间终点(含)。
|
|
49
50
|
* @param failedAttempts - 章号 → 已失败次数(来自 `RunState.failedAttempts`)。
|
|
51
|
+
* @param pendingManual - 已列入待人工的章号(来自 `RunState.pendingManual`)。
|
|
52
|
+
* 必须传入,否则重写 N 轮仍不过的章会被反复选中,每轮烧两次 rewrite + 两次 verify。
|
|
50
53
|
*/
|
|
51
|
-
export declare function pickNextChapter(chapters: ChapterPlan[], currentNo: number, endNo: number, failedAttempts: Record<string, number
|
|
54
|
+
export declare function pickNextChapter(chapters: ChapterPlan[], currentNo: number, endNo: number, failedAttempts: Record<string, number>, pendingManual?: readonly number[]): PickNextResult;
|
|
@@ -46,6 +46,14 @@ export interface StreamWithFallbackOptions {
|
|
|
46
46
|
maxTokensError: string;
|
|
47
47
|
/** 产出文本的最小长度;不足则视为失败。 */
|
|
48
48
|
minChars: number;
|
|
49
|
+
/**
|
|
50
|
+
* 取消信号。客户端断开时应abort —— 宿主 SDK 约定「implementations must honor
|
|
51
|
+
* `options.signal`」,不发信号等于让 LLM 调用在后台跑完整章(maxTokens 常20000),
|
|
52
|
+
* 用户关掉页面也停不下来。
|
|
53
|
+
*
|
|
54
|
+
* 中止时本函数抛出 `AbortError`,由调用方决定是静默收尾还是回错误帧。
|
|
55
|
+
*/
|
|
56
|
+
signal?: AbortSignal;
|
|
49
57
|
}
|
|
50
58
|
/**
|
|
51
59
|
* 执行流式生成,主模型失败且「一个字都没产出」时换备用模型重试一次。
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@waterwx/dsh-novel-forge",
|
|
3
3
|
"description": "AI 编译纯文本小说工作台 for the dsh web GUI: import a novel outline (docx/text), plan volumes & chapters with LLM, generate chapter by chapter (3000-4000 chars each), auto AI review & book audit, and export the full book as Markdown/TXT into your chosen output folder.",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.3.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "waterwx",
|
|
7
7
|
"repository": {
|
|
@@ -116,6 +116,7 @@
|
|
|
116
116
|
"check:fallback": "node scripts/check-fallback-tiers.mjs",
|
|
117
117
|
"check:third-party": "node scripts/check-third-party.mjs",
|
|
118
118
|
"check:contrast": "node scripts/audit-contrast.mjs",
|
|
119
|
+
"check:classes": "node scripts/check-css-classes.mjs",
|
|
119
120
|
"check:third-party:list": "node scripts/check-third-party.mjs --list",
|
|
120
121
|
"release": "node scripts/release.mjs",
|
|
121
122
|
"release:dry": "node scripts/release.mjs --dry-run",
|