@waterwx/dsh-novel-forge 0.1.0 → 1.0.0-alpha

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.
Files changed (180) hide show
  1. package/README.md +162 -111
  2. package/cordis.patch.yml +1 -1
  3. package/lib/client.js +54165 -2666
  4. package/lib/index.js +11895 -2211
  5. package/lib/types/ai-scan.d.ts +36 -0
  6. package/lib/types/assets.d.ts +19 -4
  7. package/lib/types/assistant.d.ts +6 -0
  8. package/lib/types/author-assets.d.ts +25 -0
  9. package/lib/types/bookshelf.d.ts +8 -1
  10. package/lib/types/client/api.d.ts +235 -3
  11. package/lib/types/client/index.d.ts +1 -1
  12. package/lib/types/client/llmLive.d.ts +33 -0
  13. package/lib/types/client/locales.d.ts +101 -28
  14. package/lib/types/client/panel/AdaptModeView.d.ts +5 -0
  15. package/lib/types/client/panel/AssetsTab.d.ts +6 -1
  16. package/lib/types/client/panel/AuthorAssetsView.d.ts +4 -0
  17. package/lib/types/client/panel/AuthorHome.d.ts +34 -0
  18. package/lib/types/client/panel/BookAnalysisView.d.ts +4 -0
  19. package/lib/types/client/panel/CreateBookView.d.ts +13 -0
  20. package/lib/types/client/panel/DirectorView.d.ts +7 -0
  21. package/lib/types/client/panel/FlowGuide.d.ts +22 -0
  22. package/lib/types/client/panel/GlobalAssetLibraryView.d.ts +4 -0
  23. package/lib/types/client/panel/IdeaInspirationView.d.ts +6 -0
  24. package/lib/types/client/panel/ImportModal.d.ts +7 -0
  25. package/lib/types/client/panel/KnowledgeBaseView.d.ts +4 -0
  26. package/lib/types/client/panel/LiveFeedLog.d.ts +5 -0
  27. package/lib/types/client/panel/MangaRoleLibrary.d.ts +20 -0
  28. package/lib/types/client/panel/MangaWorkspace.d.ts +12 -0
  29. package/lib/types/client/panel/MarketRadarView.d.ts +5 -0
  30. package/lib/types/client/panel/ModelManager.d.ts +14 -0
  31. package/lib/types/client/panel/ModelPicker.d.ts +11 -0
  32. package/lib/types/client/panel/NovelPanel.d.ts +1 -1
  33. package/lib/types/client/panel/ProgressConsole.d.ts +17 -0
  34. package/lib/types/client/panel/ProgressHomeView.d.ts +5 -0
  35. package/lib/types/client/panel/PropLibrary.d.ts +8 -0
  36. package/lib/types/client/panel/ReaderView.d.ts +8 -0
  37. package/lib/types/client/panel/ReasoningSection.d.ts +10 -0
  38. package/lib/types/client/panel/RunPanel.d.ts +5 -0
  39. package/lib/types/client/panel/SceneLibrary.d.ts +16 -0
  40. package/lib/types/client/panel/SettingsView.d.ts +16 -0
  41. package/lib/types/client/panel/ShelfView.d.ts +15 -0
  42. package/lib/types/client/panel/StoryboardTab.d.ts +19 -0
  43. package/lib/types/client/panel/StyleCard.d.ts +8 -0
  44. package/lib/types/client/panel/StyleGallery.d.ts +1 -0
  45. package/lib/types/client/panel/WorldTab.d.ts +10 -0
  46. package/lib/types/client/panel/helpers.d.ts +10 -0
  47. package/lib/types/client/panel/views.d.ts +77 -0
  48. package/lib/types/client/run-status.d.ts +19 -0
  49. package/lib/types/client/text.d.ts +9 -0
  50. package/lib/types/comic-presets.d.ts +12 -0
  51. package/lib/types/engine.d.ts +250 -8
  52. package/lib/types/global-assets.d.ts +6 -0
  53. package/lib/types/index.d.ts +24 -2
  54. package/lib/types/llm-live.d.ts +44 -0
  55. package/lib/types/manga-genre-rules.d.ts +22 -0
  56. package/lib/types/market-radar-scan.d.ts +19 -0
  57. package/lib/types/market-radar-sources.d.ts +31 -0
  58. package/lib/types/novel-context.d.ts +80 -0
  59. package/lib/types/prompt-utils.d.ts +35 -0
  60. package/lib/types/prompting.d.ts +35 -0
  61. package/lib/types/protocol.d.ts +1453 -5
  62. package/lib/types/review-policy.d.ts +97 -0
  63. package/lib/types/run.d.ts +32 -0
  64. package/lib/types/shot-language.d.ts +46 -0
  65. package/lib/types/src/ai-scan.d.ts +36 -0
  66. package/lib/types/src/assets.d.ts +37 -0
  67. package/lib/types/src/assistant.d.ts +45 -0
  68. package/lib/types/src/author-assets.d.ts +25 -0
  69. package/lib/types/src/bookshelf.d.ts +42 -0
  70. package/lib/types/src/client/api.d.ts +234 -0
  71. package/lib/types/src/client/docx.d.ts +15 -0
  72. package/lib/types/src/client/index.d.ts +14 -0
  73. package/lib/types/src/client/locales.d.ts +212 -0
  74. package/lib/types/src/client/mount.d.ts +9 -0
  75. package/lib/types/src/client/panel/AdaptModeView.d.ts +5 -0
  76. package/lib/types/src/client/panel/AssetsTab.d.ts +12 -0
  77. package/lib/types/src/client/panel/AssistantTab.d.ts +7 -0
  78. package/lib/types/src/client/panel/AuthorAssetsView.d.ts +4 -0
  79. package/lib/types/src/client/panel/AuthorHome.d.ts +32 -0
  80. package/lib/types/src/client/panel/BookshelfBar.d.ts +11 -0
  81. package/lib/types/src/client/panel/CreateBookView.d.ts +9 -0
  82. package/lib/types/src/client/panel/FlowGuide.d.ts +22 -0
  83. package/lib/types/src/client/panel/GlobalAssetLibraryView.d.ts +4 -0
  84. package/lib/types/src/client/panel/ImportModal.d.ts +7 -0
  85. package/lib/types/src/client/panel/MangaRoleLibrary.d.ts +20 -0
  86. package/lib/types/src/client/panel/MangaWorkspace.d.ts +12 -0
  87. package/lib/types/src/client/panel/ModelManager.d.ts +14 -0
  88. package/lib/types/src/client/panel/NovelPanel.d.ts +13 -0
  89. package/lib/types/src/client/panel/ProgressConsole.d.ts +17 -0
  90. package/lib/types/src/client/panel/ProgressHomeView.d.ts +5 -0
  91. package/lib/types/src/client/panel/PropLibrary.d.ts +8 -0
  92. package/lib/types/src/client/panel/ReaderView.d.ts +8 -0
  93. package/lib/types/src/client/panel/ReasoningSection.d.ts +10 -0
  94. package/lib/types/src/client/panel/RunPanel.d.ts +5 -0
  95. package/lib/types/src/client/panel/SceneLibrary.d.ts +16 -0
  96. package/lib/types/src/client/panel/SettingsView.d.ts +16 -0
  97. package/lib/types/src/client/panel/ShelfView.d.ts +15 -0
  98. package/lib/types/src/client/panel/StoryboardTab.d.ts +19 -0
  99. package/lib/types/src/client/panel/StyleCard.d.ts +8 -0
  100. package/lib/types/src/client/panel/StyleGallery.d.ts +1 -0
  101. package/lib/types/src/client/panel/WorldTab.d.ts +10 -0
  102. package/lib/types/src/client/panel/controller.d.ts +19 -0
  103. package/lib/types/src/client/panel/helpers.d.ts +18 -0
  104. package/lib/types/src/client/panel/views.d.ts +77 -0
  105. package/lib/types/src/client/sidebar-entry.d.ts +13 -0
  106. package/lib/types/src/client/text.d.ts +9 -0
  107. package/lib/types/src/comic-presets.d.ts +12 -0
  108. package/lib/types/src/docx.d.ts +19 -0
  109. package/lib/types/src/engine.d.ts +402 -0
  110. package/lib/types/src/index.d.ts +79 -0
  111. package/lib/types/src/manga-genre-rules.d.ts +22 -0
  112. package/lib/types/src/novel-context.d.ts +80 -0
  113. package/lib/types/src/prompt-utils.d.ts +35 -0
  114. package/lib/types/src/protocol.d.ts +2176 -0
  115. package/lib/types/src/review-policy.d.ts +97 -0
  116. package/lib/types/src/routes.d.ts +29 -0
  117. package/lib/types/src/run.d.ts +32 -0
  118. package/lib/types/src/shot-language.d.ts +46 -0
  119. package/lib/types/src/story-beat-language.d.ts +35 -0
  120. package/lib/types/src/style-library.d.ts +33 -0
  121. package/lib/types/story-beat-language.d.ts +35 -0
  122. package/lib/types/style-library.d.ts +33 -0
  123. package/package.json +57 -42
  124. package/scripts/patch-schemastery.mjs +47 -0
  125. package/src/ai-scan.ts +179 -0
  126. package/src/assets.ts +1774 -518
  127. package/src/assistant.ts +915 -547
  128. package/src/author-assets.ts +147 -0
  129. package/src/bookshelf.ts +32 -2
  130. package/src/client/api.ts +666 -254
  131. package/src/client/index.ts +3 -1
  132. package/src/client/llmLive.ts +101 -0
  133. package/src/client/locales.ts +178 -31
  134. package/src/client/mount.tsx +1 -1
  135. package/src/client/panel/AdaptModeView.tsx +535 -0
  136. package/src/client/panel/AssetsTab.tsx +168 -51
  137. package/src/client/panel/AssistantTab.tsx +339 -188
  138. package/src/client/panel/AuthorAssetsView.tsx +208 -0
  139. package/src/client/panel/AuthorHome.tsx +234 -0
  140. package/src/client/panel/BookAnalysisView.tsx +60 -0
  141. package/src/client/panel/BookshelfBar.tsx +63 -9
  142. package/src/client/panel/CreateBookView.tsx +371 -0
  143. package/src/client/panel/DirectorView.tsx +200 -0
  144. package/src/client/panel/GlobalAssetLibraryView.tsx +172 -0
  145. package/src/client/panel/IdeaInspirationView.tsx +71 -0
  146. package/src/client/panel/ImportModal.tsx +303 -0
  147. package/src/client/panel/KnowledgeBaseView.tsx +73 -0
  148. package/src/client/panel/LiveFeedLog.tsx +67 -0
  149. package/src/client/panel/MarketRadarView.tsx +374 -0
  150. package/src/client/panel/ModelManager.tsx +205 -0
  151. package/src/client/panel/NovelPanel.tsx +4713 -990
  152. package/src/client/panel/ProgressConsole.tsx +63 -0
  153. package/src/client/panel/ProgressHomeView.tsx +87 -0
  154. package/src/client/panel/ReaderView.tsx +306 -0
  155. package/src/client/panel/ReasoningSection.tsx +31 -0
  156. package/src/client/panel/RunPanel.tsx +204 -0
  157. package/src/client/panel/SettingsView.tsx +265 -0
  158. package/src/client/panel/ShelfView.tsx +242 -0
  159. package/src/client/panel/WorldTab.tsx +202 -0
  160. package/src/client/panel/helpers.ts +50 -0
  161. package/src/client/panel/panel.module.css +4325 -526
  162. package/src/client/panel/views.tsx +346 -0
  163. package/src/client/run-status.ts +100 -0
  164. package/src/client/sidebar-entry.ts +1 -1
  165. package/src/client/text.ts +28 -0
  166. package/src/engine.ts +4230 -1019
  167. package/src/global-assets.ts +59 -0
  168. package/src/index.ts +123 -9
  169. package/src/llm-live.ts +68 -0
  170. package/src/market-radar-scan.ts +41 -0
  171. package/src/market-radar-sources.ts +173 -0
  172. package/src/novel-context.ts +287 -0
  173. package/src/prompt-utils.ts +73 -0
  174. package/src/prompting.ts +159 -0
  175. package/src/protocol.ts +1998 -539
  176. package/src/review-policy.ts +161 -0
  177. package/src/routes.ts +3277 -955
  178. package/src/run.ts +338 -0
  179. package/lib/client.js.map +0 -1
  180. package/lib/index.js.map +0 -1
package/src/protocol.ts CHANGED
@@ -1,539 +1,1998 @@
1
- /**
2
- * dsh-novel-forge — shared protocol between the host half (Node) and the
3
- * browser half (web GUI). Route paths, request/response shapes, the project
4
- * state file format, and the NDJSON generation stream frames all live here so
5
- * both halves spell exactly one vocabulary.
6
- */
7
-
8
- /** The /api/dsh-novel-forge route family (same-origin, loopback-fenced). */
9
- export const NOVEL_API = {
10
- status: '/api/dsh-novel-forge/status',
11
- loadOutline: '/api/dsh-novel-forge/load-outline',
12
- saveOutline: '/api/dsh-novel-forge/save-outline',
13
- plan: '/api/dsh-novel-forge/plan',
14
- volumes: '/api/dsh-novel-forge/volumes',
15
- bible: '/api/dsh-novel-forge/bible',
16
- assets: '/api/dsh-novel-forge/assets',
17
- styleEngine: '/api/dsh-novel-forge/style-engine',
18
- generate: '/api/dsh-novel-forge/generate',
19
- review: '/api/dsh-novel-forge/review',
20
- rewrite: '/api/dsh-novel-forge/rewrite',
21
- polish: '/api/dsh-novel-forge/polish',
22
- summary: '/api/dsh-novel-forge/summary',
23
- foreshadow: '/api/dsh-novel-forge/foreshadow',
24
- exportBook: '/api/dsh-novel-forge/export',
25
- chapter: '/api/dsh-novel-forge/chapter',
26
- assistant: '/api/dsh-novel-forge/assistant',
27
- assistantHistory: '/api/dsh-novel-forge/assistant-history',
28
- bookshelf: '/api/dsh-novel-forge/bookshelf',
29
- config: '/api/dsh-novel-forge/config',
30
- openFolder: '/api/dsh-novel-forge/open-folder',
31
- } as const
32
-
33
- /** 书架:一本书的条目。 */
34
- export interface BookEntry {
35
- /** 稳定 id。 */
36
- id: string
37
- /** 书名。 */
38
- bookName: string
39
- /** 该书输出目录(独立项目目录)。 */
40
- outputDir: string
41
- /** 创建时间。 */
42
- createdAt: string
43
- /** 最后活动时间。 */
44
- updatedAt: string
45
- }
46
-
47
- /** 书架快照(含每本书的进度摘要)。 */
48
- export interface BookshelfSnapshot {
49
- books: Array<BookEntry & { done: number; total: number; hasProject: boolean }>
50
- /** 当前激活的书 id(无则 null)。 */
51
- activeBookId: string | null
52
- }
53
-
54
- /** POST /bookshelf 请求:创建新书。 */
55
- export interface BookCreateRequest {
56
- bookName: string
57
- outputDir?: string
58
- }
59
-
60
- /** POST /bookshelf/activate 请求:切换当前书。 */
61
- export interface BookActivateRequest {
62
- id: string
63
- }
64
-
65
- /** POST /bookshelf/remove 请求:移除书架条目。 */
66
- export interface BookRemoveRequest {
67
- id: string
68
- }
69
-
70
- /** Chapter lifecycle states (the writing pipeline's state machine). */
71
- export type ChapterStatus =
72
- | 'pending' // planned, not started
73
- | 'generating' // LLM writing right now
74
- | 'written' // body on disk, awaiting review
75
- | 'reviewing' // review in progress
76
- | 'approved' // passed review (or user-approved)
77
- | 'rejected' // review found problems
78
- | 'error' // generation failed
79
-
80
- /** One chapter in the plan. */
81
- export interface ChapterPlan {
82
- /** 1-based chapter number (stable identity; files are named from it). */
83
- no: number
84
- /** Volume this chapter belongs to (1-based; 0 = unassigned). */
85
- volume: number
86
- /** Chapter title, decided by the LLM plan step. */
87
- title: string
88
- /** Story beats / plot points for this chapter (model-facing guidance). */
89
- beats: string
90
- /** Target character count (defaults to the configured chapter size). */
91
- targetChars: number
92
- /** Generation/review state. */
93
- status: ChapterStatus
94
- /** Actual character count once generated. */
95
- chars?: number
96
- /** Failure message when status is 'error'. */
97
- error?: string
98
- /** Output file name once generated (relative to the output dir). */
99
- file?: string
100
- /** LLM summary of the chapter (narrative memory for later chapters). */
101
- summary?: string
102
- /** Latest review report (present once reviewed). */
103
- review?: ReviewReport
104
- }
105
-
106
- /** One review finding. */
107
- export interface ReviewIssue {
108
- /** Severity: high = must fix, medium = should fix, low = suggestion. */
109
- severity: 'high' | 'medium' | 'low'
110
- /** What the problem is. */
111
- item: string
112
- /** Concrete suggestion for fixing it. */
113
- suggestion: string
114
- }
115
-
116
- /** AI review report for one chapter. */
117
- export interface ReviewReport {
118
- /** Overall score 0-100. */
119
- score: number
120
- /** Pass threshold (config; 70 default). */
121
- passed: boolean
122
- /** One-line verdict. */
123
- verdict: string
124
- /** Individual findings. */
125
- issues: ReviewIssue[]
126
- /** When the review ran. */
127
- reviewedAt: string
128
- }
129
-
130
- /** A volume of the book. */
131
- export interface Volume {
132
- /** 1-based volume number. */
133
- no: number
134
- /** Volume title. */
135
- title: string
136
- /** Volume positioning / summary. */
137
- summary: string
138
- /** First chapter number of this volume. */
139
- chapterStart: number
140
- /** Last chapter number (inclusive). */
141
- chapterEnd: number
142
- }
143
-
144
- /** A character card from the story bible. */
145
- export interface CharacterCard {
146
- name: string
147
- role: 'protagonist' | 'supporting' | 'antagonist' | 'other'
148
- /** Personality / traits (short lines). */
149
- traits: string[]
150
- /** Goals and motivations. */
151
- goals: string
152
- /** Key relations to other characters. */
153
- relations: string
154
- }
155
-
156
- /** The structured story bible (worldbuilding extracted from the outline). */
157
- export interface StoryBible {
158
- /** Genre + tone tags. */
159
- genre: string
160
- /** Worldbuilding rules (power system, geography, factions...). */
161
- worldRules: string[]
162
- /** Character cards. */
163
- characters: CharacterCard[]
164
- /** Writing red lines (forbidden content / must-avoid tropes). */
165
- redLines: string[]
166
- /** Style guidance (pacing, pov, tone). */
167
- style: string[]
168
- /** When the bible was generated. */
169
- generatedAt?: string
170
- }
171
-
172
- /** A planted/active/resolved foreshadowing thread. */
173
- export interface Foreshadow {
174
- /** Stable id. */
175
- id: string
176
- /** What the foreshadow is. */
177
- description: string
178
- /** Chapter where it was planted (undefined = planned). */
179
- plantedChapter?: number
180
- /** Chapter where it should be paid off. */
181
- targetChapter?: number
182
- /** Lifecycle state. */
183
- status: 'planned' | 'planted' | 'progressing' | 'resolved' | 'abandoned'
184
- /** Resolution note when resolved. */
185
- resolvedNote?: string
186
- }
187
-
188
- /** The persisted project: outline + bible + plan + progress. */
189
- export interface ProjectState {
190
- /** Book title (first non-empty line of the outline, usually). */
191
- bookName: string
192
- /** Full outline text (docx-extracted or pasted). */
193
- outline: string
194
- /** Source outline path when loaded from a docx. */
195
- outlinePath?: string
196
- /** Structured story bible (worldbuilding), if generated. */
197
- bible?: StoryBible
198
- /** Volumes, if planned. */
199
- volumes?: Volume[]
200
- /** Chapter plan. */
201
- chapters: ChapterPlan[]
202
- /** Foreshadowing threads. */
203
- foreshadows: Foreshadow[]
204
- /** 写作资产(题材基底/推进模式/反AI规则/写法资产)。 */
205
- assets?: ProjectAssets
206
- /** ISO timestamps. */
207
- createdAt: string
208
- updatedAt: string
209
- }
210
-
211
- /** Runtime config surface exposed to the panel (subset of plugin Config). */
212
- export interface NovelConfig {
213
- /** Absolute path of the default docx outline to load. */
214
- outlinePath: string
215
- /** Absolute output directory for chapters + project state. */
216
- outputDir: string
217
- /** LLM provider route (e.g. deepseek-official). */
218
- provider: string
219
- /** LLM model id (e.g. deepseek-v4-flash). */
220
- model: string
221
- /** Target characters per chapter. */
222
- chapterChars: number
223
- /** Max output tokens per chapter call. */
224
- maxTokens: number
225
- /** Review pass threshold (0-100). */
226
- reviewPassScore: number
227
- /** Whether generation auto-runs review after writing. */
228
- autoReview: boolean
229
- }
230
-
231
- /** GET /status response. */
232
- export interface StatusResponse {
233
- config: NovelConfig
234
- /** The persisted project, when one exists in the output dir. */
235
- project?: ProjectState
236
- /** Chapter files already on disk (basenames, sorted). */
237
- generatedFiles: string[]
238
- }
239
-
240
- /** POST /load-outline request: either a docx path or raw text. */
241
- export interface LoadOutlineRequest {
242
- /** Absolute docx path; defaults to the configured outline path. */
243
- path?: string
244
- /** Raw outline text (takes precedence over path when present). */
245
- text?: string
246
- }
247
-
248
- /** POST /load-outline response. */
249
- export interface LoadOutlineResponse {
250
- outline: string
251
- bookName: string
252
- chars: number
253
- path?: string
254
- }
255
-
256
- /** POST /plan request. */
257
- export interface PlanRequest {
258
- /** Outline to plan from; defaults to the persisted project's outline. */
259
- outline?: string
260
- /** Number of chapters to plan (default: 30). */
261
- chapterCount?: number
262
- /** Volume to plan (1-based); when given, plans only that volume's chapters. */
263
- volume?: number
264
- }
265
-
266
- /** POST /plan response. */
267
- export interface PlanResponse {
268
- chapters: ChapterPlan[]
269
- volumes?: Volume[]
270
- }
271
-
272
- /** POST /volumes request/response. */
273
- export interface VolumesRequest {
274
- /** Outline to split into volumes; defaults to the project outline. */
275
- outline?: string
276
- }
277
- export interface VolumesResponse {
278
- volumes: Volume[]
279
- }
280
-
281
- /** POST /bible request/response. */
282
- export interface BibleRequest {
283
- /** Outline to extract from; defaults to the project outline. */
284
- outline?: string
285
- }
286
- export interface BibleResponse {
287
- bible: StoryBible
288
- }
289
-
290
- /** POST /generate request: one chapter of the current project. */
291
- export interface GenerateRequest {
292
- chapterNo: number
293
- /** When true, skips the auto-review step. */
294
- skipReview?: boolean
295
- }
296
-
297
- /** One NDJSON frame of a generation/review/rewrite stream. */
298
- export type JobFrame =
299
- | { type: 'start'; no: number; title: string }
300
- | { type: 'delta'; text: string }
301
- | { type: 'progress'; chars: number }
302
- | { type: 'done'; no: number; file: string; chars: number; title: string }
303
- | { type: 'review'; no: number; report: ReviewReport }
304
- | { type: 'rewritten'; no: number; file: string; chars: number }
305
- | { type: 'error'; no: number; message: string }
306
-
307
- /** POST /review request: review one written chapter. */
308
- export interface ReviewRequest {
309
- chapterNo: number
310
- }
311
-
312
- /** POST /rewrite request: rewrite one chapter (optionally per review issues). */
313
- export interface RewriteRequest {
314
- chapterNo: number
315
- /** Free-form instructions; defaults to fixing the review's high issues. */
316
- instructions?: string
317
- /**
318
- * 局部修订:正文中的一段原文(无需完全精确,取一个自然段内的片段即可)。
319
- * 提供时只重写该段,其余正文保持不变;不提供时整章重写。
320
- */
321
- target?: string
322
- }
323
-
324
- /** POST /polish request: de-AI-ify one chapter. */
325
- export interface PolishRequest {
326
- chapterNo: number
327
- }
328
-
329
- /** POST /summary request: (re)generate a chapter summary. */
330
- export interface SummaryRequest {
331
- chapterNo: number
332
- }
333
-
334
- /** POST /foreshadow request: create, update, or AI-suggest foreshadows. */
335
- export interface ForeshadowRequest {
336
- /** When true, runs the LLM suggestion pass (ignores other fields). */
337
- suggest?: boolean
338
- /** When given, updates that foreshadow instead of creating one. */
339
- id?: string
340
- description?: string
341
- plantedChapter?: number
342
- targetChapter?: number
343
- status?: Foreshadow['status']
344
- resolvedNote?: string
345
- }
346
- export interface ForeshadowResponse {
347
- foreshadows: Foreshadow[]
348
- }
349
-
350
- /** GET /chapter response. */
351
- export interface ChapterResponse {
352
- no: number
353
- title: string
354
- markdown: string
355
- }
356
-
357
- /** POST /export request/response. */
358
- export interface ExportRequest {
359
- format: 'txt' | 'md'
360
- }
361
- export interface ExportResponse {
362
- file: string
363
- chars: number
364
- chapters: number
365
- }
366
-
367
- /** POST /config request: patch any subset of the runtime config. */
368
- export interface ConfigPatch {
369
- outlinePath?: string
370
- outputDir?: string
371
- provider?: string
372
- model?: string
373
- chapterChars?: number
374
- maxTokens?: number
375
- reviewPassScore?: number
376
- autoReview?: boolean
377
- }
378
-
379
- // ------------------------------------------------------------ assistant
380
-
381
- /** One assistant conversation message (persisted per project). */
382
- export interface AssistantMessage {
383
- role: 'user' | 'assistant' | 'tool'
384
- /** Message text (tool messages carry the tool result). */
385
- content: string
386
- /** ISO timestamp. */
387
- ts: string
388
- /** For tool messages: which tool ran. */
389
- tool?: string
390
- }
391
-
392
- /** POST /assistant request: one user turn. */
393
- export interface AssistantRequest {
394
- message: string
395
- }
396
-
397
- /** One NDJSON frame of the assistant stream. */
398
- export type AssistantFrame =
399
- | { type: 'delta'; text: string }
400
- | { type: 'tool'; name: string; status: 'start' | 'done' | 'error'; detail?: string }
401
- /** Live output while a tool runs (e.g. chapter text being generated). */
402
- | { type: 'toolDelta'; name: string; text: string }
403
- | { type: 'done' }
404
- | { type: 'error'; message: string }
405
-
406
- /** GET /assistant-history response. */
407
- export interface AssistantHistoryResponse {
408
- messages: AssistantMessage[]
409
- }
410
-
411
- // ---------------------------------------------------------- writing assets
412
-
413
- /** 题材基底库:一本书属于哪个阅读市场。树形(题材→子题材→下级)。 */
414
- export interface GenreNode {
415
- /** 题材名称(标签,如「仙侠修真」「都市异能」)。 */
416
- name: string
417
- /** 题材特征、常见爽点、叙事重心或读者期待。 */
418
- description: string
419
- /** 子题材。 */
420
- children: GenreNode[]
421
- }
422
-
423
- /** 推进模式库:读者为什么继续看下一章。 */
424
- export interface ProgressionMode {
425
- /** 模式名称(如「升级变强」「经营扩张」「解谜揭露」)。 */
426
- name: string
427
- /** 核心驱动力:靠什么制造追读动力。 */
428
- driver: string
429
- /** 读者期待:每隔几章获得什么变化或回报。 */
430
- readerExpectation: string
431
- /** 常见兑现方式(爽点如何落地)。 */
432
- payoffs: string[]
433
- /** 节奏风险:最怕什么(重复升级、冲突变弱、谜题拖太久…)。 */
434
- risks: string[]
435
- /** 主模式或辅助模式。 */
436
- primary: boolean
437
- }
438
-
439
- /** 反 AI 规则:一条「要避免的问题 + 修正方向」。 */
440
- export interface AntiAiRule {
441
- /** 规则名(如「禁止解释型心理描写」「AI 高频套话」)。 */
442
- name: string
443
- /** 要避免的表达问题,具体可检查。 */
444
- avoid: string
445
- /** 推荐修正方向。 */
446
- fix: string
447
- /** 命中即告警的具体表达模式(用于审稿逐条核对与去 AI 味检测)。 */
448
- detectPatterns?: string[]
449
- /** 是否内置全局规则(内置规则随插件发布,项目规则为用户自定义)。 */
450
- builtin?: boolean
451
- }
452
-
453
- /** 预置写法模板(来自 AI-Novel-Writing-Assistant 内置数据,一键绑定无需样本文本)。 */
454
- export interface StyleTemplate {
455
- /** 模板 key(如 power-up-escalation)。 */
456
- key: string
457
- /** 模板名(如「爽文递进推进流」)。 */
458
- name: string
459
- /** 模板说明。 */
460
- description: string
461
- /** 分类(如「爽文流」「悬疑流」)。 */
462
- category: string
463
- /** 适用题材。 */
464
- applicableGenres: string[]
465
- /** 叙述规则。 */
466
- proseRules: string[]
467
- /** 角色/台词规则。 */
468
- dialogueRules: string[]
469
- /** 语言规则。 */
470
- languageRules: string[]
471
- /** 节奏规则。 */
472
- rhythmRules: string[]
473
- /** 该模板默认绑定的反 AI 规则 key(内置规则名)。 */
474
- defaultAntiAiRuleKeys: string[]
475
- }
476
-
477
- /** 写法引擎:从样本文本提取的叙事风格资产。 */
478
- export interface StyleAsset {
479
- /** 资产名(如「林越式痞坏」「冷峻猎手风」)。 */
480
- name: string
481
- /** 叙述视角与句式节奏。 */
482
- proseRules: string[]
483
- /** 角色台词风格。 */
484
- dialogueRules: string[]
485
- /** 描写密度与情绪表达。 */
486
- descriptionRules: string[]
487
- /** 表达边界(不要做什么)。 */
488
- boundaries: string[]
489
- /** 来源样本文本(可空)。 */
490
- sourceText?: string
491
- /** 创建时间。 */
492
- createdAt: string
493
- }
494
-
495
- /** 项目写作资产(题材基底 + 推进模式 + 反 AI 规则 + 写法资产)。 */
496
- export interface ProjectAssets {
497
- /** 本书选用的题材(可以是题材基底库中某节点名)。 */
498
- genre?: GenreNode
499
- /** 主推进模式。 */
500
- primaryProgression?: ProgressionMode
501
- /** 辅助推进模式。 */
502
- auxiliaryProgressions: ProgressionMode[]
503
- /** 生效的反 AI 规则(内置 + 自定义)。 */
504
- antiAiRules: AntiAiRule[]
505
- /** 绑定的写法资产。 */
506
- styleAssets: StyleAsset[]
507
- /** 资产更新时间。 */
508
- updatedAt?: string
509
- }
510
-
511
- /** GET /assets response(含全局题材库与反 AI 规则库)。 */
512
- export interface AssetsResponse {
513
- projectAssets: ProjectAssets
514
- /** 全局题材基底库(可复用资产,跨书)。 */
515
- genreLibrary: GenreNode[]
516
- /** 全局反 AI 规则库(内置默认规则)。 */
517
- antiAiLibrary: AntiAiRule[]
518
- /** 预置写法模板(一键绑定,无需样本文本)。 */
519
- styleTemplates: StyleTemplate[]
520
- /** 内置推进模式候选。 */
521
- progressionLibrary: ProgressionMode[]
522
- }
523
-
524
- /** POST /assets request:更新项目写作资产(部分字段可选)。 */
525
- export interface AssetsPatch {
526
- genre?: GenreNode
527
- primaryProgression?: ProgressionMode
528
- auxiliaryProgressions?: ProgressionMode[]
529
- antiAiRules?: AntiAiRule[]
530
- styleAssets?: StyleAsset[]
531
- }
532
-
533
- /** POST /style-engine request:从样本文本提取写法资产。 */
534
- export interface StyleEngineRequest {
535
- /** 样本文本(风格来源)。 */
536
- sampleText: string
537
- /** 资产名(可选,默认「风格资产 N」)。 */
538
- name?: string
539
- }
1
+ /**
2
+ * dsh-novel-forge — shared protocol between the host half (Node) and the
3
+ * browser half (web GUI). Route paths, request/response shapes, the project
4
+ * state file format, and the NDJSON generation stream frames all live here so
5
+ * both halves spell exactly one vocabulary.
6
+ */
7
+
8
+ /** The /api/dsh-novel-forge route family (same-origin, loopback-fenced). */
9
+ export const NOVEL_API = {
10
+ status: '/api/dsh-novel-forge/status',
11
+ loadOutline: '/api/dsh-novel-forge/load-outline',
12
+ saveOutline: '/api/dsh-novel-forge/save-outline',
13
+ plan: '/api/dsh-novel-forge/plan',
14
+ volumes: '/api/dsh-novel-forge/volumes',
15
+ bible: '/api/dsh-novel-forge/bible',
16
+ assets: '/api/dsh-novel-forge/assets',
17
+ styleEngine: '/api/dsh-novel-forge/style-engine',
18
+ styleFormula: '/api/dsh-novel-forge/style-formula',
19
+ styleDetect: '/api/dsh-novel-forge/style-detect',
20
+ knowledge: '/api/dsh-novel-forge/knowledge',
21
+ bookAnalysis: '/api/dsh-novel-forge/book-analysis',
22
+ ideaInspiration: '/api/dsh-novel-forge/idea-inspiration',
23
+ ideaInspirationMarket: '/api/dsh-novel-forge/idea-inspiration/market',
24
+ director: '/api/dsh-novel-forge/director',
25
+ directorTodos: '/api/dsh-novel-forge/director/todos',
26
+ llmLive: '/api/dsh-novel-forge/llm-live/stream',
27
+ marketRadar: '/api/dsh-novel-forge/market-radar',
28
+ marketRadarScan: '/api/dsh-novel-forge/market-radar/scan',
29
+ marketRadarApply: '/api/dsh-novel-forge/market-radar/apply',
30
+ marketRadarSync: '/api/dsh-novel-forge/market-radar/foundation-sync',
31
+ marketRadarBrief: '/api/dsh-novel-forge/market-radar/brief',
32
+ generate: '/api/dsh-novel-forge/generate',
33
+ review: '/api/dsh-novel-forge/review',
34
+ rewrite: '/api/dsh-novel-forge/rewrite',
35
+ polish: '/api/dsh-novel-forge/polish',
36
+ /** 采纳待确认草稿(润色/重写产物)覆盖正文文件。 */
37
+ draftApply: '/api/dsh-novel-forge/draft/apply',
38
+ /** 放弃待确认草稿,保留原稿。 */
39
+ draftDiscard: '/api/dsh-novel-forge/draft/discard',
40
+ summary: '/api/dsh-novel-forge/summary',
41
+ foreshadow: '/api/dsh-novel-forge/foreshadow',
42
+ exportBook: '/api/dsh-novel-forge/export',
43
+ chapter: '/api/dsh-novel-forge/chapter',
44
+ /** 审查任意正文文本(作者手动编辑后,不落盘)。 */
45
+ chapterCheck: '/api/dsh-novel-forge/chapter/check',
46
+ /** 保存手动编辑的正文(自动备份 .bak)。 */
47
+ chapterSave: '/api/dsh-novel-forge/chapter/save',
48
+ assistant: '/api/dsh-novel-forge/assistant',
49
+ assistantHistory: '/api/dsh-novel-forge/assistant-history',
50
+ /** 清空助手对话记录。 */
51
+ assistantClear: '/api/dsh-novel-forge/assistant/clear',
52
+ bookshelf: '/api/dsh-novel-forge/bookshelf',
53
+ /** 导入已有项目目录(含 novel-project.json)到书架。 */
54
+ bookshelfImportDir: '/api/dsh-novel-forge/bookshelf/import-dir',
55
+ /** 导入 txt/md 全本:拆章建项目并登记书架。 */
56
+ bookshelfImportText: '/api/dsh-novel-forge/bookshelf/import-text',
57
+ /** 导入 txt/md 全本:拆章预览(不落盘)。 */
58
+ bookshelfImportTextPreview: '/api/dsh-novel-forge/bookshelf/import-text/preview',
59
+ /** LLM 模型连通性测试:真实最小调用,验证 Key / 端点 / 模型可用。 */
60
+ llmTest: '/api/dsh-novel-forge/llm-test',
61
+ /** 添加模型:厂商直填 key 或自定义路由,写进 DSH 凭据与 llm-pi-ai 路由。 */
62
+ addModel: '/api/dsh-novel-forge/llm-add',
63
+ /** 运行时厂商目录(DSH pi-ai 可配置提供方 + 内置适配器)。 */
64
+ llmVendors: '/api/dsh-novel-forge/llm-vendors',
65
+ /** 查询某个 provider 当前可用的模型(添加成功后可即时刷新)。 */
66
+ llmModels: '/api/dsh-novel-forge/llm-models',
67
+ /** 已注册的提供方路由列表(提供方管理)。 */
68
+ llmProviders: '/api/dsh-novel-forge/llm-providers',
69
+ /** 移除一个提供方。 */
70
+ llmRemove: '/api/dsh-novel-forge/llm-remove',
71
+ /** 重置项目(可选携带新大纲):清空设定/卷/章节/伏笔/资产/事实库。 */
72
+ reset: '/api/dsh-novel-forge/reset',
73
+ /** 全书一致性质检:LLM 扫描已生成章节,输出矛盾问题清单。 */
74
+ audit: '/api/dsh-novel-forge/audit',
75
+ /** 角色卡刷新:基于事实库与各章摘要聚合角色当前状态。 */
76
+ charactersRefresh: '/api/dsh-novel-forge/characters/refresh',
77
+ /** 事实库回填:对历史已生成章节批量抽取事实(旧章节无事实记录时用)。 */
78
+ factsBackfill: '/api/dsh-novel-forge/facts/backfill',
79
+ /** 道藏局部修补(如世界观规则编辑)。 */
80
+ biblePatch: '/api/dsh-novel-forge/bible/patch',
81
+ /** 小说简介:生成(AI)/补全(AI)/保存。 */
82
+ blurb: '/api/dsh-novel-forge/blurb',
83
+ /** 重命名当前书(同步项目与书架条目)。 */
84
+ rename: '/api/dsh-novel-forge/rename',
85
+ /** 大世界:AI 提炼 / 保存结构化数据(境界/区域/势力)。 */
86
+ world: '/api/dsh-novel-forge/world',
87
+ /** 封面:GET 读取(dataUrl)/ POST 上传或移除。 */
88
+ cover: '/api/dsh-novel-forge/blurb/cover',
89
+ /** 剧情线管理:增删改 + 关联章节。 */
90
+ plotlines: '/api/dsh-novel-forge/plotlines',
91
+ /** 角色库:AI 提炼 / 采纳 / 更新 / 删除。 */
92
+ roles: '/api/dsh-novel-forge/roles',
93
+ /** 作者复盘补跑:对已写章节补齐 authorReview(全书流式 / 单章 JSON)。 */
94
+ reviewBackfill: '/api/dsh-novel-forge/review/backfill',
95
+ /** 章节复位:generating 卡死 → pending(可重新生成)。 */
96
+ chapterReset: '/api/dsh-novel-forge/chapter/reset',
97
+ /** 章节直接通过:作者对 rejected/written 章节行使最终决定权。 */
98
+ chapterApprove: '/api/dsh-novel-forge/chapter/approve',
99
+ /** 敏感词检查:全书已写章节或指定文本。 */
100
+ sensitiveCheck: '/api/dsh-novel-forge/sensitive-check',
101
+ /** 开书想法 → AI 补全大纲:输入一句话想法,生成 2-3 个可选大纲方案。 */
102
+ outlineSuggest: '/api/dsh-novel-forge/outline/suggest',
103
+ /** 反推大纲:从已写章节正文反向生成全书总纲(NDJSON 流)。 */
104
+ outlineReverse: '/api/dsh-novel-forge/outline/reverse',
105
+ /** 拆书分析:对已写章节做结构/人物/文风/卖点四维体检(两阶段:源笔记→分节分析)。 */
106
+ breakdown: '/api/dsh-novel-forge/breakdown',
107
+ /** 生产单:启动批量生产(计划补足 + 逐章生成 + 被拒分级处理)。 */
108
+ runStart: '/api/dsh-novel-forge/run/start',
109
+ /** 生产单控制:pause / resume / stop。 */
110
+ runControl: '/api/dsh-novel-forge/run/control',
111
+ /** 生产单状态(含进度统计与日志)。 */
112
+ runStatus: '/api/dsh-novel-forge/run/status',
113
+ config: '/api/dsh-novel-forge/config',
114
+ openFolder: '/api/dsh-novel-forge/open-folder',
115
+ /** 插件自更新:在 DSH profile 目录拉取最新 npm 版(下载后需重启 DSH 生效)。 */
116
+ pluginUpdate: '/api/dsh-novel-forge/plugin/update',
117
+ /** 作者资产库/总数据:读取个人跨书资产(笔法/红线/套路/角色模板/世界观模板)。 */
118
+ authorAssets: '/api/dsh-novel-forge/author-assets',
119
+ /** 作者资产库:新增/更新一条资产(upsert by id)。 */
120
+ authorAssetsUpsert: '/api/dsh-novel-forge/author-assets/upsert',
121
+ /** 作者资产库:删除一条资产。 */
122
+ authorAssetsRemove: '/api/dsh-novel-forge/author-assets/remove',
123
+ /** 作者资产库:导入默认(书架书的写作资产/角色 + 内置全局库)批量沉淀。 */
124
+ authorAssetsImportDefault: '/api/dsh-novel-forge/author-assets/import-default',
125
+ /** 改编模式:上传全文 → 分析 → 原文设定卡片/可改范围矩阵。 */
126
+ adaptAnalyze: '/api/dsh-novel-forge/adapt/analyze',
127
+ /** 改编模式:确认要改的维度 → 生成映射表/改编规则/联动影响清单。 */
128
+ adaptPropose: '/api/dsh-novel-forge/adapt/propose',
129
+ /** 改编模式:执行术语替换(全局替换 + 命中统计 + 改编文本预览)。 */
130
+ adaptExecute: '/api/dsh-novel-forge/adapt/execute',
131
+ /** 改编模式:保存改编全文为新书(原书保留,登记书架)。 */
132
+ adaptSave: '/api/dsh-novel-forge/adapt/save',
133
+ /** 改编模式:从源全文 + 编辑后方案提炼新书资料并保存为「待写新书」。 */
134
+ adaptMaterialize: '/api/dsh-novel-forge/adapt/materialize',
135
+ /** 改编模式:rewrite 逐章重写(NDJSON 流式进度)。 */
136
+ adaptRewriteStream: '/api/dsh-novel-forge/adapt/rewrite-stream',
137
+ /** 改编模式:把预览/微调后的新书资料写入并登记书架。 */
138
+ adaptMaterializeSave: '/api/dsh-novel-forge/adapt/materialize-save',
139
+ /** 主题自定义背景:上传图片(POST,存盘并返回服务端 URL)。 */
140
+ themeBackgroundUpload: '/api/dsh-novel-forge/theme/background',
141
+ /** 主题自定义背景:读取已上传文件(GET prefix,/theme/background/<name>)。 */
142
+ themeBackgroundGet: '/api/dsh-novel-forge/theme/background',
143
+ } as const
144
+
145
+ /** 书架:一本书的条目。 */
146
+ export interface BookEntry {
147
+ /** 稳定 id。 */
148
+ id: string
149
+ /** 书名。 */
150
+ bookName: string
151
+ /** 该书输出目录(独立项目目录)。 */
152
+ outputDir: string
153
+ /** 创建时间。 */
154
+ createdAt: string
155
+ /** 最后活动时间。 */
156
+ updatedAt: string
157
+ }
158
+
159
+ /** 书架快照(含每本书的进度摘要)。 */
160
+ export interface BookshelfSnapshot {
161
+ books: Array<BookEntry & { done: number; total: number; hasProject: boolean; hasCover: boolean; blurb?: string }>
162
+ /** 当前激活的书 id(无则 null)。 */
163
+ activeBookId: string | null
164
+ }
165
+
166
+ /** POST /bookshelf 请求:创建新书。 */
167
+ export interface BookCreateRequest {
168
+ bookName: string
169
+ outputDir?: string
170
+ /** 开书向导:创建时直接导入的大纲文本(提供则立即建立项目)。 */
171
+ outline?: string
172
+ }
173
+
174
+ /** POST /reset 请求:重置项目(可选更新大纲)。 */
175
+ export interface ResetRequest {
176
+ /** 新大纲文本;提供则替换 outline,否则保留原大纲。 */
177
+ outline?: string
178
+ }
179
+
180
+ /** POST /bookshelf/activate 请求:切换当前书。 */
181
+ export interface BookActivateRequest {
182
+ id: string
183
+ }
184
+
185
+ /** POST /bookshelf/remove 请求:移除书架条目。 */
186
+ export interface BookRemoveRequest {
187
+ id: string
188
+ }
189
+
190
+ /** POST /bookshelf/import-dir 请求:导入已有项目目录。 */
191
+ export interface BookImportDirRequest {
192
+ /** 项目目录(须含 novel-project.json)。 */
193
+ outputDir: string
194
+ }
195
+
196
+ /** POST /bookshelf/import-dir 响应。 */
197
+ export interface BookImportDirResponse {
198
+ book: BookEntry
199
+ /** true = 目录已在书架中(本次为重新激活)。 */
200
+ existed: boolean
201
+ }
202
+
203
+ /** POST /bookshelf/import-text 请求:导入 txt/md 全本。两种模式二选一:
204
+ * - filePath:服务器本地文件路径;
205
+ * - text + fileName:浏览器上传的全文内容(fileName 用于推断书名)。
206
+ */
207
+ export interface BookImportTextRequest {
208
+ /** 模式一:源文件绝对路径(txt 或 md)。 */
209
+ filePath?: string
210
+ /** 模式二:浏览器上传的全文内容。 */
211
+ text?: string
212
+ /** 模式二:原文件名(txt/md),用于推断书名与显示。 */
213
+ fileName?: string
214
+ /** 输出目录;缺省为 ~/.dsh/novels/书名。 */
215
+ outputDir?: string
216
+ }
217
+
218
+ /** POST /bookshelf/import-text 响应。 */
219
+ export interface BookImportTextResponse {
220
+ bookName: string
221
+ /** 成功拆出的章节数。 */
222
+ chapters: number
223
+ /** 因内容过短被跳过的章节标题列表。 */
224
+ skipped: string[]
225
+ /** 登记后的书架条目。 */
226
+ book: BookEntry
227
+ }
228
+
229
+ /** POST /bookshelf/import-text/preview 请求:上传全文做拆章预览(不落盘)。 */
230
+ export interface BookImportTextPreviewRequest {
231
+ text: string
232
+ /** 原文件名(txt/md),用于推断书名。 */
233
+ fileName?: string
234
+ }
235
+
236
+ /** POST /bookshelf/import-text/preview 响应。 */
237
+ export interface BookImportTextPreviewResponse {
238
+ /** 预计书名(fileName 去扩展名)。 */
239
+ bookName: string
240
+ /** 识别出的章节(已按正文长度过滤过短章节)。 */
241
+ chapters: Array<{ no: number; title: string; chars: number }>
242
+ /** 因内容过短被跳过的章节标题列表。 */
243
+ skipped: string[]
244
+ }
245
+
246
+ /** Chapter lifecycle states (the writing pipeline's state machine). */
247
+ export type ChapterStatus =
248
+ | 'pending' // planned, not started
249
+ | 'generating' // LLM writing right now
250
+ | 'written' // body on disk, awaiting review
251
+ | 'reviewing' // review in progress
252
+ | 'approved' // passed review (or user-approved)
253
+ | 'rejected' // review found problems
254
+ | 'error' // generation failed
255
+
256
+ /** One chapter in the plan. */
257
+ export interface ChapterPlan {
258
+ /** 1-based chapter number (stable identity; files are named from it). */
259
+ no: number
260
+ /** Volume this chapter belongs to (1-based; 0 = unassigned). */
261
+ volume: number
262
+ /** Chapter title, decided by the LLM plan step. */
263
+ title: string
264
+ /** Story beats / plot points for this chapter (model-facing guidance). */
265
+ beats: string
266
+ /** Target character count (defaults to the configured chapter size). */
267
+ targetChars: number
268
+ /** 本章必达项(必须推进的局面/关系/信息/风险/决策变化)。 */
269
+ mustAdvance?: string[]
270
+ /** 本章必须保持/不得破坏的项(如人物状态、已有伏笔不提前揭)。 */
271
+ mustPreserve?: string[]
272
+ /** 本章不可违背的人物硬事实(身份/阵营/境界/当前位置/知情度)。 */
273
+ characterHardFacts?: string[]
274
+ /** 伏笔操作指令(seed/touch/pressure/partial_reveal/payoff/forbid)。 */
275
+ payoffDirectives?: Array<{ no?: number; operation?: 'seed' | 'touch' | 'pressure' | 'partial_reveal' | 'payoff' | 'forbid'; text?: string }>
276
+ /** 章末钩子要求(悬念/反转/新线索/未闭合选择)。 */
277
+ endingHook?: string
278
+ /** 本章义务合约(人类可读摘要,供生成与审稿共同锚定)。 */
279
+ obligation?: string
280
+ /** Generation/review state. */
281
+ status: ChapterStatus
282
+ /** 进入 generating 的时间(用于超时自动复位;未在生成时无此字段)。 */
283
+ generatingAt?: string
284
+ /** Actual character count once generated. */
285
+ chars?: number
286
+ /** Failure message when status is 'error'. */
287
+ error?: string
288
+ /** Output file name once generated (relative to the output dir). */
289
+ file?: string
290
+ /** LLM summary of the chapter (narrative memory for later chapters). */
291
+ summary?: string
292
+ /** Latest review report (present once reviewed). */
293
+ review?: ReviewReport
294
+ /** 作者复盘:钩子兑现/结尾钩子/剧情线推进/连续性/节奏趋势(生成后自动)。 */
295
+ authorReview?: AuthorReview
296
+ /**
297
+ * 待确认草稿:润色(去AI味)或整章重写的产物正文。生成时先存这里,
298
+ * 用户看过对比后点「采纳」才覆盖正文文件;点「放弃」则丢弃。刷新页面不丢失。
299
+ */
300
+ pendingDraft?: string
301
+ }
302
+
303
+ /** 作者复盘:叙事结构层面的逐章检查(钩子/推进/连续性/趋势)。 */
304
+ export interface AuthorReview {
305
+ /** 上一章结尾钩子是否在本章兑现。 */
306
+ hookHonored: boolean
307
+ /** 钩子兑现说明(未兑现时给出建议)。 */
308
+ hookNote: string
309
+ /** 本章结尾钩子强度 0-10。 */
310
+ endingHook: number
311
+ /** 剧情线推进情况(推进了哪条线/或未推进)。 */
312
+ plotlineProgress: string
313
+ /** 结构化:本章推进的剧情线名称列表(与项目剧情线 name 精确匹配,复盘后自动关联章节)。 */
314
+ advancedLines?: string[]
315
+ /** 连续性检查(人物位置/时间/伤势/资源是否与上章衔接)。 */
316
+ continuity: string
317
+ /** 近期节奏趋势提示(拖沓/爽点密度等)。 */
318
+ trend: string
319
+ /** 本章发生的关键状态变化(人物状态/世界局面/关系/资源),用于回灌整本与事实库。 */
320
+ stateChanges?: string[]
321
+ /** 本章新引入或升级的冲突(供整本控制层与后续卷节奏参考)。 */
322
+ newConflicts?: string[]
323
+ /** 本章埋下/推进的新线索(供知识与伏笔系统回灌)。 */
324
+ clues?: string[]
325
+ /** 本章缺席但值得注意的角色及风险(卷级职责/缺席风险)。 */
326
+ absentRisks?: string[]
327
+ /** 复盘时间。 */
328
+ reviewedAt: string
329
+ }
330
+
331
+ /** 审稿维度(结构化定位问题类别;与 review-policy.ts 的 REVIEW_DIMENSIONS 对齐)。 */
332
+ export type ReviewDimension = 'character' | 'setting' | 'redline' | 'writing' | 'pacing' | 'logic' | 'anti-ai' | 'presentation' | 'compliance'
333
+
334
+ /** One review finding. */
335
+ export interface ReviewIssue {
336
+ /** Severity: high = must fix, medium = should fix, low = suggestion. */
337
+ severity: 'high' | 'medium' | 'low'
338
+ /** 问题维度(可选;缺省由前端按 item 推断)。 */
339
+ dimension?: ReviewDimension
340
+ /** What the problem is. */
341
+ item: string
342
+ /** Concrete suggestion for fixing it. */
343
+ suggestion: string
344
+ /** 命中的反 AI 规则名(结构化,便于统计)。 */
345
+ ruleName?: string
346
+ /** 规则类别:forbidden / risk / encourage。 */
347
+ ruleType?: 'forbidden' | 'risk' | 'encourage'
348
+ /** 问题细分类(如 套话 句式 段落 心理 设定)。 */
349
+ category?: string
350
+ /** 命中的原文摘录。 */
351
+ excerpt?: string
352
+ /** 判定理由。 */
353
+ reason?: string
354
+ /** 是否可自动改写。 */
355
+ canAutoRewrite?: boolean
356
+ }
357
+
358
+ /** AI review report for one chapter. */
359
+ export interface ReviewReport {
360
+ /** Overall score 0-100. */
361
+ score: number
362
+ /** Pass threshold (config; 70 default). */
363
+ passed: boolean
364
+ /** One-line verdict. */
365
+ verdict: string
366
+ /** Individual findings. */
367
+ issues: ReviewIssue[]
368
+ /** 风险分 0-100(越高越需人工处理;源自 LLM 复核与本地扫描)。 */
369
+ riskScore?: number
370
+ /** 本地 AI 味指数 0-100(越高越像 AI;LLM 复核锚点,供 UI 展示)。 */
371
+ aiFlavor?: number
372
+ /** 本地扫描命中的高频套话(按次数降序,取前若干)。 */
373
+ aiPhrases?: Array<{ word: string; count: number }>
374
+ /** When the review ran. */
375
+ reviewedAt: string
376
+ }
377
+
378
+ /** A volume of the book. */
379
+ export interface Volume {
380
+ /** 1-based volume number. */
381
+ no: number
382
+ /** Volume title. */
383
+ title: string
384
+ /** Volume positioning / summary. */
385
+ summary: string
386
+ /** First chapter number of this volume. */
387
+ chapterStart: number
388
+ /** Last chapter number (inclusive). */
389
+ chapterEnd: number
390
+ /** 卷级战略(这一卷的定位/承转,如「立威卷」「冲突升级卷」)。 */
391
+ strategy?: string
392
+ /** 卷节奏板(这一卷的节奏安排:起-承-转-合/爽点密度/关键节点)。 */
393
+ pacing?: string
394
+ }
395
+
396
+ /** 开书定盘:面向读者的承诺与流派定位(生成/规划均可引用)。 */
397
+ export interface BookContract {
398
+ /** 一句话卖点/题材承诺。 */
399
+ promise?: string
400
+ /** 主推进模式名(从推进模式库选)。 */
401
+ primaryModeName?: string
402
+ /** 辅助推进模式名。 */
403
+ secondaryModeNames?: string[]
404
+ /** 整体文风基调(一句话)。 */
405
+ tone?: string
406
+ /** 目标平台(如「番茄」)。 */
407
+ targetPlatform?: string
408
+ }
409
+
410
+ /** 书内知识库文档(供生成/规划时检索注入的参考资料)。 */
411
+ export interface KnowledgeDoc {
412
+ id: string
413
+ title: string
414
+ content: string
415
+ updatedAt: string
416
+ }
417
+
418
+ /** POST /knowledge request:增删改知识库文档。 */
419
+ export interface KnowledgeRequest {
420
+ action: 'add' | 'remove' | 'replace'
421
+ doc?: { id?: string; title: string; content: string }
422
+ id?: string
423
+ }
424
+
425
+ /** POST /book-analysis request。 */
426
+ export interface BookAnalysisRequest {
427
+ text: string
428
+ }
429
+
430
+ /** 书分析/拆书结果。 */
431
+ export interface BookAnalysisResult {
432
+ sellingPoints: string[]
433
+ structure: string[]
434
+ lessons: string[]
435
+ risks: string[]
436
+ }
437
+
438
+ /** POST /idea-inspiration request。 */
439
+ export interface IdeaInspirationRequest {
440
+ idea: string
441
+ count?: number
442
+ }
443
+
444
+ /** 创意灵感结果:多方向开书灵感。 */
445
+ export interface IdeaInspirationResult {
446
+ ideas: Array<{ title: string; hook: string; genre: string; pov: string; payoff: string }>
447
+ }
448
+
449
+ /** POST /director request。 */
450
+ export interface DirectorRequest {
451
+ focus?: string
452
+ }
453
+
454
+ /** 自动导演编排建议(下一卷/阶段编排 + 修复再平衡)。 */
455
+ export interface DirectorAdvice {
456
+ summary: string
457
+ nextArc: string[]
458
+ pacing: string
459
+ risks: string[]
460
+ fixes: string[]
461
+ }
462
+
463
+ /** 自动导演「采纳」后生成的书内待办项。 */
464
+ export interface DirectorTodo {
465
+ id: string
466
+ text: string
467
+ /** 来源:风险 或 修复。 */
468
+ source: 'risk' | 'fix'
469
+ done: boolean
470
+ createdAt: string
471
+ }
472
+
473
+ /** 题材雷达:单条市场信号。 */
474
+ export interface MarketRadarSignal {
475
+ id: string
476
+ kind: 'genre' | 'protagonist' | 'advantage' | 'opening' | 'relationship' | 'title_pattern' | 'opportunity' | 'crowding'
477
+ title: string
478
+ detail: string
479
+ /** 趋势:current / rising / stable / falling。 */
480
+ direction?: 'current' | 'rising' | 'stable' | 'falling'
481
+ /** 是否建议优先考虑。 */
482
+ recommended?: boolean
483
+ }
484
+
485
+ /** 题材雷达:生产底座(引用内置题材/推进模式库,或给出新资产)。 */
486
+ export interface ProductionFoundation {
487
+ genre: { existingId?: string; name: string; description: string; template?: string }
488
+ primaryStoryMode: { existingId?: string; name: string; driver: string; readerExpectation: string }
489
+ secondaryStoryMode?: { existingId?: string; name: string; driver: string; readerExpectation: string }
490
+ }
491
+
492
+ /** 题材雷达:开书创意简报(可执行,严禁照搬具体作品/命名)。 */
493
+ export interface MarketCreativeBrief {
494
+ promptBlock: string
495
+ openingIdea: string
496
+ coreAdvantage: string
497
+ bookSellingPoint: string
498
+ first30ChapterPromise: string
499
+ }
500
+
501
+ /** 题材雷达结果。 */
502
+ export interface MarketRadarResult {
503
+ signals: MarketRadarSignal[]
504
+ productionFoundation: ProductionFoundation
505
+ /** 开书创意简报(可选;用「用信号创作」接口单独生成)。 */
506
+ creativeBrief?: MarketCreativeBrief
507
+ }
508
+
509
+ /** POST /market-radar request。 */
510
+ export interface MarketRadarRequest {
511
+ platform?: string
512
+ genre?: string
513
+ keywords?: string
514
+ feedText?: string
515
+ /** 已扫描的上榜记录(来自真实榜单抓取),用于让分析基于真实榜单证据。 */
516
+ candidates?: Array<{ title: string; author?: string; tags?: string[]; synopsis?: string; category?: string; heatLabel?: string }>
517
+ }
518
+
519
+ /** POST /market-radar/brief request:用选中的信号 + 影响模式生成开书创意。 */
520
+ export interface MarketRadarBriefRequest {
521
+ influenceMode: 'follow_hot' | 'differentiate' | 'light'
522
+ signals: MarketRadarSignal[]
523
+ }
524
+
525
+ /** A character card from the story bible. */
526
+ export interface CharacterCard {
527
+ name: string
528
+ role: 'protagonist' | 'supporting' | 'antagonist' | 'other'
529
+ /** Personality / traits (short lines). */
530
+ traits: string[]
531
+ /** Goals and motivations. */
532
+ goals: string
533
+ /** Key relations to other characters. */
534
+ relations: string
535
+ /** 知情度:该角色已经知道的事实/秘密(未列出的信息该角色不知道)。 */
536
+ knowledge?: string[]
537
+ }
538
+
539
+ /** The structured story bible (worldbuilding extracted from the outline). */
540
+ export interface StoryBible {
541
+ /** Genre + tone tags. */
542
+ genre: string
543
+ /** Worldbuilding rules (power system, geography, factions...). */
544
+ worldRules: string[]
545
+ /** Character cards. */
546
+ characters: CharacterCard[]
547
+ /** Writing red lines (forbidden content / must-avoid tropes). */
548
+ redLines: string[]
549
+ /** Style guidance (pacing, pov, tone). */
550
+ style: string[]
551
+ /** When the bible was generated. */
552
+ generatedAt?: string
553
+ }
554
+
555
+ /** A planted/active/resolved foreshadowing thread. */
556
+ export interface Foreshadow {
557
+ /** Stable id. */
558
+ id: string
559
+ /** What the foreshadow is. */
560
+ description: string
561
+ /** Chapter where it was planted (undefined = planned). */
562
+ plantedChapter?: number
563
+ /** Chapter where it should be paid off. */
564
+ targetChapter?: number
565
+ /** Lifecycle state. */
566
+ status: 'planned' | 'planted' | 'progressing' | 'resolved' | 'abandoned'
567
+ /** Resolution note when resolved. */
568
+ resolvedNote?: string
569
+ }
570
+
571
+ /** 一条已确立的叙事事实(事实库/时间线,注入后续章节生成)。 */
572
+ export interface ChapterFact {
573
+ /** 来源章节号。 */
574
+ chapterNo: number
575
+ /** 事实文本(人物状态/境界资源/关系变化/伏笔落地等)。 */
576
+ text: string
577
+ }
578
+
579
+ /** 一条全书质检发现的问题(一致性矛盾,定位到章)。 */
580
+ export interface AuditIssue {
581
+ /** 问题所在章节号(无法定位时 0)。 */
582
+ chapterNo: number
583
+ severity: 'high' | 'medium' | 'low'
584
+ /** 矛盾描述。 */
585
+ item: string
586
+ /** 修改建议。 */
587
+ suggestion: string
588
+ }
589
+
590
+ /** POST /audit 响应。 */
591
+ export interface AuditResponse {
592
+ issues: AuditIssue[]
593
+ /** 参与质检的章节数。 */
594
+ auditedChapters: number
595
+ /** 质检时间。 */
596
+ auditedAt: string
597
+ /** 本次质检使用的模型(auditModel 或全局 model)。 */
598
+ model?: string
599
+ }
600
+
601
+ /** 全书质检的实时状态(通过 /status 暴露给面板/外部读取)。 */
602
+ export interface AuditStatus {
603
+ status: 'idle' | 'running' | 'done' | 'error'
604
+ /** 开始时间(ISO)。 */
605
+ startedAt?: string
606
+ /** 结束时间(ISO)。 */
607
+ finishedAt?: string
608
+ /** 总批次数(0 = 尚未开始/无章节)。 */
609
+ totalBatches: number
610
+ /** 已完成批次数。 */
611
+ completedBatches: number
612
+ /** 参与质检的章节数。 */
613
+ auditedChapters?: number
614
+ /** 发现的问题数(done 后有效)。 */
615
+ issuesCount?: number
616
+ /** 最近一次质检的问题清单(done 后有效;error 时为空)。 */
617
+ issues?: AuditIssue[]
618
+ /** 失败信息(error 时有效)。 */
619
+ error?: string
620
+ }
621
+
622
+ /** 一条剧情线(主线/支线/人物线/悬念线)。 */
623
+ export interface Plotline {
624
+ /** 稳定 id。 */
625
+ id: string
626
+ /** 线名。 */
627
+ name: string
628
+ /** 类型:主线 / 支线 / 人物线 / 悬念线。 */
629
+ kind: 'main' | 'branch' | 'character' | 'mystery'
630
+ /** 目标/终点(这条线最终要完成什么)。 */
631
+ goal: string
632
+ /** 当前进度说明(最近推进到哪)。 */
633
+ progress: string
634
+ /** 生命周期状态。 */
635
+ status: 'active' | 'paused' | 'resolved' | 'abandoned'
636
+ /** 关联章节号(推进/落地的章节)。 */
637
+ chapters: number[]
638
+ /** 创建时间。 */
639
+ createdAt: string
640
+ }
641
+
642
+ /** POST /plotlines 请求:剧情线增删改 + 关联章节 + AI 辅助。 */
643
+ export interface PlotlinesRequest {
644
+ op: 'add' | 'update' | 'remove' | 'link' | 'suggest' | 'refresh' | 'health' | 'plan'
645
+ /** add / update 时传入的完整剧情线。 */
646
+ line?: Plotline
647
+ /** remove / link / refresh 时的目标线 id。 */
648
+ id?: string
649
+ /** link 时关联的章节号。 */
650
+ chapterNo?: number
651
+ }
652
+
653
+ /** 剧情线健康检查报告。 */
654
+ export interface PlotlineHealthReport {
655
+ /** 是否需要新线(需要 / 暂不需要 / 再写 X 章后需要)。 */
656
+ verdict: string
657
+ /** 建议添加新线的时机说明。 */
658
+ timing: string
659
+ /** 依据(基于数据的理由,每条一句)。 */
660
+ reasons: string[]
661
+ /** 各线健康度。 */
662
+ lines: Array<{
663
+ name: string
664
+ /** ok=健康 / warning=预警 / stale=搁置过久。 */
665
+ health: 'ok' | 'warning' | 'stale'
666
+ note: string
667
+ }>
668
+ }
669
+
670
+ /** AI 剧情方案:下一阶段目标 + 建议新线。 */
671
+ export interface PlotlinePlan {
672
+ /** 下一阶段(未来 5-10 章)剧情方向。 */
673
+ direction: string
674
+ /** 建议的新线(可逐条采纳)。 */
675
+ suggestions: Plotline[]
676
+ }
677
+
678
+ /** POST /plotlines 响应。 */
679
+ export interface PlotlinesResponse {
680
+ plotlines: Plotline[]
681
+ /** op=suggest 时的 AI 建议候选线。 */
682
+ suggestions?: Plotline[]
683
+ /** op=health 时的健康检查报告。 */
684
+ health?: PlotlineHealthReport
685
+ /** op=plan 时的剧情方案。 */
686
+ plan?: PlotlinePlan
687
+ }
688
+
689
+ /** 一条敏感词命中。 */
690
+ export interface SensitiveHit {
691
+ /** 命中章节号(文本检测时为 0)。 */
692
+ chapterNo: number
693
+ /** 命中的违禁词。 */
694
+ word: string
695
+ /** 类别:政治 / 擦边 / 暴力 / 辱骂 / 广告 / 其他。 */
696
+ category: string
697
+ /** 出现次数。 */
698
+ count: number
699
+ }
700
+
701
+ /** POST /sensitive-check 请求:检测指定章节/任意文本/全书。 */
702
+ export interface SensitiveCheckRequest {
703
+ /** 检测该章正文。 */
704
+ chapterNo?: number
705
+ /** 检测任意文本(优先于 chapterNo)。 */
706
+ text?: string
707
+ /** 扫描全部已写章节。 */
708
+ all?: boolean
709
+ }
710
+
711
+ /** POST /sensitive-check 响应。 */
712
+ export interface SensitiveCheckResponse {
713
+ hits: SensitiveHit[]
714
+ /** 参与扫描的章节数。 */
715
+ scannedChapters: number
716
+ }
717
+
718
+ /** 开书想法 → AI 大纲方案(一个候选)。 */
719
+ export interface OutlineCandidate {
720
+ /** 唯一 id(前端暂留/换批用)。 */
721
+ id: string
722
+ /** 推荐书名。 */
723
+ bookName: string
724
+ /** 题材(如 仙侠修真 / 都市)。 */
725
+ genre: string
726
+ /** 核心卖点一句话。 */
727
+ sellingPoint: string
728
+ /** 完整大纲文本(可直接用作项目大纲,≥800 字)。 */
729
+ outline: string
730
+ }
731
+
732
+ /** POST /outline/suggest 请求:想法 → 2-3 个可选大纲。 */
733
+ export interface OutlineSuggestRequest {
734
+ /** 作者想法(一两句话,≥50 字)。 */
735
+ idea: string
736
+ /** 本次要生成的候选数(默认 3,最多 3)。 */
737
+ count?: number
738
+ /** 已暂留方案的剧情方向摘要(换批时让 LLM 避开,防止与已留方案重复)。 */
739
+ exclude?: string[]
740
+ }
741
+
742
+ /** POST /outline/suggest 响应。 */
743
+ export interface OutlineSuggestResponse {
744
+ candidates: OutlineCandidate[]
745
+ }
746
+
747
+ /** 拆书分析:一个分析小节。 */
748
+ export interface BreakdownSection {
749
+ /** 小节键:overview / plot / character / style / market。 */
750
+ key: string
751
+ /** 小节标题(如「拆书总览」)。 */
752
+ title: string
753
+ /** 可读分析稿(markdown)。 */
754
+ markdown: string
755
+ /** 结构化数据(程序可消费)。 */
756
+ structured: Record<string, unknown>
757
+ }
758
+
759
+ /** 拆书分析:一条证据(结论→原文回溯)。 */
760
+ export interface BreakdownEvidence {
761
+ label: string
762
+ excerpt: string
763
+ /** 来源章节号(0 = 未定位)。 */
764
+ chapterNo: number
765
+ /** 指向的结构化字段。 */
766
+ fieldKey?: string
767
+ }
768
+
769
+ /** POST /breakdown 请求:对已写章节做拆书分析。 */
770
+ export interface BreakdownRequest {
771
+ /** 分析范围:'recent'=最近 20 章 / 'volume:N'=第 N 卷 / 'all'=全书(默认 recent)。 */
772
+ scope?: string
773
+ /** 分析档位:'quick'=4 维(总览/剧情/人物/文风)/ 'standard'=5 维(+卖点)。 */
774
+ preset?: 'quick' | 'standard'
775
+ /** token 预算上限(默认 50000)。 */
776
+ budgetTokens?: number
777
+ }
778
+
779
+ /** POST /breakdown 响应。 */
780
+ export interface BreakdownResponse {
781
+ sections: BreakdownSection[]
782
+ evidence: BreakdownEvidence[]
783
+ /** 参与分析的章节数。 */
784
+ chaptersScanned: number
785
+ /** 估算消耗 token。 */
786
+ usedTokens: number
787
+ }
788
+
789
+ /** 角色卡:角色当前状态(从事实库聚合)。 */
790
+ export interface RoleStatusCard {
791
+ name: string
792
+ /** protagonist / supporting / antagonist / other。 */
793
+ role: string
794
+ /** 当前状态一句话(境界/资源/伤势/心境)。 */
795
+ status: string
796
+ /** 最近出场章节。 */
797
+ lastChapter: number
798
+ /** 出场次数。 */
799
+ appearances: number
800
+ }
801
+
802
+ /** 角色库条目(主表:作者维护 + AI 提炼 + 编年录自动聚合)。 */
803
+ export interface RoleRecord {
804
+ /** 角色名(唯一键)。 */
805
+ name: string
806
+ /** 定位:主角 / 女主 / 女配 / 配角 / 反派 / 路人。 */
807
+ roleLabel: 'protagonist' | 'female_lead' | 'female_support' | 'support' | 'antagonist' | 'extra'
808
+ /** 身份一句话(如:祭族后裔、青云宗杂役)。 */
809
+ identity: string
810
+ /** 性格标签。 */
811
+ traits: string[]
812
+ /** 目标与动机。 */
813
+ goals: string
814
+ /** 关系网:[角色名](关系)。 */
815
+ relations: string[]
816
+ /** 成长线:阶段 → 说明(可含章节)。 */
817
+ arc: string[]
818
+ /** 知情度:该角色已经知道的信息。 */
819
+ knowledge: string[]
820
+ /** 首次出场章节(编年录聚合,可手动修正)。 */
821
+ firstChapter?: number
822
+ }
823
+
824
+ /** POST /roles 请求:角色库增删改 + AI 提炼 + 参考图上传。 */
825
+ export interface RolesRequest {
826
+ op: 'extract' | 'adopt' | 'update' | 'remove'
827
+ /** adopt / update 时传入的角色(adopt 可修改后采纳)。 */
828
+ role?: RoleRecord
829
+ /** remove 时的角色名。 */
830
+ name?: string
831
+ }
832
+
833
+
834
+ /** POST /llm-test 请求:对选中的提供商/模型发一次最小真实调用。 */
835
+ export interface LlmTestRequest {
836
+ provider: string
837
+ model: string
838
+ }
839
+
840
+ /** POST /llm-test 响应。 */
841
+ export interface LlmTestResponse {
842
+ ok: boolean
843
+ /** 连通延迟(毫秒)。 */
844
+ ms?: number
845
+ /** 失败原因(已映射为人话)。 */
846
+ message?: string
847
+ /** 稳定错误码(LlmError code),便于排查。 */
848
+ code?: string
849
+ }
850
+
851
+ /** POST /roles 响应。 */
852
+ export interface RolesResponse {
853
+ roles: RoleRecord[]
854
+ /** op=extract 时的 AI 候选角色。 */
855
+ candidates?: RoleRecord[]
856
+ }
857
+
858
+ /** POST /bible/patch 请求:局部修补道藏。 */
859
+ export interface BiblePatchRequest {
860
+ worldRules?: string[]
861
+ redLines?: string[]
862
+ style?: string[]
863
+ /** 角色卡整体替换(人物志编辑知情度等)。 */
864
+ characters?: CharacterCard[]
865
+ }
866
+
867
+ /** POST /blurb 请求:AI 生成/补全或手动保存小说简介。 */
868
+ export interface BlurbRequest {
869
+ action: 'generate' | 'save'
870
+ /** 已写好的开头(AI 补全时使用;留空 = 全量生成)。 */
871
+ partial?: string
872
+ /** 手动保存的完整简介(action=save 时)。 */
873
+ text?: string
874
+ }
875
+
876
+ /** POST /chapter/check|save 请求:审查/保存手动编辑的正文。 */
877
+ export interface ChapterTextRequest {
878
+ chapterNo: number
879
+ /** 当前编辑中的正文全文。 */
880
+ text: string
881
+ /** 保存时携带:已在工作区审查过的报告(沿用落盘,不重复审);缺省则保存后自动正式审稿一次。 */
882
+ report?: ReviewReport
883
+ /** 审查/验证时携带:上一轮审稿报告。传入后进入「验证模式」——逐条核对原意见是否解决、
884
+ * 只挑新增 high,不再全新找茬(防止"越修 high 越多")。 */
885
+ previousReport?: ReviewReport
886
+ }
887
+
888
+ /** POST /chapter/save 响应。 */
889
+ export interface ChapterSaveResponse {
890
+ ok: boolean
891
+ chars: number
892
+ file: string
893
+ /** 落盘的审稿报告(沿用工作区报告或保存后自动审稿)。 */
894
+ report?: ReviewReport
895
+ }
896
+
897
+ /** POST /cover 请求:上传或移除封面。 */
898
+ export interface CoverRequest {
899
+ action: 'upload' | 'remove'
900
+ /** 上传时:data:image/...;base64,... 格式的图片数据。 */
901
+ dataUrl?: string
902
+ }
903
+
904
+ /** POST /rename 请求:重命名当前书。 */
905
+ export interface RenameRequest {
906
+ bookName: string
907
+ }
908
+
909
+ /** 大世界:一个境界等级。 */
910
+ export interface WorldRealm {
911
+ /** 境界名(练气/筑基/金丹…)。 */
912
+ name: string
913
+ /** 描述:突破条件/寿命/标志等。 */
914
+ description: string
915
+ }
916
+
917
+ /** 大世界:一个地理区域。 */
918
+ export interface WorldRegion {
919
+ name: string
920
+ description: string
921
+ /** 关联势力名(可空)。 */
922
+ faction?: string
923
+ }
924
+
925
+ /** 大世界:一方势力。 */
926
+ export interface WorldFaction {
927
+ name: string
928
+ /** 类型:宗门/家族/王朝/组织… */
929
+ kind: string
930
+ description: string
931
+ /** 驻地区域(可空)。 */
932
+ region?: string
933
+ }
934
+
935
+ /** 大世界结构化数据。 */
936
+ export interface WorldState {
937
+ realms: WorldRealm[]
938
+ regions: WorldRegion[]
939
+ factions: WorldFaction[]
940
+ }
941
+
942
+ /** POST /world 请求:AI 提炼或手动保存。 */
943
+ export interface WorldRequest {
944
+ action: 'generate' | 'save'
945
+ /** action=save 时的完整世界数据。 */
946
+ world?: WorldState
947
+ }
948
+
949
+ /** GET /cover 响应:封面的 dataUrl(无封面为 null)。 */
950
+ export interface CoverResponse {
951
+ dataUrl: string | null
952
+ }
953
+
954
+ /** The persisted project: outline + bible + plan + progress. */
955
+ export interface ProjectState {
956
+ /** Book title (first non-empty line of the outline, usually). */
957
+ bookName: string
958
+ /** Full outline text (docx-extracted or pasted). */
959
+ outline: string
960
+ /** Source outline path when loaded from a docx. */
961
+ outlinePath?: string
962
+ /** Structured story bible (worldbuilding), if generated. */
963
+ bible?: StoryBible
964
+ /** Volumes, if planned. */
965
+ volumes?: Volume[]
966
+ /** Chapter plan. */
967
+ chapters: ChapterPlan[]
968
+ /** Foreshadowing threads. */
969
+ foreshadows: Foreshadow[]
970
+ /** 写作资产(题材基底/推进模式/反AI规则/写法资产)。 */
971
+ assets?: ProjectAssets
972
+ /** 事实库/时间线:每章生成后抽取,注入后续章节保持一致性。 */
973
+ facts?: ChapterFact[]
974
+ /** 书内知识库文档(可检索资料/设定/参考)。 */
975
+ knowledgeDocs?: KnowledgeDoc[]
976
+ /** 自动导演待办:风险/修复「采纳」后生成的随手清单。 */
977
+ todos?: DirectorTodo[]
978
+ /** 小说简介(面向读者的作品门面,AI 生成或手动保存)。 */
979
+ blurb?: string
980
+ /** 开书定盘:书籍级承诺与流派定位(前30章承诺/主副模式/文风/平台)。 */
981
+ bookContract?: BookContract
982
+ /** 封面文件名(相对输出目录,如 cover.png)。 */
983
+ coverPath?: string
984
+ /** 大世界结构化数据(境界体系/区域/势力)。 */
985
+ world?: WorldState
986
+ /** 剧情线(主线/支线/人物线/悬念线)。 */
987
+ plotlines?: Plotline[]
988
+ /** 角色库(作者维护 + AI 提炼的主表)。 */
989
+ roles?: RoleRecord[]
990
+ /** 人物志:角色当前状态聚合结果(从编年录刷新后存档,打开页面直接显示)。 */
991
+ roleStatus?: RoleStatusCard[]
992
+ /** ISO timestamps. */
993
+ createdAt: string
994
+ updatedAt: string
995
+ }
996
+
997
+ /** 手动添加的模型库条目(只存插件内,不改 DSH 全局)。 */
998
+ export interface SavedModel {
999
+ /** 唯一 id(前端生成的短 id)。 */
1000
+ id: string
1001
+ /** 展示名(可为空,回退到 model)。 */
1002
+ name: string
1003
+ /** DSH 提供商路由(如 zai-coding-cn)。 */
1004
+ provider: string
1005
+ /** 模型 id(如 glm-5.3-flash)。 */
1006
+ model: string
1007
+ }
1008
+
1009
+ /** DSH 模型添加:厂商预设(选择厂商,直接填 API Key)。 */
1010
+ export interface LlmVendor {
1011
+ id: string
1012
+ name: string
1013
+ /** 该厂商对应的 provider 路由。 */
1014
+ route: string
1015
+ /** DSH 凭据引用名(写入 .credentials.yaml 的 refs)。 */
1016
+ apiKeyEnv: string
1017
+ /** 默认模型 id。 */
1018
+ defaultModel: string
1019
+ /** 建议可选模型 id 列表(下拉 data-list 用)。 */
1020
+ models: string[]
1021
+ /** 内置适配器(如 deepseek-official),无需注册 pi-ai 路由。 */
1022
+ builtin?: boolean
1023
+ }
1024
+
1025
+ /** 预置的常见厂商(id=provider 路由;添加模型下拉兜底用,其余厂商由运行时目录动态补充)。 */
1026
+ export const LLM_VENDORS: LlmVendor[] = [
1027
+ { id: 'deepseek-official', name: 'DeepSeek', route: 'deepseek-official', apiKeyEnv: 'DEEPSEEK_API_KEY', defaultModel: 'deepseek-v4-flash', models: ['deepseek-v4-flash', 'deepseek-v4-pro', 'deepseek-chat', 'deepseek-reasoner'], builtin: true },
1028
+ { id: 'zai-coding-cn', name: '智谱 GLM', route: 'zai-coding-cn', apiKeyEnv: 'ZAI_CODING_CN_API_KEY', defaultModel: 'glm-5.3-flash', models: ['glm-4.5-air', 'glm-4.7', 'glm-5-turbo', 'glm-5.1', 'glm-5.2', 'glm-5.3', 'glm-5.3-flash', 'glm-5v-turbo'] },
1029
+ { id: 'qwen-token-plan-cn', name: '千问百炼', route: 'qwen-token-plan-cn', apiKeyEnv: 'QWEN_TOKEN_PLAN_CN_API_KEY', defaultModel: 'qwen3.7-max', models: ['qwen3.6-flash', 'qwen3.6-plus', 'qwen3.7-max', 'qwen3.7-plus', 'qwen3.8-max', 'qwen3.8-max-preview'] },
1030
+ { id: 'openrouter', name: 'OpenRouter', route: 'openrouter', apiKeyEnv: 'OPENROUTER_API_KEY', defaultModel: 'z-ai/glm-5.3-flash', models: ['z-ai/glm-4.6', 'z-ai/glm-4.7', 'z-ai/glm-5', 'z-ai/glm-5-turbo', 'z-ai/glm-5.1', 'z-ai/glm-5.2', 'z-ai/glm-5.3-flash', 'auto', 'deepseek/deepseek-v4-flash', 'anthropic/claude-sonnet-4.6'] },
1031
+ ]
1032
+
1033
+ /** 运行时厂商目录的一项(添加到模型下拉;由 DSH 的 pi-ai 可配置提供方动态生成)。 */
1034
+ export interface LlmVendorOption {
1035
+ /** provider 路由 id(也是厂商下拉的值)。 */
1036
+ id: string
1037
+ /** 展示名。 */
1038
+ name: string
1039
+ /** 建议模型 id(可为空,用户手填)。 */
1040
+ models: string[]
1041
+ /** 已知 DSH 凭据引用名;为空时 host 生成 `PI_AI_<ID>_API_KEY`。 */
1042
+ apiKeyEnv?: string
1043
+ /** 内置适配器(只写凭据,不注册 pi-ai 路由)。 */
1044
+ builtin?: boolean
1045
+ }
1046
+
1047
+ /** GET /llm-vendors 响应。 */
1048
+ export interface LlmVendorsResponse {
1049
+ vendors: LlmVendorOption[]
1050
+ }
1051
+
1052
+ /** /llm-models 里的一条模型。 */
1053
+ export interface LlmModelOption { id: string; name: string }
1054
+
1055
+ /** GET /llm-models?provider=x 响应。 */
1056
+ export interface LlmModelsResponse {
1057
+ models: LlmModelOption[]
1058
+ }
1059
+
1060
+ /** GET /llm-providers 响应:当前已注册的提供方路由。 */
1061
+ export interface LlmProvidersResponse {
1062
+ providers: { id: string; name: string }[]
1063
+ }
1064
+
1065
+ /** POST /llm-remove 请求:移除一个提供方(unset key + 移除 llm-pi-ai 路由)。 */
1066
+ export interface RemoveProviderRequest {
1067
+ provider: string
1068
+ /** 该提供方对应的 DSH 凭据引用名(用于 unset)。 */
1069
+ apiKeyEnv?: string
1070
+ }
1071
+
1072
+ /** POST /llm-remove 响应。 */
1073
+ export interface RemoveProviderResponse {
1074
+ ok: boolean
1075
+ message?: string
1076
+ }
1077
+
1078
+ /** GET /llm-providers 响应:当前已注册的提供方路由。 */
1079
+ export interface LlmProvidersResponse {
1080
+ providers: { id: string; name: string }[]
1081
+ }
1082
+
1083
+ /** POST /llm-remove 请求:移除一个提供方(unset key + 移除 llm-pi-ai 路由)。 */
1084
+ export interface RemoveProviderRequest {
1085
+ provider: string
1086
+ /** 该提供方对应的 DSH 凭据引用名(用于 unset)。 */
1087
+ apiKeyEnv?: string
1088
+ }
1089
+
1090
+ /** POST /llm-remove 响应。 */
1091
+ export interface RemoveProviderResponse {
1092
+ ok: boolean
1093
+ message?: string
1094
+ }
1095
+
1096
+ /** POST /llm-add 请求:添加一个模型(厂商直填 key,或自定义路由)。 */
1097
+ export interface AddModelRequest {
1098
+ mode: 'vendor' | 'custom'
1099
+ /** 厂商模式用:provider 路由 id(来自 /llm-vendors)。 */
1100
+ vendor?: string
1101
+ /** 厂商已知的 DSH 凭据引用名(可选;为空时 host 生成)。 */
1102
+ apiKeyEnv?: string
1103
+ /** 自定义模式用:provider 路由 id。 */
1104
+ provider?: string
1105
+ /** 模型 id。 */
1106
+ model: string
1107
+ /** API Key。 */
1108
+ apiKey: string
1109
+ /** 展示名(可选)。 */
1110
+ name?: string
1111
+ /** 自定义模式用:OpenAI 兼容 base URL。 */
1112
+ baseURL?: string
1113
+ }
1114
+
1115
+ /** POST /llm-add 响应。 */
1116
+ export interface AddModelResponse {
1117
+ ok: boolean
1118
+ saved: SavedModel
1119
+ provider: string
1120
+ message?: string
1121
+ }
1122
+
1123
+ /** 手动添加的模型库条目(只存插件内,不改 DSH 全局)。 */
1124
+ export interface NovelConfig {
1125
+ /** Absolute path of the default docx outline to load. */
1126
+ outlinePath: string
1127
+ /** Absolute output directory for chapters + project state. */
1128
+ outputDir: string
1129
+ /** LLM provider route (e.g. deepseek-official). */
1130
+ provider: string
1131
+ /** LLM model id (e.g. deepseek-v4-flash). */
1132
+ model: string
1133
+ /** 生成正文用模型(缺省用 model)。 */
1134
+ generateModel?: string
1135
+ /** 审稿用模型(缺省用 model;建议用更强的 reasoner/pro)。 */
1136
+ reviewModel?: string
1137
+ /** 全书质检(审计)用模型(缺省用 model)。 */
1138
+ auditModel?: string
1139
+ /** LLM reasoning effort: off = no thinking; low/high/max = thinking intensity. */
1140
+ reasoningEffort: 'off' | 'low' | 'high' | 'max'
1141
+ /** 分析类任务(提炼/拆书/反推大纲等)的推理档位;默认 low,不受上面写作档位影响。 */
1142
+ analysisReasoning: 'off' | 'low' | 'high' | 'max'
1143
+ /** Target characters per chapter. */
1144
+ chapterChars: number
1145
+ /** Max output tokens per chapter call. */
1146
+ maxTokens: number
1147
+ /** Review pass threshold (0-100). */
1148
+ reviewPassScore: number
1149
+ /** Whether generation auto-runs review after writing. */
1150
+ autoReview: boolean
1151
+ /** Whether generation auto-runs the author review (hook/continuity/trend) after writing. */
1152
+ autoAuthorReview: boolean
1153
+ /** 修订/润色产出草稿后是否自动附带一次 AI 审查(工作区显示新稿评分与剩余问题)。 */
1154
+ autoReviewAfterRevise: boolean
1155
+ /** 自定义背景图(URL 或 dataURL 或服务端路径引用;空 = 使用主题默认背景)。 */
1156
+ themeBackground?: string
1157
+ /** 自定义背景遮罩/模糊强度 0-80(0 = 不遮罩)。 */
1158
+ themeBackgroundBlur?: number
1159
+ /** 玻璃透明度 0-100(100=当前原样,越小越透,新拟态/黏土可见背景图)。 */
1160
+ themeOpacity?: number
1161
+ /** 是否启用改编模式(默认关闭;发布后开启)。 */
1162
+ enableAdaptMode?: boolean
1163
+ /** 手动添加的模型库(「我的模型」条目;只存插件内)。 */
1164
+ savedModels?: SavedModel[]
1165
+ }
1166
+
1167
+ /** GET /status response. */
1168
+ export interface StatusResponse {
1169
+ config: NovelConfig
1170
+ /** The persisted project, when one exists in the output dir. */
1171
+ project?: ProjectState
1172
+ /** Chapter files already on disk (basenames, sorted). */
1173
+ generatedFiles: string[]
1174
+ /** 全书质检实时状态(用于面板/外部读取进度)。 */
1175
+ audit?: AuditStatus
1176
+ }
1177
+
1178
+ /** 生产单状态(生产单 = 区间批量生产执行器:计划补足 + 逐章生成 + 被拒分级处理)。 */
1179
+ export interface RunState {
1180
+ runId: string
1181
+ /** 区间起点(含)。 */
1182
+ startNo: number
1183
+ /** 区间终点(含)。 */
1184
+ endNo: number
1185
+ status: 'running' | 'paused' | 'done' | 'stopped' | 'error'
1186
+ /** 当前处理到的章号(已 approved 的章会快进)。 */
1187
+ currentNo: number
1188
+ stats: {
1189
+ /** 新生成(含审稿)的章数。 */
1190
+ generated: number
1191
+ /** 被拒后按意见修订并通过的章数。 */
1192
+ revised: number
1193
+ /** 被拒后豁免通过(无 high)的章数。 */
1194
+ exempted: number
1195
+ /** error 后重新生成的章数。 */
1196
+ regenerated: number
1197
+ /** 生成失败的章数。 */
1198
+ error: number
1199
+ }
1200
+ /** 两轮修订仍不过、保留草稿待人工的章号。 */
1201
+ pendingManual: number[]
1202
+ /** 运行日志(保留最近 300 条)。 */
1203
+ log: Array<{ at: string; text: string }>
1204
+ startedAt: string
1205
+ updatedAt: string
1206
+ error?: string
1207
+ }
1208
+
1209
+ /** POST /run/start request. */
1210
+ export interface RunStartRequest {
1211
+ /** 起始章号(默认 1)。 */
1212
+ startNo?: number
1213
+ /** 结束章号(含;超出计划时自动补计划)。 */
1214
+ endNo?: number
1215
+ /** 或指定新增章数(从当前最后一章 +1 起)。 */
1216
+ count?: number
1217
+ }
1218
+
1219
+ /** POST /run/control request. */
1220
+ export interface RunControlRequest {
1221
+ action: 'pause' | 'resume' | 'stop'
1222
+ }
1223
+
1224
+ /** POST /load-outline request: either a docx path or raw text. */
1225
+ export interface LoadOutlineRequest {
1226
+ /** Absolute docx path; defaults to the configured outline path. */
1227
+ path?: string
1228
+ /** Raw outline text (takes precedence over path when present). */
1229
+ text?: string
1230
+ }
1231
+
1232
+ /** POST /load-outline response. */
1233
+ export interface LoadOutlineResponse {
1234
+ outline: string
1235
+ bookName: string
1236
+ chars: number
1237
+ path?: string
1238
+ }
1239
+
1240
+ /** POST /plan request. */
1241
+ export interface PlanRequest {
1242
+ /** Outline to plan from; defaults to the persisted project's outline. */
1243
+ outline?: string
1244
+ /** Number of chapters to plan (default: 30). */
1245
+ chapterCount?: number
1246
+ /** Volume to plan (1-based); when given, plans only that volume's chapters. */
1247
+ volume?: number
1248
+ }
1249
+
1250
+ /** POST /plan response. */
1251
+ export interface PlanResponse {
1252
+ chapters: ChapterPlan[]
1253
+ volumes?: Volume[]
1254
+ }
1255
+
1256
+ /** POST /volumes request/response. */
1257
+ export interface VolumesRequest {
1258
+ /** Outline to split into volumes; defaults to the project outline. */
1259
+ outline?: string
1260
+ }
1261
+ export interface VolumesResponse {
1262
+ volumes: Volume[]
1263
+ }
1264
+
1265
+ /** POST /bible request/response. */
1266
+ export interface BibleRequest {
1267
+ /** Outline to extract from; defaults to the project outline. */
1268
+ outline?: string
1269
+ }
1270
+ export interface BibleResponse {
1271
+ bible: StoryBible
1272
+ }
1273
+
1274
+ /** POST /generate request: one chapter of the current project. */
1275
+ export interface GenerateRequest {
1276
+ chapterNo: number
1277
+ /** When true, skips the auto-review step. */
1278
+ skipReview?: boolean
1279
+ }
1280
+
1281
+ /** One NDJSON frame of a generation/review/rewrite stream. */
1282
+ export type JobFrame =
1283
+ | { type: 'start'; no: number; title: string }
1284
+ | { type: 'delta'; text: string }
1285
+ | { type: 'progress'; chars: number }
1286
+ | { type: 'done'; no: number; file: string; chars: number; title: string; warn?: string }
1287
+ | { type: 'review'; no: number; report: ReviewReport }
1288
+ | { type: 'author-review'; no: number; review: AuthorReview }
1289
+ | { type: 'author-backfill-done'; count: number }
1290
+ | { type: 'rewritten'; no: number; file: string; chars: number }
1291
+ /** 润色/重写完成,产物作为待确认草稿(尚未覆盖正文)。 */
1292
+ | { type: 'drafted'; no: number; chars: number; draft: string }
1293
+ | { type: 'outline-progress'; done: number; total: number; phase: string }
1294
+ | { type: 'outline-done'; outline: string; chars: number }
1295
+ | { type: 'error'; no: number; message: string }
1296
+
1297
+ /** POST /review request: review one written chapter. */
1298
+ export interface ReviewRequest {
1299
+ chapterNo: number
1300
+ }
1301
+
1302
+ /** POST /rewrite request: rewrite one chapter (optionally per review issues). */
1303
+ export interface RewriteRequest {
1304
+ chapterNo: number
1305
+ /** Free-form instructions; defaults to fixing the review's high issues. */
1306
+ instructions?: string
1307
+ /**
1308
+ * 局部修订:正文中的一段原文(无需完全精确,取一个自然段内的片段即可)。
1309
+ * 提供时只重写该段,其余正文保持不变;不提供时整章重写。
1310
+ */
1311
+ target?: string
1312
+ }
1313
+
1314
+ /** POST /polish request: de-AI-ify one chapter. */
1315
+ export interface PolishRequest {
1316
+ chapterNo: number
1317
+ }
1318
+
1319
+ /** POST /draft/apply | /draft/discard request: 采纳或放弃待确认草稿。 */
1320
+ export interface DraftDecisionRequest {
1321
+ chapterNo: number
1322
+ /** apply 时可携带审查报告(沿用结论定状态;不携带则置 written)。 */
1323
+ report?: ReviewReport
1324
+ }
1325
+
1326
+ /** POST /summary request: (re)generate a chapter summary. */
1327
+ export interface SummaryRequest {
1328
+ chapterNo: number
1329
+ }
1330
+
1331
+ /** POST /foreshadow request: create, update, or AI-suggest foreshadows. */
1332
+ export interface ForeshadowRequest {
1333
+ /** When true, runs the LLM suggestion pass (ignores other fields). */
1334
+ suggest?: boolean
1335
+ /** When given, updates that foreshadow instead of creating one. */
1336
+ id?: string
1337
+ description?: string
1338
+ plantedChapter?: number
1339
+ targetChapter?: number
1340
+ status?: Foreshadow['status']
1341
+ resolvedNote?: string
1342
+ }
1343
+ export interface ForeshadowResponse {
1344
+ foreshadows: Foreshadow[]
1345
+ }
1346
+
1347
+ /** GET /chapter response. */
1348
+ export interface ChapterResponse {
1349
+ no: number
1350
+ title: string
1351
+ markdown: string
1352
+ }
1353
+
1354
+ /** POST /export request/response. */
1355
+ export interface ExportRequest {
1356
+ format: 'txt' | 'md'
1357
+ }
1358
+ export interface ExportResponse {
1359
+ file: string
1360
+ chars: number
1361
+ chapters: number
1362
+ }
1363
+
1364
+ /** POST /config request: patch any subset of the runtime config. */
1365
+ export interface ConfigPatch {
1366
+ outlinePath?: string
1367
+ outputDir?: string
1368
+ provider?: string
1369
+ model?: string
1370
+ generateModel?: string
1371
+ reviewModel?: string
1372
+ auditModel?: string
1373
+ reasoningEffort?: 'off' | 'low' | 'high' | 'max'
1374
+ analysisReasoning?: 'off' | 'low' | 'high' | 'max'
1375
+ chapterChars?: number
1376
+ maxTokens?: number
1377
+ reviewPassScore?: number
1378
+ autoReview?: boolean
1379
+ autoAuthorReview?: boolean
1380
+ autoReviewAfterRevise?: boolean
1381
+ /** 自定义背景图(URL / dataURL / 服务端路径引用)。 */
1382
+ themeBackground?: string
1383
+ /** 自定义背景遮罩/模糊强度 0-80。 */
1384
+ themeBackgroundBlur?: number
1385
+ /** 玻璃透明度 0-100(100=当前原样)。 */
1386
+ themeOpacity?: number
1387
+ enableAdaptMode?: boolean
1388
+ /** 手动添加的模型库(完整替换保存)。 */
1389
+ savedModels?: SavedModel[]
1390
+ }
1391
+
1392
+ // ------------------------------------------------------------ assistant
1393
+
1394
+ /** One assistant conversation message (persisted per project). */
1395
+ export interface AssistantMessage {
1396
+ role: 'user' | 'assistant' | 'tool'
1397
+ /** Message text (tool messages carry the tool result). */
1398
+ content: string
1399
+ /** ISO timestamp. */
1400
+ ts: string
1401
+ /** For tool messages: which tool ran. */
1402
+ tool?: string
1403
+ }
1404
+
1405
+ /** POST /assistant request: one user turn. */
1406
+ export interface AssistantRequest {
1407
+ message: string
1408
+ }
1409
+
1410
+ /** One NDJSON frame of the assistant stream. */
1411
+ export type AssistantFrame =
1412
+ | { type: 'delta'; text: string }
1413
+ | { type: 'tool'; name: string; status: 'start' | 'done' | 'error'; detail?: string }
1414
+ /** Live output while a tool runs (e.g. chapter text being generated). */
1415
+ | { type: 'toolDelta'; name: string; text: string }
1416
+ /** 工具完整结果(供前端渲染成结构化卡片,如拆书/导演)。 */
1417
+ | { type: 'toolResult'; name: string; text: string }
1418
+ | { type: 'done' }
1419
+ | { type: 'error'; message: string }
1420
+
1421
+ /** GET /assistant-history response. */
1422
+ export interface AssistantHistoryResponse {
1423
+ messages: AssistantMessage[]
1424
+ }
1425
+
1426
+ // ---------------------------------------------------------- writing assets
1427
+
1428
+ /** 题材基底库:一本书属于哪个阅读市场。树形(题材→子题材→下级)。 */
1429
+ export interface GenreNode {
1430
+ /** 稳定标识(内置库交叉引用)。 */
1431
+ id?: string
1432
+ /** 题材名称(标签,如「仙侠修真」「都市异能」)。 */
1433
+ name: string
1434
+ /** 题材特征、常见爽点、叙事重心或读者期待。 */
1435
+ description: string
1436
+ /** 该题材的写法指引(开书定盘/卷计划用,区别于「读者期待」)。 */
1437
+ template?: string
1438
+ /** 子题材。 */
1439
+ children: GenreNode[]
1440
+ }
1441
+
1442
+ /** 推进模式库:读者为什么继续看下一章。 */
1443
+ export interface ProgressionMode {
1444
+ /** 稳定标识(与内置库交叉引用)。 */
1445
+ key?: string
1446
+ /** 模式名称(如「升级变强」「经营扩张」「解谜揭露」)。 */
1447
+ name: string
1448
+ /** 核心驱动力:靠什么制造追读动力。 */
1449
+ driver: string
1450
+ /** 读者期待:每隔几章获得什么变化或回报。 */
1451
+ readerExpectation: string
1452
+ /** 常见兑现方式(爽点如何落地)。 */
1453
+ payoffs: string[]
1454
+ /** 节奏风险:最怕什么(重复升级、冲突变弱、谜题拖太久…)。 */
1455
+ risks: string[]
1456
+ /** 主模式或辅助模式。 */
1457
+ primary: boolean
1458
+ /** 该模式的写法指引(开书定盘/卷计划用)。 */
1459
+ template?: string
1460
+ /** 推进单位序列(每章如何推进,如「立威→打破质疑→扩大影响→碾压」)。 */
1461
+ progressionUnits?: string[]
1462
+ /** 允许出现的冲突形态。 */
1463
+ allowedConflictForms?: string[]
1464
+ /** 应避免的冲突形态(跑偏信号)。 */
1465
+ forbiddenConflictForms?: string[]
1466
+ /** 冲突烈度上限(low/medium/high),用于卷/章计划和审稿对齐。 */
1467
+ conflictCeiling?: 'low' | 'medium' | 'high'
1468
+ /** 单章推进单位说明。 */
1469
+ chapterUnit?: string
1470
+ /** 卷末应兑现的回报。 */
1471
+ volumeReward?: string
1472
+ /** 主驱动必须持续出现的信号(读者期待确认)。 */
1473
+ mandatorySignals?: string[]
1474
+ /** 反信号:出现即跑偏。 */
1475
+ antiSignals?: string[]
1476
+ /** 优先用的问题解决方式。 */
1477
+ resolutionStyle?: string
1478
+ }
1479
+
1480
+ /** 反 AI 规则:一条「要避免的问题 + 修正方向」。 */
1481
+ export interface AntiAiRule {
1482
+ /** 规则名(如「禁止解释型心理描写」「AI 高频套话」)。 */
1483
+ name: string
1484
+ /** 稳定标识(与 defaultAntiAiRuleKeys 交叉引用;缺省用 name)。 */
1485
+ key?: string
1486
+ /** 要避免的表达问题,具体可检查。 */
1487
+ avoid: string
1488
+ /** 推荐修正方向。 */
1489
+ fix: string
1490
+ /** 命中即告警的具体表达模式(用于审稿逐条核对与去 AI 味检测)。 */
1491
+ detectPatterns?: string[]
1492
+ /** 是否内置全局规则(内置规则随插件发布,项目规则为用户自定义)。 */
1493
+ builtin?: boolean
1494
+ /** 规则类别:forbidden=禁止类(命中即问题)/ risk=风险类(需注意但不硬伤)/ encourage=鼓励类(不命中不算错,只作建议)。 */
1495
+ severity?: 'forbidden' | 'risk' | 'encourage'
1496
+ /** 问题严重度(用于审稿优先级;缺省按类别推断)。 */
1497
+ riskLevel?: 'low' | 'medium' | 'high'
1498
+ /** 生成时直接注入的约束指令(缺失时回退到 avoid)。 */
1499
+ promptInstruction?: string
1500
+ /** 是否允许自动改写(risk 类通常 false)。 */
1501
+ autoRewrite?: boolean
1502
+ /** 是否为全局基线规则(新书默认启用,防止规则丢失后降级)。 */
1503
+ globalBaselineEnabled?: boolean
1504
+ /** 是否启用(缺省 true)。 */
1505
+ enabled?: boolean
1506
+ /** 作用域(缺省 all)。 */
1507
+ scope?: Array<'writing' | 'review' | 'polish' | 'all'>
1508
+ }
1509
+
1510
+ /** 预置写法模板(来自 AI-Novel-Writing-Assistant 内置数据,一键绑定无需样本文本)。 */
1511
+ export interface StyleTemplateNarrativeRules {
1512
+ progressionMode?: string
1513
+ sceneUnitPattern?: string[]
1514
+ multiPov?: boolean
1515
+ looping?: boolean
1516
+ endingStyle?: string
1517
+ povSwitchStyle?: string
1518
+ summary?: string
1519
+ }
1520
+
1521
+ export interface StyleTemplateCharacterRules {
1522
+ allowSelfReflection?: boolean
1523
+ emotionExpression?: string
1524
+ defenseMechanisms?: string[]
1525
+ facePriority?: boolean
1526
+ dialogueStyle?: string
1527
+ summary?: string
1528
+ }
1529
+
1530
+ export interface StyleTemplateLanguageRules {
1531
+ register?: string
1532
+ roughness?: number
1533
+ allowIncompleteSentences?: boolean
1534
+ allowSwearing?: boolean
1535
+ sentenceVariation?: string
1536
+ allowUselessDetails?: boolean
1537
+ summary?: string
1538
+ }
1539
+
1540
+ export interface StyleTemplateRhythmRules {
1541
+ pace?: string
1542
+ paragraphDensity?: string
1543
+ allowFragmentedFlow?: boolean
1544
+ actionOverExplanation?: boolean
1545
+ summary?: string
1546
+ }
1547
+
1548
+ export interface StyleTemplate {
1549
+ /** 模板 key(如 power-up-escalation)。 */
1550
+ key: string
1551
+ /** 模板名(如「爽文递进推进流」)。 */
1552
+ name: string
1553
+ /** 模板说明。 */
1554
+ description: string
1555
+ /** 分类(如「爽文流」「悬疑流」)。 */
1556
+ category: string
1557
+ /** 适用题材。 */
1558
+ applicableGenres: string[]
1559
+ /** 标签(便于筛选)。 */
1560
+ tags?: string[]
1561
+ /** 一句话分析(模板定位说明)。 */
1562
+ analysisMarkdown?: string
1563
+ /** 叙述规则(结构化)。 */
1564
+ narrative?: StyleTemplateNarrativeRules
1565
+ /** 角色规则(结构化)。 */
1566
+ character?: StyleTemplateCharacterRules
1567
+ /** 语言规则(结构化)。 */
1568
+ language?: StyleTemplateLanguageRules
1569
+ /** 节奏规则(结构化)。 */
1570
+ rhythm?: StyleTemplateRhythmRules
1571
+ /** 叙述规则(扁平,兼容旧数据)。 */
1572
+ proseRules: string[]
1573
+ /** 角色/台词规则(扁平,兼容旧数据)。 */
1574
+ dialogueRules: string[]
1575
+ /** 语言规则(扁平,兼容旧数据)。 */
1576
+ languageRules: string[]
1577
+ /** 节奏规则(扁平,兼容旧数据)。 */
1578
+ rhythmRules: string[]
1579
+ /** 该模板默认绑定的反 AI 规则 key(内置规则名)。 */
1580
+ defaultAntiAiRuleKeys: string[]
1581
+ }
1582
+
1583
+ /** 起始风格画像:无样本文本也能快速绑定一套写法(对齐上游 DEFAULT_STARTER_STYLE_PROFILES)。 */
1584
+ export interface StarterStyleProfile {
1585
+ /** stable key(如 starter-power-up)。 */
1586
+ key: string
1587
+ /** 绑定到的写法模板 key。 */
1588
+ templateKey: string
1589
+ /** 画像名。 */
1590
+ name: string
1591
+ /** 画像说明。 */
1592
+ description: string
1593
+ }
1594
+
1595
+ /** 剧情桥段库:可复用的情节套路/桥段(作者阅读经验沉淀,与书内 Plotline 不同层)。 */
1596
+ export interface PlotBeatTemplate {
1597
+ /** 模板 key(如 face-slap / exit-wedding)。 */
1598
+ key: string
1599
+ /** 桥段名(如「打脸」「退婚」)。 */
1600
+ name: string
1601
+ /** 分类(如「装逼打脸」「身份逆袭」)。 */
1602
+ category: string
1603
+ /** 一句话说明。 */
1604
+ summary: string
1605
+ /** 适用位置(开局/前期/中期/后期/高潮/结尾)。 */
1606
+ position: string
1607
+ /** 前置条件。 */
1608
+ preconditions: string[]
1609
+ /** 爽点来源。 */
1610
+ payoffSource: string[]
1611
+ /** 常用组合(可搭配的桥段)。 */
1612
+ combos: string[]
1613
+ /** 禁忌(别用烂/别用死)。 */
1614
+ taboos: string[]
1615
+ /** 适用题材。 */
1616
+ applicableGenres: string[]
1617
+ }
1618
+
1619
+ /** 写法引擎:从样本文本提取的叙事风格资产。 */
1620
+ export interface StyleAsset {
1621
+ /** 资产名(如「林越式痞坏」「冷峻猎手风」)。 */
1622
+ name: string
1623
+ /** 叙述视角与句式节奏。 */
1624
+ proseRules: string[]
1625
+ /** 角色台词风格。 */
1626
+ dialogueRules: string[]
1627
+ /** 描写密度与情绪表达。 */
1628
+ descriptionRules: string[]
1629
+ /** 表达边界(不要做什么)。 */
1630
+ boundaries: string[]
1631
+ /** 来源样本文本(可空)。 */
1632
+ sourceText?: string
1633
+ /** 仿写预设:imitate=高保真仿写 / balanced=平衡 / transfer=迁移(去指纹)。 */
1634
+ preset?: 'imitate' | 'balanced' | 'transfer'
1635
+ /** 指纹风险:仿写时照搬原作独特表达的风险。 */
1636
+ fingerprintRisk?: 'low' | 'medium' | 'high'
1637
+ /** 净化后的写作指引(可安全用于生成,去掉了会暴露来源的具体细节)。 */
1638
+ writingGuidance?: string[]
1639
+ /** 禁止照搬的原作特有实体(人名/地名/核心设定句式),生成时需避开。 */
1640
+ forbiddenEntities?: string[]
1641
+ /** 创建时间。 */
1642
+ createdAt: string
1643
+ }
1644
+
1645
+ /** 写作公式(从样本文本分层提取的"这套文怎么写"浓缩,供生成/改写复用)。 */
1646
+ export interface StyleFormula {
1647
+ /** 稳定 key。 */
1648
+ key: string
1649
+ /** 公式名。 */
1650
+ name: string
1651
+ /** 提取深度:basic=骨架 / standard=完整 / deep=逐句细化。 */
1652
+ depth: 'basic' | 'standard' | 'deep'
1653
+ /** 重点聚焦域(如 开场/对话/节奏/爽点密度)。 */
1654
+ focusAreas: string[]
1655
+ /** 公式正文(Markdown)。 */
1656
+ formula: string
1657
+ /** 应用指引(生成/改写时如何套用)。 */
1658
+ applyGuidance: string
1659
+ /** 创建时间。 */
1660
+ createdAt: string
1661
+ }
1662
+
1663
+ /** 项目写作资产(题材基底 + 推进模式 + 反 AI 规则 + 写法资产)。 */
1664
+ export interface ProjectAssets {
1665
+ /** 本书选用的题材(可以是题材基底库中某节点名)。 */
1666
+ genre?: GenreNode
1667
+ /** 主推进模式。 */
1668
+ primaryProgression?: ProgressionMode
1669
+ /** 辅助推进模式。 */
1670
+ auxiliaryProgressions: ProgressionMode[]
1671
+ /** 生效的反 AI 规则(内置 + 自定义)。 */
1672
+ antiAiRules: AntiAiRule[]
1673
+ /** 绑定的写法资产。 */
1674
+ styleAssets: StyleAsset[]
1675
+ /** 写作公式(分层提取:basic/standard/deep)。 */
1676
+ styleFormulas?: StyleFormula[]
1677
+ /** 资产更新时间。 */
1678
+ updatedAt?: string
1679
+ }
1680
+
1681
+ /** GET /assets response(含全局题材库与反 AI 规则库)。 */
1682
+ export interface AssetsResponse {
1683
+ projectAssets: ProjectAssets
1684
+ /** 全局题材基底库(可复用资产,跨书)。 */
1685
+ genreLibrary: GenreNode[]
1686
+ /** 全局反 AI 规则库(内置默认规则)。 */
1687
+ antiAiLibrary: AntiAiRule[]
1688
+ /** 预置写法模板(一键绑定,无需样本文本)。 */
1689
+ styleTemplates: StyleTemplate[]
1690
+ /** 内置推进模式候选。 */
1691
+ progressionLibrary: ProgressionMode[]
1692
+ /** 起始风格画像(无样本文本快速绑定写法)。 */
1693
+ starterStyleProfiles: StarterStyleProfile[]
1694
+ /** 内置剧情桥段库(可复用套路)。 */
1695
+ plotBeatLibrary: PlotBeatTemplate[]
1696
+ }
1697
+
1698
+ /** POST /assets request:更新项目写作资产(部分字段可选)。 */
1699
+ export interface AssetsPatch {
1700
+ genre?: GenreNode
1701
+ primaryProgression?: ProgressionMode
1702
+ auxiliaryProgressions?: ProgressionMode[]
1703
+ antiAiRules?: AntiAiRule[]
1704
+ styleAssets?: StyleAsset[]
1705
+ styleFormulas?: StyleFormula[]
1706
+ }
1707
+
1708
+ /** POST /style-engine request:从样本文本提取写法资产。 */
1709
+ export interface StyleEngineRequest {
1710
+ /** 样本文本(风格来源)。 */
1711
+ sampleText: string
1712
+ /** 资产名(可选,默认「风格资产 N」)。 */
1713
+ name?: string
1714
+ }
1715
+
1716
+ // ---------------------------------------------------------- author assets (总数据)
1717
+
1718
+ /** 作者资产库中一条可跨书复用的资产(笔法/红线/套路/角色模板/世界观模板等)。 */
1719
+ export interface AuthorStyleAsset {
1720
+ /** 稳定 id(本地唯一)。 */
1721
+ id: string
1722
+ /** 资产名(如「短句快节奏爽文风」「林越式痞坏角色」)。 */
1723
+ name: string
1724
+ /** 资产类型。 */
1725
+ kind: 'style' | 'antiAi' | 'progression' | 'genre' | 'roleTemplate' | 'worldTemplate' | 'plotBeat' | 'custom'
1726
+ /** 一句话摘要。 */
1727
+ summary: string
1728
+ /** 资产正文内容(按 kind 约定解读的文本/JSON 描述)。 */
1729
+ content: string
1730
+ /** 结构化载荷(角色模板/世界观模板等可结构化字段;缺省为 null)。 */
1731
+ structured?: Record<string, unknown>
1732
+ /** 来源书名(哪本书提炼/收藏而来)。 */
1733
+ sourceBooks: string[]
1734
+ /** 标签。 */
1735
+ tags: string[]
1736
+ /** 来源样本文本(可选)。 */
1737
+ sourceText?: string
1738
+ /** 创建时间。 */
1739
+ createdAt: string
1740
+ /** 更新时间。 */
1741
+ updatedAt: string
1742
+ }
1743
+
1744
+ /** 作者资产库(跨书总数据):按作者维度聚合的可复用资产。 */
1745
+ export interface AuthorAssetLibrary {
1746
+ /** 货架版本,便于未来迁移。 */
1747
+ version: 1
1748
+ items: AuthorStyleAsset[]
1749
+ }
1750
+
1751
+ /** GET /author-assets 响应。 */
1752
+ export interface AuthorAssetsResponse {
1753
+ assets: AuthorAssetLibrary
1754
+ }
1755
+
1756
+ /** POST /author-assets/upsert 请求:新增或按 id 更新一条资产。 */
1757
+ export interface AuthorAssetUpsertRequest {
1758
+ asset: AuthorStyleAsset
1759
+ }
1760
+
1761
+ /** POST /author-assets/remove 请求:删除一条资产。 */
1762
+ export interface AuthorAssetRemoveRequest {
1763
+ id: string
1764
+ }
1765
+
1766
+ // ---------------------------------------------------------- adaptation (改编模式)
1767
+
1768
+ /** 改编可改范围的单个维度(矩阵的一行)。 */
1769
+ export interface AdaptationDimension {
1770
+ /** 维度 key(如 realm/name/goldenFinger…)。 */
1771
+ key: string
1772
+ /** 维度名(如「大世界」「修为体系」「主角名」「金手指」)。 */
1773
+ title: string
1774
+ /** 可改度:保留 / 可改影响大 / 可改影响小 / 可自由改 / 仅视觉包装。 */
1775
+ mutability: 'locked' | 'big' | 'small' | 'free' | 'visual'
1776
+ /** 原文当前值(从正文提炼,附证据)。 */
1777
+ current: string
1778
+ /** 该值在正文中的出现证据(章节/频次,可空)。 */
1779
+ evidence?: string
1780
+ /** AI 建议的候选新值(可空,每套含名称与一句话说明)。 */
1781
+ candidates?: Array<{ name: string; desc?: string }>
1782
+ /** 联动影响说明(改了会影响哪些章节/角色/伏笔/术语)。 */
1783
+ impact: string
1784
+ /** 风险评级。 */
1785
+ risk: 'high' | 'medium' | 'low'
1786
+ }
1787
+
1788
+ /** POST /adapt/analyze 请求:上传全文做改编分析。 */
1789
+ export interface AdaptAnalyzeRequest {
1790
+ /** 全文文本(优先)。 */
1791
+ text: string
1792
+ /** 或服务器端全文文件路径。 */
1793
+ filePath?: string
1794
+ }
1795
+
1796
+ /** POST /adapt/analyze 响应。 */
1797
+ export interface AdaptAnalyzeResponse {
1798
+ /** 识别书名(文件名推断或正文首行)。 */
1799
+ bookName: string
1800
+ /** 拆出的章节数。 */
1801
+ chapters: number
1802
+ /** 反推的初始大纲(可空)。 */
1803
+ outline?: string
1804
+ /** 可改范围矩阵。 */
1805
+ dimensions: AdaptationDimension[]
1806
+ /** 分析消耗说明。 */
1807
+ note?: string
1808
+ }
1809
+
1810
+ /** 一条改编映射(原值 → 新值)。 */
1811
+ export interface AdaptationMapping {
1812
+ /** 原值(如「林尘」「练气」「青云宗」)。 */
1813
+ source: string
1814
+ /** 新值(如「楚风」「凝元」「天渊阁」)。 */
1815
+ target: string
1816
+ /** 适用范围。 */
1817
+ scope: 'name' | 'realm' | 'faction' | 'term' | 'other'
1818
+ /** 说明(可空)。 */
1819
+ note?: string
1820
+ }
1821
+
1822
+ /** 改编规则:哪些必须保留、哪些允许改、一致性约束。 */
1823
+ export interface AdaptationRules {
1824
+ /** 必须保留的要素(骨架/人物动机/伏笔逻辑/爽点结构…)。 */
1825
+ preserve: string[]
1826
+ /** 允许改变的要素。 */
1827
+ change: string[]
1828
+ /** 改编红线/一致性要求。 */
1829
+ constraints: string[]
1830
+ }
1831
+
1832
+ /** 一组改编方案(映射表 + 规则 + 联动影响清单)。 */
1833
+ export interface AdaptationProposal {
1834
+ /** 映射表(原→新)。 */
1835
+ mappings: AdaptationMapping[]
1836
+ /** 改编规则。 */
1837
+ rules: AdaptationRules
1838
+ /** 联动影响清单。 */
1839
+ impacts: Array<{ item: string; detail: string; risk: 'high' | 'medium' | 'low'; chapters?: number[] }>
1840
+ }
1841
+
1842
+ /** POST /adapt/propose 请求:由用户勾选的维度 + 新值生成改编方案。 */
1843
+ export interface AdaptProposeRequest {
1844
+ /** 原文全文(复用,便于 LLM 核对联动影响)。 */
1845
+ text: string
1846
+ /** 用户确认要改的维度(含原值与新值)。 */
1847
+ selections: Array<{ key: string; title: string; current: string; target: string; mutability: string }>
1848
+ /** 若已分析过,可携带完整矩阵作为上下文。 */
1849
+ dimensions?: AdaptationDimension[]
1850
+ }
1851
+
1852
+ /** POST /adapt/propose 响应。 */
1853
+ export interface AdaptProposeResponse {
1854
+ proposal: AdaptationProposal
1855
+ }
1856
+
1857
+ /** POST /adapt/execute 请求:执行改编(replace=术语替换;rewrite=逐章 LLM 重写)。 */
1858
+ export interface AdaptExecuteRequest {
1859
+ /** 原文全文。 */
1860
+ text: string
1861
+ /** 改编映射表。 */
1862
+ mappings: AdaptationMapping[]
1863
+ /** 改编规则(rewrite 模式生效:保留/允许变/红线)。 */
1864
+ rules?: AdaptationRules
1865
+ /** 执行模式:replace(术语替换)或 rewrite(逐章重写)。 */
1866
+ mode?: 'replace' | 'rewrite'
1867
+ /** rewrite 模式:只重写前 N 章(0/缺省 = 全部,且在 startNo/endNo 窗口内)。 */
1868
+ maxChapters?: number
1869
+ /** rewrite 模式:起始章号(含,默认 1)。 */
1870
+ startNo?: number
1871
+ /** rewrite 模式:结束章号(含;0/缺省 = 到全书末尾)。 */
1872
+ endNo?: number
1873
+ }
1874
+
1875
+ /** POST /adapt/execute 响应。 */
1876
+ export interface AdaptExecuteResponse {
1877
+ /** 改编后的全文。 */
1878
+ adaptedText: string
1879
+ /** 执行的映射数。 */
1880
+ mappings: number
1881
+ /** 命中统计:每条映射的替换次数。 */
1882
+ hits: Array<{ source: string; target: string; count: number }>
1883
+ /** 执行模式(replace / rewrite)。 */
1884
+ mode?: 'replace' | 'rewrite'
1885
+ /** rewrite 模式的逐章结果(no/title/chars)。 */
1886
+ rewritten?: Array<{ no: number; title: string; chars: number }>
1887
+ /** rewrite 模式下重写失败、保留原章的章节号。 */
1888
+ skipped?: number[]
1889
+ }
1890
+
1891
+ /** POST /adapt/rewrite-stream 的 NDJSON 帧(逐章进度 + 结束结果)。 */
1892
+ export type AdaptRewriteFrame =
1893
+ | { type: 'progress'; completed: number; total: number; no: number; title: string }
1894
+ | { type: 'done'; result: AdaptExecuteResponse }
1895
+ | { type: 'error'; message: string }
1896
+
1897
+ /** POST /adapt/save 请求:保存改编全文为新书(原书保留,登记书架)。 */
1898
+ export interface AdaptSaveRequest {
1899
+ /** 改编后的全文。 */
1900
+ text: string
1901
+ /** 新书名(缺省为「改编新书」;建议用「<原著>·改编版」)。 */
1902
+ bookName?: string
1903
+ /** 新书输出目录(缺省 ~/.dsh/novels/书名)。 */
1904
+ outputDir?: string
1905
+ /** 可附带反推大纲(写进新项目,便于后续续写/编辑)。 */
1906
+ outline?: string
1907
+ }
1908
+
1909
+ /** POST /adapt/save 响应。 */
1910
+ export interface AdaptSaveResponse {
1911
+ /** 登记后的书架条目。 */
1912
+ book: BookEntry
1913
+ /** 新书名。 */
1914
+ bookName: string
1915
+ /** 成功拆出的章节数。 */
1916
+ chapters: number
1917
+ /** 因内容过短被跳过的章节标题列表。 */
1918
+ skipped: string[]
1919
+ /** 新书输出目录。 */
1920
+ outputDir: string
1921
+ }
1922
+
1923
+ /** POST /adapt/materialize 请求:从源全文 + 用户编辑后的改编方案,提炼新书资料并保存为「待写新书」。 */
1924
+ export interface AdaptMaterializeRequest {
1925
+ /** 源书全文。 */
1926
+ text: string
1927
+ /** 新书名(缺省为「<源书名>·改编版」)。 */
1928
+ bookName?: string
1929
+ /** 新书输出目录(缺省 ~/.dsh/novels/书名)。 */
1930
+ outputDir?: string
1931
+ /** 反推大纲(来自分析;缺少时用源文章题兜底)。 */
1932
+ outline?: string
1933
+ /** 用户编辑后的改编方案(映射表 + 规则)。 */
1934
+ proposal: AdaptationProposal
1935
+ /** 拟规划章节数(缺省 30,可在前端调整)。 */
1936
+ chapterCount?: number
1937
+ }
1938
+
1939
+ /** POST /adapt/materialize 响应:提炼后的新书资料(预览,尚未落盘;保存走 /adapt/materialize-save)。 */
1940
+ export interface AdaptMaterializeResponse {
1941
+ /** 书架条目(仅在已保存时存在;预览阶段为 undefined)。 */
1942
+ book?: BookEntry
1943
+ /** 新书名。 */
1944
+ bookName: string
1945
+ /** 改编后总纲。 */
1946
+ outline: string
1947
+ /** 改编后道藏。 */
1948
+ bible: StoryBible
1949
+ /** 改编后角色库。 */
1950
+ roles: RoleRecord[]
1951
+ /** 改编后大世界。 */
1952
+ world: WorldState
1953
+ /** 改编后卷计划。 */
1954
+ volumes: Volume[]
1955
+ /** 改编后章节计划(status=pending)。 */
1956
+ chapters: ChapterPlan[]
1957
+ /** 新书输出目录。 */
1958
+ outputDir: string
1959
+ }
1960
+
1961
+ /** POST /adapt/materialize-save 请求:把预览/微调后的新书资料写入并登记书架。 */
1962
+ export interface AdaptMaterializeSaveRequest {
1963
+ /** 新书名(缺省为「改编版」)。 */
1964
+ bookName?: string
1965
+ /** 新书输出目录(缺省 ~/.dsh/novels/书名)。 */
1966
+ outputDir?: string
1967
+ /** 改编后总纲。 */
1968
+ outline: string
1969
+ /** 改编后道藏。 */
1970
+ bible: StoryBible
1971
+ /** 改编后角色库。 */
1972
+ roles: RoleRecord[]
1973
+ /** 改编后大世界。 */
1974
+ world: WorldState
1975
+ /** 改编后卷计划。 */
1976
+ volumes: Volume[]
1977
+ /** 改编后章节计划(status=pending)。 */
1978
+ chapters: ChapterPlan[]
1979
+ }
1980
+
1981
+ /** POST /adapt/materialize-save 响应。 */
1982
+ export interface AdaptMaterializeSaveResponse {
1983
+ /** 登记后的书架条目。 */
1984
+ book: BookEntry
1985
+ /** 新书名。 */
1986
+ bookName: string
1987
+ /** 成功写入的章节数。 */
1988
+ chapters: number
1989
+ /** 新书输出目录。 */
1990
+ outputDir: string
1991
+ }
1992
+
1993
+ /** POST /plugin/update 响应:插件自更新结果。 */
1994
+ export interface PluginUpdateResponse {
1995
+ ok: boolean
1996
+ /** 更新结果说明(成功/失败/环境提示)。 */
1997
+ message: string
1998
+ }