- app/ (Electron 45 + TypeScript): the core joins one voice channel, decodes each speaker's Opus to 48 kHz stereo and streams it to the voice worker, sends speaking_end and speaker_leave, and emits speech_start/partial/final with the speaker's display name. - Sentence playback from the worker's TTS, first come first served, with stop that silences the clip at once and cancels unfinished requests; slash command join/leave/stop (create-or-update by name). - Transcription notice posted on every join; other bots ignored by default; at most maxSpeakers people transcribed at once. - Registered chat channels: live message events, history reads, sends split at 2,000 characters with mentions disabled; Message Content intent checked before login. - The app starts the Python voice worker with a fresh token in the environment, restarts it with backoff, and the worker client reconnects and fails in-flight TTS on a lost connection. - Spec in app/src/core/discord_core.spec.md; Vitest unit tests, a protocol test against the real Python worker server with fake engines, and an opt-in live test with two bots on real Discord. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
/**
|
|
* Electron main process. The GUI arrives in M5; for now the app runs its services in the background.
|
|
* The data folder comes from JARVIS_DATA_DIR until the setup wizard picks one (M5).
|
|
*/
|
|
import { join } from "node:path";
|
|
import { app } from "electron";
|
|
import { errorLog } from "./core/log.js";
|
|
import { startServices, type Services } from "./services.js";
|
|
|
|
const dataDir = process.env.JARVIS_DATA_DIR;
|
|
// Electron's own profile goes inside the data folder too, not into the user's AppData.
|
|
if (dataDir) app.setPath("userData", join(dataDir, "cache", "electron"));
|
|
|
|
if (!app.requestSingleInstanceLock()) app.quit();
|
|
|
|
let services: Services | null = null;
|
|
|
|
app.on("window-all-closed", () => {
|
|
// No windows yet; keep running.
|
|
});
|
|
|
|
app.whenReady().then(async () => {
|
|
if (!dataDir) throw new Error("JARVIS_DATA_DIR is not set");
|
|
services = await startServices(dataDir);
|
|
}).catch((e: Error) => {
|
|
errorLog(`could not start: ${e.message}`);
|
|
app.exit(1);
|
|
});
|
|
|
|
let quitting = false;
|
|
app.on("before-quit", (event) => {
|
|
if (quitting || !services) return;
|
|
event.preventDefault();
|
|
quitting = true;
|
|
void services.stop().finally(() => app.quit());
|
|
});
|