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.
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.
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.
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.
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
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>
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.
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
#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>
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>
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
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
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#108353Fixes#108388Fixes#127901Fixes#136768
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.
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.
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.
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.
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>
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).
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>
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
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
- 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>
The Interactions transport (default for Gemini 3+/-latest on AI Studio) let
any function_call step override an incomplete/budget_exceeded status, and the
long-decode hop ceiling reported tool_calls when a call had streamed, so a
cut-off call executed. Report tool_calls only when the status maps to stop;
the hop ceiling always reports length. Also pin the native stream case where
finishReason arrives in a later event than the functionCall.
Fixes#144949
Review follow-ups on dm_threads: shared (Greptile on #155680):
- text batches stay per DM thread (the session key drops the thread, a merged
batch kept only the first event's source, so a second thread got no answer)
- /topic state is read from the source's pinned runtime profile store, not the
active scope (a primary bot routing to another profile keys before scoping)
- a hot reload of dm_topics updates config.extra too, so a topic added while
running stays its own session
- the shared copy uses session_identity.replace_source (keeps provenance)
- a rebuilt source with no live adapter ref (/loop, restored routes) reads the
answering bot's settings through the runner's delivery resolver
Review findings on #155645:
- 'Some finals still lose quotes': a final edit that lands after a short flood wait now runs the
same bookkeeping, and an oversized final indexes its edited first chunk and every continuation.
- 'Saved quotes change code': quotable_text() strips MarkdownV2 only outside code spans/fences.
- 'Write failures stay silent': rich_sent_store.record/record_async return False on a failed write
(still never raising) and the adapter logs on that result.
- 'The oversized adapter keeps growing': _edit_overflow_split moves to telegram_overflow_edit.py;
adapter.py is now below its origin/main line count.
Indexing the finalized text pushed edit_message's complexity over its
ratcheted cap; the saturated-preview dedup and the final's index write now
sit in one helper. Also maps @AlexGogin's commit email for attribution.
Trim the salvage to its fix: drop the quote-touch refresh (a synchronous
index rewrite on the event loop for every quote-reply, with no report of
eviction in practice) and the HERMES_RICH_SENT_MAX_ENTRIES env knob
(behaviour config does not go in env vars). Replace the mocked unit tests
with two real-gateway invariants against the Bot API stand-in: a
quote-reply to a plain send and to a streamed final, whose echo carries no
body, still reaches the model as [Replying to: "..."]. Both are red on the
base (the quoted text is missing) and green here.
Refs #147287, salvage of #151125.
Telegram does not echo a message body back in reply_to_message, so the adapter
resolves the quoted text from its own sent index (gateway/rich_sent_store). Only
the rich send path (sendRichMessage) wrote that index; the ordinary MarkdownV2
sendMessage path - which carries the vast majority of outbound messages - wrote
nothing. A user quoting such a message therefore produced an inbound event with
reply_to_message_id set and reply_to_text empty: the agent answered a question
whose subject it could not see, and nothing in the logs showed why.
- record the sent text on the legacy send path and on the legacy finalize edit
- refresh a quoted entry's timestamp so the FIFO trim keeps it
- make the index cap configurable via HERMES_RICH_SENT_MAX_ENTRIES
- log a warning when a quoted body is unrecoverable (the loss was silent)
- tests: tests/gateway/test_telegram_sent_text_index.py
On a multiplexed gateway, a routed profile's direct FAL image or video job
went out signed with the launch profile's FAL_KEY, so it was billed to the
launch profile's FAL account. Hermes' own check (fal_key_is_configured) reads
the routed profile's scope and says "configured", but the submit then used
the module-level fal_client.submit: one process-wide SyncClient() that reads
os.environ (the launch profile's .env, loaded at gateway start) on first use
and keeps that key for the life of the process.
Both direct sites now submit through tools.fal_common.direct_fal_client(),
which builds fal_client.SyncClient(key=...) from the same key the check reads
(new tool_backend_helpers.fal_key(), shared with fal_key_is_configured). One
client per key, reused, as the managed client already is. Unscoped
single-profile runs read the same key as before: get_secret falls through to
os.environ there.
The unscoped submit shapes came from 95dc9aaa75 (rewbs, 2026-03-26, #3287,
image) and d04b3c193e (alt-glitch, 2026-05-27, #33259, video). They became a
cross-profile leak once routed profiles started sharing one process.
Part of #151791 step 9-pre (tracker #152308): explicit per-profile SDK keys.
Modal, Vercel token mode and HF upload are separate follow-up slices.
Every core dashboard WS route runs _ws_request_is_allowed after
_ws_auth_ok; the kanban plugin's /events stream only ran the credential
check, and fell open (accepted) whenever web_server_chat failed to
import. Run both gates and drop the fail-open import fallback, so the
stream can no longer drift from core WS policy.
npm ci from a lockfile never consults min-release-age; the mirrored
.npmrc only matters for the npm install fallback's fresh resolve.
Refs #134019
Co-authored-by: BearHuddleston <196404565+BearHuddleston@users.noreply.github.com>
Follow-up to the salvaged #134062 commit. Drop its repo-walking
structural test (banned shape per tests/AGENTS.md) and instead assert the
read-only-tree mirror actually carries .npmrc to where npm ci runs. The
.npmrc comments now say what the gate mirrors: the root .npmrc carries
only engine-strict; the 14-day floor lives in pnpm-workspace.yaml's
minimumReleaseAge, which npm never reads.
Fixes#134019
npm reads project config only from the directory that owns the
package.json, so scripts/whatsapp-bridge and plugins/platforms/photon/
sidecar never inherited the root .npmrc's min-release-age=14 and their
lockfiles resolved without the cooldown - pinning versions published
days earlier (#134019).
The bridge holds WhatsApp session credentials, parses inbound messages
from arbitrary senders, and the gateway npm-installs exactly the locked
versions for every user (_ensure_bridge_deps), so the gate cannot be
applied user-side.
- add scripts/whatsapp-bridge/.npmrc and plugins/platforms/photon/
sidecar/.npmrc with min-release-age=14, matching the root
- include .npmrc in the photon sidecar _MIRROR_FILES whitelist so the
read-only-tree mirror keeps the gate where npm ci actually runs
- add a structural guard test: every directory with a package-lock.json
must carry a .npmrc with the same floor
Greptile: Custom proxy routes stop working. bot_api_urls appended /bot to any
path not ending in bot, so base_url https://proxy.example/telegram/ moved to
/telegram/bot<token>; it now appends only when the URL has no path, for
base_url and base_file_url alike.
PTB appends the bot token straight to base_url, so `extra.base_url:
http://127.0.0.1:8081` became `...8081123456:AA...` and httpx parsed the
token's secret half as a port: every connect attempt failed with
InvalidURL("Invalid port: '<secret>'") (#81787). bot_api_urls() appends the
Bot API `/bot` (`/file/bot`) path when the URL doesn't already end in `bot`
or carry PTB's {token} placeholder; the gateway adapter and the standalone
sender both use it.
Self-chat rejections logged the full chat/sender id of every other chat
on the owner's account, unconditionally; they now go through
redactWhatsAppId() like the debug events. libsignal's console.info
session dumps (private/root/base keys) are collapsed to their label by
the console wrapper, which now also covers console.info. bridge.log
rotates to one .1 generation above 5 MB when the adapter opens it at
spawn, and full/pre-update backups skip both generations.
Fixes#149860
* fix(security): keep the BlueBubbles password out of gateway logs
Every BlueBubbles request carries the server password as ?password=.
Two paths wrote it to agent.log in clear:
- Inbound: on the shared listener that serves multiplexed profiles,
aiohttp's default access logger records the full request target; the
adapter's access_log=None only applies when it binds its own runner.
RedactingFormatter now masks credential query params on aiohttp.access
records (the strict URL pass, which ordinary logs keep off so OAuth /
magic-link URLs survive).
- Outbound: httpx.HTTPStatusError text embeds the request URL. The
adapter's log lines and SendResult.error now go through one helper that
applies redact_url_credentials.
Fixes#143550Fixes#146420
* test(security): pin every BlueBubbles REST error path and the access-line gate
Each remaining _safe_error site (register, unregister, attachment upload,
attachment download) now has a real httpx 401 test, and a RedactingFormatter
test pins that only aiohttp.access records get the strict URL pass.
Refs #143550
Co-authored-by: BearHuddleston <196404565+BearHuddleston@users.noreply.github.com>
---------
Co-authored-by: BearHuddleston <196404565+BearHuddleston@users.noreply.github.com>
* fix(plugins): keep config-selected plugin names inside their plugin root
memory.provider, cron.provider and context.engine were joined onto the
plugin root unchecked, so a path-shaped name loaded a package from
anywhere. Worse, the "is bundled" test was lexical (Path.parents), so a
`<root>/../..` spelling counted as bundled and was imported in-process
even under plugins.isolation: host. Names must now be a plain directory
segment (invalid = not found, so the built-in fallbacks apply), and the
bundled test compares resolved paths.
Fixes#141328
* fix(plugins): a user-dir symlink into the bundled root is not bundled
is_direct_child compared resolved paths only, so $HERMES_HOME/plugins/<x>
linking into a bundled dir counted as bundled and loaded in-process past
plugins.isolation: host (and the link could be swapped between check and
import). Require the path to sit under the root both as written and resolved.
Refs #141328
* test(plugins): satisfy ruff PLR0402 and cover the resolved half of is_direct_child
Use `from plugins import ...` instead of aliased submodule imports (ruff
PLR0402 failed the Python lints lane). Add a bundled-root child symlink that
resolves outside the root, so dropping the resolved comparison in
is_direct_child is caught.
Refs #141328
Co-authored-by: BearHuddleston <196404565+BearHuddleston@users.noreply.github.com>
---------
Co-authored-by: BearHuddleston <196404565+BearHuddleston@users.noreply.github.com>
Greptile: Split replies still carry quotes. The split-anchor rule moves into
telegram_split.split_reply_anchor and send_rich_parts applies it before
_deliver_parts, so an opted-out split rich reply carries no reply_parameters.
Docs state the streamed-reply limit (anchor chosen at the first preview; an
edit cannot remove it).