Files
javis_bot/bot/src/config.ts
javis-bot ef6f6ff57d feat(stream): STREAM_BROWSER flag + make toolbar-hide/subtitles broadcast-wide
- Add STREAM_BROWSER (.env) gating screen-share/browser mode. false => the
  /자비스 stream command stays voice + API/MCP only (no Go-Live); true (default)
  => screen share as before. (Browser-driven info retrieval in true mode is a
  follow-up build; the bot has no browser-control tools yet.)
- Make the two test-time fixes broadcast-wide defaults via broadcast-helper.mjs:
  it now also watches every tab for HTML5 fullscreen and toggles Chrome window
  fullscreen so the address bar is hidden for ANY video (xfwm4 won't hide it on
  'f' alone), restoring on exit. Subtitles were already enforced per video.
  scenario.mjs drops its own fullscreen toggle and relies on the helper.
- Revert the test-settings env vars from .env.example (not wanted).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-10 16:17:29 +09:00

67 lines
2.6 KiB
TypeScript

/**
* Centralised, typed configuration loaded from environment (.env at repo root).
* Nothing else in the bot reads process.env directly.
*/
import "dotenv/config";
function req(name: string): string {
const v = process.env[name];
if (!v) throw new Error(`Missing required env var: ${name} (see .env.example)`);
return v;
}
function opt(name: string, fallback = ""): string {
return process.env[name] ?? fallback;
}
export type StreamBackend = "selfbot" | "novnc" | "screenshot" | "none";
export const config = {
// --- Normal Discord bot (voice I/O, slash commands) ---
botToken: req("DISCORD_BOT_TOKEN"),
appId: req("DISCORD_APP_ID"),
guildId: req("DISCORD_GUILD_ID"),
// --- Python brain bridge ---
bridgeUrl: opt("BRIDGE_URL", "http://127.0.0.1:8765"),
// --- VNC screen broadcast ---
// selfbot = real live "Go Live" stream via a user (burner) account token
// novnc = post a noVNC web link the channel can open in a browser
// screenshot= periodically upload VNC screenshots
// none = disable screen sharing
streamBackend: (opt("STREAM_BACKEND", "selfbot") as StreamBackend),
// x11grab source for the VNC display (TigerVNC runs the desktop on :1)
vncDisplay: opt("VNC_DISPLAY", ":1"),
vncResolution: opt("VNC_RESOLUTION", "1920x1080"),
vncFramerate: parseInt(opt("VNC_FRAMERATE", "60"), 10),
vncBitrateKbps: parseInt(opt("VNC_BITRATE_KBPS", "8000"), 10),
// selfbot backend (ToS-risk; use a throwaway account token, never your main)
selfbotToken: opt("DISCORD_SELFBOT_TOKEN"),
// Use NVENC hardware encode + hw-accelerated decode for the stream (RTX 5050).
streamHw: opt("STREAM_HW", "1") !== "0",
// Capture desktop audio into the broadcast so the stream has sound. Pulls the
// PipeWire/Pulse monitor of the default sink (what the desktop plays). Set
// STREAM_AUDIO=0 to mute; STREAM_AUDIO_SOURCE overrides the capture source.
streamAudio: opt("STREAM_AUDIO", "1") !== "0",
streamAudioSource: opt("STREAM_AUDIO_SOURCE", "@DEFAULT_MONITOR@"),
// Screen-share + browser mode. true = the bot may go Live (Go-Live screen
// share of the VNC desktop) and drive the on-screen browser for real-time
// info. false = no screen share; use voice + API/MCP tools for info only.
screenBrowser: opt("STREAM_BROWSER", "true") !== "false",
// novnc backend
novncUrl: opt("NOVNC_URL", ""),
// screenshot backend
screenshotIntervalSec: parseInt(opt("SCREENSHOT_INTERVAL_SEC", "5"), 10),
// --- Voice behaviour ---
// Min/max captured utterance bounds (ms) before forwarding to the brain.
silenceMs: parseInt(opt("VOICE_SILENCE_MS", "800"), 10),
};
export type AppConfig = typeof config;