Phase 1+2 구현: Electron 뼈대 + STT/핫키/오케스트레이터
Phase 1: - 프로젝트 초기화 (TypeScript strict, electron-vite, ESLint, Prettier) - shared 타입 (ipc-channels 113채널, types, errors, constants) - 메인 프로세스 뼈대 (bootstrap, lifecycle, 단일 인스턴스) - LoggerService, ConfigService (electron-store ESM dynamic import) - React 19 + MUI 7 Dashboard, 시스템 트레이 Phase 2: - AudioCaptureService (node-record-lpcm16, PCM16 16kHz mono) - HotkeyService (uiohook-napi, 더블프레스, holdMode/toggleMode) - LocalSTTService (faster-whisper Python sidecar, 이중 조건 플러시) - VoiceModeService 오케스트레이터 (이중 상태머신, Action Queue) - Python sidecar (FastAPI: health/load/transcribe/shutdown) - IPC 핸들러 (voice, stt, hotkey) + Preload API 확장
This commit is contained in:
parent
e24bb8378c
commit
1d152d01a1
46 changed files with 10828 additions and 4 deletions
658
src/shared/types.ts
Normal file
658
src/shared/types.ts
Normal file
|
|
@ -0,0 +1,658 @@
|
|||
// src/shared/types.ts
|
||||
// 모든 IPC 파라미터/반환 타입 정의
|
||||
|
||||
// ============================================================
|
||||
// Common
|
||||
// ============================================================
|
||||
|
||||
export type ThemeMode = 'light' | 'dark' | 'auto'
|
||||
|
||||
export type VoiceMode = 'dictation' | 'hands-free'
|
||||
|
||||
export type PermissionStatus = 'granted' | 'denied' | 'unknown'
|
||||
|
||||
// ============================================================
|
||||
// Voice (음성 오케스트레이션)
|
||||
// ============================================================
|
||||
|
||||
export enum RecognitionState {
|
||||
IDLE = 'idle',
|
||||
PREPARING = 'preparing',
|
||||
CONNECTING = 'connecting',
|
||||
READY = 'ready',
|
||||
RECOGNIZING = 'recognizing',
|
||||
COMPLETED = 'completed',
|
||||
CANCELLED = 'cancelled',
|
||||
ERROR = 'error',
|
||||
DESTROYED = 'destroyed'
|
||||
}
|
||||
|
||||
export enum AudioState {
|
||||
IDLE = 'idle',
|
||||
INITIALIZING = 'initializing',
|
||||
STREAMING = 'streaming',
|
||||
STOPPED = 'stopped'
|
||||
}
|
||||
|
||||
export interface VoiceState {
|
||||
recognitionState: RecognitionState
|
||||
audioState: AudioState
|
||||
mode: VoiceMode
|
||||
sessionId: string | null
|
||||
recordingStartedAt: number | null
|
||||
}
|
||||
|
||||
export interface StartRecordingParams {
|
||||
sessionId?: string
|
||||
deviceId?: string
|
||||
}
|
||||
|
||||
export interface StartRecordingResult {
|
||||
sessionId: string
|
||||
}
|
||||
|
||||
export interface StopRecordingParams {
|
||||
sessionId: string
|
||||
}
|
||||
|
||||
export interface StopRecordingResult {
|
||||
sessionId: string
|
||||
text: string
|
||||
durationMs: number
|
||||
}
|
||||
|
||||
export interface CancelRecordingParams {
|
||||
sessionId: string
|
||||
}
|
||||
|
||||
export interface SetVoiceModeParams {
|
||||
mode: VoiceMode
|
||||
}
|
||||
|
||||
// Voice events (Main → Renderer)
|
||||
|
||||
export interface VoiceStateChangedEvent {
|
||||
previousState: RecognitionState
|
||||
currentState: RecognitionState
|
||||
audioState: AudioState
|
||||
sessionId: string | null
|
||||
}
|
||||
|
||||
export interface TranscriptionDeltaEvent {
|
||||
sessionId: string
|
||||
text: string
|
||||
delta: string
|
||||
isFinal: boolean
|
||||
}
|
||||
|
||||
export interface TranscriptionCompleteEvent {
|
||||
sessionId: string
|
||||
text: string
|
||||
durationMs: number
|
||||
language: string
|
||||
}
|
||||
|
||||
export interface VoiceErrorEvent {
|
||||
sessionId: string | null
|
||||
errorCode: number
|
||||
message: string
|
||||
}
|
||||
|
||||
export interface AudioLevelEvent {
|
||||
level: number
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// Audio (디바이스 & 캡처)
|
||||
// ============================================================
|
||||
|
||||
export interface AudioDevice {
|
||||
deviceId: string
|
||||
label: string
|
||||
isDefault: boolean
|
||||
}
|
||||
|
||||
export interface SetDeviceParams {
|
||||
deviceId: string
|
||||
}
|
||||
|
||||
export interface TestDeviceParams {
|
||||
deviceId: string
|
||||
durationMs?: number
|
||||
}
|
||||
|
||||
export interface TestDeviceResult {
|
||||
averageLevel: number
|
||||
peakLevel: number
|
||||
hasAudio: boolean
|
||||
}
|
||||
|
||||
export interface AudioDeviceChangedEvent {
|
||||
devices: AudioDevice[]
|
||||
type: 'added' | 'removed' | 'default-changed'
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// STT (로컬 Whisper)
|
||||
// ============================================================
|
||||
|
||||
export enum STTEngineState {
|
||||
NOT_INSTALLED = 'not-installed',
|
||||
DOWNLOADING = 'downloading',
|
||||
LOADING = 'loading',
|
||||
READY = 'ready',
|
||||
PROCESSING = 'processing',
|
||||
ERROR = 'error'
|
||||
}
|
||||
|
||||
export interface STTStatus {
|
||||
engineState: STTEngineState
|
||||
activeModel: string | null
|
||||
engineVersion: string | null
|
||||
gpuAccelerated: boolean
|
||||
}
|
||||
|
||||
export interface STTModel {
|
||||
id: string
|
||||
name: string
|
||||
sizeBytes: number
|
||||
downloaded: boolean
|
||||
languages: string[]
|
||||
accuracy: number
|
||||
speed: number
|
||||
}
|
||||
|
||||
export interface SetSTTModelParams {
|
||||
modelId: string
|
||||
}
|
||||
|
||||
export interface DownloadModelParams {
|
||||
modelId: string
|
||||
}
|
||||
|
||||
export interface SetSTTLanguageParams {
|
||||
language: string
|
||||
}
|
||||
|
||||
export interface STTStatusChangedEvent {
|
||||
status: STTStatus
|
||||
}
|
||||
|
||||
export interface DownloadProgressEvent {
|
||||
modelId: string
|
||||
percent: number
|
||||
downloadedBytes: number
|
||||
totalBytes: number
|
||||
bytesPerSecond: number
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// TTS (로컬 TTS)
|
||||
// ============================================================
|
||||
|
||||
export enum TTSEngineState {
|
||||
NOT_INSTALLED = 'not-installed',
|
||||
LOADING = 'loading',
|
||||
READY = 'ready',
|
||||
SPEAKING = 'speaking',
|
||||
ERROR = 'error'
|
||||
}
|
||||
|
||||
export interface TTSStatus {
|
||||
engineState: TTSEngineState
|
||||
activeVoice: string | null
|
||||
engineVersion: string | null
|
||||
}
|
||||
|
||||
export interface TTSVoice {
|
||||
id: string
|
||||
name: string
|
||||
language: string
|
||||
gender: 'male' | 'female' | 'neutral'
|
||||
downloaded: boolean
|
||||
sizeBytes: number
|
||||
}
|
||||
|
||||
export interface TTSSpeakParams {
|
||||
text: string
|
||||
voiceId?: string
|
||||
speed?: number
|
||||
}
|
||||
|
||||
export interface TTSSpeakResult {
|
||||
durationMs: number
|
||||
}
|
||||
|
||||
export interface SetTTSVoiceParams {
|
||||
voiceId: string
|
||||
}
|
||||
|
||||
export interface DownloadVoiceParams {
|
||||
voiceId: string
|
||||
}
|
||||
|
||||
export interface TTSStatusChangedEvent {
|
||||
status: TTSStatus
|
||||
}
|
||||
|
||||
export interface SpeakingStateChangedEvent {
|
||||
isSpeaking: boolean
|
||||
text: string
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// LLM (Ollama)
|
||||
// ============================================================
|
||||
|
||||
export enum LLMConnectionState {
|
||||
DISCONNECTED = 'disconnected',
|
||||
CONNECTING = 'connecting',
|
||||
CONNECTED = 'connected',
|
||||
ERROR = 'error'
|
||||
}
|
||||
|
||||
export interface LLMStatus {
|
||||
connectionState: LLMConnectionState
|
||||
serverUrl: string
|
||||
activeModel: string | null
|
||||
serverVersion: string | null
|
||||
}
|
||||
|
||||
export interface LLMModel {
|
||||
id: string
|
||||
name: string
|
||||
sizeBytes: number
|
||||
parameterSize: string
|
||||
quantization: string
|
||||
modifiedAt: string
|
||||
}
|
||||
|
||||
export type LLMAction = 'refine' | 'translate' | 'summarize' | 'expand' | 'grammar' | 'custom'
|
||||
|
||||
export interface LLMProcessParams {
|
||||
text: string
|
||||
action: LLMAction
|
||||
targetLanguage?: string
|
||||
customPrompt?: string
|
||||
modelId?: string
|
||||
}
|
||||
|
||||
export interface LLMProcessResult {
|
||||
originalText: string
|
||||
processedText: string
|
||||
action: LLMAction
|
||||
processingTimeMs: number
|
||||
tokenCount: number
|
||||
}
|
||||
|
||||
export interface SetLLMModelParams {
|
||||
modelId: string
|
||||
}
|
||||
|
||||
export interface SetServerUrlParams {
|
||||
url: string
|
||||
}
|
||||
|
||||
export interface PullModelParams {
|
||||
modelName: string
|
||||
}
|
||||
|
||||
export interface LLMStatusChangedEvent {
|
||||
status: LLMStatus
|
||||
}
|
||||
|
||||
export interface LLMProcessProgressEvent {
|
||||
text: string
|
||||
token: string
|
||||
done: boolean
|
||||
}
|
||||
|
||||
export interface LLMPullProgressEvent {
|
||||
modelName: string
|
||||
status: string
|
||||
percent: number
|
||||
downloadedBytes: number
|
||||
totalBytes: number
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// Hotkey (핫키)
|
||||
// ============================================================
|
||||
|
||||
export interface HotkeyBinding {
|
||||
keyCode: number
|
||||
ctrl: boolean
|
||||
alt: boolean
|
||||
shift: boolean
|
||||
meta: boolean
|
||||
displayLabel: string
|
||||
}
|
||||
|
||||
export interface SetHotkeyParams {
|
||||
binding: HotkeyBinding
|
||||
}
|
||||
|
||||
export interface SetEnabledParams {
|
||||
enabled: boolean
|
||||
}
|
||||
|
||||
export type HotkeyAction = 'dictation' | 'hands-free' | 'command'
|
||||
|
||||
export interface HotkeyTriggeredEvent {
|
||||
action: HotkeyAction
|
||||
type: 'pressed' | 'released'
|
||||
isDoublePress: boolean
|
||||
}
|
||||
|
||||
export interface HotkeyRecordingResultEvent {
|
||||
binding: HotkeyBinding | null
|
||||
conflictReason: string | null
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// Config (설정)
|
||||
// ============================================================
|
||||
|
||||
export interface AppConfig {
|
||||
theme: ThemeMode
|
||||
language: string
|
||||
closeToTray: boolean
|
||||
autoLaunch: boolean
|
||||
soundEnabled: boolean
|
||||
selectedDeviceId: string | null
|
||||
sttModelId: string
|
||||
sttLanguage: string
|
||||
ttsVoiceId: string | null
|
||||
ttsSpeed: number
|
||||
ollamaServerUrl: string
|
||||
llmModelId: string | null
|
||||
defaultLLMAction: LLMAction
|
||||
dictationShortcut: HotkeyBinding
|
||||
handsFreeShortcut: HotkeyBinding
|
||||
commandShortcut: HotkeyBinding
|
||||
hotkeyEnabled: boolean
|
||||
insertMethod: 'clipboard' | 'keyboard'
|
||||
autoInsert: boolean
|
||||
maxHistoryEntries: number
|
||||
}
|
||||
|
||||
export interface ConfigGetParams {
|
||||
key: keyof AppConfig
|
||||
}
|
||||
|
||||
export interface ConfigSetParams {
|
||||
key: keyof AppConfig
|
||||
value: AppConfig[keyof AppConfig]
|
||||
}
|
||||
|
||||
export interface ConfigResetParams {
|
||||
key?: keyof AppConfig
|
||||
}
|
||||
|
||||
export interface SetThemeParams {
|
||||
theme: ThemeMode
|
||||
}
|
||||
|
||||
export interface SetLanguageParams {
|
||||
language: string
|
||||
}
|
||||
|
||||
export interface SetAutoLaunchParams {
|
||||
enabled: boolean
|
||||
}
|
||||
|
||||
export interface SetCloseToTrayParams {
|
||||
enabled: boolean
|
||||
}
|
||||
|
||||
export interface ConfigChangedEvent {
|
||||
key: keyof AppConfig
|
||||
value: AppConfig[keyof AppConfig]
|
||||
previousValue: AppConfig[keyof AppConfig]
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// History (히스토리)
|
||||
// ============================================================
|
||||
|
||||
export interface HistoryEntry {
|
||||
id: string
|
||||
originalText: string
|
||||
polishedText: string | null
|
||||
focusedApp: string | null
|
||||
focusedAppName: string | null
|
||||
focusedAppWindowTitle: string | null
|
||||
mode: 'dictation' | 'translate' | 'command'
|
||||
status: 'completed' | 'cancelled' | 'error'
|
||||
errorCode: string | null
|
||||
audioLocalPath: string | null
|
||||
duration: number
|
||||
detectedLanguage: string | null
|
||||
micDevice: string | null
|
||||
wordCount: number
|
||||
sttModel: string | null
|
||||
llmModel: string | null
|
||||
sttLatencyMs: number | null
|
||||
llmLatencyMs: number | null
|
||||
createdAt: number
|
||||
updatedAt: number
|
||||
appVersion: string
|
||||
}
|
||||
|
||||
export interface HistoryQueryParams {
|
||||
page: number
|
||||
pageSize: number
|
||||
sortBy?: 'createdAt' | 'durationMs' | 'wordCount'
|
||||
sortOrder?: 'asc' | 'desc'
|
||||
}
|
||||
|
||||
export interface HistoryPage {
|
||||
entries: HistoryEntry[]
|
||||
total: number
|
||||
page: number
|
||||
pageSize: number
|
||||
totalPages: number
|
||||
}
|
||||
|
||||
export interface HistoryGetByIdParams {
|
||||
id: string
|
||||
}
|
||||
|
||||
export interface HistoryDeleteParams {
|
||||
id: string
|
||||
}
|
||||
|
||||
export interface HistorySearchParams {
|
||||
query: string
|
||||
page: number
|
||||
pageSize: number
|
||||
}
|
||||
|
||||
export interface HistoryExportParams {
|
||||
format: 'json' | 'csv'
|
||||
from?: string
|
||||
to?: string
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// Dictionary (사전)
|
||||
// ============================================================
|
||||
|
||||
export interface DictionaryEntry {
|
||||
id: string
|
||||
word: string
|
||||
pronunciation: string | null
|
||||
category: 'user' | 'auto' | 'technical'
|
||||
usageCount: number
|
||||
lastUsedAt: number | null
|
||||
createdAt: number
|
||||
updatedAt: number
|
||||
}
|
||||
|
||||
export interface DictionaryQueryParams {
|
||||
page: number
|
||||
pageSize: number
|
||||
sortBy?: 'word' | 'category' | 'usageCount' | 'createdAt'
|
||||
sortOrder?: 'asc' | 'desc'
|
||||
}
|
||||
|
||||
export interface DictionaryPage {
|
||||
entries: DictionaryEntry[]
|
||||
total: number
|
||||
page: number
|
||||
pageSize: number
|
||||
totalPages: number
|
||||
}
|
||||
|
||||
export interface DictionaryAddParams {
|
||||
word: string
|
||||
pronunciation?: string
|
||||
category?: 'user' | 'auto' | 'technical'
|
||||
}
|
||||
|
||||
export interface DictionaryUpdateParams {
|
||||
id: string
|
||||
word?: string
|
||||
pronunciation?: string
|
||||
category?: 'user' | 'auto' | 'technical'
|
||||
}
|
||||
|
||||
export interface DictionaryDeleteParams {
|
||||
id: string
|
||||
}
|
||||
|
||||
export interface DictionaryImportParams {
|
||||
filePath: string
|
||||
format: 'json' | 'csv'
|
||||
}
|
||||
|
||||
export interface DictionaryImportResult {
|
||||
imported: number
|
||||
skipped: number
|
||||
errors: number
|
||||
}
|
||||
|
||||
export interface DictionaryExportParams {
|
||||
format: 'json' | 'csv'
|
||||
}
|
||||
|
||||
export interface DictionarySearchParams {
|
||||
query: string
|
||||
page: number
|
||||
pageSize: number
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// Window (윈도우 제어)
|
||||
// ============================================================
|
||||
|
||||
export type RecordingTipState = 'opening' | 'recording' | 'thinking' | 'result' | 'error'
|
||||
|
||||
export interface ShowRecordingTipParams {
|
||||
state: RecordingTipState
|
||||
text?: string
|
||||
errorMessage?: string
|
||||
}
|
||||
|
||||
export interface ShowResultPopupParams {
|
||||
text: string
|
||||
autoHideMs?: number
|
||||
}
|
||||
|
||||
export interface TipMeasuredParams {
|
||||
width: number
|
||||
height: number
|
||||
}
|
||||
|
||||
export interface TipStateChangedEvent {
|
||||
state: RecordingTipState
|
||||
text?: string
|
||||
errorMessage?: string
|
||||
}
|
||||
|
||||
export interface TipPrepareEvent {
|
||||
state: RecordingTipState
|
||||
text?: string
|
||||
}
|
||||
|
||||
export interface TipShowEvent {
|
||||
state: RecordingTipState
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// System (시스템)
|
||||
// ============================================================
|
||||
|
||||
export interface ActiveAppInfo {
|
||||
name: string
|
||||
title: string
|
||||
pid: number
|
||||
}
|
||||
|
||||
export interface ShowNotificationParams {
|
||||
title: string
|
||||
body: string
|
||||
type?: 'info' | 'warning' | 'error'
|
||||
}
|
||||
|
||||
export interface OpenExternalParams {
|
||||
url: string
|
||||
}
|
||||
|
||||
export interface InsertTextParams {
|
||||
text: string
|
||||
method?: 'clipboard' | 'keyboard'
|
||||
}
|
||||
|
||||
export interface InsertTextResult {
|
||||
success: boolean
|
||||
insertedLength: number
|
||||
}
|
||||
|
||||
export type SoundEffect =
|
||||
| 'recording-start'
|
||||
| 'recording-stop'
|
||||
| 'transcription-complete'
|
||||
| 'error'
|
||||
| 'notification'
|
||||
|
||||
export interface PlaySoundParams {
|
||||
sound: SoundEffect
|
||||
}
|
||||
|
||||
export interface SetSoundEnabledParams {
|
||||
enabled: boolean
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// Stats (통계)
|
||||
// ============================================================
|
||||
|
||||
export interface StatsSummary {
|
||||
totalRecordingTimeMs: number
|
||||
totalWordCount: number
|
||||
totalSessionCount: number
|
||||
todayRecordingTimeMs: number
|
||||
todayWordCount: number
|
||||
todaySessionCount: number
|
||||
streakDays: number
|
||||
}
|
||||
|
||||
export interface StatsQueryParams {
|
||||
from: string
|
||||
to: string
|
||||
}
|
||||
|
||||
export interface DailyStats {
|
||||
date: string
|
||||
recordingTimeMs: number
|
||||
wordCount: number
|
||||
sessionCount: number
|
||||
}
|
||||
|
||||
export interface WeeklyStats {
|
||||
weekStart: string
|
||||
recordingTimeMs: number
|
||||
wordCount: number
|
||||
sessionCount: number
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue