Add Discord-native hybrid front-end for Jarvis (bot + bridge)
Some checks failed
Release / semantic-release (push) Successful in 59s
tests / Unit tests (Linux, Python 3.11) (push) Successful in 13m45s
Release / build-linux (push) Failing after 7m47s
Release / build-windows (push) Has been cancelled
Release / build-macos (arm64, macos-latest) (push) Has been cancelled
Release / build-macos (x64, macos-15-intel) (push) Has been cancelled
Release / release-main (push) Has been cancelled
Release / release-develop (push) Has been cancelled
Some checks failed
Release / semantic-release (push) Successful in 59s
tests / Unit tests (Linux, Python 3.11) (push) Successful in 13m45s
Release / build-linux (push) Failing after 7m47s
Release / build-windows (push) Has been cancelled
Release / build-macos (arm64, macos-latest) (push) Has been cancelled
Release / build-macos (x64, macos-15-intel) (push) Has been cancelled
Release / release-main (push) Has been cancelled
Release / release-develop (push) Has been cancelled
Transform isair/jarvis into a Discord-controlled voice assistant running on the Ubuntu VNC desktop, keeping the mature ~39k-line Python brain intact. - bot/ (Node + bun, discord.js): /자비스 slash commands (ephemeral), voice channel join + voice receive/playback, pluggable VNC screen broadcast (selfbot live / noVNC / screenshot) - bridge/ (Python, Flask): wraps jarvis STT + run_reply_engine + Piper TTS behind a thin localhost HTTP API - .env.example, scripts/ (start_bridge/start_bot/dev), README rewrite, docs/language-comparison.md and docs/vnc-xfce-setup.md Language decision: hybrid (Python brain + Node/bun Discord layer) because Discord blocks bot video; native screen broadcast only works via a Node selfbot library.
This commit is contained in:
52
bot/src/bridge.ts
Normal file
52
bot/src/bridge.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* HTTP client for the Python brain bridge (bridge/server.py).
|
||||
* All AI work (STT, reply engine, TTS) lives behind these calls.
|
||||
*/
|
||||
import { config } from "./config.ts";
|
||||
|
||||
export interface ConverseResult {
|
||||
transcript: string;
|
||||
language?: string | null;
|
||||
reply: string;
|
||||
error?: string | null;
|
||||
/** base64-encoded 16-bit PCM WAV of the spoken reply, or null if TTS off */
|
||||
audio_b64?: string | null;
|
||||
}
|
||||
|
||||
export interface TextResult {
|
||||
reply: string;
|
||||
error?: string | null;
|
||||
audio_b64?: string | null;
|
||||
}
|
||||
|
||||
/** Full voice turn: WAV in -> {transcript, reply, reply audio}. */
|
||||
export async function converse(wav: Buffer): Promise<ConverseResult> {
|
||||
const res = await fetch(`${config.bridgeUrl}/converse`, {
|
||||
method: "POST",
|
||||
headers: { "content-type": "audio/wav" },
|
||||
body: wav,
|
||||
});
|
||||
if (!res.ok) throw new Error(`bridge /converse ${res.status}: ${await res.text()}`);
|
||||
return (await res.json()) as ConverseResult;
|
||||
}
|
||||
|
||||
/** Text-only turn (used by /자비스 ask). */
|
||||
export async function ask(text: string): Promise<TextResult> {
|
||||
const res = await fetch(`${config.bridgeUrl}/text`, {
|
||||
method: "POST",
|
||||
headers: { "content-type": "application/json" },
|
||||
body: JSON.stringify({ text }),
|
||||
});
|
||||
if (!res.ok) throw new Error(`bridge /text ${res.status}: ${await res.text()}`);
|
||||
return (await res.json()) as TextResult;
|
||||
}
|
||||
|
||||
export async function health(): Promise<any> {
|
||||
const res = await fetch(`${config.bridgeUrl}/health`);
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export function decodeWav(audio_b64?: string | null): Buffer | null {
|
||||
if (!audio_b64) return null;
|
||||
return Buffer.from(audio_b64, "base64");
|
||||
}
|
||||
Reference in New Issue
Block a user