Commit Graph

177 Commits

Author SHA1 Message Date
Maciej Lisiewski
6a0b9d29da refactor(matrix): share read_body_capped with the outbound image fetch
_download_external_media_with_cap kept its own copy of the
Content-Length + streamed-size check; route it through the same reader
as the inbound mxc path so the cap lives in one place. The image/* type
check stays outbound-only.

Refs #55041
2026-11-13 17:30:13 -08:00
Maciej Lisiewski
8963d75e0d fix(matrix): enforce MATRIX_MAX_MEDIA_BYTES on the inbound mxc read
mautrix 0.21.1 Client.download_media() returns `await response.read()`,
so an event that omits or under-reports info.size had its whole body
buffered (and cached) regardless of MATRIX_MAX_MEDIA_BYTES.

Move the capped request into plugins/platforms/matrix/media_download.py,
mirroring download_media (same URL helper, v1.11 auth header, request
logging) but streaming under the cap, and drop the event when the cap is
crossed instead of falling back to the HTTP URL. Replaces the salvaged
commit's in-adapter helper, whose unittest.mock detection kept the
unbounded path reachable, and keeps the facade from growing.

Fixes #55041
2026-11-13 17:30:13 -08:00
luyifan
1d646f5af3 fix(matrix): stream inbound media under cap 2026-11-13 17:30:13 -08:00
Maciej Lisiewski
342b54fa53 Merge pull request #154614 from NousResearch/sec/46006-no-user-content-at-info
fix(gateway): keep user content and identities out of INFO+ logs (HX017)
2026-11-13 17:17:09 +01:00
Maciej Lisiewski
53a5c32f18 fix(gateway): keep user content and identities out of INFO+ logs
Gateway and adapter logs reach `hermes debug share` uploads, whose redaction covers
secrets only, so message bodies, subjects, display names, e-mail addresses and the
inbound-message preview were being published verbatim. INFO+ lines now carry lengths,
platform ids or a short `hash_for_log` digest; the raw value moves to DEBUG.

HX017 (scripts/code_health/py_rules_log_content.py) flags INFO+ log calls in gateway/
and plugins/platforms/ whose args are content-named values (text, body, subject,
user_name, display_name, sender_addr, ...). It is name-based on purpose: ids are not
matched, and transport payloads (resp.text, error_text) are skipped. Every existing
hit is fixed or waived with a reason, none baselined. Policy documented in
gateway/AGENTS.md and ADDING_A_PLATFORM.md.

Refs #46006
2026-11-13 13:59:39 +01:00
Maciej Lisiewski
bbfcf16ec5 fix(matrix): keep m.notice bot flag narrowing-only, drop MATRIX_ALLOW_BOTS
msgtype is chosen by the sender, so any Matrix user (federated strangers in
DMs included) can send m.notice. With MATRIX_ALLOW_BOTS=mentions|all and
process_notices on, that let an unlisted sender skip MATRIX_ALLOWED_USERS,
and 'mentions' was never enforced by the Matrix adapter anyway.

Keep m.notice -> is_bot (loop guard, no pairing reply), but don't declare
allow_bots_env until Matrix has an unspoofable bot identity; notice senders
still need a human rung.

Refs #143370
2026-11-13 13:57:48 +01:00
liuhao1024
9e11b317d7 fix(matrix): flag m.notice senders as bots on the session source
A Matrix notice author reached the gateway as a person: only Discord,
Slack, Telegram and Feishu stamped SessionSource.is_bot, so the bot
loop guard and the no-pairing-DM rule never saw a notice-writing bot
(#143370).

Flag msgtype=m.notice sources in _resolve_message_context. The flag only
narrows: a notice sender still needs a human authorization rung.
2026-11-13 13:57:47 +01:00
Maciej Lisiewski
6154847dc8 refactor(matrix): move HTML sanitizer and TeX helpers to adapter_html.py
adapter.py is over the 2,000-line ratchet, so the sanitizer fix must not
grow it. Both send paths (live adapter and standalone sender) import the
shared sanitizer from the sibling; behaviour is unchanged.
2026-11-12 15:55:51 +01:00
Maciej Lisiewski
4122e6e0ec fix(matrix): sanitize standalone formatted_body; expand TeX only in text nodes
The standalone sender (cron / send_message without a live adapter) put
markdown.markdown() output straight into formatted_body, so raw HTML and
javascript:/data: links reached Matrix clients. Run the same allowlist
sanitizer the adapter uses.

Both paths also expanded $...$ sentinel tokens into data-mx-maths markup
with a regex over the finished, sanitized HTML, including inside attribute
values: [x](https://e.com/$onmouseover=alert(1)//$) broke out of href and
injected on* attributes. Token expansion now happens inside the sanitizer:
text nodes expand to data-mx-maths, attribute values get the inert $tex$
source back.

Fixes #42667
2026-11-12 15:55:51 +01:00
Teknium
bf77c21427 fix(gateway): picker cards and the /update prompt answer only to their opener
A picker card (/model, /reasoning, /fast, the usage-limit switch offer)
and the /update Yes/No prompt only checked the chat allowlist on a tap,
and a pending /update prompt took the next message ANY admitted member
sent in the session as its answer. In a shared group with
group_allow_admin_from set, a member refused /reasoning or /model could
tap the admin's open card and apply it, and anyone's chat text answered
the admin's "Restore local changes now?".

The gateway now records the opener (sender id, name, chat scope) when it
sends the card (prompt_authority on the selection callback) and in the
/update pending marker. Every renderer refuses another member's tap with
the existing localized "Only <name> can answer this approval." note and
leaves the card open: Telegram mp:/cp:/update_prompt:, Discord
ModelPickerView/ChoicePickerView/UpdatePromptView (one _gate), Slack
model picker (ephemeral), Matrix picker reactions, Feishu choice picker
and update card (toast). A non-opener's typed text during a pending
/update prompt falls through as an ordinary message. The check is
gateway.approval_actor.may_answer, the same rule exec approvals use:
the opener and the chat scope's admins always pass; a sender-less card
(shared observed route) keeps the old anyone-admitted behaviour.

QQBot's update button already accepts only the session's own user.
picker_refusal / update_prompt_refusal join approval_refusal in the
published plugin API so platform plugins can apply the same check.
2026-11-10 14:06:57 -08:00
Teknium
17dd06937e fix(gateway): a non-admin cannot answer a prompt where they could not type its command
With `allow_admin_from` set and the default `approvals.approvers: ["*"]`, a non-admin was
refused `/approve` but could still answer an admin's blocked command by typing a bare
`always` (which also writes the profile-wide allowlist), tapping Allow on any adapter, or
answering a `/reset`-style slash confirm.

`gateway.approval_actor.may_answer` now takes the answer's command (`approve` / `deny`, or
the confirmed command) and the chat's full slash policy, so one decision covers every path
main already routes through it: `/approve` and bare words, typed confirm replies, relay,
and the Telegram/Discord/Slack/Matrix/Feishu/Teams/WhatsApp Cloud buttons; QQ Bot's settle
now passes the clicker too. Precedence: a narrowed `approvers` decides on its own
(requester, listed ids, admins); under `["*"]` the slash policy decides (admins plus
`user_allowed_commands`). No admin list, admins and clarify answers behave as on main.

Fixes #120506

Co-authored-by: Froraut <79215537+Froraut@users.noreply.github.com>
Co-authored-by: John Paul Soliva <soliva.johnpaul@icloud.com>
2026-11-10 13:52:56 -08:00
Teknium
466591fe65 fix(gateway): opt-in approvals.approvers binds shared-chat exec approvals to the requester on every platform
Some checks failed
Live provider canaries / Live provider canaries (push) Has been cancelled
Carries #144799 rebased onto #151023's request-bound approval cards (one
squashed commit, because #151023 rewrote the same resolver, card and
adapter paths that #144799's eight commits patched one by one).

With `approvals.approvers: []`, an approval raised by one person's message
can only be answered by that person, a listed approver or a platform admin;
anyone else who taps Allow/Deny, reacts or sends /approve gets a private
"Only <name> can answer this approval." and the command stays pending. The
default stays `["*"]` (any admitted member answers), unchanged from main.

How it sits on #151023:
- tools/approval.py::resolve_gateway_approval_card takes #144799's
  signature (actor_id, admin_ids, extra) with #151023's body: a tap with no
  request id resolves nothing, and a Deny-only card can only deny.
- _ApprovalEntry carries both `authority` (#144799) and `card_deny_only`
  (#151023).
- Discord, Matrix and Telegram card handlers check the requester first,
  then settle through the request-bound resolver; the Telegram refusal
  toast goes through #151004's expired-query-safe answer_callback.
- #144799's tests that seeded id-less cards and expected the oldest
  request to settle now seed the real request id.
- Relayed approval answers check the bot-owning profile's admins;
  identical approvals coalesce only under the same answerers.

Fixes #80281
2026-11-08 22:46:20 -08:00
Teknium
02d07c811c fix(matrix): keep a Deny-only card live without reaching into tools.approval
CI red (boundary lint): the crafted-checkmark fix looked up whether the card's
request was still pending through tools.approval.list_gateway_approvals, a core
name the plugin API does not publish (module_to_core 1, baseline 0). The card
now remembers the choices it seeded, so a reaction for a choice it never
offered (a hand-added checkmark on a Deny-only card) is answered 'not a valid
reaction' before anything resolves, and the card stays live for the owner's
later Deny. A published resolve_gateway_approval_card refusal again means the
request already settled.

(cherry picked from commit cca49ecac80242a455139925cfa5f07338d781be)
2026-11-08 22:46:20 -08:00
Teknium
5f4ca97c77 fix(matrix): a refused approve reaction leaves a pending Deny-only card live
Finding (review P3): the session owner adding a checkmark to a Deny-only card
was correctly refused by resolve_gateway_approval_card, but the reaction
handler read every refusal as 'already settled'. It retired the card and posted
'Approval expired' while the request was still pending, so the owner's later
Deny found no prompt and the agent waited out the full timeout. A refusal
while the card's request is still queued now answers 'not a valid reaction'
and keeps the card.

(cherry picked from commit 2e9d033a9969faebc45e33b20f0111f8fa64d443)
2026-11-08 22:46:20 -08:00
Teknium
f0ac114d2d fix(telegram): every native approval renderer honours a Deny-only prompt
Finding "Deny-only cards still offer approval" (and "QQ hides shorter command
tails"): filtering ExecApprovalPrompt.actions did not reach every renderer.
WhatsApp Cloud hardcoded Approve, QQ always built allow-once and re-cut the
command to 300 chars (so a 300-3,000 char command passed the shared check yet
hid its tail behind live approve buttons), and Matrix still printed the
!approve instructions.

- WhatsApp Cloud: the Approve button is sent only when "once" is offered.
- QQ: the card body is the shared prompt.text (the preview the truncation
  check measured, with its notice) and the keyboard offers only
  prompt.choices.
- Matrix: a Deny-only prompt drops the typed !approve hint; reactions were
  already per choice.
- Backend: send_exec_approval marks a Deny-only request card_deny_only, and
  resolve_gateway_approval_card refuses any other choice for it, so a
  hand-added reaction, a replayed callback or a FIFO tap (QQ carries no
  request id) cannot approve it. QQ now resolves through
  resolve_gateway_approval_card. Typed /approve is unchanged (the
  text-command path is the CLI/owner escape hatch the notice points to).

(cherry picked from commit a72c5491a698bca5512bdbadff1c32dbc6b1b7e1)
2026-11-08 22:46:20 -08:00
Teknium
948ee7dcd0 fix(matrix): redact against the env proxy the session uses after the missing-SOCKS fallback
Finding: Matrix missing-SOCKS fallback checks the ignored SOCKS proxy.
Without aiohttp_socks, _create_matrix_session drops MATRIX_PROXY=socks5://...
and returns ClientSession(trust_env=True), which dials HTTPS_PROXY. Every
catch checked the clean, unused SOCKS URL, so the whoami catch kept
exc_info and logged the chained 'invalid literal for int(): <password>'.
matrix_redaction_proxy() now names the proxy the session really uses
(the env proxy, NO_PROXY and gateway.trust_env applied, after a fallback).
2026-11-08 19:47:57 -08:00
Teknium
c3d47e8caa fix(gateway): log only the exception type and proxy host:port for proxy errors
Round-3 review findings 1-4 and the Greptile thread "Some passwords still reach logs".

redact_proxy_in_text cut configured proxy-URL pieces out of library error text, but
yarl/httpx percent-encode, split or reformat the URL before raising (bob:p%C3%A4ss...,
Invalid port: 'abc'), so short, re-quoted or scheme-word passwords still leaked. It is
replaced by describe_proxy_error(exc, proxy_url): when the proxy URL holds anything its
log-safe rendering leaves out, the log line and chat reply carry only
"<ExceptionType> via <scheme://host:port | placeholder>" and no exc_info traceback.
A proxy-free or secret-free proxy keeps the full error text.

Sites: proxy-mode turn (log + chat reply), Telegram connect, network-retry, reconnect,
conflict-retry/exhausted and polling-error callbacks, the standalone Telegram sender's
attach fallback, Discord connect, Matrix whoami/login/initial sync/sync loop, Slack connect.
2026-11-08 19:47:57 -08:00
Teknium
e6a6d0df94 fix(gateway): log proxy URLs without any path segment
Delta review P3 'the file-name keep rule can carry a token':
http://proxy:8080/<token>.json logged as http://proxy:8080/.../<token>.json
because the media file-name rule keeps a 40-char stem + extension.

A proxy URL's path carries no routing meaning, so every proxy log site
(Matrix x2, Telegram, Discord, Slack x2, standalone sender, base SOCKS
warning, run_turn x4) now uses safe_proxy_url_for_log: scheme://host[:port]
or the placeholder. safe_url_for_log keeps the file-name rule for its media
callers (send_images, cache retries, SSRF errors), which rely on it.
2026-11-08 19:47:57 -08:00
Adolanium
7e3af16bc2 fix(gateway): keep SOCKS proxy credentials out of the missing-aiohttp_socks warning
When a socks5:// proxy is configured but aiohttp_socks is not installed,
the shared connector helper and the Matrix session builder warn that the
proxy is ignored and log the raw URL. The redactor does not mask userinfo
in socks5:// URLs either, so DISCORD_PROXY=socks5://user:pass@host still
wrote the password to gateway.log. Log both through safe_url_for_log, like
the INFO lines in the previous commit.
2026-11-08 19:47:57 -08:00
Adolanium
2f3e21fc36 fix(gateway): log proxy URLs without their embedded credentials
resolve_proxy_url documents that a proxy URL may carry credentials
(http://user:pass@host). Telegram, Discord, Matrix and the standalone
Telegram sender logged that URL verbatim at INFO, and the log redactor
passes http(s) userinfo through on purpose, so the proxy password ended
up in gateway.log and agent.log. Slack already logs the proxy through
safe_url_for_log; the other four call sites now do the same.

The transport still receives the full URL; only the log line changes.
2026-11-08 19:47:57 -08:00
Teknium
7ab170ea6d fix(matrix): a reaction on a settled approval card reports that it expired
Review minor (unsupportedpastels): Matrix ignored a stale card's reaction
silently; it now retires the card and posts platform.matrix.approval.expired,
the same path the local deadline already takes.
2026-11-04 21:40:32 -08:00
Teknium
5ab58da1f6 fix(gateway): a stale approval card no longer approves the next request
Discord already binds its approval view to the tools.approval request id
(4f86e97791, 50f57a131f) and the runner passes ExecApprovalPrompt.request_id
since cfed2ca71f. Every other native-button surface still resolved by
session key alone, FIFO: when the request a card was rendered for had
already settled (timeout, typed /approve), a press on that card resolved
the NEXT pending approval in the session, one the user had not seen.

Telegram, Slack, Feishu, Matrix, WhatsApp Cloud, Teams and the relay
adapter now remember prompt.request_id with the card and resolve through
tools.approval.resolve_gateway_approval_card, which targets only that
request. A card sent without an id keeps the FIFO behaviour.
2026-11-04 21:40:32 -08:00
rob-maron
15307dece7 Usage-window plan support 2026-10-20 21:04:30 -04:00
David Dudok de Wit
de526521ab fix(gateway): let a serial reader return once a busy burst input is held
Signal and IRC await handle_message before they read their next input.
A busy photo or queue-mode text was held for the burst window and the
call returned only after the durable commit, so the burst's next input
could arrive only once the burst had committed alone: two turns where
main merged one, and the reader stalled about 0.38 s per busy input.

An adapter now declares serial_receive_loop when it delivers a chat's
next input only after handle_message returns and returning triggers no
acknowledgement. For it, dispatch_busy_burst returns as soon as the
input is held, as main returned once the input was merged into the
pending slot. The burst still commits once and in order, and a failed
commit is logged. Every other adapter keeps commit-before-return.

The reader still never runs ahead of what it returned on:
- a command first waits until every earlier input of that reader has
  committed (/stop, /new and /reset drop their own chat's held burst),
  so /restart cannot close admission under a held input and /new
  cannot miss one still committing;
- a chat holds at most one uncommitted burst: the next one waits for
  that commit, as main's reader waited at its first commit.

Flagged: Signal, IRC, email, Matrix, Mattermost, ntfy, Photon, SimpleX,
WeCom, WhatsApp and Feishu. Buzz is left out: it saves its cursor only
after the call returns.

Refs #134889
Fixes #140538

(cherry picked from commit e72e05a1e6e415ff54426b205dcc6b6f408417cf)
2026-10-18 03:15:07 -07:00
Teknium
914737a811 feat(gateway): public SSRF-safe HTTP client helper for platform plugins
Every bundled adapter built its client from three private pieces:
gateway.platforms.base._ssrf_redirect_guard, tools.url_safety's
create_ssrf_safe_async_client and _http_client_limits.platform_httpx_limits.
The redirect guard becomes public (ssrf_redirect_guard; callers renamed, no
alias) and gateway.platforms.helpers.platform_http_client(**kw) composes all
three, with the guard ahead of any caller response hooks. QQ Bot and WeCom
move to it.
2026-10-17 14:51:46 -07:00
Teknium
47d9efe490 feat(gateway): plugin platforms declare group-chat allowlist and pairing suppression
Two authz behaviours were hard-coded on Platform.QQBOT/TELEGRAM/... in
gateway/authz_mixin.py (_GROUP_CHAT_ENV, _ALLOWLIST_SUPPRESSES_PAIRING), so a
plugin-registered platform could not get them and removing the bundled QQ
adapter would silently drop QQ_GROUP_ALLOWED_USERS gating and change pairing.

PlatformEntry gains group_allowed_chats_env and allowlist_suppresses_pairing;
authz_mixin reads them through authz_field (live entry, else the bundled
gateway_env.AUTHZ). Every bundled platform that was in the old tables declares
them in its AUTHZ, so behaviour is unchanged.
2026-10-17 14:51:46 -07:00
Teknium
b95c4861b2 fix(platforms): bundled authorization env names hold when the live entry lacks them
Independent review found the allowlist, the open-policy startup refusal, the pairing-noise
rule and `hermes pairing revoke` reading only the live PlatformEntry: a user plugin overriding a
bundled platform without the fields, safe mode or a disabled plugin then gated on nothing
(looser than main, whose core tables always applied).

Each bundled plugin now declares them once as `gateway_env.AUTHZ` (passed to register() with
**), and `gateway.platform_env.authz_field` answers from the entry, else from that file (read
without the plugin package). Probed main vs head: 208/208 authz decisions identical in normal,
safe-mode, plugin-disabled and user-override modes; revoke drops the user in all four.

The terminal secret blocklist and config_env_table_keys() read the same files, which removes the
three hand-listed plugin secrets in local_env_policy.
2026-10-16 19:42:34 -07:00
Teknium
2f4b42191e fix(platforms): import new plugin siblings relatively (no second adapter copy)
The plugin loader runs a bundled platform package as hermes_plugins.platforms__<name>.
An absolute `from plugins.platforms.<name>.<sibling> import ...` inside register() imports
the canonical package too, whose __init__ loads a second copy of the adapter. The prompt-hint
and send-target siblings added on this branch did that for buzz, feishu and slack (three new
double-loaded adapters vs main). Relative imports, as the dashboard_card / gateway_env siblings
already use; after every plugin registers, the double-loaded set is back to main's five.
2026-10-16 19:42:34 -07:00
Teknium
3c3f85a0d0 refactor(gateway): plugin platforms declare their env->config rows on PlatformEntry
Move the per-platform `_Cred` rows of `_ENV_STEPS`, their helper steps and the
`_ENV_ENABLE_CREDENTIALS` rows for every plugin-backed platform (telegram, discord,
slack, whatsapp, whatsapp_cloud, signal, mattermost, matrix, email, sms, dingtalk,
feishu, wecom, wecom_callback, weixin, bluebubbles, qqbot, yuanbao) out of
gateway/config_env.py into each plugin's `gateway_env.py`, attached via two new
PlatformEntry fields: `env_overrides` (ordered steps) and `env_enable_credentials`.

`gateway/platform_env.py` holds the declarative `EnvCred` row and shared parsers.
`_apply_env_overrides` runs the rows of entries with activation evidence (same gate
as the plugin enable pass, computed once). Core-only rows (api_server, webhook,
msgraph_webhook, relay) stay in config_env. profile_channels reads the rows from
registry entries; the import-time terminal secret blocklist lists the three secrets
only those rows read, pinned by a new invariant test.

Resulting GatewayConfig and explicit-disable warnings are identical (differential
oracle, 100 fixtures); only env-created insertion order of api_server/webhook/
msgraph_webhook relative to plugin platforms changes.
2026-10-16 19:42:34 -07:00
Teknium
28e4da48fe refactor(dashboard): channel cards and env-value checks read the plugin's PlatformEntry
The Channels page catalog (_PLATFORM_OVERRIDES) and the PUT env-value validators
(_ENV_VALUE_RULES) duplicated per-platform data the bundled platform plugins can
declare. Each plugin now declares its card on its PlatformEntry (new dashboard
block: dashboard_label, dashboard_description, docs_url, dashboard_env_vars,
dashboard_required_env, env_value_rules); core keeps static rows only for the
core-only platforms (api_server, webhook, msgraph_webhook, relay).

Telegram/Slack validators move into their plugins. The PUT route resolves the
rules right after _require_platform (catalog build already materialized every
entry, so nothing extra is imported) and before entering _profile_scope, where
the registry's profile overlay may not hold the entry.

Adapters over their size cap (discord, feishu, matrix, slack, telegram) keep the
card in a sibling dashboard_card.py, imported relatively so no second canonical
copy of the adapter module loads; surplus blank lines offset the two added lines.

Behaviour identity: differential oracle over the real route handlers (GET
/api/messaging/platforms root + profile, PUT valid/invalid per rule root +
profile) is byte-identical to base.
2026-10-16 19:42:34 -07:00
Teknium
e24f12c69f refactor(send): read send_message target syntax and standalone routing from the plugin registry
Delete the per-platform tables in tools/send_message_targets.py (_PLATFORM_PARSERS, 14 rows) and
tools/send_message_tool.py (_PLUGIN_STANDALONE_MEDIA, _TEXT_SENDERS, plus the discord-always and
whatsapp-mentions ladders). Each bundled plugin now declares them on its PlatformEntry:

- target_ref_syntax_fn: the old parser, body unchanged. A new field rather than parse_target_ref_fn
  because that field is an authority (strict under pass_unresolved_references, no "not explicit"
  sentinel, not re-applied to channel-directory hits) and reusing it would change react/cron
  behaviour for ntfy/buzz/photon.
- standalone_send: StandaloneSendPolicy (label, media, all_sends, captionable,
  empty_list_between_chunks, forward_force_document, mentions, text_direct).

Shared builders and the NOT_EXPLICIT sentinel live in gateway/platforms/send_targets.py so plugins
import no core-private helpers. Lookups discover plugins first when the name is not registered yet
(fresh CLI/cron process). Differential oracle (33 platforms x 48 refs, 10 send cases each): base and
head output identical.
2026-10-16 19:42:34 -07:00
Teknium
3d21ec1294 refactor(platforms): plugin PlatformEntry carries its prompt hint and display defaults
PLATFORM_HINTS (agent/prompt_builder.py) and _PLATFORM_DEFAULTS (gateway/display_config.py)
duplicated per-platform data for every bundled messaging plugin. Both consumers already fell
back to the registry (PlatformEntry.platform_hint / display_tier), so the plugin rows move onto
each plugin's register() call and the core tables keep only core surfaces (cron, cli, tui,
desktop, api_server hints; webhook, api_server display rows).

New PlatformEntry field display_overrides: per-key defaults layered over display_tier (telegram,
discord, slack, wecom had tier + tweaks). Hint text is copied byte-for-byte (the shared
_MEDIA_NATIVE fragment is inlined); a base-vs-head oracle of platform_hint() and
resolve_display_setting()/resolve_tool_progress() for every platform, with and without user
display overrides, is byte-identical. Oversize adapters keep the hint in adapter_hint.py.
2026-10-16 19:42:34 -07:00
Maciej Lisiewski
0006a5e229 ci: fix PLW1509, PLW1510, PLW2101 linter errors 2026-10-10 15:20:13 +02:00
Maciej Lisiewski
aff64c3eeb ci: UP007, UP022, UP028, UP031, UP041 linter fixes 2026-10-09 17:31:52 +02:00
Maciej Lisiewski
d76cce4f11 ci: apply all automatic linter fixes available 2026-10-08 17:22:54 +02:00
kshitijk4poor
2efd6961f7 refactor(matrix): move _CryptoStateStore into adapter_crypto to keep adapter.py under its size cap
Code-health ratchet: plugins/platforms/matrix/adapter.py was 3308 > 3278 and
tests/gateway/test_matrix.py 3310 > 3245 (both over the 2,000-line target, so
they may only shrink vs main).

- Move the existing _CryptoStateStore OlmMachine state-store shim (byte-identical)
  into the new topical sibling plugins/platforms/matrix/adapter_crypto.py; the
  one call site in _connect_setup_e2ee late-imports it. No facade re-export.
- Move this stack's encrypted-drop warning tests (and their _cryptoless_client
  helper) into tests/gateway/test_matrix_encrypted_drop_warning.py.
2026-10-05 19:47:30 +05:30
kshitijk4poor
07030cc2d3 refactor(matrix): read encrypted-drop timeline events like the rest of the sync path
Gate finding B08-2: `((room_data or {}).get("timeline", {}) or {}).get("events", ()) or ()`
guarded against shapes a /sync join entry never has. rooms_join comes from
`sync_data.get("rooms", {}).get("join", {})` (same unguarded style a few lines
up) and mautrix's own handle_sync reads the identical payload as
`room_data.get("timeline", {}).get("events", [])`, so any malformed entry would
already fail there. Match that form; keep the per-event isinstance guard.
2026-10-05 19:47:30 +05:30
kshitijk4poor
1680245d7e fix(matrix): don't give install advice in the encrypted-drop warning when E2EE is on
Gate finding B08-1: when MATRIX_E2EE_MODE is optional/required but the
decryptor failed to set up at connect (degraded mode), the warning still
told the user to pip install the E2EE deps and set MATRIX_E2EE_MODE=optional
-- advice that is wrong (the mode is already on) and hides the real cause.
Keep the install hint only for mode=off; otherwise name the active mode and
point at the earlier Matrix E2EE startup warning. The warn-once test is
parametrized over off/optional to pin both messages.
2026-10-05 19:47:30 +05:30
kshitijk4poor
f30d3c870e fix(matrix): name MATRIX_E2EE_MODE in the encrypted-drop warning
The default MATRIX_E2EE_MODE is off, so installing the E2EE deps alone
never attaches a decryptor; an operator following the old hint would
stay deaf. Point at the mode setting too.
2026-10-05 19:47:30 +05:30
liuhao1024
846e63d9ec fix(matrix): warn when encrypted room events arrive with no E2EE decryptor
Under hermes acp/gateway, a Matrix connection with E2EE off or degraded
(optional mode with missing deps or a failed setup) drops every
m.room.encrypted timeline event silently: mautrix dispatches them to an
empty ROOM_ENCRYPTED handler set, so the room looks connected but deaf —
syncs succeed with no errors and no warnings (#131778).

_absorb_sync now checks each joined room's timeline and logs one warning
per room when encrypted events arrive while client.crypto is unset,
pointing at the E2EE install hint. With a decryptor attached, mautrix's
own DecryptionDispatcher already reports decryption failures.

(cherry picked from commit 8cf08825296b88ab57ed0b83371840bb5fc7c7c0)
2026-10-05 19:47:30 +05:30
kshitijk4poor
05fdbf6317 refactor(matrix): import markdown once in the standalone sender, drop the None sentinel
The standalone payload builder imported markdown inside the per-chunk loop
under suppress(ImportError), which read as though the import could fail per
chunk. Try it once before the loop and branch on the result.

_standalone_send seeded `result = None` and returned it after the loop,
suggesting a possible None return. truncate_message always yields at least one
chunk, so the loop always runs; return the failing result directly and the
last result otherwise. No behaviour change.
2026-10-03 16:31:35 +05:30
Froraut
b015e59fb9 fix(matrix): address review — budget edit mentions and move plugin tests
An edit carries m.mentions twice: once inside m.new_content and once at the
top level. When a budget-sized edit names many distinct Matrix IDs, that
fixed part alone could pass the content budget. Shortening the fallback body
then had no room to work with, and the edit still went out at about 54 KB,
which an encrypted room would reject with M_TOO_LARGE.

When the edit is still over budget with an empty fallback, it now drops the
top-level mentions copy. That copy only drives the edit's own notifications,
and m.new_content keeps the full list.

The event-size tests move to tests/plugins/platforms/matrix/test_event_size.py,
mirroring the plugin source tree, and gain a mention-heavy text. The
tests/gateway/test_matrix_message_length.py file is back to main apart from the
env-override value that the new ceiling requires.

(cherry picked from commit 4b06bcb7dbffb732bef6e877cb66dea2fbff8c73)
2026-10-03 16:31:35 +05:30
Froraut
d584836ffa fix(matrix): keep every outbound event under the homeserver's byte cap
The homeserver rejects any event whose canonical JSON is over 65,536 bytes
(M_TOO_LARGE), but Matrix chunked outbound text on characters, 16,000 by
default with a 65,535 ceiling. Each message carries its text twice (body plus
formatted_body HTML), and an edit carries it four times (the "* " fallback
plus m.new_content).

On the default config this caused three failures:

- A formatted chunk of CJK text came to about 95 KB and was rejected, so
  _send_with_retry fell back to a plain 3,500-char truncation.
- A streamed edit near the limit came to about 80 KB even for English, so
  edits failed mid-stream.
- The standalone sender (cron without a running gateway) posted each
  16,000-char chunk as one event, and hit the same failure on non-Latin text.

The fix measures Matrix text in UTF-8 bytes, the unit of the cap:

- The adapter's message_len_fn now returns UTF-8 bytes, so send() and the
  stream consumer's split and progress-edit budgets count the same unit.
- A chunk gets a third of a 45,000-byte content budget, which leaves room for
  the event envelope and E2EE's 4/3 base64 inflation. That makes 15,000 the
  default and the ceiling for max_message_length, so English chunks stay
  about the same size.
- _build_text_message_content drops the HTML when escape-heavy text would
  push the content past the budget.
- An edit that would still be too large keeps its full m.new_content and
  shortens only the top-level fallback, which edit-aware clients never
  render.
- The standalone sender re-chunks on UTF-8 bytes and applies the same HTML
  guard.

(cherry picked from commit cab00c94175955a68ecd4d38c5748d63148ca6be)
2026-10-03 16:31:35 +05:30
kshitijk4poor
45871e100f refactor(matrix): let the auth callback default chat_type for invites/reactions
The hardcoded "group" duplicated the registered callback's own
chat_type default and implied a DM/group decision that was never made.
Passing chat_id only yields identical verdicts.
2026-10-02 02:59:59 +05:30
FroRaut
09c9ed2a61 fix(matrix): apply pairing revocations live
(cherry picked from commit 6c69d87fee43e5bcdcbc5f0e2d26fa9e1aa83ecc)
2026-10-02 02:59:59 +05:30
Teknium
9bcbe7b5df feat(i18n): pluggable, layered language packs across core, Desktop and TUI (#126296)
* feat(i18n): layered catalogs — plugin packs and user overlay over bundled locales

* feat(tui): i18n layer — en catalog, nanostore runtime, RPC pack loader, _keys.tui.json emitter

ui-tui/src/i18n/: en.ts (facade over topical siblings under en/), types.ts
(Translations + dotted TranslationKey derived from en), runtime.ts ($locale/
$catalog atoms, translateFrom active→en→key, pack merge with string→fn
wrapping for {0}/{1} placeholders), loader.ts (display.language →
i18n.catalog {lang, surface:'tui'}, English when the method is missing),
useT()/useLocale() hooks, t() for non-React code. useConfigSync feeds the
loader from the existing config.get full hydration. `npm run i18n:keys`
writes locales/_keys.tui.json (sorted flat key list) and runs before build.

* feat(plugins): provides_locales manifest field, ctx.register_locale/register_locale_dir, manifest-only language packs

* chore(tui): split en catalog siblings by lane (slash sibling)

* feat(plugins): validate language packs — parse, text-only, key-subset WARN against en / _keys exports

* feat(tui_gateway): i18n.languages / i18n.catalog RPC + regenerated contracts

* feat(config): display.language accepts any supported_languages() id, refuses unknown ids with the list

* docs(i18n): language packs user guide, pluggable display.language, plugin developer section, AGENTS notes

* feat(plugins): report language-pack layers in the mid-run activation summary

* feat(tui): wire status bar, composer placeholders, hotkey help and approval/clarify/confirm prompts through i18n

StatusRule maps compared state values (ready/running…/summoning) to catalog
text at render via displayStatus(); hotkeys()/placeholder() resolve lazily so
a pack that arrives after boot applies. Catalog grows to 81 keys.

* feat(desktop): pluggable app locales — registry, host.i18n.registerAppLocale, backend packs, keys emitter

- Locale widens to string (BundledLocale keeps the union); TRANSLATIONS stays
  the bundled record and every consumer resolves through the registry.
- src/i18n/registry.ts: registerAppLocale(id, {endonym, rtl, translations})
  layers partial packs (nested or flat dotted) over bundled/en via
  mergeTranslations; a string over a function-valued en entry becomes a
  positional {0}/{1} formatter; $appLocaleVersion bumps so translators
  re-render; per-source disposers + replaceAppLocaleSource for atomic swaps.
- Backend packs: i18n.languages + i18n.catalog {surface:'desktop'} feed the
  registry as source 'backend' (method-not-found is silent); re-synced on
  socket open, display.language change and profile switch. A saved pack-only
  language is promoted once its pack registers.
- SDK: host.i18n.registerAppLocale / languageOptions; ctx.i18n.registerAppLocale
  tracked for unload. Docs in the desktop plugin SDK guide + skill reference.
- Language switcher lists bundled ∪ registered ∪ backend, endonym-only; RTL
  from the registry (applyDocumentLocale takes rtl).
- npm run i18n:keys emits locales/_keys.desktop.json (wired into build).

* i18n(cli): route /topup + /subscription copy through t() (cli.billing.*, cli.subscription.*)

Module-level copy tables and modal choice tuples in cli_billing_mixin.py froze
English at import, before display.language was known. They are now key tables /
builder functions evaluated at call time; every user-facing line in the /usage
balance block, /subscription and the five /topup screens reads the catalog.
Choice VALUES stay English identifiers. Fragment-assembled status lines
(Plan: … → cancels · $x left · renews …) become full templates.

* i18n(gateway): exec-approval card contract + base/run/run_busy/run_inbound replies through t()

- base_exec_approval: EA_* English constants stay; add ea_header_text()/ea_reason_label_text()/
  ea_smart_deny_line_text()/ea_default_reason_text()/ea_action_labels()/approval_timed_out_notice()
  accessors; deadline + timed-out notice resolve via gateway.exec_approval.*
- BasePlatformAdapter._EA_HEADER/_EA_REASON_LABEL/_EA_SMART_DENY_LINE/_EA_ACTION_LABELS become
  properties (adapters still shadow them with markup class attrs)
- run.py: provider error replies table holds catalog keys; _CONTEXT_OVERFLOW_REPLY -> _context_overflow_reply()
- run_busy/run_inbound: typed approval + slash-confirm matchers accept English ∪ approval.inputs.* (t())
- locales/en.yaml: gateway.exec_approval/busy/errors/... namespaces

* i18n(cli): wire modal, loops, agent-setup mixins through t() (cli.* keys)

* i18n(platforms): route Slack, Matrix and Feishu user-facing text through t()

Exec-approval markup overrides (_EA_HEADER/_EA_REASON_LABEL/_EA_SMART_DENY_LINE/
_EA_ACTION_LABELS) become per-call properties over the shared
gateway.exec_approval.* contract keys, so Slack's 3000-char section budget
measures the resolved template. Slack _APPROVAL_DECISIONS/_CONFIRM_DECISIONS,
Feishu _APPROVAL_LABEL_MAP and Matrix _EA_LEGEND/_EA_TYPED_HINT turn into
key tables resolved at click time; the Matrix typed hints become whole
sentences per offered tier instead of spliced fragments. Slack button labels
are cut to 75 chars and select placeholders to 150 after translation; the
model-facing clarify fallback answer ('choice N') stays English while the
card copy localizes.

locales/en.yaml gains the gateway.exec_approval.* contract keys plus the
platform.shared.* / platform.slack.* / platform.matrix.* / platform.feishu.*
namespaces (and the keys for the other adapters wired in follow-up commits).

* i18n(gateway): run_turn / run_turn_runner / approval-settle copy through t()

- status hints, proxy errors, background task notices, progress heartbeats, session info lines
- tool progress chrome (tool_head/tool_pending/tool_preview/tool_verbose) shared by base.format_tool_event
- run_turn_runner:1406 Chinese clarify placeholder -> gateway.clarify.native_stream_placeholder (zh text kept in zh.yaml)
- _UNEXPECTED_SILENCE_REPLY/_CLARIFY_EXPIRED_NOTICE -> accessor functions

* i18n(platforms): route Google Chat and Teams user-facing text through t()

Google Chat clarify card, typing placeholder, orphan-card labels and the whole
/setup-files reply set (module constants become platform.google_chat.setup_files.*
keys resolved at reply time). The attachment-fallback notice that shipped
hardcoded in Spanish is keyed with an English en value; es.yaml carries the
original Spanish text for those four keys.

Teams approval card header/reason use the gateway.exec_approval.* contract,
_APPROVAL_LABELS becomes a key table resolved at click time, and the meeting
summary writer resolves its section headings/fallbacks per render.

* i18n(platforms): route LINE, WeCom, email, DingTalk, IRC and Home Assistant text through t()

LINE default copy constants become catalog keys resolved in __init__ (the
LINE_*_TEXT / extra.* operator overrides still win); the busy-ack bypass
matcher keys on the leading emoji marker only, so it keeps firing once the
gateway busy heads are localized. WeCom media size/format notices that shipped
hardcoded in Chinese are keyed with English en values and zh.yaml carries the
original Chinese text. DingTalk emotion bubbles resolve per send.

* i18n(cli): route /model switch output and -q status lines through t() (cli.model.*, cli.single_query.*)

Switch-summary labels shared with the gateway reuse gateway.model.* keys
(provider/context/max-output/capabilities/prompt-caching); CLI-only variants
(glyph or no-backtick forms) live under cli.model.*. The hand-padded /model usage
block becomes a (form, description-key) table padded at render time so the
command syntax stays fixed while descriptions translate. -q 'Error:' reuses
gateway.model.error_prefix.

* i18n(cli): route TUI panel/hint/placeholder copy through t() (cli.tui.*)

_APPROVAL_CHOICE_LABELS and _TUI_MODAL_HINTS become key tables resolved at
render time; vault/sudo panel bodies are one catalog value per panel split on
newline; inline plurals use <key>_one/<key>_other. Adds the cli.* namespace
(shared/tui/voice/render/subagents/dock) to locales/en.yaml.

* i18n(cli): voice/wake-word CLI copy through t() (cli.voice.*)

RuntimeError texts raised in _voice_start_recording are human copy (callers
print {e}) and are keyed; the Termux requirement-check match stays English.
Wake state ids stay internal, only their labels localize.

* i18n(cli): live-work dock, subagent monitor and render copy through t()

cli.subagents.* / cli.dock.* / cli.render.*; count fragments pluralize via
_one/_other keys, verdict table holds keys resolved at paint time so width
clipping measures the translated text.

* i18n(gateway): unauthorized/pairing, voice, topics, shutdown, startup, notifications, kanban pings through t()

* i18n(cli): move tips + composer placeholders into the catalog (tips.tNNN / tips.placeholder.pNN)

get_random_tip()/get_random_composer_placeholder() pick a key from the English catalog
(the parity baseline, probed once per process) and resolve it through t() for the active
language, so language packs translate tips like any other string. Also lands the cli.*
en.yaml namespace consumed by the CLI info/help/error-copy wiring in the next commit.

* i18n(cli): wire chat-turn + session mixins through t(); kanban log trimmer matches t() output

* test(cli): assert TUI/dock/voice copy via t(key); prove labels resolve at render time

Pinned-English assertions in the approval-UI, live-work dock and voice tests now
go through the catalog. New test swaps the catalog after import and checks the
approval panel + hint row follow it (the reason _APPROVAL_CHOICE_LABELS and
_TUI_MODAL_HINTS became key tables).

* i18n(cli): route CLI info/help/error copy through t() (cli.* namespace)

cli_info_mixin: /help consumes CommandDef.describe() (added to commands.py: slash.<name>.description
with fallback to .description), section titles/skill/quick-command headers, /tools, /toolsets,
/usage labels, /context, /whoami, /insights, /gateway status, tool-progress labels, bang-shell
denials, MCP config-watch + /reload-mcp confirm/reload lines, /reload-skills, and the session-store
warning all read the catalog at call time (module-level label tables became functions so the
active language is honoured after startup). cli.py: worktree cleanup, tirith warning, show_config
(labels re-padded at print time), quick/plugin/skill slash-command errors, ambiguous-command hint,
stdin error, gateway start, profile warning. cli_chat_error_copy / cli_unknown_command /
cli_output / cli_init_mixin: chat error panel copy, did-you-mean lines, n-more / yes-no prompt
(localized affirmative initial alongside 'y'), unknown-toolsets warning.

* i18n(w1a): wire agent display/explainers/approval + slash registry/help through t()

- hermes_cli/commands.py: CommandDef.describe() resolves slash.<name>.description
  at call time; category labels via slash.category.*; help/alias/usage suffixes
  via slash.shared.*; gateway_help_lines and commands_platforms/slash_exec use them.
- agent/display.py: display.verb.* resolved at call time via get_tool_verb();
  bridge/spinner/thinking-verb/cute-row/failure/preview/diff text via display.*.
- agent/turn_explainers.py: exit-reason / persistence-cause tables become call-time
  lookups (explainer.exit.*, explainer.persistence.*, explainer.file_mutation.*).
- agent/background_review.py, session_activity.py, context_breakdown.py,
  status_output.py: review summaries, iteration progress, context notices.
- tools/approval.py, approval_context.py: approval.summary.*, approval.noun.*,
  approval.window.* pluralized keys.
- gateway/slash_commands*.py: remaining raw strings (busy, whoami, platform,
  bundles, memory, skills, approvals, set_home, diff, update, debug, profile,
  heartbeat, refine, review, subgoal, loop, retry, compress codex path, save,
  sessions, model guard/errors, agents rows, topup, login). HISTORY_UNREADABLE
  keeps its English constant; callers use history_unreadable() ->
  gateway.shared.history_unreadable.
- locales/en.yaml: new approval/display/explainer/slash blocks + gateway leftovers.

* i18n(telegram): route adapter chat copy through t()

Approval card (header/reason/smart-deny as HTML-escaped properties), inline
button labels, callback toasts (cut at Telegram's 200-char cap), model/choice
pickers, clarify/update/slash-confirm prompts, gmail-triage labels and the
inbound-media failure notice now come from the catalog. _UNAUTHORIZED is a
lazy _unauthorized() so the import no longer binds a language. The command
menu carries a language+payload fingerprint (forum scopes re-register on
change) and BotCommand descriptions are cut at 256.

Adds gateway.exec_approval.* (WAVE2 contract), platform.telegram.*,
platform.discord.* and the slash.*.description keys the Discord table shares
with the CLI registry to locales/en.yaml.

* i18n(gateway/platforms): whatsapp_cloud, yuanbao, weixin, signal, api_server copy through t()

- whatsapp_cloud: clarify list/buttons, approve/deny + slash-confirm labels via platform.whatsapp.* (t()-then-truncate at 20/24/72 caps); _EA_HEADER becomes a property wrapping ea_header_text()
- yuanbao: SLOW_RESPONSE_MESSAGE -> slow_response_message() (platform.yuanbao.slow_response_notice; zh keeps the original text); cron-wrapper markers centralized as module constants for strip_cron_wrapper
- api_server: PROVIDER_AUTH_FAILED_LABEL/PROVIDER_RATE_LIMITED_LABEL stay English for run.py matchers; user_text() renders via t()
- signal/_format_wait, weixin voice caption, openai_routes transformed notice
- run_turn: second _UNEXPECTED_SILENCE_REPLY consumer -> accessor

* i18n(discord): route adapter chat copy through t()

Native slash-command table becomes _NATIVE_SLASH_COMMAND_SPECS holding catalog
keys; _native_slash_commands() resolves descriptions, parameter descriptions
and Choice names for the active language, each cut at Discord's 100-char cap,
and the app-command sync fingerprint now includes get_language() so a
display.language change re-syncs. Exec-approval card (gateway.exec_approval.*
contract), slash-confirm / clarify / update views, model+choice pickers,
thread creation, forum titles, voice acks, the response-truncation notice,
the unauthorized-slash security alert and the media upload-size notices all
read from platform.discord.*. Decorator-declared button labels are relabelled
in __init__ (80-char cap); embed titles cut at 256, select placeholders at
150, option label/description at 100. _UNAUTHORIZED is a lazy _unauthorized().

* i18n(cli): wire status-bar, stream, terminal mixins + terminal_input through t(); rename kwargs that shadow t(key)

* i18n: wire hermes_cli/cli_commands_mixin.py slash-command copy through t()

- 431 new leaves under cli.commands.<cmd>.* in locales/en.yaml; 12 rows reuse
  existing gateway.* keys (rollback, diff, resume, branch, btw, model, reasoning)
  via a _gt() helper so CLI and gateway replies stay identical.
- Module-level English tables (_BUSY_MODE_*, _REASONING_TOGGLES, _HATCH_PROGRESS,
  _DIFF_LABELS, _LOCAL_ENGINE_LINES) become call-time catalog lookups keyed by id.
- Verb tables (Enabling/Disabling, Paused/Resumed/Triggered, planned/done,
  Updating/Generating) are one full template per variant; plurals use
  <key>_one/<key>_other via _tn(); hand-padded column labels (/snapshot list)
  translate the value and re-pad at the call site.
- Multi-line usage blocks are single catalog values split with _lines().
- Model-facing system notes and DB-stored reasons stay English (EXCLUDED).

* tests: assert /handoff, /worktree, /login CLI copy via t(key) instead of pinned English

* test(i18n): pin Telegram/Discord adapter catalog wiring

Lazy unauthorized notice, exec-approval contract keys, HTML escaping before
Telegram <b> wrapping, 200-char toast / 256-char BotCommand caps, Discord
100-char app-command text and 80-char button caps, and language-bearing
command-menu fingerprints on both platforms.

* i18n: reconcile cli.shared on/off vs enabled/disabled after lane merge

* i18n: describe() in TUI-gateway slash listings; localize TUI exit resume hint

* i18n(tr): translate bundled catalog + tui pack

* i18n(ja): translate bundled catalog + tui pack

* i18n(ko): translate bundled catalog + tui pack

* i18n(zh): translate bundled catalog + tui pack

* i18n(fr): translate bundled catalog + tui pack

* i18n(af): translate bundled catalog + tui pack

* i18n(uk): translate bundled catalog + tui pack

* i18n(ar): translate bundled catalog + tui pack

* i18n(pt): translate bundled catalog + tui pack

* i18n(it): translate bundled catalog + tui pack

* i18n(es): translate bundled catalog + tui pack

* i18n(zh-hant): translate bundled catalog + tui pack

* i18n(ru): translate bundled catalog + tui pack

* i18n(hu): translate bundled catalog + tui pack

* i18n(hu): translate pre-existing English-valued leftovers (kanban wake, /context, /status, fast labels)

* i18n(de): translate bundled catalog + tui pack

* i18n(ga): translate bundled catalog + tui pack

* test(i18n): fixture matches _normalize_lang(lang, home) signature

* i18n(tui): scaffold userMessages/slashCmd en siblings

* i18n(tui): wire secure prompts + content tables

* feat(tui): i18n — wire billing, subscription, connection-setup and journey overlays

Adds en siblings billing.ts / subscription.ts / connection.ts (namespaces
billing, subscription, connection, journey) and routes every user-facing
literal in billingOverlay, subscriptionOverlay, connectionSetupOverlay and
journey through useT()/messages(). Module-level label tables became lazy
(scopeStillDeniedResult(), verbOf(T, action)); auto-reload rows dispatch on
stable ids instead of label text. Regenerates locales/_keys.tui.json.

* i18n(tui): wire slash ops/wake replies

* i18n(tui): wire pickers (modelPicker, activeSessionSwitcher, petPicker)

* i18n(tui): wire slash core/debug/setup replies

* i18n(tui): wire hubs (agents overlay/panel/controls, skills, plugins)

* i18n(tui): wire slash session/topup/subscription replies

* i18n(tui): wire chat bits (branding, thinking, messageLine, loaders, todo, queued, banner, entry)

* i18n(tui): register t3 siblings (pickers, hubs, secure, content, chatBits) and regenerate keys

* i18n(tui): wire userMessages copy through the userMessages namespace

* i18n(tui): lazy-copy test for userMessages, regenerate _keys.tui.json

* i18n(tui): wire session/gateway/lib text through the TUI catalog (lane t2)

Adds en siblings session.ts, gatewayMsg.ts, libText.ts (namespaces session,
gatewayMsg, libText) and routes user-facing literals in app/{useMainApp,
useSessionLifecycle,useInputHandlers,turnController,createServerRequestHandler,
setupHandoff,createGatewayEventHandler}.ts, gatewayClient displayed reasons,
lib/*, domain/*, hooks/* through t()/messages(). Status-bar state values that
code compares against, backend-matched strings, log lines, model-bound text,
and machine 'error:' prefixes stay literal. Regenerates locales/_keys.tui.json
(232 keys).

* i18n: serve bundled locales/<lang>.tui.yaml under overlay/packs; TUI pack parity test; regen _keys.tui.json (1250)

* i18n: translate pre-existing English stubs in bundled locales (424 leaves, 14 locales)

* tui: i18n-export-en script (English templates for pack translators)

* docs(i18n): bundled TUI packs are the bottom layer of the tui surface

* i18n(ru): translate TUI pack

* i18n(ar): translate TUI pack

* i18n(es): translate TUI pack

* i18n(pt): translate TUI pack

* i18n(ko): translate TUI pack

* i18n(de): translate TUI pack

* i18n(ja): translate TUI pack

* i18n(fr): translate TUI pack

* i18n(tr): translate TUI pack

* i18n(it): translate TUI pack

* i18n(zh): translate TUI pack

* i18n(zh-hant): translate TUI pack

* i18n(hu): translate TUI pack

* i18n(uk): translate TUI pack

1,169 missing keys translated; 81 pre-existing kept byte-identical. Parity OK missing=0 extra=0 placeholder_mismatch=0 empty=0.

Deliberately identical to en: chatBits.branding.mcpSummary ({0} MCP), chatBits.thinking.agentsHint ((/agents)), session.main.voiceStt (◉ STT), session.main.voiceTtsSuffix ( [tts]), slashCmd.core.help.tuiSection (TUI), slashCmd.core.history.hermesTag (Hermes #{0}), slashCmd.debug.heapdump.heapPath (heapdump: {0}), slashCmd.debug.mem.rss (rss), subscription.stepUp.title (Remote Spending — product feature name, as in core catalog), content.faces.* (glyph-only kaomoji).

* i18n(ga): translate TUI pack

* i18n(af): translate TUI pack

* plugin_guard: locale catalogs in language packs step down the agent-config family

A translated status line such as "Updating AGENTS.md" in locales/<lang>.yaml is UI text the loader
reads as a string leaf; it cannot edit a file. The bundled en.yaml itself tripped agent_config_mod
at critical, making any faithful language pack uninstallable. Injection shapes keep full severity.

* plugin_validate_locales: read key exports with utf-8-sig (Windows footgun lint)

* i18n(relay): route relay adapter prompt copy through t(); drop dead import-bound approval header

Adds platform.relay.* (5 keys) to en and all 16 bundled locales, reusing the sibling platform
translations for the confirm buttons and the Other option.

* ci: fix TUI import order, MDX table pipe, main's overflow-warning wording in all locales; fresh-install fixture carries the i18n kernel

- ui-tui/src/i18n/en.ts: perfectionist/sort-imports (slash before slashCmd)
- docs plugins/index.md: escape the | inside the provides_locales table cell (MDX parsed <id> as JSX)
- display.notice.uncompressed_context_overflow: adopt main's wording (names compression.enabled: false
  and /compact) in en + 16 locales; the guardrail test pins that phrase
- tests/scripts/test_fresh_source_install.py: the installer tail now resolves CLI text through
  agent.i18n, so the fixture tree carries the i18n kernel + en.yaml (not the agent runtime)

* docs(desktop-plugin-sdk): double-backtick the template-literal example (MDX evaluated ${n})

* test(e2e): display.language is validated against the live language set; exclude it from the arbitrary-string set property

* commands: keep the localized COMMANDS/COMMANDS_BY_CATEGORY module __getattr__ after the compat block removal

* build: never write locales/_keys.*.json from the desktop/TUI builds; regenerate the committed desktop key export

The desktop build regenerated locales/_keys.desktop.json in the checkout, so a
hermes update that rebuilt the app left the tree dirty (Desktop update E2E:
'M locales/_keys.desktop.json'). The key exports are committed artifacts pinned
to en.ts by apps/desktop/scripts/i18n-keys.test.mjs and ui-tui i18n:keys:check;
builds read them, never write them. Regenerated after main's new desktop strings.

* test: unbreak two main-red timing tests the PR merge-ref inherits

- test_local_runtime racing fake publishes the modern state record (legacy pid-only
  records are rejected since 65ff3ad353; main has been red on this test since)
- test_run_progress_topics ManyProgressLinesAgent waits for the first bubble instead of
  a fixed 0.35s, which a loaded CI runner does not always meet

* chore(i18n): regenerate desktop key catalog for main's new strings (model pricing, copy changelog)

* test(e2e): torture-chamber fd monitor confirms a deleted sidecar is still held before calling it a leak

SQLite's WAL last-close unlinks -shm before closing its descriptor (unixShmUnmap, then
unixShmPurge), so a healthy close shows a (deleted) -shm for microseconds; the 20ms poll
occasionally caught that window on the short-lived opener and failed the episode.

* chore(i18n): regenerate desktop key catalog for main's telemetry/consent strings

* chore(i18n): regenerate desktop key catalog after main sync

---------

Co-authored-by: Teknium <teknium@nousresearch.com>
2026-09-28 14:16:18 -07:00
Teknium
a5bd246865 Old pre-decomposition import paths are gone: plugin compat layer removed on schedule (#126164)
* refactor(plugins): remove the Sep 2026 decomposition compat layer on schedule

The PLUGIN-COMPAT layer (2776813df3 + d63e380324 + 0a5164cebe) kept pre-#102117 import paths
alive for external plugins until 2026-09-14. That window closed two weeks ago; since then the loader
has already been skipping plugins that use the old paths. This removes the layer itself:

- 328 appended `PLUGIN-COMPAT` blocks (lazy `__getattr__` pointer tables, re-exported third-party
  names, restored dead definitions) and the three re-export stub modules
  (gateway/startup_watchdog, hermes_cli/observability/relay_runtime, tools/environments/modal_utils)
- COMPAT_MANIFEST.md, compat_manifest.json, scripts/check_compat_pointers.py and its lint step
- the reporting surfaces: CLI banner notice, `hermes plugins compat`, the `hermes doctor` section,
  the post-update notice, the Desktop one-time dialog, the loader's pre-import skip and the
  `plugins.allow_deprecated_imports` escape hatch

An external plugin that still imports an old path now fails to load with its ImportError as the
reason in `hermes plugins list`, the same path as any broken plugin.

hermes_cli/plugin_compat.py stays as three inert stubs (compat_report, removal_in_effect,
summary_lines): an already-running pre-removal `hermes update` lazy-imports them after the checkout
swap (tests/compat/old_updater_surface.json).

In-tree fallout, both already dead: hermes_cli/setup.py::_check_espeak_ng (no callers; its
`shutil` came from a compat block) and gateway/config.py::SessionResetPolicy ("retained solely for
the scheduled plugin-compat window"). Two test_run_agent patches targeted the removed
`run_agent.handle_function_call` pointer; they now patch `model_tools.handle_function_call`, the
seam production reads, like every sibling test in that file.

* chore: retrigger CI (zero-job startup_failure phantom)

* test: drop resolution allowlist rows for the two deleted which() sites

hermes_cli/setup.py::_check_espeak_ng (dead) and tools/skillevaluator_scan.py::scanner_available
(a restored definition inside a PLUGIN-COMPAT block) no longer exist; the stale-row gate requires
their allowlist entries go with them.
2026-09-28 10:21:41 -07:00
kshitijk4poor
2f14d5e6e4 docs(matrix): fix the parked-voice cap limit count 2026-09-27 19:06:05 +05:30
kshitijk4poor
67066dba29 docs(matrix): note the parked-voice cap limit
Co-authored-by: miregal89 <142085869+miregal89@users.noreply.github.com>
2026-09-27 19:06:05 +05:30
kshitijk4poor
35a24efaf3 fix(matrix): claim the newest voice sent before the bare mention, not after it
The r3 fold made park refuse an older voice once a newer one from the same
sender had parked. With one /sync batch holding [v1 (slow gate), m1 bare
mention, v2 (fast)], v2 parked first, v1 was then refused, and m1 claimed
v2 -- a voice sent after the mention. v1 was lost and v2's own mention was
answered as empty text.

The bare mention now takes an arrival limit (ParkedVoices.mark) before it
settles, and claim pops the newest parked voice that began before that
limit, dropping older ones. park no longer refuses by arrival; parked
voices are kept per sender ordered by seq (bounded to 4). A claim made
while gates are still in flight records a floor, so a late older voice
(seq <= claimed) cannot park and outlive the claim; the floor clears when
the sender's in-flight list empties. One answer per bare mention, newest
before the mention wins, and the r3 orphan case still leaves nothing
parked.

Also: pending() ignores entries past CLAIM_WINDOW_SECONDS so an expired
voice no longer sends every later text through the mention regexes; the
m.thread root lookup is one _thread_root helper used by both the park
decision and its pre-check; voice_gate is annotated.

The kept test gains a [voice slow, mention, voice2 fast] + mention2 row:
red on a932dc031c (['$voice2', '$text2']) and on f1ea71de7c
(['$voice', '$text2']).

Co-authored-by: miregal89 <142085869+miregal89@users.noreply.github.com>
2026-09-27 19:06:05 +05:30