From 3d1e1b6a1545c4d51e22513eb8475c3b26899362 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Fri, 12 Jun 2026 19:20:27 +0100 Subject: [PATCH] Mirror owner Aquarium text through Metame voice --- .env.example | 4 + apps/bot/src/discord-bot.ts | 6 + apps/bot/src/metame-owner-voice-bridge.ts | 172 ++++++++++++++++++ apps/worker/src/index.ts | 3 +- packages/config/src/index.ts | 16 ++ packages/core/src/index.ts | 1 + .../core}/src/weksa-speech.ts | 27 ++- state/evidence.jsonl | 1 + 8 files changed, 221 insertions(+), 9 deletions(-) create mode 100644 apps/bot/src/metame-owner-voice-bridge.ts rename {apps/worker => packages/core}/src/weksa-speech.ts (77%) diff --git a/.env.example b/.env.example index 68dfad7..386c4a3 100644 --- a/.env.example +++ b/.env.example @@ -76,6 +76,10 @@ REPO_FACE_DISCORD_VOICE_CHANNEL_ID= REPO_FACE_DISCORD_VOICE_OUTBOX_PATH=.voidbot/status/repo-face-voice-outbox.jsonl REPO_FACE_DISCORD_VOICE_PLAYED_PATH=.voidbot/status/repo-face-voice-played.jsonl REPO_FACE_DISCORD_VOICE_POLL_INTERVAL_MS=5000 +METAME_OWNER_VOICE_ENABLED=false +METAME_OWNER_VOICE_SOURCE_CHANNEL_ID= +METAME_OWNER_VOICE_PERSONA_ID=metame +METAME_OWNER_VOICE_STATE_PATH=.voidbot/private/personas/metame/metame-owner-voice-sync.md REPO_FACE_HEARTBEATS_ENABLED=false REPO_FACE_HEARTBEAT_STATE_PATH=.voidbot/status/repo-face-heartbeats.json REPO_FACE_HEARTBEAT_TASK_NAME=VoidBot Repo Face Heartbeats diff --git a/apps/bot/src/discord-bot.ts b/apps/bot/src/discord-bot.ts index 7458e21..ade17d3 100644 --- a/apps/bot/src/discord-bot.ts +++ b/apps/bot/src/discord-bot.ts @@ -61,6 +61,7 @@ import { parseProviderOverride, replyEphemeral, } from "./discord-bot-handlers"; +import { maybeMirrorOwnerAquariumMessageAsMetameVoice } from "./metame-owner-voice-bridge"; import { startRepoFaceVoicePlayback } from "./repo-face-voice-playback"; import { buildActorFromInteraction, @@ -333,6 +334,11 @@ export async function startBot(): Promise { botDirectedRoleIds, ); await rememberAmbientVoidReference(message, client.user?.id, interactionMemory); + await maybeMirrorOwnerAquariumMessageAsMetameVoice({ + message, + registry: repoDiscordIdentities, + config, + }); const roleAddressedRepoIdentity = isDirectMessage ? undefined diff --git a/apps/bot/src/metame-owner-voice-bridge.ts b/apps/bot/src/metame-owner-voice-bridge.ts new file mode 100644 index 0000000..374743e --- /dev/null +++ b/apps/bot/src/metame-owner-voice-bridge.ts @@ -0,0 +1,172 @@ +import { appendFile, mkdir, readFile } from "node:fs/promises"; +import { dirname } from "node:path"; + +import type { AppConfig } from "@voidbot/config"; +import { + appendRepoFaceVoiceOutboxEntry, + findRepoDiscordIdentity, + isRepoDiscordIdentityAllowedInChannel, + resolveWeksaArtifactPath, + type RepoDiscordIdentityRegistry, + WeksaSpeechClient, +} from "@voidbot/core"; +import type { Message } from "discord.js"; + +const METAME_VOICE_DESIGN_PROMPT = [ + "Metame voice profile, owner-authorized:", + "Sultry and velvet-fist dominant, spoken close to the microphone.", + "She never raises her voice.", + "When angry, diction sharpens until each word lands like a carefully aimed high-caliber bullet.", + "When stressed, the voice becomes teary, wavery, high-pitched, and stutters over every word.", + "Preserve the speaker's high-functioning autistic self-description as texture and pacing truth, not caricature.", +].join("\n"); + +export async function maybeMirrorOwnerAquariumMessageAsMetameVoice(input: { + message: Message; + registry: RepoDiscordIdentityRegistry; + config: AppConfig; +}): Promise { + const { message, registry, config } = input; + if ( + !config.metameOwnerVoice.enabled || + !config.repoFaceWeksaSpeech.enabled || + !config.repoFaceDiscordVoice.enabled || + !message.inGuild() || + message.author.id !== config.ownerDiscordId || + !config.metameOwnerVoice.sourceChannelId || + message.channelId !== config.metameOwnerVoice.sourceChannelId + ) { + return; + } + + const exactUtterance = message.content; + if (exactUtterance.trim().length === 0) { + return; + } + + const metame = findRepoDiscordIdentity(registry, config.metameOwnerVoice.personaId); + if (!metame) { + console.warn(`Skipped Metame owner voice bridge: no identity named ${config.metameOwnerVoice.personaId}.`); + return; + } + if (!isRepoDiscordIdentityAllowedInChannel(metame, message.channelId)) { + console.warn(`Skipped Metame owner voice bridge: ${metame.id} is not allowed in channel ${message.channelId}.`); + return; + } + + await appendMetameOwnerVoiceState({ + statePath: config.metameOwnerVoice.statePath, + canonicalPersonaStatePath: metame.personaStatePath, + message, + exactUtterance, + }); + + const client = new WeksaSpeechClient({ + baseUrl: config.repoFaceWeksaSpeech.daemonBaseUrl, + timeoutMs: config.repoFaceWeksaSpeech.timeoutMs, + }); + try { + const receipt = await client.renderRepoFaceSpeech({ + jobId: `metame-owner-${message.id}`, + identityId: metame.id, + displayName: metame.displayName, + repoName: metame.repoName, + personaStatePath: config.metameOwnerVoice.statePath, + channelId: message.channelId, + messageId: message.id, + content: exactUtterance, + requestId: `voidbot-metame-owner-${message.id}`, + scene: `Owner-authored Metame mirror in Discord #aquarium text channel ${message.channelId}`, + addressee: "MiMo and the Aquarium voice channel", + performanceRegister: { + label: "Metame owner voice mirror", + medium: "Discord voice channel playback", + delivery_archetype: "Metame speaks the owner's exact Aquarium text as an authorized voice projection", + }, + deliveryControls: [ + "preserve the Discord message content exactly", + "close microphone intimacy", + "sultry velvet-fist dominance", + "quiet authority; never shout", + "anger sharpens diction instead of raising volume", + "stress becomes teary, wavery, high-pitched, and stuttered", + ], + forbiddenTraits: [ + "generic assistant voice", + "rewriting the source utterance", + "softening dominant diction", + "shouting", + "mocking or caricaturing autistic speech texture", + ], + voiceDesignPrompt: METAME_VOICE_DESIGN_PROMPT, + privateInterpretation: + "This is an owner-authorized Metame voice mirror. The source text is the owner's exact Aquarium message; Weksa may design delivery, but must not rewrite the utterance. The canonical Metame Persona state remains in CultCache; this markdown file is the Weksa-readable voice sync projection.", + intendedEffect: + "Let the owner type in #aquarium and hear that exact utterance delivered through Metame's synchronized voice in the Aquarium voice channel.", + }); + const audioPath = resolveWeksaArtifactPath( + config.repoFaceWeksaSpeech.repoRoot, + receipt.artifacts?.audio, + ); + if (!audioPath) { + console.warn(`Metame owner voice render for message ${message.id} returned no audio artifact.`); + return; + } + await appendRepoFaceVoiceOutboxEntry(config.repoFaceDiscordVoice.outboxPath, { + schemaVersion: "voidbot.repo_face_voice_outbox.v1", + id: `metame-owner:${message.id}`, + createdAt: new Date().toISOString(), + identityId: metame.id, + displayName: metame.displayName, + repoName: metame.repoName, + textChannelId: message.channelId, + textMessageId: message.id, + contentPreview: exactUtterance.slice(0, 500), + weksaRequestId: receipt.request_id, + weksaReceiptArtifact: receipt.artifacts?.receipt, + audioPath, + audioBytes: receipt.provider_response?.audio_bytes, + }); + console.log(`Queued Metame owner voice mirror for Aquarium message ${message.id}: ${audioPath}.`); + } catch (error) { + const detail = error instanceof Error ? error.message : String(error); + console.warn(`Metame owner voice bridge failed for message ${message.id}: ${detail}`); + } +} + +async function appendMetameOwnerVoiceState(input: { + statePath: string; + canonicalPersonaStatePath?: string; + message: Message; + exactUtterance: string; +}): Promise { + await mkdir(dirname(input.statePath), { recursive: true }); + const existing = await readFile(input.statePath, "utf8").catch((error: NodeJS.ErrnoException) => { + if (error.code === "ENOENT") { + return ""; + } + throw error; + }); + const header = existing.trim().length > 0 + ? "" + : [ + "# Metame Owner Voice Sync", + "", + "This is a Weksa-readable projection, not Metame's canonical CultCache state.", + `Canonical Persona state: ${input.canonicalPersonaStatePath ?? "unregistered"}`, + "", + "Voice profile:", + METAME_VOICE_DESIGN_PROMPT, + "", + "Owner-authored Aquarium utterances:", + "", + ].join("\n"); + const entry = [ + `## ${input.message.createdAt.toISOString()} Discord message ${input.message.id}`, + `Channel: ${input.message.channelId}`, + `Author: ${input.message.author.id}`, + `Exact utterance JSON string: ${JSON.stringify(input.exactUtterance)}`, + "", + ].join("\n"); + await appendFile(input.statePath, `${header}${entry}`, "utf8"); +} diff --git a/apps/worker/src/index.ts b/apps/worker/src/index.ts index d8df653..4b5c228 100644 --- a/apps/worker/src/index.ts +++ b/apps/worker/src/index.ts @@ -22,6 +22,8 @@ import { resolveRepoFaceStatePath, resolveWeksaArtifactPath, type SystemMessageCatalog, + WeksaSpeechClient, + type WeksaMimoReceipt, } from "@voidbot/core"; import { LocalLlmProvider, @@ -64,7 +66,6 @@ import { parseRepoIdentityPostIntents, type RepoIdentityPostIntent, } from "./repo-face-speech.js"; -import { WeksaSpeechClient, type WeksaMimoReceipt } from "./weksa-speech.js"; const config = loadConfig(); const weksaSpeechClient = new WeksaSpeechClient({ diff --git a/packages/config/src/index.ts b/packages/config/src/index.ts index fab6b5c..41d7551 100644 --- a/packages/config/src/index.ts +++ b/packages/config/src/index.ts @@ -117,6 +117,10 @@ const envSchema = z.object({ REPO_FACE_DISCORD_VOICE_OUTBOX_PATH: z.string().min(1).default(".voidbot/status/repo-face-voice-outbox.jsonl"), REPO_FACE_DISCORD_VOICE_PLAYED_PATH: z.string().min(1).default(".voidbot/status/repo-face-voice-played.jsonl"), REPO_FACE_DISCORD_VOICE_POLL_INTERVAL_MS: z.coerce.number().int().positive().default(5000), + METAME_OWNER_VOICE_ENABLED: booleanFromEnv.default(false), + METAME_OWNER_VOICE_SOURCE_CHANNEL_ID: optionalNonEmptyString, + METAME_OWNER_VOICE_PERSONA_ID: z.string().min(1).default("metame"), + METAME_OWNER_VOICE_STATE_PATH: z.string().min(1).default(".voidbot/private/personas/metame/metame-owner-voice-sync.md"), BIFROST_ROOT: z.string().min(1).default("E:/Projects/Bifrost"), BIFROST_DISCORD_CHANNEL_ID: optionalNonEmptyString, REPO_FACE_HEARTBEATS_ENABLED: booleanFromEnv.default(false), @@ -205,6 +209,12 @@ export interface AppConfig { playedPath: string; pollIntervalMs: number; }; + metameOwnerVoice: { + enabled: boolean; + sourceChannelId?: string; + personaId: string; + statePath: string; + }; bifrostRoot: string; bifrostDiscordChannelId?: string; repoFaceHeartbeats: { @@ -459,6 +469,12 @@ export function loadConfig(env: NodeJS.ProcessEnv = process.env): AppConfig { playedPath: resolve(parsed.REPO_FACE_DISCORD_VOICE_PLAYED_PATH), pollIntervalMs: parsed.REPO_FACE_DISCORD_VOICE_POLL_INTERVAL_MS, }, + metameOwnerVoice: { + enabled: parsed.METAME_OWNER_VOICE_ENABLED, + sourceChannelId: parsed.METAME_OWNER_VOICE_SOURCE_CHANNEL_ID, + personaId: parsed.METAME_OWNER_VOICE_PERSONA_ID, + statePath: resolve(parsed.METAME_OWNER_VOICE_STATE_PATH), + }, bifrostRoot: resolve(parsed.BIFROST_ROOT), bifrostDiscordChannelId: parsed.BIFROST_DISCORD_CHANNEL_ID, repoFaceHeartbeats: { diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 99b49a3..28c3c50 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -16,6 +16,7 @@ export * from "./state-storage"; export * from "./style-pack-loader"; export * from "./system-message-catalog"; export * from "./void-usage-rate-limiter"; +export * from "./weksa-speech"; export * from "./void-self-state-loader"; export * from "./void-self-state-domain"; export * from "./void-self-state-projection"; diff --git a/apps/worker/src/weksa-speech.ts b/packages/core/src/weksa-speech.ts similarity index 77% rename from apps/worker/src/weksa-speech.ts rename to packages/core/src/weksa-speech.ts index e40ecf2..c823bd8 100644 --- a/apps/worker/src/weksa-speech.ts +++ b/packages/core/src/weksa-speech.ts @@ -13,6 +13,15 @@ export interface WeksaRepoFaceSpeechInput { messageId: string; content: string; replyToMessageId?: string; + requestId?: string; + scene?: string; + addressee?: string; + performanceRegister?: Record; + deliveryControls?: string[]; + forbiddenTraits?: string[]; + voiceDesignPrompt?: string; + privateInterpretation?: string; + intendedEffect?: string; } export interface WeksaMimoReceipt { @@ -52,32 +61,34 @@ export class WeksaSpeechClient { }, signal: controller.signal, body: JSON.stringify({ - request_id: buildRequestId(input), + request_id: input.requestId ?? buildRequestId(input), persona_state_path: input.personaStatePath, speaker_agent_id: input.identityId, thought_text: input.content, spoken_text: input.content, - scene: `Discord channel ${input.channelId}`, - addressee: "Discord room", + scene: input.scene ?? `Discord channel ${input.channelId}`, + addressee: input.addressee ?? "Discord room", intent: input.content, - performance_register: { + performance_register: input.performanceRegister ?? { label: `${input.displayName} Discord voice`, medium: "Discord voice channel playback", delivery_archetype: `${input.displayName} speaks an approved VoidBot SAY line`, }, - delivery_controls: [ + delivery_controls: input.deliveryControls ?? [ "Discord-room conversational delivery", "preserve the approved text exactly", `repo Face for ${input.repoName}`, ], - forbidden_traits: [ + forbidden_traits: input.forbiddenTraits ?? [ "generic assistant voice", "rewriting source meaning", "changing the approved Discord text", ], - private_interpretation: + voice_design_prompt: input.voiceDesignPrompt, + private_interpretation: input.privateInterpretation ?? "VoidBot already approved this SAY line for public text delivery; Weksa is only projecting it into spoken audio.", - intended_effect: "Make the approved public Discord line audible without changing its meaning.", + intended_effect: input.intendedEffect ?? + "Make the approved public Discord line audible without changing its meaning.", }), }); diff --git a/state/evidence.jsonl b/state/evidence.jsonl index 1c260be..102d0e6 100644 --- a/state/evidence.jsonl +++ b/state/evidence.jsonl @@ -354,3 +354,4 @@ {"ts":"2026-06-12T14:12:05Z","type":"verification","status":"ok","note":"Kimodo real generation now works on Raven through Vili. Direct smoke generated E:\\Projects\\Vili\\.vili\\artifacts\\kimodo-real-smoke-live\\motion.npz after first-run cache warmup. Vili HTTP POST /motion/generate succeeded for prompt 'A person gives a small friendly wave.' with duration=1, diffusionSteps=2, seed=10, producing E:\\Projects\\Vili\\.vili\\artifacts\\vili-1781273290152\\motion.npz. Key fixes: writable Hugging Face cache mount and file-based Kimodo input_folder/meta.json prompt handoff."} {"ts":"2026-06-12T16:01:29Z","type":"implementation","status":"ok","note":"Added gated repo Face Weksa speech projection after parent-approved Discord SAY delivery. Weksa remains utterance/MiMo artifact owner; VoidBot records audit receipts and text delivery stays authoritative if speech rendering fails."} {"ts":"2026-06-12T17:06:36Z","type":"verification","status":"ok","note":"Discord voice playback organ is live for Weksa MiMo artifacts. Bot consumed repo-face voice outbox entry manual-voice-smoke-1781283564, joined Aquarium voice channel 1505916699831046224, played E:\\\\Projects\\\\weksa\\\\.weksa\\\\speech-provider\\\\mimo\\\\metame-1513599037692182589-smoke-003-auto-feminine\\\\metame-1513599037692182589-smoke-003-auto-feminine.wav, and wrote repo-face-voice-played receipt."} +{"ts":"2026-06-12T18:12:19Z","type":"implementation","status":"ok","note":"Added owner-authorized Aquarium-to-Metame voice bridge: owner messages in Aquarium can be mirrored exactly through shared Weksa/MiMo speech rendering, persisted to a Weksa-readable Metame voice-sync projection, and queued into the existing Discord voice outbox."}