Skip to main content

Crate wabot

Crate wabot 

Source
Expand description

§wabot

Umbrella crate. Re-exports the wabot_core foundations and the wabot_macros decorators so consumers only need:

ⓘ
use wabot::prelude::*;

Optional feature crates are exposed under their own modules:

  • rest — REST controllers on axum (feature rest, default).
  • chat — chat controllers + channel framework (feature chat, default).
  • chatbot — chat-bot orchestrator + mindset framework (feature chatbot, default).
  • mindset — Mindset trait + operator + tool definitions (tools themselves live in [tool], shared with agents).
  • agent — programmatically-driven LLM sessions (ask / confirm / order) and mindset→agent delegation.
  • [testing] — harnesses that drive the real stack against a scriptable LLM (feature testing, opt-in).
  • addons::cmd — CLI channel addon (feature addon-cmd, default).
  • [addons::telegram] — Telegram channel addon (feature addon-telegram, opt-in).
  • [addons::socket] — Socket.IO channel addon (feature addon-socket, opt-in).
  • [addons::anthropic] — Anthropic Claude chat adapter (feature addon-anthropic, opt-in).
  • [addons::openai] — OpenAI chat adapter (feature addon-openai, opt-in).
  • [addons::deepseek] — DeepSeek chat adapter (feature addon-deepseek, opt-in).
  • [addons::google] — Google Gemini chat adapter (feature addon-google, opt-in).
  • [addons::openrouter] — OpenRouter chat adapter (feature addon-openrouter, opt-in).
  • [addons::wabot_llm] — Wabot LLM proxy adapter (feature addon-wabot, opt-in).
  • [addons::mindset_html] — HTML-fetch-to-text mindset module (feature addon-mindset-html, opt-in).
  • [async_jobs] — async / cron job framework (feature async-jobs, opt-in).
  • [addons::async_memory] — in-memory job + cron repository (feature addon-async-memory, opt-in).
  • [pg] — Postgres pool + JSONB store + advisory-lock Locker (feature pg, opt-in).
  • [addons::async_pg] — Postgres job + cron repository (feature addon-async-pg, opt-in).
  • [addons::chat_bot_pg] — Postgres chat repository + memory (feature addon-chat-bot-pg, opt-in).
  • [ui] — server-rendered pages with islands (features ui = Maud, ui-hypertext = rsx, ui-tsx = TSX via QuickJS).
  • [addons::auth_jwt] — JWT guard + signer (feature addon-auth-jwt, opt-in).
  • [addons::auth_api_key] — API-key guard + repository (feature addon-auth-api-key, opt-in).

Re-exports§

pub use runner::ProjectRunner;

Modules§

addons
Channel + adapter + mindset addons. Enable individually via addon-* features.
agent
Agents — LLM sessions you drive from code: typed answers, tool gating, budgets, and delegation from a mindset. Enabled together with chatbot.
audit
Who caused a change. Port of wabot-ts/src/core/audit.
chat
Chat controllers + channel framework. Enabled by chat (default).
chatbot
Chat-bot orchestrator + data types. Enabled by chatbot (default). Pulls in the mindset module as a peer.
config
Declarative configuration read from the environment. Port of wabot-ts/src/core/config.
description
Description metadata — human-readable text attached to fields and methods, used by the mindset layer to build LLM tool schemas.
entity
Entity — Storable + identity, timestamps, and protected-field-aware update.
idempotency
Handle a repeated delivery once. Port of wabot-ts/src/core/idempotency.
injection
Dependency injection — the foundation everything else in the framework sits on. See container::Container.
lifecycle
Graceful shutdown, cooperative cancellation, and the sd_notify handshake with systemd.
log_context
Correlation fields that follow a unit of work across .await points. Behind the async-context feature (on by default) because it is the one part of core that needs a task-local, and so an async runtime — see the note in CLAUDE.md about keeping core runtime-free. Correlation fields that follow a unit of work. Port of wabot-ts/src/core/logger/logContext.ts.
mapper
Convert one shape into another, validating on the way. Port of wabot-ts/src/core/mapper.
mindset
Mindset framework — Mindset trait, MindsetOperator, tool definitions. Enabled together with chatbot.
prelude
One-stop import for everything most apps need.
rate_limit
Fixed-window rate limiting. Port of wabot-ts/src/core/rate-limit.
repository
Storage-agnostic repository traits. Port of wabot-ts/src/core/repository.
rest
REST controllers on axum. Enabled by the rest feature (default).
runner
Run a whole application: every subsystem, one shutdown. Port of wabot-ts/src/feature/project-runner.
storable
Storable — generic, serialization-safe data container.
tool
The tool runtime shared by mindsets and agents — #[tools] definitions, the schema shipped to the model, and gating. Enabled together with chatbot.
validation
Validation system — declarative field validators with introspectable metadata.

Macros§

register_singletons
Register every #[singleton]-annotated type in one call.

Attribute Macros§

action
Decorator-style macros — direct counterparts to wabot-ts decorators. @action('name') — marker on a method inside a #[ui_controller] impl block. Becomes POST <controller>/_action/<name> returning JSON; the name defaults to the method name.
chat_controller
Decorator-style macros — direct counterparts to wabot-ts decorators. @chatController() — apply to an impl Controller block. Walks every method; methods carrying a channel marker (#[cmd], future #[telegram] / #[socket], …) are wired into a per-channel dispatch closure, and a Self::register_channels(&Container, Arc<ChatResolver>) function is emitted that hands each channel its dispatch via listen.
cmd
Decorator-style macros — direct counterparts to wabot-ts decorators. @cmd() — marks a method inside a #[chat_controller] impl block as the handler for the CLI (CmdChannel) channel. Inert outside a #[chat_controller] impl block.
command
Decorator-style macros — direct counterparts to wabot-ts decorators. @command('name') — apply to a command-payload struct. Bakes Self::COMMAND_NAME = "name" and an impl CommandData so the typed run_command / schedule_command helpers can find the name. The struct must also derive Serialize + Deserialize.
command_handler
Decorator-style macros — direct counterparts to wabot-ts decorators. @commandHandler({ command, ...options }) — apply to a handler struct. Emits Self::__handler_entry(&Container) -> CommandHandlerEntry so the runtime can dispatch by COMMAND_NAME. The handler must implement async fn handle(&self, cmd: MyCommand) -> Result<(), E: Display> on a separate inherent impl, and the struct itself must be #[injectable].
cron_command
Decorator-style macros — direct counterparts to wabot-ts decorators. @cronCommand({ name, cron }) — apply to a command struct that’s fired periodically. Bakes COMMAND_NAME + CRON_SCHEDULE.
cron_handler
Decorator-style macros — direct counterparts to wabot-ts decorators. @cronHandler({ ...config }) — apply to a handler struct. Emits Self::__cron_entry(&Container) -> CronHandlerEntry. The handler must implement async fn handle(&self) -> Result<(), E: Display> (cron handlers carry no arguments) and the struct must be #[injectable].
delete
Decorator-style macros — direct counterparts to wabot-ts decorators. @onDelete(...) — see [get].
description
Decorator-style macros — direct counterparts to wabot-ts decorators. @description("...") — attaches a human-readable description to a field or method. On struct fields it is consumed by #[derive(Validate)] and folded into [PropertyInfo::description]. On methods it is consumed by mindset macros (later phase). Used standalone, the attribute is a no-op so it never appears as “unknown attribute”.
get
Decorator-style macros — direct counterparts to wabot-ts decorators. @onGet(...) — marks a method inside a #[rest_controller] impl block as an HTTP GET endpoint. Inert when used outside such a block.
head
Decorator-style macros — direct counterparts to wabot-ts decorators. #[head("…")] — the headers a GET would answer with, and no body.
injectable
Decorator-style macros — direct counterparts to wabot-ts decorators. @injectable() — emits a Self::inject(&Container) -> Arc<Self> constructor that resolves each Arc<T> field from the container and fills the rest from Default. Does not auto-register; pair with #[singleton] or call container.register_* manually.
max_body
Decorator-style macros — direct counterparts to wabot-ts decorators. #[max_body(N)] — how many bytes this endpoint buffers before refusing the request. Defaults to DEFAULT_MAX_BODY (1 MiB), which is generous for a REST payload and mean for a file upload.
middleware
Decorator-style macros — direct counterparts to wabot-ts decorators. @middleware(MyMiddleware) — attaches a middleware to the next endpoint method. Multiple #[middleware(...)] attributes stack; they run in source order before the handler. Inert outside a #[rest_controller] impl block.
mindset_lang
Decorator-style macros — direct counterparts to wabot-ts decorators. Deprecated alias of tool_lang.
mindset_module
Decorator-style macros — direct counterparts to wabot-ts decorators. Deprecated alias of tools, from when tool sets were a mindset-only concept.
mindset_tool
Decorator-style macros — direct counterparts to wabot-ts decorators. Deprecated alias of tool.
on_socket_event
Decorator-style macros — direct counterparts to wabot-ts decorators. #[on_socket_event("name")] — marker on one method inside a #[socket_controller] impl block. Inert outside such a block.
patch
Decorator-style macros — direct counterparts to wabot-ts decorators. #[patch("…")] — a partial update. See [get].
post
Decorator-style macros — direct counterparts to wabot-ts decorators. @onPost(...) — see [get].
put
Decorator-style macros — direct counterparts to wabot-ts decorators. @onPut(...) — see [get].
raw
Decorator-style macros — direct counterparts to wabot-ts decorators. #[raw] — take the Request and return the Response untouched.
rest_controller
Decorator-style macros — direct counterparts to wabot-ts decorators. @restController('/path') — apply to an impl Controller block. The macro walks every method, finds the #[get] / #[post] / #[put] / #[delete] / #[middleware] attributes, and emits a Self::register_routes(&Container, axum::Router) -> axum::Router function that adds every endpoint nested under the controller’s base path.
singleton
Decorator-style macros — direct counterparts to wabot-ts decorators. @singleton() — like #[injectable], but additionally registers the type as a singleton via inventory. Equivalent to writing container.register_singleton_factory::<Self, _>(|c| Self::inject(c)) at framework startup, except the registration is collected at compile time so a fresh Container::new() already knows about it.
socket
Decorator-style macros — direct counterparts to wabot-ts decorators. @socket() — marks a method as the handler for the Socket.IO (SocketChannel) channel. Namespace + bind address come from the runtime-registered SocketChannelConfig singleton. Inert outside a #[chat_controller] impl block.
socket_controller
Decorator-style macros — direct counterparts to wabot-ts decorators. @socketController('/ns') — apply to an impl MyController block. Walks every method, finds those carrying #[on_socket_event("name")], and emits Self::register_socket_handlers(&Container, &SocketIo).
telegram
Decorator-style macros — direct counterparts to wabot-ts decorators. @telegram() — marks a method as the handler for the Telegram (TelegramChannel) channel. The bot token is supplied at runtime via a registered Arc<TelegramChannelConfig> singleton, not as an attribute argument. Inert outside a #[chat_controller] impl block.
tool
Decorator-style macros — direct counterparts to wabot-ts decorators. #[tool("description")] — marker on one method inside a #[tools] impl block. Inert outside such a block — the enclosing macro reads it and strips it.
tool_lang
Decorator-style macros — direct counterparts to wabot-ts decorators. #[tool_lang("english")] — per-method language override, when one tool’s description is written in a different language from the rest of its set. Inert outside a #[tools] impl block.
tools
Decorator-style macros — direct counterparts to wabot-ts decorators. @tools() — apply to an impl MyTools block. Walks every method, finds those carrying #[tool("description")], and emits a Self::register_tools(&Container) -> Vec<ToolDefinition> helper. The struct must be #[injectable] (or #[singleton]) so dispatch can resolve it from the container.
ui_controller
Decorator-style macros — direct counterparts to wabot-ts decorators. @uiController({ path, app, layout }) — apply to the controller’s impl block. Walks every method, interprets #[view], #[action] and #[middleware], and emits Self::register_ui_routes.
view
Decorator-style macros — direct counterparts to wabot-ts decorators. @view('/path') — marker on a method inside a #[ui_controller] impl block. The method takes &self plus at most one typed request and returns UiResult<ViewBody> (or UiResult<ViewOutcome> to redirect).

Derive Macros§

Validate
Decorator-style macros — direct counterparts to wabot-ts decorators. #[derive(Validate)] — generates a Validate impl that owns a ModelInfo describing the struct and a validate() that runs every declared constraint against an instance.