@waterwx/dsh-novel-forge 2.1.2-alpha → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +278 -368
- package/lib/client.js +19568 -21381
- package/lib/index.js +4850 -4002
- package/lib/types/action-guard.d.ts +61 -0
- package/lib/types/ai-scan.d.ts +66 -12
- package/lib/types/assets.d.ts +7 -9
- package/lib/types/assistant.d.ts +25 -0
- package/lib/types/author-assets.d.ts +1 -3
- package/lib/types/bookshelf.d.ts +13 -3
- package/lib/types/client/api.d.ts +49 -29
- package/lib/types/client/chip-prefs.d.ts +36 -0
- package/lib/types/client/docx.d.ts +2 -2
- package/lib/types/client/llmLive.d.ts +12 -14
- package/lib/types/client/locales.d.ts +12 -67
- package/lib/types/client/mount.d.ts +0 -2
- package/lib/types/client/panel/AdaptModeView.d.ts +1 -1
- package/lib/types/client/panel/AiTag.d.ts +1 -0
- package/lib/types/client/panel/AssetsTab.d.ts +1 -1
- package/lib/types/client/panel/AssistantTab.d.ts +4 -1
- package/lib/types/client/panel/AuthorAssetsView.d.ts +1 -1
- package/lib/types/client/panel/AuthorHome.d.ts +12 -12
- package/lib/types/client/panel/CmdPalette.d.ts +12 -0
- package/lib/types/client/panel/CreateBookView.d.ts +1 -1
- package/lib/types/client/panel/GlobalAssetLibraryView.d.ts +1 -1
- package/lib/types/client/panel/ImportModal.d.ts +1 -1
- package/lib/types/client/panel/LiveFeedLog.d.ts +8 -0
- package/lib/types/client/panel/ModelManager.d.ts +2 -2
- package/lib/types/client/panel/NovelPanel.d.ts +7 -2
- package/lib/types/client/panel/PageHeader.d.ts +18 -0
- package/lib/types/client/panel/ProgressConsole.d.ts +1 -1
- package/lib/types/client/panel/PromptSlotsView.d.ts +11 -0
- package/lib/types/client/panel/ReaderView.d.ts +1 -1
- package/lib/types/client/panel/RunPanel.d.ts +1 -1
- package/lib/types/client/panel/SettingsView.d.ts +13 -10
- package/lib/types/client/panel/ShelfView.d.ts +11 -2
- package/lib/types/client/panel/SubPage.d.ts +27 -0
- package/lib/types/client/panel/TensionView.d.ts +18 -0
- package/lib/types/client/panel/TimelineView.d.ts +18 -0
- package/lib/types/client/panel/WorldTab.d.ts +1 -1
- package/lib/types/client/panel/helpers.d.ts +5 -3
- package/lib/types/client/panel/market-radar-state.d.ts +56 -0
- package/lib/types/client/panel/outline-markdown.d.ts +112 -0
- package/lib/types/client/panel/status-badge.d.ts +13 -0
- package/lib/types/client/panel/storage-parse.d.ts +46 -0
- package/lib/types/client/panel/toast.d.ts +2 -0
- package/lib/types/client/panel/usePersistentState.d.ts +17 -0
- package/lib/types/client/panel/views.d.ts +21 -35
- package/lib/types/client/run-status.d.ts +21 -0
- package/lib/types/client/sidebar-entry.d.ts +0 -2
- package/lib/types/digest-parse.d.ts +29 -0
- package/lib/types/docx-core.d.ts +16 -0
- package/lib/types/docx.d.ts +2 -3
- package/lib/types/engine.d.ts +122 -103
- package/lib/types/home.d.ts +11 -0
- package/lib/types/index.d.ts +21 -13
- package/lib/types/llm-live.d.ts +62 -36
- package/lib/types/llm-retry.d.ts +38 -0
- package/lib/types/market-radar-scan.d.ts +0 -1
- package/lib/types/market-radar-sources.d.ts +1 -1
- package/lib/types/migrate-output.d.ts +25 -0
- package/lib/types/model-capability.d.ts +119 -0
- package/lib/types/model-request.d.ts +36 -0
- package/lib/types/output-budget.d.ts +86 -0
- package/lib/types/plotline-align.d.ts +35 -0
- package/lib/types/prompt-slots.d.ts +57 -0
- package/lib/types/prompting.d.ts +2 -27
- package/lib/types/protocol.d.ts +479 -595
- package/lib/types/revision.d.ts +76 -0
- package/lib/types/routes.d.ts +9 -3
- package/lib/types/run-selection.d.ts +51 -0
- package/lib/types/run.d.ts +31 -0
- package/lib/types/settings-persist.d.ts +59 -0
- package/lib/types/snapshots.d.ts +46 -0
- package/lib/types/stage-contract.d.ts +58 -0
- package/lib/types/stream-fallback.d.ts +60 -0
- package/lib/types/strip-headings.d.ts +33 -0
- package/lib/types/tension.d.ts +53 -0
- package/lib/types/timeline.d.ts +37 -0
- package/package.json +41 -28
- package/assets/styles/arcane-thick-3d.webp +0 -0
- package/assets/styles/chinese-ink.webp +0 -0
- package/assets/styles/clay-stopmotion-3d.webp +0 -0
- package/assets/styles/dark-ghibli.webp +0 -0
- package/assets/styles/dark-gothic-3d.webp +0 -0
- package/assets/styles/film-photo.webp +0 -0
- package/assets/styles/guofeng-heavy.webp +0 -0
- package/assets/styles/guoman-2d-gufeng.webp +0 -0
- package/assets/styles/guoman-3d-tianyuan.webp +0 -0
- package/assets/styles/guoman-3d-xuanhuan.webp +0 -0
- package/assets/styles/horror-game-3d.webp +0 -0
- package/assets/styles/hyperreal-3d.webp +0 -0
- package/assets/styles/japan-cel-dark.webp +0 -0
- package/assets/styles/korean-webtoon.webp +0 -0
- package/assets/styles/low-cyberpunk-3d.webp +0 -0
- package/assets/styles/nextgen-cg.webp +0 -0
- package/assets/styles/noir-film.webp +0 -0
- package/assets/styles/openworld-survival.webp +0 -0
- package/assets/styles/paper-cut-3d.webp +0 -0
- package/assets/styles/pixar-adult-3d.webp +0 -0
- package/assets/styles/pop-marvel-2d.webp +0 -0
- package/assets/styles/sandiao-qban.webp +0 -0
- package/assets/styles/shinkai-anime.webp +0 -0
- package/assets/styles/tactical-stealth.webp +0 -0
- package/assets/styles/urban-lightreal-3d.webp +0 -0
- package/assets/styles/vaporwave-3d.webp +0 -0
- package/assets/styles/vhs90.webp +0 -0
- package/lib/types/client/panel/BookshelfBar.d.ts +0 -11
- package/lib/types/client/panel/FlowGuide.d.ts +0 -22
- package/lib/types/client/panel/MangaRoleLibrary.d.ts +0 -20
- package/lib/types/client/panel/MangaWorkspace.d.ts +0 -12
- package/lib/types/client/panel/ModelPicker.d.ts +0 -11
- package/lib/types/client/panel/ProgressHomeView.d.ts +0 -5
- package/lib/types/client/panel/PropLibrary.d.ts +0 -8
- package/lib/types/client/panel/SceneLibrary.d.ts +0 -16
- package/lib/types/client/panel/StoryboardTab.d.ts +0 -19
- package/lib/types/client/panel/StyleCard.d.ts +0 -8
- package/lib/types/client/panel/StyleGallery.d.ts +0 -1
- package/lib/types/comic-presets.d.ts +0 -12
- package/lib/types/manga-genre-rules.d.ts +0 -22
- package/lib/types/prompt-utils.d.ts +0 -35
- package/lib/types/review-policy.d.ts +0 -97
- package/lib/types/shot-language.d.ts +0 -46
- package/lib/types/src/ai-scan.d.ts +0 -36
- package/lib/types/src/assets.d.ts +0 -37
- package/lib/types/src/assistant.d.ts +0 -45
- package/lib/types/src/author-assets.d.ts +0 -25
- package/lib/types/src/bookshelf.d.ts +0 -42
- package/lib/types/src/client/api.d.ts +0 -234
- package/lib/types/src/client/docx.d.ts +0 -15
- package/lib/types/src/client/index.d.ts +0 -14
- package/lib/types/src/client/locales.d.ts +0 -212
- package/lib/types/src/client/mount.d.ts +0 -9
- package/lib/types/src/client/panel/AdaptModeView.d.ts +0 -5
- package/lib/types/src/client/panel/AssetsTab.d.ts +0 -12
- package/lib/types/src/client/panel/AssistantTab.d.ts +0 -7
- package/lib/types/src/client/panel/AuthorAssetsView.d.ts +0 -4
- package/lib/types/src/client/panel/AuthorHome.d.ts +0 -32
- package/lib/types/src/client/panel/BookshelfBar.d.ts +0 -11
- package/lib/types/src/client/panel/CreateBookView.d.ts +0 -9
- package/lib/types/src/client/panel/FlowGuide.d.ts +0 -22
- package/lib/types/src/client/panel/GlobalAssetLibraryView.d.ts +0 -4
- package/lib/types/src/client/panel/ImportModal.d.ts +0 -7
- package/lib/types/src/client/panel/MangaRoleLibrary.d.ts +0 -20
- package/lib/types/src/client/panel/MangaWorkspace.d.ts +0 -12
- package/lib/types/src/client/panel/ModelManager.d.ts +0 -14
- package/lib/types/src/client/panel/NovelPanel.d.ts +0 -13
- package/lib/types/src/client/panel/ProgressConsole.d.ts +0 -17
- package/lib/types/src/client/panel/ProgressHomeView.d.ts +0 -5
- package/lib/types/src/client/panel/PropLibrary.d.ts +0 -8
- package/lib/types/src/client/panel/ReaderView.d.ts +0 -8
- package/lib/types/src/client/panel/ReasoningSection.d.ts +0 -10
- package/lib/types/src/client/panel/RunPanel.d.ts +0 -5
- package/lib/types/src/client/panel/SceneLibrary.d.ts +0 -16
- package/lib/types/src/client/panel/SettingsView.d.ts +0 -16
- package/lib/types/src/client/panel/ShelfView.d.ts +0 -15
- package/lib/types/src/client/panel/StoryboardTab.d.ts +0 -19
- package/lib/types/src/client/panel/StyleCard.d.ts +0 -8
- package/lib/types/src/client/panel/StyleGallery.d.ts +0 -1
- package/lib/types/src/client/panel/WorldTab.d.ts +0 -10
- package/lib/types/src/client/panel/controller.d.ts +0 -19
- package/lib/types/src/client/panel/helpers.d.ts +0 -18
- package/lib/types/src/client/panel/views.d.ts +0 -77
- package/lib/types/src/client/sidebar-entry.d.ts +0 -13
- package/lib/types/src/client/text.d.ts +0 -9
- package/lib/types/src/comic-presets.d.ts +0 -12
- package/lib/types/src/docx.d.ts +0 -19
- package/lib/types/src/engine.d.ts +0 -402
- package/lib/types/src/index.d.ts +0 -79
- package/lib/types/src/manga-genre-rules.d.ts +0 -22
- package/lib/types/src/novel-context.d.ts +0 -80
- package/lib/types/src/prompt-utils.d.ts +0 -35
- package/lib/types/src/protocol.d.ts +0 -2176
- package/lib/types/src/review-policy.d.ts +0 -97
- package/lib/types/src/routes.d.ts +0 -29
- package/lib/types/src/run.d.ts +0 -32
- package/lib/types/src/shot-language.d.ts +0 -46
- package/lib/types/src/story-beat-language.d.ts +0 -35
- package/lib/types/src/style-library.d.ts +0 -33
- package/lib/types/story-beat-language.d.ts +0 -35
- package/lib/types/style-library.d.ts +0 -33
- package/src/ai-scan.ts +0 -179
- package/src/assets.ts +0 -1774
- package/src/assistant.ts +0 -915
- package/src/author-assets.ts +0 -147
- package/src/bookshelf.ts +0 -167
- package/src/client/api.ts +0 -716
- package/src/client/css-modules.d.ts +0 -8
- package/src/client/docx.ts +0 -69
- package/src/client/index.ts +0 -34
- package/src/client/llmLive.ts +0 -101
- package/src/client/locales.ts +0 -418
- package/src/client/mount.tsx +0 -97
- package/src/client/mount.tsx._new +0 -97
- package/src/client/mount.tsx._nf +0 -97
- package/src/client/mount.tsx._tmp +0 -97
- package/src/client/panel/AdaptModeView.tsx +0 -535
- package/src/client/panel/AssetsTab.tsx +0 -458
- package/src/client/panel/AssistantTab.tsx +0 -339
- package/src/client/panel/AuthorAssetsView.tsx +0 -208
- package/src/client/panel/AuthorHome.tsx +0 -234
- package/src/client/panel/BookAnalysisView.tsx +0 -60
- package/src/client/panel/BookshelfBar.tsx +0 -170
- package/src/client/panel/CreateBookView.tsx +0 -371
- package/src/client/panel/DirectorView.tsx +0 -200
- package/src/client/panel/FlowGuide.tsx +0 -84
- package/src/client/panel/GlobalAssetLibraryView.tsx +0 -172
- package/src/client/panel/IdeaInspirationView.tsx +0 -71
- package/src/client/panel/ImportModal.tsx +0 -303
- package/src/client/panel/KnowledgeBaseView.tsx +0 -73
- package/src/client/panel/LiveFeedLog.tsx +0 -76
- package/src/client/panel/MangaRoleLibrary.tsx +0 -1002
- package/src/client/panel/MangaWorkspace.tsx +0 -715
- package/src/client/panel/MarketRadarView.tsx +0 -374
- package/src/client/panel/ModelManager.tsx +0 -205
- package/src/client/panel/NovelPanel.tsx +0 -4721
- package/src/client/panel/ProgressConsole.tsx +0 -63
- package/src/client/panel/ProgressHomeView.tsx +0 -87
- package/src/client/panel/PropLibrary.tsx +0 -175
- package/src/client/panel/ReaderView.tsx +0 -306
- package/src/client/panel/ReasoningSection.tsx +0 -31
- package/src/client/panel/RunPanel.tsx +0 -204
- package/src/client/panel/SceneLibrary.tsx +0 -453
- package/src/client/panel/SettingsView.tsx +0 -289
- package/src/client/panel/ShelfView.tsx +0 -242
- package/src/client/panel/StoryboardTab.tsx +0 -472
- package/src/client/panel/StyleCard.tsx +0 -90
- package/src/client/panel/StyleGallery.tsx +0 -58
- package/src/client/panel/WorldTab.tsx +0 -202
- package/src/client/panel/controller.ts +0 -45
- package/src/client/panel/helpers.ts +0 -67
- package/src/client/panel/panel.module.css +0 -4359
- package/src/client/panel/views.tsx +0 -314
- package/src/client/sidebar-entry.ts +0 -122
- package/src/client/text.ts +0 -28
- package/src/comic-presets.ts +0 -67
- package/src/docx.ts +0 -83
- package/src/engine.ts +0 -5636
- package/src/global-assets.ts +0 -59
- package/src/index.ts +0 -346
- package/src/llm-live.ts +0 -68
- package/src/manga-genre-rules.ts +0 -87
- package/src/market-radar-scan.ts +0 -41
- package/src/market-radar-sources.ts +0 -173
- package/src/novel-context.ts +0 -287
- package/src/prompt-utils.ts +0 -73
- package/src/prompting.ts +0 -159
- package/src/protocol.ts +0 -2565
- package/src/review-policy.ts +0 -161
- package/src/routes.ts +0 -3939
- package/src/run.ts +0 -338
- package/src/shot-language.ts +0 -181
- package/src/story-beat-language.ts +0 -130
- package/src/style-library.ts +0 -84
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 动作失败分级(fail-stop 规则)——不依赖 LLM/宿主服务的纯逻辑模块,可离线单测。
|
|
3
|
+
*
|
|
4
|
+
* 规则来源(借鉴同类 DSH 小说插件的规则设计):
|
|
5
|
+
* - 参数/契约类失败**不得重复同一调用**,解释一次即停;
|
|
6
|
+
* - 瞬时故障允许有限重试,同样禁止无限重试。
|
|
7
|
+
* 规则必须可测试,否则只是文档。
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* 动作失败分级:
|
|
11
|
+
* - `contract` 参数/契约类(参数缺失、片段未找到、章节不存在、非法取值…):
|
|
12
|
+
* 同一调用只允许修正一次,禁止原样重复。
|
|
13
|
+
* - `transient` 瞬时故障(网络、模型中断、磁盘临时不可用…):允许重试一次。
|
|
14
|
+
*/
|
|
15
|
+
export type ActionErrorKind = 'contract' | 'transient';
|
|
16
|
+
/** 带分级的动作失败(executeAction 抛出,供 fail-stop 判定)。 */
|
|
17
|
+
export declare class NovelActionError extends Error {
|
|
18
|
+
readonly kind: ActionErrorKind;
|
|
19
|
+
constructor(kind: ActionErrorKind, message: string);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* 判定一次动作失败的类别。
|
|
23
|
+
*
|
|
24
|
+
* @param error 捕获到的异常。
|
|
25
|
+
* @returns `contract`(参数/契约,不重试原样调用)或 `transient`(瞬时,可重试一次)。
|
|
26
|
+
*/
|
|
27
|
+
export declare function classifyActionError(error: unknown): ActionErrorKind;
|
|
28
|
+
/**
|
|
29
|
+
* 同一调用签名允许的总尝试次数(含首次)。
|
|
30
|
+
*
|
|
31
|
+
* @param kind 失败类别。
|
|
32
|
+
* @returns `contract` = 1(禁止原样重复),`transient` = 2(允许一次重试)。
|
|
33
|
+
*/
|
|
34
|
+
export declare function actionRetryLimit(kind: ActionErrorKind): number;
|
|
35
|
+
/**
|
|
36
|
+
* 把动作参数规范化为稳定签名(键排序),用于识别「同一个调用」。
|
|
37
|
+
*
|
|
38
|
+
* @param args 动作参数。
|
|
39
|
+
* @returns 稳定字符串签名。
|
|
40
|
+
*/
|
|
41
|
+
export declare function safeArgsKey(args: Record<string, unknown> | undefined): string;
|
|
42
|
+
/**
|
|
43
|
+
* 已失败调用记账:同一签名达到重试上限即 fail-stop。
|
|
44
|
+
*/
|
|
45
|
+
export declare class FailureLedger {
|
|
46
|
+
private readonly counts;
|
|
47
|
+
/**
|
|
48
|
+
* 记录一次失败并判断是否应当停止本轮。
|
|
49
|
+
*
|
|
50
|
+
* @param tool 工具名。
|
|
51
|
+
* @param args 该次调用参数。
|
|
52
|
+
* @param kind 失败类别。
|
|
53
|
+
* @returns `attempts` 本次是第几次失败;`stop` 是否达到上限(true = 立即停止,不再喂回模型)。
|
|
54
|
+
*/
|
|
55
|
+
record(tool: string, args: Record<string, unknown> | undefined, kind: ActionErrorKind): {
|
|
56
|
+
attempts: number;
|
|
57
|
+
stop: boolean;
|
|
58
|
+
};
|
|
59
|
+
/** 已登记的失败签名数量(测试/诊断用)。 */
|
|
60
|
+
get size(): number;
|
|
61
|
+
}
|
package/lib/types/ai-scan.d.ts
CHANGED
|
@@ -3,34 +3,88 @@
|
|
|
3
3
|
*
|
|
4
4
|
* 用途:生成/润色后自动扫描,结果作为「事实锚点」注入审稿提示词,
|
|
5
5
|
* 让 LLM 做判断而非机械统计。也可用于 UI 展示 AI 味指标。
|
|
6
|
+
*
|
|
7
|
+
* ## 度量口径
|
|
8
|
+
*
|
|
9
|
+
* 下面五条口径全部用 **1279 章 / 6 本已发布书稿**实测标定过。前两条是**已修复的
|
|
10
|
+
* 真实缺陷**(不是调参偏好),后三条是把不可比的量纲换成可比的。
|
|
11
|
+
*
|
|
12
|
+
* 1. **段落**:书稿正文的自然段由**单换行**分隔(run.ts 写盘即如此),历史实现按
|
|
13
|
+
* /\n{2,}/ 切 —— 在真实书稿上整章只切出 **2 段**(1279 章无一例外),于是段落方差、
|
|
14
|
+
* 过长段、连续解说段三项指标全部失效,其中「连续解说段 >= 3」永不成立。
|
|
15
|
+
* 现按 /\n+/ 切,并剔除 # 标题行。实测每章 p50 = 68 段,段落均长 p50 = 50 字。
|
|
16
|
+
* 2. **对话**:中文书稿主流用全角弯引号(语料 6 本里 **5 本**如此:番茄线上正文、
|
|
17
|
+
* 还债疯了、我养的废柴师妹、归墟玉主、保质期),历史实现的字符类只认 ASCII 双引号
|
|
18
|
+
* 与角括号,使这 5 本的对话占比**恒为 0**,并因此每章误加 10 分。
|
|
19
|
+
* 3. **段落整齐度**:用变异系数 CV = sigma / mean,不用方差 —— 方差的量纲是「字符平方」,
|
|
20
|
+
* 随段长平方缩放,段落均长 50 与均长 500 的章用同一个绝对阈值不可比。
|
|
21
|
+
* 语料 CV:p5 0.55 / p50 0.69 / p95 0.87。
|
|
22
|
+
* 4. **套话按稀有度加权**:历史实现把「重度 / 轻度」两档等同计分,而实测「知道」覆盖
|
|
23
|
+
* 78.4% 的已发布章节、「微微」48.2%,「难以言喻」0.0%、「不由得」0.1%。把前者与后者
|
|
24
|
+
* 等同,会让所有正常章节的基线虚高。现按相对语料的覆盖率给权重(见 PATTERN_COVERAGE)。
|
|
25
|
+
* 5. **短章不再爆炸**:密度分母取 max(字数, 2000) —— 历史实现里同样「1 次套话」,在
|
|
26
|
+
* 444 字的章值 18 分、在 3576 字的章值 2.2 分,同一现象 8 倍权重差。
|
|
27
|
+
*
|
|
28
|
+
* 分项满分与语料分位点的对应关系集中在 {@link SCORE_SPEC},便于日后重新标定。
|
|
6
29
|
*/
|
|
7
30
|
export interface AiScanResult {
|
|
8
31
|
/** 总评分 0-100,越高越像 AI 写的 */
|
|
9
32
|
aiScore: number;
|
|
10
|
-
/**
|
|
33
|
+
/** 命中的套话及次数(weight 为该词按语料稀有度折算的权重,0 = 功能词) */
|
|
11
34
|
clicheHits: Array<{
|
|
12
35
|
word: string;
|
|
13
36
|
count: number;
|
|
37
|
+
weight: number;
|
|
14
38
|
}>;
|
|
15
|
-
/**
|
|
39
|
+
/** 判定用的自然段数(口径可自查:真实书稿每章数十段) */
|
|
40
|
+
paragraphCount: number;
|
|
41
|
+
/** 段落长度方差(保留原字段,注意其量纲随段长平方缩放,判定请用 cv) */
|
|
16
42
|
paragraphLengthVariance: number;
|
|
17
|
-
/**
|
|
43
|
+
/** 段落长度变异系数 sigma / mean:与段长规模无关,整齐度判定用这个 */
|
|
44
|
+
paragraphLengthCv: number;
|
|
45
|
+
/** 连续解释性叙事段数(>=3 视为问题) */
|
|
18
46
|
consecutiveExpositoryParagraphs: number;
|
|
19
47
|
/** 句式重复率(相同开头句式占比) */
|
|
20
48
|
sentenceRepetitionRate: number;
|
|
21
|
-
/** 过长段落数(>300字) */
|
|
49
|
+
/** 过长段落数(>300 字) */
|
|
22
50
|
longParagraphCount: number;
|
|
23
|
-
/** 过短段落数(<20字) */
|
|
51
|
+
/** 过短段落数(<20 字) */
|
|
24
52
|
shortParagraphCount: number;
|
|
25
53
|
/** 对话占比(0-1) */
|
|
26
54
|
dialogueRatio: number;
|
|
55
|
+
/** 作者生效规则里的确定性命中(按规则逐条统计;未传规则时为空) */
|
|
56
|
+
ruleHits: AiScanRuleHit[];
|
|
57
|
+
/** 各分项得分:便于自查「这章凭什么这么多分」,也是标定与单测的抓手 */
|
|
58
|
+
scoreParts: AiScanScoreParts;
|
|
27
59
|
/** 问题摘要,可直接注入审稿提示词 */
|
|
28
60
|
summary: string;
|
|
29
61
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
62
|
+
/** 评分分项(每项满分与语料分位点的对应见 SCORE_SPEC)。 */
|
|
63
|
+
export interface AiScanScoreParts {
|
|
64
|
+
/** 套话/模式:满分对应语料加权密度 p99(2.478/千字,63 模式并集口径) */
|
|
65
|
+
cliche: number;
|
|
66
|
+
/** 段落过于整齐(CV 低于语料 p5) */
|
|
67
|
+
uniformParagraphs: number;
|
|
68
|
+
/** 连续解释性叙事 */
|
|
69
|
+
expository: number;
|
|
70
|
+
/** 句首重复率(零点取语料 p50 = 0.37,满分取 p99 = 0.63) */
|
|
71
|
+
repetition: number;
|
|
72
|
+
/** 对话占比过低 */
|
|
73
|
+
lowDialogue: number;
|
|
74
|
+
}
|
|
75
|
+
/** 扫描器需要的规则输入(结构类型,避免 ai-scan 反向依赖协议层)。 */
|
|
76
|
+
export interface AiScanRuleInput {
|
|
77
|
+
name: string;
|
|
78
|
+
severity?: 'forbidden' | 'risk' | 'encourage';
|
|
79
|
+
detectPatterns?: readonly string[];
|
|
80
|
+
}
|
|
81
|
+
/** 一条规则在本章的确定性命中(只报命中的规则)。 */
|
|
82
|
+
export interface AiScanRuleHit {
|
|
83
|
+
name: string;
|
|
84
|
+
severity?: 'forbidden' | 'risk' | 'encourage';
|
|
85
|
+
matches: Array<{
|
|
86
|
+
pattern: string;
|
|
87
|
+
count: number;
|
|
88
|
+
}>;
|
|
89
|
+
}
|
|
90
|
+
export declare function scanAiFlavor(text: string, rules?: readonly AiScanRuleInput[]): AiScanResult;
|
package/lib/types/assets.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Writing assets — 题材基底库 / 推进模式库 / 反 AI 规则 / 写法引擎.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* - 8
|
|
6
|
-
* - 12
|
|
7
|
-
* -
|
|
4
|
+
* 内置种子数据(本项目自研表述;结构参考了同类工具的功能划分):
|
|
5
|
+
* - 8 套预置叙事风格模板
|
|
6
|
+
* - 12 条带命中模式的反 AI 规则
|
|
7
|
+
* - 题材树 + 推进模式种子
|
|
8
8
|
* Assets persist with the project (novel-project.json) and are injected into
|
|
9
9
|
* generation / planning / review prompts, and available to the AI assistant.
|
|
10
10
|
*/
|
|
11
11
|
import type { AntiAiRule, GenreNode, PlotBeatTemplate, ProgressionMode, ProjectAssets, StarterStyleProfile, StyleAsset, StyleTemplate } from './protocol.ts';
|
|
12
|
-
/**
|
|
12
|
+
/** 预置叙事风格模板(8 套,一键绑定无需样本文本)。 */
|
|
13
13
|
export declare const BUILTIN_STYLE_TEMPLATES: StyleTemplate[];
|
|
14
|
-
/** 内置全局反 AI
|
|
14
|
+
/** 内置全局反 AI 规则(12 条,随插件发布;项目可叠加自定义规则)。 */
|
|
15
15
|
export declare const BUILTIN_ANTI_AI_RULES: AntiAiRule[];
|
|
16
16
|
/** 内置题材基底库(常用网文题材树,跨书复用)。 */
|
|
17
17
|
export declare const BUILTIN_GENRE_LIBRARY: GenreNode[];
|
|
@@ -23,8 +23,6 @@ export declare const BUILTIN_PLOT_BEATS: PlotBeatTemplate[];
|
|
|
23
23
|
export declare function emptyProjectAssets(): ProjectAssets;
|
|
24
24
|
/** 合并项目资产与内置库:返回「生效的反 AI 规则」(内置全局 + 项目自定义)。 */
|
|
25
25
|
export declare function effectiveAntiAiRules(assets: ProjectAssets | undefined): AntiAiRule[];
|
|
26
|
-
/** 安定 key:内置规则全局基线(globalBaselineEnabled)在新书/旧书一律生效。 */
|
|
27
|
-
export declare function ensureGlobalBaseline(assets: ProjectAssets | undefined): ProjectAssets;
|
|
28
26
|
/** 内置库种子化 upsert(对齐上游 SystemResourceBootstrapService 精神)。
|
|
29
27
|
* missing_only 仅补齐缺失的全局基线规则;sync_existing 还会按 key 刷新已内置规则的结构化字段。 */
|
|
30
28
|
export declare function ensureBuiltinAssets(assets: ProjectAssets | undefined, mode?: 'missing_only' | 'sync_existing'): ProjectAssets;
|
|
@@ -38,7 +36,7 @@ export declare function renderStyleAssets(assets: ProjectAssets | undefined): st
|
|
|
38
36
|
export declare function renderAllAssets(assets: ProjectAssets | undefined): string;
|
|
39
37
|
/** 预置写法模板 → 可直接绑定的 StyleAsset。 */
|
|
40
38
|
export declare function styleTemplateToAsset(template: StyleTemplate): StyleAsset;
|
|
41
|
-
/**
|
|
39
|
+
/** 起始风格画像库:无样本文本也能快速绑定一套写法(4 档起步写法)。 */
|
|
42
40
|
export declare const BUILTIN_STARTER_STYLE_PROFILES: StarterStyleProfile[];
|
|
43
41
|
/** 起始风格画像 → 可直接绑定的 StyleAsset(绑定对应模板,名称用画像名)。 */
|
|
44
42
|
export declare function starterProfileToAsset(profile: StarterStyleProfile): StyleAsset | null;
|
package/lib/types/assistant.d.ts
CHANGED
|
@@ -15,8 +15,33 @@
|
|
|
15
15
|
import type { Context } from '@deepseek-ai/cordis';
|
|
16
16
|
import type { AssistantMessage, NovelConfig, ProjectState } from './protocol.ts';
|
|
17
17
|
import { chapterFileName } from './engine.ts';
|
|
18
|
+
import { type BookStage } from './stage-contract.ts';
|
|
18
19
|
/** History file name inside the output dir. */
|
|
19
20
|
export declare const ASSISTANT_HISTORY_FILE = "novel-assistant.jsonl";
|
|
21
|
+
/**
|
|
22
|
+
* 按阶段渲染动作说明书。
|
|
23
|
+
*
|
|
24
|
+
* - `strict=false`(作者点明了要做什么):全量说明书照给,只靠动作可见性段提示
|
|
25
|
+
* 哪些属于阶段外——作者有权指定任意动作。
|
|
26
|
+
* - `strict=true`(作者只说「继续/下一步」):阶段外的写操作说明书直接**从提示词里移除**,
|
|
27
|
+
* 和执行层的阶段白名单完全一致,模型不再有机会去试错撞守卫。
|
|
28
|
+
*
|
|
29
|
+
* @param docs 动作说明书行。
|
|
30
|
+
* @param stage 阶段契约。
|
|
31
|
+
* @param strict 是否为「阶段即唯一命令」模式。
|
|
32
|
+
* @returns 裁剪后的说明书行。
|
|
33
|
+
*/
|
|
34
|
+
export declare function renderToolDocs(docs: readonly string[], stage: BookStage, strict: boolean): string[];
|
|
35
|
+
/**
|
|
36
|
+
* 渲染「动作可见性」:把写操作分成「本阶段可用」与「阶段外(仅作者点名时执行)」,
|
|
37
|
+
* 让模型不必靠试错去发现哪些动作会被拒绝。
|
|
38
|
+
*
|
|
39
|
+
* @param stage 阶段契约。
|
|
40
|
+
* @returns 多行文本。
|
|
41
|
+
*/
|
|
42
|
+
export declare function renderActionVisibility(stage: BookStage): string;
|
|
43
|
+
export { classifyActionError, actionRetryLimit, safeArgsKey, NovelActionError, FailureLedger } from './action-guard.ts';
|
|
44
|
+
export type { ActionErrorKind } from './action-guard.ts';
|
|
20
45
|
/** Load the persisted conversation (empty when none). */
|
|
21
46
|
export declare function loadAssistantHistory(outputDir: string): AssistantMessage[];
|
|
22
47
|
/** 清空助手对话记录(删除历史文件)。 */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 作者资产库/总数据(跨书)— 按作者维度聚合的可复用资产。
|
|
3
|
-
* 与书架同惯例持久化到
|
|
3
|
+
* 与书架同惯例持久化到 <DSH_HOME>/dsh-novel-forge-author-assets.json。
|
|
4
4
|
* 提供读取/持久化/新增或更新/删除,以及「导入默认」:把书架书的写作资产/角色 +
|
|
5
5
|
* 内置全局库(题材/反AI规则/风格模板/推进模式)批量沉淀成资产条目(默认库)。
|
|
6
6
|
*/
|
|
@@ -11,8 +11,6 @@ export declare function authorAssetsFile(): string;
|
|
|
11
11
|
export declare function loadAuthorAssets(): AuthorAssetLibrary;
|
|
12
12
|
/** 持久化作者资产库。 */
|
|
13
13
|
export declare function saveAuthorAssets(library: AuthorAssetLibrary): void;
|
|
14
|
-
/** 新建一条资产(自动生成 id 与时间戳)。 */
|
|
15
|
-
export declare function createAuthorAsset(input: Omit<AuthorStyleAsset, 'id' | 'createdAt' | 'updatedAt'>): AuthorStyleAsset;
|
|
16
14
|
/** 按 id 更新一条资产;不存在则追加。 */
|
|
17
15
|
export declare function upsertAuthorAsset(input: AuthorStyleAsset): AuthorAssetLibrary;
|
|
18
16
|
/** 删除一条资产;返回更新后的资产库。 */
|
package/lib/types/bookshelf.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 书架(Bookshelf)— 多书管理:一本书记录一个独立输出目录。
|
|
3
|
-
* 状态持久化到
|
|
3
|
+
* 状态持久化到 <DSH_HOME>/dsh-novel-forge-bookshelf.json(跟随 dsh 配置惯例)。
|
|
4
4
|
*/
|
|
5
5
|
import type { BookEntry, BookshelfSnapshot } from './protocol.ts';
|
|
6
6
|
/** 书架配置文件路径。 */
|
|
@@ -37,6 +37,16 @@ export declare function activateBook(id: string): BookEntry | undefined;
|
|
|
37
37
|
export declare function removeBook(id: string): boolean;
|
|
38
38
|
/** 当前书输出目录(无书架则 undefined,回退 settings)。 */
|
|
39
39
|
export declare function activeBookOutputDir(): string | undefined;
|
|
40
|
-
/**
|
|
41
|
-
|
|
40
|
+
/**
|
|
41
|
+
* 书目录重指向:把 outputDir 等于 from 的书条目全部改为 to(目录迁移联动)。
|
|
42
|
+
* @returns 重指向的条目数。
|
|
43
|
+
*/
|
|
44
|
+
export declare function repointBookDirs(from: string, to: string): number;
|
|
45
|
+
/**
|
|
46
|
+
* 新书默认输出目录:`<配置的输出目录>/书名`;未配置时回退 `<DSH_HOME>/novels/书名`。
|
|
47
|
+
* @param bookName - 书名(剔除文件系统非法字符并截断到 40 字)。
|
|
48
|
+
* @param baseDir - settings 里配置的输出目录(未经激活书合并的原始值)。
|
|
49
|
+
* @returns 该书应写入的绝对目录。
|
|
50
|
+
*/
|
|
51
|
+
export declare function defaultOutputDirFor(bookName: string, baseDir?: string): string;
|
|
42
52
|
export {};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* fetch, same origin; generation/rewrite/polish ride NDJSON streams read
|
|
4
4
|
* incrementally.
|
|
5
5
|
*/
|
|
6
|
-
import { type AssetsPatch, type AssetsResponse, type AddModelRequest, type AddModelResponse, type LlmModelsResponse, type LlmProvidersResponse, type LlmVendorsResponse, type RemoveProviderRequest, type RemoveProviderResponse, type BibleResponse, type ChapterResponse, type ConfigPatch, type ExportResponse, type ForeshadowRequest, type ForeshadowResponse, type JobFrame, type LoadOutlineResponse, type AdaptExecuteRequest, type AdaptRewriteFrame, type AdaptMaterializeSaveRequest, type AdaptMaterializeSaveResponse, type PluginUpdateResponse, type LlmTestResponse, type NovelConfig, type PlanResponse, type ReviewReport, type StatusResponse, type StyleEngineRequest, type StyleAsset, type VolumesResponse } from '../protocol.ts';
|
|
6
|
+
import { type AssetsPatch, type AssetsResponse, type AddModelRequest, type AddModelResponse, type LlmModelsResponse, type LlmProvidersResponse, type LlmVendorsResponse, type RemoveProviderRequest, type RemoveProviderResponse, type BibleResponse, type ChapterResponse, type ConfigPatch, type ExportResponse, type ForeshadowRequest, type ForeshadowResponse, type JobFrame, type LoadOutlineResponse, type AdaptExecuteRequest, type AdaptRewriteFrame, type AdaptMaterializeSaveRequest, type AdaptMaterializeSaveResponse, type PluginUpdateResponse, type LlmTestResponse, type NovelConfig, type PlanResponse, type ReviewReport, type RevisionPlanResponse, type StatusResponse, type StyleEngineRequest, type StyleAsset, type VolumesResponse } from '../protocol.ts';
|
|
7
7
|
/** Error carrying the route's JSON error message. */
|
|
8
8
|
export declare class NovelApiError extends Error {
|
|
9
9
|
constructor(message: string);
|
|
@@ -19,14 +19,6 @@ export declare class NovelApi {
|
|
|
19
19
|
}>;
|
|
20
20
|
/** 反推大纲:从已写章节正文反向生成全书总纲(NDJSON 流)。 */
|
|
21
21
|
outlineReverse(onFrame: (frame: JobFrame) => void): Promise<void>;
|
|
22
|
-
/** 分镜·导演级:骨架 → 分镜表(镜头级)。 */
|
|
23
|
-
storyboardTable(chapterNo: number, skeleton: import('../protocol.ts').StoryboardSkeleton, styleId?: string, filterId?: string): Promise<import('../protocol.ts').StoryboardTableResponse>;
|
|
24
|
-
/** 漫剧方案管理:create / remove / activate。 */
|
|
25
|
-
manhuaPlans(req: import('../protocol.ts').MangaPlansRequest): Promise<import('../protocol.ts').MangaPlansResponse>;
|
|
26
|
-
/** 分镜·提示词级:分镜表 → 即梦可粘贴视频提示词。 */
|
|
27
|
-
storyboardPrompts(chapterNo: number, table: import('../protocol.ts').StoryboardTable, styleId?: string, filterId?: string): Promise<import('../protocol.ts').StoryboardPromptsResponse>;
|
|
28
|
-
/** 分镜·编剧级:单章 → 剧情骨架(节拍链)。 */
|
|
29
|
-
storyboardSkeleton(chapterNo: number): Promise<import('../protocol.ts').StoryboardSkeletonResponse>;
|
|
30
22
|
/** 开书想法 → AI 大纲:生成 count 个方案(换批时传 exclude 避开已暂留方向)。 */
|
|
31
23
|
outlineSuggest(idea: string, count?: number, exclude?: string[]): Promise<import('../protocol.ts').OutlineSuggestResponse>;
|
|
32
24
|
/** 拆书分析:对已写章节做结构/人物/文风/卖点体检。 */
|
|
@@ -41,17 +33,30 @@ export declare class NovelApi {
|
|
|
41
33
|
summary: string;
|
|
42
34
|
}>;
|
|
43
35
|
foreshadow(req: ForeshadowRequest): Promise<ForeshadowResponse>;
|
|
44
|
-
exportBook(format: 'txt' | 'md'): Promise<ExportResponse>;
|
|
36
|
+
exportBook(format: 'txt' | 'md' | 'json', scope?: import('../protocol.ts').ExportScope): Promise<ExportResponse>;
|
|
45
37
|
chapter(no: number): Promise<ChapterResponse>;
|
|
46
38
|
/** 审查手动编辑的正文(不落盘)。previousReport 传入时走「验证模式」(核对原意见解决 + 只挑新增 high)。 */
|
|
47
39
|
chapterCheck(no: number, text: string, previousReport?: ReviewReport): Promise<{
|
|
48
40
|
report: ReviewReport;
|
|
49
41
|
}>;
|
|
42
|
+
/**
|
|
43
|
+
* 修订指令合并:把本章的审稿意见(勾选项)+ 时间线矛盾 + 张力偏差合成**一份**指令。
|
|
44
|
+
* 面板所有「按意见修订 / 一键按建议修订」入口都先走这里,保证同一章只改一轮。
|
|
45
|
+
*/
|
|
46
|
+
revisionPlan(no: number, reviewIssues?: ReviewReport['issues'], opts?: {
|
|
47
|
+
includeTimeline?: boolean;
|
|
48
|
+
includeTension?: boolean;
|
|
49
|
+
}): Promise<RevisionPlanResponse>;
|
|
50
50
|
/** 保存手动编辑的正文(自动备份 .bak;带报告则沿用落盘,否则保存后自动审稿)。 */
|
|
51
51
|
chapterSave(no: number, text: string, report?: ReviewReport): Promise<import('../protocol.ts').ChapterSaveResponse>;
|
|
52
52
|
patchConfig(patch: ConfigPatch): Promise<{
|
|
53
53
|
config: NovelConfig;
|
|
54
|
+
settingsWarning?: string;
|
|
54
55
|
}>;
|
|
56
|
+
/** 输出目录迁移:dryRun=true 仅预览目录内容;确认时传 to 搬迁。 */
|
|
57
|
+
moveOutputDir(to?: string, dryRun?: boolean): Promise<import('../protocol.ts').MoveOutputDirResponse>;
|
|
58
|
+
/** 本书参数:不带 patch 读取;带 patch 合并保存(字段传 null = 回退全局)。 */
|
|
59
|
+
bookSettings(patch?: Record<string, unknown>): Promise<import('../protocol.ts').BookSettingsResponse>;
|
|
55
60
|
openFolder(): Promise<void>;
|
|
56
61
|
/** 插件自更新:在 DSH profile 目录拉取最新 npm 版(需重启 DSH 生效)。 */
|
|
57
62
|
pluginUpdate(): Promise<PluginUpdateResponse>;
|
|
@@ -122,11 +127,11 @@ export declare class NovelApi {
|
|
|
122
127
|
}): Promise<{
|
|
123
128
|
result: import('../protocol.ts').IdeaInspirationResult;
|
|
124
129
|
}>;
|
|
125
|
-
/**
|
|
130
|
+
/** 自动编辑编排建议:基于全书上下文。 */
|
|
126
131
|
director(focus?: string): Promise<{
|
|
127
132
|
result: import('../protocol.ts').DirectorAdvice;
|
|
128
133
|
}>;
|
|
129
|
-
/**
|
|
134
|
+
/** 自动编辑「采纳」出的书内待办:读取。 */
|
|
130
135
|
directorTodosList(): Promise<{
|
|
131
136
|
todos: import('../protocol.ts').DirectorTodo[];
|
|
132
137
|
}>;
|
|
@@ -188,8 +193,6 @@ export declare class NovelApi {
|
|
|
188
193
|
ok: boolean;
|
|
189
194
|
no: number;
|
|
190
195
|
}>;
|
|
191
|
-
/** 角色库:AI 提炼 / 采纳 / 更新 / 删除。 */
|
|
192
|
-
imageTest(req: import('../protocol.ts').ImageTestRequest): Promise<import('../protocol.ts').ImageTestResponse>;
|
|
193
196
|
/** 对选中的提供商/模型发一次最小真实调用,验证连通性。 */
|
|
194
197
|
llmTest(provider: string, model: string): Promise<LlmTestResponse>;
|
|
195
198
|
/** 添加模型:厂商直填 key,或自定义 OpenAI 兼容路由(写 DSH 凭据 + 注册路由)。 */
|
|
@@ -203,20 +206,7 @@ export declare class NovelApi {
|
|
|
203
206
|
/** 移除一个提供方(unset key + 移除 llm-pi-ai 路由)。 */
|
|
204
207
|
removeProvider(req: RemoveProviderRequest): Promise<RemoveProviderResponse>;
|
|
205
208
|
roles(req: import('../protocol.ts').RolesRequest): Promise<import('../protocol.ts').RolesResponse>;
|
|
206
|
-
/**
|
|
207
|
-
mangaRoles(req: import('../protocol.ts').MangaRolesRequest): Promise<import('../protocol.ts').MangaRolesResponse>;
|
|
208
|
-
/** 导出「即梦素材包」落盘到资产库 manga-assets/素材包/。 */
|
|
209
|
-
exportPackage(chapterNo: number, title: string, markdown: string): Promise<{
|
|
210
|
-
ok: boolean;
|
|
211
|
-
file: string;
|
|
212
|
-
}>;
|
|
213
|
-
/** 场景库:AI 提炼 / 采纳 / 更新 / 删除 / 图集。 */
|
|
214
|
-
scenes(req: import('../protocol.ts').ScenesRequest): Promise<import('../protocol.ts').ScenesResponse>;
|
|
215
|
-
/** 视觉世界观规则:提炼 / 保存。 */
|
|
216
|
-
visualRules(req: import('../protocol.ts').VisualRulesRequest): Promise<import('../protocol.ts').VisualRulesResponse>;
|
|
217
|
-
/** 道具库:从已写章节提炼常驻道具 / 保存清单。 */
|
|
218
|
-
mangaProps(req: import('../protocol.ts').MangaPropsRequest): Promise<import('../protocol.ts').MangaPropsResponse>;
|
|
219
|
-
/** 小说简介:AI 生成/补全(partial 留空 = 全量),或手动保存。 */
|
|
209
|
+
/** 小说简介:生成/补全(partial 留空 = 全量),或手动保存。 */
|
|
220
210
|
blurb(action: 'generate' | 'save', text?: string, partial?: string): Promise<{
|
|
221
211
|
blurb: string;
|
|
222
212
|
}>;
|
|
@@ -231,7 +221,7 @@ export declare class NovelApi {
|
|
|
231
221
|
rename(bookName: string): Promise<{
|
|
232
222
|
bookName: string;
|
|
233
223
|
}>;
|
|
234
|
-
/**
|
|
224
|
+
/** 大世界:提炼(generate)或手动保存(save)。 */
|
|
235
225
|
world(action: 'generate' | 'save', world?: import('../protocol.ts').WorldState): Promise<{
|
|
236
226
|
world: import('../protocol.ts').WorldState;
|
|
237
227
|
}>;
|
|
@@ -288,6 +278,36 @@ export declare class NovelApi {
|
|
|
288
278
|
}>;
|
|
289
279
|
/** Run one assistant turn (NDJSON stream). */
|
|
290
280
|
assistant(message: string, onFrame: (frame: import('../protocol.ts').AssistantFrame) => void): Promise<void>;
|
|
281
|
+
/** 张力曲线:数据 + 规则核对。 */
|
|
282
|
+
tension(): Promise<import('../protocol.ts').TensionResponse>;
|
|
283
|
+
/** 设置张力曲线预设。 */
|
|
284
|
+
tensionPreset(preset: import('../protocol.ts').TensionCurvePreset): Promise<void>;
|
|
285
|
+
/** 设置/清除某一章的目标张力。 */
|
|
286
|
+
tensionSet(chapterNo: number, tension?: number): Promise<void>;
|
|
287
|
+
/** 提示词槽位:列表。 */
|
|
288
|
+
promptSlots(): Promise<import('../protocol.ts').PromptSlotsResponse>;
|
|
289
|
+
/** 写入一个提示词槽位(空串 = 清空)。 */
|
|
290
|
+
promptSlotSet(id: import('../protocol.ts').PromptSlotId, value: string): Promise<void>;
|
|
291
|
+
/** 故事时间线:列表(含规则初筛问题)。 */
|
|
292
|
+
timeline(): Promise<import('../protocol.ts').TimelineResponse>;
|
|
293
|
+
/** 抽取某一章的时间线事件。 */
|
|
294
|
+
timelineExtract(chapterNo: number): Promise<{
|
|
295
|
+
events: import('../protocol.ts').TimelineEvent[];
|
|
296
|
+
}>;
|
|
297
|
+
/** 检查时间线矛盾(规则初筛 + AI 复核)。 */
|
|
298
|
+
timelineCheck(): Promise<import('../protocol.ts').TimelineResponse>;
|
|
299
|
+
/** 手工修正一条时间线事件。 */
|
|
300
|
+
timelineUpdate(event: import('../protocol.ts').TimelineEvent): Promise<void>;
|
|
301
|
+
/** 删除一条时间线事件。 */
|
|
302
|
+
timelineRemove(id: string): Promise<void>;
|
|
303
|
+
/** 章节历史版本列表。 */
|
|
304
|
+
snapshots(): Promise<import('../protocol.ts').SnapshotResponse>;
|
|
305
|
+
/** 回滚到某个历史版本。 */
|
|
306
|
+
snapshotRestore(id: string): Promise<void>;
|
|
307
|
+
/** 给某章手工存档。 */
|
|
308
|
+
snapshotCreate(chapterNo: number): Promise<void>;
|
|
309
|
+
/** 删除一个历史版本。 */
|
|
310
|
+
snapshotRemove(id: string): Promise<void>;
|
|
291
311
|
/** Load the persisted assistant conversation. */
|
|
292
312
|
assistantHistory(): Promise<import('../protocol.ts').AssistantMessage[]>;
|
|
293
313
|
/** 清空助手对话记录。 */
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 右上角「小说工坊生成状态」芯片的显示偏好(纯客户端、localStorage)。
|
|
3
|
+
*
|
|
4
|
+
* 为什么是 localStorage 而不是插件配置:这是纯界面 chrome,与显示模式 / 界面密度 /
|
|
5
|
+
* 编辑器字号 / 芯片自身的位置记忆同类;哪个浏览器想清屏就哪个浏览器清,不需要跨端同步。
|
|
6
|
+
* 将来若要跨端,把键名沿用成 config 字段 `showRunChip` 即可平滑升级。
|
|
7
|
+
*
|
|
8
|
+
* 三态:
|
|
9
|
+
* off 关闭(同时停止 4 秒轮询,不白跑)
|
|
10
|
+
* active 只在生产单**运行中或已暂停**时显示(不想错过生成,也不想留残影)
|
|
11
|
+
* always 只要该目录有生产单状态就显示(默认,保持历史行为)
|
|
12
|
+
*/
|
|
13
|
+
import type { RunState } from '../protocol.ts';
|
|
14
|
+
export type RunChipMode = 'off' | 'active' | 'always';
|
|
15
|
+
/** localStorage 键(与芯片位置记忆同一命名空间)。 */
|
|
16
|
+
export declare const RUN_CHIP_MODE_KEY = "dsh-novel-forge.runChip.mode";
|
|
17
|
+
/** 同页变更通知用的自定义事件名(跨标签页走原生 storage 事件)。 */
|
|
18
|
+
export declare const RUN_CHIP_MODE_EVENT = "dsh-novel-forge:runchip-mode";
|
|
19
|
+
/** 默认值与历史行为一致:有生产单状态就显示。 */
|
|
20
|
+
export declare const DEFAULT_RUN_CHIP_MODE: RunChipMode;
|
|
21
|
+
/** 设置页下拉用的三态选项(顺序即用户看到的顺序)。 */
|
|
22
|
+
export declare const RUN_CHIP_MODE_OPTIONS: ReadonlyArray<{
|
|
23
|
+
value: RunChipMode;
|
|
24
|
+
label: string;
|
|
25
|
+
}>;
|
|
26
|
+
/** 读取偏好(缺失 / 非法 / 存储不可用 → 默认值)。 */
|
|
27
|
+
export declare function readRunChipMode(): RunChipMode;
|
|
28
|
+
/** 写入偏好并通知所有监听者;存储不可用时仍通知(本次会话内生效)。 */
|
|
29
|
+
export declare function writeRunChipMode(mode: RunChipMode): void;
|
|
30
|
+
/** 订阅偏好变化(同页 + 跨标签页 storage);返回退订函数。 */
|
|
31
|
+
export declare function subscribeRunChipMode(listener: (mode: RunChipMode) => void): () => void;
|
|
32
|
+
/**
|
|
33
|
+
* 给定偏好与当前生产单状态,判断芯片是否应可见。
|
|
34
|
+
* null(没有生产单状态)永远不显示——这是渲染层与测试共用的唯一判据。
|
|
35
|
+
*/
|
|
36
|
+
export declare function isRunChipVisible(mode: RunChipMode, state: RunState | null | undefined): boolean;
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
* the Node build (esm/index.mjs), which calls module.createRequire() for the
|
|
9
9
|
* optional worker_threads path — inlining that into the browser bundle leaves
|
|
10
10
|
* a bare require("module") the client-modules table cannot answer.
|
|
11
|
+
*
|
|
12
|
+
* XML 解析共享核心在 ../docx-core.ts(与服务端同源)。
|
|
11
13
|
*/
|
|
12
14
|
/** Extract plain text from a docx buffer: one line per <w:p> paragraph. */
|
|
13
15
|
export declare function extractDocxTextFromBuffer(buffer: ArrayBuffer | Uint8Array): string;
|
|
14
|
-
/** Read a File as ArrayBuffer. */
|
|
15
|
-
export declare function readFileAsArrayBuffer(file: File): Promise<ArrayBuffer>;
|
|
@@ -2,20 +2,8 @@
|
|
|
2
2
|
* 浏览器端「AI 创作实况」钩子:连接 /llm-live/stream (SSE),按 LLM 调用分组会话。
|
|
3
3
|
* 轻量实现,不持久化缓存(对齐上游 useLlmLiveFeed 的核心行为)。
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
sessionId: string;
|
|
8
|
-
label?: string;
|
|
9
|
-
model?: string;
|
|
10
|
-
at: string;
|
|
11
|
-
content?: string;
|
|
12
|
-
totalChars?: number;
|
|
13
|
-
totalReasoningChars?: number;
|
|
14
|
-
phase?: 'requesting' | 'streaming' | 'completed' | 'failed';
|
|
15
|
-
phaseMessage?: string;
|
|
16
|
-
preview?: string;
|
|
17
|
-
error?: string;
|
|
18
|
-
}
|
|
5
|
+
import { type LlmLiveFrame, type LlmTokenUsage } from '../protocol.ts';
|
|
6
|
+
export type { LlmLiveFrame };
|
|
19
7
|
export interface LlmLiveSession {
|
|
20
8
|
sessionId: string;
|
|
21
9
|
label: string;
|
|
@@ -26,6 +14,16 @@ export interface LlmLiveSession {
|
|
|
26
14
|
totalChars: number;
|
|
27
15
|
startedAt: string;
|
|
28
16
|
updatedAt: string;
|
|
17
|
+
/** 本次调用的 token 用量(供应商未上报时缺省)。 */
|
|
18
|
+
usage?: LlmTokenUsage;
|
|
19
|
+
/** 本次调用耗时(毫秒)。 */
|
|
20
|
+
elapsedMs?: number;
|
|
21
|
+
/** 首字耗时(毫秒)。 */
|
|
22
|
+
firstTokenMs?: number;
|
|
23
|
+
/** 是否保存了可查看的 Prompt。 */
|
|
24
|
+
hasPrompt?: boolean;
|
|
25
|
+
/** Prompt 字符数(system + user)。 */
|
|
26
|
+
promptChars?: number;
|
|
29
27
|
}
|
|
30
28
|
export declare function useLlmLiveFeed(enabled?: boolean): {
|
|
31
29
|
connected: boolean;
|