feat(V2-1a): Monorepo 구조 전환 — apps/desktop으로 V1 이동
- npm workspaces 루트 (apps/*, packages/*) 세팅 - V1 전체를 apps/desktop/으로 git mv (src, resources, tests, sidecar, scripts, electron.vite.config.ts, electron-builder.yml, vitest.config.ts, tsconfig.node.json, tsconfig.web.json) - apps/desktop/package.json 신규 (name=@d3ro/desktop) - productName: 'd3ro-voice' 명시 — app.getName()을 고정하여 userData 경로 %APPDATA%\d3ro-voice\ 그대로 유지 (기존 DB/설정 연속성 보장) - 루트 package.json을 workspace 루트로 재구성, 공통 devDep만 유지 (typescript, eslint, prettier) - turbo.json, tsconfig.base.json 추가 (Turborepo 자체 설치는 별도 sub-phase) - memory/project_status.md 생성 (규칙 13) 검증: - npm run typecheck 통과 - npm run build 통과 (electron-vite main+preload+renderer) - npm run dev 실제 실행 → DB/핫키/Ollama 자동 실행 모두 정상
This commit is contained in:
parent
3a160b9032
commit
45a580878a
178 changed files with 214 additions and 0 deletions
77
apps/desktop/src/main/ipc/llm-handlers.ts
Normal file
77
apps/desktop/src/main/ipc/llm-handlers.ts
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
// src/main/ipc/llm-handlers.ts
|
||||
|
||||
import { ipcMain } from 'electron'
|
||||
import { IPC_CHANNELS } from '@shared/ipc-channels'
|
||||
import { ipcSuccess, ipcError, ErrorCode } from '@shared/errors'
|
||||
import { getLocalLLMService } from '../services/LocalLLMService'
|
||||
import { configGet, configSet } from '../services/ConfigService'
|
||||
import { getMainWindow } from '../windows/WindowManager'
|
||||
import type { SetLLMModelParams, SetServerUrlParams, LLMProcessParams } from '@shared/types'
|
||||
|
||||
export function registerLLMHandlers(): void {
|
||||
// LLM 가용성 변경 시 렌더러에 상태 전파
|
||||
const llm = getLocalLLMService()
|
||||
llm.on('availability-changed', () => {
|
||||
const win = getMainWindow()
|
||||
if (win && !win.isDestroyed()) {
|
||||
win.webContents.send(IPC_CHANNELS.LLM.STATUS_CHANGED, { status: llm.getStatus() })
|
||||
}
|
||||
})
|
||||
ipcMain.handle(IPC_CHANNELS.LLM.GET_STATUS, async () => {
|
||||
return ipcSuccess(getLocalLLMService().getStatus())
|
||||
})
|
||||
|
||||
ipcMain.handle(IPC_CHANNELS.LLM.GET_MODELS, async () => {
|
||||
try {
|
||||
const models = await getLocalLLMService().getModels()
|
||||
return ipcSuccess(models)
|
||||
} catch {
|
||||
return ipcError(ErrorCode.LLMServerUnreachable, 'Failed to get models')
|
||||
}
|
||||
})
|
||||
|
||||
ipcMain.handle(IPC_CHANNELS.LLM.GET_ACTIVE_MODEL, async () => {
|
||||
return ipcSuccess(configGet('llmModelId'))
|
||||
})
|
||||
|
||||
ipcMain.handle(IPC_CHANNELS.LLM.SET_MODEL, async (_event, params: SetLLMModelParams) => {
|
||||
configSet('llmModelId', params.modelId)
|
||||
return ipcSuccess(undefined)
|
||||
})
|
||||
|
||||
ipcMain.handle(IPC_CHANNELS.LLM.PROCESS, async (_event, params: LLMProcessParams) => {
|
||||
try {
|
||||
const llm = getLocalLLMService()
|
||||
const start = performance.now()
|
||||
const processedText = await llm.processText(
|
||||
params.text,
|
||||
params.action,
|
||||
params.targetLanguage,
|
||||
params.customPrompt
|
||||
)
|
||||
return ipcSuccess({
|
||||
originalText: params.text,
|
||||
processedText,
|
||||
action: params.action,
|
||||
processingTimeMs: Math.round(performance.now() - start),
|
||||
tokenCount: 0
|
||||
})
|
||||
} catch {
|
||||
return ipcError(ErrorCode.LLMProcessingFailed, 'LLM processing failed')
|
||||
}
|
||||
})
|
||||
|
||||
ipcMain.handle(IPC_CHANNELS.LLM.CANCEL_PROCESS, async () => {
|
||||
getLocalLLMService().cancelGeneration()
|
||||
return ipcSuccess(undefined)
|
||||
})
|
||||
|
||||
ipcMain.handle(IPC_CHANNELS.LLM.GET_SERVER_URL, async () => {
|
||||
return ipcSuccess(configGet('ollamaServerUrl'))
|
||||
})
|
||||
|
||||
ipcMain.handle(IPC_CHANNELS.LLM.SET_SERVER_URL, async (_event, params: SetServerUrlParams) => {
|
||||
configSet('ollamaServerUrl', params.url)
|
||||
return ipcSuccess(undefined)
|
||||
})
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue