Add owner-only Epiphany Discord requests

This commit is contained in:
Meta Vens 2026-07-19 12:05:53 +01:00
commit 7493642d05
12 changed files with 386 additions and 0 deletions

View file

@ -11,6 +11,7 @@ import {
import type { AppConfig } from "@voidbot/config";
import {
ContextBuilder,
type EpiphanyOperatorCommand,
type OllamaSituationalSocialReadInferer,
loadVoidSelfState,
PermissionEngine,
@ -122,8 +123,62 @@ export const commandDefinitions = [
new SlashCommandBuilder()
.setName("set-style")
.setDescription("Reload the configured style pack from disk."),
new SlashCommandBuilder()
.setName("epiphany")
.setDescription("Request an operator action from the Yggdrasil Epiphany runtime.")
.addSubcommand((command) =>
command.setName("status").setDescription("Request a sealed operator status receipt."),
)
.addSubcommand((command) =>
command
.setName("sleep")
.setDescription("Request that Epiphany engage its swarm brake.")
.addStringOption((option) =>
option
.setName("reason")
.setDescription("Why the swarm should sleep.")
.setRequired(true)
.setMaxLength(500),
),
)
.addSubcommand((command) =>
command.setName("wake").setDescription("Request that Epiphany release its swarm brake."),
)
.addSubcommand((command) =>
command
.setName("direct")
.setDescription("Submit bounded operator pressure to resident Self.")
.addStringOption((option) =>
option
.setName("objective")
.setDescription("The objective to consider; this grants no consequence authority.")
.setRequired(true)
.setMaxLength(2000),
),
),
];
export function epiphanyOperatorCommandFromInteraction(
interaction: ChatInputCommandInteraction<CacheType>,
): EpiphanyOperatorCommand {
switch (interaction.options.getSubcommand(true)) {
case "status":
return { kind: "status" };
case "sleep":
return { kind: "sleep", reason: interaction.options.getString("reason", true) };
case "wake":
return { kind: "wake" };
case "direct":
return { kind: "directive", objective: interaction.options.getString("objective", true) };
default:
throw new Error("Unsupported Epiphany operator subcommand.");
}
}
export function isExactDiscordOwner(actorId: string, ownerDiscordId: string): boolean {
return actorId === ownerDiscordId;
}
export interface PromptHandlerOptions {
prompt: string;
command: CommandName;

View file

@ -24,6 +24,7 @@ import {
loadFaceIdentityRegistry,
queueRepoFaceMention,
exportPersonaFeedbackObservation,
submitEpiphanyOperatorRequest,
type RepoDiscordIdentity,
stripRepoIdentityTextAddress,
loadStylePack,
@ -57,6 +58,8 @@ import {
handleReindexChannel,
handleSearchHistory,
handleSummarizeChannel,
epiphanyOperatorCommandFromInteraction,
isExactDiscordOwner,
maybeRegisterCommands,
parseProviderOverride,
replyEphemeral,
@ -563,6 +566,43 @@ export async function startBot(): Promise<void> {
const guildContext = buildGuildContextFromInteraction(interaction);
switch (interaction.commandName) {
case "epiphany": {
await interaction.deferReply({ ephemeral: true });
if (!isExactDiscordOwner(actor.id, config.ownerDiscordId)) {
await replyEphemeral(
interaction,
"Refused: Epiphany operator requests require the exact configured Discord owner identity.",
);
break;
}
if (!interaction.guildId) {
await replyEphemeral(
interaction,
"Refused: Epiphany operator requests require their exact Discord organization provenance.",
);
break;
}
const request = await submitEpiphanyOperatorRequest(
{
interactionId: interaction.id,
actorDiscordId: actor.id,
guildId: interaction.guildId,
channelId: interaction.channelId,
command: epiphanyOperatorCommandFromInteraction(interaction),
},
{
storePath: config.bifrostEpiphanyOperatorRequestStorePath,
bifrostRoot: config.bifrostRoot,
cultlibRoot: process.env.VOIDBOT_CULTLIB_ROOT,
producerRuntimeId: "voidbot-yggdrasil",
},
);
await replyEphemeral(
interaction,
`Epiphany operator request \`${request.requestId}\` is pending Bifrost admission. This request grants no Mind, Hands, release, deployment, or local execution authority.`,
);
break;
}
case "ask":
const requestedProvider = parseProviderOverride(
interaction.options.getString("provider", false),