A provider plugin was imported once per process, and the forced plugin sweep
skips model providers, so an update never reached a running gateway. A plugin
importing part of its package on first use then ran one new file against
siblings loaded from the old tree (cannot import name ...), while the update
surfaces said nothing needed a restart.
The forced sweep now re-scans the profile's provider plugins; one whose tree
changed (catalog pin, else file mtimes) is dropped whole (package, submodules,
its profiles) and imported again. hermes plugins update reports activation like
install/enable, the gateway auto-apply tick reloads in-process, and a model
provider's activation summary says it was reloaded or why it failed.
Fixes#153300
The guard that turns registrars into no-ops after a plugin's load times out
wrapped only the names defined directly on PluginContext. register_idle_task
lives on a mixin, so a plugin whose register() overran the load timeout could
still register an idle task from its abandoned worker after the failure path
had swept its other registrations, and the host would later run it.
The guard now walks PluginContext's MRO, so every register_*, subscribe and
on_unload that PluginContext defines or inherits is a no-op once the load is
abandoned. A contract test calls every registrar on an abandoned context and
expects nothing to run.
The guard lives in hermes_cli.plugins_load_guard, so the hermes_cli.plugins
facade does not grow with it; plugins.py applies it to PluginContext once,
after its last registrar is defined.
Co-authored-by: xue xinglong <257216957+chaos-xxl@users.noreply.github.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.
61 call sites counted directories up from their own __file__ to find the
install folder. They now call hermes_cli._startup_fast.project_root_str(),
so the layout move changes one line instead of 61.
Kept with a reason in the lint baseline: files that cannot import Hermes
code (bootstrap, update path, pm/) and the sys.path bootstraps left for
part 2b. The baseline drops from 89 to 28 root_from_file sites.
Six existing tests that patched a module __file__ now patch the owner.
Greptile on #153538: _loaded_manager_nowait released the discovery lock before its callers read
_plugin_commands / _hooks, so a reload taking the lock in that gap could make an enabled command
or hook read as absent. The loaded check and the registry read now run under the same
non-blocking lock (_loaded_registry_nowait), as hook_unused_nowait did before.
Greptile on #153538: the first plugin-command lookup discovers the profile's plugins, so moving
the lookup out of the secret scope ran register(ctx) without it; a plugin reading a secret while
registering failed to load (UnscopedSecretError) and its command was never found. Discovery and
lookup are back inside the scope. The bind is skipped only when this home's registry is already
loaded and lacks the name (plugins.plugin_command_absent_nowait, which never discovers), and a
failing bind still never fails a built-in. The plugin-command helpers move to
methods_tools_plugin_commands.py to keep methods_tools.py under its line cap.
Greptile P2 on 900ef9cbc8: discover_and_load sets _discovered before its sweep finishes, and a
force reload clears the registrations first, so an open during that window could read the
profile as having no consumer and skip the plugin's setup. hook_unused_nowait now treats a held
discovery lock as unknown (no wait, still non-blocking on the event loop), so delivery goes to its
thread, where has_hook waits for the sweep.
Independent review round:
- P2: post_curator_run fires on `hermes curator run --dry-run` with no way to tell;
the payload now carries dry_run (documented in hooks.md + plugins guide).
- P3: _delivery_manager joined background discovery on every hook call, so a plugin
whose register() hangs cost every invoke_hook/has_hook another 30s; a join that
times out once is not repeated (the mid-discovery race fix is kept).
- P3: hermes hooks test post_curator_run sent the generic session payload; it now
sends the real shape (run_dir, run_json_path, report_md_path, dry_run).
Review fixes for the post_curator_run salvage:
- `hermes curator run` never registered `hooks:` shell hooks: startup
registration runs only for agent commands. `curator run` joins
`_AGENT_SUBCOMMANDS` (beside `cron run/tick` and `gateway run`), so its
pass reaches configured, consented shell hooks and plugins discover in the
background as they do there.
- That exposed a startup race: `_delivery_manager()` joined the background
plugin scan only when `_discovered` was False, but the scan sets that flag
when it STARTS. A hook fired while the scan was still loading saw a
half-loaded registry and silently skipped user plugins. It now always joins
an in-flight scan first.
- The hook fired even when run.json or REPORT.md failed to write
(`_write_file` swallows the error). `_write_file` now reports success and
the hook fires only once both files are on disk.
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.
Second independent review of #151120:
- P2: every open queued its own task behind its predecessor with no bound, so
under `plugins.hook_callback_timeout: 0` a hung callback let every later open
of that session pile up (41 pending tasks in the review's probe). Now at most
one delivery runs and one queues per (profile, session); opens arriving while
that one still queues join it and fire once after the running one, with the
latest open's payload (an open is setup, so firing it once is enough). The
first join logs one WARNING.
- P3: the delivery thread started before `has_hook('on_session_open')` was
checked. The loop now asks `hook_known_unused` first, under the owning
profile's home override: safe mode, or that profile's plugins already loaded
with no callback for a hook no first-party observer handles, answers without
discovering plugins or reading config, and no thread starts. A profile whose
plugins are not loaded yet still goes to the thread, which discovers and
checks `has_hook` off the loop as before.
Plugins had no way to act when a session opens: on_session_start waits
for the first agent turn and never fires on a reopen, so a memory
provider cannot pre-load context and a status consumer cannot show the
session as open (#89385).
on_session_open now fires in the gateway, at the canonical authority's
one open seam (AuthorityConnection.resume, which session.create ends
in), whenever a client connection attaches to a local session it was
not already attached to. Kwargs: session_id, platform (cli, tui,
desktop, acp, ...), reason ("create" or "resume").
- Once per open: a snapshot poll on an attachment the client already
holds and a reconnect's event replay fire nothing; no process-global
dedup set.
- Runs under the owning profile's runtime scope, so a multiplexing
gateway dispatches to that profile's plugin manager only.
- Delivered on a thread of its own via hermes_cli.lifecycle.invoke_hook
(first-party observers, then plugins), bounded by
plugins.hook_callback_timeout, fail-open. The create/resume reply
never waits on it; the session's next claimed turn does, so plugins
see the open before the model does.
- No plugin code runs in the classic CLI process (PLG-7).
- Bypass launches (--safe-mode / --ignore-user-config) fire nothing.
- Internal openers (kanban workers, A2A, onboarding, branch attach)
pass the right reason.
Salvage of #118895 by @Sahil-SS9: same hook and kwargs, moved from the
TUI JSON-RPC handlers and the CLI REPL to the gateway seam that creates
and resumes local sessions on main.
Fixes#89385
Co-authored-by: Sahil-SS9 <218421507+Sahil-SS9@users.noreply.github.com>
Main exports it from hermes_cli.plugins and hermes_cli.plugins_registrars.
Restore it with main's behaviour (it builds the method from the row it is
given, so the shared row body stays a parameterised helper) and the facade
import, and test that the method it builds matches main's: name, qualname,
docstring, signature, and registration into the row's registry.
make_scoped_provider_registrar lost its only caller when the setattr loop
became explicit methods, so remove it and its facade import, and fold the
now single-caller _register_with_row into register_scoped_provider.
Add a test that each admit-gated registrar judges admission under the
manager's home, not the process home, so dropping the _plugin_home_scope
block (or skipping admission) fails a test.
Main exports it from the facade, so the move must too. Restores the
re-export and its identity check, and adds a test that every name
importable from hermes_cli.plugins on main still is.
Rename hermes_cli/plugin_context.py to hermes_cli/plugins_context.py (and its
test to tests/hermes_cli/test_plugins_context.py) so it sits in the
plugins_<topic>.py sibling family that the facade grep convention covers.
Regenerate the plugin_api.json source label and public-api.md.
Stop re-exporting _ignore_after_abandoned_load from hermes_cli.plugins:
nothing reads it through the facade, and internal moves do not get shims.
hermes_cli/plugins.py was 2,163 lines, about 800 of them the PluginContext
class. The class, its setattr-built provider registrars and the
abandoned-load guard loop now live in hermes_cli/plugin_context.py;
plugins.py drops to 1,345 lines.
hermes_cli.plugins keeps re-exporting PluginContext, _UNSET and
_ignore_after_abandoned_load, and every name it imported before is still
imported there. Functions and classes the ctx methods call
(load_config_readonly, _plugin_settings_entry, get_hermes_home, PluginState,
PluginToolOverrideError, ...) are read from hermes_cli.plugins at call time,
so a monkeypatch on the facade still reaches ctx methods. Log records keep
the hermes_cli.plugins logger name, and typing.get_type_hints on
PluginContext.__init__ still resolves PluginManager.
The public plugin API list names the new file as PluginContext's source.
Tools run in the shared gateway, so a variable of the terminal or pane that
shows a conversation (a pane id, its socket) never reaches the commands the
agent runs for it. A plugin could only rewrite each `terminal` command with
`tool_request` middleware to prefix an `export`, which changes the command
text and does not cover every spawn.
`ctx.register_session_env(names, resolver)` declares the names and a
`resolver(session_id) -> {name: str | None}`. The child-env bridge
(`tools/environments/local.py::_inject_session_context_env`) calls the active
profile's resolvers with the child's own HERMES_SESSION_ID each time it builds
a local child env: terminal foreground and background, `execute_code`'s
`terminal()`, and the other children that already get HERMES_SESSION_*.
`None` unsets a name; an omitted name keeps the gateway's value.
- Names must be valid env names outside HERMES_*, so core session vars stay
core's. Values pass the same internal-secret and provider-blocklist
predicates as the scrub, so a plugin cannot put a credential back.
- LocalEnvironment keeps the declared names out of the shared bash snapshot
(the existing save/restore + dump exclusion for passthrough names). Without
that, the snapshot sourced before each command replaces the fresh value with
a stale one when a session's pane changes or goes away.
- A resolver that raises is logged with its traceback and contributes nothing.
- Registrations are scoped to the plugin manager's profile and released on
unload through the registration ledger.
- Remote backends (Docker, SSH, Modal) are out of scope: they do not receive
session context vars today either.
The new registrar lives in the hermes_cli/plugins_session_env.py sibling; the
facade method is a delegate, offset by a duplicated docstring paragraph in
_delivery_manager so plugins.py does not grow.
A plugin frontend that is a JSON-RPC client of the gateway could not call
its own Python half, and the Python half could not reach the viewers of one
session. Plugins passed data through shared files and tool.complete payloads.
ctx.register_rpc(name, handler) serves plugin.<plugin_id>.<name> on the
session authority, after the core handler table, with the gate of a plugin
slash command: session:control, plus the session authorization when the call
names a session_id. The handler runs off the loop in the owning profile scope;
a failure answers 4001 plugin_rpc_failed. The ownership ledger removes the
methods on unload and force rediscovery.
ctx.emit_to_session(session_id, event, payload) (and
plugin_events.emit_plugin_session_event) publishes plugin.<plugin_id>.<event>
on that live session event stream only. The session is found by its
conversation id or its resident agent current id, so an id from after
compression still reaches the viewers.
Salvages the idea of #66874 as a smaller redo on the canonical gateway.
Co-authored-by: eiritsu <yoeiritsu@gmail.com>
Plugin tool handlers, pre_tool_call / post_tool_call / transform_tool_result
hooks, tool middleware and system-prompt sections receive conversation_id
next to session_id. It is the compression-lineage root of the session (the
walk prompt_cache_scope already uses), so a rotating compression keeps it
while /new and /branch start a new one. A delegated subagent and a
background-review fork report their parent's conversation, stamped at spawn.
Memoized per physical session id: one lineage walk per segment, none per
tool call.
Plugins that keyed per-conversation state had to call the internal
SessionDB.get_compression_lineage (and walk _delegate_from markers) to
find the conversation.
The staged context references were found by slicing the manager's
registration list from the offset saved at load start. An earlier
registration disposed while the plugin loaded shortens that list, so the
reload's entries slid below the offset and the old provider kept answering
while the plugin was reported as reloaded.
Each load's PluginContext now keeps the registrations it staged, and a
successful load publishes exactly those, then clears the list so a
provider that holds its ctx does not keep the provider it replaced.
A forced plugin re-discovery (reload) re-runs register(), but the plugin's
@-prefix was still held from its first load, so the new provider was refused
with "prefix 'x' is already registered" and the stale one kept answering.
Context-reference registrations now go through the plugin ownership ledger.
The prefix table remembers which plugin on which manager claimed a prefix.
Unloading keeps the provider registered, as before, and only releases the
claim. When the same plugin on the same manager registers that prefix again,
the new provider is staged on a ledger entry and published only after the
plugin's load succeeds. A load that fails or times out disposes the entry
first, so the working provider and its owner stay exactly as they were.
Everything else matches main: providers stay in one process-wide table shared
by every profile; a second registration of a prefix in the same load, another
plugin, another profile's manager or a second manager are refused with the
same warning; built-in prefixes are refused; both registration calls still
return None when called as before.
A plugin that rewrites the reply (redaction, policy filters) can declare that it
must see the reply before the user does. The declaration rides the hook's
registration handle, so it lives exactly as long as the registration and is
scoped to the plugin manager of the profile that loaded it; stream_held()
answers for the active profile. Plain transform registrations keep streaming
(opt-in), and the flag on any other hook is ignored with a warning. The memory-provider hook proxy and the
`plugins validate` probe stub accept the keyword so a declaring plugin loads
through every registration seam.
Shape and seams salvaged from #102481 (mutates= on register_hook, the memory
proxy and validate-stub forwarding).
Co-authored-by: Halldrix <12357213+Halldrix@users.noreply.github.com>
Password-manager integrations must come from verified sources. ctx.register_login_backend
now refuses every plugin that is not bundled with Hermes or installed from the plugin
catalog at tier verified or official and at the catalog's reviewed pin.
Provenance is read from the installer-owned .install-metadata.json catalog block of the
manager's own home (tier, pin, allow_removed), never from the plugin tree, so a repo that
commits a forged .hermes-catalog.json gains nothing. Local directories, Git URL installs,
community-tier entries, --ref (off-pin) and --allow-removed installs, project plugins and
pip entry points are refused with a warning that names the rule. No config key relaxes it.
The registrar table gains an `admit` option (module:function over the manifest, judged under
the manager's home before the registry is touched); the factory moves from plugins.py into
plugins_registrars.py to carry 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
A portable plugin's skills registered as agent-plugin-<slug>-<sha8>:<skill>
(agent-plugin-blender-5a80e4ba:blender) because one manifest field named both
its plugin-data directory and its skill namespace. The hash only matters on
disk. Skills now take the plugin's own name (blender:blender), the form every
native plugin skill uses; a clash with an already-registered qualified name is
skipped with a warning naming the owner, as before. The data directory keeps
its hashed name, so no plugin data moves, and skill_view still resolves names
saved in the old form.
The delegate_task schema is built from the active backend and is cached prompt,
so a session-only /delegation switch changed routing but not the schema.
- Remove the session-only backend override (get/set_session_backend,
session_delegation_config, the /new boundary clear). delegate_task routes on
delegation.backend.
- set_global_backend(name, *, session_key='', apply_now=False): saves config;
apply_now rebuilds that session's tools at its next turn (after the pin
restore, so fresh agents rebuild too) and re-pins them, one opt-in cache break.
- The undeclared-parameter refusal names the fix: /delegation <b> --now or /new.
- Docs: delegation guide + provider-plugin API table.
Under plugins.isolation: host a /delegation handler calling agent.delegation_backends
changed the plugin host's copy of the session overrides, not the one delegate_task
reads, and listed the host's (empty) registry. ctx.delegation_backends exposes the
same API as plain data and is a host remote facade, so the call runs in the Hermes
process. Greptile P1 on #142563.
PluginContext.ask_choice(question, choices) -> str | None lets a sync
slash-command handler ask the user who ran it to pick one option and get
the picked value back. Choices are strings or {value, label, description}.
Each surface binds an asker around the handler call
(hermes_cli/plugin_choices.py), and every asker is that surface's
existing clarify prompt. No surface gets a new card type or wire shape:
- messaging chats (gateway/plugin_command_choice.py): adapter.send_clarify
plus the clarify tool's own delivery (_clarify_send_then_wait, text
fallback, card retire). Telegram/Discord/Slack show buttons, other
platforms a numbered list. The typed reply reaches the clarify
text-intercept while the command still holds the chat.
- local sessions on the gateway (classic CLI, Ink TUI, Desktop): the
`clarify` server request to the session's viewers. Two fixes make the
answer arrive while slash.exec is still waiting for the handler:
* tui_gateway/ws.py: a viewer's answer to an open server request (a
response frame, `clarify.lock`) is settled at once instead of queuing
behind that socket's running slash.exec.
* hermes_cli/gateway_plugin_commands.py: the classic CLI answers the
session's `clarify` requests with its clarify panel while it waits for
slash.exec. No turn pump reads the session's frames between turns.
- in-process classic CLI and the legacy `hermes serve` backend: their
clarify panel / `clarify` server request.
Returns None when nothing can ask (hooks, cron, async handlers on the
event loop), when the user cancels or answers with something that is not a
choice, or when the clarify timeout passes. The handler then prints its
text usage.
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.
The Singularity/Apptainer backend (tools/environments/singularity.py) now ships
as the official 'singularity' plugin in NousResearch/hermes-official-plugins,
registered through the terminal-environment provider seam under the same
backend name and config keys (terminal.backend: singularity,
terminal.singularity_image / TERMINAL_SINGULARITY_IMAGE, terminal.container_*).
- 'singularity' leaves BUILTIN_BACKEND_NAMES so the plugin can register it;
every hardcoded classification set drops it (the provider declares
is_remote/is_container/supports_streams instead).
- LEFT_CORE gains a singularity row: homes whose terminal.backend (or .env
TERMINAL_ENV) is singularity get the catalog plugin once, on hermes update
or agent/gateway start. An unknown-backend error for 'singularity' names
the install command (new row field terminal_backend).
- A plugin backend receives its per-task '<backend>_image' override; batch
runs register one for the active backend.
- BaseEnvironment's sudo-probe knob is renamed _passwordless_sudo_probe_supported:
plugin backends set it, and the old spelling trips the install scanner.
- Core's scratch-dir disk warning and process-exit sweep were Singularity-only
and move to the plugin; the singularity setup row, dashboard probe/row and
config defaults/bridges go too. Docs point at the plugin.
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.
Fires once after a successful context compaction so plugins/providers
can react (re-inject context, update indices, etc.). Gated on has_hook
for zero-cost when no listener. Observer-only, returns ignored.
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.
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
17 conflicts, all from main's lint sweep (ruff UP007/UP017/UP022/UP028/UP031/UP037/UP041,
FURB188/FURB192); 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). ruff.strict.toml takes main's copy. The pool-retirement live fixture stays
deleted with the pooled backend this branch retires.
45 conflicts, all from #135177 (lefthook + `ruff check --fix` over 2,366 files). No other main commit
touches a conflicted file. Resolution: the branch side of each file, then main's exact autofix
(ruff 0.15.10, `--config ./ruff.strict.toml --fix`) on it — rewrites only (typing generics, noqa
drops, import forms), no import removed. tests/cron/test_bot_chat_cli_home.py stays deleted
(1cc9cb9199 retired its lane).
main's ratchet caps every >2000-line facade at its main value; the PR grew seven.
- config.py: `hermes config show` rendering -> hermes_cli/config_show.py (reads config names via
the module at call time so hermes_cli.config.<name> patch seams hold).
- backup.py: the cron prompt-field safety net -> hermes_cli/backup_cron_prompts.py; also drops a
dead duplicate _PROTECTED_CONFIG_PATHS left by an earlier merge (the later definition won).
restore_config_model_settings_* stay in backup: they are on the frozen old-updater surface.
- profiles.py: Honcho host migration on rename -> hermes_cli/profiles_honcho.py.
- plugins.py: resolve_plugin_command_result -> plugins_dispatch.py (re-exported from plugins,
the public import path for cli/tui_gateway/plugins).
- main.py: --query-file reader -> hermes_cli/main_query_file.py.
- kanban_db.py: worker-context section renderers (_ctx_* + caps) -> hermes_cli/kanban_db_context.py;
build_worker_context stays in kanban_db.
- config_defaults.py: drop the blank line the gateway block gained.
Patch-target retargets (moved symbols only): test_plugins.py (asyncio / await timeout now in
plugins_dispatch), test_managed_scope_surfacing.py (show_config import), test_backup.py
(restore_cron_prompt_fields_if_degraded import).
(cherry picked from commit 4079d422e0c2283c500c16885e959f5c170eb6cf)
Plugins can now call ctx.register_automation_blueprint(key, *, title,
description, schedule_template, prompt_template, category, slots,
deliver_default, skills, tags). The fields mirror the built-in
AutomationBlueprint, and slots are BlueprintSlot field dicts, so the call
also crosses the plugin-host boundary.
- One lookup, cron.blueprint_catalog.list_blueprints() / get_blueprint(),
merges the built-ins with the active profile's plugin blueprints at call
time. /blueprint (CLI/TUI/messengers), /api/cron/blueprints and the
instantiate route all use it. Each dashboard route resolves inside the
?profile= scope, off the event loop.
- Keys are namespaced <plugin>:<key>, so a plugin cannot shadow a built-in.
A ':' in the key, a duplicate key, an unknown placeholder, a bad slot type
or a schedule that does not parse is warned and ignored at registration.
- Catalog entries carry source/plugin. Desktop fetches the catalog for the
profile it creates jobs in, keyed per profile, and shows the plugin name
on the blueprint row and in the "Start from" select. The dashboard shows
a plugin badge.
- A created job is an ordinary cron job with the prompt and schedule already
filled in, so it keeps running if the plugin is later disabled.
- The ctx content registrars (register_skill, now joined by
register_automation_blueprint) move to hermes_cli/plugins_content.py.
The dashboard's blueprint types move to web/src/lib/automation-blueprints.ts.
Closes#132373. Requested by @enckequity.
No behavior change. Keeps every touched file and function at or below
its value on main:
- agent/auxiliary_task_config.py: read-time `auxiliary.<task>`
resolution (plugin defaults, inherit_from, whole-route pin); still
re-exported as agent.auxiliary_client._get_auxiliary_task_config.
- hermes_cli/plugins_aux_tasks.py: register_auxiliary_task validation
and entry shape.
- web/src/lib/api-aux.ts: /api/model/auxiliary wire types.
- Desktop: aux row list, label resolver, deep-link highlight, route
summary, Follow button and the set-to-main route in
settings/aux-task-rows.tsx; one assignAuxiliary callback replaces
setAuxiliaryToMain. Built-in aux slot labels move from each locale
into <locale>_aux_tasks.ts (types_aux_tasks.ts holds the shape).
Salvage follow-up for #129189 on top of #129209:
- An unknown or self-referential `inherit_from` now logs a warning and
registers the task without inheritance instead of raising, so one bad
base no longer fails the whole plugin load (the #129191 approach).
- `provider: auto` on an inheriting task means "no preference", like the
empty strings: "Reset all to auto" (CLI + dashboard) writes exactly that,
and before this it pinned the slot to the main provider while the model
was still inherited from the base (mismatched route).
- Once the user pins a route on the task (non-auto provider, model or
base_url), provider/model/base_url/api_key/api_mode/key_env/effort all
come from the task's own block. Mixing per key let a pinned provider pick
up the base's base_url and api_key.
- The CLI picker resolves the inherited view only for inheriting tasks.
Tests collapse to behavior contracts: base followed and changes
propagate, picker placeholders keep following, a pin wins whole, bad
bases warn and are ignored, re-registration cycles are cut.
Co-authored-by: Yuan Li <dskwelmcy@163.com>