Commit Graph

3832 Commits

Author SHA1 Message Date
kshitijk4poor
8d70b88abd docs(discord): say who syncs after a mid-refresh client replacement 2026-11-19 12:32:41 +05:30
kshitijk4poor
c1a3cb0e83 refactor(discord): move slash-command registry diff into adapter_command_sync
adapter.py is far over the file-size cap and this PR grew it. Move the
payload canonicalization, the safe per-command sync, and the install-scope
helper into a DiscordCommandSyncMixin module; adapter.py ends 133 lines
shorter than main. Code is moved unchanged.
2026-11-19 12:32:41 +05:30
kshitijk4poor
7c33ac97b9 fix(discord): tie the app-info memo to its client
A reconnect could replace the client while application_info() was in
flight, and the old client's result was then stored and applied to the new
one. Capture the client before the call, and stop if it changed by the time
the call returns; the new client's READY runs its own sync. Clear the memo
when connect() builds a new client and on disconnect, so it no longer holds
a closed client.

Tests: named scope scenarios, including a new client ignoring the old
client's refresh and a replacement mid-refresh; the reconnect test asserts
the memo is cleared.
2026-11-19 12:32:41 +05:30
kshitijk4poor
32bceb33b8 fix(discord): bound the app-info refresh and keep its last good result
Bound the application_info() refresh at 15 s so a stalled call can't hold
post-connect forever. When it fails, reuse the last refresh for the same
client instead of the login-time snapshot, which can be older than settings
already synced; the snapshot is used only before any refresh succeeded.

Tests: one subprocess runs every scope case, adding the failed-later-refresh
and changed-between-READY cases; the remaining safe-sync test uses
_sync_adapter.
2026-11-19 12:32:41 +05:30
kshitijk4poor
1ba9016a3b fix(discord): upsert on mixed drift and refresh app info before syncing
A command whose description AND install types both differed took the PATCH
path. discord.py's edit_global_command sends only name/description/options,
so the install types stayed stale while the sync recorded success, and the
fingerprint then skipped every later start. Upsert whenever anything a PATCH
cannot carry differs.

Read the Installation settings from a fresh application_info() at each sync
instead of the login-time snapshot, which a reconnect reuses after a settings
change. A failed refresh falls back to the snapshot.

Tests: share _sync_adapter across the safe-sync tests, cover mixed drift and
description-only edits, and cover the refresh and its fallback.
2026-11-19 12:32:41 +05:30
kshitijk4poor
779cee6e68 fix(discord): set command install types from the app's Installation settings
Hermes left integration_types/contexts unset, so each command kept whatever
Discord stamped on it at creation. Commands created while the app was
user-install only stayed integration_types=[1]; other members of the bot's
server got "Unknown Integration" on /new, /status, /model, /stop and /reset,
and no sync could repair them.

Derive both from the app's own Installation settings (application_info's
integration_types_config, already fetched at login) before every sync. The
hardcoded [0,1]/[0,1,2] would be refused by Discord on a guild-install-only
app: a command can only use install types the app enables, and the
private_channel context needs user install. When the settings are
unavailable the tree stays unset, as before.
2026-11-19 12:32:41 +05:30
Andy
4504606a39 fix(discord): preserve scope drift recreation 2026-11-19 12:32:41 +05:30
Andy
dc1b4a9902 Fix Discord guild slash command visibility 2026-11-19 12:32:41 +05:30
Jarvis
4bd86568d0 fix(discord): diff slash commands against the raw registry #104399
discord.py parses zero-based integration types and contexts lossily. Discord also fills defaults for install fields Hermes leaves unset, producing perpetual false diffs.
2026-11-19 12:32:41 +05:30
Teknium
b1db37d2b9 fix(compat): carry only the turn helpers pinned catalog plugins import, until v0.27.0
Some checks failed
Skills Index Freshness Check / check-freshness (push) Has been cancelled
Skills Index Freshness Check / check-catalog-cors (push) Has been cancelled
auto-fix lint issues & formatting / Generate eslint --fix patch (push) Has been cancelled
auto-fix lint issues & formatting / Apply patch (push) Has been cancelled
Deploy Site / deploy-vercel (push) Has been cancelled
Deploy Site / deploy-docs (push) Has been cancelled
Review follow-up. The compat layer now keeps exactly the old imports the
catalog's OpenViking 2.1.2 and Honcho 1.2.0 pins make at load time, and
says so:

- agent.context_compressor_retry is no longer aliased (no catalog plugin
  imports it), and agent.skill_commands re-exports only
  extract_user_instruction_from_skill_message (neither pin imports
  register_auto_load_scaffold).
- moves.py admits a folded module only when a catalog-pinned plugin
  imports it.
- plugins/AGENTS.md and the plugin guide record the exception: which
  names, where they live now, and that they follow the hermes_state
  stand-in's window (removed no earlier than v0.27.0).
2026-11-18 11:31:39 -08:00
Teknium
1f0103a89f fix(compat): plugins that import a module the storage refactor removed load again
The storage interface (#149567, db4d50b9e7) folded agent/message_content.py and
agent/context_compressor_retry.py into session_rules/turns.py, and moved
extract_user_instruction_from_skill_message / register_auto_load_scaffold from
agent/skill_commands.py to the same module. Catalog plugins still import the old
paths at module top level, so they never registered: OpenViking 2.1.2 (the pinned
memory provider) and hermes-council fail with "No module named
'agent.message_content'", OpenViking then with "cannot import name
'extract_user_instruction_from_skill_message' from 'agent.skill_commands'", and
Hermes silently ran on built-in memory.

- MOVES gains agent.message_content and agent.context_compressor_retry ->
  session_rules.turns; the target defines every name each published, byte-identical.
  No other module the stack deleted is aliased: the 35 hermes_state_* modules were
  mixins or SQLite-backend helpers whose functions now take a store holder instead of
  a SessionDB (an alias would import and then fail on call), and
  gateway.session_admission's admission_fingerprint has no catalog importer.
- agent.skill_commands re-exports the two skill-scaffolding helpers it published.
- A plugin package whose __init__.py raises now propagates that exception from
  load_plugin_module instead of returning None, so the memory, context-engine,
  cron and computer-use loaders' one WARNING line names the real error rather than
  "loaded but no provider instance found". The bundled delegation fallback and
  import_provider_module keep their contracts (None / ImportError) and carry the text.

Fixes #157438
Part of #157077
2026-11-18 11:31:39 -08:00
Teknium
8116fa3e90 feat(caching): Nous models get cache markers when the catalog prices a cache write; 1h writes billed at the catalog rate
Nous Portal's /v1/models lists input_cache_write for every model that takes explicit cache_control
(Claude, Qwen 3.7/4, Gemini, GPT-6, ...). The nous profile declares prompt_cache_markers_from_catalog,
so the marker policy reads that rate: priced -> markers at the tier asked (Anthropic spec, declared),
unpriced -> no markers (OpenAI spec, 30m). Measured on qwen/qwen3.7-max: without markers its automatic
cache missed at 4 min; with a 1h marker it still hit after 13 idle minutes, the write billed at 1.25x.
Pricing now takes a catalog's input_cache_write_1h (Claude: 2x) or its single write rate for 1h writes
instead of a fixed 2x.
2026-11-18 03:40:34 -08:00
Teknium
bf6a59f336 feat(caching): Nous Portal gets the full prompt-cache lifecycle (1h declared)
The Portal now keeps Claude's 1h tier: a raw probe read a 13.2k-token 1h prefix back from
cache after 7 and after 25 idle minutes, with its write billed at 2x (the 5m control rewrote).
The Nous profile drops its 5m ceiling and declares prompt_cache_max_ttl="1h" instead, so the
wire asks for 1h under cache_ttl auto and the clock declares it (route_ceiling_1h): human chats
on Nous now warm x3 on the 1h schedule, compact at the budget's end/release, and offload on a
cold return like Anthropic and OpenRouter. Without a declared ceiling a 1h ask on an
Anthropic-wire gateway stays unproven (gateway_1h_untrusted), which would leave Nous with no
lifecycle at all.

route_ttl_ceilings stays: tests that exercised the clamp now set {nous: 5m} in their temp config.
Docs drop every 'Nous is 5m' sentence; the Nous wire snapshot gains ttl 1h on its markers.
2026-11-18 03:40:34 -08:00
100yenadmin
8cb040b214 fix(caching): auto re-resolves after a platform stamp and at request time
Agents stamped as gateway_hygiene after construction (hygiene and manual
/compress) re-resolve their auto tier after the stamp, so they stay on 5m
while context engines still bind to the real platform at construction.
Request-time clamps carry the auto flag, so a session that moves to Bedrock
mid-session under auto drops to 5m; an explicit 1h pin is kept. The Feishu
comment agent change is reverted (it changed the system prompt, not the tier).
2026-11-18 03:40:34 -08:00
100yenadmin
68c9cd437f fix(caching): auto keeps one-shots, background tasks and automation sources on 5m
Gateway-routed one-shots (hermes -z, chat -q), messaging /background, a2a and
msgraph_webhook sessions, the gateway hygiene agent and the Feishu comment
agent are machine-paced and now resolve to 5m under auto. Bedrock resolves to
5m under auto (legacy Claude models there accept only 5m); an explicit 1h pin
is kept. Interactive CLI, TUI, Desktop, ACP and messaging chats stay on 1h.
2026-11-18 03:40:34 -08:00
yoniebans
aa768b20d4 test(gateway): the newer Telegram and session cases run over the persistence interface
Main's new or changed cases that seeded or read the old store run on the storage interface with main's assertions: the observed transcript timestamp, the observe-mode /resume ownership guard, the dead private topic prune and the kept binding of an unconfirmed send, the oversized file admission, the idle /new that drops a held burst, the adoption of a chat on an external-process provider, and the send-path recovery sweep after a profile stop. Rows are seeded through the storage handle, the ledger's store follows the test's HERMES_HOME, and each authority's stores close by profile folder.

The private topic send ladder's docstring names the interface verb that prunes a dead topic's binding.
2026-11-17 17:51:22 +01:00
yoniebans
3f91a4a43b refactor(tools): tools, ACP, plugins and cron through the persistence interface
Each legacy store call in these areas moves to the interface operation that carries it, with main's errors and values.
2026-11-17 17:51:20 +01:00
Teknium
5c4db986bb fix(video_gen): downscale inlined images only for providers with a body cap
Review finding on this PR: the tool layer ran every video backend's sources
through the FAL helper, which also downscales to the managed FAL gateway's
3.5 MB budget. xAI, OpenRouter and DeepInfra have no such cap, so a large
data: URL the caller already supplied (or a big local file) was silently
re-encoded smaller (2048x2048 PNG -> 1536x1536 JPEG) for them.

Split the guarded path-to-data: conversion from the budget fit. The tool
layer always does the former; it applies the latter only when the active
provider declares `max_inline_image_chars` in capabilities(). FAL declares
the managed gateway's budget; the others send images at full size.
2026-11-17 02:36:12 -08:00
alt-glitch
67b3025978 fix(feishu): comment agent tools reach the Lark client again
The Feishu comment bot's five tools (feishu_doc_read and the four
feishu_drive_* tools) answered "Feishu client not available" on every call.
feishu_comment stored the Lark client in a threading.local on the thread
that starts the agent, and since ededa8c4f1 the agent runs each tool call
on a worker thread. The worker gets a copy of the caller's context
variables, not its thread-locals.

The client handle is now a context variable in tools/feishu_lark.py, set
and reset by token around the agent run. The handle's row in
gateway/turn_thread_reset.py goes, because nothing is keyed by thread any
more. The bot's reply was never affected: it is posted outside the tools.
2026-11-17 15:36:07 +05:30
alt-glitch
40d1e95f37 refactor(teams): move the Microsoft Graph auth and client into the teams_pipeline plugin
Some checks failed
Skills Index Freshness Check / check-freshness (push) Has been cancelled
Skills Index Freshness Check / check-catalog-cors (push) Has been cancelled
Docs Search Monitor / probe (push) Has been cancelled
Deploy Site / deploy-vercel (push) Has been cancelled
Deploy Site / deploy-docs (push) Has been cancelled
Build Skills Index / build-index (push) Has been cancelled
Build Skills Index / trigger-deploy (push) Has been cancelled
auto-fix lint issues & formatting / Generate eslint --fix patch (push) Has been cancelled
auto-fix lint issues & formatting / Apply patch (push) Has been cancelled
Canary Release / Tag, draft, and start the canary build (push) Has been cancelled
Canary Release / Prune canaries older than 14 days (push) Has been cancelled
Live provider canaries / Live provider canaries (push) Has been cancelled
tools/microsoft_graph_auth.py and tools/microsoft_graph_client.py register
no tool and only Teams code imports them, four of six imports from
plugins/teams_pipeline/. They move there as graph_auth.py and
graph_client.py, with their two tests under tests/plugins/teams_pipeline/.

- Importers change one import line where it stands; summary_writer.py
  keeps its imports inside _build_graph_client.
- The Graph client's only core import, parse_retry_after_seconds, is on
  the published plugin API.
- boundary_lint baseline drops the 8 rows for these imports; an import of
  another in-tree plugin is not a crossing (module_to_core 833 -> 825).
- The Graph app registration guide and its zh-Hans copy name the new path.
- Nothing stays at the old paths; neither module is on a frozen list.

Measured: with teams_pipeline disabled, Graph delivery from the Teams
summary writer still works, but its first call now imports the
teams_pipeline package (17 Hermes modules instead of 2), because
plugins/teams_pipeline/__init__.py imports its CLI.
2026-11-17 09:09:45 +05:30
alt-glitch
f8acc26834 refactor(gateway): outbound send files move from tools/ to gateway/outbound/
tools/ holds model tools. These three files register none: they send a
message to a platform for `hermes send` and for cron delivery, through
gateway adapters and gateway config. They move to the gateway package:

  tools/send_message_tool.py    -> gateway/outbound/send.py
  tools/send_message_senders.py -> gateway/outbound/senders.py
  tools/send_message_targets.py -> gateway/outbound/targets.py

Twelve test files move with them to tests/gateway/outbound/. Every importer
changes its import line in place. Nothing stays at the old paths: none of
the three names is on the plugin API list, the shipped-release list or the
old-updater list.

Behaviour is unchanged. The logger name stays tools.send_message_tool in
the three files and in the QQ Bot sender that shares it, so the lines stay
under `hermes logs --component tools`. The boundary-lint baseline changes
12 keys and no count, because its keys carry the module path of the
underscore names five bundled plugins import.

The import and docs rewrites were made by scripts/move/rewrite_imports.py
and rewrite_docs.py.
2026-11-16 18:09:07 +05:30
alt-glitch
c4635985a0 refactor(core): delete unreached send_message actions, clarify/session helpers and backend aliases
Removed. A search for callers by name, attribute and string (Python, TypeScript,
docs, the plugin API list and the frozen old-updater list) finds no supported
path that reaches any of them:
- tools/send_message_tool.py: _handle_list, _handle_react and the action
  dispatch in send_message_tool (every caller, including the external
  hermes-snooze plugin, passes action="send")
- tools/bot_failure_reasons.py: is_auto_retryable
- tools/clarify_gateway.py: _notify_cbs, _coerce_text_response,
  attempt_text_response_for_session, resolve_text_response_for_session
- tools/cronjob_tools.py: the unused task_id parameter of cronjob()
- tools/interrupt.py: is_thread_yield_requested
- toolsets.py: create_custom_toolset
- tools/tool_backend_helpers.py: prefers_gateway, REMOVED_BACKENDS,
  removed_backend_note, normalize_modal_mode (callers use coerce_modal_mode)
- hermes_cli/config_value_checks.py: _validate_web_backends (only read the
  always-empty REMOVED_BACKENDS map)

Tests that existed only for these symbols are deleted; tests that also
cover live behaviour now call the canonical live names
(attempt_text_response, _coerce_text_response_detailed, consume_yield).

The shared-bot route-gate tests that reached the gate through the deleted
react action now call _shared_bot_target_allowed directly, so the origin
rules (guild-only, thread-under-channel and user_id routes, Telegram topics,
the turn's sender in a shared channel) keep their coverage. The two error
hints and one comment that named send_message(action='list') now name
`hermes send --list`; the stale send_message row in the zh-Hans tools
reference goes.

Also:
- test_messaging_slash_command_fifo spies on clarify_gateway.attempt_text_response,
  the name gateway/run_inbound.py calls, so its [clarify] case can fail again
- send_message_tool: an action other than 'send' returns an error that names
  `hermes send --list` for listing targets
- multi-profile-gateways.md no longer says send_message sends reactions; the zh-Hans
  simplex.md and tools-reference.md match the English pages
2026-11-16 15:40:08 +05:30
Teknium
4a89bc6c02 feat(cache): one prompt-cache clock per session; Nous 5m ceiling as data
Every consumer that needs "when does this session's cached prompt expire?" now reads one
answer, agent/prompt_cache_clock.py:cache_window(), instead of re-deriving it from _cache_ttl.

- Per successful attempt the clock records the tier actually on the wire (cache_control ttl,
  prompt_cache_options.ttl, prompt_cache_retention, read from the sent payload), the send time,
  and the tier the response proved: Anthropic cache_creation.ephemeral_5m/1h_input_tokens,
  OpenAI Responses cache_write_tokens_details.ttl_30m/12h_tokens. normalize_usage keeps that
  split as CanonicalUsage.cache_write_by_ttl instead of dropping it.
- Per-route rules are a dict of small handlers: native Anthropic proves via the split;
  OpenRouter Claude is declared (live-probed to honour 1h); routes with a ceiling are clamped;
  other Anthropic-wire gateways assume 5m; OpenAI GPT-5.6+ proves via ttl_30m/12h or declares
  the documented 30m minimum; pre-5.6 assumes ~30m (5m on in_memory); implicit caches are
  unknown. expires = latest read-or-write send time + the written tier. A route switch,
  fallback, session rotation or compaction makes it unknown.
- Route TTL ceiling is data: ProviderProfile.prompt_cache_max_ttl (Nous ships "5m", because
  the Portal's upstream drops 1h after ~7 min and bills 5m), overridden per provider by config
  prompt_caching.route_ttl_ceilings. effective_cache_ttl uses the same helper, so Hermes stops
  asking Nous for 1h. A custom endpoint at the Portal host gets the Nous ceiling.
- Persisted as nullable sessions.prompt_cache_clock (JSON) through the existing token batch;
  restored lazily on resume, falling back to the newest assistant row (assumed).
- Codex app-server: read cacheWriteInputTokens instead of hard-coding cache_write_tokens=0.
- /context shows "Prompt cache: warm until HH:MM (…; 1h, proven)", "expired … ago" or
  "unknown (…)". The surface is absorbed from #142387 (render/duration helpers, the
  SessionContextBreakdownResult.prompt_cache contract and translations), reworked onto the clock.

Co-authored-by: Teknium <127238744+teknium1@users.noreply.github.com>
2026-11-15 12:04:54 -08:00
alt-glitch
7defffc296 fix(lint): clear the findings ruff preview reports
Turning on ruff preview (needed for PLW1514, unspecified-encoding) also
widens some stable rules. Clearing what it reports first lets the config
change that enables it land with no ignore list:

- evals workers: 20 text-mode open() calls get encoding="utf-8".
- a2a and weixin adapters: legacy "# type:" comments become annotations.
- agent/lsp/client.py, gateway/run_turn.py: two prose comments started a
  line with "type:", which type checkers read as a type comment.
- sorted(x)[0] becomes min(x) (plugins_session_env, one test).
- test_plugin_session_fork: the attempts default is built per call
  instead of a shared list inside a tuple.

The pinned ruff 0.15.22 passes with today's config and with preview on.
2026-11-15 14:02:40 +05:30
Maciej Lisiewski
f821b5bac1 Merge pull request #155430 from NousResearch/sec3/134019-standalone-npmrc
fix(security): release-age gate for the standalone WhatsApp bridge and Photon sidecar npm packages
2026-11-15 01:32:38 +01:00
Maciej Lisiewski
b678b78682 Merge pull request #155535 from NousResearch/sec3/149024-typing-before-auth
fix(gateway): no typing indicator or processing reactions for a sender admission will drop
2026-11-14 22:31:54 +01:00
Maciej Lisiewski
03ab6e9d01 Merge pull request #155427 from NousResearch/sec3/136773-dashboard-auth-hardening
fix(dashboard): HTTPS-only prefixed cookies, kanban WS host/origin gate, media-proxy per-hop allowlist
2026-11-14 22:21:38 +01:00
Maciej Lisiewski
17bb833679 Merge pull request #155374 from NousResearch/sec3/108353-inbound-secret-compare
fix(gateway): timing-safe inbound secret compares, replay windows, uniform webhook 404
2026-11-14 22:21:00 +01:00
Maciej Lisiewski
6272b26e95 fix(bluebubbles): send read receipts only to authorized senders
BlueBubbles runs on the owner's own Apple ID, so marking a stranger's DM
read showed "Read" from the owner before the runner's authorization check.
Gate mark_read on the same verdict the attachment download already uses.

Refs #149024
2026-11-14 21:11:55 +01:00
Maciej Lisiewski
41cbff6871 Merge pull request #155457 from NousResearch/sec3/136770-email-sender-identity
fix(email): sender identity must be exactly one round-tripping mailbox; ASCII-only folding
2026-11-14 20:25:58 +01:00
Teknium
803b3ec70c fix(telegram): an album's command caption still leads after an absorbed comment 2026-11-14 10:34:27 -08:00
Teknium
0896d4df55 fix(telegram): a comment absorbed by an inlined document survives the album's command caption 2026-11-14 10:34:27 -08:00
Teknium
f670c8b4a8 fix(telegram): a comment and the video, voice or file sent right after it are one turn
#151809 held a short text for the image sent right after it. Forward-with-comment and
"here's the clip:" then a clip send the TEXT first too, but for video, voice, audio and
documents the comment still flushed alone and the attachment became a second turn. The
media handler now claims the pending comment for any attachment and the generic dispatch
path absorbs it, the same claim/absorb seam the image path uses.

Co-authored-by: mene-crab <mene-crab@proton.me>
2026-11-14 10:34:27 -08:00
Maciej Lisiewski
e054275cf9 Merge pull request #155512 from NousResearch/sec3/146848-signal-code-restyle
fix(signal): never restyle text inside code blocks or inline code
2026-11-14 19:16:50 +01:00
Maciej Lisiewski
77509521cd Merge pull request #155486 from NousResearch/sec3/144949-gemini-finish-reason
fix(gemini): don't let a function call override truncated/blocked finish reasons
2026-11-14 19:15:13 +01:00
Maciej Lisiewski
f1ecb5e08f fix(signal): clear the 👀 actually sent even if the auth verdict flips mid-turn
The reaction gate now consults the gateway auth check, which can change
during a turn (the message that trips a bot's loop-guard budget passes
at start and fails at completion). Key the completion on the 👀 sent at
start; re-check the verdict only before the outcome emoji.

Refs #108353

Co-authored-by: BearHuddleston <196404565+BearHuddleston@users.noreply.github.com>
2026-11-14 17:16:42 +01:00
Maciej Lisiewski
c43b99bc03 fix(signal): pass is_bot to the attachment auth gate too
The attachment fetch gate called the gateway auth check without is_bot, so a
bot_users sender on the human allowlist got the human verdict and its
attachments were fetched while its chat was in loop-guard cooldown. The
SessionSource is now built before the gate and its is_bot is forwarded, the
same way the reaction gate does it (keyword only when set, so 3-arg callbacks
keep working).

Refs #108353
2026-11-14 17:16:40 +01:00
Maciej Lisiewski
75f970cb53 fix(gateway): keep the BlueBubbles password byte-exact, pass is_bot to Signal's reaction auth check
Only a whitespace-only BlueBubbles password is treated as unset; any other value
is used exactly as configured, both in the requests sent to the server and in the
webhook compare. Before this, .strip() altered passwords with leading or trailing
spaces.

Signal's pre-auth reaction gate now forwards source.is_bot, so a bot_users sender
gets the gateway's bot verdict (loop-guard cooldown) and a refused bot gets no 👀.

Refs #108353
2026-11-14 17:16:37 +01:00
Maciej Lisiewski
99b14b3cbb fix(gateway): adapt salvaged inbound-auth fixes to current main
Rejecting a bad webhook signature now returns the same 404 as an unknown
route, so the pin/V1/forged-challenge tests and the docs that still named
401 for signature rejections follow. The Feishu replay-window case ran only
with lark_oapi installed although the signature check never needs it, and
the quota tests signed with a fixed 2023 timestamp that the new window
refuses. The shared-helper test still imported BlueBubbles from its old
gateway/platforms path.

Fixes #108353
Fixes #108388
Fixes #127901
Fixes #136768
2026-11-14 17:16:33 +01:00
Adolanium
ef6bea4820 fix(signal): skip the processing reaction for senders the gateway rejects
on_processing_start fires before the gateway's authorization gate. With SIGNAL_ALLOWED_USERS unset the adapter's DM allowlist is "*", so when the operator authorizes through GATEWAY_ALLOWED_USERS or pairing, any sender still got the eyes reaction, revealing a listening bot. Consult the registered authorization check as well and skip the reaction when it returns False.
2026-11-14 17:16:33 +01:00
Adolanium
6a5d284097 fix(sms): ignore a repeated Twilio MessageSid instead of dispatching it again
X-Twilio-Signature covers only the URL and form fields, with no nonce or timestamp, so a captured signed POST replayed later passed validation and started the same turn again. Track recent MessageSids in a MessageDeduplicator (24h TTL, bounded) after signature validation and acknowledge a repeat with empty TwiML without dispatching. The cache is carried across adapter rebuilds by carry_inbound_dedup.
2026-11-14 17:16:32 +01:00
Adolanium
3426fe1ae4 fix(bluebubbles): compare the webhook password in constant time, treat blank as unset
The webhook check compared the request token to the configured password with !=, and a whitespace-only password counted as set, so a webhook sending the same blanks was accepted. Strip the password (connect() already refuses an unset one) and compare UTF-8 bytes with hmac.compare_digest, failing closed when the password is empty.
2026-11-14 17:16:31 +01:00
Adolanium
90ad8bbc80 fix(gateway): timing-safe webhook secret compare and uniform 404 on bad signature
Two webhook auth hardening gaps:

- bluebubbles compared the inbound token with != instead of the
  hmac.compare_digest pattern used by the other adapters. It now compares
  UTF-8 bytes (compare_digest raises on a non-ASCII str, and the token is
  attacker-controlled) and fails closed when no password is configured.
- The generic webhook adapter returned 404 for unknown routes but 401
  for a known route with a bad signature, so route names were enumerable.
  Bad signatures now return the same 404 (the profile-mismatch path
  already did exactly this). The webhook docs' response tables follow.
2026-11-14 17:16:30 +01:00
John Paul Soliva
bc7ff51ace fix(gateway): one timing-safe secret compare for every inbound adapter, replay window for WeCom and Feishu
BlueBubbles, the Google Meet node and WeCom compared remote-supplied secrets
with ==/!=. WeCom and Feishu verified a signature over a timestamp they never
checked, so a captured callback verified forever once message-id dedup
forgot it. The timing-safe compares elsewhere used provided.encode(), which
raises on the surrogate-escaped bytes aiohttp hands over, and A2A compared
str to str, which raises on any non-ASCII token: a 500 instead of a 401.

The compare and the 300 s window already existed privately in webhook.py.
They move to gateway/platforms/_shared.py as secrets_match and
timestamp_fresh (WEBHOOK_REPLAY_WINDOW_SECONDS), and every inbound compare
uses them. The Meet node keeps a stdlib-only inline compare because its
protocol module is deliberately free of gateway imports.

Fixes #127901

Co-authored-by: Bartok9 <259807879+Bartok9@users.noreply.github.com>
Co-authored-by: Adolanium <94890352+Adolanium@users.noreply.github.com>
Co-authored-by: zapabob <130830376+zapabob@users.noreply.github.com>
Co-authored-by: memosr <memosr_email@gmail.com>
Co-authored-by: zashraf1337 <6955094+zashraf1337@users.noreply.github.com>
2026-11-14 17:16:29 +01:00
Teknium
62adc7bfc2 fix(telegram): typing_indicator: false stops every sendChatAction, not only the refresh loop
The progress, proxy and queued follow-up paths called send_typing directly, so the
opt-out still sent a chat action after every progress edit. The check now sits at
the one sendChatAction call. Documents the opt-out for clients that move the view
while the indicator is on (#40885).
2026-11-14 07:28:22 -08:00
Maciej Lisiewski
64d66d8985 docs(signal): note why inline code is matched before enclosing pairs
Refs #146848

Co-authored-by: BearHuddleston <196404565+BearHuddleston@users.noreply.github.com>
2026-11-14 16:08:55 +01:00
Maciej Lisiewski
c238025571 fix(signal): unwrap fenced code in one pass so kept backtick runs are never re-parsed
A longer fence keeps ``` runs inside its code; the search-and-splice loop then matched
those runs as a new block, deleting them and leaving a stale MONOSPACE length. Build the
unwrapped text and ranges in a single finditer pass over the original text.

Refs #146848

Co-authored-by: BearHuddleston <196404565+BearHuddleston@users.noreply.github.com>
2026-11-14 16:08:55 +01:00
Maciej Lisiewski
6b41b2cfcc fix(signal): honour fences of any length when keeping code verbatim
code_fence() wraps a command that contains ``` in a longer backtick run, but
the formatter only knew three-backtick fences, so the ``` inside the command
closed the block and the rest of the command was restyled on the approval
card. Match any fence length with a backreference, in the code-block pass and
in the bullet/table fence splits.

Refs #146848
2026-11-14 16:08:55 +01:00
Maciej Lisiewski
5e1b13f6d2 fix(signal): keep code markers from opening matches that swallow prose styling
Follow-up to the salvaged fix: seeding `occupied` with code ranges stops
code from being restyled, but finditer still let a `**` inside a fence
pair with one in the prose after it; that overlapping match was dropped
and consumed the real pair, so the prose kept raw markers. Scan only the
gaps between code blocks. Adds a round-trip test that each issue command
in a fenced approval prompt reads byte-identical while prose is styled.

Refs #146848
2026-11-14 16:08:54 +01:00
crustdev
af2f9bf7d7 fix(signal): prevent restyling and corruption of code block contents (#146848)
- Protect fenced code blocks by pre-populating occupied spans so inline patterns cannot match inside them
- Skip heading matches that fall inside existing code blocks to avoid converting comments to bold headings
- Shift code block ranges when preceding headings are stripped
- Prioritize inline monospace backticks so inline code spans cannot be split by bold or italic markers
- Add comprehensive regression test suite in test_signal_format.py

Signed-off-by: crustdev <dev@crusts.dev>
2026-11-14 16:08:54 +01:00