Commit Graph

146 Commits

Author SHA1 Message Date
Teknium
808eaf32f9 fix(plugins): hosted providers keep their declared types across the plugin-host wire
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.
2026-10-25 05:10:15 -07:00
Teknium
4ea8d23cc9 fix(agent): side-question review fixes (unattended turns, profile-bound leases, billing, attribution)
- 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.
2026-10-24 19:56:21 -07:00
Cleo
a8db83446f feat(plugins): ctx.side_question asks the session's own agent after a turn
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
2026-10-24 19:56:21 -07:00
Teknium
5c353467dc refactor(delegation): the default delegation strategy is a bundled plugin
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.
2026-10-22 14:48:49 -07:00
Teknium
919322f6c3 feat(delegation): pluggable delegation providers
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.
2026-10-22 14:37:10 -07:00
Teknium
02f46d9818 fix(terminal): a plugin backend in the plugin host refuses with the isolation setting
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).
2026-10-22 05:26:10 -07:00
alt-glitch
3ac037670a fix(plugins): Desktop and the dashboard update git-installed plugins through the CLI's path
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.
2026-10-20 12:26:35 +05:30
Ilya Balobanov
b1b4effe51 feat(plugins): OAuth clients a plugin declares, signed in and refreshed by Hermes
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
2026-10-19 07:09:56 -07:00
Teknium
ced2a39350 feat(plugins): hermes plugins update with no name offers every plugin update
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.
2026-10-19 06:07:41 -07:00
Teknium
3e4f28ee8a fix(plugins): post_message review fixes — interim sends, full bound route, pending timeouts, raised-edit fallback
- 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.
2026-10-18 02:45:04 -07:00
Teknium
a2eab1f45c feat(plugins): ctx.post_message — post one message to the current conversation and edit it in place
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.
2026-10-18 02:45:04 -07:00
Teknium
ed9fb3cf56 fix(plugins): fire post_compaction on every committed compaction path
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.
2026-10-18 02:31:09 -07:00
Teknium
aab0dc72cf feat(plugins): on_session_delete covers Desktop deletes and deliberate archives
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>
2026-10-18 02:11:06 -07:00
Teknium
0975937593 feat(plugins): pass the calling session to plugin slash commands on every surface
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.
2026-10-18 01:27:20 -07:00
unsupportedpastels
f7322744fc fix(plugins): send a key-less inject_message to the session the plugin is working for
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
2026-10-16 19:39:48 -04:00
unsupportedpastels
fa29a29945 docs(plugins): say a secondary profile's plugin host lives until the gateway exits
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
2026-10-16 19:15:07 -04:00
unsupportedpastels
358ed4c305 fix(plugins): keep slow hosted plugin requests off the gateway's shared threads
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
2026-10-16 19:15:07 -04:00
unsupportedpastels
f42db87655 docs(plugins): say that in-process dashboard handlers must not block
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
2026-10-16 19:15:07 -04:00
unsupportedpastels
da01ee9c3c fix(plugins): run a served profile's dashboard plugins in its own plugin host
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
2026-10-16 19:15:07 -04:00
Mark S.
be9427acc9 Merge pull request #139575 from unsupportedpastels/fix/gateway-p5-plugin-loading
fix(plugins): classic CLI plugin commands run in the gateway, and disable reaches the running gateway
2026-10-16 19:12:02 -04:00
unsupportedpastels
06111d20fd fix(cli): run a gateway plugin command on a socket of its own
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
2026-10-16 22:37:29 +00:00
unsupportedpastels
5ba46cd4b2 docs(plugins): say CLI plugin commands get the session id and how Ctrl+C stops the wait
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
2026-10-16 22:17:17 +00:00
Mark S.
6255980b19 Merge pull request #139570 from unsupportedpastels/fix/gateway-p5-plugin-hooks
fix(gateway): plugin hooks fire once per message, and plugin injection stays in its profile
2026-10-16 17:58:51 -04:00
unsupportedpastels
027e62ed17 fix(plugins): say plainly that the gateway does not load project plugins
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
2026-10-16 17:49:54 -04:00
unsupportedpastels
8d9271b20e docs(plugins): say a key-less CLI inject runs in the session but the classic CLI does not show it
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
2026-10-16 21:36:26 +00:00
unsupportedpastels
c92611c4c1 fix(plugins): refuse a keyed inject into another profile's messaging session up front
_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
2026-10-16 21:35:53 +00:00
unsupportedpastels
11ba615c3c fix(plugins): give gateway-run plugin code the calling session's key, surface and cwd
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
2026-10-16 21:35:53 +00:00
unsupportedpastels
5018d437cc fix(plugins): refuse inject_message(origin=...) up front when the FIFO cannot admit it
Under the session authority a plugin turn borrows the connector
provenance of a human message already committed in that chat; the
gateway never mints it. A chat with no session, or a session with no
committed human turn, was refused only at dispatch, after the plugin had
already been told True, so notification and reminder plugins silently
did nothing.

The scheduler now checks this synchronously through one shared helper
(committed_route_envelope, also used by the automation snapshot and the
route wake), returns False, and logs the named reason. Dispatch still
rechecks. Origins without an authority keep the adapter's normal session
path.

Refs #134889 (PLG-6)
Refs #139523
2026-10-16 21:35:53 +00:00
unsupportedpastels
8af0911efc docs(plugins): slash command handlers run in the gateway process
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
2026-10-16 16:11:56 +00:00
Teknium
5d2f94b92c Merge origin/main (#37: 15 commits to 1f711b275f) into feat/unified-gateway-runtime
No conflicts. Brings in #136276 (update e2e sandboxes pinned to the main channel; the
source hand-off fixture installs its loopback transport once).
2026-10-10 14:30:21 -07:00
Teknium
4070f011a2 feat(plugins): core-made Codex requests so plugins never hold the token
Plugins that need the user's ChatGPT/Codex subscription (hermes-live-voice mints
an OpenAI Realtime client secret) vendored their own reader + refresher for
~/.codex/auth.json. Codex refresh tokens are single-use, so that second refresher
races Hermes's locked refresh and can revoke the user's whole token family.

hermes_cli.plugin_provider_requests.credentialed_provider_request() lets core make
the request instead: it resolves the credential through
resolve_codex_runtime_credentials (Hermes's locked refresh, profile-scoped),
attaches Authorization itself, sends only to chatgpt.com / api.openai.com, never
follows redirects, and returns status/headers/body. Callers are attributed by the
plugin directory on the call stack and must declare `requires_auth: [openai-codex]`
in plugin.yaml; the declaration shows at install, in `hermes plugins show`, and a
catalog re-pin that adds it asks for consent. A plain importable function so
dashboard plugin_api.py modules can use it.
2026-10-10 10:43:32 -07:00
Teknium
607a23e858 Merge origin/main (#30: 54 commits to 1744a19e0d) into feat/unified-gateway-runtime
8 conflicts, all from main's lint sweep (#135281 "Harder linter fixes" + the RUF series:
implicit-Optional, unused-unpacked-variable, next(...) for [...][0]). No other main commit touches
a conflicted file. Resolution: the branch side of each file plus main's exact autofix
(ruff 0.15.10, main's ruff.strict.toml, --fix --unsafe-fixes) on it. ruff.strict.toml takes main's
copy (the newly enabled rules). tests/cron/test_bot_chat_delivery_child_env.py stays deleted
(1cc9cb9199 retired its lane).
2026-10-08 21:38:54 -07:00
teknium1
05df0382a5 fix(plugins): re-enabling a plugin restores its toolset in a saved platform_toolsets list
The Desktop/TUI/dashboard toggle edited the saved list before the plugin
loaded, so a backend that scanned while the plugin was off found no toolset
key and left the toolset out: the plugin showed enabled with its tools off.
Enable now edits the list after activation; disable resolves the key before
the disable is written. hermes plugins enable/disable make the same edit.
Only saved lists are touched; a fresh config still gets no list.
2026-10-08 15:15:47 -07:00
Teknium
23030bf9f1 docs: plugin inject_message(origin=...) needs an existing session under the authority
05305c4efb moved plugin injection under the session authority into the session's
durable FIFO as a trusted producer admission. That admission borrows the connector
provenance of a human message already committed to the session; there is no seam
that mints native provenance for a chat the platform never delivered (msgraph's
own-route admission is bound to its adapter's signed HTTP callback). So an origin
for a never-seen chat (the Discord bot-authored forum post case 7b2ff7a7d4 added)
is refused and logged. That refusal is deliberate. Document it in plugins.md rather
than forge provenance.

(cherry picked from commit 76f3b6bf5d2329af54442bdcf2e138db5a5a1be6)
2026-10-06 21:58:25 -07:00
Teknium
63f5e0ea45 feat(computer-use): pluggable single-select computer-use providers
Third-party drivers (e.g. a Codex-style computer-use reimplementation) could
only replace cua-driver by patching core. computer_use now follows the
single-select provider model Hermes uses for memory providers, context
engines and cron schedulers:

- plugins/computer_use/__init__.py discovers bundled
  plugins/computer_use/<name>/ then user $HERMES_HOME/plugins/<name>/
  (marker: register_computer_use_provider / ComputerUseProvider) and loads
  ONLY the provider computer_use.backend names (default "cua"), read per
  call so each profile gets its own. Unselected providers are never
  imported; listing reads plugin.yaml only. An unknown/unloadable name
  returns an error naming it and the installed providers; no fallback.
- The built-in cua-driver is an ordinary bundled provider at
  plugins/computer_use/cua/ (driver implementation stays in
  tools/computer_use). tools/computer_use/backend.py gains
  ComputerUseProvider (create_backend(permission_mode=...), is_available(),
  optional doctor()).
- The tool's check_fn and backend construction go through the selected
  provider; the model-facing schema is unchanged for every provider
  (prompt-cache invariant). The test-only HERMES_COMPUTER_USE_BACKEND env
  switch is gone (tests patch _new_backend).
- General plugin discovery treats computer-use providers as exclusive
  (not eagerly imported, not listed as toggleable) and skips the bundled
  computer_use/ category, same as memory/, context_engine/, cron_providers/.
- hermes tools and the Desktop toolset panel list installed providers next
  to cua; computer-use doctor/status/permissions and the Desktop status
  payload skip cua-driver/TCC probes when another provider is selected.
2026-10-05 17:20:30 -07:00
Teknium
7b2ff7a7d4 feat(plugins): inject_message(origin=...) starts a gateway session in the plugin's own profile
`ctx.inject_message` could only reach an existing gateway session (`session_key`), so an
orchestrator plugin that opens a chat/thread itself (a bot-authored Discord forum post never
comes back as an inbound message) had no way to get an agent turn there.

`origin` takes the SessionSource.to_dict() shape. The gateway creates (or continues) that chat's
session through the adapter's normal message path, in the profile whose plugin manager loaded the
plugin, and the reply goes back to the origin chat:

- Profile: resolved from the manager's immutable home, never an ambient one. The origin may not
  name another profile, the gateway's own routing for that chat through that profile's adapter
  must land in the plugin's profile, and the profile needs its own connected adapter for the
  platform (another profile's bot is never borrowed). Refusals are synchronous False + one log line.
- Authorization: same current-allowlist check as the session_key path (no bypass for host code).
- Multiplex: handle_message runs inside the profile's runtime scope so the spawned turn AND the
  reply send after it inherit that profile's home and secrets (applies to the session_key path too,
  which used to send from the default loop context).
- allow_gateway_injection is read from the plugin's own profile config.
- Plugin/system turns (event.internal) skip the human first-contact notes (onboarding intro and
  the "no home channel" nudge), which were posted into the plugin's fresh thread.

Requested by canonicle-desk in #132609.

Closes #132609
2026-10-05 17:11:30 -07:00
Teknium
59224a20f0 fix(plugins): only a real memory-provider tree selects memory.provider on install
Catalog category "memory" also holds hook plugins, context engines and
skill packages. Deciding from the category made `--enable` overwrite the
user's memory.provider with an unloadable name and never enable the plugin.
Decide from the installed tree (_is_memory_provider_dir), and save
memory.provider only when find_provider_dir resolves the name.
2026-10-05 15:38:19 -07:00
Teknium
dc81e17f0a docs(memory): memory providers activate via memory.provider, not plugins enable
The install prompt for a memory provider now sets memory.provider; say so on
the Hindsight setup and plugin install pages and drop the claim that the
plugin is enabled under plugins.enabled.
2026-10-05 15:38:19 -07:00
Teknium
c958e1a7b9 feat(plugins): on_human_input_request / on_human_input_resolved hooks
One observer pair fires wherever the agent blocks waiting on a person, so a
notifier plugin no longer needs a hook per prompt type or a `sudo` regex over
terminal commands (#132333, consumer: pushover-hermes-plugin).

Fire sites are the existing choke points every surface already routes through:
- sudo: tools/terminal_tool_sudo.py::_prompt_for_sudo_password (CLI callback,
  Ink TUI/Desktop sudo.request card, /dev/tty fallback)
- clarify: tools/clarify_tool.py::clarify_tool (CLI, TUI/Desktop, gateway)
- approval: tools/approval_prompt.py::prompt_dangerous_approval (CLI/TUI/ACP
  callback and input() paths), ::_present_with_selected_transport (plugin
  transports), tools/approval_gateway_wait.py::_await_gateway_decision
  (gateway platforms)

Payload: kind, request_id (shared by the pair), session_id, session_key,
platform, prompt; resolved adds outcome. prompt is always force-redacted and
the typed password / clarify answers are never passed. Smart (aux-LLM)
approvals and coalesced gateway followers do not fire it: no new human prompt.

Closes #132333
2026-10-05 01:15:16 -07:00
John Paul Soliva
ddde067010 fix(plugins): a forced reinstall of the same source keeps the user's files
install --force --ref is the documented way to move a pinned plugin, but it replaced the whole plugin directory: untracked and git-ignored files (plugin state, local config) were deleted and tracked edits were lost with no copy. A reinstall from the source the plugin was installed from now carries user files like update does and copies tracked edits to plugins-backup/. A different source still starts clean.
2026-10-03 21:40:42 -04:00
teknium1
33eedf29c9 docs(plugins): pin plugins.isolation in the managed scope for shared deployments
plugins.isolation is profile config, so a profile (or its agent) can set it
back to in_process. The managed scope already beats profile config and makes
`hermes config set` refuse, and the isolation reader goes through that
overlay; document it as the operator lock and pin the contract with a test
(red when isolation_mode() reads the raw profile file).
2026-10-03 10:15:11 -07:00
teknium1
17a7a9cb6b docs(plugins): plugin host isolation mode and its invariants 2026-10-03 10:15:11 -07:00
teknium1
6cb7a64e59 revert: Skills and Plugins card catalog browser, third landing (reverts #119381)
Reverts all seven commits of #119381 (59c54c78..476ff4dd), which
re-landed the native card-based Skills/Plugins catalog browser after it
was reverted twice (#113037 reverting #112669, #115787 reverting
#113128). Capabilities -> Skills and Plugins return to the list/detail
tabs with the embedded catalog picker they had before #119381.

Removed with it:
- Desktop catalog/ module (browser, cards, detail dialog, filters,
  reels/masonry, install switch) and skill deep-link install
  (hermes://skill/install); skills/embedded-hub-picker.tsx comes back.
- apps/shared catalog-browse.ts and catalog-install.ts.
- The `catalog` i18n namespace in every locale (+ regenerated
  locales/_keys.desktop.json); the two i18n pack tests and the keys
  test now exercise connectorsPage.searchPlaceholder instead.
- Website /skills "Open in Hermes Desktop" skill links and the
  extract-skills install identifiers; docs return to the pre-#119381 text.
- Later fixes that only patched the reverted catalog code go with it:
  5832a6eb93 + 7aba2cbbe9 (catalog download deadline),
  9e63cdc4b8 (catalog lookalike rows), c756986db2 (catalog counts),
  the catalog half of c13232e90c / f265273347.

Kept on purpose (later work that depends on code #119381 introduced):
- DialogContent `chrome` / `overlayClassName` / nested-dialog layering
  (the image lightbox uses them).
- vitest.setup.ts / src/test/jsdom.ts stubs (other suites rely on them).
- Kanban toolset wiring on the Plugins Desktop switch (cd30fdadf6,
  7ca2f5665f) and its tests, the `hermes_not_connected` server tone,
  the SearchField flex-1 fix, skill provenance helpers. SkillDetail shows
  a provenance pill only for agent/hub skills, since the pre-#119381
  labels have no `external` entry.
2026-10-02 10:29:28 -07:00
brooklyn!
e47db9414a feat(catalog): restore website skill links and native browse guidance 2026-09-25 12:09:55 -05:00
Victor Kyriazakos
bfb8d3bd64 fix(plugins): picker preselects the effective state and persists only flipped rows
The bare `hermes plugins` picker preselected only rows listed in
plugins.enabled. Bundled platforms, backends and model providers are active
without a list entry, so they opened unticked, and the save on exit wrote every
unticked row into plugins.disabled: opening the picker and leaving without a
change disabled every messaging adapter on the next gateway restart.

Rows now open ticked by the load-time rule (_plugin_status), and only rows the
user flipped are written.

Ported onto the plugins_cmd_toggle sibling and the admission-authority save
(the original targeted the pre-split plugins_cmd.py). The nested
canonical-key composite test now ticks its row explicitly: it handed the menu
a checkbox state that contradicted the config and relied on the old
rebuild-everything save. The original helper-level tests are rewritten
against real admission in a follow-up commit.

(cherry picked from commit 3a0d5f1b8bce3b23b115ba4995b8c23dfbba9ad0)
2026-09-25 21:19:04 +05:30
ethernet
ed6e37f9c1 Merge remote-tracking branch 'origin/main' into ethie/pm-clean 2026-09-24 11:58:45 -04:00
brooklyn!
177f275b77 fix(plugins): route inject_message to the TUI session_key queue
Ink TUI and desktop never registered an inject host, and sharing
set_gateway_message_injector with a live messaging gateway would let
the last writer win. A separate host queues the reported session_key
onto that session's prompt queue and leaves other keys for the gateway.

Fixes #87412
2026-09-24 10:56:54 -05:00
ethernet
66d54ebf51 Merge remote-tracking branch 'origin/main' into ethie/pm-clean
# Conflicts:
#	.github/workflows/docker.yml
#	Dockerfile
#	apps/desktop/src/app/settings/about-settings.tsx
#	docker/stage2-hook.sh
2026-09-24 02:23:44 -04:00
teknium1
72d18ce59f fix(plugins): subdirectory installs download only that folder
A plugin that lives in a monorepo subdirectory (the Hindsight catalog entry:
vectorize-io/hindsight#hindsight-integrations/hermes) was cloned with every
file in the repository even at --depth 1: 170 MB for a 2 MB plugin folder.
On a slow link that exceeds any reasonable deadline, so `hermes update`'s
Hindsight migration failed with "Git clone timed out" every time.

Subdirectory installs now do a blobless clone (--filter=blob:none
--no-checkout) and a sparse checkout of just that folder, written as the
classic info/sparse-checkout file so older Git clients work too. Servers
without partial-clone support ignore the filter and fall back to the old
download.

Because a partial clone downloads file contents at checkout time, the
checkout step (pinned and unpinned) now gets the configured network
deadline and the credential fallback, same as clone and fetch. Every
timeout error names plugins.clone_timeout_seconds so users can find the
knob.

Existing test fakes of _clone_plugin_repo accept the new subdir argument.
2026-09-23 21:29:21 -07:00
Gille
5dbbc9a9c0 fix(cli): make plugin clone timeout configurable 2026-09-23 21:29:21 -07:00