mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-12-04 17:38:45 +00:00
Accepted WhatsApp senders could persistently relax their own tool policy and toggle instance-wide plugins using ordinary chat authorization. Add a separate admin_numbers allowlist, empty by default, and derive administrative access from the normalized sender of each inbound message. Keep allowed-number and group checks in force. Require administration at the WhatsApp plugin-toggle and tool-policy mutation boundaries while preserving read-only menus and ordinary chat controls. Gate built-in profile creation and browser-runtime changes before shared command execution. Use the shared argument parser for profile creation checks and preserve existing profile selection and custom overrides. Expose the administrator list in settings and document the new defaults. Add regressions for denied writes, real policy persistence and runtime decisions, normalized sender identities, revocation, administrative commands, and independent frontend access-list editing. Validation: - Conda framework: 165 tests and 62 subtests passed. - Docker framework: 12 focused tests and 32 subtests passed. - Node bridge and configuration store: all 4 tests passed. - WebUI: administrator field renders, parses and clears independently. - JavaScript syntax and git diff checks passed. - Restarted the bound Docker instance and verified HTTP 200. Live WhatsApp delivery was not exercised. Synthetic events and disposable policy files cover the authorization paths without changing live access lists or sending test messages to WhatsApp users.
4.4 KiB
4.4 KiB
WhatsApp Integration Plugin DOX
Purpose
- Own WhatsApp communication through a Baileys-based Node.js bridge.
Ownership
helpers/bridge_manager.pyowns bridge lifecycle.helpers/handler.pyandhelpers/wa_client.pyown message routing and bridge API interaction.helpers/slash_commands.pyadapts the shared Commands resolver to WhatsApp text menus, settings, chat selection, transcript export, and compaction confirmation.helpers/storage_paths.py, attachment helpers, and number utilities own storage, attachment, and phone-number handling.whatsapp-bridge/owns the Node.js bridge package.api/,prompts/,extensions/,default_config.yaml,plugin.yaml,README.md, andwebui/own QR/start/disconnect/test endpoints, prompt fragments, hooks, settings, metadata, docs, and UI.
Local Contracts
- Treat WhatsApp sessions, QR data, phone numbers, attachments, and bridge state as sensitive.
- Keep allowed-number and group-response controls enforced.
- Derive administration from each inbound message's normalized sender number and the separate
admin_numberslist in the current poll configuration, never from stored chat identity. An omitted or empty list grants nobody administrative access; administrators still pass sender and group checks. - Enforce sender and group authorization in the bridge before downloading media, and contain every media write beneath the configured cache directory.
- Keep Python dispatch checks and number normalization; propagate normalized authorization settings through all bridge startup paths and restart on policy changes.
- Resolve prefix/postfix commands before wrapping incoming text or captions; preserve attachments on rendered prompts. Unknown leading commands return help without invoking the model. Closing message markers keep rendered and queued text from resolving twice.
- Command discovery uses
_commands.helpers.commands.list_context_commands; project/global overrides retain precedence, and Telegram-specific controls are not advertised. - WhatsApp menus use explicit text commands, not Telegram buttons or dependencies. Plugin toggles protect required plugins and the WhatsApp/Commands connection; permission changes use Agent Editor's existing sparse writer and canonical tool catalog and require an idle editable profile.
- Plugin toggles and tool-policy writes require administration at the WhatsApp settings mutation boundary. Gate built-in profile creation and browser-runtime changes before shared command resolution; retain read-only menus, profile selection, and custom-command precedence, using the shared argument parser for profile creation checks.
wa_activepersists the selected context./newpreserves previous chats, and/chatand/sessionsstay within the originating WhatsApp JID. Existing chats without a selection fall back to recency, never random context-ID order./compactrequires confirmation naming the current idle context and reuses the backup-producing compactor./copysends a temporary transcript document from the bridge media directory and removes it after delivery.- Do not leave unmanaged bridge services outside plugin-owned runtime paths.
- Use the shared project/profile scope selector and Advanced accordion. Configuration is the sole plugin UI; keep pairing and connection controls there.
Work Guidance
- Coordinate Node bridge changes with Python bridge client and settings UI.
- Pairing starts on one explicit Show QR code action, which enables the draft configuration. Keep QR polling sequential and ignore responses after cancellation or modal cleanup; saving remains owned by the settings wizard.
Verification
- Run
node --test tests/test_whatsapp_bridge.mjsandpytest tests/test_whatsapp_bridge_manager.py tests/test_whatsapp_number_utils.py tests/test_whatsapp_storage_paths.pyfrom the repository root. - Run
pytest tests/test_whatsapp_commands.py tests/test_telegram_commands.py plugins/_commands/testsfor command resolution, isolation, administrator-only writes and revocation, permissions, exports, and shared-catalog regressions. - Run
node --test tests/test_whatsapp_config_store.mjsfor pairing lifecycle and independent sender/administrator list handling; verify the two-column pairing layout and its mobile stack in the WebUI. - Smoke-test dependency install, bridge start, QR pairing, allowed-number filtering, message routing, and replies when practical.
Child DOX Index
No child DOX files.