aien-sovereign-core-mv
AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination.
Brought by drakestapleton
aien-sovereign-core-mv / crates / spark-discord-hub / src / gideon_bot.rs
| 1 | // SPDX-License-Identifier: Apache-2.0 |
| 2 | // Copyright 2026 Drake Stapleton (AIEN / aien-dev) |
| 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // |
| 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | // See the License for the specific language governing permissions and |
| 14 | // limitations under the License. |
| 15 | |
| 16 | use reqwest::Client; |
| 17 | use tracing::{error, info}; |
| 18 | |
| 19 | use crate::models::{CreateMessagePayload, MessageReference}; |
| 20 | use crate::vault::get_vault_secret; |
| 21 | |
| 22 | pub struct GideonBot { |
| 23 | pub client: Client, |
| 24 | pub token: String, |
| 25 | } |
| 26 | |
| 27 | impl GideonBot { |
| 28 | pub fn new(token: String) -> Self { |
| 29 | Self { |
| 30 | client: Client::builder().build().unwrap_or_default(), |
| 31 | token, |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | pub async fn handle_command( |
| 36 | &self, |
| 37 | channel_id: &str, |
| 38 | message_id: &str, |
| 39 | command: &str, |
| 40 | author_name: &str, |
| 41 | ) { |
| 42 | info!( |
| 43 | "[GideonBot] Processing command from {}: {}", |
| 44 | author_name, command |
| 45 | ); |
| 46 | |
| 47 | let reply_text = match command { |
| 48 | "!gideon status" | "!status" => { |
| 49 | let torn_key_status = if get_vault_secret("TORN_API_KEY").is_some() { "ARMED (TPM)" } else { "MISSING" }; |
| 50 | format!("G.I.D.E.O.N. Sovereign Core: ONLINE\nArchitecture: Native Rust (GB10 SparkOS)\nTorn API Vault: {}\nRoles: Deterministic Ledger Active", torn_key_status) |
| 51 | } |
| 52 | "!verify" | "!link" => { |
| 53 | "To verify your Torn membership, use the native verification modal or link your Torn ID directly with Gideon.".to_string() |
| 54 | } |
| 55 | "!help" => { |
| 56 | "G.I.D.E.O.N. Commands:\n- - Check sovereign bot and vault status\n- - Torn membership verification\n- - Command listing".to_string() |
| 57 | } |
| 58 | _ => { |
| 59 | format!("G.I.D.E.O.N. command not recognized: {}. Try .", command) |
| 60 | } |
| 61 | }; |
| 62 | |
| 63 | let discord_url = format!( |
| 64 | "https://discord.com/api/v10/channels/{}/messages", |
| 65 | channel_id |
| 66 | ); |
| 67 | let payload = CreateMessagePayload { |
| 68 | content: reply_text, |
| 69 | message_reference: Some(MessageReference { |
| 70 | message_id: message_id.to_string(), |
| 71 | }), |
| 72 | }; |
| 73 | |
| 74 | if let Err(e) = self |
| 75 | .client |
| 76 | .post(&discord_url) |
| 77 | .header("Authorization", format!("Bot {}", self.token)) |
| 78 | .json(&payload) |
| 79 | .send() |
| 80 | .await |
| 81 | { |
| 82 | error!("[GideonBot] Failed to send Discord reply: {}", e); |
| 83 | } else { |
| 84 | info!( |
| 85 | "[GideonBot] Replied to {} in channel {}", |
| 86 | author_name, channel_id |
| 87 | ); |
| 88 | } |
| 89 | } |
| 90 | } |