Commit Graph
21 Commits
Author SHA1 Message Date
Alessandro 9ae1939bd6 Restore secure Telegram scopes and preserve legacy configuration
Restore global, project, profile, and project/profile configuration with
one bot identity per saved scope. Preserve inherited configuration and
pause conflicting legacy bot identities without discarding their settings.

Revalidate scope, activation, and access rules for inbound messages,
commands, callbacks, session selection, and outbound delivery. Keep scoped
bots within their owning project/profile, omit credentials from persisted
chat metadata, and sanitize attachment filenames.

Automatically back up existing configuration, activation, and session
mappings before upgrade. Preserve their contents and stable global session
keys, while provisioning secure webhook secrets where legacy settings
require them. Document scope ownership, conflict recovery, and migration.

Validation:
- Docker framework suite: 216 passed, plus 73 subtests.
- Live Telegram status and message/reply round-trip confirmed.
- Missing and forged webhook credentials rejected with HTTP 403.
- Existing live configuration, activation, and session mappings unchanged.
2026-11-12 17:27:15 +01:00
Alessandro 5f45daa61a Reject unsupported Telegram configuration scopes
Telegram advertised project/profile settings while its lifecycle and sender
authorization read only global configuration. A saved scoped allowlist or
disable could therefore leave a permissive global bot accepting messages.

Make Telegram configuration and activation explicitly global, preserving
per-user project routing. Enforce manifest scope support before plugin
configuration or activation writes and return HTTP 400 for invalid saves.

Pause Telegram bots and block incoming events whenever legacy scoped
configurations or activation overrides exist. Preserve those files, skip
attachment cleanup, notify the operator, and retain settings UI access for
manual review and removal. Each event must resolve a currently enabled
global bot; removed, renamed, disabled, or globally deactivated bots cannot
fall back to captured settings.

Add regressions for scope rejection without side effects, supported-plugin
scopes, legacy settings shutdown and migration, current allowlists, and
immediate revocation. Update existing administrator tests and owning docs.

Validation: 339 tests and 73 subtests passed in both Conda a0 and Docker's
framework runtime. A before/after reproduction showed an excluded sender
reaching context creation before the fix and being blocked afterward.
Restarted the live runtime and checked HTTP health and Telegram settings UI.
No live Telegram message test was performed.
2026-11-01 08:05:25 +01:00
Alessandro 17033d277e Extend slash commands coverage and menus in Telegram
Resolve built-in, plugin, global, and project slash commands before wrapping Telegram messages, preserving custom overrides and existing integration controls. Add paginated command, plugin, and permission menus, compaction confirmation, transcript export, and fresh-chat session binding.

Generate stable names for unnamed bots, reject duplicate names on save, and restart bots when their connection settings change. Preserve webhook authentication and private-only group controls, and prevent rendered or queued messages from resolving a second slash command.

Validation: 80 tests and 11 webhook subtests passed. Verified command execution and menu rendering in the Docker framework runtime, source/runtime file hashes, HTTP health, and polling with 33 registered commands. Telegram replies were confirmed by the user; direct in-app browser automation was unavailable.
2026-09-14 13:21:15 +02:00
Alessandro 8e270c5ab7 Ignore non-Telegram tool streaming contexts
Make Telegram tool lifecycle hooks no-op for contexts that do not expose a raw data dict or do not carry the Telegram bot marker.

This keeps global tool extension dispatch safe for non-Telegram contexts, including Responses API tool-call regression tests, without changing behavior for real Telegram sessions.
2026-06-11 19:14:03 +02:00
Anmol Malik abf0cef8e8 Scope Telegram integration commands 2026-06-07 21:20:30 +05:30
Anmol Malik 013a374daa Revert "Add Telegram speech mode"
This reverts commit c51c235faacbbed44994635d4743b97f7a143a17.
2026-05-29 00:10:04 +05:30
Anmol Malik 709b865399 Add Telegram speech mode 2026-05-29 00:10:04 +05:30
Anmol Malik 99207d60a2 Add Telegram long-run status updates 2026-05-29 00:10:04 +05:30
Anmol Malik 92b728c3d7 Show friendly Telegram errors 2026-05-29 00:10:04 +05:30
Anmol Malik 8bc81c7a6a Send Telegram intermediate responses separately 2026-05-29 00:10:04 +05:30
Anmol Malik 1bbbfa44ac Improve Telegram integration command and streaming UX 2026-05-29 00:10:04 +05:30
Alessandro 395ef8dd33 integrations: add native chat controls and email config presets
Add shared transport-level control commands so Telegram, WhatsApp, and
email threads can manage the active chat directly.

- add a shared integration command helper for /project, /config, /send,
  and /queue send
- wire native command handling into Telegram and WhatsApp sessions
- expose Telegram control commands through bot command routing and update
  transport docs
- add email thread command handling for existing A0 email conversations
- add an optional per-handler email conversation preset backed by model
  presets in the email settings UI and default config
- document the new transport control flow across Telegram, WhatsApp, and
  email
2026-04-11 18:49:13 +02:00
frdel 247c8d845f Change default self-update backup directory from /a0/tmp to /root and add lazy aiogram dependency loading for Telegram plugin
- Update default backup path from /a0/tmp/self-update-backups to /root/update-backups in self_update_manager.py, helpers/self_update.py, and documentation
- Move aiogram from global requirements.txt to plugin-local requirements for _telegram_integration
- Add ensure_dependencies() helper that installs aiogram on-demand via uv pip install
- Add has_aiogram() check to avoid
2026-03-26 10:20:35 +01:00
keyboardstaff 24eb762963 fix(telegram): group attachment detection, typing lifecycle, per-chat session isolation
- Fix group @mention with attachments being silently dropped: filter now checks caption / caption_entities for media messages
- Fix typing indicator cancelled prematurely on inline updates (break_loop=false): typing and reply_to cleanup moved to process_chain_end's finally block
- Fix same user's group and private chat interfering with each other: _map_key now includes chat_id for per-chat context isolation
- Refactor _make_handler to use direct function references instead of string-based getattr
2026-03-23 07:18:42 -07:00
keyboardstaff f5adfa26ce refactor(telegram): handler factory and add README 2026-03-23 06:26:54 -07:00
keyboardstaff 4a06e0c05e feat(telegram): add welcome message for new group members
- handler.py: Added handle_new_members() to send customized greetings (supports {name} placeholder, skips bots).

- bot_manager.py: Registered new handler using NEW_CHAT_MEMBERS filter.

- _10_telegram_bot.py: Integrated _wrap_new_members to ensure the bot uses the latest configuration.

- config.html: Added Welcome New Members toggle and Welcome Message input (conditional visibility based on Group Mode).

- telegram-config-store.js & default_config.yaml: Added default state (false) and documentation.
2026-03-22 10:09:31 -07:00
keyboardstaff d6811c1ec4 refactor(telegram): optimize message handling and unify system context
- handler.py: Cleaned up. All functions and imports are now actively used.

- _enqueue_user_message: Refactored to handle both messages and callback queries, eliminating duplicate building logic.

- _20_telegram_context.py: Now the single source of truth for injecting agent_instructions and system_context_reply.

- File Cleanup: Deleted unused fw.telegram.system_context.md and fw.telegram.cleared.md.

- fix: Corrected bot invocation logic within group chats.
2026-03-22 10:05:36 -07:00
keyboardstaff 5f996eded5 refactor(telegram): restructure handler.py and integrate model configuration 2026-03-21 23:54:38 -07:00
keyboardstaff af60a6e291 feat(telegram): message formatting rewrite, cross-event-loop fixes & hot mode switching 2026-03-21 09:02:49 -07:00
keyboardstaff fc787ea2c4 feat/fix(telegram): Frontend Input Persistence Fix & Webhook Backend Refactor
- Replaced :value reactive binding on Allowed Users and User→Project Mapping inputs with x-effect and focus guard, ensuring Alpine.js rerenders don't clear user-typed values while editing.
- Enhanced setUserProjects() to preserve incomplete entries (e.g., 123=), preventing accidental data loss.
- Refactored Default Project <select> persistence: replaced x-model with a x-effect + @change one-way binding, fixing value resets before option loading completes.

- Removed standalone aiohttp HTTP server for webhook mode; switched to Agent Zero's built-in API handler at /api/plugins/_telegram_integration/webhook.
- Added a new unauthenticated POST handler (api/webhook.py) that receives Telegram updates and feeds them to aiogram's Dispatcher.
- Webhook URLs are auto-constructed from the base URL and API path—no additional port or reverse proxy configuration required.
- Added webhook_secret verification in the API handler for improved security.
- bot.delete_webhook() is now called before starting polling mode to prevent TelegramConflictError races.
- Improved bot lifecycle: detects active webhook mode via webhook_active flag to avoid restart loops on each job_loop tick.
- Removed unused aiohttp/SimpleRequestHandler code.
2026-03-21 00:46:20 -07:00
keyboardstaff 88b5d97335 feat: Telegram plugin extensions 2026-03-20 10:21:00 -07:00