-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtypes.ts
More file actions
906 lines (821 loc) Β· 26 KB
/
Copy pathtypes.ts
File metadata and controls
906 lines (821 loc) Β· 26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
import type { Type } from '@google/genai';
import type { EntityState } from '@reduxjs/toolkit';
import type { ProjectData } from './features/project/projectSlice'; // Import ProjectData type
export type View =
| 'dashboard'
| 'manuscript'
| 'writer'
| 'templates'
| 'outline'
| 'characters'
| 'world'
| 'export'
| 'settings'
| 'help'
| 'sceneboard'
| 'analytics'
| 'zen'
| 'characterGraph'
| 'consistencyChecker'
| 'critic'
| 'preview'
| 'progress'
| 'objects'
| 'mindmap'
| 'characterInterviews'
| 'lora';
export interface Character {
id: string;
name: string;
backstory: string;
motivation: string;
appearance: string;
personalityTraits: string;
flaws: string;
notes: string;
hasAvatar?: boolean;
characterArc: string;
relationships: string;
}
export interface CharacterRelationship {
id: string;
fromCharacterId: string;
toCharacterId: string;
type: 'family' | 'romantic' | 'friend' | 'enemy' | 'mentor' | 'rival' | 'ally' | 'acquaintance';
description?: string;
strength: number; // 1-10
}
export interface WorldLocation {
id: string;
name: string;
description: string;
coordinates?: { lat: number; lng: number };
type: 'city' | 'village' | 'forest' | 'mountain' | 'castle' | 'temple' | 'other';
population?: number;
significance?: string;
}
export interface WorldTimelineEvent {
id: string;
era: string;
year?: number;
title: string;
description: string;
date?: string; // ISO date string
locationId?: string;
characterIds?: string[];
}
export interface WritingSession {
id: string;
date: string; // YYYY-MM-DD
startTime: string; // HH:MM
endTime: string; // HH:MM
wordsWritten: number;
sectionId?: string;
notes?: string;
}
export interface World {
id: string;
name: string;
description: string;
geography: string;
magicSystem: string;
culture: string;
notes: string;
hasAmbianceImage?: boolean;
timeline: WorldTimelineEvent[];
locations: WorldLocation[];
relationships?: CharacterRelationship[]; // Character relationships in this world
}
// --- Story Objects & Groups (Phase 1 β v1.7) ---
export type StoryObjectType =
| 'prop'
| 'weapon'
| 'vehicle'
| 'artifact'
| 'document'
| 'place-item'
| 'other';
export interface StoryObject {
id: string;
name: string;
description: string;
type: StoryObjectType;
groupIds: string[];
characterIds?: string[];
sceneIds?: string[];
significance?: string;
notes?: string;
imageAssetId?: string;
createdAt: string;
updatedAt: string;
}
export interface ObjectGroup {
id: string;
name: string;
description?: string;
color: string; // #hex
objectIds: string[];
createdAt: string;
updatedAt: string;
}
// --- Mind Maps (Phase 2 β v1.7) ---
export type MindMapNodeType = 'free' | 'linked';
export type MindMapLinkedEntityType = 'character' | 'world' | 'object' | 'group' | 'scene';
export type MindMapNodeShape = 'circle' | 'rectangle' | 'diamond' | 'ellipse' | 'hexagon';
export type MindMapEdgeStyle = 'solid' | 'dotted';
export type MindMapEdgeDirection = 'uni' | 'bi';
export interface MindMapNode {
id: string;
mindMapId: string;
label: string;
type: MindMapNodeType;
linkedEntityType?: MindMapLinkedEntityType;
linkedEntityId?: string;
position: { x: number; y: number };
color: string;
shape: MindMapNodeShape;
profileImageUrl?: string;
textNotes: string;
createdAt: string;
updatedAt: string;
}
export interface MindMapEdge {
id: string;
mindMapId: string;
sourceNodeId: string;
targetNodeId: string;
label?: string;
color: string;
style: MindMapEdgeStyle;
direction: MindMapEdgeDirection;
createdAt: string;
}
export interface MindMap {
id: string;
projectId: string;
name: string;
description?: string;
nodes: MindMapNode[];
edges: MindMapEdge[];
viewport?: { x: number; y: number; zoom: number };
createdAt: string;
updatedAt: string;
}
// ββ Character Interviews ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
export type CharacterArchetype =
| 'hero'
| 'mentor'
| 'villain'
| 'shadow'
| 'trickster'
| 'shapeshifter'
| 'herald'
| 'ally'
| 'threshold-guardian';
export interface InterviewMessage {
id: string;
role: 'user' | 'ai';
content: string;
timestamp: string;
}
export interface CharacterInterview {
id: string;
characterId: string;
archetype: CharacterArchetype;
templateId: string;
title?: string;
messages: InterviewMessage[];
createdAt: string;
updatedAt: string;
}
// ββ Binder ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
/** Hierarchical research / reference tree (Binder); stored with project data. */
export type BinderNodeType = 'folder' | 'text' | 'note' | 'image' | 'pdf' | 'link';
export interface BinderNode {
id: string;
parentId: string | null;
type: BinderNodeType;
title: string;
linkedSectionId?: string;
content?: string;
/** Legacy/small images may use character-style image store; binder blobs prefer `binderAssetId`. */
imageAssetId?: string;
/** Unified blob key for PDF/image/audio in StorageBackend binder asset API. */
binderAssetId?: string;
/** External reference (no blob). */
linkUrl?: string;
mimeType?: string;
byteSize?: number;
originalFileName?: string;
sortIndex: number;
}
export interface StorySection {
id: string;
title: string;
content: string;
prompt?: string;
summary?: string;
notes?: string;
color?: string; // For scene board cards
position?: { x: number; y: number }; // For scene board positioning
characterIds?: string[]; // Linked characters
worldIds?: string[]; // Linked worlds
wordCount?: number;
status?: 'draft' | 'outline' | 'first-draft' | 'revised' | 'final';
act?: 1 | 2 | 3; // Act membership for swimlanes
/** In-universe scene start (ISO-like or story-calendar string). */
sceneStart?: string;
/** Human-readable duration (e.g. PT2H, "3 days"). */
sceneDuration?: string;
/** Links to WorldLocation.id when places are modeled. */
sceneLocationId?: string;
/** Primary POV character for analytics. */
povCharacterId?: string;
}
/** Compile front/back matter (Scrivener-style), stored with project. */
export interface CompileMatterBlock {
id: string;
title: string;
bodyMarkdown: string;
}
export interface CompileProfile {
titlePageMarkdown?: string;
dedicationMarkdown?: string;
imprintMarkdown?: string;
acknowledgementsMarkdown?: string;
/** Ordered sections inserted before/after manuscript at export. */
frontMatter?: CompileMatterBlock[];
backMatter?: CompileMatterBlock[];
}
export interface StoryProject {
title: string;
logline: string;
author?: string;
characters: Character[] | EntityState<Character, string>;
worlds: World[] | EntityState<World, string>;
outline?: OutlineSection[];
manuscript: StorySection[];
/** Optional research binder (feature-flagged UI). */
binderNodes?: BinderNode[];
/** Export / compile metadata (title page, imprint, Normseiten tuning). */
compileProfile?: CompileProfile;
projectGoals?: {
totalWordCount: number;
targetDate: string | null;
};
writingHistory?: {
date: string; // YYYY-MM-DD
words: number;
}[];
}
export interface StoryCodexMention {
sectionId: string;
sectionTitle: string;
excerpt: string;
count: number;
}
export interface StoryCodexEntity {
id: string;
name: string;
type: 'character' | 'world' | 'location' | 'object' | 'event' | 'unknown';
known: boolean;
mentionCount: number;
canonicalId?: string | undefined;
mentions: StoryCodexMention[];
}
export interface StoryCodex {
projectId: string;
extractedAt: string;
entities: StoryCodexEntity[];
summary: string;
/** Co-mention edges between entities (Story Bible advanced). */
relationshipEdges?: StoryCodexRelationshipEdge[];
/** Rule-based consistency hints (Story Bible advanced). */
consistencyHints?: StoryCodexConsistencyHint[];
}
/** Undirected co-appearance edge derived from shared scene/section mentions. */
export interface StoryCodexRelationshipEdge {
sourceEntityId: string;
targetEntityId: string;
weight: number;
sectionIds: string[];
}
export interface StoryCodexConsistencyHint {
id: string;
severity: 'info' | 'warn';
message: string;
entityIds?: string[];
}
export interface Template {
id: string;
name: string;
description: string;
type: 'Genre' | 'Structure';
tags: string[];
arcDescription: string;
sections: { titleKey: string }[];
}
export interface OutlineSection {
id: string;
title: string;
description: string;
isTwist?: boolean;
}
// Settings Types
export type Theme = 'dark' | 'light' | 'auto';
/** Creative appearance presets β map to `body` classes in App (`.appearance-sepia`). */
export type AppearancePreset = 'default' | 'sepia';
/**
* AI execution mode β controls whether requests are routed to cloud providers,
* local on-device models, or resolved automatically (hybrid smart routing).
* Mirrors the CannaGuide-2025 AiMode pattern (localRoutingService ADR).
*/
export type AiMode = 'hybrid' | 'cloud' | 'local' | 'eco';
export type EditorFont = 'serif' | 'sans-serif' | 'monospace' | 'custom';
export type AiCreativity = 'Focused' | 'Balanced' | 'Imaginative';
export type AiModel =
// Gemini β latest generation (3.x)
| 'gemini-3.5-flash'
| 'gemini-3.1-pro-preview'
| 'gemini-3.1-flash'
| 'gemini-3.1-flash-lite'
// Gemini β 2.5 stable (backward compat for stored values)
| 'gemini-2.5-flash'
| 'gemini-2.5-pro'
// Gemini β legacy (backward compat for stored values)
| 'gemini-2.0-flash'
| 'gemini-2.0-flash-lite'
| 'gemini-1.5-flash'
| 'gemini-1.5-pro'
// Anthropic β Claude 4.x
| 'claude-opus-4-7'
| 'claude-sonnet-4-6'
| 'claude-haiku-4-5'
// Anthropic β Claude 3.x (backward compat for stored values)
| 'claude-3-sonnet'
| 'claude-3-haiku'
// OpenAI
| 'gpt-4o'
| 'gpt-4o-mini'
// Grok (xAI)
| 'grok-3'
| 'grok-3-mini'
// Ollama β any local model (e.g. "ollama/gemma3" or "ollama/qwen3:8b")
| `ollama/${string}`
// WebLLM β specific MLC-packaged checkpoints (see WEBLLM_SUPPORTED_MODELS in @domain/ai-core)
| 'Llama-3.2-1B-Instruct-q4f16_1-MLC'
| 'Llama-3.2-3B-Instruct-q4f16_1-MLC'
| 'Phi-3.5-mini-instruct-q4f16_1-MLC'
| 'gemma-2-2b-it-q4f16_1-MLC'
// QNBS-v3: Qwen 2.5 added in v1.5 WEBLLM_SUPPORTED_MODELS β keep AiModel in sync.
| 'Qwen2.5-0.5B-Instruct-q4f16_1-MLC'
/** Browser-only WebGPU path via @mlc-ai/web-llm (generic fallback for stored values). */
| 'webllm/browser'
// ONNX Runtime Web β WASM CPU/GPU inference (see ONNX_SUPPORTED_MODELS in @domain/ai-core)
| 'HuggingFaceTB/SmolLM2-135M-Instruct'
| 'Xenova/distilgpt2'
| 'Xenova/gpt2'
// Transformers.js β any Xenova-compatible HuggingFace model
| `Xenova/${string}`;
export type AIProvider =
| 'gemini'
| 'openai'
| 'anthropic'
| 'grok'
| 'ollama'
/** OpenRouter β unified OpenAI-compatible gateway with free-tier models and many open-source providers. */
| 'openrouter'
/** Fully in-browser inference (WebLLM / Transformers.js stack in @domain/ai-core). */
| 'webllm'
/** ONNX Runtime Web β CPU/WASM inference, no API key needed. */
| 'onnx'
/** Transformers.js β Xenova/HuggingFace WASM/WebGPU inference. */
| 'transformers';
/**
* Per-project AI preset β overrides global advancedAi settings for this project only.
* When enabled, buildAiOptions() merges these values over the global settings.
* LoRA fields are preparatory (webllm/onnx/transformers layer accepts them; actual
* weight loading is handled by localAiFacade once LoRA adapters are bundled).
*/
// QNBS-v3: exactOptionalPropertyTypes requires explicit `| undefined` so patch calls can clear fields.
export interface ProjectAiPreset {
enabled: boolean;
provider?: AIProvider | undefined;
model?: AiModel | undefined;
creativity?: AiCreativity | undefined;
temperature?: number | undefined;
maxTokens?: number | undefined;
/** Optional system-prompt override injected before the standard story prompts. */
customSystemPrompt?: string | undefined;
/** Path/id of a LoRA adapter compatible with the selected local model (future). */
loraModelPath?: string | undefined;
/** Adapter scale Ξ± (0β2, default 1.0). Controls LoRA influence strength. */
loraScale?: number | undefined;
}
export interface CustomFont {
name: string;
url: string;
format: 'woff' | 'woff2' | 'ttf' | 'otf';
}
export interface KeyboardShortcut {
id: string;
keys: string[];
action: string;
}
export interface WritingGoal {
id?: string;
type: 'words' | 'time' | 'sessions' | 'daily' | 'weekly' | 'monthly' | 'total';
target: number;
current?: number;
period: 'daily' | 'weekly' | 'monthly' | string;
achieved?: boolean;
enabled?: boolean;
}
/** Lokales OpenAI-kompatibles Backend β Preset setzt nur Default-URL (LM Studio, vLLM, β¦). */
export type LocalBackendPreset = 'ollama_default' | 'lm_studio' | 'vllm' | 'custom';
export interface AdvancedAiSettings {
model: AiModel;
provider: AIProvider;
temperature: number;
maxTokens: number;
topP: number;
frequencyPenalty: number;
presencePenalty: number;
customPrompts: Record<string, string>;
rateLimit: number; // requests per minute
ollamaBaseUrl: string;
/** Preset for local /v1 servers; switching sets the typical base URL (custom = manual URL). */
localBackendPreset: LocalBackendPreset;
/**
* OpenAI-compatible cloud or proxy API (OpenRouter, Groq, β¦): root without path, e.g. `https://openrouter.ai/api`.
* Empty = official OpenAI API (`api.openai.com`).
*/
openAiCompatibleBaseUrl: string;
/** Optional for OpenRouter rankings / attribution (HTTP Referer header). */
openAiSiteUrl: string;
/** Optional for OpenRouter (X-Title header). */
openAiSiteTitle: string;
/** Try additional providers after the primary provider on error (project thunks / legacy streaming). */
hybridFallbackEnabled: boolean;
/** Order of fallback providers (no duplicates; primary always comes first). */
hybridFallbackChain: AIProvider[];
// QNBS-v3: lexical = fast BoW only; hybrid = semantic MiniLM + lexical token-overlap + recency (default).
ragMode: 'lexical' | 'hybrid';
}
export type AccessibilityPresetId = 'custom' | 'motor' | 'lowVision' | 'cognitive' | 'screenReader';
export type LiveRegionVerbosity = 'minimal' | 'normal' | 'verbose';
export interface AccessibilitySettings {
highContrast: boolean;
reducedMotion: boolean;
largeText: boolean;
screenReader: boolean;
focusIndicators: boolean;
colorBlindMode: 'none' | 'protanopia' | 'deuteranopia' | 'tritanopia';
/** Last applied accessibility preset (manual tweaks set this to custom). */
presetId: AccessibilityPresetId;
/** Controls non-critical screen reader announcements (view titles always announce). */
liveRegionVerbosity: LiveRegionVerbosity;
/** Larger minimum tap targets (motor comfort). */
comfortableTargets: boolean;
}
export interface PrivacySettings {
analyticsEnabled: boolean;
dataEncryption: boolean;
localStorageOnly: boolean;
euDataResidency: boolean;
// QNBS-v3: SEC one-time migration marker. Before the analytics gate existed, analyticsEnabled was
// cosmetic (persistence was controlled solely by enableDuckDbAnalytics, default on), so legacy
// persisted settings hold a meaningless value. On the first load after the gate ships we reset
// analyticsEnabled to the new default to preserve prior behavior, then set this flag so the user's
// real choice is respected on every subsequent load. Optional for back-compat with old payloads.
analyticsGateMigrated?: boolean;
}
export interface CollaborationSettings {
/** WebRTC signaling URLs (wss:// or ws://), one per line in UI; empty uses built-in defaults. */
webrtcSignalingUrls: string[];
}
export interface IntegrationSettings {
/** Opt-in: nur eigener LanguageTool-Server (typ. localhost) β kein stiller Cloud-Upload. */
languageToolEnabled: boolean;
languageToolBaseUrl: string;
}
export interface AdvancedEditorSettings {
autoComplete: boolean;
spellCheck: boolean;
grammarCheck: boolean;
wordCount: boolean;
readingTime: boolean;
distractionFree: boolean;
typewriterMode: boolean;
zenMode: boolean;
focusMode: boolean;
customDictionary: string[];
writingStats: boolean;
}
export interface ThemeCustomization {
primaryColor: string;
secondaryColor: string;
accentColor: string;
backgroundColor: string;
textColor: string;
customCss: string;
}
// ββ Voice Full Support (opt-in) ββββββββββββββββββββββββββββββββββββββββββββββ
export type VoiceSttEngine = 'whisper' | 'webSpeech' | 'auto';
export type VoiceTtsEngine = 'kokoro' | 'piper' | 'webSpeech' | 'auto';
export type VoiceFeedbackLevel = 'minimal' | 'standard' | 'verbose';
export type VoiceActivationMode = 'pushToTalk' | 'wakeWord' | 'manual';
export interface VoiceSettings {
/** Master toggle β Voice Full Support opt-in */
enabled: boolean;
/** How voice is activated: PTT key, wake-word, or manual button */
activationMode: VoiceActivationMode;
/** Primary speech-to-text engine preference */
sttEngine: VoiceSttEngine;
/** Primary text-to-speech engine preference */
ttsEngine: VoiceTtsEngine;
/** Audio feedback verbosity */
feedbackLevel: VoiceFeedbackLevel;
/** TTS speech rate (0.5 - 2.0) */
speechRate: number;
/** TTS speech volume (0.0 - 1.0) */
speechVolume: number;
/** Allow cloud STT fallback when local engines unavailable */
allowCloudSttFallback: boolean;
/** Continuous listening timeout in seconds (5-30) */
listeningTimeoutSeconds: number;
/** Wake-word phrase (default: "Hey WorldScript") */
wakeWordPhrase: string;
/** Push-to-talk keyboard shortcut (stored as action id) */
pttShortcutId: string;
/** Mute all TTS output */
ttsMuted: boolean;
/** Dictation auto-punctuation */
dictationAutoPunctuation: boolean;
/** GDPR Art. 13 consent granted for Web Speech API (routes audio to cloud STT providers) */
webSpeechConsentGranted?: boolean;
/** WASM voice models download progress (0-1) */
wasmModelDownloadProgress?: number;
/** WASM voice models ready for use */
wasmModelsReady?: boolean;
/** WASM voice model download error message */
voiceWasmDownloadError?: string;
}
/** OpenRouter provider settings β key stored encrypted, model controls free-vs-paid selection. */
export interface OpenRouterSettings {
/** Whether OpenRouter is enabled as a provider in the routing chain. */
enabled: boolean;
/**
* OpenRouter API key (encrypted at rest via IDB AES-256-GCM when enableIdbAtRestEncryption is on).
* Never logged; sanitizeLogContext redacts it automatically.
*/
apiKey: string;
/**
* Preferred model identifier. Use `:free` suffix for the free tier
* (e.g. `"deepseek/deepseek-r1:free"`, `"meta-llama/llama-3.3-70b-instruct:free"`).
*/
preferredModel: string;
}
/** QNBS-v3 (T2): Desktop-only (Tauri) behavior. Ignored on the web. Extended by later native phases. */
export interface DesktopSettings {
/** Hide to the system tray on window close instead of quitting. */
minimizeToTray: boolean;
}
export interface Settings {
// Basic Settings
theme: Theme;
appearancePreset: AppearancePreset;
/** AI execution routing mode β hybrid (default), cloud-only, local-only, or eco (tiny models). */
aiMode: AiMode;
/** OpenRouter cloud provider settings β enabled/disabled, API key, preferred model. */
openRouter?: OpenRouterSettings;
editorFont: EditorFont;
fontSize: number;
lineSpacing: number;
aiCreativity: AiCreativity;
paragraphSpacing: number;
indentFirstLine: boolean;
// Advanced Settings
customFont?: CustomFont;
keyboardShortcuts: KeyboardShortcut[];
writingGoals: WritingGoal[];
advancedAi: AdvancedAiSettings;
accessibility: AccessibilitySettings;
privacy: PrivacySettings;
collaboration: CollaborationSettings;
integrations: IntegrationSettings;
advancedEditor: AdvancedEditorSettings;
themeCustomization: ThemeCustomization;
voice: VoiceSettings;
desktop: DesktopSettings;
// Legacy support
language?: string;
}
// Help Types
export interface HelpArticle {
title: string;
content: string;
/** Optional command id from the command registry (e.g. nav-manuscript). */
tryActionId?: string;
}
// βββ Version Control Types ββββββββββββββββββββββββββββββββββββββββββββββββββ
export interface VersionSnapshot {
id: string;
branchId: string;
label: string;
timestamp: string;
manuscriptSnapshot: string; // LZ-string compressed JSON of StorySection[]
wordCount: number;
parentId?: string;
/** When set, snapshot restores a single manuscript section only. */
sectionId?: string;
}
export interface VersionBranch {
id: string;
name: string;
description: string;
color: string;
createdAt: string;
headSnapshotId?: string;
}
/** Serialized alongside project payload for offline persistence of branches/snapshots. */
export interface PersistedVersionControlState {
branches: VersionBranch[];
snapshots: VersionSnapshot[];
currentBranchId: string;
}
// βββ Plot-Board v2 Types βββββββββββββββββββββββββββββββββββββββββββββββββββββ
/** A named subplot grouping scenes by a secondary story thread. */
export interface Subplot {
id: string;
name: string;
/** Hex color, e.g. "#a855f7". */
color: string;
sectionIds: string[];
}
export type PlotConnectionType =
| 'cause-effect'
| 'parallel'
| 'subplot'
| 'temporal'
| 'character-arc';
/** Directed edge between two scenes on the Plot-Board canvas. */
export interface PlotConnection {
id: string;
fromSectionId: string;
toSectionId: string;
type: PlotConnectionType;
/** When set, inherits color from the linked subplot. */
subplotId?: string;
label?: string;
/** Override color (hex). Falls back to connection-type default. */
color?: string;
}
// βββ Scene Revision + Comment Types ββββββββββββββββββββββββββββββββββββββββββ
/** Snapshot of a single scene at a point in time (stored in IDB, not Redux). */
export interface SceneRevision {
id: string;
sectionId: string;
createdAt: number; // Date.now()
title: string;
content: string;
wordCount: number;
/** User-supplied label, e.g. "Draft 2". */
label?: string;
authorName?: string;
}
export interface CommentReply {
id: string;
createdAt: number;
authorName: string;
authorColor: string;
body: string;
}
/** Threaded comment anchored to a scene, optionally to a text range. */
export interface SceneComment {
id: string;
sectionId: string;
createdAt: number;
authorName: string;
/** Hex color assigned to the author for avatar/highlight. */
authorColor: string;
body: string;
resolved: boolean;
/** Optional text selection anchor within the scene content. */
selectionStart?: number;
selectionEnd?: number;
replies: CommentReply[];
}
// βββ Community Template Types ββββββββββββββββββββββββββββββββββββββββββββββββ
export interface CommunityTemplate {
id: string;
name: string;
description: string;
type: 'Genre' | 'Structure';
tags: string[];
arcDescription: string;
author: string;
stars?: number;
sections: { title: string; description?: string }[];
}
// βββ Collaboration Types βββββββββββββββββββββββββββββββββββββββββββββββββββββ
export interface CollaborationUser {
id: string;
name: string;
color: string;
cursor?: number;
}
export interface CollaborationRoom {
roomId: string;
users: CollaborationUser[];
isConnected: boolean;
}
export interface HelpCategory {
id: string;
title: string;
icon: string;
articles: HelpArticle[];
}
// Snapshot Types
export interface ProjectSnapshot {
id: number;
date: string;
name: string;
wordCount: number;
}
// AI Types
export interface GeminiSchema {
type: Type;
items?: GeminiSchema;
properties?: Record<string, GeminiSchema>;
required?: string[];
description?: string;
}
export interface OutlineGenerationParams {
genre: string;
idea: string;
characters?: string;
setting?: string;
pacing?: string;
numChapters: number;
includeTwist: boolean;
lang: string;
}
export interface CustomTemplateParams {
customConcept: string;
customElements: string;
numSections: number;
lang: string;
}
// Speech Recognition Types
interface ISpeechRecognitionConstructor {
new (): ISpeechRecognition;
}
declare global {
interface Window {
SpeechRecognition: ISpeechRecognitionConstructor;
webkitSpeechRecognition: ISpeechRecognitionConstructor;
// QNBS-v3: cross-service gate set by listenerMiddleware (adaptive-AI ON/OFF) and read by
// localAiFacade β typed here so call sites avoid `(window as any)` casts (F-4 abatement).
__worldscript_adaptive_ai__?: boolean;
}
}
export interface ISpeechRecognitionEvent {
resultIndex: number;
results: {
[key: number]: {
isFinal: boolean;
[key: number]: {
transcript: string;
};
};
length: number;
};
}
export interface ISpeechRecognitionError {
error: string;
message?: string;
}
export interface ISpeechRecognition {
continuous: boolean;
interimResults: boolean;
lang: string;
start: () => void;
stop: () => void;
onresult: (event: ISpeechRecognitionEvent) => void;
onend: () => void;
onerror: (event: ISpeechRecognitionError) => void;
}
// Persistence Types
export interface PersistedRootState {
project?: {
present?: { data: ProjectData };
data?: ProjectData;
past?: unknown[];
future?: unknown[];
_latestUnfiltered?: unknown;
};
settings?: Settings;
status?: unknown;
writer?: unknown;
}