Skip to main content

Crate mahbot

Crate mahbot 

Source
Expand description

Library crate for mahbot.

The binary (main.rs) uses the same module tree. This crate root provides the public API for both the dashboard and background agent dispatch.

Modules§

audio
Audio/voice subsystem — wake word detection, voice command pipeline, local transcription (Qwen3-ASR), and text-to-speech.
bench_openrouter
mahbot bench-openrouter — standalone OpenRouter provider benchmark CLI.
board
Ticket/board system — Turso-backed task management.
channels
checkpoint
WAL checkpointing for all Turso database stores.
config
Configuration system with three independent resolution chains.
config_db
Config key-value pairs and per-model routing rules stored in config.db.
debug
Debug query tool — read-only SQL diagnostics for mahbot’s databases.
gui
Native Iced dashboard — application entry point, navigation, and shared state.
jobs
Durable job substrate: jobs/agents/pending_jobs lifecycle, boot recovery scan, and stale purge orchestration.
lock_utils
Shared lock utilities for single-instance enforcement.
logs
Turso-backed log storage.
maintainer
Maintainer — autonomous periodic codebase investigation agent.
management
Board poller — picks up tickets from the board and dispatches agents.
message_router
Agent-ID-based message router — replaces per-role queue with per-agent channels for true instance-level parallelism.
providers
Provider subsystem for model inference backends.
registry
Global registry of running agents with cancellation support.
research_cleanup
Research-run cleanup: per-run temp folders, results archive, the raw shell-command dump, and the Sanitation-agent cleanup dispatch.
search_engine
Shared per-workspace search engine registry.
self_update
Self-update logic — single-instance guarding, build, binary swap, and restart.
session
Session persistence — Turso-backed store + native history decoding.
shutdown
Global shutdown infrastructure.
temp_cleanup
Periodic OS temp-dir cleaner: a Sanitation-role agent that removes clearly-old, abandoned agent artifacts from the common OS temp folder — including the pinned daemon temp root (/tmp/mahbot) — on the nightly discovery pass cadence.
temp_root
Private daemon temp root: one /tmp/mahbot root for ALL daemon temp artifacts.
ticket_buffer
Ticket phase transition buffer — piggyback non-critical transitions onto critical notifications and user messages.
tools
Tool implementations for agent-callable capabilities.
turso
users
Per-user identity, permissions, workspace and role preferences, and channel bindings.
util
Utility modules for shared helper functions.
wal_guard
Detection guard for live-WAL / .tshm inconsistency artifacts.
workspace
Workspace storage — persisted workspace metadata and contexts.

Macros§

__columns_gen
Generate COL_{prefix}_{name} index constants with positional indices.
__columns_join
Join literal strings with ", " separator.
columns
Generate a column-string constant and matching column-index constants from a single source-of-truth list.
define_store
Generate a DB-backed store struct, its open() constructor, and a global singleton (via crate::global_store!).
global_store
Declare a global OnceCell-backed store with init_global() and store().

Structs§

Agent
Running context for an agent turn.
ChannelMessage
ChannelRegistry
Registry of all active channels, keyed by Channel::name().
RoleIter
An iterator over the variants of Role
SendMessage
An outbound message to deliver on a channel.
Workspace
A persisted workspace entry.

Enums§

BotCommand
Represents a recognized Telegram bot text command.
ChatDirection
Direction of a chat message: from the user or from an agent.
ChatEvent
A chat event broadcast to GUI subscribers.
Role
Typed role identifier for agents.
WorkspaceStatus
Lifecycle status of a workspace.

Statics§

CHANNEL_REGISTRY
Global channel registry — channels register during startup.
CHAT_BROADCAST
Global broadcast channel for live chat events in the GUI. Set during init_message_pipeline. Capacity 256 to prevent Lagged errors in burst scenarios.
GUI_MESSAGE_TX
Global sender for GUI-to-channel messages. The Iced UI pushes ChannelMessage values here; GuiChannel::listen() reads them from the paired receiver and forwards them into the pipeline.
MESSAGE_TX
Global sender for the pipeline message channel. Set during init_message_pipeline, used by GuiChannel::listen() to forward GUI-originated messages into the shared pipeline.

Traits§

Channel

Functions§

channel_registry
Shorthand to get the global channel registry. Panics if not initialized — call during startup after channels are set up.
generate_id
Generate a unique identifier (10-char NanoID, ~60 bits entropy).
parse_bot_command
Parse a Telegram bot text command from message content.
run_grep_engine
Hidden grep-engine subcommand entry (dispatched from main() before the instance lock; the shell tool’s read-only grep interception rewrites served invocations to this subcommand of the current binary). Entry point for the hidden __grep-engine subcommand (dispatched from main() before instance-lock acquisition). --probe answers whether the binary still carries the subcommand (self-update version skew). Any runtime doubt execs the real grep in place; when even that fails, the sentinel exit code tells the parent to re-run the original command.