Commit Graph

3815 Commits

Author SHA1 Message Date
Teknium
5c4db986bb fix(video_gen): downscale inlined images only for providers with a body cap
Review finding on this PR: the tool layer ran every video backend's sources
through the FAL helper, which also downscales to the managed FAL gateway's
3.5 MB budget. xAI, OpenRouter and DeepInfra have no such cap, so a large
data: URL the caller already supplied (or a big local file) was silently
re-encoded smaller (2048x2048 PNG -> 1536x1536 JPEG) for them.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Refs #108353

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

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

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

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

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

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

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

Fixes #127901

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

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

Refs #146848

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

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

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

Signed-off-by: crustdev <dev@crusts.dev>
2026-11-14 16:08:54 +01:00
Maciej Lisiewski
61be8bf593 fix(gemini): keep length when an Interactions call ends truncated
The Interactions transport (default for Gemini 3+/-latest on AI Studio) let
any function_call step override an incomplete/budget_exceeded status, and the
long-decode hop ceiling reported tool_calls when a call had streamed, so a
cut-off call executed. Report tool_calls only when the status maps to stop;
the hop ceiling always reports length. Also pin the native stream case where
finishReason arrives in a later event than the functionCall.

Fixes #144949
2026-11-14 15:11:41 +01:00
Teknium
2cb67feb64 fix(telegram): shared DM threads keep per-thread batches and the routed profile's topic state
Review follow-ups on dm_threads: shared (Greptile on #155680):
- text batches stay per DM thread (the session key drops the thread, a merged
  batch kept only the first event's source, so a second thread got no answer)
- /topic state is read from the source's pinned runtime profile store, not the
  active scope (a primary bot routing to another profile keys before scoping)
- a hot reload of dm_topics updates config.extra too, so a topic added while
  running stays its own session
- the shared copy uses session_identity.replace_source (keeps provenance)
- a rebuilt source with no live adapter ref (/loop, restored routes) reads the
  answering bot's settings through the runner's delivery resolver
2026-11-14 06:08:13 -08:00
Teknium
cd582ed706 fix(telegram): index every final delivery for quote-replies, code verbatim, loud write failures
Review findings on #155645:
- 'Some finals still lose quotes': a final edit that lands after a short flood wait now runs the
  same bookkeeping, and an oversized final indexes its edited first chunk and every continuation.
- 'Saved quotes change code': quotable_text() strips MarkdownV2 only outside code spans/fences.
- 'Write failures stay silent': rich_sent_store.record/record_async return False on a failed write
  (still never raising) and the adapter logs on that result.
- 'The oversized adapter keeps growing': _edit_overflow_split moves to telegram_overflow_edit.py;
  adapter.py is now below its origin/main line count.
2026-11-14 05:02:08 -08:00
Teknium
f17cecbdf3 refactor(telegram): move legacy-edit bookkeeping out of edit_message
Indexing the finalized text pushed edit_message's complexity over its
ratcheted cap; the saturated-preview dedup and the final's index write now
sit in one helper. Also maps @AlexGogin's commit email for attribution.
2026-11-14 05:02:08 -08:00
Teknium
2bda0d848b test(telegram): prove quote-replies keep their text through a real gateway
Trim the salvage to its fix: drop the quote-touch refresh (a synchronous
index rewrite on the event loop for every quote-reply, with no report of
eviction in practice) and the HERMES_RICH_SENT_MAX_ENTRIES env knob
(behaviour config does not go in env vars). Replace the mocked unit tests
with two real-gateway invariants against the Bot API stand-in: a
quote-reply to a plain send and to a streamed final, whose echo carries no
body, still reaches the model as [Replying to: "..."]. Both are red on the
base (the quoted text is missing) and green here.

Refs #147287, salvage of #151125.
2026-11-14 05:02:08 -08:00
AlexGogin
ffab2797d0 fix(telegram): index every sent message so quote-replies keep their text
Telegram does not echo a message body back in reply_to_message, so the adapter
resolves the quoted text from its own sent index (gateway/rich_sent_store). Only
the rich send path (sendRichMessage) wrote that index; the ordinary MarkdownV2
sendMessage path - which carries the vast majority of outbound messages - wrote
nothing. A user quoting such a message therefore produced an inbound event with
reply_to_message_id set and reply_to_text empty: the agent answered a question
whose subject it could not see, and nothing in the logs showed why.

- record the sent text on the legacy send path and on the legacy finalize edit
- refresh a quoted entry's timestamp so the FIFO trim keeps it
- make the index cap configurable via HERMES_RICH_SENT_MAX_ENTRIES
- log a warning when a quoted body is unrecoverable (the loss was silent)
- tests: tests/gateway/test_telegram_sent_text_index.py
2026-11-14 05:02:08 -08:00
kshitijk4poor
a254de068f fix(image_gen,video_gen): sign direct FAL jobs with the serving profile's own FAL_KEY
On a multiplexed gateway, a routed profile's direct FAL image or video job
went out signed with the launch profile's FAL_KEY, so it was billed to the
launch profile's FAL account. Hermes' own check (fal_key_is_configured) reads
the routed profile's scope and says "configured", but the submit then used
the module-level fal_client.submit: one process-wide SyncClient() that reads
os.environ (the launch profile's .env, loaded at gateway start) on first use
and keeps that key for the life of the process.

Both direct sites now submit through tools.fal_common.direct_fal_client(),
which builds fal_client.SyncClient(key=...) from the same key the check reads
(new tool_backend_helpers.fal_key(), shared with fal_key_is_configured). One
client per key, reused, as the managed client already is. Unscoped
single-profile runs read the same key as before: get_secret falls through to
os.environ there.

The unscoped submit shapes came from 95dc9aaa75 (rewbs, 2026-03-26, #3287,
image) and d04b3c193e (alt-glitch, 2026-05-27, #33259, video). They became a
cross-profile leak once routed profiles started sharing one process.

Part of #151791 step 9-pre (tracker #152308): explicit per-profile SDK keys.
Modal, Vercel token mode and HF upload are separate follow-up slices.
2026-11-14 18:28:19 +05:30
Adolanium
73cb700bcb fix(kanban): apply the dashboard Host/Origin/peer guard to the /events WebSocket
Every core dashboard WS route runs _ws_request_is_allowed after
_ws_auth_ok; the kanban plugin's /events stream only ran the credential
check, and fell open (accepted) whenever web_server_chat failed to
import. Run both gates and drop the fail-open import fallback, so the
stream can no longer drift from core WS policy.
2026-11-14 13:24:25 +01:00
Maciej Lisiewski
4554919b1c docs(photon): say when the mirrored .npmrc gate actually applies
npm ci from a lockfile never consults min-release-age; the mirrored
.npmrc only matters for the npm install fallback's fresh resolve.

Refs #134019

Co-authored-by: BearHuddleston <196404565+BearHuddleston@users.noreply.github.com>
2026-11-14 13:24:16 +01:00
Maciej Lisiewski
c0ef1ccba4 test(photon): pin the sidecar .npmrc mirror behaviourally; fix gate wording
Follow-up to the salvaged #134062 commit. Drop its repo-walking
structural test (banned shape per tests/AGENTS.md) and instead assert the
read-only-tree mirror actually carries .npmrc to where npm ci runs. The
.npmrc comments now say what the gate mirrors: the root .npmrc carries
only engine-strict; the 14-day floor lives in pnpm-workspace.yaml's
minimumReleaseAge, which npm never reads.

Fixes #134019
2026-11-14 13:24:16 +01:00
liuhao1024
203e533631 fix(security): give standalone npm packages their own release-age gate
npm reads project config only from the directory that owns the
package.json, so scripts/whatsapp-bridge and plugins/platforms/photon/
sidecar never inherited the root .npmrc's min-release-age=14 and their
lockfiles resolved without the cooldown - pinning versions published
days earlier (#134019).

The bridge holds WhatsApp session credentials, parses inbound messages
from arbitrary senders, and the gateway npm-installs exactly the locked
versions for every user (_ensure_bridge_deps), so the gate cannot be
applied user-side.

- add scripts/whatsapp-bridge/.npmrc and plugins/platforms/photon/
  sidecar/.npmrc with min-release-age=14, matching the root
- include .npmrc in the photon sidecar _MIRROR_FILES whitelist so the
  read-only-tree mirror keeps the gate where npm ci actually runs
- add a structural guard test: every directory with a package-lock.json
  must carry a .npmrc with the same floor
2026-11-14 13:24:16 +01:00
Teknium
e8f1dfdb5a fix(telegram): only a bare base_url gets the Bot API path; configured proxy paths stay as written
Greptile: Custom proxy routes stop working. bot_api_urls appended /bot to any
path not ending in bot, so base_url https://proxy.example/telegram/ moved to
/telegram/bot<token>; it now appends only when the URL has no path, for
base_url and base_file_url alike.
2026-11-14 03:59:38 -08:00
Teknium
b8241e3453 fix(telegram): a custom base_url without the /bot path no longer reads the token as a port
PTB appends the bot token straight to base_url, so `extra.base_url:
http://127.0.0.1:8081` became `...8081123456:AA...` and httpx parsed the
token's secret half as a port: every connect attempt failed with
InvalidURL("Invalid port: '<secret>'") (#81787). bot_api_urls() appends the
Bot API `/bot` (`/file/bot`) path when the URL doesn't already end in `bot`
or carry PTB's {token} placeholder; the gateway adapter and the standalone
sender both use it.
2026-11-14 03:59:38 -08:00
Maciej Lisiewski
8a00155e54 fix(whatsapp): keep contact ids and Signal session keys out of bridge.log (#155542)
Self-chat rejections logged the full chat/sender id of every other chat
on the owner's account, unconditionally; they now go through
redactWhatsAppId() like the debug events. libsignal's console.info
session dumps (private/root/base keys) are collapsed to their label by
the console wrapper, which now also covers console.info. bridge.log
rotates to one .1 generation above 5 MB when the adapter opens it at
spawn, and full/pre-update backups skip both generations.

Fixes #149860
2026-11-14 12:49:21 +01:00
Maciej Lisiewski
c1405617cd fix(security): keep the BlueBubbles password out of gateway logs (#155459)
* fix(security): keep the BlueBubbles password out of gateway logs

Every BlueBubbles request carries the server password as ?password=.
Two paths wrote it to agent.log in clear:

- Inbound: on the shared listener that serves multiplexed profiles,
  aiohttp's default access logger records the full request target; the
  adapter's access_log=None only applies when it binds its own runner.
  RedactingFormatter now masks credential query params on aiohttp.access
  records (the strict URL pass, which ordinary logs keep off so OAuth /
  magic-link URLs survive).
- Outbound: httpx.HTTPStatusError text embeds the request URL. The
  adapter's log lines and SendResult.error now go through one helper that
  applies redact_url_credentials.

Fixes #143550
Fixes #146420

* test(security): pin every BlueBubbles REST error path and the access-line gate

Each remaining _safe_error site (register, unregister, attachment upload,
attachment download) now has a real httpx 401 test, and a RedactingFormatter
test pins that only aiohttp.access records get the strict URL pass.

Refs #143550

Co-authored-by: BearHuddleston <196404565+BearHuddleston@users.noreply.github.com>

---------

Co-authored-by: BearHuddleston <196404565+BearHuddleston@users.noreply.github.com>
2026-11-14 12:48:24 +01:00
Maciej Lisiewski
d8fdbe8a54 fix(plugins): keep config-selected plugin names inside their plugin root (#155450)
* fix(plugins): keep config-selected plugin names inside their plugin root

memory.provider, cron.provider and context.engine were joined onto the
plugin root unchecked, so a path-shaped name loaded a package from
anywhere. Worse, the "is bundled" test was lexical (Path.parents), so a
`<root>/../..` spelling counted as bundled and was imported in-process
even under plugins.isolation: host. Names must now be a plain directory
segment (invalid = not found, so the built-in fallbacks apply), and the
bundled test compares resolved paths.

Fixes #141328

* fix(plugins): a user-dir symlink into the bundled root is not bundled

is_direct_child compared resolved paths only, so $HERMES_HOME/plugins/<x>
linking into a bundled dir counted as bundled and loaded in-process past
plugins.isolation: host (and the link could be swapped between check and
import). Require the path to sit under the root both as written and resolved.

Refs #141328

* test(plugins): satisfy ruff PLR0402 and cover the resolved half of is_direct_child

Use `from plugins import ...` instead of aliased submodule imports (ruff
PLR0402 failed the Python lints lane). Add a bundled-root child symlink that
resolves outside the root, so dropping the resolved comparison in
is_direct_child is caught.

Refs #141328

Co-authored-by: BearHuddleston <196404565+BearHuddleston@users.noreply.github.com>

---------

Co-authored-by: BearHuddleston <196404565+BearHuddleston@users.noreply.github.com>
2026-11-14 12:48:09 +01:00
Teknium
36af5c3f4d fix(telegram): anchor_multipart_replies also covers split Rich Messages
Greptile: Split replies still carry quotes. The split-anchor rule moves into
telegram_split.split_reply_anchor and send_rich_parts applies it before
_deliver_parts, so an opted-out split rich reply carries no reply_parameters.
Docs state the streamed-reply limit (anchor chosen at the first preview; an
edit cannot remove it).
2026-11-14 03:46:01 -08:00