@waterwx/dsh-novel-forge 1.3.1 → 1.3.2-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 (161) hide show
  1. package/README.md +288 -279
  2. package/lib/client.js +56309 -12221
  3. package/lib/index.js +14239 -5595
  4. package/lib/types/action-guard.d.ts +61 -0
  5. package/lib/types/ai-scan.d.ts +36 -0
  6. package/lib/types/assets.d.ts +24 -9
  7. package/lib/types/assistant.d.ts +29 -0
  8. package/lib/types/author-assets.d.ts +25 -0
  9. package/lib/types/bookshelf.d.ts +11 -1
  10. package/lib/types/client/api.d.ts +186 -10
  11. package/lib/types/client/chip-prefs.d.ts +36 -0
  12. package/lib/types/client/docx.d.ts +2 -0
  13. package/lib/types/client/index.d.ts +1 -1
  14. package/lib/types/client/llmLive.d.ts +31 -0
  15. package/lib/types/client/locales.d.ts +28 -67
  16. package/lib/types/client/panel/AdaptModeView.d.ts +5 -0
  17. package/lib/types/client/panel/AiTag.d.ts +1 -0
  18. package/lib/types/client/panel/AssistantTab.d.ts +4 -1
  19. package/lib/types/client/panel/AuthorAssetsView.d.ts +4 -0
  20. package/lib/types/client/panel/AuthorHome.d.ts +34 -0
  21. package/lib/types/client/panel/BookAnalysisView.d.ts +4 -0
  22. package/lib/types/client/panel/CmdPalette.d.ts +12 -0
  23. package/lib/types/client/panel/CreateBookView.d.ts +5 -1
  24. package/lib/types/client/panel/DirectorView.d.ts +7 -0
  25. package/lib/types/client/panel/GlobalAssetLibraryView.d.ts +4 -0
  26. package/lib/types/client/panel/IdeaInspirationView.d.ts +6 -0
  27. package/lib/types/client/panel/ImportModal.d.ts +7 -0
  28. package/lib/types/client/panel/KnowledgeBaseView.d.ts +4 -0
  29. package/lib/types/client/panel/LiveFeedLog.d.ts +13 -0
  30. package/lib/types/client/panel/MarketRadarView.d.ts +5 -0
  31. package/lib/types/client/panel/ModelManager.d.ts +14 -0
  32. package/lib/types/client/panel/NovelPanel.d.ts +6 -1
  33. package/lib/types/client/panel/PageHeader.d.ts +18 -0
  34. package/lib/types/client/panel/ProgressConsole.d.ts +17 -0
  35. package/lib/types/client/panel/ProgressHomeView.d.ts +5 -0
  36. package/lib/types/client/panel/PromptSlotsView.d.ts +11 -0
  37. package/lib/types/client/panel/ReasoningSection.d.ts +10 -0
  38. package/lib/types/client/panel/SettingsView.d.ts +19 -0
  39. package/lib/types/client/panel/ShelfView.d.ts +12 -1
  40. package/lib/types/client/panel/SubPage.d.ts +27 -0
  41. package/lib/types/client/panel/TensionView.d.ts +18 -0
  42. package/lib/types/client/panel/TimelineView.d.ts +18 -0
  43. package/lib/types/client/panel/helpers.d.ts +5 -3
  44. package/lib/types/client/panel/toast.d.ts +2 -0
  45. package/lib/types/client/panel/views.d.ts +25 -7
  46. package/lib/types/client/run-status.d.ts +21 -0
  47. package/lib/types/client/text.d.ts +9 -0
  48. package/lib/types/docx-core.d.ts +16 -0
  49. package/lib/types/docx.d.ts +2 -3
  50. package/lib/types/engine.d.ts +186 -45
  51. package/lib/types/global-assets.d.ts +6 -0
  52. package/lib/types/index.d.ts +22 -8
  53. package/lib/types/llm-live.d.ts +75 -0
  54. package/lib/types/llm-retry.d.ts +38 -0
  55. package/lib/types/market-radar-scan.d.ts +19 -0
  56. package/lib/types/market-radar-sources.d.ts +31 -0
  57. package/lib/types/migrate-output.d.ts +25 -0
  58. package/lib/types/novel-context.d.ts +80 -0
  59. package/lib/types/prompt-slots.d.ts +57 -0
  60. package/lib/types/prompt-utils.d.ts +35 -0
  61. package/lib/types/prompting.d.ts +10 -0
  62. package/lib/types/protocol.d.ts +1362 -166
  63. package/lib/types/review-policy.d.ts +97 -0
  64. package/lib/types/revision.d.ts +76 -0
  65. package/lib/types/routes.d.ts +4 -0
  66. package/lib/types/run.d.ts +23 -1
  67. package/lib/types/snapshots.d.ts +46 -0
  68. package/lib/types/stage-contract.d.ts +60 -0
  69. package/lib/types/tension.d.ts +53 -0
  70. package/lib/types/timeline.d.ts +37 -0
  71. package/package.json +52 -28
  72. package/src/action-guard.ts +127 -0
  73. package/src/ai-scan.ts +179 -0
  74. package/src/assets.ts +1806 -520
  75. package/src/assistant.ts +1098 -770
  76. package/src/author-assets.ts +149 -0
  77. package/src/bookshelf.ts +187 -151
  78. package/src/client/api.ts +378 -21
  79. package/src/client/chip-prefs.ts +121 -0
  80. package/src/client/docx.ts +37 -69
  81. package/src/client/index.ts +3 -1
  82. package/src/client/llmLive.ts +111 -0
  83. package/src/client/locales.ts +28 -253
  84. package/src/client/mount.tsx +1 -1
  85. package/src/client/panel/AdaptModeView.tsx +535 -0
  86. package/src/client/panel/AiTag.tsx +7 -0
  87. package/src/client/panel/AssetsTab.tsx +448 -458
  88. package/src/client/panel/AssistantTab.tsx +355 -301
  89. package/src/client/panel/AuthorAssetsView.tsx +206 -0
  90. package/src/client/panel/AuthorHome.tsx +309 -0
  91. package/src/client/panel/BookAnalysisView.tsx +63 -0
  92. package/src/client/panel/CmdPalette.tsx +102 -0
  93. package/src/client/panel/CreateBookView.tsx +366 -348
  94. package/src/client/panel/DirectorView.tsx +200 -0
  95. package/src/client/panel/GlobalAssetLibraryView.tsx +168 -0
  96. package/src/client/panel/IdeaInspirationView.tsx +76 -0
  97. package/src/client/panel/ImportModal.tsx +303 -0
  98. package/src/client/panel/KnowledgeBaseView.tsx +125 -0
  99. package/src/client/panel/LiveFeedLog.tsx +204 -0
  100. package/src/client/panel/MarketRadarView.tsx +377 -0
  101. package/src/client/panel/ModelManager.tsx +205 -0
  102. package/src/client/panel/NovelPanel.tsx +3135 -2651
  103. package/src/client/panel/PageHeader.tsx +37 -0
  104. package/src/client/panel/ProgressConsole.tsx +63 -0
  105. package/src/client/panel/PromptSlotsView.tsx +97 -0
  106. package/src/client/panel/ReaderView.tsx +306 -306
  107. package/src/client/panel/ReasoningSection.tsx +31 -0
  108. package/src/client/panel/RunPanel.tsx +64 -32
  109. package/src/client/panel/SettingsView.tsx +354 -0
  110. package/src/client/panel/ShelfView.tsx +266 -236
  111. package/src/client/panel/SubPage.tsx +42 -0
  112. package/src/client/panel/TensionView.tsx +212 -0
  113. package/src/client/panel/TimelineView.tsx +208 -0
  114. package/src/client/panel/WorldTab.tsx +202 -202
  115. package/src/client/panel/helpers.ts +7 -5
  116. package/src/client/panel/panel.module.css +4481 -1655
  117. package/src/client/panel/toast.ts +51 -0
  118. package/src/client/panel/views.tsx +401 -314
  119. package/src/client/run-status.ts +171 -0
  120. package/src/client/sidebar-entry.ts +1 -1
  121. package/src/client/text.ts +28 -0
  122. package/src/docx-core.ts +53 -0
  123. package/src/docx.ts +44 -83
  124. package/src/engine.ts +4672 -2943
  125. package/src/global-assets.ts +59 -0
  126. package/src/index.ts +89 -33
  127. package/src/llm-live.ts +260 -0
  128. package/src/llm-retry.ts +77 -0
  129. package/src/market-radar-scan.ts +41 -0
  130. package/src/market-radar-sources.ts +173 -0
  131. package/src/migrate-output.ts +76 -0
  132. package/src/novel-context.ts +286 -0
  133. package/src/prompt-slots.ts +125 -0
  134. package/src/prompting.ts +26 -0
  135. package/src/protocol.ts +1388 -158
  136. package/src/review-policy.ts +161 -0
  137. package/src/revision.ts +283 -0
  138. package/src/routes.ts +1934 -434
  139. package/src/run.ts +118 -21
  140. package/src/snapshots.ts +174 -0
  141. package/src/stage-contract.ts +189 -0
  142. package/src/tension.ts +251 -0
  143. package/src/timeline.ts +159 -0
  144. package/lib/client.js.map +0 -1
  145. package/lib/index.js.map +0 -1
  146. package/lib/types/comic-presets.d.ts +0 -12
  147. package/scripts/assistant-frames.txt +0 -8
  148. package/scripts/diagnose-adapter.mts +0 -81
  149. package/scripts/diagnose-assistant.mjs +0 -58
  150. package/scripts/diagnose-bible.mjs +0 -72
  151. package/scripts/diagnose-harness.mts +0 -75
  152. package/scripts/novel-forge-restart.log +0 -10
  153. package/scripts/novel-forge-web.stderr.log +0 -2
  154. package/scripts/novel-forge-web.stdout.log +0 -1
  155. package/scripts/outline-sample.txt +0 -449
  156. package/scripts/probe.mjs +0 -6
  157. package/scripts/restart-web.ps1 +0 -88
  158. package/scripts/smoke.mts +0 -72
  159. package/scripts/upload-github.ps1 +0 -51
  160. package/src/client/panel/BookshelfBar.tsx +0 -170
  161. package/src/comic-presets.ts +0 -67
@@ -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
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * 本地 AI 味扫描器(不调 LLM,确定性检测)
3
+ *
4
+ * 用途:生成/润色后自动扫描,结果作为「事实锚点」注入审稿提示词,
5
+ * 让 LLM 做判断而非机械统计。也可用于 UI 展示 AI 味指标。
6
+ */
7
+ export interface AiScanResult {
8
+ /** 总评分 0-100,越高越像 AI 写的 */
9
+ aiScore: number;
10
+ /** 命中的套话及次数 */
11
+ clicheHits: Array<{
12
+ word: string;
13
+ count: number;
14
+ }>;
15
+ /** 段落长度方差(过高=段落过于整齐) */
16
+ paragraphLengthVariance: number;
17
+ /** 连续解释性叙事段数(≥3 视为问题) */
18
+ consecutiveExpositoryParagraphs: number;
19
+ /** 句式重复率(相同开头句式占比) */
20
+ sentenceRepetitionRate: number;
21
+ /** 过长段落数(>300字) */
22
+ longParagraphCount: number;
23
+ /** 过短段落数(<20字) */
24
+ shortParagraphCount: number;
25
+ /** 对话占比(0-1) */
26
+ dialogueRatio: number;
27
+ /** 问题摘要,可直接注入审稿提示词 */
28
+ summary: string;
29
+ }
30
+ export declare function scanAiFlavor(text: string): AiScanResult;
31
+ /** 扫描前后对比(润色时用) */
32
+ export declare function compareAiScan(before: AiScanResult, after: AiScanResult): {
33
+ improved: boolean;
34
+ deltaScore: number;
35
+ details: string[];
36
+ };
@@ -1,27 +1,34 @@
1
1
  /**
2
2
  * Writing assets — 题材基底库 / 推进模式库 / 反 AI 规则 / 写法引擎.
3
3
  *
4
- * Ported from AI-Novel-Writing-Assistant (Apache-2.0) built-in seed data:
5
- * - 8 preset style templates (DEFAULT_STYLE_TEMPLATES)
6
- * - 12 anti-AI rules with concrete detect patterns (DEFAULT_ANTI_AI_RULES)
7
- * - genre tree + progression mode seeds
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
- import type { AntiAiRule, GenreNode, ProgressionMode, ProjectAssets, StyleAsset, StyleTemplate } from './protocol.ts';
12
- /** 预置写法模板(来自 AI-Novel-Writing-Assistant 内置 DEFAULT_STYLE_TEMPLATES)。 */
11
+ import type { AntiAiRule, GenreNode, PlotBeatTemplate, ProgressionMode, ProjectAssets, StarterStyleProfile, StyleAsset, StyleTemplate } from './protocol.ts';
12
+ /** 预置叙事风格模板(8 套,一键绑定无需样本文本)。 */
13
13
  export declare const BUILTIN_STYLE_TEMPLATES: StyleTemplate[];
14
- /** 内置全局反 AI 规则(来自 AI-Novel-Writing-Assistant 内置 DEFAULT_ANTI_AI_RULES)。 */
14
+ /** 内置全局反 AI 规则(12 条,随插件发布;项目可叠加自定义规则)。 */
15
15
  export declare const BUILTIN_ANTI_AI_RULES: AntiAiRule[];
16
16
  /** 内置题材基底库(常用网文题材树,跨书复用)。 */
17
17
  export declare const BUILTIN_GENRE_LIBRARY: GenreNode[];
18
18
  /** 内置常用推进模式。 */
19
19
  export declare const BUILTIN_PROGRESSION_MODES: ProgressionMode[];
20
+ /** 剧情桥段库:可复用情节套路(作者阅读经验沉淀,非某本书的剧情线)。 */
21
+ export declare const BUILTIN_PLOT_BEATS: PlotBeatTemplate[];
20
22
  /** 默认(空)项目写作资产。 */
21
23
  export declare function emptyProjectAssets(): ProjectAssets;
22
24
  /** 合并项目资产与内置库:返回「生效的反 AI 规则」(内置全局 + 项目自定义)。 */
23
25
  export declare function effectiveAntiAiRules(assets: ProjectAssets | undefined): AntiAiRule[];
24
- /** 把生效规则渲染成提示词块(压缩:avoid/fix 截断,省 token)。 */
26
+ /** 安定 key:内置规则全局基线(globalBaselineEnabled)在新书/旧书一律生效。 */
27
+ export declare function ensureGlobalBaseline(assets: ProjectAssets | undefined): ProjectAssets;
28
+ /** 内置库种子化 upsert(对齐上游 SystemResourceBootstrapService 精神)。
29
+ * missing_only 仅补齐缺失的全局基线规则;sync_existing 还会按 key 刷新已内置规则的结构化字段。 */
30
+ export declare function ensureBuiltinAssets(assets: ProjectAssets | undefined, mode?: 'missing_only' | 'sync_existing'): ProjectAssets;
31
+ /** 把生效规则渲染成提示词块(禁止/风险/鼓励三档分列,压缩省 token)。 */
25
32
  export declare function renderAntiAiRules(assets: ProjectAssets | undefined): string;
26
33
  /** 渲染题材与推进模式提示词块。 */
27
34
  export declare function renderGenreAndProgression(assets: ProjectAssets | undefined): string;
@@ -31,5 +38,13 @@ export declare function renderStyleAssets(assets: ProjectAssets | undefined): st
31
38
  export declare function renderAllAssets(assets: ProjectAssets | undefined): string;
32
39
  /** 预置写法模板 → 可直接绑定的 StyleAsset。 */
33
40
  export declare function styleTemplateToAsset(template: StyleTemplate): StyleAsset;
34
- /** 写法引擎:从样本文本提取风格资产的系统提示词。 */
41
+ /** 起始风格画像库:无样本文本也能快速绑定一套写法(4 档起步写法)。 */
42
+ export declare const BUILTIN_STARTER_STYLE_PROFILES: StarterStyleProfile[];
43
+ /** 起始风格画像 → 可直接绑定的 StyleAsset(绑定对应模板,名称用画像名)。 */
44
+ export declare function starterProfileToAsset(profile: StarterStyleProfile): StyleAsset | null;
45
+ /** 根据指纹风险推荐仿写预设:low→imitate / medium→balanced / high→transfer。 */
46
+ export declare function recommendStylePreset(fingerprintRisk?: 'low' | 'medium' | 'high'): 'imitate' | 'balanced' | 'transfer';
47
+ /** 写法引擎:从样本文本提取风格资产的系统提示词(含 preset / 指纹 / 净化管线)。 */
35
48
  export declare function styleEngineSystemPrompt(): string;
49
+ /** 写作公式提取系统提示词(分层:basic 骨架 / standard 完整 / deep 逐句细化)。 */
50
+ export declare function styleFormulaSystemPrompt(depth: 'basic' | 'standard' | 'deep'): string;
@@ -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
  /** 清空助手对话记录(删除历史文件)。 */
@@ -41,5 +66,9 @@ export declare function runAssistantTurn(ctx: Context, config: NovelConfig, proj
41
66
  frame: 'toolDelta';
42
67
  name: string;
43
68
  text: string;
69
+ } | {
70
+ frame: 'toolResult';
71
+ name: string;
72
+ text: string;
44
73
  }, void, unknown>;
45
74
  export { chapterFileName };
@@ -0,0 +1,25 @@
1
+ /**
2
+ * 作者资产库/总数据(跨书)— 按作者维度聚合的可复用资产。
3
+ * 与书架同惯例持久化到 ~/.dsh/dsh-novel-forge-author-assets.json。
4
+ * 提供读取/持久化/新增或更新/删除,以及「导入默认」:把书架书的写作资产/角色 +
5
+ * 内置全局库(题材/反AI规则/风格模板/推进模式)批量沉淀成资产条目(默认库)。
6
+ */
7
+ import type { AuthorAssetLibrary, AuthorStyleAsset } from './protocol.ts';
8
+ /** 作者资产库配置文件路径。 */
9
+ export declare function authorAssetsFile(): string;
10
+ /** 读取作者资产库(不存在/损坏则返回空库,不抛错)。 */
11
+ export declare function loadAuthorAssets(): AuthorAssetLibrary;
12
+ /** 持久化作者资产库。 */
13
+ export declare function saveAuthorAssets(library: AuthorAssetLibrary): void;
14
+ /** 新建一条资产(自动生成 id 与时间戳)。 */
15
+ export declare function createAuthorAsset(input: Omit<AuthorStyleAsset, 'id' | 'createdAt' | 'updatedAt'>): AuthorStyleAsset;
16
+ /** 按 id 更新一条资产;不存在则追加。 */
17
+ export declare function upsertAuthorAsset(input: AuthorStyleAsset): AuthorAssetLibrary;
18
+ /** 删除一条资产;返回更新后的资产库。 */
19
+ export declare function removeAuthorAsset(id: string): AuthorAssetLibrary;
20
+ /**
21
+ * 导入默认:把书架所有书的写作资产/角色 + 内置全局库批量沉淀到作者资产库。
22
+ * 按 `kind:name` 去重(已存在则跳过),不覆盖用户已有条目。
23
+ * @returns 更新后的资产库。
24
+ */
25
+ export declare function importDefaultAuthorAssets(): AuthorAssetLibrary;
@@ -26,12 +26,22 @@ export declare function renameBook(id: string, bookName: string): boolean;
26
26
  * @returns 是否发生了播种。
27
27
  */
28
28
  export declare function seedBookshelfFromOutputDir(outputDir: string): boolean;
29
+ /** 导入已有项目目录到书架:校验 novel-project.json,已存在则直接激活。 */
30
+ export declare function importDir(outputDir: string): {
31
+ book: BookEntry;
32
+ existed: boolean;
33
+ };
29
34
  /** 激活一本书。 */
30
35
  export declare function activateBook(id: string): BookEntry | undefined;
31
36
  /** 移除一本书。 */
32
37
  export declare function removeBook(id: string): boolean;
33
38
  /** 当前书输出目录(无书架则 undefined,回退 settings)。 */
34
39
  export declare function activeBookOutputDir(): string | undefined;
35
- /** 默认输出目录推断:小说目录/书名。 */
40
+ /**
41
+ * 书目录重指向:把 outputDir 等于 from 的书条目全部改为 to(目录迁移联动)。
42
+ * @returns 重指向的条目数。
43
+ */
44
+ export declare function repointBookDirs(from: string, to: string): number;
45
+ /** 默认输出目录推断:~/.dsh/novels/书名。 */
36
46
  export declare function defaultOutputDirFor(bookName: string): string;
37
47
  export {};
@@ -3,11 +3,12 @@
3
3
  * fetch, same origin; generation/rewrite/polish ride NDJSON streams read
4
4
  * incrementally.
5
5
  */
6
- import { type AssetsPatch, type AssetsResponse, type BibleResponse, type ChapterResponse, type ConfigPatch, type ExportResponse, type ForeshadowRequest, type ForeshadowResponse, type JobFrame, type LoadOutlineResponse, 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);
10
10
  }
11
+ export declare function setCurrentBook(id: string | null): void;
11
12
  /** The browser half's only data entry point. */
12
13
  export declare class NovelApi {
13
14
  status(): Promise<StatusResponse>;
@@ -16,6 +17,8 @@ export declare class NovelApi {
16
17
  ok: boolean;
17
18
  bookName: string;
18
19
  }>;
20
+ /** 反推大纲:从已写章节正文反向生成全书总纲(NDJSON 流)。 */
21
+ outlineReverse(onFrame: (frame: JobFrame) => void): Promise<void>;
19
22
  /** 开书想法 → AI 大纲:生成 count 个方案(换批时传 exclude 避开已暂留方向)。 */
20
23
  outlineSuggest(idea: string, count?: number, exclude?: string[]): Promise<import('../protocol.ts').OutlineSuggestResponse>;
21
24
  /** 拆书分析:对已写章节做结构/人物/文风/卖点体检。 */
@@ -30,18 +33,32 @@ export declare class NovelApi {
30
33
  summary: string;
31
34
  }>;
32
35
  foreshadow(req: ForeshadowRequest): Promise<ForeshadowResponse>;
33
- exportBook(format: 'txt' | 'md'): Promise<ExportResponse>;
36
+ exportBook(format: 'txt' | 'md' | 'json', scope?: import('../protocol.ts').ExportScope): Promise<ExportResponse>;
34
37
  chapter(no: number): Promise<ChapterResponse>;
35
38
  /** 审查手动编辑的正文(不落盘)。previousReport 传入时走「验证模式」(核对原意见解决 + 只挑新增 high)。 */
36
39
  chapterCheck(no: number, text: string, previousReport?: ReviewReport): Promise<{
37
40
  report: ReviewReport;
38
41
  }>;
42
+ /**
43
+ * 修订指令合并:把本章的审稿意见(勾选项)+ 时间线矛盾 + 张力偏差合成**一份**指令。
44
+ * 面板所有「按意见修订 / 一键按建议修订」入口都先走这里,保证同一章只改一轮。
45
+ */
46
+ revisionPlan(no: number, reviewIssues?: ReviewReport['issues'], opts?: {
47
+ includeTimeline?: boolean;
48
+ includeTension?: boolean;
49
+ }): Promise<RevisionPlanResponse>;
39
50
  /** 保存手动编辑的正文(自动备份 .bak;带报告则沿用落盘,否则保存后自动审稿)。 */
40
51
  chapterSave(no: number, text: string, report?: ReviewReport): Promise<import('../protocol.ts').ChapterSaveResponse>;
41
52
  patchConfig(patch: ConfigPatch): Promise<{
42
53
  config: NovelConfig;
43
54
  }>;
55
+ /** 输出目录迁移:dryRun=true 仅预览目录内容;确认时传 to 搬迁。 */
56
+ moveOutputDir(to?: string, dryRun?: boolean): Promise<import('../protocol.ts').MoveOutputDirResponse>;
57
+ /** 本书参数:不带 patch 读取;带 patch 合并保存(字段传 null = 回退全局)。 */
58
+ bookSettings(patch?: Record<string, unknown>): Promise<import('../protocol.ts').BookSettingsResponse>;
44
59
  openFolder(): Promise<void>;
60
+ /** 插件自更新:在 DSH profile 目录拉取最新 npm 版(需重启 DSH 生效)。 */
61
+ pluginUpdate(): Promise<PluginUpdateResponse>;
45
62
  /** 书架快照。 */
46
63
  bookshelf(): Promise<import('../protocol.ts').BookshelfSnapshot>;
47
64
  /** 新建书并激活(开书向导:可携带大纲文本,创建即建项目)。 */
@@ -53,6 +70,94 @@ export declare class NovelApi {
53
70
  }>;
54
71
  /** 全书一致性质检。 */
55
72
  audit(): Promise<import('../protocol.ts').AuditResponse>;
73
+ /** 热门题材雷达:信号 + 生产底座。 */
74
+ marketRadar(req: import('../protocol.ts').MarketRadarRequest): Promise<{
75
+ result: import('../protocol.ts').MarketRadarResult;
76
+ }>;
77
+ /** 真实榜单扫榜:抓取公开榜单,返回分组候选。 */
78
+ marketRadarScan(req: {
79
+ platforms?: string[];
80
+ }): Promise<{
81
+ result: {
82
+ scannedAt: string;
83
+ groups: any[];
84
+ };
85
+ }>;
86
+ /** 把雷达生产底座里的新资产同步进全局资源库(跨书复用;已有名字跳过)。 */
87
+ marketRadarSync(req: {
88
+ foundation: import('../protocol.ts').ProductionFoundation;
89
+ }): Promise<{
90
+ ok: boolean;
91
+ synced: {
92
+ genre: boolean;
93
+ primaryMode: boolean;
94
+ secondaryMode: boolean;
95
+ };
96
+ }>;
97
+ /** 书内知识库:读取。 */
98
+ knowledgeList(): Promise<{
99
+ docs: import('../protocol.ts').KnowledgeDoc[];
100
+ }>;
101
+ /** 书内知识库:新增。 */
102
+ knowledgeAdd(doc: {
103
+ title: string;
104
+ content: string;
105
+ }): Promise<{
106
+ docs: import('../protocol.ts').KnowledgeDoc[];
107
+ }>;
108
+ /** 书内知识库:删除。 */
109
+ knowledgeRemove(id: string): Promise<{
110
+ docs: import('../protocol.ts').KnowledgeDoc[];
111
+ }>;
112
+ /** 书分析/拆书。 */
113
+ bookAnalysis(text: string): Promise<{
114
+ result: import('../protocol.ts').BookAnalysisResult;
115
+ }>;
116
+ /** 创意灵感。 */
117
+ ideaInspiration(idea: string, count?: number): Promise<{
118
+ result: import('../protocol.ts').IdeaInspirationResult;
119
+ }>;
120
+ /** 雷达→灵感:基于市场信号/生产底座/创意简报生成开书灵感。 */
121
+ marketIdeaInspiration(req: {
122
+ signals?: import('../protocol.ts').MarketRadarSignal[];
123
+ foundation?: import('../protocol.ts').ProductionFoundation;
124
+ brief?: import('../protocol.ts').MarketCreativeBrief;
125
+ count?: number;
126
+ }): Promise<{
127
+ result: import('../protocol.ts').IdeaInspirationResult;
128
+ }>;
129
+ /** 自动编辑编排建议:基于全书上下文。 */
130
+ director(focus?: string): Promise<{
131
+ result: import('../protocol.ts').DirectorAdvice;
132
+ }>;
133
+ /** 自动编辑「采纳」出的书内待办:读取。 */
134
+ directorTodosList(): Promise<{
135
+ todos: import('../protocol.ts').DirectorTodo[];
136
+ }>;
137
+ /** 待办:新增(来源 risk/fix)。 */
138
+ directorTodosAdd(text: string, source: 'risk' | 'fix'): Promise<{
139
+ todos: import('../protocol.ts').DirectorTodo[];
140
+ }>;
141
+ /** 待办:勾选/取消。 */
142
+ directorTodosToggle(id: string): Promise<{
143
+ todos: import('../protocol.ts').DirectorTodo[];
144
+ }>;
145
+ /** 待办:删除。 */
146
+ directorTodosRemove(id: string): Promise<{
147
+ todos: import('../protocol.ts').DirectorTodo[];
148
+ }>;
149
+ /** 用选中的市场信号 + 影响模式生成开书创意简报。 */
150
+ marketRadarBrief(req: import('../protocol.ts').MarketRadarBriefRequest): Promise<{
151
+ creativeBrief: import('../protocol.ts').MarketCreativeBrief;
152
+ }>;
153
+ /** 把雷达生产底座一键应用到某本书(写入项目资产/开书定盘)。 */
154
+ marketRadarApply(req: {
155
+ bookId?: string;
156
+ foundation: import('../protocol.ts').ProductionFoundation;
157
+ }): Promise<{
158
+ ok: boolean;
159
+ bookName: string;
160
+ }>;
56
161
  /** 角色卡刷新(基于事实库聚合)。 */
57
162
  charactersRefresh(): Promise<{
58
163
  cards: import('../protocol.ts').RoleStatusCard[];
@@ -62,7 +167,7 @@ export declare class NovelApi {
62
167
  ok: boolean;
63
168
  filled: number;
64
169
  }>;
65
- /** 设定圣经局部修补。 */
170
+ /** 道藏局部修补。 */
66
171
  biblePatch(patch: import('../protocol.ts').BiblePatchRequest): Promise<{
67
172
  bible: import('../protocol.ts').StoryBible;
68
173
  }>;
@@ -87,13 +192,20 @@ export declare class NovelApi {
87
192
  ok: boolean;
88
193
  no: number;
89
194
  }>;
90
- /** 角色库:AI 提炼 / 采纳 / 更新 / 删除。 */
195
+ /** 对选中的提供商/模型发一次最小真实调用,验证连通性。 */
196
+ llmTest(provider: string, model: string): Promise<LlmTestResponse>;
197
+ /** 添加模型:厂商直填 key,或自定义 OpenAI 兼容路由(写 DSH 凭据 + 注册路由)。 */
198
+ addModel(req: AddModelRequest): Promise<AddModelResponse>;
199
+ /** 运行时厂商目录(DSH pi-ai 可配置提供方 + 内置适配器)。 */
200
+ llmVendors(): Promise<LlmVendorsResponse>;
201
+ /** 查询某个 provider 当前可用的模型(添加成功后可即时刷新)。 */
202
+ llmModels(provider: string): Promise<LlmModelsResponse>;
203
+ /** 已注册的提供方路由列表(提供方管理卡片)。 */
204
+ llmProviders(): Promise<LlmProvidersResponse>;
205
+ /** 移除一个提供方(unset key + 移除 llm-pi-ai 路由)。 */
206
+ removeProvider(req: RemoveProviderRequest): Promise<RemoveProviderResponse>;
91
207
  roles(req: import('../protocol.ts').RolesRequest): Promise<import('../protocol.ts').RolesResponse>;
92
- /** 场景库:AI 提炼 / 采纳 / 更新 / 删除 / 图集。 */
93
- scenes(req: import('../protocol.ts').ScenesRequest): Promise<import('../protocol.ts').ScenesResponse>;
94
- /** 视觉世界观规则:提炼 / 保存。 */
95
- visualRules(req: import('../protocol.ts').VisualRulesRequest): Promise<import('../protocol.ts').VisualRulesResponse>;
96
- /** 小说简介:AI 生成/补全(partial 留空 = 全量),或手动保存。 */
208
+ /** 小说简介:生成/补全(partial 留空 = 全量),或手动保存。 */
97
209
  blurb(action: 'generate' | 'save', text?: string, partial?: string): Promise<{
98
210
  blurb: string;
99
211
  }>;
@@ -108,7 +220,7 @@ export declare class NovelApi {
108
220
  rename(bookName: string): Promise<{
109
221
  bookName: string;
110
222
  }>;
111
- /** 大世界:AI 提炼(generate)或手动保存(save)。 */
223
+ /** 大世界:提炼(generate)或手动保存(save)。 */
112
224
  world(action: 'generate' | 'save', world?: import('../protocol.ts').WorldState): Promise<{
113
225
  world: import('../protocol.ts').WorldState;
114
226
  }>;
@@ -116,6 +228,14 @@ export declare class NovelApi {
116
228
  bookActivate(id: string): Promise<import('../protocol.ts').BookshelfSnapshot>;
117
229
  /** 移除书架条目。 */
118
230
  bookRemove(id: string): Promise<import('../protocol.ts').BookshelfSnapshot>;
231
+ /** 导入已有项目目录(Mode A):校验 novel-project.json,登记/激活书架。 */
232
+ bookImportDir(outputDir: string): Promise<import('../protocol.ts').BookImportDirResponse>;
233
+ /** 导入 txt/md 全本(Mode B):服务器本地文件路径模式。 */
234
+ bookImportText(filePath: string, outputDir?: string): Promise<import('../protocol.ts').BookImportTextResponse>;
235
+ /** 拆章预览(浏览器上传全文,不落盘):返回识别到的章节与跳过清单。 */
236
+ bookImportTextPreview(text: string, fileName?: string): Promise<import('../protocol.ts').BookImportTextPreviewResponse>;
237
+ /** 导入 txt/md 全本(Mode B):浏览器上传全文内容模式。 */
238
+ bookImportTextContent(text: string, fileName: string, outputDir?: string): Promise<import('../protocol.ts').BookImportTextResponse>;
119
239
  /** 生产单:启动批量生产(区间或新增 N 章;计划不足自动补)。 */
120
240
  runStart(req: import('../protocol.ts').RunStartRequest): Promise<import('../protocol.ts').RunState>;
121
241
  /** 生产单控制:pause / resume / stop。 */
@@ -157,10 +277,66 @@ export declare class NovelApi {
157
277
  }>;
158
278
  /** Run one assistant turn (NDJSON stream). */
159
279
  assistant(message: string, onFrame: (frame: import('../protocol.ts').AssistantFrame) => void): Promise<void>;
280
+ /** 张力曲线:数据 + 规则核对。 */
281
+ tension(): Promise<import('../protocol.ts').TensionResponse>;
282
+ /** 设置张力曲线预设。 */
283
+ tensionPreset(preset: import('../protocol.ts').TensionCurvePreset): Promise<void>;
284
+ /** 设置/清除某一章的目标张力。 */
285
+ tensionSet(chapterNo: number, tension?: number): Promise<void>;
286
+ /** 提示词槽位:列表。 */
287
+ promptSlots(): Promise<import('../protocol.ts').PromptSlotsResponse>;
288
+ /** 写入一个提示词槽位(空串 = 清空)。 */
289
+ promptSlotSet(id: import('../protocol.ts').PromptSlotId, value: string): Promise<void>;
290
+ /** 故事时间线:列表(含规则初筛问题)。 */
291
+ timeline(): Promise<import('../protocol.ts').TimelineResponse>;
292
+ /** 抽取某一章的时间线事件。 */
293
+ timelineExtract(chapterNo: number): Promise<{
294
+ events: import('../protocol.ts').TimelineEvent[];
295
+ }>;
296
+ /** 检查时间线矛盾(规则初筛 + AI 复核)。 */
297
+ timelineCheck(): Promise<import('../protocol.ts').TimelineResponse>;
298
+ /** 手工修正一条时间线事件。 */
299
+ timelineUpdate(event: import('../protocol.ts').TimelineEvent): Promise<void>;
300
+ /** 删除一条时间线事件。 */
301
+ timelineRemove(id: string): Promise<void>;
302
+ /** 章节历史版本列表。 */
303
+ snapshots(): Promise<import('../protocol.ts').SnapshotResponse>;
304
+ /** 回滚到某个历史版本。 */
305
+ snapshotRestore(id: string): Promise<void>;
306
+ /** 给某章手工存档。 */
307
+ snapshotCreate(chapterNo: number): Promise<void>;
308
+ /** 删除一个历史版本。 */
309
+ snapshotRemove(id: string): Promise<void>;
160
310
  /** Load the persisted assistant conversation. */
161
311
  assistantHistory(): Promise<import('../protocol.ts').AssistantMessage[]>;
162
312
  /** 清空助手对话记录。 */
163
313
  assistantClear(): Promise<{
164
314
  ok: boolean;
165
315
  }>;
316
+ /** 作者资产库/总数据:读取跨书可复用资产。 */
317
+ authorAssets(): Promise<import('../protocol.ts').AuthorAssetsResponse>;
318
+ /** 作者资产库:新增/更新一条资产(upsert by id)。 */
319
+ authorAssetsUpsert(asset: import('../protocol.ts').AuthorStyleAsset): Promise<import('../protocol.ts').AuthorAssetsResponse>;
320
+ /** 作者资产库:删除一条资产。 */
321
+ authorAssetsRemove(id: string): Promise<import('../protocol.ts').AuthorAssetsResponse>;
322
+ /** 作者资产库:导入默认(书架书的写作资产/角色 + 内置全局库)批量沉淀。 */
323
+ authorAssetsImportDefault(): Promise<import('../protocol.ts').AuthorAssetsResponse>;
324
+ /** 改编模式 P0:上传全文 → 原文设定卡片 / 可改范围矩阵。 */
325
+ adaptAnalyze(text: string, filePath?: string): Promise<import('../protocol.ts').AdaptAnalyzeResponse>;
326
+ /** 改编模式 P1:确认要改的维度 → 生成映射表/改编规则/联动影响清单。 */
327
+ adaptPropose(req: import('../protocol.ts').AdaptProposeRequest): Promise<import('../protocol.ts').AdaptProposeResponse>;
328
+ /** 改编模式 P2:执行术语替换(全局替换 + 命中统计 + 改编文本预览)。 */
329
+ adaptExecute(req: import('../protocol.ts').AdaptExecuteRequest): Promise<import('../protocol.ts').AdaptExecuteResponse>;
330
+ /** 改编模式 P3:保存改编全文为新书(原书保留,登记书架)。 */
331
+ adaptSave(req: import('../protocol.ts').AdaptSaveRequest): Promise<import('../protocol.ts').AdaptSaveResponse>;
332
+ /** 改编模式 P4:从源全文 + 编辑后方案提炼新书资料并保存为「待写新书」。 */
333
+ adaptMaterialize(req: import('../protocol.ts').AdaptMaterializeRequest): Promise<import('../protocol.ts').AdaptMaterializeResponse>;
334
+ /** 改编模式:保存预览/微调后的新书资料为新书(原书保留,登记书架)。 */
335
+ adaptMaterializeSave(req: AdaptMaterializeSaveRequest): Promise<AdaptMaterializeSaveResponse>;
336
+ /** 改编模式:rewrite 逐章重写(NDJSON 流式进度,支持分段 startNo/endNo)。 */
337
+ adaptRewriteStream(req: AdaptExecuteRequest, onFrame: (frame: AdaptRewriteFrame) => void): Promise<void>;
338
+ /** 主题自定义背景:上传图片,服务端存盘并返回可访问 URL。 */
339
+ themeBackgroundUpload(dataUrl: string): Promise<{
340
+ url: string;
341
+ }>;
166
342
  }
@@ -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,6 +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;
@@ -4,7 +4,7 @@
4
4
  * problems are logged, never thrown — the web shell fails the whole boot when
5
5
  * a plugin apply throws.
6
6
  */
7
- import type { ClientContext } from '@deepseek-ai/dsh-client-runtime/client';
7
+ import type { Context as ClientContext } from '@deepseek-ai/cordis';
8
8
  /** Required services (fiber inject waiting). */
9
9
  export declare const inject: string[];
10
10
  /**
@@ -0,0 +1,31 @@
1
+ /**
2
+ * 浏览器端「AI 创作实况」钩子:连接 /llm-live/stream (SSE),按 LLM 调用分组会话。
3
+ * 轻量实现,不持久化缓存(对齐上游 useLlmLiveFeed 的核心行为)。
4
+ */
5
+ import { type LlmLiveFrame, type LlmTokenUsage } from '../protocol.ts';
6
+ export type { LlmLiveFrame };
7
+ export interface LlmLiveSession {
8
+ sessionId: string;
9
+ label: string;
10
+ model?: string;
11
+ phase: 'requesting' | 'streaming' | 'completed' | 'failed';
12
+ phaseMessage: string;
13
+ preview: string;
14
+ totalChars: number;
15
+ startedAt: string;
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;
27
+ }
28
+ export declare function useLlmLiveFeed(enabled?: boolean): {
29
+ connected: boolean;
30
+ sessions: LlmLiveSession[];
31
+ };