Reference

Components

Every Rust module in Whatszara explained — what it does, how it works, and why it exists.

policy.rs

src/whatszara/policy.rs

What it does

Policy engine — the gatekeeper for all actions.

How it works

Defines ToolCategory, ToolPermissions, ContactMode (Assistant/Chat/Summarize/Blocked), RiskLevel, ActionProposal, PolicyDecision, and the PolicyEngine with allowlist support.

Why it exists

Separates security policy from action execution. Every action goes through propose → evaluate → execute, ensuring no action runs without policy validation.

actions.rs

src/whatszara/actions.rs

What it does

Structured action executors for shell, apps, media, and file scanning.

How it works

Defines ActionResult with action/params fields. ShellExecutor has blocked commands list. AppLauncher, MediaController, DesktopScanner are platform-aware executors.

Why it exists

No free-form shell by default. Actions are typed structures (open_app, set_volume, play_media) that can be validated, logged, and reversed.

llm.rs

src/whatszara/llm.rs

What it does

Multi-provider LLM abstraction with 6 backends.

How it works

LLMProvider trait + ProviderRegistry. Supports Ollama (with live model list), Claude, Groq, Grok, Gemini, and Vercel AI SDK. Each provider implements the same chat() interface.

Why it exists

Users aren't locked into one LLM. Switch providers at runtime via the GUI. Local models (Ollama) work offline.

orchestrator.rs

src/whatszara/orchestrator.rs

What it does

Central orchestrator — ties policy, LLM, actions, and undo together.

How it works

process_message() checks contact mode and routes to LLM. handle_action() uses propose() → evaluate() → execute(). Manages the undo journal.

Why it exists

Single entry point for all message processing. Contact mode routing means blocked/chat/summarize/assistant modes are handled cleanly.

undo.rs

src/whatszara/undo.rs

What it does

Action journal with reversible actions for undo support.

How it works

ActionJournal records every action with its reverse. undo_last() executes the reverse action and marks it as reversed. Supports per-contact undo.

Why it exists

Accidents happen. Every action is reversible — volume changes, music playback, and more can be undone with a single command.

whatsapp.rs

src/whatszara/whatsapp.rs

What it does

WhatsApp integration — reads SQLite from Go bridge, sends messages via HTTP.

How it works

list_chats() reads the SQLite database directly. search_contacts() searches by name/number. send_message() calls the Go bridge REST API.

Why it exists

No Python MCP server needed. Direct SQLite access is faster and more reliable than going through a secondary service.