mirror of
https://github.com/Heretek-AI/GDevelop-BYOK.git
synced 2026-07-01 18:48:04 -04:00
[GH-ISSUE #18] M001/S01/T02: Create IPC handler and preload bridge #18
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @BillyOutlast on GitHub (May 16, 2026).
Original GitHub issue: https://github.com/Heretek-AI/GDevelop-BYOK/issues/18
T02: Create IPC handler and preload bridge
The proxy modules (T01) need to be wired into Electron's IPC system. The IPC handler lives in the main process; the preload bridge exposes it to the renderer. (1) Create src/ipc/byokHandler.js — export registerByokIpcHandlers(ipcMain) which registers a single ipcMain.handle('byok-ai-request', handler). The handler reads payload { mode, messages, userRequest, projectContext, aiConfiguration } from the renderer. Mode routing: 'chat' → direct request-response returning { content, usage }; 'agent' | 'orchestrator' → fire-and-forget via requestStore, returns { requestId }. Uses callLLM from T01, buildSystemPrompt to assemble system message + user messages. Integrates ByokError. Logs entry/exit/failure to console. (2) Create src/preload/byokBridge.js — uses contextBridge.exposeInMainWorld('byokAiRequest', ...) wrapping ipcRenderer.invoke('byok-ai-request', payload). Exposes byokAiRequest(payload) and byokAiRequestStatus(requestId) (polls requestStore). (3) Write unit tests using node:test that exercise the handler's mode routing with mocked ipcMain and proxy modules.
Files
src/ipc/byokHandler.jssrc/preload/byokBridge.jstest/unit/ipc.test.jsVerification