1596 Commits

Author SHA1 Message Date
calvinnwq
9c1a75e56f fix(gateway): Discord's config allow_from also governs guild channels
Under multiplex, authorization reads each profile's own secret scope, so the
DISCORD_ALLOWED_USERS the YAML bridge copies from discord.allow_from into os.environ is never
seen. The fallback to the adapter's extra then read group_allow_from for 'group' sources:
Telegram's group-only list, which Discord does not have. An allowlisted user's guild-channel
messages were dropped and their button clicks refused, while threads and DMs worked.

Discord declares allow_from_covers_groups, so its groups read allow_from. Adapters with a
separate group list (Telegram) are unchanged; a test pins that a Telegram DM-only allow_from
still does not admit the user in a group.
2026-10-26 13:04:38 +05:30
calvinnwq
2712a096db fix(discord): a button click in a thread gets the thread's authorization verdict
#133213 confirms a snapshot-admitted clicker with the gateway's live check, but labelled every
guild click 'group' and passed no thread id. Message intake labels the same channel 'thread',
so a user the gateway admits in a thread could be refused on its approval card ("This bot is
private..."), and a thread_id profile route never matched the click. Label the click like
intake does: a discord.Thread is 'thread' with its id as thread_id.
2026-10-26 13:04:38 +05:30
kshitijk4poor
ab3e4affd6 fix(config): meet the code-health ratchet and keep pm's runtime tree off the YAML stack
CI on the salvage was red on the code-health ratchet (over-cap facades grew; two blind excepts)
and on the pm observer fixture, whose isolated source tree carries pm/ + hermes_cli/ but no utils.

- config_backend imports become module-level in the facades (it imports only stdlib); gateway,
  auth and telegram take config_exists through the hermes_cli.config import they already have.
- Pure helpers move to topical siblings, offsetting the growth: _csv_or_list_to_set ->
  gateway/run_common.py, the dotted config-path pair -> hermes_cli/backup_restore.py, the
  voice/timezone/web-backend checks -> hermes_cli/config_value_checks.py, _load_config_dict ->
  hermes_cli/profile_memory_config.py (both callers are memory-provider code).
- _load_config_dict catches YAMLError/OSError/UnicodeError instead of Exception.
- _load_config_cache_hit probes readability with config_backend.probe_config_readable (a 1-byte
  read through the backend's open) instead of a full parse plus a blind except.
- pm/plugins_state.read_home_selection checks config_exists before importing the YAML stack, so
  a home with no config never needs utils.
- developer-guide/config-backend.md describes this build (file backend only).

Same approach as @benbarclay's 74421be709 in #122509, which does not cherry-pick onto current main.
2026-10-25 18:54:09 -07:00
Ben Barclay
871900df63 feat(config): route every user config.yaml read and write through a ConfigBackend seam
Add hermes_cli/config_backend.py (config-config design §4.1, D10/D11): a
ConfigBackend protocol, the FileBackend (today's behaviour), selection by
HERMES_CONFIG_BACKEND only (default file; 'remote' and unknown values fail
closed with ConfigBackendUnavailable), and path-level helpers
(read_config_doc, read_config_doc_readonly, config_version, config_exists,
write_config_key, write_config_document, supports_file_tooling).

Migrate every direct reader/stat/exists/bypass writer of a user config.yaml
to the helpers (config.py loaders + caches, config_effective, env_loader,
gateway, TUI, CLI watchers, cron, tools, profiles, logging, time). File
tooling (config edit, backups, xAI migration rewrite, raw dashboard editor)
checks supports_file_tooling() first; migrations skip write-back without it.

Add scripts/check_config_yaml_readers.py (CI lint next to the writers gate)
that rejects a direct read of a config path outside the backend.
2026-10-25 18:54:09 -07:00
Teknium
68e4c2b31a fix(startup): build version-bearing User-Agents when a request is built, not at import
Every CLI start imports all provider plugins (hermes_cli.config lists their env vars), and
fireworks/gmi/xai/router/kimi/opencode plus auth_constants, models, model_catalog,
auxiliary_client, gemini_native_adapter, web_server_messaging, slack, yuanbao and perplexity
built a `<product>/<release>` string at module level. In a source checkout the release comes
from the 7-call git provenance walk (`git tag --merged HEAD` alone is ~0.35 s in a large
clone), so `hermes sessions list` paid it for headers it never sends.

Provider profiles take a LazyHeaders mapping (resolved on first read by the client builders,
which already copy with dict()); core modules call version_info.hermes_user_agent() where the
request is built. Header values are unchanged.
2026-10-25 17:50:59 -07:00
Maciej Lisiewski
05b83f632f
Merge pull request #143719 from NousResearch/bulk-update-js
chore(deps): bump npm dependencies to latest minor/patch releases
2026-10-25 12:54:29 +01:00
Teknium
43cc33ec6f fix: address review — Feishu plain .ogg stays a file, Ogg duration walks pages
- Feishu routed .ogg/.opus to an "audio" (voice) message by extension even
  for send_document / is_voice=False; Opus is now an audio message only when
  the caller requested one.
- Discord _ogg_opus_duration walks page headers by segment table instead of
  rfind("OggS"), which could match packet data and misread the granule.
- Tests: successful transcode path (bytes, duration, temp removed), OggS run
  inside packet data, Feishu plain .ogg/.opus and the voice-intent control.
2026-10-23 17:40:07 -07:00
Teknium
183cd6cc35 fix(gateway): keep plain audio MEDIA out of WhatsApp/BlueBubbles voice notes
Same class as the Discord and Feishu fixes: these adapters' send_voice
ignored is_voice, so a plain audio MEDIA file (music, a sound effect)
became a voice note. The WhatsApp bridge always sends "audio" as ptt
(transcoded to Opus), WhatsApp Cloud converted every local mp3 into an
Opus voice bubble, and BlueBubbles flagged every file isAudioMessage.

is_voice=False now goes as a named document (WhatsApp bridge), as the
original audio/mpeg (WhatsApp Cloud), or as a plain attachment
(BlueBubbles). Voice intent and the no-flag auto-TTS path are unchanged.
2026-10-23 17:40:07 -07:00
Teknium
e2fe88cf7a fix(discord): send plain audio as an attachment, voice messages only as Ogg/Opus
The media dispatch routes every audio MEDIA file to send_voice with is_voice,
but the Discord adapter swallowed the flag and uploaded every file as a native
voice message named voice-message.ogg (audio/ogg), whatever the bytes were.
A sound-effect mp3 or a wav arrived as a voice note that does not play, with a
duration guessed from the byte size (mutagen is not a dependency).

is_voice=False now goes out as a regular attachment under its real name.
Voice intent ([[audio_as_voice]], auto-TTS) sends real Ogg/Opus: non-Opus
input is transcoded with ffmpeg, without ffmpeg the original goes out as an
attachment, and duration_secs is read from the Ogg granule position.
2026-10-23 17:40:07 -07:00
Teknium
95505c60e9 docs(tools): lead every tool description with its key capability
The deferred tool_search catalog shows each tool's first sentence clipped to
60 chars, so lines like 'image_generate: Generate high-quality images from
text prompts, or edit /…' hid that it edits with reference images on the
user's configured model. An agent skipped it and called FAL directly with a
hardcoded model.

- catalog line cap 60 -> 80 (CATALOG_SUMMARY_MAX_CHARS); every built-in
  tool's first sentence now fits and leads with what it does
- image_generate/video_generate say they use the configured model;
  image_generate says to use it rather than direct API calls/scripts
- web_search/web_extract/browser_exec name when to use each other
- drop a duplicated cronjob sentence and filler in skill_view/video_generate
- regenerate tests/fixtures/prompt_surface
2026-10-23 16:04:50 -07:00
Maciej Lisiewski
48217bc858 chore(deps): bump spectrum-ts to 12.10.1 (plugins/platforms/photon/sidecar)
spectrum-ts: 12.7.0 -> 12.10.1 (pins edited: 1; also: {'@opentelemetry/resources': "['2.10.0']->['2.12.0']", '@opentelemetry/sdk-trace': "['2.10.0']->['2.12.0']", '@opentelemetry/sdk-trace-base': "['2.10.0']->['2.12.0']", '@spectrum-ts/core': "['12.7.0']->['12.10.1']", '@spectrum-ts/imessage': "['12.7.0']->['12.10.1']", '@spectrum-ts/slack': "['12.7.0']->['12.10.1']", '@spectrum-ts/telegram': "['12.7.0']->['12.10.1']", '@spectrum-ts/terminal': "['12.7.0']->['12.10.1']", '@spectrum-ts/whatsapp-business': "['12.7.0']->['12.10.1']", 'es-module-lexer': "['2.3.2']->['3.0.3']", 'import-in-the-middle': "['3.3.3']->['3.5.2']"})
2026-10-23 22:00:12 +02:00
Maciej Lisiewski
9b53c4d2fb chore(deps): bump protobufjs to 8.8.0 (plugins/platforms/photon/sidecar)
protobufjs: 8.7.1 -> 8.8.0 (pins edited: 1; also: {})
2026-10-23 22:00:12 +02:00
Maciej Lisiewski
069f15795e chore(deps): bump @opentelemetry/otlp-transformer to 0.223.0 (plugins/platforms/photon/sidecar)
@opentelemetry/otlp-transformer: 0.218.0 -> 0.223.0 (pins edited: 1; also: {'@opentelemetry/resources': "['2.7.1']->['2.12.0']"})
2026-10-23 22:00:12 +02:00
Maciej Lisiewski
c88d3a492c chore(deps): bump @opentelemetry/otlp-exporter-base to 0.223.0 (plugins/platforms/photon/sidecar)
@opentelemetry/otlp-exporter-base: 0.218.0 -> 0.223.0 (pins edited: 1; also: {})
2026-10-23 22:00:12 +02:00
Maciej Lisiewski
85938b8b63 chore(deps): bump @opentelemetry/exporter-trace-otlp-http to 0.223.0 (plugins/platforms/photon/sidecar)
@opentelemetry/exporter-trace-otlp-http: 0.218.0 -> 0.223.0 (pins edited: 1; also: {'@opentelemetry/resources': "['2.7.1']->['2.12.0']"})
2026-10-23 22:00:12 +02:00
Maciej Lisiewski
bf02f6133d chore(deps): bump @opentelemetry/exporter-logs-otlp-http to 0.223.0 (plugins/platforms/photon/sidecar)
@opentelemetry/exporter-logs-otlp-http: 0.218.0 -> 0.223.0 (pins edited: 1; also: {})
2026-10-23 22:00:12 +02:00
Maciej Lisiewski
a42905d0e7 chore(deps): bump @opentelemetry/core to 2.12.0 (plugins/platforms/photon/sidecar)
@opentelemetry/core: 2.10.0 -> 2.12.0 (pins edited: 1; also: {})
2026-10-23 22:00:12 +02:00
Maciej Lisiewski
d0b2d6bb71 chore(deps): bump indirect npm dependencies within existing ranges (photon)
- @bufbuild/protobuf: 2.14.0 -> 2.16.0
- @opentelemetry/context-async-hooks: 2.10.0 -> 2.12.0
- @opentelemetry/sdk-metrics: 2.10.0 -> 2.12.0
- @photon-ai/advanced-imessage: 2.1.0 -> 2.2.0
- @photon-ai/otel: 3.7.0 -> 3.8.1
- cjs-module-lexer: 2.2.1 -> 2.3.0
- lru-cache: 11.5.2 -> 11.5.3
- marked: 18.0.11 -> 18.1.0
- zod: 4.5.4 -> 4.6.5
2026-10-23 22:00:12 +02:00
Maciej Lisiewski
154748800b chore(deps): bump google-auth-oauthlib to 1.5.0
google-auth-oauthlib: 1.3.1 -> 1.5.0 (pins edited: 1; also: {})
2026-10-23 09:23:34 +02:00
Maciej Lisiewski
77da0e47a1 chore(deps): bump google-auth-httplib2 to 0.4.4
google-auth-httplib2: 0.3.1 -> 0.4.4 (pins edited: 1; also: {})
2026-10-23 09:23:33 +02:00
Maciej Lisiewski
9200e9202b chore(deps): bump google-auth to 2.62.0
google-auth: 2.55.1 -> 2.62.0 (pins edited: 2; also: {})
2026-10-23 09:23:32 +02:00
Maciej Lisiewski
5bc07faa3c chore(deps): bump google-api-python-client to 2.201.0
google-api-python-client: 2.194.0 -> 2.201.0 (pins edited: 1; also: {})
2026-10-23 09:23:31 +02:00
rob-maron
83c5737be2 merge main in 2026-10-20 21:19:31 -04:00
rob-maron
15307dece7 Usage-window plan support 2026-10-20 21:04:30 -04:00
Teknium
d2b3446b1e fix(a2a): one IPv6 server class; dual-stack peers keep their IPv4 identity
Folds the two IPv6 server classes into one: every IPv6 host gets
AF_INET6, and V6ONLY=0 makes the :: wildcard answer IPv4 too.

A dual-stack socket reports an IPv4 peer as ::ffff:a.b.c.d, so the
shared-token / no-token identity became ip:::ffff:127.0.0.1 and an
A2A_TRUSTED_PEERS entry written as ip:127.0.0.1 no longer matched
(403 "peer not trusted"). _client_ip unmaps it. The test drives a
token-gated :: bind over both stacks plus an IPv4 tasks/list call
behind an IPv4 allow-list.
2026-10-20 04:05:08 -07:00
John Paul Soliva
1f0981bd8e fix(a2a): accept the bracketed [::1] spelling of an IPv6 A2A_HOST
A2A_HOST=[::1] was not recognised as loopback (no-token runs fell back
to 127.0.0.1 with a misleading warning), failed to bind with a token, and
advertised http://[[::1]]:port/. Strip URL brackets when capturing the
host, and pin the Host-less advertised URL in the IPv6 test.
2026-10-20 04:05:08 -07:00
John Paul Soliva
9f908ca3dd fix(a2a): bind and advertise IPv6 hosts such as ::1
A2A_HOST=::1 is an accepted loopback bind, but ThreadingHTTPServer is
AF_INET only, so the listener failed with bind_failed. An IPv6 host now
uses the AF_INET6 server, and the Agent Card URL brackets the literal.
2026-10-20 04:05:08 -07:00
chatchap-2nd-of-chartup
36a6c85c46 fix(a2a): dual-stack (AF_INET6, V6ONLY=0) bind when A2A_HOST=::
What this fixes: A2A_HOST=:: is the conventional IPv6 wildcard (one socket,
both stacks). stdlib ThreadingHTTPServer is AF_INET-pinned and cannot bind
:: at all (gaierror 11001 on Windows) - A2A stays down. The AF_INET pin is
the root cause.

Change: when host == ::, swap in an AF_INET6 + IPV6_V6ONLY=0 subclass; one
dual-stack socket, matching the aiohttp DM bind on 8642. Other hosts keep
the standard family. Failed binds stay loud via the existing bind_failed
fatal/retry path.

Test: regression test - with A2A_HOST=::, connect a live adapter, assert
dual-stack class + AF_INET6 + V6ONLY=0, GET the agent card over [::1] on
the bound port. Placed in TestBindSafety (default lane) because the repo
addopts -m "not integration and not live" deselect the integration class;
self-skips on hosts without IPv6. Verified against the upstream adapter
before the change: the same live bind fails (getaddrinfo EAFNOSUPPORT on
Linux; the same failure class as gaierror 11001 on Windows).

Related work: complements #126285 (IPv6 literal bind + bracketed agent
card URL) by making the A2A socket dual-stack (V6ONLY=0) so :: answers on
both stacks.

Base: 865ba906 (main).
2026-10-20 04:05:08 -07:00
Teknium
84b480d38e fix(telegram): two edits in one second are two inputs
The edit revision was edit_date, whole seconds, so a second edit of the
same message within that second reused the first edit's request id with
different text and still replied admission_conflict (#140845).

Key the edit on its update_id, which Telegram assigns once per edit and
keeps on redelivery; with no update id, edit_date plus a digest of the
edited text. A replayed edit still admits once.
2026-10-20 03:17:18 -07:00
Teknium
b9d49d3d77 fix(buzz): a deferred cursor write never names an uncommitted event
The cursor write deferred behind a held busy burst re-read the live
channel state when it fired. By then the serial reader had already marked
the next event seen (and advanced last_ts) before its dispatch committed,
so a restart restored a cursor past an event with no admission row.

The write now carries the cursor snapshotted when it was scheduled, and a
write older than one already landed is skipped so the file never moves
back. The invariant test holds e2 inside _resolve_user_name while e1's
burst commits and asserts every saved cursor names only admitted events.
2026-10-20 03:17:18 -07:00
Teknium
1338acd6ff fix(buzz): a held busy burst is durable before the receive cursor passes it (#141378)
de526521ab left Buzz out of serial_receive_loop on purpose: Buzz saves its
channel cursor after _handle_events returns, and a serial reader returns while
the busy input is only held for the burst window, so the flag alone (#141389)
lets the saved cursor pass an input with no admission row. A restart inside
the hold window would then never replay it.

Keep the flag, and save the cursor only once every input the reader returned
on is committed (session_ingress_burst.when_returned_inputs_durable: held
bursts, burst commits and busy inputs released before their commit). Inline
when nothing is pending, so the idle path is unchanged; otherwise a tracked
task, so the reader still reads on.

The cursor-file helpers move to plugins/platforms/buzz/buzz_cursors.py
(BuzzCursorMixin) to keep adapter.py under the file-size ratchet.
2026-10-20 03:17:18 -07:00
Teknium
6483c39f84 fix(gateway): editing a sent message no longer replies admission_conflict (#140845)
Native admission keyed every message by its platform message_id. A Telegram
edit re-sends that same id with new text, so the ledger saw a changed replay
of the original send and refused it with admission_conflict, which reached the
user as "Sorry, I encountered an error (RuntimeStoreError)".

Edits stay turns, as they were before the unified runtime (pinned by
test_replay_is_admitted_once_before_dispatch[text-edit]). The adapter now stamps
MessageEvent.edit_revision from the edit's edit_date, it rides in the native
envelope, and _admit_native keys the edit as <message_id>:edit:<revision>. A
redelivered edit is still an exact replay of that edit; a second edit is its
own input.
2026-10-20 03:17:18 -07:00
Nolan
2a8934ba17 fix(buzz): declare the serial receive loop for burst merging
Buzz was left out of the #140973 sweep that marked the other
await-per-event readers: both the WebSocket listener and the poll
sweep await _handle_events before reading the next batch, so a busy
split text or a photo burst commits each message as its own follow-up
turn and holds the account's single reader. Declare
serial_receive_loop and add the split-text regression beside the
Signal/IRC ones (#141378).
2026-10-20 03:17:18 -07:00
Teknium
ae596f49a0 fix(telegram): an edit of an older lobby message keeps its room (#136567)
Message.date of an edit is the ORIGINAL send time, so an edit of a root-DM
message sent before the topic creation passed the send-time window (negative
gap) and was adopted into the new topic, consuming the record the real opener
needed. A message dated before the creation is now left alone and the record
stays for the opener.

Found by Greptile on #141751.

Live (real gateway + Telegram stand-in): edit an old lobby message right after
creating a topic, then send the opener. At 5e0eb93 the edit went to the new
topic; now the edit stays in the previous topic and the opener lands in the
new one. Slow-photo, split, interleaved-DM and late-lobby cases unchanged.
2026-10-19 21:47:53 -07:00
Teknium
406580697a fix(telegram): time the new-topic follow on send time, not handler time (#136567)
The 5 s follow window was read from time.monotonic() when each handler ran.
PerChatUpdateProcessor holds a chat's next update until the previous handler
returns, so a thread-less photo whose download (or STT, or a document's
caching) outlasted the window pushed the text sent right after it out of the
new topic, into the previous topic or the root DM.

The window now compares Telegram's Message.date stamps (set when the user
sent the message, untouched by queueing). A creation without a date is not
recorded. The local clock only bounds memory (records older than 600 s are
pruned; the oldest is evicted at the 256 cap).

Found by Greptile on #141751; root-caused and fixed in a proposed diff by
@PRELVAS94, adapted here.

Live (real gateway + Telegram stand-in, photo download held 7 s, text sent
right after): before, the text went to the old topic; after, both land in the
new topic. Split opener, interleaved DM and late-lobby cases unchanged.

Co-authored-by: PRELVAS94 <86016656+PRELVAS94@users.noreply.github.com>
2026-10-19 21:47:53 -07:00
Teknium
bda200183d fix(telegram): follow a new DM topic by time, not message-id adjacency (#136567)
The adoption of a client-created topic's thread-less opener required
message_id == creation + 1. Private-chat message ids come from ONE sequence
shared by every private chat of the bot account (bot replies included,
core.telegram.org/api/updates "Common message ID sequence"), so any message
in another DM, or a bot reply, between the creation and the opener broke
adjacency and the opener misrouted to the previous topic again. One-shot
adoption also split a long opener the client sends as several messages:
chunk 1 went to the new topic, chunk 2 back to the old one.

Now a thread-less message from the creator adopts the new topic while it
arrives within 5 s of the creation or of the previous adopted message; a
stamped message or a longer gap ends the follow. Per-chat FIFO update
processing (PerChatUpdateProcessor) means nothing from this chat lands in
between, so adjacency bought no safety.

Also drops the duplicated identity helpers the mixin redefined from the
adapter and restores the unrelated _cache_dm_topic_from_message move.

Live (real gateway + Telegram stand-in, DM topic mode, production batching):
main misroutes all four cases; the pairing as proposed misroutes the
interleaved-DM and split-opener cases; this lands every case in the new topic,
and a lobby message 7 s later still recovers to the bound topic.
2026-10-19 21:47:53 -07:00
sharpnotebot
7cfafba18e fix(telegram): 建立 topic 時不再快取名稱,恢復自動改名 (Refs #136567)
The forum_topic_created handler cached the user-chosen topic name (e.g.
"New Chat") in _dm_topics. _get_dm_topic_info treats any _dm_topics hit
as an operator-declared topic, so _rename_telegram_topic_for_session_title
silently skipped every dynamically created topic and session-title
auto-rename stopped working.

Keep only the pending-creation record (opener adoption is unchanged) and
leave _dm_topics to operator config. Topics declared in extra.dm_topics
stay protected from auto-rename.

Tests: real PTB creation -> thread-less opener -> runner rename path
renames once; a config-fixed topic is not renamed; a creation stays
pending without populating _dm_topics. The opener test that pinned the
cache side effect now asserts its absence.
2026-10-19 21:47:53 -07:00
sharpnotebot
37ec498ea7 fix(telegram): record topic creations only from authorized humans and consume them once (Refs #136567)
Builds on the salvaged #137348 commits above. The pairing store accepted
any private-chat forum_topic_created service message and kept records
whose opener arrived already threaded until the TTL ran out.

- Record a creation (and cache its topic name) only when the service
  Message carries message_thread_id, has a non-bot sender, and passes
  the existing intake prefilter _is_user_authorized_from_message, so a
  rejected user cannot populate adapter state.
- Cap the store at _NEW_TOPIC_OPENER_MAX_PENDING (256), evicting the
  oldest stamp after the TTL prune.
- The first later message from the same chat and sender consumes the
  record whether it is adopted, already threaded, non-adjacent or
  expired; adoption still requires a thread-less, adjacent, fresh
  opener. Other chats and senders neither adopt nor consume it.

Tests: adds real PTB Update.de_json -> connect() -> process_update
cases for unauthorized, bot, missing thread/sender, healthy consume,
non-adjacent consume, other chat/sender, expiry and the cap. Phase 1
of test_pending_created_topics_stays_bounded now expects the five
healthy records to be consumed (it previously pinned the leak), and an
unused unpacked `delivered` is renamed to satisfy RUF059.

Adapted from a local field-tested patch; the PTB service+opener
pairing design is from #137348 (PRELVAS94), and reading the topic id
from Message.message_thread_id rather than ForumTopicCreated follows
e756b3b in #136581 (liuhao1024).
2026-10-19 21:47:53 -07:00
Pedro Relvas
328b64a9a7 fix(telegram): bound the pending-created-topics cache (Refs #136567)
The _pending_created_topics map grows unboundedly: records whose opener
arrives already threaded (the healthy path) return early before any pop,
and records that simply never get claimed are never revisited. Prune
expired records at record time inside _pending_created_topics_store.

Adds a regression test that demonstrates the leak (10 distinct keys all
survive), the prune (negative TTL evicts all), and the routing contract
(fresh record still claims its opener).

Also cleans stale update receipts in the test's connected() fixture so
the admission controller doesn't drop updates across test runs.
2026-10-19 21:47:53 -07:00
PRELVAS94
3687ef0bf4 fix(telegram): route a new DM topic's thread-less opening message into that topic
Telegram normally stamps a new private-chat topic's opening message with the new
message_thread_id, but it sometimes delivers that opener with no thread id at all.
A forum_topic_created service message carries no text, so no core handler matched it and
the new topic id was never learned: the opener arrived lobby-shaped and gateway topic
recovery (gateway/run_topics.py) pinned it to the most recently bound topic, leaving the
new topic with no session, binding or auto-rename.

- telegram_topic_routing.py: narrow handler for filters.StatusUpdate.FORUM_TOPIC_CREATED
  records (chat_id, sender_id) -> (new thread id, creation message id, stamp) for private
  chats and caches the topic name; the opener adopts that thread id in _build_message_event
  (one-shot, only for the message immediately after the creation, inside a 120s window).
- adapter.py: wire the handler + mixin in, and drop the now-unreachable
  forum_topic_created branch in _resolve_topic_binding.
- tests/plugins/test_telegram_forum_topic_created_opener.py: real PTB dispatch coverage.

Fixes #136567
2026-10-19 21:47:53 -07:00
Teknium
fbd482d5c5 fix(telegram): a newer chunk no longer cancels a committed batch flush
_enqueue_text_event cancels the key's previous flush task on every new chunk,
even after that task has popped its batch and is dispatching it. With
dm_topic_auto_transfer on, a second root-DM message arriving while
createForumTopic for the first was in flight cancelled the dispatch: Telegram
had already created the topic, Hermes lost its ID, and the hold-queue replay of
the still-root message created a second topic, leaving the first empty.

_flush_buffered now leaves the per-key task slot once it pops the batch, so a
newer chunk re-arms a fresh flush instead of cancelling it. Committed flushes
are tracked per (family, key): a later flush for the same key waits for the
earlier one to settle, keeping order. Disconnect teardown still cancels them
(and the cancel path still holds the popped event).

Test: a fake Bot pauses createForumTopic while a second root message arrives;
no event is held, the first keeps topic 777, and every created topic gets its
message.
2026-10-19 01:15:18 -07:00
Teknium
407303dfdc fix(telegram): move dm_topic_auto_transfer to adapter ingress so the reply lands in the new topic
Builds on the salvaged #139188 (@KoNit-K). The salvaged commit ran the transfer in the runner's
_hmwa_resolve_session, which is too late through the real adapter. By then the adapter has keyed
the session on the root-DM source, and _handle_message has already answered with the lobby
reminder. So with the key on, no topic was ever created, and every root-DM message got the
"main chat is reserved" notice.

- The transfer now runs in TelegramAdapter.handle_message before session keying
  (telegram_topic_transfer.py), through a runner hook (_transfer_telegram_root_dm) wired in
  _wire_adapter_handlers next to topic recovery.
- If topic creation fails, the hook returns the lobby-recovery topic (fallback). Commands,
  internal wakes, routed events and unauthorized senders are never moved.
- The first reply in the new topic carries no reply anchor (the root message lives outside the
  topic), via reply_anchor_override="". This replaces the base.py metadata flag.
- With the key unset (default), behaviour is unchanged and the v0.22 lobby recovery stays
  (#136567).
- The top-level `telegram: dm_topic_auto_transfer` YAML key is bridged into extra, like
  disable_topic_auto_rename.
- Documented in the Telegram multi-session docs.

Refs #139136
Refs #134889 (MSG-15)
Refs #141321
2026-10-18 19:27:36 -07: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
kshitijk4poor
793ec8d77d docs(weixin): the connector docstring names both no-bundle cases 2026-10-18 06:04:35 +05:30
Pedro Relvas
e681d6fae5 fix(ssl): route the auth and platform certifi pins through the shared re-derivation
The Nous credential exchange builds its TLS context in
hermes_cli/auth_device_flow._default_verify, which on macOS pinned
certifi.where() directly. That made it a second trust stand outside
agent/ssl_verify, so an install-environment rotation could hand it the
cacert.pem of a deleted environment and every credential refresh failed
until the gateway restarted (#137255, seen in the wild on a launchd
gateway).

_default_verify now asks agent.ssl_verify for the bundle, which
re-derives a path the rotation invalidated. The same one-line move
covers the other three direct certifi.where() consumers — the Weixin
and WeCom aiohttp connectors and the Actual relay's ssl_ca_cert — so
no pin in the tree bypasses the re-derivation.
2026-10-18 06:04:35 +05:30
Teknium
952666501f feat(setup): public names for the gateway setup-wizard helpers
Platform setup_fn code (bundled QQ Bot, Weixin, Signal and the community QQ
plugin) imported _print_setup_header, _confirm_reconfigure,
_offer_home_channel, _save_env_values and _prompt_csv from
hermes_cli.gateway_setup_wizard. They are now print_setup_header,
confirm_reconfigure, offer_home_channel, save_env_values and prompt_csv; every
internal caller moves (no aliases). Bundled QQ setup drops the private _gw()
facade for hermes_cli.setup / cli_output / config primitives.
2026-10-17 14:51:46 -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
53de7ff326 feat(clarify): public get_pending() query replaces _lock/_entries reads
Adapters rendering native clarify buttons (core Discord/Telegram, base
send_clarify, the community QQ plugin) read tools.clarify_gateway._entries
under _lock to learn whether a request is still pending and its choices.
get_pending(clarify_id) returns the entry while it awaits an answer, else
None; internal readers 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
unsupportedpastels
5ec9bb6b10 fix(google-chat): answer a parked-profile HTTP event retryably
Google Chat's HTTP callback awaits the dispatch before it answers, so
unlike Pub/Sub (acked on hand-off) the delivery is not acknowledged yet.
The parked-profile refusal still answered HTTP 200 with nothing
admitted, and the message id stayed in the adapter's dedup cache, so
Google had no reason to retry and a manual resend would be the only way
back.

dispatch_http_event now runs the dispatch inside
parked_route_refusal.retryable_ingress(). Inside that scope,
drop_rejected_route records the refusal instead of sending an in-chat
notice. The adapter then releases what ingress recorded for the
unadmitted delivery (its dedup claim and the DM thread count) and raises
the named ParkedRouteRefused, which the platform-event callback answers
as 503 profile_parked with Retry-After. _dispatch_message swallows
exceptions, so the refusal is carried by the scope, not raised from the
shared helper. Pub/Sub keeps the in-chat notice.

A redelivery of the same event after the profile is served again is
admitted exactly once, and reads its DM thread as the first delivery.

Refs #134889 (GW-12)
Refs #140018
2026-10-17 13:16:34 -04:00