A plugin directory that is a link to a git checkout elsewhere is classed
as self-cloned, so `hermes plugins update` printed "run `hermes plugins
adopt` first". `adopt` then refused with "resolves outside the plugins
directory": `_sanitize_plugin_name` resolves links on purpose, so that no
plugin verb updates or deletes files outside the plugins directory.
The guard stays. The update check now says where the checkout is and to
pull updates there, and every named verb (`adopt`, `update <name>`,
`remove`) that reaches the guard through `_require_installed_plugin` says
the same and that deleting the link removes the plugin, instead of the
bare path error.
A plugin host's buffered answer is served from the gateway's own origin,
so passing Set-Cookie through let a hosted plugin set or overwrite the
dashboard's cookies. hosted_response (shared by the launch profile's
isolation: host mount and secondary profiles' hosts) now drops it and
warns once per (profile, plugin). No bundled plugin sets cookies.
Part of #140051 (item 1; the tracker stays open for items 2-5).
The Python SDK `{"result": value}` dedupe ran in the shared result
renderer, so plugins calling `ctx.call_mcp` lost `structuredContent`
and got newline-joined item text for list[int]/list[dict] tools, which
is not JSON. Only the registry handler (`native_images=True`, what the
agent loop dispatches) now collapses the wrapper; `ctx.call_mcp` gets
what main returned.
A per-item list now reaches the model as one JSON copy of the value
instead of rejoined block text, so `[1, "1"]` no longer reads as
"1\n1" and items containing newlines keep their boundaries. The str
case is unchanged (the text block itself).
FastMCP and the official Python SDK (MCPServer) cannot put a bare string,
number or list in structuredContent, so a `-> str` / `-> int` / `-> list`
tool answers with content = the bare value (FastMCP 3.x: one text block,
a list as one JSON block; MCPServer: one block per list item) and
structuredContent = {"result": value}. FastMCP marks the shape with
"x-fastmcp-wrap-result" in outputSchema (and, from 3.2, in _meta).
_content_dual_emits_structured (kimi-code#3234, narrowed in #115445 for
#115430) only recognised structuredContent serialised verbatim in a text
block, so the wrapper never matched and every such result reached the
model twice. That doubled the inline token cost, crossed the 50K
mcp_result_size_chars spill threshold at half the real size, wrote an
escaped second copy into the spill file's <mcp-result-metadata> block
(#90426), and spent the 200K per-turn budget twice as fast.
The check now unwraps the single-key {"result": ...} wrapper and applies
the same per-block equality to its value (block by block for a list).
Equality stays exact and type-stable (1 is not True). A wrapper whose
value differs from the text, or one with extra keys, keeps its
structuredContent (#115430). A bytes return (content '"abc"', structured
"abc") is compared as JSON too; a list[str] whose item holds a newline
keeps structuredContent, because the newline-joined text cannot show the
item boundary. The outputSchema / _meta marker is not consulted: it is
absent on FastMCP 3.0/3.1 _meta and on MCPServer, and it cannot replace
the equality check.
Salvaged from #124452 (production change as written there), with tests
for the FastMCP 3.x shapes, the _meta marker, multi-block and non-text
content, and the spill threshold / spill file through the real handler.
Fixes#124451
Co-authored-by: Julia <julia1988@users.noreply.github.com>
Co-authored-by: JoaoMarcos44 <87440198+JoaoMarcos44@users.noreply.github.com>
Co-authored-by: Victor Kyriazakos <victor@rocketfueldev.com>
A plugin with session-less background work (re-scoring its own data,
suggesting a cleanup) had to run its own timer. register_idle_task(name, fn,
*, interval_hours, min_idle_hours=2, first_run="defer") puts it on the skill
curator's scheduler instead:
- polled from every site that drives the curator (gateway housekeeping per
served profile, CLI/TUI startup maintenance, the hermes serve maintenance
tick) through one run_idle_jobs(): the curator, then the active profile's
plugin tasks;
- the curator's gates via agent/idle_schedule: the min-idle check, the
interval (floored to 1 h) whose first observation seeds last_run_at and
defers one interval (first_run="immediate" opts out), and the O_EXCL claim
file so a task never overlaps itself across threads or processes;
- state per (profile, plugin, task) in <plugin data dir>/idle-tasks/<name>.json
(last_run_at, run_count, paused, last_summary, last_status, last_error);
a manager polled outside its own home runs nothing;
- exceptions are logged and recorded, never raised into housekeeping;
- the registration is a PluginRegistration, so unload stops the polling;
- `hermes plugins idle-tasks [plugin] [--pause TASK | --resume TASK]`.
fn receives plain data (name, idle_for_seconds, last_run_at, run_count) and
reaches its ctx through its closure, so the payload also crosses the isolated
plugin host. No capability: the scheduler only calls the plugin's own
function; model calls inside it go through ctx.llm's existing gate.
plugins.py and gateway/run.py are over the file-size cap, so the mixin lives
in hermes_cli/plugins_idle_tasks.py and neither file grows.
Hermes' own background review (fork the live agent after a turn, run a
bounded multi-step prompt with a narrow tool list, cancel on the next live
turn) is now open to plugins as ctx.fork_session(token, prompt, *, tools=(),
max_iterations=8, input_budget=None, task=None, timeout=None), gated by the
new consent-only capability llm.session_fork.
Reused, not copied:
- Lease: post_llm_call's side_question_token backs a side question OR a fork
(side_question_lease.take_lease; same TTL, turn_moved_on, profile fence,
no token for unattended turns, one redemption per turn). The payload field
keeps its name for compatibility.
- Fork: build_cache_parity_fork(write_origin="plugin_fork:<id>") on a
context-bound thread in the captured turn context; same-model forks replay
the captured system prompt and tools[] byte-for-byte; routed forks get the
history digest. Persistence stays fully detached.
- Guardrails: the thread tool whitelist is the requested names (each must
already be in the session's tools[]); approvals auto-deny; the review's
input budget (a plugin can only lower it) and iteration cap (<= 16);
_BackgroundReviewRun admission so cancel_background_review_for_live_turn
interrupts plugin forks with the review under one bounded wait;
review_idle_queue deferral on the managed local runtime (enqueue takes a
dispatch callable; a newer fork of the same plugin supersedes the queued
one).
- Routing: task must be one of the plugin's register_auxiliary_task lanes,
resolved like auxiliary.background_review.
- Usage and hooks: release_cache_parity_fork bills the parent session as
plugin_fork:<id>; each fork loop request reports pre/post_auxiliary_call
(aux_task="plugin_fork", plugin_id) instead of pre/post_api_request.
Tool handlers inside the fork receive turn_origin="plugin_fork:<id>"
(live calls get no new kwarg), so a plugin can refuse calls from the live
agent. The handle exposes done/cancelled/outcome/result/actions/wait/cancel,
never the fork agent. Fails closed (None) without the capability, on a bad,
expired, spent or foreign token, a tool the session does not advertise, or
a task the plugin does not own.
A client that failed to start, or Ctrl+C in the launcher, skipped finish and left the new
worktree and branch behind. restore needs the full session id, so the example resolves the
short id the summary prints before it calls restore.
A module entry in plugin_api.json also publishes the module's imports (logging, os, sys,
Path). The list now names the three functions, and the docs example imports them by name.
Adds the subsection "`-w`: run the session in a fresh worktree" to the plugins page. It says when
a launcher calls `create`, `restore` and `finish`, that `create()`'s path is the `cwd` of
`session.create`, and why a plugin must not make the tree itself.
A new profile has no state.db, so opening it for every launch stopped the first chat.
A --resume or -c that matched nothing started a new chat without a word.
On Windows the install's launcher is hermes.exe, or hermes.cmd when no exe could be made.
hermes_command returned the extensionless path, which a child process cannot start when
only the batch file exists. It now returns hermes.exe, or the interpreter form.
The docs example printed resume lines it could not accept, and every launch shared one
session file. It now registers --resume and -c, resolves them to a session id, and uses
one temporary file per launch that may be empty.
The example read os.environ["HERMES_HOME"], which a Hermes started as a console script
on the default profile does not set. It now calls get_hermes_home(). The section says the
launcher command needs plugins.isolation: in_process. plugin_api.json lists hermes_command
and print_exit_summary by name, so the module's imports are not published with them.
Adds a section to the plugins guide for a plugin whose command starts its own chat frontend. It
names the three public imports, says what each returns and when to call it, and shows one short
launcher that uses all three.
Fires once per curator pass, after the per-run report directory
(run.json + REPORT.md) is fully written, with the report paths in the
payload. Goes through the standard lifecycle hook surface
(hermes_cli.lifecycle.invoke_hook), so Python plugins and shell-script hooks both
receive it with no extra wiring, and per-callback error isolation comes
for free.
Lets multi-profile governance layers (profile routing, archival
overrides, audit logging) react to curator output without polling
logs/curator/. Observer-only: return values are ignored, and a raising
callback never breaks the curator pass.
Kwargs: run_dir, run_json_path, report_md_path.
Follow-up to the discussion on #43113, scoped down to the hook event
suggested there.
Rebased onto main by the maintainers: fired through hermes_cli.lifecycle
(first-party observers, then plugins) without an extra wrapper, documented
in the hooks reference, tests trimmed to the two behaviour contracts.
The plugins guide still described the pre-gateway classic CLI host: an
injected message sent mid-turn "interrupts the current operation". Since
plugins load in the gateway on every local surface (PLG-7), injection goes
through the session's durable FIFO (gateway/run_plugin_injection.py
_admit_plugin_injection) or the TUI/Desktop prompt queue
(tui_gateway/plugin_inject.py), and a busy session keeps the message for
its next turn.
Prompted by the review of #85279 and #118906 by @Sahil-SS9, which asked
for exactly this queue-safe behaviour; main already has it.
A third-party client can now say who it is: session.create takes an optional
client {name, version?}. It is attribution only. source still picks the
policy, and no toolset, approval, permission, prompt text or telemetry reads
the label.
- Validated beside the editor check (bounded, safe charset); a malformed value
is invalid_params on field client.
- Kept inside the frozen creation request, so there is no new column, receipt
key or policy field: an older owner restores the session, and the label is
part of the exact-retry identity.
- session.info.client echoes it (absent when none was sent); runtime.describe
lists client in session_create.parameters and capability session-client-v1.
- Plugins read it with hermes_cli.plugin_session.session_client() (published
in plugin_api.json) and the client / client_version keys of prompt-section
session info ("" when none). No PluginContext method, no hook kwarg.
- The classic CLI's /new copies the frozen launch request but never the
creating client's label: the new session belongs to the terminal.
- Contracts regenerated; docs say the label is self-declared and must never
grant anything.
READMEs, contributor guides, AGENTS.md files, skills and the website (with
the zh-Hans translations) give pnpm commands for the workspaces; the
website itself is still an npm project.
The plugin guide told authors to read session identity with
`gateway.session_context.get_session_env(...)`, written as a dotted module
call with no import line. `hermes plugins validate` treats only
`from gateway.session_context import get_session_env` as public, so an author
who wrote `import gateway.session_context` to match that spelling got a
private-import warning.
The developer guide and the user guide now name that import, and the
slash-command example uses it to read the platform and the chat id. A test
validates the guide's `get_session_env` example as a plugin and expects no
private-import warning.
- Docs/docstrings: an unattended update never accepts a caution verdict on a git update;
a catalog re-pin accepts one (a reviewer read that pin at admission). Name the --ref hold.
- /plugins update, Desktop and the dashboard reload each updated plugin (MCP + skills live now,
Python tools in new sessions); the scheduled check's 'loads in new sessions' stays.
- Desktop: $pluginUpdateAllRunning is a per-profile set, so profile A's run leaves B's button enabled.
The plugin.yaml gains provides_tools and provides_hooks, and the
post_tool_call hook takes (tool_name, args, result, **kwargs) to match
the hook signature.
Under plugins.isolation: host every value crosses as JSON, so a dataclass
arrived as a generic Record, a Path as str, an enum as its value and a
plugin object as an Opaque placeholder. Core consumers that type-check
broke:
- secret sources: SecretSource.fetch() came back as Record, the
orchestrator rejected it ("fetch returned Record instead of
FetchResult") and applied no secrets; fetch() also received home_path
as str, so `home_path / "x"` raised in the plugin.
- context references: ContextCompletionItem (a __slots__ class) became
Opaque, so @prefix: autocomplete silently returned nothing.
- context engines: clone_for_agent() returned Opaque, so no agent could
get its own copy of a hosted engine.
The provider ABC's annotations are the contract, so the wire now
restores against them: the parent rebuilds results from the declared
return type (dataclasses, enums, Paths, typed containers; a declared
provider ABC becomes an object proxy) and the host rebuilds method
arguments from the declared parameter types. Type names never come from
the host. ContextCompletionItem becomes a slots dataclass so it crosses
as data.
- No side_question_token for cron runs (platform="cron") or delegated subagent turns
(_delegate_depth > 0): nobody reads the answer, so it is pure unattended spend.
- A lease is bound to the profile home it was issued in; a plugin context of another profile
gets None and leaves the lease for its owner.
- Usage bills to the session the token was issued for (capture.session_id), not the parent's
id at release time, which can rotate between issue and redeem.
- Plugin side questions report as aux_task="plugin_side_question" with the asking plugin_id in
pre/post_auxiliary_call, and record usage as plugin_side_question:<plugin_id>; /btw keeps
side_question.
- Drop the new legacy key llm.allow_side_question: the capability is declare + consent only.
- The timeout starts before the fork build, so runtime resolution counts against it.
post_llm_call now carries a single-use side_question_token when a loaded
plugin holds the new llm.side_question capability. ctx.side_question(token,
prompt) redeems it: ONE text-only request on a cache-parity fork through
the turn loop's own request phases (assemble_api_request, build_api_request,
perform_api_call), never the tool loop. The parent's system prompt, tools[],
reasoning config and max_tokens are replayed verbatim, so the request reads
the warm prompt cache. Tool calls in the reply are dropped, nothing is
persisted, and usage lands on the session as side_question.
Lease rules: one attempt per turn shared by every plugin (consumed even on
failure), 60 s, invalid once the parent starts its next turn, prompt capped
at 4096 chars, timeout capped at 60 s. The lease holds its parent weakly and
runs under the turn's captured contextvars (profile and secret scope).
Refused with None: MoA, agent-as-provider runtimes, requests that carry
provider-executed tools.
has_capability moves with side_question into a PluginContext mixin
(hermes_cli/plugins_capability_ctx.py) so hermes_cli/plugins.py shrinks.
Fixes#143788
Move today's delegation routing (every child follows the delegation section,
else the parent's route) out of core into plugins/delegation/default, a bundled
kind: backend plugin that registers through ctx.register_delegation_provider
like any other strategy. Core keeps only the name 'default' as the fallback
selection; no built-in provider class and no reserved name remain.
The registry loads a bundled strategy on first use when the plugin sweep never
registered it (runtimes that pinned discovery with zero plugins), so
delegate_task never depends on the sweep; plugins.disabled still wins and a
disabled default is a clear refusal. Config names are validated before they
become a path.
delegate_task asks the active delegation provider (delegation.backend, a new
provider category registered with ctx.register_delegation_provider) for each
task's route: model/provider/endpoint/reasoning resolved by the existing
delegation credential resolver, or a Hermes profile the child runs as. A
provider may add enum-checked per-task schema parameters built once with the
tool definitions. Core keeps the whole lifecycle.
- agent/delegation_provider.py + agent/delegation_registry.py: ABC + registry;
the built-in 'default' strategy is today's behaviour and the fallback for an
unregistered/unavailable backend.
- tools/delegate_tool_routes.py: per-task routes, parameter validation, and the
profile scope binding (home override + secret scope + multiplex semantics +
terminal policy) around a profile child's construction and conversation.
- Host isolation: HOST_OBJECT_BASES row, so providers run under
plugins.isolation: host.
- delegation.backend in DEFAULT_CONFIG; registrar table moved to
hermes_cli/plugins_registrars.py to keep plugins.py under its cap.
- Default config: delegate_task schema and every hermes-cli tool definition
are byte-identical to main.
Under plugins.isolation: host a user terminal backend's create_environment()
ran in the host and its environment came back as an Opaque placeholder, so the
first command failed with a backwards 'not available inside the plugin host'
AttributeError and the host was left holding a sandbox nothing could clean up.
Pre-existing for every plugin terminal backend; the Singularity move makes it
reachable for Singularity users who run host isolation.
Creating the environment now refuses before the host starts anything, naming
plugins.isolation: in_process (the Bot Desktop placement refusal's shape).
Desktop's plugins.manage update refused every non-catalog install ("not a
catalog install — update it via the CLI") and kept its own third copy of
the re-pin logic. It now calls dashboard_update_user_plugin, the same
function the dashboard route uses, so catalog and git installs update the
same way on every surface.
A scan block comes back as ok=false + scan_blocked + scan_verdict +
scan_findings (the shape install already returns) with nothing changed;
the client retries a caution verdict with force. The dashboard route reads
force from its body next to accept_capabilities.
The Plugins tab can only offer Update when it knows an update exists. Git
installs had no such signal, so the row never showed a button. The gateway
already runs the update check every plugins.auto_update_check_hours, and
`hermes plugins check-updates` runs it on demand; both now save the results
next to the cadence marker. The plugin list reads that file (no network per
listing) and sets update_available + latest_sha on git rows. A saved result
is ignored once the install's revision moves past the one it compared.
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
Running `hermes plugins update` without a name now runs the check-updates
probe, lists the plugins the update path can actually move (catalog re-pin,
git pull), names every one it skips and why (pinned, needs fixing, unknown,
pip distributions Hermes never upgrades — #132494), asks once, and updates
each through cmd_update so per-plugin consent prompts still apply. One
failure does not stop the rest; the summary quotes each failure's reason.
Without a terminal nothing moves unless --yes is passed; --yes runs the
updates with interactive=False, so consent stays fail-closed.
- Mark every post/fallback send _interim_send so a relay stream open for the
turn's answer is never sealed with plugin progress.
- Rebuild a first-message source from every field the gateway binds
(scope_id, user_id_alt, parent_chat_id, ...) so it keys like the live one.
- A send past the 30 s wait keeps running as the handle's pending
operation; its result still lands on the handle and the next edit waits
for it, so a slow post never leaves an orphan message.
- An edit_message that raises falls back to a fresh send like a refused one.
A plugin can now post a status message into the conversation it is working
for and update that same message later, on any channel, with no
per-platform code (#133306).
- ctx.post_message(text) -> PluginMessage; handle.edit(text). Async twins
ctx.apost_message / handle.aedit for code on the gateway loop.
- The conversation is the session bound to the calling tool call, slash
command or hook; the plugin never names a chat. No bound session (timer,
plugin thread, cron) or no live gateway -> ok=False with an error code,
never an exception.
- Messaging chats go through the answering adapter's send/edit_message.
Adapters without edit support, or a refused edit, get a fresh send and
the handle follows the new message (edited=False, fallback=True).
- Local CLI/TUI/Desktop sessions get a keyed notification.show that
Desktop and the Ink TUI replace in place.
- Refused in the out-of-process plugin host (handle is loop-bound).
- Every post/edit is logged as plugin_message plugin=... op=post|edit.
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.
Before the one-gateway runtime each classic CLI loaded its own plugins, so
ctx.inject_message(text) without a session key meant that CLI's own chat.
On a gateway session the classic CLI now loads no plugin code (PLG-7): the
only copy of a plugin is the gateway's (or its plugin host's), which serves
every session of its profile, so a key-less inject had no chat to target
and was refused.
The gateway now picks the target, in order:
1. The plugin is handling a local session's own call (its slash command, a
hook fired for that session, a tool or hook in its turn): the message
goes to that session. The key is read from the calling context, so this
never guesses, however many sessions are open. pre_command deliveries
now bind the session they fire for. Under plugins.isolation: host the
forwarded ctx call already runs in its caller's context.
2. No session in the calling context (a timer, the plugin's own thread):
the one local session of the plugin's profile launched by the classic
CLI (frozen policy source "cli") with a viewer attached. TUI, Desktop,
messaging and other profiles' sessions are never picked this way.
3. Otherwise (none, or several): refused. inject_message returns False,
nothing is injected, and one warning per plugin and reason (rate
limited) names the plugin and says to pass a session key.
A resolved target is committed through the keyed path's producer
admission: a queued input in that session's FIFO, run once and in order.
A key-less call made for a messaging chat keeps main's refusal; a keyed
inject is unchanged; allow_gateway_injection is still required.
The classic chat view's client-side inject slot (gateway_chat_inject) is
removed: nothing in that process calls it any more. Off the gateway the
in-process _cli_ref path is unchanged. The plugin guide describes the three
rules and recommends passing a session key.
Refs #134889 (PLG-7)
Refs #139523
Refs #139847
A secondary profile's plugin host starts on its first dashboard plugin
request and stays until the gateway exits. The plugins page now says so:
one extra Python process for each profile that has used a dashboard plugin.
Refs #134889 (PLG-3)
Refs #139523
Every request forwarded to a profile's plugin host parked a thread of the
gateway's default asyncio.to_thread pool until the host answered, with no
timeout. Forty concurrent slow requests to a secondary profile's plugin
held that pool, so /api/dashboard/plugins (also to_thread) timed out and
plugin assets took seconds; a hung handler held its thread for good.
Forwarded requests now run on a small pool of that profile's own (four
threads per plugin host home), so a slow plugin queues only behind its own
profile's plugin requests. Each request gets HOSTED_REQUEST_TIMEOUT_SECS
(60 s, a documented module constant; no config key), queueing included,
and then answers 504; PluginHost.asgi_request takes the remaining time as
its reply timeout, so the gateway thread is freed and the host keeps
serving later requests. The host protocol has no cancel, so the host may
still finish the abandoned handler. The launch profile's
plugins.isolation: host mount forwards through the same helper and gets
the same pool and 504. The docs say so.
Refs #134889 (PLG-3)
Refs #139523
In-process dashboard plugin API handlers run on the gateway's event loop.
A handler that blocked for 3 s held an unrelated /api/status for about
2.5 s and timed out Desktop's control socket. No default changes; the
dashboard extension guide and the plugins.isolation section now say to use
async I/O or move blocking work to a thread, and that plugins.isolation:
host runs the handlers in a separate process.
Refs #134889 (GW-3)
Refs #139523
On a gateway serving several profiles, dashboard plugins were discovered
from the launch home only and mounted once in the gateway process. A plugin
installed only in a secondary profile answered 404 from that profile's
Desktop window, its plugins.isolation was ignored, and the interim rule ran
the launch profile's copy for it when both profiles enabled the name.
A request scoped to a secondary profile (its native grant or a ?profile=
selection) now gets that profile's own plugins, served through its own
plugin host (the existing per-profile host and its asgi op, bound to that
profile's home and secrets) whatever its isolation setting says. Their code
is never imported into the gateway.
- Discovery: the profile's own plugins/, then the root ~/.hermes/plugins
(as a standalone `hermes --profile X serve` scanned before the cutover),
then bundled; the profile's own copy wins a name clash. Root plugins also
run in that profile's host.
- Consent: the requesting profile's plugins.enabled/disabled decide; the
launch profile's consent no longer gates them. Disabled, not enabled and
unknown names get identical answers (404 on HTTP, a 1008 close before
accept on a websocket).
- Bundled plugins are Hermes code: a secondary profile uses the in-process
router only when it is that profile's own bundled copy (the imported
module's file, or for a cold mount the copy that would be mounted), and
the cold mount binds the request's ?profile= before deciding. Otherwise,
for example when a launch-profile user plugin shadows the bundled name,
the request goes to the profile's host.
- Credentials: the session token, native grants, the Authorization and
Cookie headers, and the gateway's query keys (token, ticket, internal,
display_ticket, attach, profile; URL-decoded, every repeat) are removed
before the request reaches the host. Ordinary plugin parameters pass.
- Assets: /dashboard-plugins/@<profile>/<name>/<file>, and
/dashboard-plugins/... with ?profile=, bind that profile for the lookup
and consent check (traversal and file-type checks unchanged; an unknown
profile answers like an unknown plugin). The dashboard builds the path
form, so files a stylesheet or bundle loads by relative URL come from
the same profile. Its plugin loader binds its list request, asset URLs
and loaded plugins to the selected profile and drops a list that lands
after a switch; leaving a profile always removes that profile's
stylesheets and bundles, even after its list became empty. A ?profile=
rescan refreshes that profile's own cache.
- Plugin SDK: fetchJSON and authedFetch scope /api/plugins/ requests to
the selected profile with ?profile=, and plugin sockets carry it too; a
profile the plugin passes itself wins.
- The launch profile is unchanged.
The host protocol is request/response, so an authenticated websocket to a
secondary profile's hosted plugin gets a named refusal (HTTP 501 before
accept) instead of running in-process.
Tests that relied on a secondary profile reaching the launch copy now use
that profile's own copy (through a real host) or a bundled probe, and a
consent and refusal matrix covers both ways of selecting a profile.
Refs #134889 (PLG-3)
Refs #139523
The gateway answers one WebSocket connection's requests one at a time,
in arrival order (tui_gateway/ws.py _dispatch_loop). A classic CLI
plugin command went out as slash.exec on the CLI's only connection, so
while its handler ran, and still after Ctrl+C stopped the wait, the
session's prompt.submit, session.interrupt and reads queued behind it.
An ordinary request could time out meanwhile, and a handler that never
returned left the connection unusable. Main's CLI ran the handler
itself and held no gateway connection.
GatewayConnection.call_until now dials a socket of its own to the same
gateway with the same connect path (same home and profile ticket) and
sends the one slash.exec there, for the CLI's existing session; the
gateway authorizes it by the authenticated user and profile, as on the
primary socket, so no new session or protocol is involved and the
handler still runs only in the gateway. The request is sent once and
never retried. The socket and its thread close on the reply, on a
hang-up, on Ctrl+C and on close(). The stop line and the plugin guide
no longer say the next request waits for the handler.
The new daemon test holds the handler on a FIFO after Ctrl+C and checks
that the CLI's connection admits a prompt, reads its receipt and
interrupts that turn before the handler is released, then that no
command socket or pending request is left; a second test kills the
gateway during the wait. Unit tests cover the reply, Ctrl+C, close()
and a failed dial.
Refs #134889 (PLG-7)
Refs #139523
The plugin guide now names HERMES_SESSION_ID and HERMES_SESSION_KEY
among the values bound around a gateway-run command handler, and says
that the classic CLI waits for the reply as long as the handler runs,
and what Ctrl+C does then.
Refs #134889 (PLG-7)
Refs #139523
On main each `hermes` process scanned ./.hermes/plugins in its own cwd
when HERMES_ENABLE_PROJECT_PLUGINS was set. Every session now runs in the
one gateway, which discovers plugins once from its own directory, so a
project's plugins silently never load.
The plugins guide now says so in a Project-local plugins section. When a
CLI or TUI session starts with a forwarded HERMES_ENABLE_PROJECT_PLUGINS
in a folder whose ./.hermes/plugins has entries, the gateway logs a line
to gateway.log and session.info carries it as config_warning: the TUI
already renders that at session start, and the classic CLI now prints it.
A folder that can't be listed skips the notice; it never fails
session.create or session.info. Nothing is loaded; loading project
plugins in a plugin host is left for later.
Host-specific client values also need proof that the client is on this
host. A connection is native_owner only when it redeemed a ticket minted
over the gateway's private control socket, from loopback with no Origin
header; session.create passes that as client_local, and a client can't
send it (an unknown field). Without it only HERMES_EPHEMERAL_SYSTEM_PROMPT
and HERMES_INFERENCE_PROVIDER from client_env apply: the session keeps the
gateway's toolchain, prefill file and project-plugins check
(client_env_remote on its policy, left out of the policy identity when
false), and its config_warning says the client's environment was not
applied because the client is not attached to this gateway locally.
Refs #134889 (LC-4)
Refs #134889 (LC-8)
Refs #134889 (T3)
Refs #139523
The docs said a key-less inject_message from a classic CLI session's
turn is committed to that session's queue and starts the next turn. It
does, but the attached hermes chat never displays that turn or its reply.
The gateway publishes the turn's message.start, deltas and
message.complete to the attached client; the classic CLI's idle tick
(gateway_tools_notify.queue_admitted_turn) adopts a turn it did not
submit only when its message.start carries a producer card
(process_complete or async_delegation_complete), and a plugin admission
has none. The line now says the turn and its reply are in the session's
transcript and the classic CLI does not display them.
Refs #134889 (LC-5)
Refs #139523
_plugin_session_key_admissible returned False up front only for another
profile's local session. A beta plugin naming default's Telegram or ntfy
session key got True, and the session authority then refused the turn at
dispatch (admission_conflict), so the plugin was told a message was
accepted that went nowhere.
A messaging session now belongs to the profile its key names
(agent:<profile>:...) under multiplexing, or to the one served profile of
a standalone gateway, and it is compared with the plugin's profile
(_served_profile_for_home), as the origin path does. Another profile's
session gets False with the reason in gateway.log; dispatch rechecks.
The plugin's own messaging sessions are unchanged, and a caller with no
plugin home is still decided at dispatch.
Refs #134889 (LC-5)
Refs #139523
Since the one-gateway runtime, plugin hooks and tools of classic CLI,
TUI and Desktop sessions run in the gateway process. Plugins written for
the CLI broke there:
- inject_message() with neither session_key nor origin was refused. A
hook or tool running for a classic CLI session now resolves that
session's key from the turn context, and the text is committed to its
FIFO through the local session's own source and adapter (local
sessions have no messaging allowlist). allow_gateway_injection is
still required. Keyed injection into a local session is refused unless
the session authority registered for the calling plugin's own profile
holds that live session; ownership is never resolved through the
ambient profile scope.
- Approval hooks and transports saw surface='gateway' for CLI sessions.
They now report 'cli' again for a classic CLI session's turn. TUI,
Desktop and messaging keep 'gateway', as documented.
- os.getcwd() is the gateway's install root. ctx.session_cwd() and
ctx.session_surface() read the calling session's recorded workspace
and client from the turn's task-local policy. The gateway process is
never chdir-ed.
print() going to gateway-stdio.log and input() getting EOF are intended
differences, now documented in the plugin guide.
Refs #134889 (LC-5)
Refs #139523