Symptom: in a classic `hermes chat` session on the shared gateway, /cron
add|edit|pause|resume|run|remove still ran main's handler in the CLI
process, which called the cronjob tool there and wrote the profile's
cron/jobs.json from the client. Under strace, every write to jobs.json
came from the `chat --cli` process and none from the gateway.
Root cause: the one-gateway runtime (#106742) made the gateway the
owner of the profile's runtime state and of the ticker that fires cron
jobs. It left CLICommandsMixin._cron_* in the client, and the
gateway's slash.exec refused /cron for every local session except TUI
reads (2efe028116). That left the cron store with two writers.
Change:
- Move main's /cron handler (overview, list and every write) into
hermes_cli/cli_cron_lines.py as line builders (cron_command_lines),
with no other behaviour change. The CLI prints them when it has no
gateway session. The unused CLICommandsMixin._cron_list goes; its
test and eval read cron_list_lines directly.
- On the gateway, /cron is an owner command
(gateway/session_cron_commands.py). Bare /cron and `list` are reads
for every local session; that includes Desktop- and ACP-created
sessions, which main refused with unsupported_command. Every other
form is an admission-fenced control. An unclosed quote is refused as
invalid_params before pre_command fires. `/cron list -a` keeps the
list-all alias that the TUI read path accepted.
- A /cron write runs only when it arrives on a connection that is not
attached to the session: the classic CLI's own command socket
(GatewayConnection.call_until), which waits with no deadline. A
connection attached to the session keeps main's unsupported_command.
That is how Ink, Desktop and ACP send /cron: on their main
connection, which the gateway answers one request at a time and
which waits with a deadline, while a /cron run lasts as long as its
job. The gate is on the requesting connection, not on the surface
that created the session, so a classic CLI that resumed a TUI-made
session still writes (as on main), and Ink on a CLI-made session is
still refused.
- The classic CLI sends /cron to slash.exec
(gateway_setting_commands.GATEWAY_SETTINGS) with no deadline, on a
socket of its own (gateway_plugin_commands.call_unbounded, now shared
with plugin commands; its Ctrl+C handle is renamed
_gateway_command_wait). Ctrl+C prints the stopped line and
propagates.
- Regenerate the parity table. test_pre_command_in_gateway pinned the
old refusal of every classic CLI /cron; it now pins that the accepted
/cron forms fire pre_command once and a refused one (an unclosed
quote) fires nothing.
Why: the design contract allows one writer per owned store, and
clients only read and submit. The gateway already serves this
profile's cron store to its ticker and to Desktop (cron.manage). Now
the classic CLI's writes go through the same process.
Refs #134889 (T1)
Refs #139158
The "prototype patching" admission rule matched any `X.prototype.y =` line. A
bundled library setting fields on classes it declares itself trips it: three.js
alone hits it 29 times (`var Vector2 = class _Vector2 { constructor() {
_Vector2.prototype.isVector2 = true } }`, `KeyframeTrack.prototype.ValueTypeName
= ...`), so no Desktop plugin could ship a three.js viewer.
The write now fails only when the receiver is not a class/function the file
declares, or is a renderer/browser global (Storage, HTMLElement, Array, ...),
which keeps failing even when the file shadows it with a same-named class (a
regex cannot see scope). Every attack shape the rule exists for still fails:
`Storage.prototype.setItem = ...`, an alias of a global, a shadowed global.
A portable Agent Plugins v1 package (plugin.json) had no way into Settings >
Plugins: the schema reader only looked at plugin.yaml, and v1 rejects unknown
top-level fields. It now reads extensions.com.nousresearch.hermes.config_schema
(the vendor namespace that already carries server trust and timeouts) for the
form, the save, the loader's schema warnings and catalog admission.
Two gaps any plugin with settings hit once the form existed:
- The plugin's Desktop half had no way to learn a save happened. Every
plugins.manage settings save now broadcasts plugin.<id>.settings.changed
({written}); a secret-only save still makes the (empty) settings call so the
event fires for a new API key too.
- A secret the form stored never reached the plugin's running MCP server (its
env ${VAR} was rendered at spawn). After a save, Hermes reconnects the plugin's
servers whose resolved launch inputs changed (identity digest, rendered the way
the connect path renders it); a toggle-only save leaves them alone.
A revoked grant kept its dead access and refresh tokens on disk; it now keeps only the marker
and fingerprint. hermes plugins remove drops the plugin's grants, so a later plugin installed
under the same key does not inherit the sign-in, and hermes auth logout <plugin>:<id> still
removes a grant after the plugin is gone. hermes auth add refuses to run from the gateway, cron or
an agent session and says which hosts get the code, the client secret and the token first.
Maintainer requirement on #139985: authorize_url, token_url and hosts are https at manifest
validation and catalog admission, with no loopback http exception. client_id_env and
client_secret_env may not name a variable Hermes itself uses (a provider API key, a platform
token): Hermes POSTs those values to the manifest's token_url, so a manifest naming
OPENROUTER_API_KEY would have sent it there. A host outside the IdP's domains is a reviewer
warning, and the install notice names the sign-in host.
Microsoft and Notion were named without being tried against this route, and
Notion's token endpoint expects HTTP Basic client authentication, which the
broker does not send.
Refs #139077
The authorize URL is the page the user's browser opens to sign in. A catalog
re-pin that points it at another host now shows up in the consent delta, next
to the token host, hosts and scopes. A new path on the same host still only
changes the fingerprint, so the user signs in again.
Refs #139077
A plugin that calls a third-party API with the user's own OAuth client
(Google, Microsoft, Notion) declares it under `oauth:` in plugin.yaml
instead of running the consent flow and keeping the refresh token itself.
- `hermes auth add|status|refresh|logout <plugin>:<id>` runs the PKCE
login of auth_oauth_pkce_plugin and keeps the grant in the active
profile's auth.json (section `plugin_oauth`, keyed by the plugin's key)
- `credentialed_provider_request(<id>, ...)` attaches the bearer for the
entry's declared hosts only (https, port 443) and refreshes the grant
under the auth-store lock; the calling plugin's own entry is resolved
before `_PROVIDERS`, so a later core provider of the same name cannot
take it over
- each grant stores a fingerprint of the entry it was made for: a plugin
version that changes the token URL, hosts, scopes or client variables
gets ProviderNotSignedIn until the user signs in again
- the client secret is read with get_secret right before each token POST
(OAuthPKCEConfig.token_request) and never sits in the frozen config
- grant-dead codes retire the grant; invalid_client, unauthorized_client
and invalid_scope surface as AuthError codes; a sign-in granted fewer
scopes than declared saves nothing
- `hermes plugins validate` checks the block and the declared variables
and warns when plugin code names the token URL; install/show notices
and the catalog re-pin consent delta list the entries
Refs #139077
Follow-up to #141379 from an independent post-merge review:
- the MCP SDK re-adds its inherited set (PATH, HOME, TERM, ...) at spawn,
so popping an unset override never unset those keys. Treat the entry as
absent instead: the key keeps its baseline value, one rule for every key,
matching what the child actually receives.
- carry resolution provenance from interpolation (_RenderedStr) instead of
guessing from the rendered text, so a set variable whose value is
literally '${OTHER}' is passed through, not dropped.
Brings in #141354 (Ink T10) and the shared session.export commit already on
main. The only conflict, website/docs/developer-guide/gateway-command-parity.md,
was resolved by regenerating it with scripts/gen_gateway_command_parity.py
(--check clean); the desktop slash registry and gateway contracts --check
clean as merged.
A stdio MCP server env entry like "GHIDRA_INSTALL_DIR": "${GHIDRA_INSTALL_DIR}"
was passed to the child as the literal text "${GHIDRA_INSTALL_DIR}" when the
variable was unset. Servers that validate the value refuse to start (REA:
"GHIDRA_INSTALL_DIR must be absolute"), so a portable plugin could not forward
an optional variable, and Hermes' filtered MCP env means forwarding is the only
way a user's variable reaches the server.
_build_safe_env now drops an env entry whose whole value is still one
unresolved ${VAR}/${env:VAR} reference. Partial references, context vars and
url/headers keep their existing behaviour. Applies to config.yaml mcp_servers
and plugin mcp.json alike (same launch path).
Co-authored-by: Rodrigo Gomes <2362425+rodrigogs@users.noreply.github.com>
test_a_refused_subcommand_keeps_the_rest_of_the_command_routed still
expected Ink's /voice cell to be the sidecar's voice.toggle alone. On
the shared gateway /voice on|off|status now run the owner's per-session
/voice (slash.exec) and read the mode back (config.get); voice.toggle
stays only as the standalone backend's route. The expectation now says
so, and `/voice tts` is still refused.
Regenerated gateway-command-parity.md with its script: Ink's
/timestamps now saves through config.set on both backends.
Refs #134889 (T9, T10)
The generator's /save note still said the export file is written on the gateway host; Desktop with
a current gateway saves session.export text through its own dialog. Fix the note in
scripts/gen_gateway_command_parity.py and regenerate the table.
scripts/gen_gateway_command_parity.py output after Desktop gained /agents, /config, /history,
/export, /import and the other T11 actions; test_committed_parity_table_matches_every_client_verdict
failed on the stale table.
A person's turn lost in a gateway restart still pauses the session's FIFO
(only they know whether to resend it), but messaging told them to "ask the
operator" and the TUI queue showed a bare `[unknown]` tag.
- Messaging: the pause notice says a turn was lost in the restart and offers
`/discard` in the chat. The new gateway command resolves the chat's lost
turns through the owner's existing fenced `resolve_unknown` (the path
Desktop's Discard, the TUI queue and `hermes sessions discard` use); the
saved followers then run. Demoted to `/hermes discard` on Slack (50-slash cap).
- TUI: a lost row reads "paused: lost in restart · ↑ select, Ctrl+X discard"
(Ctrl+X on it already sends prompt.resolve_unknown).
- Desktop already shows "Turn lost during restart" with a Discard button.
Refs #134889 (GW-10)
Refs #139532
Refs #141321
Ink on the shared gateway refused /timestamps /export /import /snapshot
/handoff /hatch /palette /worktree with a bare "not available".
- /timestamps (/ts) [on|off|status] now writes display.timestamps (the
classic CLI's key) through the owner's config.set, a new display
toggle in gateway/session_tui_config.py, and repaints at once.
- The rest act on the gateway host's profiles, state snapshots,
terminal or git checkout, which the owner may not share with the
client. They stay refused (`unsupported_command`, unchanged for
shipped clients), but the refusal now carries what to use instead in
data.detail (gateway/session_commands.py REFUSAL_HINTS: `hermes
profile export|import`, `hermes backup --quick`, `hermes -w`, the
classic CLI for /handoff and /hatch, typing / for the palette). Ink
prints it under the refusal, and Desktop can do the same.
Refs #134889 (T10)
Refs #141321
(cherry picked from commit b67e44de12133ca9578f42850f7d84767c0ba25f)
Ink's /save on the shared gateway called session.save, which writes the
export on the gateway host and takes no format, filename or redact
argument. It now takes `/save [json|md|html] [filename] [redact]`, asks
the owner for the rendered transcript (session.export) and writes the
file itself: a named path against the cwd, else
<HERMES_HOME>/sessions/saved/hermes_conversation_<ts>.<fmt>.
(cherry picked from commit 11956c404bc4d9b5769c4b08cbd5683743a57363,
ui-tui and docs half; the gateway half is the session.export commit)
Refs #134889 (T10)
Refs #141321
On the shared gateway Ink refused /reload-mcp and /config by name even
though the owner serves both:
- /reload-mcp now calls the owner's session-scoped reload.mcp
(gateway/session_ancillary.py): bare asks for confirmation, now/yes/
always confirm once. The owner has no persistent opt-out, so `always`
no longer writes approvals.mcp_reload_confirm on that path.
- /config pages config.get key=full, the redacted presentation
projection (display, approvals, voice keybinding). Provider, MCP and
terminal config stay out of the client, as the projection already
decides; the full dump stays `hermes config`.
The sidecar path for both is unchanged.
Refs #134889 (T10)
Refs #141321
(cherry picked from commit 37714ad7c410e3e6c4f174436aeeb09ea3ac0df9)
On the shared gateway Ink's /voice on|off|status still called the
sidecar's voice.toggle, which flips the owner process's HERMES_VOICE for
every chat, and push-to-talk (voice.record) gated on that same env flag.
The gateway's /voice handler holds the real per-session mode.
Ink now runs `slash.exec voice <on|off|status>` and mirrors the mode the
owner reports through a new `config.get key=voice` read; startup seeds
the voice bit the same way. voice.record gates on the session's gateway
mode when the owner holds the session (the sidecar keeps its env flag
for its own sessions). /voice tts stays a named refusal (CMD-2).
Refs #134889 (T9)
Refs #141321
(cherry picked from commit 269373bb69b1a02875671d41806d7df12ab8af9f)
A local session's /voice tts set the messaging voice mode to all.
Later replies were synthesized and then dropped, because no client
can play them, and turning voice off did not clear that mode.
Refuse the form, and do not synthesize speech for a local session.
Refs #140398
Refs #134889 (CMD-2)
Refs #140719
(cherry picked from commit f2c38323515a5563c22a8eaabe2ab1993d0bd995)
The salvaged hook fired from ContextCompressor.compress(), which is not where
a compaction commits: compress_context can still refuse or roll back the
candidate (snapshot stale, commit fence, split failure), the gateway's
/compress runs its own compressor and commits elsewhere, and Codex-native,
micro-compaction and proactive-prune rewrites never call compress() at all.
session_id was also the compressor's bound id, which is stale after rotation.
Fire it from the compaction-record seam (agent/compaction_events.py) that
already sees exactly one committed record per rewrite on every agent path,
and from the gateway session.mutate compress commit. Payload: session_id (the
session holding the compacted transcript), old_session_id, kind, reason,
before/after token estimates, messages_removed. Bounded by
plugins.hook_callback_timeout, since it runs inside the commit window.
Tests trimmed to one invariant (fires once per committed compaction, never
for an aborted one, raising plugin isolated); docs in hooks.md and the
plugin guide.
Finn's state-layer hook missed the paths Desktop actually uses: single
delete and archive go through the canonical mutation receipt
(mutate_runtime_session), not SessionDB.delete_session, so a plugin never
heard about either. Archive (the "this is done" signal #132639 asked for)
fired nowhere.
- mutate_runtime_session fires after its write commits for operation
'delete' and for a real unarchived -> archived sidebar flip; an exact
retry replays the receipt and stays silent.
- set_session_archived fires reason="archive" on a real flip, so TUI
session.archive, `hermes sessions archive` and deferred TUI archives are
covered from one place. Repeats, un-archives, the idle auto-archive
sweep and profile adoption (notify=False) stay silent.
- Payload is now session_id + reason + profile on every path (profile
from the store's home), deleted_ids when more than one row went;
primary id is the one the caller asked for, not the alphabetically
first.
- One fail-open seam (emit_session_deleted) calls lifecycle.invoke_hook
directly; the extra notify_session_deleted wrapper is gone.
- Tests trimmed to two invariants against the real hook registry.
Co-authored-by: Lucas Piera <pieralukasz@gmail.com>
Widen the contributor's opt-in `source=` to the calling-session context plugins
asked for (#140199, #91526, #123245): a `ctx.register_command` handler that
declares any of `session_id`, `session_key`, `platform`, `source` (or
`**kwargs`) receives them; one-argument handlers keep `handler(raw_args)`.
- One call boundary (hermes_cli/plugin_command_dispatch.py) used by the gateway
(messaging platforms and local CLI/Desktop sessions via
`_hm_run_plugin_handler`), the TUI/Desktop RPC (`_run_plugin_command`) and
the classic CLI's off-gateway fallback. The first positional parameter
always gets raw_args whatever its name.
- Messaging plugin commands look up the chat's current session entry (never
create one), so HERMES_SESSION_ID / `session_id` are the id a later /new
reports as old_session_id instead of "" (#123245).
- Fold the contributor's separate gateway adapter module back into
`_hm_run_plugin_handler` so the local-session path shares it.
- Tests trimmed to two invariants, both red on origin/main.
Plugins that show the agent's skills (catalog views, "open this skill", drift checks against the
installed copy) need the same walk, order, search roots and lookup gate the skills_list / skill_view
tools use, plus the package hash the bundled-skill sync stores. All seven were private.
Rename, with every internal caller moved and no underscore aliases (same shape as the platform
helpers in e6cf2a9):
- tools/skills_tool.py: find_all_skills, sort_skills, skill_search_dirs, locate_skill,
skill_lookup_path_error
- tools/skills_sync.py: dir_hash
- tools/skill_usage.py: read_skill_name
The names join _PUBLIC in the private-import lint and are documented under "Read the skill catalog"
in the plugin developer guide.
Builds on #129698 by @nekwo, which proposed the same names with legacy aliases kept.
Closes#129696
Co-authored-by: nekwo <beastant1@gmail.com>
The rule-9 pointer to the platform helpers section broke the docs/README rules mirror test;
the section stays reachable from the platform adapter guide.
hermes plugins validate warned on every platform plugin's use of
OwnAccessPolicyMixin, tools.approval.resolve_gateway_approval, the clarify
button API, the SSRF client pieces and the setup-wizard helpers. Those names
join _PUBLIC and get a "Public helpers for platform plugins" section (plus
the two new PlatformEntry authz fields) in adding-platform-adapters.md.
The refusals log under agent.memory_caller_scope, which gateway.log's
component filter (gateway, hermes_plugins, plugins.platforms) dropped: on a
live multiplexed gateway they reached the profile's agent.log and
errors.log but never gateway.log, which the PR, the docs and the
chat-visible refusal all pointed at. The refusal can also happen in
hermes serve, the TUI and Desktop, where there is no gateway.log.
Add agent.memory_caller_scope to the gateway component's prefixes, and
have the generic refusal (tool error and the checkpoint RuntimeError) point
at `hermes logs errors`, which every host writes. The chat still sees no
check name and no home path.
Refs #134889 (PLG-11)
Refs #140208
On a multiplexed gateway every served profile's agents share one process.
Each agent's MemoryManager owns its own provider instance, but nothing stopped
a tool call or lifecycle hook from another profile's context, or from a
context naming no profile, from reaching it. Nothing stopped two agents being
handed one shared instance either. The in-repo providers also bound their
stores from the ambient home rather than the one the manager passed.
MemoryManager.initialize_all records the profile home (and agent_identity) it
bound its providers to. Then:
- Tool calls and every lifecycle hook (prefetch, queue_prefetch, sync_turn,
on_turn_start, on_memory_write, on_session_end, on_session_switch, the
session boundary, on_pre_compress, on_delegation) run only when the caller
explicitly names that profile: the context's HERMES_HOME override, or the
home its secret scope was built for. On a multiplexed process a caller that
names no profile is refused, never resolved to the process's own profile.
A refused checkpoint compression raises, so the transcript stays
uncompressed.
- Background hooks run under the owning profile's HERMES_HOME, set
explicitly in the worker.
- An instance another profile's manager already bound is dropped, not
re-initialized (logged as memory_provider_instance_shared). Claims are
tracked by instance identity, never by the provider's own hash or
equality; on a multiplexed process an instance that can't be tracked
(no weak reference) is refused too.
- handle_tool_call passes hermes_home / agent_identity next to the previous
commit's caller_gsk. A provider with the two-argument handle_tool_call gets
only what it declares; caller_gsk alone made every call to it a TypeError.
- The model sees a generic "refused, check gateway.log". gateway.log keeps
memory_caller_profile_unresolved and both homes.
ByteRover and RetainDB now bind their store from initialize()'s hermes_home.
Both already kept their bindings on the instance and hold no profile state at
module level.
The provider side of the rule is documented on MemoryProvider and in the
memory-provider plugin guide: a new instance per load, every binding from
initialize()'s hermes_home, no profile state at module or class level, no
per-call rebinding. Core cannot see inside an external provider; one that
keeps a process-wide binding still mixes profiles' memories.
The previous commit's two MagicMock tests in test_run_agent.py move into
tests/agent/test_memory_provider_caller_profile.py (test_run_agent.py is over
its line cap and may not grow). That file drives both dispatch paths and
every hook with real managers and two profiles interleaving on threads;
tests/plugins/memory/test_provider_multiplex_contract.py does the same for
ByteRover and RetainDB with a fake backend.
Refs #134889 (PLG-11)
Refs #140208
Refs #140058
On the gateway ACP path every registered Hermes command outside the adapter's
small allowlist (/title /yolo /retry /undo /skills /clear /bg ...) raised
GatewayClientError('unsupported_command'), which the ACP SDK turned into a
JSON-RPC -32603 "Internal error" for the whole prompt, while /help said
unrecognized commands go to the model.
Map them the way the classic transport client (gateway_chat_commands.py) does:
/title <name> is session.mutate rename, /undo [N] and /retry the rewind
mutation, /clear the reset, and every other registry command goes to the
owner's slash.exec, which runs what it serves for a local session (/yolo,
/skills, bare /title, /plan's turn...) and refuses the rest. That refusal
(and /branch's pointer to session/fork) is the command's reply with
stop_reason end_turn, using the shared "not available on the shared gateway
yet" wording. The parity table's ACP column now reads those routes.
Red on main: tests/acp_adapter/test_gateway_registry_commands.py (real
acp_adapter.entry stdio process + real gateway.run daemon) failed with
{'code': -32603, 'message': 'Internal error', 'data': {'details': 'unsupported_command'}}
on /title.
Refs #134889 (ACP-17)
Refs #140138
The env bridge, allowlist names and prompt hint now live on the PlatformEntry (gateway_env.py,
AUTHZ, platform_hint), not in _ENV_STEPS, _PLATFORM_ALLOWLIST_ENV or PLATFORM_HINTS.
The Desktop asks profiles.list of the selected bot over its one host-scoped
socket. Since the unified gateway, only that bot's row carried session fields:
every other served profile was listed by name alone, so on a fleet every row
but one showed a hollow draft dot and no age, although the same socket may
already open each of those bots' sessions.
Each served sibling a host-scoped connection routes to now carries the same
canonical_session / last_session, read from that sibling's own authority with
the connection's subject and capabilities. The sibling set is snapshotted on
the owner loop, and no connection is built for it. A profile-bound ticket, a
retiring sibling, a row listed under a name that routes to another profile,
and a sibling whose read fails for any reason stay metadata-only; a failing
sibling is warned once, not on every poll. The owner-or-operator rule applies
per profile.
Each row is read on one connection that never reopens a closed store
(SessionDB._read_ctx(reopen=False)), so a roster poll racing an unserve cannot
reopen a writer into a home being deleted. last_session skips hidden rows
again, as the pre-unified roster did, and the rows are reused while a
profile's store has not moved, on the signature the pre-unified roster cache
used (#117257), keyed by reader. The adopted-binding predicate from the
previous commit becomes one SQL predicate for both lookups.
AuthorityConnection.host_scoped names the gate _sibling_for applies.
Fixes#139227
Refs #134889 (RT-24), #139161
(cherry picked from commit 714da8acbcafc41a0e6ebce0e490eaf5ad0e72a0)
Desktop -> Bots -> New Group Chat refused every multi-bot group with a bare
`invalid_params` on a default install (#139002). The canonical room service
knew only its own profile plus `hosted_rooms.profiles`, and a default config
has no such key, so every sibling bot failed roster validation even though
`profiles.list` offers the multiplexer's served siblings as group members.
A group now seats the profiles this gateway serves plus the profiles
`hosted_rooms.profiles` names, and nothing else
(`gateway/session_hosted_members.py`). Served profiles come from the live
registry under their reserved names (`SessionAuthorities.named_serving`); a
retiring or unbuilt serve seats nobody, and an installed profile that
nothing here serves is still refused: it has no live owner to run its
turns. A host-scoped connection (Desktop's shared socket, the dashboard),
the one that may address a sibling directly, seats served siblings with no
entry, and their served home wins over any entry. A profile-bound
connection seats its own profile plus the profiles its entries name, as
before; an entry naming a served profile must match its served home.
One home answers to one name. An aliasing or malformed entry is ignored and
logged once per value, and only a new member naming it is refused; a room
that already seats an alias keeps running its other members. A null section
is empty. Previously one such entry broke the whole roster. A served
profile whose `profiles/<name>` is a link is refused by name: the member
transport names a destination by its resolved home, so its turns would fail.
Both create paths, the room driver's and the one used while it is stopped,
apply this rule. A refused member is named: `error.data` carries the field
(`members`, or the `hosted_rooms.profiles` entry) and a sentence with the
profile, and the refusal boundary logs one warning line.
Refs #134889
(cherry picked from commit ed4885c193a3740d8e590f1007f4fca25bf0e870)
The SDK guide said the gateway refuses a plugin socket's upgrade when the
plugin is disabled for the gateway's launch profile. PLG-3 removed that
check: a socket is gated by its own profile's consent alone
(test_runtime_disable_refuses_new_grant_sockets_in_that_profile_only).
The sentence now says so, and that a secondary profile's plugin served by
its plugin host gets HTTP 501, because the host does not carry websockets
yet.
Refs #134889 (PLG-3)
Refs #139523
pluginSocket read the active profile when it started a dial but never
re-checked it after the connection lookup or the grant mint resolved. A
profile switch during either await still dialed the old profile's URL, and
no dial for the new profile followed. A socket already open when the
profile changed also stayed bound to the old profile's grant: the scope
listener only reset the counters and re-dialed a stopped socket. The
gateway checks the grant's own profile, so consent held, but the plugin
view showed the other profile's stream.
Each dial now carries the generation it was started under. A connection
or profile change bumps the generation, closes an open socket, and dials
for the new scope. A lookup, mint, backoff timer or socket callback from
an older generation is dropped. It neither retries nor counts toward
MAX_REFUSED_PLUGIN_DIALS. Permission refusals still stop at the limit,
connection failures keep the capped retry, and the no-bridge/OAuth,
disposed and null-URL cases are unchanged. The SDK guide says a live
socket follows a profile switch.
Refs #134889 (PLG-1)
Refs #139523
A relayed Discord message carries connector-resolved chat_name / chat_topic and
user_display_name; a relayed interaction (slash command, component, modal) was
built from the raw body: user_name = raw username, no chat labels, and inside a
thread chat_type "group" with no thread_id / parent_chat_id. All of these feed
_ephemeral_change_key, so message -> interaction -> message re-rendered the
pinned session-context prompt each way, and a slash in a thread keyed another
session.
- the interaction names its user from its own payload: guild nick, else
global name, else username (discord.py display_name order);
- the text lane's last (chat_name, chat_topic) per (guild, chat) is kept in a
bounded map and recorded in state_meta when observed (off the loop,
retryable when the database is away); the interaction lane reads the map,
then the record after a restart;
- a thread interaction derives chat_type=thread, thread_id, parent_chat_id
from the partial channel object;
- a cancellation before admission releases the inbound seen bit so the
connector's replay is admitted.
Squash-port of #128797 (six commits) onto current main, where
_discord_interaction_to_event lives in gateway/relay/adapter_discord_interaction.py;
_on_passthrough moves there with it to keep adapter.py under its health cap.
sessions.auto_prune goes back to false by default. Deleting history is the
user's call, but an install that never decides still needs to hear about it
when the disk holding state.db runs low, or state.db grows until the disk
fills (the reason #54189 turned it on).
While the user's config.yaml has no sessions.auto_prune key, every surface
asks once the disk is low (< 2 GiB free, or < 10% free with < 20 GiB left):
- classic CLI: a y / n / Enter(later) question at startup (TTY only)
- TUI and Desktop: one sticky notification.show per profile per process
- gateway: the question on each served profile's home channel, at most
once per 7-day snooze window
- /autoprune on|off|later|status answers it on every surface (registry
executor, so the text is identical); on/off writes the explicit key and
the question never comes back, later snoozes a week
The prompt estimates what a prune would free (read-only count of ended
sessions past retention_days, scaled by their share of messages) and says
plainly when pruning will not fix the disk: no session old enough, or only
a small amount reclaimable.
The hot-path check is os.stat + shutil.disk_usage + one small YAML read;
the DB estimate only runs once that gate fires, off the prompt thread on
TUI/Desktop.
gateway/run.py and tui_gateway stay under their line caps: the media-cache
chore moves to the new gateway/run_housekeeping_disk.py with the prompt
chore.
pluginSocket turned a failed or timed-out activeConnection() into null and
returned without scheduling another attempt. That lookup is part of the
restart path: getConnection re-ensures the gateway, which rejects while it
starts or drains, and a stale ticket forgets the cached descriptor before
re-ensuring. The socket then stopped for good, and since it was not marked
stopped, a connection or profile change did not revive it either.
A descriptor failure or timeout is now a connection failure like a dial
that never opened: the next attempt is scheduled with the same capped
backoff (500 ms base, 30 s cap) and does not count toward
MAX_REFUSED_PLUGIN_DIALS. A missing bridge and OAuth connections still stay
on polling, and permission refusals still stop at the limit. The SDK doc
now says the socket keeps retrying while the connection or grant can't be
resolved yet.
Refs #134889 (PLG-1)
Refs #139523
A plugin `/command` typed in the classic CLI now runs in the gateway that
owns the session, so `os.getcwd()` there is the gateway's directory and
`print()` goes to the gateway's stdout. The plugin docs did not say so.
The user guide (features/plugins.md) and the build-a-plugin guide now say
to return text instead of printing, to take the session's directory from
`agent.runtime_cwd.resolve_agent_cwd()`, and to read session identity with
`gateway.session_context.get_session_env()`. The real-daemon test's plugin
gains a `/probe-cwd` command that checks both helpers return the session's
values while `os.getcwd()` is the gateway's.
Refs #134889 (CLI-13)
Refs #134889 (PLG-7)
Refs #139523
- desktop-plugin-sdk.md: ctx.socket on a local gateway authenticates with
the native grant its ctx.rest calls carry (minted by main, attached as a
header to that one dial). Also when the socket keeps retrying, when it
stops, and when it starts again.
- web_server_chat._ws_auth_reason: a socket that sends
X-Hermes-Gateway-Ticket is judged by that header alone, so a core socket
presenting it is refused even with a valid token query credential.
- web_server.py: why the web_server_dashboard import sits mid-module. It is
not an import cycle (web_server_dashboard reaches back only inside
functions); the load-bearing part is the middleware registration order.
Refs #134889 (PLG-1, PLG-8)
Refs #139523
With signal, weixin, bluebubbles, qqbot, yuanbao and whatsapp_cloud now
bundled platform plugins, gateway/platforms/ keeps only the base class and
the HTTP ingress adapters (api_server, webhook, msgraph_webhook). (The
now-unused _gateway_platform_module helper and the setup wizard's
second-credential map were dropped while integrating the weixin and
yuanbao "drop core wiring" commits.)
- ffmpeg calls in the Signal and QQ adapters get stdin=DEVNULL: they now
sit under plugins/, which check_subprocess_stdin scans (gateway/ is not
scanned), and ffmpeg reads stdin for its interactive keys.
- Setup wizard: collapse the blank lines left by the removed static rows.
- Developer docs (EN + zh-Hans) describe gateway/platforms/ as core base +
HTTP ingress adapters and list the six platforms under plugins/platforms/.