Commit Graph

3236 Commits

Author SHA1 Message Date
Teknium
f5500de1c4 fix(gateway): shortened clarify options stay distinct; Google Chat lists them literally
Independent review round:
- Google Chat: the numbered list went through the card builder's Markdown
  pass, folding a literal **bold** option into *bold* (two options read the
  same next to numeric buttons). The HTML-escaped list is now appended after
  the card build; only the question is converted.
- Shortening kept start and end only, so options differing mid-string
  (TARGET=staging/canary/...) became identical. Each shortened option now
  keeps a window around where it first differs from its nearest sibling,
  and options whose lines still clash are re-cut around the group's
  earliest difference.
2026-11-08 11:44:52 -08:00
Teknium
05b85c4e4d fix(gateway): keep shortened clarify options distinguishable and literal in Google Chat
- A shortened option keeps its start and end, so options sharing a long opening
  (differing only at the end) still read differently once shortened.
- Google Chat's text widget renders HTML: the numbered list is HTML-escaped so
  an option with literal <b>/<br> reads as written.
2026-11-08 11:44:52 -08:00
Teknium
10b6eb5f0a fix(gateway): keep every numbered clarify line when the prompt is over its cap
Independent review round:
- P2 Slack: a long question left no room for the numbered list, so the final
  section cut dropped it and the positional buttons pointed at nothing. The list is
  now reserved first (shared clarify_text_with_choices) and the question is cut.
- P3 relay: text[:limit-1] could cut numbered lines; same helper, measured with the
  chat's length unit (UTF-16 lanes).
- P3 class: Discord's max_chars dropped trailing lines; numbered_clarify_choices now
  shortens options instead so every button keeps its line. Google Chat never cuts
  the card text (no fix needed).
2026-11-08 11:44:52 -08:00
Teknium
7bf5a982a6 fix(slack): over the section cap, shorten each option instead of cutting the list
Review finding from @guvengursel: the numbered list is appended and the
section body was then hard-cut at Slack's 3000-char cap, so with several
long options the cut landed mid-list and buttons "3", "4" pointed at lines
no longer visible — positional labels without their list are unanswerable,
the same failure this PR fixes. Now every option keeps its numbered line:
when the list is over the cap, each option's own text is shortened (ending
in "…"), measured on the escaped text. Buttons, values and the full choice
the click resolves to are unchanged.
2026-11-08 11:44:52 -08:00
Teknium
ca237dc5fd fix(discord): keep the numbered clarify list whole-line and literal
Review on #111093: the numbered option list was cut at a flat 1000 chars,
which could split an option mid-line, and it carried no markdown escaping,
so an option with `*` or `_` rendered formatted in the message while its
button showed it literally. `numbered_clarify_choices` gains `max_chars`,
which drops whole trailing lines and marks the cut with `…`, and Discord
passes a markdown escape. Since #114693 the list lives in the 2000-char
message content (the embed is header-only), so the 1000-char budget keeps
the question and hint inside that cap.
2026-11-08 11:44:52 -08:00
teknium1
4b0be5b740 fix(gateway): long clarify choices render in full, buttons go positional (#78115)
Slack, Discord, Google Chat and the relay all put the option text on the
button label. Every client clips labels well below the API cap (Slack ~48
columns, narrower on mobile, no tooltip), so a 50-character option from a
grilling/wayfinder skill was unreadable and the prompt unanswerable.

When any option is wider than the label budget, the numbered full text goes
in the message body and the buttons are labelled 1..N (Telegram and WhatsApp
Cloud already worked this way). A press still resolves to the canonical
choice text via the clarify entry; positional values/ids are unchanged.
CJK wide characters count as two columns.

One shared helper (gateway.platforms.helpers.numbered_clarify_choices) so
the four adapters cannot drift again.
2026-11-08 11:44:52 -08:00
kshitijk4poor
e89b47ac8b fix(whatsapp): keep a connected gateway alive on a late passkey request
Before passkey support, Baileys rc13 acked and ignored passkey_prologue_request.
With it, any such notification made a signer-less bridge exit 78, which the
adapter parks as non-retryable, so a request reaching an already open
gateway session would stop a working gateway until a manual re-pair.
Exit only when the session has not connected yet (or in pair-only mode),
and log and ignore it otherwise.

Also name the exit status (PASSKEY_REQUIRED_EXIT) on both sides, and emit
the dashboard-readable {event: error, error: passkey_required} under
--pair-json instead of a passkey_required event no watcher handles. The
passkey_failed / passkey_confirmation_failed emits and the PAIR_JSON guard
in confirmPasskey are dropped: loadPasskeySigner rejects --pair-json, so
those paths only run in an interactive terminal.

Tests: bridge.passkey.test.mjs drives the real bridge entry point; a
stubbed socket that opens before the request stays alive, and pair-json
emits the error event. Both new assertions fail with the guard / emit
removed.
2026-11-08 15:52:48 +05:30
helix4u
618b0d6bbe fix(whatsapp): stop passkey retry loops and tighten pairing setup 2026-11-08 15:52:48 +05:30
Turgut Kural
ba560a7067 fix(agent): keep OpenCode Go keys on a per-model upstream 429
OpenCode Go answers 429 for two different walls. GoUsageLimitError is the
key's plan window and must bench the key (the built-in pipeline already
classifies it as billing). 'Upstream request failed: Rate limit exceeded'
is a single model's upstream throttle: the key keeps serving every other
model, yet the pool benched it for the 429 hour. With a two-key pool whose
primary hit its weekly window, one throttled main model benched the backup
too, and every auxiliary task on a different model failed with
'no available entries'.

The opencode-go profile now classifies that body as upstream_rate_limit
through its classify_api_error hook, which the main recovery path already
treats as 'credential healthy, defer to fallback'. The auxiliary pool
recovery consulted only substring predicates, so it now also skips the
bench for an upstream_rate_limit verdict (covers OpenRouter-wrapped
upstream 429s the same way).

Salvaged from #140713.
2026-11-08 13:18:54 +05:30
kshitijk4poor
af5c2014a8 refactor(dashboard-auth): collapse verify_jwt's identical except arms
Final-head review fold:

- verify_jwt: the expired / bad-signature / not-yet-valid arms existed only
  because the catch-all used to raise ProviderError; all now raise the same
  InvalidCodeError, so one InvalidTokenError arm covers them (PyJWT's own
  message names the failure; the clock-skew test matches it). The aud/iss
  arm's diagnostic re-decode runs only after the signature verified, so its
  try/except-pass guarded nothing.
- Docstrings: ProviderError also covers a malformed JWKS and a provider-wide
  contract failure (oauth_contract_version); the refresh comment no longer
  assumes Portal's rotate-on-use refresh tokens.
- Cookie tests use the __Host- names the server sets over HTTPS, so they
  keep exercising verify/refresh once bare names stop being read there
  (#136772); the access-token-only case asserts the session-expired reason
  rather than any 401.
2026-11-07 16:04:30 +05:30
kshitijk4poor
b182c16aee fix(dashboard-auth): log drift only for verified aud/iss mismatches
Round-2 review: the drift WARNING fired on every InvalidTokenError. PyJWT
checks the algorithm before the signature, so a forged token naming the
published kid with another alg reached that branch unauthenticated and
logged attacker-chosen iss/aud of any length.

Warn only on InvalidAudienceError / InvalidIssuerError, which PyJWT raises
after the signature verified (a real IdP-signed token: a foreign client's,
or config drift), with the echoed unverified values capped at 128 chars.
Other claim failures stay a plain InvalidCodeError, unlogged.

Tests: a forged-alg token with the published kid is a 401 with no drift
line (fails against the previous shape), and a gate-level cookie+RT case
where Portal's rotated token does not verify here is a signed-out 401.
2026-11-07 16:04:30 +05:30
kshitijk4poor
f6c8b95fda refactor(dashboard-auth): one refresh-boundary mapping, keep drift visible
Folds the pre-arm review of the salvaged stack:

- Map a grant's "minted token is not ours" InvalidCodeError to
  RefreshExpiredError once, in JwtOAuthProvider.refresh_session, instead of
  a copy in each provider's _grant (the auth-code path already raises
  InvalidCodeError -> 400, so the copies only mattered for refresh).
- A wrong aud/iss is also what config drift looks like (wrong client_id or
  portal URL). Now that it is a 401 instead of a 503, nothing logged it:
  verify_jwt logs the token's and the configured iss/aud at WARNING. The
  diagnostics tests assert that log through verify_session instead of
  calling _claims_for/_verify_id_token directly.
- oauth_contract_version mismatch deliberately stays a 503 (every token
  Portal mints would fail it); say so beside the check.
- Fix the now-stale InvalidCodeError and classify_jwks_lookup_error
  docstrings and trim per-branch comments that restated the rule.
- Tests: fold the gate-level cases into test_opaque_bearer_not_unreachable.py
  with one JWKS-server helper and one gated-app helper (three server copies
  -> one), add a cookie-path case, close the server socket.
2026-11-07 16:04:30 +05:30
kshitijk4poor
b0eb36ba90 fix(dashboard-auth): another instance's agent_instance_id is a 401, not 503
The Nous provider's agent_instance_id cross-check raised ProviderError, so
a well-signed Portal token naming another instance answered the same
"Auth provider 'nous' unreachable" 503 as the foreign-aud case fixed by the
salvaged verify_jwt commit. It is a token this instance does not accept:
raise InvalidCodeError (verify_session -> None -> 401).

Adds a gate-level regression against a real local Portal JWKS and the real
gated web_server app: the user's live shape (Portal CLI token,
aud=hermes-cli:hermes-cli), another instance's aud, another instance's
agent_instance_id, and an unknown kid all get 401; a valid token is 200 and
an unreachable JWKS stays 503. 4 of 6 cases fail on origin/main (503).

Maps paul@letscubo.com -> paulyang-fm for the salvaged #107305 commit.
2026-11-07 16:04:30 +05:30
paul.yang
3fe7d20c88 fix(dashboard-auth): verify-stage token denials trigger re-login, not a misleading 503
verify_jwt raised ProviderError for every decode-time rejection except
expiry, so a token minted for a different client on the same IdP (e.g. the
Hermes Desktop app reusing one session across two same-issuer gateways)
surfaced as '503 Auth provider self-hosted unreachable' — the IdP was
reachable and had answered; the token was simply not ours (audience
mismatch). Operators only saw the real reason in errors.log.

Denials are now InvalidCodeError end-to-end:
- verify_jwt: wrong audience/issuer, bad signature, missing claims ->
  InvalidCodeError (diagnostic iss/aud still appended). verify_session
  returns None per protocol -> middleware refreshes / re-logins.
- JwtOAuthProvider grants (self-hosted + nous) map a verify-stage
  InvalidCodeError to the caller's bad_request_exc (InvalidCodeError for
  the auth-code path, RefreshExpiredError for refresh) so the middleware
  refresh scan rejects the provider instead of crashing on an uncaught
  InvalidCodeError.
- JWKS transport failures stay ProviderError (503) — unreachable means
  unreachable.
2026-11-07 16:04:30 +05:30
Teknium
e1f7b59ec2 refactor: move Yuanbao out of core into the yuanbao Hermes Labs plugin
The Yuanbao gateway platform (plugins/platforms/yuanbao) and its yb_* tools
(tools/yuanbao_tools.py) now ship as the `yuanbao` plugin in
NousResearch/hermes-labs-plugins, a community-tier, Nous-built, unsupported
plugin. Platform name, toolset name (`yuanbao`), tool names, env vars,
config keys (platforms.yuanbao.*, legacy gateway.yuanbao) and
YUANBAO_HOME_CHANNEL are unchanged.

Migration: a LEFT_CORE row (hermes_cli/left_core_migration.py) installs the
catalog plugin for every home core ran Yuanbao for: YUANBAO_APP_ID (or the
legacy YUANBAO_APP_KEY) plus YUANBAO_APP_SECRET in its dotenv layers (the
process env too for the launch home), platforms.yuanbao on through the
gateway's own config loaders, or the yuanbao / hermes-yuanbao toolset
selected for another platform. The shipped `yuanbao: [hermes-yuanbao]`
platform_toolsets row is not use. The row keeps the yb_* tools off on every
platform whose core composite never carried them, keeps YUANBAO_APP_SECRET
stripped from children (secret_env) and the other YUANBAO_* settings on the
provider blocklist (private_env) while the plugin is absent, and its notice
carries the unsupported sentence.

Core wiring removed: toolsets (yuanbao, hermes-yuanbao, the hermes-gateway
include), Platform.YUANBAO (Platform('yuanbao') resolves once the plugin
registers it), the platform/toolset menu rows, the TUI special case, the
static session note (the plugin's platform_hint carries it), env/config-key
lists, webhook deliver set, startup allowlist list, locales strings and
yuanbao-only tests. Telemetry enum values stay.
2026-11-06 20:39:14 -08:00
unsupportedpastels
c0049c7810 docs(plugins): have a seam PR name the plugin that needs it
Both AGENTS.md files reject a hook with no concrete consumer, and the
contributing guide accepts one with a real, stated use case even when
the consumer ships separately. A seam PR opened first, as this section
asks, must therefore say which plugin needs it.

Wording from @BearHuddleston's review.
2026-11-06 19:25:20 -05:00
unsupportedpastels
166a220197 docs(plugins): say how to add a seam when no listed name fits
The boundary-lint section told agents what not to do (list a name just
to pass, run --update to go green) but not what to do when the plugin
API has no name for what they need, so an agent could only work round
the lint or stop. Add the route: put the seam in its own PR first,
preferring a ctx method or hook; otherwise list the name in
plugin_api.json, regenerate public-api.md, document it and add a
behavior test. The feature PR then uses it.
2026-11-06 19:25:20 -05:00
unsupportedpastels
2fc37067e8 docs(plugins): close three ways round the boundary lint
Adding a name to plugin_api.json passes the lint but publishes it to
every plugin author; --update rewrites the whole baseline, so it also
accepts any other crossing in the same change; and moving an import to
another file is a new per-file key that needs --update, not a rewrite.
Say all three.

Wording from @BearHuddleston's review.
2026-11-06 19:25:20 -05:00
unsupportedpastels
c367ee3990 docs(plugins): tell agents how to handle the boundary lint
#149895 added scripts/boundary_lint.py, which fails CI when a bundled
plugin imports a core name outside plugin_api.json, or core imports a
specific bundled plugin, beyond the committed baseline. Agents only met
it when CI failed, and the fastest way to turn CI green is --update.

Add a short section to plugins/AGENTS.md: fix the import with a listed
name, a ctx method or discovery, and run --update only for an intended
crossing, saying why in the PR body.
2026-11-06 19:25:20 -05:00
kshitijk4poor
e79ac5ab27 fix(memory): release every registration a hook-only provider load made before its host stops
A provider that registers a tool (or any non-hook registration) while loaded for a profile hook
kept it after the hook's plugin host was stopped; calling it raised PluginHostUnavailable. The
loader (plugins.memory.provider_registration_scope) now releases everything that load put in
the profile manager's ownership ledger (hooks, tools, middleware, session env, RPC methods...),
not only the fallback hooks. It keys on the name the collector registers under, the provider
directory's name, which differs from the selected name for a pip provider whose package is named
differently. The hosted test registers each kind and runs for both directory shapes.
2026-11-06 23:27:29 +05:30
kshitijk4poor
bcd5626c24 fix(memory): close the provider-seam follow-ups
Follow-ups from the memory-provider seam review (#149330):

- Profile hooks skip all setup when the profile names no external memory.provider (in its
  config.yaml or the managed overlay): no secret scope, effective config or provider load on
  the common create.
- The hook also hydrates the new profile's configured secret sources (1Password and the like)
  before binding its scope, as the dashboard and cron workers do.
- Under plugins.isolation: host, a plugin host started only for the hook is stopped when the
  hook returns, so a long-lived dashboard keeps no host per created or renamed profile.
- Dashboard config panel: an unknown storage value shows no panel and refuses saves instead
  of writing a stray $HERMES_HOME/<name>/config.json; storage=provider without
  write_config_fields is a 501 (no secret saved); a provider that declares a panel but fails
  to load is a 503, not "unknown provider".
- A config_schema.py that fails to load logs its traceback once per file, then at debug: the
  panel polls, and an outdated plugin fails the same way every time.

Tests cover each case, including the real plugin host (a refused save crossing it is a 400
with no secret saved; the hook runs in the host and its host is stopped); each fails with
its fix reverted.
2026-11-06 23:27:29 +05:30
Ben Barclay
ca43606920 fix(remote-config): restore the caller's home when the token scope build fails
Build the scope inside the try so a failing build still resets the home
override and is reported as a PlaneCredentialError. Cover the launch
profile's frozen env-only override and a secondary never borrowing the
launch profile's env override.
2026-11-05 23:01:15 -05:00
Ben Barclay
87746862af fix(remote-config): resolve the Nous plane token under its profile's secret scope
Under gateway multiplexing the Remote Config poller (a bare thread) resolved
the Nous token with no secret scope. The Portal override read failed closed,
default routing applied, and a non-production agent's refresh token was sent
to the production Portal, which rejected it and quarantined the login.

_nous_token now binds the owning home's secret scope (owner_secret_scope:
the launch profile's own mapping for the launch home, the profile's files
otherwise) for the resolution and resets it afterwards.
2026-11-05 23:01:15 -05:00
Jan-Stefan Janetzky
f02ba87b8c feat(agent): fork sub-agents inherit the memory provider under checkpoint_required
Four call sites fork a second agent with skip_memory=True, which leaves the
child with _memory_manager = None: a fork is not the user, and its scratch
transcript is not the user's memory. With compression.checkpoint_required
armed that saving turns into a kill. The gate is armed globally per agent
instance from config, not from whether the agent has a provider, so the child
arms the same gate its parent did and then meets its first compaction with
nothing to checkpoint against. It raises CompressionCheckpointUnavailable --
"no active provider implements checkpoint API v2" -- and the delegate turn
dies with status=error and a null summary while the parent runs on. The gate
is not bypassed there; it is armed against a provider that was never loaded.

- The four sites (delegate_tool, curator, batch_runner, feishu_comment) pass
  skip_memory=not checkpoint_required_from_config(). Gate off is the default
  and stays byte-identical: skip_memory=True, no provider init, no hook. Same
  shape and the same reason as the two gateway disposable-agent sites that
  already read the key this way (run_turn_hygiene.py,
  slash_commands_session.py). delegate_tool reads it inside the delegated
  profile scope, where the child reads it.
- The detached review and /btw forks (build_cache_parity_fork) are not
  touched: they persist nothing, and _pre_compress_memory_context already
  exempts exactly that shape (decabd79f1), so the gate never fails them.
- checkpoint_required_from_config() in conversation_compression_checkpoint,
  next to the gate's init refusals. One resolver rather than four parses, and
  the call sites need it before an agent exists:
  agent.compression_checkpoint_required is assigned inside the child's own
  init, and the parent's says nothing about the child. It reads
  load_config_readonly() -- the call init_agent makes to arm the gate on that
  child, so parent and child answer from one source and a fork is given a
  provider precisely when the child would refuse to compact without one. An
  unreadable config reads as "not armed", matching init_agent's own except
  around the same load.
- New memory_agent_context kwarg on AIAgent/init_agent, handed to the
  provider's initialize() as agent_context; unset, the platform rule decides
  as before (cron/subagent, else "primary"). The platform rule alone cannot
  scope these forks: the curator runs as platform "curator", the batch runner
  takes its platform from the caller's config, and the Feishu responder sets
  none, so each would file its transcript as the user's own memory in every
  provider that scopes writes by that key. All four pass "subagent" -- the
  value memory_provider.py documents and supermemory gates on. A fresh
  per-site string ("curator", "batch", ...) would drop out of every
  provider's non-primary membership test and re-enable writes the provider
  had deliberately disabled, which is a fail-open on the one path this commit
  opens. platform still separates the shapes.

Costs, taken deliberately rather than hidden: one provider initialize() per
fork (a round trip for a network-backed store, on a path that made none), and
fork transcripts reaching the archive as checkpoints. Both are named at the
call site and in the contract doc, where a provider author reads them.

Ten tests (tests/agent/test_fork_memory_under_checkpoint_gate.py). The
four site probes drive the real spawn functions with the smallest parent stub
they accept and record the child constructor kwargs -- red at all four against
the previous commit with the literal skip_memory=True. The gate-off probes are
the control in the other direction: without them "inherit the provider" could
have shipped as "always inherit". The recorder aborts with a BaseException
because the sites wrap the spawn in except Exception and would have swallowed
an ordinary failure into a green test. The provider-initialize test drives a
real AIAgent init, the only way to observe the keyword at initialize().

Live probe (on the August base), isolated HERMES_HOME with a stub API-v2
provider and the gate armed: before, the child aborts with failure_class
"exception:CompressionCheckpointUnavailable" and delegate_task returns
status=error, summary=null. After, the child initializes the provider
(agent_context "subagent", platform "subagent"), its own session fires
on_pre_compress, no CompressionCheckpointUnavailable appears, and the parent
returns the subagent's answer.

(cherry picked from commit 31af59c54ebff4c6c1861961111700b8e42dba76)
(cherry picked from commit 9bf3feaf8c98dff6e90eadf0f533204adc150a8c)
2026-11-05 19:55:33 -06:00
unsupportedpastels
01888fc206 fix(webapp): the gated Webapp accepts the deployment session token
On the gateway's Webapp behind the sign-in gate, a provider token worked
on its own (bearer header, socket ?token=) only when this listener gave
it to a native app's sign-in. The deployment session token
(HERMES_DASHBOARD_SESSION_TOKEN, literal or file:<path>) that the bundled
session-token provider vouches for was therefore refused with 401 /
close 4401, although the docs promise it authorizes the gated listener.

The bearer, peek_session and socket ?token= checks now call
access_token_works_alone: token_works_alone (looked up at call time) or
the token the registered session-token provider read at startup,
compared in constant time by the provider's matches_token, which its
verify_session also uses. With the provider not registered
(dashboard.session_token_auth enabled: false) the token is refused as on
main. token_works_alone and the refresh route are unchanged from main:
the deployment token has no refresh.
2026-11-05 18:26:06 -05:00
kshitijk4poor
e090092285 feat(memory): profile lifecycle and config-storage seams for memory providers
A catalog memory provider (Honcho today) has no way to own its per-profile setup or its
dashboard config file, so core carries that code for it: profile create/rename edit Honcho's
host blocks and the dashboard has a Honcho-only storage kind that imports the plugin's private
modules. These seams let a provider do that work itself; core's Honcho code is untouched here
and is removed in a follow-up once the plugin implements them.

- MemoryProvider.on_profile_created(profile_name, hermes_home) / on_profile_renamed(old, new,
  hermes_home): called from create_profile (CLI, dashboard, Desktop/TUI) and rename_profile for
  the provider the profile's effective config selects, with that profile's home and its own
  .env secrets bound. A failing hook or unreadable config is logged and never fails the create
  or rename. No-ops by default.
- storage=STORAGE_PROVIDER in config_schema.py, with read_config_fields(hermes_home) /
  write_config_fields(values, hermes_home): the provider owns its file layout. Core keeps
  value coercion, placeholders, write-only secrets, the memory.provider switch and the 400 on
  a refused write, and saves secrets to .env only after the provider accepted them.

_record_profile_rename moves to profile_identity.py (profiles.py line budget).
2026-11-05 13:08:14 +05:30
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
Teknium
c46c34cfcd feat(video-gen): add Wan 2.7 FAL video family (t2v + i2v)
Adds Alibaba's Wan 2.7 to FAL_FAMILIES: fal-ai/wan/v2.7/{text,image}-to-video.
1080p/720p, integer duration 2-15s, negative prompts, seed, native auto audio
(no generate_audio key), i2v drops aspect_ratio (schema omits it).
Schema verified against fal.ai llms.txt + OpenAPI. $0.10/s (720p), $0.15/s (1080p).
2026-11-04 21:31:17 -08:00
Teknium
1206ecf03d fix(feishu): shared picker card, race-safe stale prune, full labels for one-line titles
Review nits: snapshot _choice_picker_state before pruning (the SDK callback thread pops concurrently); send and settle the picker with config.update_multi so a group settle reaches everyone; a one-line title (usage-limit offer) lists the full choice labels as body instead of repeating the header.
2026-11-04 21:29:10 -08:00
Teknium
14cfad0a6b fix(feishu): multi-select clarify card takes a typed free-form answer
Review nit (hint_multi): the hint offers "your own answer" but typed prose was rejected and cancelled the clarify. The card now calls mark_awaiting_text like the base text prompt.
2026-11-04 21:29:10 -08:00
Teknium
04d45f0d7f fix(feishu): clarify/picker card taps answer in webhook mode
Review finding (MAJOR, webhook transport): _handle_webhook_request turned the whole payload into SimpleNamespaces, so action.value failed the dict route check and the settled card was dropped by the fixed {code:0} reply. card.action.trigger now keeps the button value a dict and returns the callback card as the HTTP body; token/signature checks still run first.
2026-11-04 21:29:10 -08:00
Teknium
f94194ba73 feat(feishu): interactive clarify cards + native choice picker
Feishu already rendered exec approvals and update prompts as interactive
cards, but the clarify tool fell back to the base numbered-text prompt and
finite-choice slash commands (/reasoning, /fast, usage-limit switch) fell
back to text status cards. This implements the generic adapter contracts
from BasePlatformAdapter instead of a Feishu-only path:

- send_clarify(): multiple-choice questions become a card with one numbered
  button per option plus "Other (type answer)"; a tap answers through
  resolve_gateway_clarify and the callback response settles the card inline
  for every client; "Other" calls mark_awaiting_text. Open-ended questions
  use the base text prompt. Answers come from the pending clarify entry, so
  a tap after a timeout or /new reports the prompt expired.
- retire_clarify_card(): the gateway's hook for a clarify that ended without
  a tap (timeout, reset, superseding prose, typed answer) PATCHes the card
  button-less; the card is a shared card (update_multi) so the update
  reaches every recipient.
- send_choice_picker(): one-tap picker card; the tap settles the card and
  runs on_choice_selected on the adapter loop, then sends its confirmation.
- Every click passes the approval path's _validate_card_action (operator
  authorization incl. the gateway pairing check, callback-vs-card chat
  match); state pops are first-writer-wins, so a double or stale tap is
  refused.

Behaviour lives in plugins/platforms/feishu/adapter_choice_cards.py (mixin);
adapter.py stays at main's length (card-action routing became a table).
New platform.feishu.clarify/picker strings in all 17 locales, reusing each
locale's existing Telegram/Discord wording.
2026-11-04 21:29:10 -08:00
Teknium
4e93f80e47 fix(gateway): end bot-to-bot exchanges: no runtime notices to bots, a runtime hop cap, replies need no answer
Widens #137037 from Mattermost to the whole class (#137027):

- Runtime notices never reach a bot peer: every busy-path reply (ack, redirect,
  drain), lifecycle/status and credits notices, tool progress, interim and thinking
  bubbles, the long-running heartbeat, the auto-reset notice, and the runtime failure
  copy ("not processed", retry hints, generic failure apology) on a failed or empty
  turn. The model's own reply is still delivered.
- Chain rules in gateway.bot_loop_guard (config.yaml): a human message starts a chain,
  each bot message after it is one hop, max_hops (default 4) caps them, a bot repeating
  the same text in one chain is dropped, and with bot_replies_expect_reply false (the
  default) a bot answering the reply this bot just gave it starts no turn. A bot
  message also counts as not expecting a reply, so a silence marker ends it quietly.
- Bot authorship everywhere it is knowable: a generic per-adapter bot_users opt-in
  (config.yaml platform extra) for platforms whose events carry no bot flag,
  Mattermost props.from_bot, QQ guild author.bot.
- Bot Mode message_agent: agent/bot_chain.py owns a per-session hop count carried in
  the delivery's author envelope (runtime-written, parse_turn_author keeps it), refuses
  sends past the same max_hops and identical repeated asks, sends a reply to the bot
  that messaged this turn notify-only (expects_reply false, no wake), and refuses a
  message back to a bot whose reply said it needs no answer. tools/bot_mode_dm.py gets
  only the gate call and the wake flag (LANE dm owns that file; same wake names as #144789).
2026-11-04 21:01:10 -08:00
KoNit-K
cb52533765 fix: contain Mattermost bot peer loops
(cherry picked from commit b21f2e9fdc45335c55d200c2812f895d81ec28fd, #137037;
conflicts resolved onto main: ALLOW_BOTS moved to the Mattermost gateway_env AUTHZ
entry, status suppression moved to gateway/run_turn_progress.py)
2026-11-04 21:01:10 -08:00
Victor Kyriazakos
cad0aaaf0d fix(slack): tag thread-context senders against the live message's allowlist
Slack thread context authorized each prior sender as chat_type="thread". The
gateway authz chain only treats group/forum/channel as group chats, so a
channel thread's senders were judged on the DM allowlist: group_allow_from
was never read and every human was tagged [unverified] even under
group_allow_from: ["*"], while a DM-only allow_from user read as verified in
a channel. The live message is authorized as "group" (channel) or "dm"
(IM/MPIM); thread-context senders now get that same chat type plus the
thread id, so the tag marks exactly the senders the live message's allowlist
would refuse. Authz is unchanged, so the Discord "thread" callers keep their
behaviour.

Origin: 0198713c33 (CWE-863 thread-context tagging, #55979).
2026-11-04 11:36:46 -05:00
Maciej Lisiewski
3d4d73e0fd fix(deps): bump pyasn1 to 0.6.5
Moves the google extra pin and the Google Chat staleness probe
(_REQUIRED_PACKAGES) from 0.6.4 to 0.6.5 so a half-synced interpreter
is repaired onto the patched release. pyasn1-modules 0.4.2 allows
<0.7.0. 0.6.5 was published 2026-10-27, past the 3-day release-age
check.

Advisories: GHSA-2qm8-x737-gmw5, GHSA-9m75-vc3g-4x39,
GHSA-fm9c-5rcf-2q5p, GHSA-mm57-4v3p-rchx
2026-11-03 21:06:29 +01:00
Maciej Lisiewski
b9621cd0b2 fix(deps): bump zod to 4.6.7
Moves the tests-js direct pin (which the root lock hoists for
@assistant-ui/react and eslint-plugin-react-hooks) and the photon
sidecar's transitive copy from 4.6.5 to 4.6.7, the newest 4.6 patch.
4.6.7 was published 2026-10-12, past the 14-day npm release-age gate.

Advisory: GHSA-mrhx-c7xc-m3w5
2026-11-03 21:06:29 +01:00
Maciej Lisiewski
e3085ec023 fix(deps): bump undici to 6.29.1 and 7.30.1
Moves the ui-tui direct pin and the root undici@^6/@^7 overrides, plus
the photon sidecar's direct pin and override, to the patched releases
in each line. Both were published 2026-10-15, past the 14-day npm
release-age gate.

Advisories: GHSA-2m5v-pch6-74hx, GHSA-4qv8-2p9j-2685,
GHSA-4w7w-5xrc-9h26, GHSA-55wc-3pg8-jfw6, GHSA-9fm3-97px-rjf6,
GHSA-f72v-6w45-q472, GHSA-qrxm-fqhp-jwvm, GHSA-xjj6-f33q-929c
2026-11-03 21:06:29 +01:00
kshitijk4poor
5ce74340f9 fix(discord): probe for libopus once, off the event loop
connect() called ctypes.util.find_library("opus") on the gateway loop
whenever opus was not loaded. On Linux find_library runs ldconfig, gcc
and ld subprocesses, and on a host without libopus (the Hermes Cloud
image) it never succeeds, so every Discord connect and reconnect
repeated that blocking work on the loop. On a memory-starved 2 GB
instance both loop-liveness watchdog dumps that restarted the gateway
had the loop thread inside this probe.

Move the opus helpers into adapter_opus.py and probe at most once per
process under a lock; connect() runs it with asyncio.to_thread. A libopus
installed later needs a restart, and the "Opus codec not found" warning
now logs once instead of on every reconnect.

The per-connect probe came in with 0ff1b4ade2 (#1299).
2026-11-03 21:58:19 +05:30
hackartist
53308b1947 feat(slack): add opt-in thread_followup_silence for unaddressed thread replies
A plain unaddressed follow-up in a channel thread the bot participates in
gets reply_expected=None, so a bare [SILENT] is rejected and the gateway
posts the unexpected-silence notice. That is noisy when humans in the
thread talk to each other without @mentioning.

thread_followup_silence (config.extra / SLACK_THREAD_FOLLOWUP_SILENCE,
default false) makes such non-DM thread replies reply_expected=False so the
silence marker stands. DMs, @mentions and flat channels are unchanged,
and the default keeps the #110952 behaviour.

Move the Slack config getter factories into adapter_config_readers.py to
keep adapter.py within its code-health line cap.
2026-11-02 14:54:09 -08:00
Teknium
38bfb94b5c fix(image_gen): OpenRouter's Grok image row is x-ai/grok-imagine-image-2.0
OpenRouter's Image API catalog (GET /api/v1/images/models) no longer lists
x-ai/grok-imagine-image-quality; it lists x-ai/grok-imagine-image-2.0. Swap
the curated _IMAGE_API_MODELS row, with every knob taken from the live
catalog entry: the same 14 aspect ratios, 1K/2K, n=1, 3 references, plus a
quality enum (low|medium) the old row never declared.

The direct xAI backend keeps grok-imagine-image-quality: xAI's authed
/v1/image-generation-models still serves it.
2026-11-02 07:57:26 -08:00
kshitijk4poor
df128a1cb4 refactor(telegram): read a video note through the video branch at each site
The video-note support added a second, line-for-line copy of the video
branch in _observed_media_source and _handle_media_message, differing only in
the attribute read and the log label. Take `msg.video or msg.video_note` once
in each place instead, keeping the "video note" label for circles, and rejoin
the video_note entry of the _media_message_type table onto the next line.

adapter.py is over the 2,000-line cap, where units may only shrink: this
brings the file back to its origin/main line count (7380), so the PR adds
no lines to it. Behaviour is unchanged; the video and video-note cases of
test_native_video_is_cached and test_reply_to_a_video_note_caches_it still
pass, and each still fails with its branch removed.
2026-11-01 19:35:16 +05:30
kshitijk4poor
840d104031 fix(telegram): an uncaptioned video note keeps the group silence notice
group_reply_expected treats an uncaptioned voice note or audio file as spoken
(its words are not in the message text), so it returns None and the silence
notice stays. Video notes now reach the agent too, and a circle without a
caption is the same case: the question is in the audio. Without this it came
out reply_expected=False, so in a group with require_mention off a spoken
question in a circle could vanish behind a bare silence marker.

Tests: the new video-note row of
test_reply_expected_follows_who_the_group_message_addresses fails without the
change (False != None) and passes with it. Docs updated in the same sentence
that lists voice notes and audio files.
2026-11-01 19:35:16 +05:30
kshitijk4poor
ed960fe960 fix(telegram): localize the download-failure reply for video notes
The video-note branch passes the label "video note" to
_surface_media_cache_failure, which translates the chat reply through
_MEDIA_KIND_KEYS. The label had no entry there, so a German or Japanese user
whose circle failed to download got a translated sentence with the English
words "video note" in it. Map it to the existing kind_video key ("video file"
in every catalog). The agent-visible note keeps the English "video note".

Scope: no new catalog key; a circle is reported as a video file in the reply,
which every locale already translates.

Test: test_video_note_failure_reply_is_localized (added with the test fold
later in this stack) fails with this entry removed.
2026-11-01 19:35:16 +05:30
Horizont367
016bc1df65 feat(telegram): support video note messages 2026-11-01 19:35:16 +05:30
kshitijk4poor
94bd083712 fix(mattermost): tidy the user-ID setup hint and move the plugin test
Follow-up to the cherry-picked setup-text fix (salvage of #147215).

- Wizard step 4 and the plugin's security hint now share the same lines.
  Before this they had drifted: only the wizard said where on the page
  the ID is. Step 4 now says what the step is for instead of opening
  with "the profile dialog does not show your user ID".
- Add a route for non-admins: a logged-in browser tab can open
  /api/v4/users/me with its session cookie and get the user's own ID.
  Mattermost reads the session cookie on API requests and only checks
  CSRF on non-GET requests, so a plain GET works.
- The allowlist help text points back at step 4 again rather than
  repeating one of the lookups.
- Docs (en + zh-Hans): indent the curl block under its list item so the
  list no longer splits in two, add the browser route, note that
  `mmctl user list` needs `--all` past 200 users, and use the canonical
  docs URL (the .html form redirects).
- Move the plugin setup test into tests/gateway/test_mattermost_plugin_setup.py
  next to the existing plugin setup tests and its _patch_setup_io helper,
  so it no longer writes a real .env. Drop the assertions that pinned the
  new wording; keep the ones that pin the old, wrong advice and the two
  documented lookups.

Both setup tests fail on origin/main and pass here.
2026-11-01 19:24:04 +05:30
xxxigm
4e89a6d585 fix(mattermost): stop sending setup to a profile dialog that has no user id
Mattermost documents the id on the System Console user page and on
GET /api/v4/users/username/<username>. /users/me with the bot token is the bot.
2026-11-01 19:24:04 +05:30
Teknium
ab8bd7ba4f docs(teams): correct which cards carry the command in their button data
Only cards sent by an older build carry cmd/desc in the button data; cards from
this build carry just the prompt id.
2026-10-31 22:19:18 -07:00
Teknium
ce0602e8a9 fix(telegram): catch NetworkError, not TelegramError, after a kept-prompt edit fails
TelegramError is absent from the shared Telegram test stubs, so the import
broke test_slash_confirm_forum_callback_followup_keeps_existing_thread_behavior
with an ImportError. NetworkError covers the same transient cases (timeouts
and network failures subclass it in python-telegram-bot); BadRequest is still
caught first and keeps the decision-only fallback.
2026-10-31 22:19:18 -07:00