From 61af0c166170b62709c4e5360b0aed8f68c59fc0 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Tue, 19 May 2026 18:17:09 +0100 Subject: [PATCH] Enqueue chat consensus into Bifrost intake --- notes/voidbot-current-system-map.md | 2 +- scripts/feed-codex-chat-consensus.mjs | 98 +++++++++++++++++++++++++++ 2 files changed, 99 insertions(+), 1 deletion(-) diff --git a/notes/voidbot-current-system-map.md b/notes/voidbot-current-system-map.md index 8d140ea..a8459c7 100644 --- a/notes/voidbot-current-system-map.md +++ b/notes/voidbot-current-system-map.md @@ -170,7 +170,7 @@ This note is the source-grounded description of how the live VoidBot stack is sh - `scripts/export-random-discord-history.mjs` - plain Node helper for novelty excursions that samples one random archived Discord seam, returns a local context window around the anchor message, and skips bot-directed prompt rows by default. - `scripts/feed-codex-chat-consensus.mjs` - - plain Node helper that turns recent archived Discord messages, defaulting to text `#aquarium`, into a markdown consensus packet plus a target Codex prompt. By default it writes files under `.voidbot/artifacts/chat-consensus/`; with `--execute`, it feeds the generated prompt to `codex exec` in the requested workspace. + - plain Node helper that turns recent archived Discord messages, defaulting to text `#aquarium`, into a markdown consensus packet plus a target Codex prompt. By default it writes files under `.voidbot/artifacts/chat-consensus/`; with `--execute`, it feeds the generated prompt to `codex exec` in the requested workspace. With `--enqueue-bifrost`, it also calls `E:/Projects/Bifrost/tools/agent-transport.mjs enqueue` so the packet becomes a CultCache-backed Bifrost intake request for the target repo Face instead of remaining an inert local artifact. - `scripts/backup-voidbot-state.ps1` - local backup of Postgres, Qdrant snapshots, and RAG archives. - `scripts/restore-voidbot-state.ps1` diff --git a/scripts/feed-codex-chat-consensus.mjs b/scripts/feed-codex-chat-consensus.mjs index 9c8ede5..1b5985d 100644 --- a/scripts/feed-codex-chat-consensus.mjs +++ b/scripts/feed-codex-chat-consensus.mjs @@ -37,6 +37,16 @@ function main() { `Target: ${options.agent}; cwd=${resolve(options.cwd)}; messages=${selected.length}\n`, ); + if (options.enqueueBifrost) { + enqueueBifrostRequest({ + options, + packet, + outputPath, + promptPath, + selected, + }); + } + if (!options.execute) { process.stdout.write( `Dry run. Re-run with --execute to feed this to Codex, or pass the prompt file to the target agent.\n`, @@ -139,6 +149,18 @@ function parseArgs(args) { case "--execute": options.execute = true; break; + case "--enqueue-bifrost": + options.enqueueBifrost = true; + break; + case "--bifrost-root": + options.bifrostRoot = requireValue(args, ++index, arg); + break; + case "--bifrost-priority": + options.bifrostPriority = parsePositiveInteger(requireValue(args, ++index, arg), arg); + break; + case "--bifrost-store": + options.bifrostStore = requireValue(args, ++index, arg); + break; case "--include-bot-prompts": options.includeBotPrompts = true; break; @@ -157,6 +179,73 @@ function parseArgs(args) { return options; } +function enqueueBifrostRequest({ options, packet, outputPath, promptPath, selected }) { + const bifrostRoot = resolve(options.bifrostRoot ?? "E:/Projects/Bifrost"); + const transportCli = resolve(bifrostRoot, "tools/agent-transport.mjs"); + if (!existsSync(transportCli)) { + throw new Error(`Bifrost transport CLI was not found at ${transportCli}.`); + } + + const targetRepo = options.repo ?? inferRepoNameFromCwd(options.cwd); + if (!targetRepo) { + throw new Error("--enqueue-bifrost requires --repo or a target --cwd with a final path segment."); + } + + const title = `Recent ${targetRepo} consensus for ${options.agent}`; + const priority = String(options.bifrostPriority ?? 70); + const sourceMessageIds = selected + .map((message) => message.id) + .filter(Boolean) + .join(","); + + const args = [ + transportCli, + "enqueue", + "--repo", + targetRepo, + "--agent", + options.agent, + "--title", + title, + "--request-file", + outputPath, + "--priority", + priority, + "--source-kind", + "discord_consensus", + "--source-channel-id", + options.channelId, + "--packet-path", + outputPath, + "--prompt-path", + promptPath, + "--created-by", + "voidbot", + ]; + + if (sourceMessageIds.length > 0) { + args.push("--source-message-ids", sourceMessageIds); + } + if (options.bifrostStore) { + args.push("--store", resolve(options.bifrostStore)); + } + + const result = spawnSync(process.execPath, args, { + cwd: bifrostRoot, + encoding: "utf8", + stdio: ["ignore", "pipe", "pipe"], + windowsHide: true, + }); + + if (result.status !== 0) { + throw new Error( + `Bifrost enqueue failed with exit ${result.status ?? "unknown"}: ${result.stderr || result.stdout}`, + ); + } + + process.stdout.write(`Enqueued Bifrost intake request:\n${result.stdout}`); +} + function buildConsensusPacket(messages, options, archivePath) { const generatedAt = new Date().toISOString(); const transcript = messages.map(formatTranscriptLine).join("\n"); @@ -348,6 +437,11 @@ function parsePositiveInteger(value, flag) { return parsed; } +function inferRepoNameFromCwd(cwd) { + const normalized = resolve(cwd); + return normalized.split(/[\\/]+/).filter(Boolean).at(-1); +} + function timestampSlug(date) { return date.toISOString().replace(/[:.]/g, "-"); } @@ -382,6 +476,10 @@ Options: --limit Max messages. Defaults to 80. --out Packet output path. --execute Feed the generated prompt to codex exec. + --enqueue-bifrost Enqueue the generated packet into Bifrost intake. + --bifrost-root Bifrost repo root. Defaults to E:/Projects/Bifrost. + --bifrost-priority Priority for --enqueue-bifrost. Defaults to 70. + --bifrost-store Override Bifrost .cc store path, mainly for tests. --sandbox Codex sandbox for --execute. Defaults to read-only. `); process.exit(0);