packages/core (@d3ro/core) 신규 생성:
- types.ts, errors.ts, ipc-channels.ts, constants.ts (shared에서 이동)
- utils/meeting-markdown.ts, utils/markdown-to-docx.ts (main/utils에서 이동)
- subpath exports 정의 (./types, ./errors, ./ipc-channels, ./constants,
./utils/meeting-markdown, ./utils/markdown-to-docx)
- src/index.ts barrel export 추가
- docx를 core 자체 dependency로 선언
apps/desktop 연결:
- package.json에 @d3ro/core: '*' dep 추가
- tsconfig.node/web.json paths에 @d3ro/core/* 추가
- electron.vite.config.ts 3개 섹션 alias 추가 (main/preload/renderer)
- externalizeDepsPlugin exclude에 @d3ro/core (workspace 소스 번들 대상)
- vitest.config.ts alias 추가
일괄 치환 (79 파일, 167건):
- @shared/{types,errors,ipc-channels,constants} → @d3ro/core/*
- static/dynamic import + type expression import 모두 포함
- MeetingModeService.ts의 ../utils/* 상대 경로 → @d3ro/core/utils/*
- @shared/theme-vars는 V2-1c 범위로 남김 (WindowManager만 사용)
M1 수정 포함:
- electron.vite.config.ts의 resolve('src/shared') → resolve(__dirname, ...)
CWD 독립적으로 동작하도록 견고화
검증:
- typecheck 통과
- build 통과 (main+preload+renderer)
- dev 런타임 → DB/핫키/Ollama 모두 정상, 기존 데이터 연속성 유지
88 lines
2.6 KiB
TypeScript
88 lines
2.6 KiB
TypeScript
// src/main/ipc/chain-handlers.ts
|
|
// Phase 10.4: Multi-LLM Chain IPC 핸들러
|
|
|
|
import { ipcMain } from 'electron'
|
|
import { IPC_CHANNELS } from '@d3ro/core/ipc-channels'
|
|
import { ipcSuccess, ipcError, ErrorCode, D3ROError } from '@d3ro/core/errors'
|
|
import { getChainService } from '../services/ChainService'
|
|
import type {
|
|
CreateChainParams,
|
|
UpdateChainParams,
|
|
DeleteChainParams,
|
|
ExecuteChainParams
|
|
} from '@d3ro/core/types'
|
|
|
|
export function registerChainHandlers(): void {
|
|
ipcMain.handle(IPC_CHANNELS.CHAIN.GET_ALL, async () => {
|
|
return ipcSuccess(getChainService().getAll())
|
|
})
|
|
|
|
ipcMain.handle(
|
|
IPC_CHANNELS.CHAIN.CREATE,
|
|
async (_event, params: CreateChainParams) => {
|
|
try {
|
|
const result = getChainService().create(params)
|
|
return ipcSuccess(result)
|
|
} catch (err) {
|
|
return ipcError(
|
|
ErrorCode.ConfigWriteFailed,
|
|
`Failed to create chain: ${err instanceof Error ? err.message : String(err)}`
|
|
)
|
|
}
|
|
}
|
|
)
|
|
|
|
ipcMain.handle(
|
|
IPC_CHANNELS.CHAIN.UPDATE,
|
|
async (_event, params: UpdateChainParams) => {
|
|
try {
|
|
const result = getChainService().update(params)
|
|
return ipcSuccess(result)
|
|
} catch (err) {
|
|
if (err instanceof D3ROError && err.code === ErrorCode.ChainNotFound) {
|
|
return ipcError(ErrorCode.ChainNotFound, err.message)
|
|
}
|
|
return ipcError(
|
|
ErrorCode.ConfigWriteFailed,
|
|
`Failed to update chain: ${err instanceof Error ? err.message : String(err)}`
|
|
)
|
|
}
|
|
}
|
|
)
|
|
|
|
ipcMain.handle(
|
|
IPC_CHANNELS.CHAIN.DELETE,
|
|
async (_event, params: DeleteChainParams) => {
|
|
try {
|
|
getChainService().delete(params.id)
|
|
return ipcSuccess(undefined)
|
|
} catch (err) {
|
|
if (err instanceof D3ROError && err.code === ErrorCode.ChainNotFound) {
|
|
return ipcError(ErrorCode.ChainNotFound, err.message)
|
|
}
|
|
return ipcError(
|
|
ErrorCode.ConfigWriteFailed,
|
|
`Failed to delete chain: ${err instanceof Error ? err.message : String(err)}`
|
|
)
|
|
}
|
|
}
|
|
)
|
|
|
|
ipcMain.handle(
|
|
IPC_CHANNELS.CHAIN.EXECUTE,
|
|
async (_event, params: ExecuteChainParams) => {
|
|
try {
|
|
const result = await getChainService().execute(params.chainId, params.text)
|
|
return ipcSuccess(result)
|
|
} catch (err) {
|
|
if (err instanceof D3ROError) {
|
|
return ipcError(err.code, err.message)
|
|
}
|
|
return ipcError(
|
|
ErrorCode.ChainExecutionFailed,
|
|
`Chain execution failed: ${err instanceof Error ? err.message : String(err)}`
|
|
)
|
|
}
|
|
}
|
|
)
|
|
}
|