Commit Graph

3866 Commits

Author SHA1 Message Date
kshitijk4poor
eee77ea20d fix(matrix): an operator recovery-key path outside every profile home keeps a plain mkdir
MATRIX_RECOVERY_KEY_OUTPUT_FILE is an operator path (the docs example is
/secure/path/...). Through mkdir_under_hermes_home an elevated Windows run
ACL-repaired that directory and everything under it. Take the boundary only
when the key directory sits inside a named profile home.

Patch and test by BearHuddleston (review 6019624984).

Co-authored-by: BearHuddleston <196404565+BearHuddleston@users.noreply.github.com>
2026-11-24 03:03:06 +05:30
kshitijk4poor
4fc866bae7 fix(profiles): platform adapters never recreate a deleted profile home
Eight writers in gateway platform plugins still created their directory with a
raw mkdir(parents=True) under the active profile home. An adapter bound to a
named profile that was deleted or renamed meanwhile brought profiles/<name>/
back on its next write (tracker #155595 U3, part 2 of #9).

They now go through mkdir_under_hermes_home; each keeps its existing handling:
- Google Chat thread-count store: skipped, counts stay in memory;
- Feishu comment pairing: raises, so an approval is never reported saved;
- Matrix crypto store (connect and E2EE setup) and recovery-key target and
  write: refused through the existing reason / warning / abort paths;
  line-neutral (the adapter is over the 2000-line cap);
- the auth.json lock helper (_file_lock): raises before a lock file is created;
  Photon's stores take it before writing, so the lock recreated a renamed home
  first. Line-neutral (auth.py is over the cap);
- Photon auth.json: raises to the auth caller;
- Photon sidecar mirror: falls back to the source dir like a read-only one;
- WhatsApp secondary bridge-port record: raises into connect's existing
  OSError handling;
- WhatsApp Cloud inbound media cache: the media is dropped like a failed
  write.

Each gets a delete+rename regression that fails on main and on a raw-mkdir
mutant.

Co-authored-by: BearHuddleston <196404565+BearHuddleston@users.noreply.github.com>
2026-11-24 03:03:06 +05:30
unsupportedpastels
fa537e5882 feat(solstice): offer Gemini 4 Hydrogen, Neon and Carbon
The per-user-quota endpoint exposes no model listing to user tokens, so the
picker shows the hardcoded fallback list. Add the Gemini 4 Hydrogen, Neon and
Carbon IDs. Hydrogen goes first, so it becomes the default model for new
Solstice users (wire snapshot regenerated for solstice only); lite stays last
as the quota reserve.
2026-11-23 15:11:07 -05:00
unsupportedpastels
4c2cceb34b refactor(plugins): one listing helper for context engines and cron schedulers
discover_context_engines and discover_cron_schedulers built their rows with the same conditional
comprehension. It now lives once in plugin_loader.list_category; both listings return the same rows
as before.
2026-11-23 11:44:18 -05:00
unsupportedpastels
4de231797f refactor(plugins): listings read config.yaml through the uncopied cached view
read_plugin_choice only reads the selection and the plugins.enabled / plugins.disabled lists, so it
now uses load_config_readonly(), which returns the same values without copying the cached config.
Its docstring now says what a config.yaml that does not parse means: its last good copy when one
was kept, else the defaults.
2026-11-23 11:44:18 -05:00
unsupportedpastels
56b3d07d33 fix(plugins): a selection that names the built-in turns no listed plugin on
context.engine: compressor (also the default) and the cron.provider values that pick the built-in
ticker (empty, builtin, in-process, inprocess) never load a plugin, but the listings counted them
as choosing a user plugin folder with the same name, so listing context engines or cron
schedulers ran its code. Those values now select nothing for a listing; a folder with such a name
still runs for a listing when plugins.enabled names it. Memory listings do not read the selection,
so they are unchanged.
2026-11-23 11:44:18 -05:00
unsupportedpastels
1d4b208bda fix(memory): listing memory providers no longer loads one that is turned off
A user-installed memory provider that plugins.disabled lists (by its
directory name, provider name or manifest name) is no longer imported
while memory providers are listed. The dashboard Plugins page, `hermes
memory status`, `hermes memory setup` and the `hermes plugins` memory
picker still show it with its manifest description and the same
"turned off" status and notice as before, and selecting it is still
refused the way the loader already did.

Every other provider is listed exactly as before: bundled providers,
pip-installed providers and user providers that are not turned off are
still loaded to report their real availability, whether or not they are
enabled or selected, so the dashboard readiness check keeps working.
2026-11-23 11:44:18 -05:00
unsupportedpastels
06f5ec11a9 fix(plugins): a context engine or cron provider in plugins.disabled stays off when selected
The memory loader already refuses a user-installed provider that
plugins.disabled lists, even when memory.provider still names it. The
context-engine and cron loaders did not: context.engine or cron.provider
naming a turned-off plugin still ran its code.

load_context_engine() and load_cron_scheduler() now share that check
(moved next to the other loader helpers, the memory module keeps using
it) and refuse a non-bundled provider in plugins.disabled before
importing it, with a warning that names the command that turns it back
on. Callers end where they do for a provider that is not found: the
agent falls back to the built-in compressor and cron to the built-in
ticker. Bundled providers are not affected.
2026-11-23 11:44:18 -05:00
unsupportedpastels
482bf3b351 fix(plugins): listing context engines and cron schedulers no longer runs plugins that are not turned on
Opening the Context Engine category in `hermes plugins`, the dashboard's
context-engine options, or any caller of discover_context_engines() /
discover_cron_schedulers() imported every user plugin whose __init__.py
mentioned the contract, to read its availability. A plugin that was only
installed, or that plugins.disabled lists, ran its code just by being
listed.

Now a user plugin directory is imported for a listing only when the
operator turned it on: it is the one context.engine / cron.provider
selects, or plugins.enabled names it under any of its spellings, and
plugins.disabled does not. Every other one is still listed, with its
name and manifest description, as not available. Selecting it by name
keeps working and loads it on the existing select path. Bundled
providers list exactly as before. config.yaml is read once per listing.
2026-11-23 11:44:18 -05:00
kshitijk4poor
31a161a6d2 fix(profiles): plugin cache and state writers never recreate a deleted profile home
Four writers under get_hermes_home() still created their directory with a raw
mkdir(parents=True). A gateway or plugin process bound to a named profile that
was deleted or renamed meanwhile brought profiles/<name>/ back on its next
write (probed on #158270's head by @xytxg and @BearHuddleston; tracker #155595 U3).

They now go through mkdir_under_hermes_home, the #158270 boundary:
- plugin host extraction cache (cache/plugin_host/model-providers/*.json):
  skipped, and the extracted payload is still returned;
- Discord slash-command sync state: the path helper no longer creates the
  dir. Reads need none, and the write's atomic_json_write already creates it
  through the boundary. A refused write ends in the sync's existing
  "Slash command sync failed" warning;
- Google Chat bot-id cache and the router catalog disk mirror: their
  existing OSError / Exception handlers turn the refusal into a skip.

Each gets a delete+rename regression that fails on main and on a raw-mkdir
mutant.

Co-authored-by: BearHuddleston <196404565+BearHuddleston@users.noreply.github.com>
2026-11-23 15:16:35 +05:30
kshitijk4poor
da8e7d71ab test(profiles): pin the review-surfaced branches of the profile lifecycle fixes
Optional nits from BearHuddleston's approving reviews of #158223, #158271,
#158272, #158273 and #158211 (tracker #155595, issuecomment-7059727896),
each one of his tested patches unless noted:

Tests, each catching a mutant that passed the whole suite before:
- F06: a Windows WinError 5 with nothing at the destination stays raw
  (the os.path.exists() half of publish_staging's fallback).
- F16 Edge A: the popped-adapter clause of the unserve finally guard.
- F07: import and rename onto an unfinished delete name it (ported to the
  `incomplete` record main now writes); record_delete_finished's silent
  FileNotFoundError; an unreadable record reads as incomplete.
- F10: the throwaway plugin host is stopped and its registrations
  disposed; the channel-lost test closes the channel the read-error way,
  so the child no longer exits on its own inside the asserted window.

Docs and dead code:
- F16 Edge A: _hold_secondary_claims docstring.
- F10: unused contextlib/Callable/Iterator imports; the developer guide
  says the hooks run in a plugin host of their own.
- F09-1: share_auth comment and mirror_launch_credentials docstring follow
  the _logins_home rule.

Co-authored-by: BearHuddleston <196404565+BearHuddleston@users.noreply.github.com>
2026-11-22 15:50:29 +05:30
kshitijk4poor
291a187f4f fix(memory): a profile hook load claims no @ prefix
The context-reference prefix table is process-wide and keyed to the claiming
manager. A load through the hook's throwaway manager would hold the prefix
past its stopped host, so the profile's own load of the same plugin was refused
it and @<prefix>: raised PluginHostUnavailable. A load with an explicit manager
now skips register_context_reference; the profile's shared load claims it.

Co-authored-by: BearHuddleston <196404565+BearHuddleston@users.noreply.github.com>
2026-11-22 02:31:32 +05:30
kshitijk4poor
859d90e90f fix(memory): run the profile-created hook in its own throwaway plugin host
With plugins.isolation: host, notify_memory_provider loaded the new
profile's memory provider through that profile's shared plugin manager and
host, then on exit disposed every registration the provider key had gained
and stopped the host if it had started inside the block. A real load of the
same profile's provider during the hook (the dashboard serving the new
profile) lost its registrations, and an in-flight call failed with
PluginHostUnavailable (#155595 F10).

transient_plugin_host() now yields a throwaway PluginManager for the
profile's home with a distinct scope key ("<home>#transient"), so
_BARE_MODULE_SCOPE and the scope-keyed registries never merge it with the
shared manager. load_memory_provider gains a private manager= argument,
threaded through _load_provider_from_dir and _ProviderCollector, used only
by the hook path. On exit the block unloads that manager and stops its own
host; the shared manager and host are never touched.
provider_registration_scope is removed (its only caller was this path).
Every other caller keeps get_plugin_manager(). PluginHost uses only stdio
pipes, with no per-home socket, lock or pid file, so two hosts for one
home cannot collide.

For plugin authors: with plugins.isolation: host, on_profile_created and
on_profile_renamed now run in a separate host process from the profile's
shared host. Module-level state set up by the shared host's import is not
visible to the hook. Registrations the hook load makes are disposed when
it returns, as before. Bundled providers (in-process) and
plugins.isolation: in_process do not change. No bundled or in-repo
provider implements either hook (only the MemoryProvider base no-ops).

Test: the hosted seams module gains a hook that loads the provider through
the shared manager while it runs; the shared host, its registrations and
its next call survive. Red on origin/main, green here.
2026-11-22 02:31:32 +05:30
kshitijk4poor
c12d6009e6 fix(achievements): fall back to the local data dir only when plugin_storage is missing
_data_dir caught every exception from plugin_data_dir, so its dead-home refusal
was retried by the standalone fallback (which refused again, through the same
guard). The fallback now catches ImportError around the import alone.
2026-11-22 02:17:23 +05:30
kshitijk4poor
921c25e917 test(achievements): the compaction test creates the data dir its _data_dir stub returns
_write_json no longer repeats the parent mkdir (the real _data_dir creates the
directory through the home boundary), so a stub that returns a not-yet-created
path must create it, as the real one does.
2026-11-22 02:17:23 +05:30
kshitijk4poor
72b67603d4 fix(plugins): a2a conversation log and achievements writes refuse a dead profile home
persist_message runs right after every a2a security.audit call (inbound,
reply, and the a2a send tool) and still created
get_hermes_home()/a2a_conversations with a raw mkdir(parents=True), so a
session bound to a deleted or renamed profile recreated profiles/<name>.
It now goes through mkdir_under_hermes_home and, like audit, skips the
write. The test drives the real tools._send_task after a delete and a
rename.

The achievements _write_json no longer repeats the data-dir mkdir that
_data_file already did; that second mkdir could only rebuild a home
removed in between. Adds tests for the _data_dir standalone fallback,
for _write_json, and for the disk-cleanup _handle_slash liveness guard
(an unrelated FileNotFoundError on a live home still raises), and fixes
the _on_post_tool_call docstring.

Co-authored-by: BearHuddleston <196404565+BearHuddleston@users.noreply.github.com>
2026-11-22 02:17:23 +05:30
kshitijk4poor
a81ecc281f fix(disk-cleanup): say a cleanup cut short by a deleted profile may have removed files
quick and deep can delete tracked files before save_tracked() refuses the
missing home, so "disk-cleanup did nothing" could be false. The reply now
says disk-cleanup stopped and already-removed files stay removed.
2026-11-22 02:17:23 +05:30
kshitijk4poor
8f239226bc fix(plugins): plugin writes refuse a deleted or renamed profile home
A session still bound to profile b survives `hermes profile delete b` and
`hermes profile rename b c`. Its next plugin write recreated profiles/b
through a raw mkdir, and nothing raised.

Seven plugin state writers now create their directories through
mkdir_under_hermes_home, which refuses a missing or tombstoned named home
with its existing FileNotFoundError: plugin_data_dir (and the
hermes-achievements fallback that duplicates it), the CLI plugins dir,
the update-check markers, disk-cleanup state, the Discord recovery ledger,
the Weixin account dir and the A2A audit log.

Callers that already catch keep skipping the write (Discord recovery,
the update-check writers, the disk-cleanup session-end hook and audit log,
the A2A audit). The disk-cleanup slash commands reply that the profile no
longer exists instead of raising. plugin_data_dir documents the refusal.
2026-11-22 02:17:23 +05:30
BearHuddleston
aeb5a07106 fix(telegram): a late plugin's group-99 handler runs ahead of the observer
Some checks failed
Skills Index Freshness Check / check-freshness (push) Has been cancelled
Skills Index Freshness Check / check-catalog-cors (push) Has been cancelled
Deploy Site / deploy-vercel (push) Has been cancelled
Deploy Site / deploy-docs (push) Has been cancelled
Docs Search Monitor / probe (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
PTB's Application.add_handler creates a group by keying it on the
current dict and then replacing app.handlers with a new sorted dict.
_register_handlers kept a reference to app.handlers from before core
registration and read the core handler ids from it afterwards, so only
the first group created during registration was recorded. When no
plugin had a handler at connect (the usual late-install case), group 0
was recorded and the group-99 gateway_platform_event observer was not.
A plugin loaded mid-run that registered a group-99 handler was then
appended behind that catch-all TypeHandler(Update), and PTB, which runs
the first matching handler per group, never ran it. A plugin present
at connect already sat ahead of the observer, so the late re-wire did
not match connect as documented.

The core ids now come from the live table after registration, minus
the handlers that were there before it (the plugin handlers wired at
connect), so a late handler lands after earlier plugin handlers and
ahead of the observer, as at connect.

Ahead of the observer is the order connect already uses, and nothing
the observer does depends on running first: dispatch is counted in
TelegramApplication.process_update, an observer's return never
completes an admission claim (4a2b984fd2), and a plugin callback
accepts the claim on entry. For an update the plugin's own group-99
handler matches, the observer does not emit gateway_platform_event,
the same trade-off as for a plugin wired at connect; updates it does
not match still reach the observer.

The gateway test's _PtbApp appended with setdefault, which hid the
swap; it now mirrors PTB 22.8. A real-PTB dispatch test covers both
load orders where python-telegram-bot is installed. The snapshot came
with the late re-wire in 21d0b12958 (#119266).

Reported-by: AliZakaee (#152827)
2026-11-21 01:30:48 -06:00
BearHuddleston
e75272d80e fix(telegram): read ParseMode from telegram.constants in vault-code prompts
telegram_vault_code.py landed after this PR was first written and imported
ParseMode from plugins.platforms.telegram.adapter at both send and card-edit
sites. On a first gateway run after on-demand python-telegram-bot install,
that sibling copy still binds ParseMode = None while only the running
hermes_plugins copy is rebound, so send_vault_code_prompt raised
AttributeError and _mark_vault_code_card failed silently.

Read ParseMode from telegram.constants at both sites and extend the lazy
install probe to exercise send_vault_code_prompt and _mark_vault_code_card.
2026-11-20 23:55:04 -06:00
Kevin Rajan
da753b1b2e fix(telegram): preserve disconnected draft result before lazy PTB install
Credit BearHuddleston for the first-run draft fix and AliZakaee for reporting the lazy-install problem.
Keep the no-bot failure contract while the optional Telegram dependency is still absent.

The ParseMode import now runs after the no-bot guard: a disconnected adapter returns
not_connected again instead of raising ModuleNotFoundError when python-telegram-bot is
missing. The added probe assertion fails on d1f52f77f2 and passes here.

(cherry picked from commit bda1e423d754b07aa65f8cbd7af3b929803cc40f)
2026-11-20 23:55:04 -06:00
BearHuddleston
aa0400f06d fix(telegram): drafts stream on the first gateway run after the on-demand python-telegram-bot install
send_draft read ParseMode from plugins.platforms.telegram.adapter, but the gateway
runs the hermes_plugins.platforms__telegram.adapter copy. When python-telegram-bot is
missing at plugin load, both copies bind ParseMode = None, and the registry's
installer (check_telegram_requirements) rebinds only the running copy. The first
draft frame then raised AttributeError ('NoneType' object has no attribute
'MARKDOWN_V2'), the stream consumer logged it at DEBUG and turned drafts off, and
every DM turn streamed through edits until the gateway restarted.

Regression from 7222595b82 (#151863), which moved the send_draft body out of
adapter.py, where it read the running module's global. ParseMode now comes from
telegram.constants at call time, as standalone.py already does.

The new test runs real plugin discovery with telegram blocked, then the registry's
create_adapter install path, and asserts the first draft goes out as MarkdownV2.

Reported-by: AliZakaee (#152827)
2026-11-20 23:55:04 -06:00
Teknium
f6c3eb1a79 docs(plugins): the catalog import check warns, it no longer fails a PR
plugins/AGENTS.md still said scripts/ci/catalog_core_imports.py fails a core PR
and offered the breaks-catalog-plugin label. Since f998a982cb the check only
warns (naming each lost core name, whether it is private, and each plugin's
catalog entry, repo and line) and the label is gone. The sentence also moves
after Boundary lint's `--update` lines, so those no longer read as options of
the catalog check (BearHuddleston's suggestion on #157986).

Co-authored-by: Bear Huddleston <196404565+BearHuddleston@users.noreply.github.com>
2026-11-20 08:34:47 -08:00
Teknium
d45aac385e feat(ci): name the pinned catalog plugins a core PR breaks, before it merges
Catalog plugins live in their own repos, pinned by sha, and many import Hermes modules that are not
on the published plugin API. When a core PR removes or renames such a module or name, nothing in
this repository's CI sees it: the plugin's code is not here. This week the storage rewrite broke
three that way (OpenViking via agent.message_content, Honcho via hermes_state_common, holographic
via hermes_state_wal: #157818), each found only after users upgraded.

- scripts/ci/catalog_core_imports/ (31 shards, ~780 KiB) records every Hermes import each of the
  2,514 catalog entries makes at its pinned sha, parsed by
  plugin_validate_private_imports.hermes_import_sites (the same parser `hermes plugins validate`
  uses). An import inside a try that catches ImportError carries its alternatives, so a plugin
  that already falls back is not reported.
- `catalog_core_imports.py check` (Repository guards, PR python lane) resolves each import against
  the base and the merge commit from git objects alone: no network, no plugin code, nothing
  imported. It only resolves imports whose module files the PR touches (every import when
  compat/moves.py changes): 0.3 s on a typical PR, 2-3 s on the storage-rewrite commits.
- On failure it names plugin, file:line and import, and offers: open a PR for an official seam
  (ctx method, hook, plugin_api.json entry), keep the old name via compat/moves.py, or the
  breaks-catalog-plugin label.
- catalog-core-imports.yml re-indexes added or repinned entries daily and opens a bot PR.

The check asks only whether a name still exists; a name that stays but changes behaviour or
signature passes.
2026-11-20 08:06:29 -08:00
kshitijk4poor
0eeb0f4adf fix(vertex): send xhigh to Gemini 4 Hydrogen and Neon on Vertex too
The vertex profile never applied the gemini plugin's xhigh step, so xhigh/max/ultra
reached google/gemini-4-hydrogen and google/gemini-4-neon as thinking_level "high".
The model set and the step move to agent.reasoning_effort (next to
GEMINI4_THINKING_LEVELS) and both profiles call it; Argon and Carbon still cap at high.
2026-11-20 16:38:21 +05:30
Gabby Ong
845acdd9e9 feat(gemini): add Gemini 4 Neon and its xhigh thinking level
Adds gemini-4-neon to the Gemini provider catalog and official pricing snapshot ($3/$15/$0.15 per 1M input, output, and cache-read tokens) while keeping gemini-3.8-flash as the silent default. Enables the xhigh thinking level for Gemini 4 Neon alongside Hydrogen on xhigh, max, and ultra efforts, inheriting the existing 1M context window, 64K single-request cap, long decode continuation, and Interactions API routing.
2026-11-20 16:38:21 +05:30
kshitijk4poor
ac646d1f59 fix(memory): the parked-provider enable command names the inspected home through HERMES_HOME
A bare or -p command still depended on the shell that ran it: a named launch inspecting the
default home, or a custom root copied into a shell with HERMES_HOME unset, enabled another home
and left the inspected one parked. The command now always says which HERMES_HOME to set, plus
-p default when that home is not profile-shaped (profile_root_for_env_home). The notice reads
config once for the update record and the selected provider.
2026-11-20 15:44:41 +05:30
kshitijk4poor
d494004173 fix(memory): the parked-provider enable command targets the home that printed it
A bare hermes follows the sticky active_profile, so a default-home notice copied into a shell
whose sticky profile is another one enabled the provider there. The default home now drops -p
only while no other profile is sticky, and a home outside the profile tree is named with
HERMES_HOME plus -p default.
2026-11-20 15:44:41 +05:30
kshitijk4poor
ac15954199 fix(memory): the panel says plugins.disabled parks a provider instead of a bare load failure
A provider-owned config panel (storage=provider) answered a provider parked in
plugins.disabled with "could not be loaded; see the logs" (#149402 follow-up).
It now returns parked_provider_notice, the notice the CLI, doctor and agent show.

The notice now says "external memory is off" only when the parked provider is
the selected memory.provider; the panel can inspect any provider while another
stays active. Its enable command carries `-p <profile>` for a named profile
(profile_cli_selector), so a ?profile=work panel names the profile it reads.
2026-11-20 15:44:41 +05:30
Maciej Lisiewski
e97efa9c35 fix(feishu): import the card mixins package-relative so a reload reaches cards/
adapter.py still imported adapter_choice_cards and adapter_synthetic_events by absolute path, so their own `.cards` imports resolved to plugins.platforms.feishu.cards, which a plugin reload never evicts: clarify/choice clicks and synthetic events kept running the pre-reload card helpers. The reload test now overrides the helpers in the copied cards/authz.py and drives the chat-info, clarify and synthetic-event lanes.

Co-authored-by: BearHuddleston <196404565+BearHuddleston@users.noreply.github.com>
2026-11-19 15:23:56 +01:00
Maciej Lisiewski
797be253e1 refactor(feishu): card authz as a cards/ package imported package-relative
The directory loader imports the plugin as hermes_plugins.<slug> and evicts that
namespace on reload; the absolute import of adapter_card_authz registered it under
plugins.platforms.feishu.*, so a reload kept serving the old helpers. The six
helpers become plain functions in cards/authz.py (the adapter is passed in), the
FeishuCardAuthzMixin base goes away, and every consumer imports `.cards`.

test_feishu_table_markdown.py loaded adapter.py with no parent package, which a
relative import cannot resolve; it now imports the adapter from its package.
Card-authz log records now come from the ...feishu.cards.authz logger.

Co-authored-by: BearHuddleston <196404565+BearHuddleston@users.noreply.github.com>
2026-11-19 14:46:56 +01:00
Maciej Lisiewski
bf353ddde6 refactor(feishu): move card-click authz and chat-mode mapping into adapter_card_authz
adapter.py is far over the 2,000-line cap and may only shrink; this PR had grown it.
Pure move of _is_interactive_operator_authorized, _validate_card_action,
_pop_validated_prompt_state, _map_chat_type, _resolve_source_chat_type and
_cached_chat_type into a FeishuCardAuthzMixin, following adapter_choice_cards /
adapter_synthetic_events. adapter.py: 4,451 on main -> 4,366.
2026-11-19 14:46:56 +01:00
winple
6bb6ea065f fix(feishu): derive chat type from raw_mode, not raw_type
get_chat_info mapped _map_chat_type(raw_chat_type) where raw_chat_type is
private/public (visibility). The mapper expects p2p/group/topic (conversation
mode), so all private-visibility chats fell through to the "dm" default.

- Pass raw_chat_mode to _map_chat_type (root cause)
- _cached_chat_type now derives from raw_mode directly (defense-in-depth)
- Add counterexample tests: private+group->group, private+topic->forum
2026-11-19 14:46:55 +01:00
winple
b3d632df07 fix(feishu): resolve card-click chat type from cache and try every operator id form
The gateway-check fallback in _is_interactive_operator_authorized (added in
PR #145582) rejects every interactive-card click of a gateway-admitted user:
errors.log shows "[Feishu] Unauthorized approval click by ou_..." per click
and the approval times out as deny, while the same user's DM messages are
processed normally.

Two defects in the fallback path:

1. Chat type hardcoded to "group". A DM click was judged by the group policy
   (empty FEISHU_ALLOWED_USERS -> deny), not by DM admission. Resolve the
   real dm/group/forum type from the chat-info cache the message lane warms
   (a card only exists because a message reached that chat); cache misses
   stay "group" (fail-closed).

2. Single principal. The check was given one id form (tenant user_id, else
   open_id) while pairing records another form (e.g. the open_id "ou_..."
   in pairing/feishu-approved.json), and _user_id_aliases does not bridge
   Feishu's open_id/union_id/user_id tiers. Try every operator id form,
   primary first, short-circuiting on the first pass -- the same any-form
   identity the allowlist branch above already applies.

Both fixes are in the one fallback, so they cover approval cards,
update-prompt cards, and both loop-side rechecks with a single change.

Tests: tests/gateway/test_feishu_card_action_gateway_authz.py gains
TestCachedChatTypeResolution (4 tests) and TestIdFormFallback (3 tests).
The whole file passes (24 tests) and the broader -k "feishu or approval or
interactive" gateway suite shows no new failures versus the unpatched tree.
2026-11-19 14:46:54 +01:00
kshitijk4poor
8d70b88abd docs(discord): say who syncs after a mid-refresh client replacement 2026-11-19 12:32:41 +05:30
kshitijk4poor
c1a3cb0e83 refactor(discord): move slash-command registry diff into adapter_command_sync
adapter.py is far over the file-size cap and this PR grew it. Move the
payload canonicalization, the safe per-command sync, and the install-scope
helper into a DiscordCommandSyncMixin module; adapter.py ends 133 lines
shorter than main. Code is moved unchanged.
2026-11-19 12:32:41 +05:30
kshitijk4poor
7c33ac97b9 fix(discord): tie the app-info memo to its client
A reconnect could replace the client while application_info() was in
flight, and the old client's result was then stored and applied to the new
one. Capture the client before the call, and stop if it changed by the time
the call returns; the new client's READY runs its own sync. Clear the memo
when connect() builds a new client and on disconnect, so it no longer holds
a closed client.

Tests: named scope scenarios, including a new client ignoring the old
client's refresh and a replacement mid-refresh; the reconnect test asserts
the memo is cleared.
2026-11-19 12:32:41 +05:30
kshitijk4poor
32bceb33b8 fix(discord): bound the app-info refresh and keep its last good result
Bound the application_info() refresh at 15 s so a stalled call can't hold
post-connect forever. When it fails, reuse the last refresh for the same
client instead of the login-time snapshot, which can be older than settings
already synced; the snapshot is used only before any refresh succeeded.

Tests: one subprocess runs every scope case, adding the failed-later-refresh
and changed-between-READY cases; the remaining safe-sync test uses
_sync_adapter.
2026-11-19 12:32:41 +05:30
kshitijk4poor
1ba9016a3b fix(discord): upsert on mixed drift and refresh app info before syncing
A command whose description AND install types both differed took the PATCH
path. discord.py's edit_global_command sends only name/description/options,
so the install types stayed stale while the sync recorded success, and the
fingerprint then skipped every later start. Upsert whenever anything a PATCH
cannot carry differs.

Read the Installation settings from a fresh application_info() at each sync
instead of the login-time snapshot, which a reconnect reuses after a settings
change. A failed refresh falls back to the snapshot.

Tests: share _sync_adapter across the safe-sync tests, cover mixed drift and
description-only edits, and cover the refresh and its fallback.
2026-11-19 12:32:41 +05:30
kshitijk4poor
779cee6e68 fix(discord): set command install types from the app's Installation settings
Hermes left integration_types/contexts unset, so each command kept whatever
Discord stamped on it at creation. Commands created while the app was
user-install only stayed integration_types=[1]; other members of the bot's
server got "Unknown Integration" on /new, /status, /model, /stop and /reset,
and no sync could repair them.

Derive both from the app's own Installation settings (application_info's
integration_types_config, already fetched at login) before every sync. The
hardcoded [0,1]/[0,1,2] would be refused by Discord on a guild-install-only
app: a command can only use install types the app enables, and the
private_channel context needs user install. When the settings are
unavailable the tree stays unset, as before.
2026-11-19 12:32:41 +05:30
Andy
4504606a39 fix(discord): preserve scope drift recreation 2026-11-19 12:32:41 +05:30
Andy
dc1b4a9902 Fix Discord guild slash command visibility 2026-11-19 12:32:41 +05:30
Jarvis
4bd86568d0 fix(discord): diff slash commands against the raw registry #104399
discord.py parses zero-based integration types and contexts lossily. Discord also fills defaults for install fields Hermes leaves unset, producing perpetual false diffs.
2026-11-19 12:32:41 +05:30
Teknium
b1db37d2b9 fix(compat): carry only the turn helpers pinned catalog plugins import, until v0.27.0
Some checks failed
Skills Index Freshness Check / check-freshness (push) Has been cancelled
Skills Index Freshness Check / check-catalog-cors (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
Deploy Site / deploy-vercel (push) Has been cancelled
Deploy Site / deploy-docs (push) Has been cancelled
Review follow-up. The compat layer now keeps exactly the old imports the
catalog's OpenViking 2.1.2 and Honcho 1.2.0 pins make at load time, and
says so:

- agent.context_compressor_retry is no longer aliased (no catalog plugin
  imports it), and agent.skill_commands re-exports only
  extract_user_instruction_from_skill_message (neither pin imports
  register_auto_load_scaffold).
- moves.py admits a folded module only when a catalog-pinned plugin
  imports it.
- plugins/AGENTS.md and the plugin guide record the exception: which
  names, where they live now, and that they follow the hermes_state
  stand-in's window (removed no earlier than v0.27.0).
2026-11-18 11:31:39 -08:00
Teknium
1f0103a89f fix(compat): plugins that import a module the storage refactor removed load again
The storage interface (#149567, db4d50b9e7) folded agent/message_content.py and
agent/context_compressor_retry.py into session_rules/turns.py, and moved
extract_user_instruction_from_skill_message / register_auto_load_scaffold from
agent/skill_commands.py to the same module. Catalog plugins still import the old
paths at module top level, so they never registered: OpenViking 2.1.2 (the pinned
memory provider) and hermes-council fail with "No module named
'agent.message_content'", OpenViking then with "cannot import name
'extract_user_instruction_from_skill_message' from 'agent.skill_commands'", and
Hermes silently ran on built-in memory.

- MOVES gains agent.message_content and agent.context_compressor_retry ->
  session_rules.turns; the target defines every name each published, byte-identical.
  No other module the stack deleted is aliased: the 35 hermes_state_* modules were
  mixins or SQLite-backend helpers whose functions now take a store holder instead of
  a SessionDB (an alias would import and then fail on call), and
  gateway.session_admission's admission_fingerprint has no catalog importer.
- agent.skill_commands re-exports the two skill-scaffolding helpers it published.
- A plugin package whose __init__.py raises now propagates that exception from
  load_plugin_module instead of returning None, so the memory, context-engine,
  cron and computer-use loaders' one WARNING line names the real error rather than
  "loaded but no provider instance found". The bundled delegation fallback and
  import_provider_module keep their contracts (None / ImportError) and carry the text.

Fixes #157438
Part of #157077
2026-11-18 11:31:39 -08:00
Teknium
8116fa3e90 feat(caching): Nous models get cache markers when the catalog prices a cache write; 1h writes billed at the catalog rate
Nous Portal's /v1/models lists input_cache_write for every model that takes explicit cache_control
(Claude, Qwen 3.7/4, Gemini, GPT-6, ...). The nous profile declares prompt_cache_markers_from_catalog,
so the marker policy reads that rate: priced -> markers at the tier asked (Anthropic spec, declared),
unpriced -> no markers (OpenAI spec, 30m). Measured on qwen/qwen3.7-max: without markers its automatic
cache missed at 4 min; with a 1h marker it still hit after 13 idle minutes, the write billed at 1.25x.
Pricing now takes a catalog's input_cache_write_1h (Claude: 2x) or its single write rate for 1h writes
instead of a fixed 2x.
2026-11-18 03:40:34 -08:00
Teknium
bf6a59f336 feat(caching): Nous Portal gets the full prompt-cache lifecycle (1h declared)
The Portal now keeps Claude's 1h tier: a raw probe read a 13.2k-token 1h prefix back from
cache after 7 and after 25 idle minutes, with its write billed at 2x (the 5m control rewrote).
The Nous profile drops its 5m ceiling and declares prompt_cache_max_ttl="1h" instead, so the
wire asks for 1h under cache_ttl auto and the clock declares it (route_ceiling_1h): human chats
on Nous now warm x3 on the 1h schedule, compact at the budget's end/release, and offload on a
cold return like Anthropic and OpenRouter. Without a declared ceiling a 1h ask on an
Anthropic-wire gateway stays unproven (gateway_1h_untrusted), which would leave Nous with no
lifecycle at all.

route_ttl_ceilings stays: tests that exercised the clamp now set {nous: 5m} in their temp config.
Docs drop every 'Nous is 5m' sentence; the Nous wire snapshot gains ttl 1h on its markers.
2026-11-18 03:40:34 -08:00
100yenadmin
8cb040b214 fix(caching): auto re-resolves after a platform stamp and at request time
Agents stamped as gateway_hygiene after construction (hygiene and manual
/compress) re-resolve their auto tier after the stamp, so they stay on 5m
while context engines still bind to the real platform at construction.
Request-time clamps carry the auto flag, so a session that moves to Bedrock
mid-session under auto drops to 5m; an explicit 1h pin is kept. The Feishu
comment agent change is reverted (it changed the system prompt, not the tier).
2026-11-18 03:40:34 -08:00
100yenadmin
68c9cd437f fix(caching): auto keeps one-shots, background tasks and automation sources on 5m
Gateway-routed one-shots (hermes -z, chat -q), messaging /background, a2a and
msgraph_webhook sessions, the gateway hygiene agent and the Feishu comment
agent are machine-paced and now resolve to 5m under auto. Bedrock resolves to
5m under auto (legacy Claude models there accept only 5m); an explicit 1h pin
is kept. Interactive CLI, TUI, Desktop, ACP and messaging chats stay on 1h.
2026-11-18 03:40:34 -08:00
yoniebans
aa768b20d4 test(gateway): the newer Telegram and session cases run over the persistence interface
Main's new or changed cases that seeded or read the old store run on the storage interface with main's assertions: the observed transcript timestamp, the observe-mode /resume ownership guard, the dead private topic prune and the kept binding of an unconfirmed send, the oversized file admission, the idle /new that drops a held burst, the adoption of a chat on an external-process provider, and the send-path recovery sweep after a profile stop. Rows are seeded through the storage handle, the ledger's store follows the test's HERMES_HOME, and each authority's stores close by profile folder.

The private topic send ladder's docstring names the interface verb that prunes a dead topic's binding.
2026-11-17 17:51:22 +01:00