feat(gateway): multi-platform delivery simulator - #80175
Open
JoaoMarcos44 wants to merge 1 commit into
Open
JoaoMarcos44 wants to merge 1 commit into
JoaoMarcos44 wants to merge 1 commit into
Conversation
Adds `hermes gateway simulate-delivery --platform <p> --text/--input [--json]`, previewing real per-adapter format_message() rendering and truncate_message() chunking (Telegram/Discord/Slack/WhatsApp) with zero network calls and no credentials — catches rendering/chunking bugs before a live send instead of after. Resolves NousResearch#80174
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
hermes gateway simulate-delivery --platform <p> --text/--input [--json]— a preview command that renders and chunks content through the REAL adapter code for Telegram, Discord, Slack, and WhatsApp, with zero network calls and no credentials required.%%{init: {'theme': 'dark', 'themeVariables': { 'primaryColor': '#8b0000', 'mainBkg': '#0a0204', 'primaryTextColor': '#ffccd5', 'primaryBorderColor': '#ff0038', 'lineColor': '#ff0038'}}}%% graph TD A[Raw Input Text] -->|Real format_message| B[Adapter Renderer] B -->|Telegram| C[MarkdownV2 Escaping] B -->|Discord| D[GFM Table to Bullets] B -->|Slack| E[mrkdwn] B -->|WhatsApp| F[Native Formatting] C --> G[truncate_message Chunker] D --> G E --> G F --> G G -->|No Network, No Credentials| H[Formatted Output + Chunk Report]Infographic :
Closes #80174
Why this doesn't duplicate existing work
Design notes
format_message()is called unbound (AdapterClass.format_message(None, text)) for Telegram/Discord/Slack, and via a bareobject.__new__(WhatsAppBehaviorMixin)instance for WhatsApp — the exact constructionscripts/generate_conformance_vectors.pyuses, asserted self-free bytests/conformance/test_vector_generator.py.BasePlatformAdapter.truncate_message()static method (code-fence-boundary preservation included), called with each adapter's realMAX_MESSAGE_LENGTHandlen_fn(Telegram measures UTF-16 code units viautf16_len, matchinggateway/delivery.py's real call site).simulate-deliverysubparser added to the existinggatewayparser (hermes_cli/subcommands/gateway.py), dispatched via one guard clause added at the top ofhermes_cli/gateway.py::_gateway_command_inner— no existinggatewaysubcommand branch was touched.Test plan
pytest tests/hermes_cli/test_gateway_delivery_simulator.py -q— 11 passing: real MarkdownV2 escaping, Discord pass-through, UTF-16 length check, chunk-boundary correctness (len(chunk) <= max_lengthfor every chunk), unsupported-platform error, file-input path, JSON outputpytest tests/hermes_cli/test_gateway.py -q— no regressions (10 passed, 5 pre-existing skips)ruff checkon new/changed files — cleanhermes gateway simulate-delivery --platform telegram --text "Price 3.50 (was 4.00) save ~12%!"→ correctly escaped MarkdownV2 output;--platform whatsapp --json; unsupported platform → clean error message