153073d9be2fcbabbd64213e3003ced284e4cb7e
205 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
231617ea5a | refactor(gemini): extract neutral model-family, URL, and output-budget timeout helpers | ||
|
|
6d18eb30a2 |
refactor(plugins): name the producer of a Hermes-started turn instead of a boolean
turn_internal() read execution trust, so a restart's resume of a person's interrupted turn, automations, plugin injections and Bot Chat deliveries all looked Hermes-started. Replace it with turn_origin() (and ctx.turn_origin()), which names the producer only where Hermes knows it: - "process_notification": a background process's completion, watch match or liveness tick (_inject_watch_notification). - "delegation_result": an async delegation's result re-entering its parent. Every other turn reads None. The producer sets the origin on its event; the committed automation row records it as turn_origin and restore reads it back, so a row without one (any other producer, or one an older build queued) restores as None and its fingerprint is unchanged. A late steer or interrupt text run as the next turn reads None. The started_by_hermes bookkeeping in the Bot Chat and API admission paths is removed. Trust, authorization, allow_gateway_control and model-facing text are unchanged. |
||
|
|
e8b16ba90c |
feat(plugins): tell plugins whether Hermes started the running turn
turn_client() is None both for a turn Hermes started itself (a background-process notification, a delegation result, an automation wake) and for a person's turn sent over a connection that announced no client, so a plugin cannot tell a wake from a typed message by it. hermes_cli.plugin_session.turn_internal() (also ctx.turn_internal(), which answers through the gateway under plugins.isolation: host) reads the running turn's own event: True when Hermes produced its input, False for a message someone sent (typed in a client, announced or not, on a messaging chat, or an API request), None outside a turn, in a delegated child, in a managed worker, in a plugin's own slash command and for a synthetic turn Hermes does not mark internal (a goal continuation). An API turn is marked internal for trust when it executes, so admission now records what the event was before that mark; an API event with no record reads None rather than True. It only reads the turn context at hook time: no system prompt, tool list, message or model request changes. |
||
|
|
16fd059ad8 |
feat(plugins): publish the Gemini thinking helpers for provider plugins
A provider plugin on the native Gemini wire (generateContent) has no published way to map a Hermes reasoning config onto thinkingConfig: the mapping lives in private core helpers, so a plugin either re-implements the per-model rules or imports internals the boundary lint rejects. The Solstice provider plugin needs this seam. Publish three helpers in agent.reasoning_effort under a new plugin_api.json group, document them in the model-provider guide and regenerate public-api.md: - gemini_thinking_config(model, reasoning_config): the shared Gemini thinkingConfig mapping plus the xhigh lift, keyed on the id the native client sends. - bare_gemini_model_id(model): the native client's prefix rule (gemini/ and google/ stripped), moved verbatim from agent.gemini_native_adapter into this import-light module; the adapter imports it back, so its existing name keeps working. - clamp_effort (already in the module). The gemini and vertex profiles are unchanged. test_reasoning_effort_plugin_api.py checks the helper against the gemini profile's own output across models and efforts (prefixed ids included), the prefix rule, the adapter's import name, and that importing the module loads no HTTP stack. |
||
|
|
feceed663e | fix(cron): keep plugin lookups within one profile | ||
|
|
bbdc728912 |
docs(plugins): note off-chain fallback in store.lineage.lineage guide paragraph
Clarify in website/docs/developer-guide/plugins/index.md that [0] of store.lineage.lineage(session_id) is the first id of the returned chain (not necessarily the original session) and that (session_id,) is also returned for a session with no compression chain or a session outside the oldest-continuation chain the lookup follows (such as a later sibling continuation), alongside fork children and tool-sourced runs. Pin the branch-fork and off-chain sibling cases in test_the_plugin_guides_lineage_read_gives_the_root_first_on_a_read_only_handle. |
||
|
|
a5a7a0784d |
fix(cron): use firing job settings in delivery_platforms and expose ctx.cron_delivery_platforms
Capture a delivery-relevant snapshot of the firing job inside cron.execution_identity.enter_cron_execution so delivery_platforms() with job_id=None answers from the run that is actually firing even when the saved job is edited or deleted mid-run, while explicit job_id lookups remain previews of the stored job. Add PluginContext.cron_delivery_platforms(job_id=None) (and tuple preservation in RemotePluginContext) so hooks running under plugins.isolation: host read the firing run's delivery platforms in the gateway in the calling hook's context. Re-export CronSchedulerRegistrationError from cron.plugin_api so plugins can catch it without a private core import, and update the plugin guide example and tests accordingly. Addresses Greptile review feedback on PR #159657. |
||
|
|
1dd65c2587 |
docs(plugins): the lineage read returns only its own id for a tool session
The guide said `[0]` of `store.lineage.lineage(session_id)` is the session the conversation started in. The read treats every `tool` session and every fork child as a fork, so a `tool` run that continued after compression returns only its own id. The paragraph now says what the first id is and lists those cases, and the test pins the `tool` one. |
||
|
|
030a6c439e |
fix(cron): cron.plugin_api reads home one way and reports a failed registration one way
- `home` was expanded for `~` only, while core's profile bind also expands environment variables. For a directory whose path holds a literal `$NAME` with NAME set, the job was stored in the literal directory while its settings (time zone) were read from the expanded one, which the bind also created. `home` is now read the way Hermes reads a home path, once, for the existence check, the bind and the cron store. - A failed registration raised `CronSchedulerRegistrationError` for a new job but the provider's raw error for a job that already existed, so a second attempt against an unreachable provider raised a different type. Both now raise `CronSchedulerRegistrationError` carrying the saved job. - Docs: `delivery_platforms` answers for the normal delivery lane; a `failure_deliver` override is not consulted. |
||
|
|
5159f3be0d |
fix(cron): ensure_named_job reads the name from the job store, and the guide names the running job through ctx
`ensure_named_job` looked the name up with `list_jobs`, which also reads every job's latest and live run from the executions ledger and adds `latest_execution` / `live_execution` to each record. So an existing job came back with two keys a newly created job does not have, and every call paid for a ledger read it never used. The lookup now reads the job store and returns the same record shape either way. Docs for `delivery_platforms`: - With no job id it answers for the cron run bound in the calling process. A hook of a plugin running in a plugin host has no run bound there, so the guide and its example now name the job with `ctx.current_cron_execution().job_id`, which answers in both modes. - The answer is the stored job's: an edit saved while a run is in flight shows up, though that run delivers with the settings it started with. - `home` naming the process's own profile runs no external secret source; only another profile's first call does. |
||
|
|
92f61fa16d |
docs(plugins): name the storage-interface read that replaces get_compression_lineage
The old session store's `get_compression_lineage(session_id)` is not one of the methods the `hermes_state` stand-in carries, and the migration guide did not say what replaces it. A plugin that needs the session a conversation started in (for example to match a prompt to a chat after a compression) reads `store.lineage.lineage(session_id)` on the handle: the lineage's ids, root first, `(session_id,)` for a session that was never compressed and `()` for an unknown id. It works on a read-only handle. The guide now says so, and a test reads a three-session chain that way through `open_persistence_reader`. |
||
|
|
80d6bba3dc |
feat(cron): publish cron.plugin_api for scheduling a named job and reading delivery platforms
A plugin can now create one named follow-up job in a profile, once, with `ensure_named_job`, and ask which platforms cron will deliver a job's output to with `delivery_platforms`, without importing cron.jobs, cron.scheduler, cron.scheduler_provider or private helpers of cron.scheduler_delivery. Both functions forward to the code cron already runs (job creation with scheduler registration, the provider's register_job, and cron's own delivery-target resolver) and add no rule of their own. `home` runs the call with that profile bound whole, the way core binds a profile (its Hermes home, secrets and terminal policy) plus its cron store. A profile other than the process's own also runs under multiplex semantics, as a cron fire for it does, so its own time zone sets a schedule and its home channels and provider credentials are the ones read. `~` is expanded, and the caller's state is restored afterwards, also when the call raises. A `home` that is not an existing directory is never created: `ensure_named_job` raises FileNotFoundError and `delivery_platforms` returns None. A hosted activity cannot act for a profile, so binding `home` is refused there. `AmbiguousJobReference` is re-exported for the duplicate-name case. `ensure_named_job` refuses, with ValueError and before any lookup, a name that is not a non-empty string free of leading and trailing whitespace: cron could never find such a name again, so every call would add a job. The module is listed as a whole in plugin_api.json, documented in the plugin guide, and covered by tests against a real cron store. |
||
|
|
f261cd2d41 |
feat(plugins): plugins can read how the session was created, delegated children and forks
A notification plugin uses these to alert only for the user's own turn, without importing gateway, agent or tools internals. `hermes_cli.plugin_session.session_source()` (and `ctx.session_source()`) returns the label the calling session was created with, its launch policy's `source`: cli, tui, gui, acp, tool or oneshot for a chat a person started; any other non-empty value is the label of a session Hermes started itself. "" says only that no launch policy is bound: outside a session, for a person's messaging chat turn and for a cron run. It reads only the running turn's policy, never `os.environ`. `in_delegated_child(*, include_subprocesses=False)` (and the ctx method) is True while the code runs for a `delegate_task` child; with `include_subprocesses=True` also in a process such a child started. `fork_origin()` (and the ctx method) is "" for a session's own agent and every other regular agent, and the fork's label inside a detached fork: "background_review", "side_question" or "plugin_fork:<plugin id>". The ctx forms answer under `plugins.isolation: host` the same way `ctx.turn_client()` does: the call runs in the gateway, in the calling hook's context. Listed in plugin_api.json (public-api.md regenerated) and the plugin guide. |
||
|
|
c8bb9645e6 |
feat(plugin api): publish the gateway's silence helpers for platform plugins
A platform plugin that decides whether a finished turn's reply is worth sending can now read Hermes's own rule instead of importing private core names: - gateway.response_filters:is_intentional_silence_response: True only when the whole reply is a silence marker such as [SILENT] or NO_REPLY. - gateway.response_filters:strip_trailing_silence_marker: the reply without a marker that closes it on its own line; anything else is unchanged. - gateway.response_filters:is_autonomous_silence_response: the looser rule for runs with no user waiting (cron, webhook), which also treats a reply opening with the bracketed sentinel as silent. The three names are listed in the "Public helpers for platform plugins" group of plugin_api.json, documented as one row of that page's table, and public-api.md is regenerated. No line of gateway/response_filters.py changes, and no other name of that module becomes public. The boundary lint baseline is unchanged: no bundled plugin imports these names, and a full --update would only drop unrelated stale rows. Test: a plugin importing the three names validates with no private-import warning, while silence_allowed from the same module still warns, and the helpers answer what the docs row says. Red on main. |
||
|
|
06296e269e |
feat(plugins): tell plugins which prompt a gateway session is waiting on
Add two observer hooks, on_session_prompt and on_session_prompt_settled, fired by the gateway session owner for each prompt a person answers for a session's viewers, with the id that answers it: - approval / clarify: when SessionAuthority.register_approval / register_clarify has published the approval.request / clarify.request event (prompt_id = the event's prompt_id); settled whenever the prompt leaves PendingControls.pending (snapshot, a remote_responders answer, a managed worker's prompt_settled frame), reason "settled". - request frames: when session_server_requests._ask has opened and written a sudo, secret, clarify (batch), vault.unlock_prompt, vault.code or vault.save_login frame (prompt_id = the srq- id); settled after its request.cancel with that event's reason. Window requests, replay=False requests and an _ask that returns early never fire. params is a deep copy of what the viewers received with every string force-redacted through redact_approval_display(force=True); it never holds an answer. Calls are queued to one FIFO worker thread, so plugin code never runs under event_stream.lock or the request registry lock, on the agent thread or on the event loop, and each runs in the owning profile's owner_scope (for a request frame: the served authority whose live session owns the stream, else the asker's context). Plugin exceptions are logged at debug and swallowed. Event payloads, publish order, open_requests replay, return values and on_human_input_* are unchanged. Both names join VALID_HOOKS and are documented in the observer-hooks, hooks, plugins and plugin developer guide pages. |
||
|
|
fe9a4b58ec |
feat(profiles): never run a profile on the host while a plugin runs it elsewhere (#156725)
* feat(profiles): never run a profile on the host while a plugin runs it elsewhere
One host gateway serves every profile by default and runs each profile's
cron, messaging platforms, Kanban dispatch and Webapp; the CLI, TUI and
desktop build agents on the host too. A plugin that runs a profile's whole
backend somewhere else (for example in a sandbox, through its own host
launcher) had no way to stop the host from also running that profile outside
it, reading config the sandbox can write.
A host-side plugin now marks such a profile in host-only storage under the
Hermes root, never in a profile home:
<hermes root>/profiles_run_elsewhere/<profile>.json
{"plugin": "<plugin name>", "since": "<ISO 8601 UTC>"}
The file's presence is the marker, and an unreadable marker still marks the
profile. Writers write a dot-prefixed temp file in the folder and rename it
over <profile>.json. hermes_cli.profiles_run_elsewhere reads it and gives
host-side plugin code mark_profile_run_elsewhere() and
clear_profile_run_elsewhere().
For a marked profile:
- profiles_to_serve() leaves it out, the default profile included, unless
the caller passes include_run_elsewhere=True. The host gateway stops
serving it at its next rescan, and the desktop cron ticker, /p/<profile>/
routing and the dashboard's cron and session fan-outs skip it. Callers
that only look for live gateways, count installed homes or read which
worktrees a resumable subagent pins opt in (host attach, the launch
profile policy, the multiplex counts, the worktree sweep's pin view).
- AIAgent refuses to build an agent for it (ProfileRunsElsewhere), whichever
frontend asks, including a multi-profile host building a sibling's agent.
- CLI commands that run a turn exit 1 before any banner, TUI or gateway
contact; `hermes serve` and `hermes dashboard` exit 78 before attaching or
binding; the gateway process exits 78 before reading config.
- ensure_gateway_runtime() answers inaccessible / profile_runs_elsewhere
before discovery, so nothing starts or attaches to it on the host.
- The dashboard's cron, session, file and Webapp requests for it answer 409,
the desktop cron ticker's gate refuses it, and the Kanban dispatcher
leaves its cards in ready (skipped_nonspawnable).
A process that cannot list the marker folder (permission denied) is the
backend the plugin runs, not the host: it refuses nothing. Any other error
reading the folder fails closed. A profiles folder the process cannot list
shows only the process's own profile instead of raising PermissionError.
_seed_file_if_missing moves to profiles_initialization.py, its only caller,
to keep profiles.py under its size cap.
* fix(profiles): close review gaps in the run-elsewhere marker
Follow-up to "feat(profiles): never run a profile on the host while a
plugin runs it elsewhere", from the first review of #156725.
Checks added where a host process could still run a marked profile:
- cron.scheduler_tick.tick() returns before the tick lock, the due scan or
any job for a marked profile, so every in-process ticker skips it: the
gateway's (its launch profile included), the desktop's, and the built-in
fallback an external provider starts. CronScheduler.claim_fire() claims
nothing for it, for a provider's inbound fires and the misfire sweep.
- AIAgent.run_conversation() makes the check AIAgent.__init__ makes, so an
agent built before the profile was marked (a gateway's cached agent, an
open dashboard or TUI session) runs no further turn.
- The dashboard's deferred agent build refuses first, before it binds the
profile's scope or starts its MCP servers.
- `hermes gateway run` exits 78 in _prepare_agent_startup, with or without
--force: before plugin discovery, shell-hook registration and the
host-gateway attach guards.
The marker module:
- run_elsewhere_for_home() reads the home as written and as resolved, and
refuses when either reading is marked. A symlink or junction to a profile
home, a relative or `..` path, or the profile id in another letter case
now reaches that profile's marker.
- mark_profile_run_elsewhere() publishes a new marker with a hard link,
which never replaces a file: of two plugins that both found no marker,
one claims the profile and the other gets the ValueError. Where the
filesystem has no hard links it renames as before.
clear_profile_run_elsewhere() returns False without unlinking when it
finds no marker, so it cannot remove one published after it looked. No
lock is taken.
- Only a missing marker folder means nothing is marked. A regular file in
its place refuses every profile, like any other read error.
- The folder reader returns one shape, _MarkerFolder(names, error).
- mark_profile_run_elsewhere, clear_profile_run_elsewhere and run_elsewhere
are listed in plugin_api.json and public-api.md is regenerated, so
`hermes plugins validate` accepts a plugin that imports them by name.
Corrections to that commit's message:
- "A profiles folder the process cannot list shows only the process's own
profile instead of raising PermissionError" now holds only for a process
whose own home is a named profile under that folder (the backend a
plugin runs elsewhere). Any other process gets the PermissionError, as on
main, so activate_multi_profile_hosting_eagerly() fails closed again for
a default-profile host that cannot list the folder.
- "Any other error reading the folder fails closed" did not hold for a
regular file at the folder's path, which read as "nothing marked". It
holds now.
- "Writers write a dot-prefixed temp file in the folder and rename it over
<profile>.json": the Python API's first write of a marker is the hard
link above. Its rewrite of an existing marker, and other writers, still
rename.
Not changed: a gateway or a serve/dashboard backend already running as the
marked profile is not stopped. It runs no further turn and no cron job for
the profile, and stays up until it is stopped.
* fix(profiles): load no env file or secret source from a marked home
Second follow-up to "feat(profiles): never run a profile on the host while
a plugin runs it elsewhere", for the review finding "CLI runs code before
refusing" on #156725.
While a plugin runs a profile elsewhere, the backend it runs writes the
profile's home. Every `hermes` start loads that home when hermes_cli.main
is imported (load_hermes_dotenv), before argparse and before any refusal,
and so does the plugin's own host process. A `secrets:` source that
backend wrote into its own config.yaml therefore ran on the host as the
user: `secrets.command` through /bin/sh on Linux and macOS,
`secrets.onepassword.binary_path` as a program on every OS. A .env it
wrote reached the environment of every such start, overriding what the
process already had.
Now a dotenv load whose home is marked takes nothing from that home:
- load_hermes_dotenv() does not read, rewrite or publish the home's .env,
does not load .op.env and resolves no `secrets:` source. It asks once
per load (run_elsewhere_for_home: a path resolve and a listing of a
folder that is normally not there) and treats the two files as absent,
so the project .env takes the precedence it has for a home without a
.env. The project .env, the administrator-managed .env, the
config-backend boot and the terminal bridge are unchanged.
- The config-backend bootstrap (_bootstrap_env) takes no selector or plane
credential from a marked home's .env or .op.env, also when it runs
before the first load. bootstrap_deployment() passes the load's answer
on, so one load asks once.
- hydrate_profile_secret_sources() resolves nothing for a marked home, so
a host gateway or dashboard that serves the profile runs none of its
sources either.
A process that is denied the marker folder is the backend the plugin runs:
its home reads as not marked and it loads its own files as before. A
marker folder that cannot be read for any other reason already refuses
every profile; no profile's env files or secret sources are loaded either
until it can be read, and the log line says so.
What this changes for a marked profile: a host process started under its
home has none of its .env values in the process environment and none of
the keys its secret sources supply. The marking plugin supplies what its
own host process needs.
Not covered: hermes_cli.config.load_env() and the readers built on it
(get_env_value, reload_env) still open the .env file when asked, and the
secret scope a multi-profile host builds for a profile it serves still
reads it. Neither runs anything.
* fix(profiles): start no command and read no env value from a marked home
Third follow-up to "feat(profiles): never run a profile on the host
while a plugin runs it elsewhere" (#156725), on top of "load no env file
or secret source from a marked home".
While a plugin runs a profile elsewhere, the backend it runs writes the
profile's home. Two kinds of host process still acted on what that
backend wrote there (measured under a marked profile with stand-ins that
only append a line to a file):
- Commands that start a command the profile's own files name, without
building an agent. `hermes hooks test` ran a shell hook from
config.yaml. `hermes mcp test` started an `mcp_servers` stdio command,
and sent an HTTP server's request to the address in its entry.
`hermes secrets onepassword status` and `sync` ran the program
`secrets.onepassword.binary_path` names. `hermes send` loaded the
home's .env into the process with a loader of its own.
- Code that reads one env value on demand. The previous commit stopped
the dotenv load; load_env() and get_env_value() still opened the
home's .env. So `hermes status` listed keys that backend wrote as
configured, `status --all` sent a request with a bearer from the file
to a URL from the file, `status`, `dump` and `auth list` copied its
keys into the profile's auth.json, and HERMES_REDACT_SECRETS was taken
from it.
Now, for a home that is marked:
- tools.hosted_tool_policy: the four host features that start a process
from the profile's files (RUNS_PROFILE_COMMANDS: shell_hooks,
mcp_stdio, cron_scripts, skill_inline_shell) are off, at the place
each already asks whether it may run in a hosted scope, and
host_feature_refusal() answers with the run-elsewhere message. The
one subprocess site of shell hooks starts nothing (`hooks test`,
`hooks doctor`, a hook registered before the profile was marked), and
the MCP stdio transport starts nothing, whoever asks.
- The MCP probe (_probe_single_server: `mcp test`, `mcp add`,
`mcp configure`, `doctor`, the dashboard and TUI routes) raises
ProfileRunsElsewhere before it validates, resolves, starts or calls a
server, stdio or HTTP. `mcp login` and `mcp reauth` refuse first,
before they drop the stored tokens or the device flow calls the
entry's server.
- `hermes secrets <source> <verb>` exits 1 with the message of the
commands that run a turn (one wrapper where the verbs are registered).
- `hermes send` exits 1 the same way, before its own loader reads the
home's .env and config.yaml credentials into the process.
- agent.secret_scope.load_env_file(), the one .env tokenizer, reads a
file in a marked home as empty and does not open it. That covers
hermes_cli.config.load_env(), get_env_value(),
get_env_value_prefer_dotenv(), reload_env(), the credential pool's
seeding from .env, and the secret scope a multi-profile host builds
for a profile. Hermes's own .env writers (save_env_value,
remove_env_value) do not read through it and still write the file, so
a key the user saves through the marking plugin's host process lands
there. A file in any other folder (a plugin's host-only copy) reads as
before.
- `hermes status --all` does not probe LM Studio at model.base_url: with
the .env values out of reach, the address in config.yaml still sent a
request from the host.
- `hermes status` and `hermes config` print one line saying that the
profile's .env keys are not read on this host, because they now show
as not set.
The check behind the tokenizer and the features is
profiles_run_elsewhere.home_runs_elsewhere(home): the answer of
run_elsewhere_for_home, kept per process and home. Each call stats the
marker folder and the home's marker file, and asks again when that
differs from the stat taken before the last asking, so a marker written
or removed by any process is seen at the next call. A marker folder that
cannot be read marks every home, as it does for running a profile, and
is asked about again every time. A process that is denied the folder is
the backend the plugin runs: it reads its own .env and runs its own
hooks and MCP servers as before.
This corrects the previous commit's message, which said "Not covered:
hermes_cli.config.load_env() and the readers built on it (get_env_value,
reload_env) still open the .env file when asked, and the secret scope a
multi-profile host builds for a profile it serves still reads it". Both
are covered now.
Not covered: config.yaml of a marked home is still read (`hermes status`
and `hermes config` show it). `quick_commands` of type exec still run in
a chat client, gateway or TUI backend that was already running when the
profile was marked. resolve_home_dotenv() (two config migrations) still
parses the home's .env. Plugins in the home are still discovered.
* fix(profiles): no quick command runs for a profile that runs elsewhere
A quick_commands entry of type exec is a shell command in the profile's
config.yaml, a file the backend the plugin runs writes. The refusals so
far keep a hermes command from starting, on a marked home, a process
that dispatches one. Three cases still reached the three places that
start the command (the classic CLI, the gateway, the TUI / dashboard
backend):
- a chat client, gateway or backend that was already running as the
profile when it was marked: its turns are refused, its slash commands
were not;
- a dashboard or `hermes serve` backend on another profile's home, whose
command.dispatch takes the profile with the request (the `profile`
parameter, or a session of that profile);
- a multiplexing gateway: its own quick commands are the default
profile's whichever profile's process started it
(load_gateway_config_for_runner), so a gateway started from a named
profile while `default` is marked had them.
Each of the three places now asks run_elsewhere_refusal() before it
starts the command and answers with the run-elsewhere message instead.
The home asked is the one whose config.yaml names the command: the home
bound for the request in the TUI / dashboard backend and for a local
session of the gateway, the process's own in the classic CLI, and for a
gateway's messaging commands the home its config was loaded from
(_hm_quick_commands_home: the default profile's when it multiplexes).
Alias quick commands are unchanged, and so is the backend the plugin
runs, which does not see the marker.
* test(profiles): fire the marker race helper after the module's own look
`_between_look_and_change` runs an action right after the marker module's
next look at a profile's marker, to play the writer that gets in between a
look and a change. It patched `os.listdir`, `os.lstat` and `_read_entry`,
and fired as soon as a call for the marker returned.
The suite's home guard (`tests/home_io_guard.py`) wraps `os.lstat` too, and
resolves the path before it calls the real function. On POSIX
`os.path.realpath` lstats every component of the path through `os.lstat`,
so the helper saw the guard's own lstat of `<profile>.json` first and fired
inside the guard, before the module's lstat had run. In
`test_a_clear_that_found_no_marker_never_removes_one_published_after_it_looked`
the other plugin's marker was therefore already in place when
`clear_profile_run_elsewhere` looked, and the call raised `ValueError`
instead of returning False. On Windows `realpath` does not call `os.lstat`,
so the test passed there and failed on Linux only.
The three wrappers now share a depth counter and fire only when the
outermost patched call returns: a look made inside a look is part of it.
The action runs at the same point on both systems, after the module's own
look and before its change. No product code changes.
* fix(mcp): refuse "mcp add" first for a profile a plugin runs elsewhere
`hermes mcp add` reached the run-elsewhere refusal only inside its probe,
and treated it like any failed connection: it printed "Failed to connect"
and offered "Save config anyway", which wrote the server entry (disabled)
into the marked profile's config.yaml. For an HTTP server it had by then
asked for a bearer token and saved it to the profile's `.env`.
`cmd_mcp_add` now refuses before its first question, the way `send` and
the `secrets` verbs do: the message on stderr, exit 1, nothing asked and
no file of the profile changed.
The probe's other callers leave nothing written when the probe refuses
(`mcp test`, `mcp configure`, the dashboard and TUI test routes, the
connector install, the OAuth flows) and are unchanged.
* test(profiles): gate the Windows letter-case test with the platforms marker
`test_a_profiles_folder_spelled_in_another_letter_case_reads_the_marker_on_windows`
was gated with a bare `skipif(os.name != "nt")`. The Windows lane imports
only files that carry a `platforms(...)` spec covering Windows and selects
with `-m platforms`, so the test ran on no CI host (tests/AGENTS.md: "Use
the marker, never a bare `skipif`"). It now carries
`@pytest.mark.platforms("windows")`. No other test this branch adds gates
on the host with a `skipif`.
* docs(dashboard): say which requests _cron_profile_home() refuses
The helper's docstring said that the host "neither reads nor runs" a marked
profile's "jobs, sessions or files". The helper answers 409 only to the
requests that resolve their profile through it: every cron request (an omitted
profile resolves to the backend's own), and the session and file requests that
name the profile. A session or file request with no profile uses the backend's
own home without asking the helper, as the description's "Not covered" section
says. The docstring now says that. No code change.
Found in review.
* fix(profiles): ask again when a home's link leads to another profile
home_runs_elsewhere() keeps its answer per process and home path, and held it
valid while a stat of the marker files it had worked out was unchanged. Those
files belong to the directory the path led to at the first asking. When the
home is a symlink or junction and the link is pointed at another profile, no
marker is written or removed, so the kept answer stayed: pointed at a marked
profile, run_elsewhere_for_home() refused the home while load_env_file() still
read the marked profile's .env; pointed away from one, the unmarked home's
.env read as empty. Reproduced with a symlink on Linux and with a symlink and
a junction on Windows. A link above the home (the root itself) was already
seen, because the marker paths are read through it.
The kept answer is now also for the directory the path leads to: each call
stats the home and compares device and file id with the stat taken before the
home was resolved. That is one more stat per call. Measured for a plain home,
the cached check goes from 2.5 to 5.4 us on Linux and from 7.0 to 12.3 us on
Windows, and load_env_file() from 17 to 20 us and from 104 to 112 us; through
a link on Windows the check goes from 27 to 71 us. Resolving the home at every
call instead would add 23 us on Linux and 87 us on Windows, more than the
whole check.
Found in review.
* fix(profiles): a second name for a marked profile's home is not served either
Found in review. With profiles/alias a link to profiles/ops (a symlink, or a
junction on Windows), marking ops took only the name ops out of
profiles_to_serve(): the list was filtered by name, so the host gateway kept
alias in its served set, although every check that asks by home refused it.
Two more checks asked by name and let the link through: the Kanban
dispatcher's profile_exists_here(), and the dashboard's profile resolution
_cron_profile_home(), behind the cron, session, history and file requests
that name a profile.
All three now ask by home. The served list and the dispatcher use the kept
answer of home_runs_elsewhere(), which costs stats per profile instead of a
resolve and a folder listing; the dashboard asks run_elsewhere_for_home()
and answers 409 with the marked profile's name. The kept answers hold 4096
homes instead of 256, so a host with several hundred profiles still answers
its list from stats.
* fix(profiles): a clone made under a marked name keeps the keys it was cloned with
Found in review. Creating a profile mirrors the launch profile's .env into
it, but only over the seeded comment-only stub, never over the keys a clone
brought. That check asked the .env tokenizer what the new file holds, and
the tokenizer answers with nothing for a home a plugin runs elsewhere. A
profile cloned under a name whose marker was already there (left behind
when an earlier profile of that name was deleted) therefore looked empty,
and the launch profile's .env was copied over the cloned keys.
The check now reads the destination as the file it is
(load_env_file(..., for_overwrite_check=True)). Nothing else reads a marked
home's .env: every value reader still gets nothing from it. A new profile
whose .env is the stub still receives the launch keys, marked name or not,
as every new profile does.
* fix(profiles): a marker covers its profile's directory under every name
Found in review, as the mirror of the link case fixed before: with
profiles/ops a symlink or junction to profiles/real and ops marked, the
directory's own name real was still listed, served, built and run on this
host, and its .env was read. A home was followed to the profile its path
leads to, but not to the other names that lead to its directory, while the
backend elsewhere runs in that one directory whatever it is called.
run_elsewhere_for_home() and home_runs_elsewhere() are the two functions
every refusal asks. Both now also compare the home's directory (device and
file id) with the home of each profile the root's marker folder marks, so a
marked name that is itself a link marks the directory it leads to, under
that directory's own name too. An error or a filesystem without file ids is
never a match.
The kept answer of home_runs_elsewhere() adds one stat per other marked
profile, which also sees a marked link pointed at another directory. It
learns of a new marker under another name from the marker folder's time, so
a listing taken less than two seconds after the folder changed is not
relied on and is taken again at the next call, without resolving the home
again: two changes can share one tick of a filesystem's clock.
* fix(profiles): home maintenance waits while a plugin runs the profile elsewhere
After an installed revision changes, the first start of each profile runs
home maintenance for its own home (boot_bootstrap): the config migration,
which first copies config.yaml and .env beside themselves as
<name>.bak-<stamp>, the plugin-catalog cache drop, launcher publication and
the default-plugin check. Every hermes command and the gateway process make
that call before any command can refuse. A host start under a marked
profile, the marking plugin's own status and switch-off commands included,
therefore rewrote config.yaml under the backend the plugin runs and left a
byte copy of the keys file in a home that backend reads and writes.
run_boot_bootstrap now asks run_elsewhere_for_home() for this process's
home when maintenance is due (a new revision, or a step still owed), before
it takes the record lock. For a marked home it runs no step and writes no
record, so the maintenance stays owed and the first start after the marker
is gone does it. The question is asked by home: a marked home reached
through a link, and the directory behind a marked link, are covered. The
backend the plugin runs (it is denied the marker folder) and every unmarked
profile, the default one included, are maintained as before. A marker
folder that cannot be read holds maintenance back, as it refuses every
profile.
A start whose record says this revision is done reads its record and
returns as before; nothing is asked on that path.
One log line says why: "home maintenance: the '<plugin>' plugin runs
profile '<name>' elsewhere, so this host leaves its home alone; it is owed
until the profile runs here".
* fix(profiles): the backend migration does not move a profile a plugin runs elsewhere
`hermes gateway migrate --backends --apply` and the dashboard's "move to the
gateway" request (`POST /api/gateway/migrate/backends/apply?profile=`) went
ahead for a profile a plugin runs elsewhere. The move wrote `.env` and
`config.yaml` in that profile's home, installed and started a gateway service
for it and stopped its old backend. The gateway then refused to run the profile
and exited, so the run could only end in its rollback, which put the saved
`.env` and `config.yaml` back over whatever the backend the plugin runs had
written in the meantime.
The refusal a marked profile gets everywhere else is now one of the blockers
the apply path adds before anything changes. The command exits 3 with it, the
dry run and `GET /api/gateway/migrate/backends/plan` list it, and the
dashboard's request answers 409 and starts no run.
* fix(profiles): the config.yaml of a profile a plugin runs elsewhere sets no host environment variable
Importing `gateway.run` copies settings of the launch home's `config.yaml` into
the process environment. Among them is every top-level scalar of the file,
under the scalar's own name when that name is not set yet. `hermes -p <profile>
gateway status` imports the module, and so does the gateway process before it
refuses a marked profile. While a plugin runs the profile elsewhere, the
backend it runs writes that file, so it could choose `LD_PRELOAD`,
`NODE_OPTIONS`, `PYTHONPATH` or a proxy for that host process and for every
program the process starts afterwards. The home's `.env` was already closed for
this reason; `config.yaml` was a second way in.
`load_launch_home_dotenv()` in `env_loader.py` asks once whether a plugin runs
the launch profile elsewhere, runs the dotenv load with that answer
(`load_hermes_dotenv(home_elsewhere=...)`, the keyword the bootstraps already
take) and returns it. `gateway.run` calls it where it called
`load_hermes_dotenv`, and for a marked home it does not read the file for its
bridge. A home without a marker is asked about as often as before, and its
bridge is unchanged.
* fix(profiles): reading an env file under a folder named like ~user no longer raises
`load_env_file()` asks whether the file's folder is the home of a profile a
plugin runs elsewhere. That question expanded a leading `~name` with
`Path.expanduser()`, which raises `RuntimeError` when no user has that name.
So on Linux and macOS, with no marker anywhere, a relative path whose first
folder is named like `~someone` made the tokenizer raise ("Could not determine
home directory."), where it had always read the file as written or returned
`{}`. Windows guesses a folder for any `~name` and did not raise.
The marker question now expands with `os.path.expanduser()`, as its stat of the
home already did: a `~name` that is no user's stays as written, which is the
path the read opens.
* fix(profiles): the refusal says how to get a profile back when its plugin is gone
A marker can outlive the plugin that wrote it: the plugin was removed or
disabled, it no longer loads, or the Hermes root came back from a backup taken
while the profile ran elsewhere. The owner then meets the refusal at every
command that runs the profile, and its advice was to turn this off in a plugin
he no longer has. Core has no command that clears a marker, and the refusal
named neither the file nor another way.
The refusal for a marker that names its plugin keeps its sentences and ends
with one more: if that plugin is no longer installed or no longer loads,
deleting the marker file (named by its path) lets Hermes run the profile on
this computer again, and the file is not to be deleted while the plugin still
runs the profile. The user guide says the same.
* test(profiles): marking a profile leaves the marker folder listable by other local users
On Linux and macOS `mark_profile_run_elsewhere()` sets the marker folder to
0755. A host service that runs as another local user must be able to list the
folder: a listing that is denied reads as "this process is the backend the
plugin runs", and such a process refuses nothing. No test noticed when that
`chmod` was removed. This one marks under umask 077, and marks again after the
folder was made 0700, and expects 0755 both times.
* test(profiles): the quiet-folder test no longer depends on how fast it runs
`test_a_marker_folder_that_has_been_quiet_is_not_listed_again` expects 150
listings of the marker folder "a moment after the marker was written". The
module stops listing once the folder's time is two seconds old, so a test run
that stalls for two seconds between writing the marker and the end of that loop
counts fewer listings and fails. It did once on a loaded machine.
The test now stands the module's clock at the folder's own time before it asks
for the first time, as it already moved that clock forward for its second half.
* test(profiles): the marker question by home does not raise for a folder named like ~user
The dotenv load asks whether a plugin runs a home's profile elsewhere through
`run_elsewhere_for_home()`, which expanded a leading `~name` the way the
tokenizer's question did. The test of a folder named like a user that does not
exist now asks through both, so each of the two expansions has a test that
fails when it raises again.
* fix(profiles): the backend migration plans no step against a profile a plugin runs elsewhere
The block for a marked profile sat among the blockers of the apply path, which
a plan that can only be done by hand never reaches. On Windows every plan is of
that kind, and there the backend a plugin runs is a process of this host
(`hermes serve --isolated` under the profile's home). So `hermes gateway
migrate --backends --apply`, with or without `--dry-run`, found that process as
an old backend of the marked home, exited 6 and printed the steps of a move by
hand: `taskkill /PID <its pid> /T /F`, then installing a gateway for the
profile.
The refusal is now the first answer of the plan's own owner check, which every
form of the plan passes before a step is chosen. A marked home gets a blocked
plan (exit 3) with the run-elsewhere message and no step, on every platform;
the dashboard's plan and apply routes read the same plan.
* test(profiles): the public marker functions are pinned by what the validator does
`test_the_user_guides_marker_example_validates_clean` read the user guide from
the repository, cut its Python example out, parsed it and compared the names
it imports with a list. That is a test of a file's text. What it guarded is
that `hermes plugins validate` calls the three documented marker functions
public, and `test_the_documented_marker_functions_are_public_plugin_api`
already pins that by running the validator on a plugin that imports them:
with one of the three taken out of the public list, that test fails.
The guide-reading test is removed. The other tests of this branch read only
files under their own temporary homes.
* fix(profiles): no form of the backend migration acts on a profile a plugin runs elsewhere
The block for a marked profile sat in the migration's plan, and several
forms of `hermes gateway migrate --backends` never reach the plan or act
before it:
- `--apply --detach` started the run in the background and reported it as
started; only that run then refused.
- `--restore` undid a move that was made before the profile was marked: it
stopped and removed the gateway service, wrote `config.yaml` and `.env`
back from the move's backups and started the old backend.
- A move that did not finish was rolled back the same way by the next
`--apply` or `--restore`, and the dry run named the command that does it.
- A second `--apply` on a moved home named `--restore`.
- Every form but the dry run made the run lock in the marked home first.
The command now refuses where every form enters: for a marked profile
`--apply` and `--restore`, with any other flag, exit 3 with the
run-elsewhere message before the home's record is read or its lock is made.
Nothing is written, started or stopped, and the record of an earlier move
stays for when the profile runs on this host again. `--status` still reads.
The dashboard's `POST /api/gateway/migrate/backends/apply` and
`.../restore` answer 409 `blocked` with the same message for a marked
profile, start no run and name no command.
* fix(profiles): the lists of old backends say when a plugin runs the profile elsewhere
The backend a plugin runs for a profile can be a `hermes serve` process of
this machine, which the backend migration's scan finds like any other old
backend of that home:
- `hermes gateway migrate --backends` listed it without a word about the
plugin and ended with the line that offers the dry run of its move.
- After `hermes update`, the notice called it "an old Hermes backend for
this profile" and offered the same dry run.
- The rows the dashboard's plan route returns said nothing about it either.
A listed backend whose home's profile a plugin runs elsewhere now carries
one more note, in the report's text and JSON and in the dashboard's rows:
"Profile 'ops' runs elsewhere (the 'x' plugin runs its backend): Hermes
does not move this backend to the gateway on this host." The report offers
no dry run when its own profile is marked, and the update prints no notice
for such a profile. The move itself is already refused for it.
* fix(profiles): the blocked plan of a profile a plugin runs elsewhere lists no backend to move by hand
Where a backend can only be moved by hand (on Windows every one), the plan
of a marked profile printed no step but kept the entry above the blocker:
"manual cannot be migrated automatically ... Run the steps below in
PowerShell or Command Prompt ... Steps, in this order", with nothing under
it. The dashboard's card prints "This server cannot be moved from here" and
those instructions for every such entry.
The marker's check is now its own step of the plan, before the checks of
which gateway serves the home, and the plan it blocks lists no backend at
all: the text is the home and the blocker, and the JSON has an empty
`unsupported`. The other reasons a plan is blocked print as before.
* fix(profiles): the refusal's last sentence says "on this host" like the sentences before it
The sentence the refusal gained for a plugin that is gone said that deleting
the marker file "lets Hermes run the profile on this computer again", two
sentences after "Hermes does not run it on this host". The message and the
user guide say "host" everywhere else, so this sentence does too.
* test(profiles): the line for a listed backend says what the marker tells
The line a listed backend of a marked home carries has three forms: the
plugin by name, "a plugin" when the marker file cannot be read, and "Hermes
cannot read <folder>" when the marker folder cannot be read. The tests of
the report covered the first. This one reads all three from real markers.
* fix(ci): a change to the run-elsewhere marker module starts the update suite
The notice `hermes update` prints about an old backend
(hermes_cli/update_backend_notice.py) now asks whether a plugin runs the
profile elsewhere, so it imports hermes_cli/profiles_run_elsewhere.py. The
change classifier did not route that module to the upgrade E2E lane, and
tests/ci/test_update_ci_routing.py failed for it:
e2e_upgrade: imported by the update path but not routed to it:
{'hermes_cli/profiles_run_elsewhere.py': ['hermes_cli/update_backend_notice.py']}
The module joins the lane's owner list, beside the backend-migration marker
the same notice reads.
* fix(profiles): a marked profile's key_cmd is not run on this host
`providers.<id>.key_cmd`, and a custom provider's `key_cmd`, is a shell
command line in the profile's own `config.yaml`. Hermes runs it to get the
provider's key, with the profile's environment and credentials. For a
profile a plugin runs elsewhere, the backend there writes that file, and
nothing on this path asked the marker: the dashboard's
`GET /api/model/options?profile=<name>` ran a marked profile's command once,
as it does for any profile.
`_mint`, the one place every `key_cmd` runs, now raises `CommandTokenError`
with the run-elsewhere message for a marked profile. The model picker turns
that error into a probe without a key, so it still answers; the same request
now runs the command zero times.
The fix and its test are the reviewer's patch from the review of
6a60a75a669, taken as posted.
Co-authored-by: Bear Huddleston <196404565+BearHuddleston@users.noreply.github.com>
* fix(profiles): a dashboard file request never dials a marked profile's SSH workspace
A file request that names a profile is answered 409 when a plugin runs that
profile elsewhere. For a profile whose workspace is on an SSH host the
request went another way first: `_fs_backend` read `terminal` from the
profile's `config.yaml` and dialed the host named there before the route
reached the refusal. `GET /api/fs/list?profile=<name>` and
`GET /api/fs/default-cwd?profile=<name>` dialed the host a marked profile's
config names.
`_fs_backend` now resolves the profile first, which answers 409 for a marked
one before its config is read. Every file route that can go to an SSH host
passes through it. A request that names no profile behaves as before. Two
existing tests call the real `_fs_backend` with a profile that is not on
disk; they now stand in for the lookup.
The fix and its tests are the reviewer's patch from the review of
6a60a75a669, taken as posted.
Co-authored-by: Bear Huddleston <196404565+BearHuddleston@users.noreply.github.com>
* fix(profiles): gateway ensure and attach refuse a marked profile whose directory is a link out of the root
A marker covers the profile's directory whatever path leads to it. But
`ensure_gateway_runtime` made the home canonical before it asked the marker.
When `profiles/ops` is a link to a directory outside the Hermes root, the
canonical path has no Hermes root above it and so no marker: `gateway ensure`
went on to discovery for a marked profile and did not answer
`profile_runs_elsewhere`. `attach_gateway` resolves the home before it calls
`ensure`, so it went the same way.
Both now ask about the home as it was given too. In `ensure` the check sits
inside the existing assignment, which keeps the function at the complexity
cap; `attach_gateway` checks before it resolves. The answer for a marked
profile is the one `ensure` already gave: `inaccessible`,
`profile_runs_elsewhere`, the refusal in `detail`.
The fix and its test are the reviewer's patch from the review of
6a60a75a669, taken as posted.
Co-authored-by: Bear Huddleston <196404565+BearHuddleston@users.noreply.github.com>
* fix(profiles): marked profiles still count when an external cron registry may be shared
An external cron provider keeps one remote registry that is not scoped to a
profile, so Hermes uses it only on a host with a single profile. Two callers
decide that by counting the served profiles, and a profile a plugin runs
elsewhere is no longer in that list:
- The gateway chose its scheduler with the number of profiles it ticks. On a
host with `default` and a marked `ops` that number is 1, so the gateway
kept the external provider, which reconciles the registry toward
`default`'s jobs when it starts.
- The dashboard skips an external reconcile when it counts more than one
profile. With the other profiles marked, the reconcile ran.
On main both counts included `ops`. If the backend elsewhere arms that
profile's jobs through the same provider account, such a reconcile can
cancel them.
Both callers now count the marked profiles where the question is who may
share the registry. The profiles the gateway ticks and the dashboard lists
are unchanged. Three existing stand-ins for `_cron_profile_dicts` accept the
new keyword.
The fix and its tests are the reviewer's patch from the review of
6a60a75a669, taken as posted.
Co-authored-by: Bear Huddleston <196404565+BearHuddleston@users.noreply.github.com>
* fix(profiles): a marked profile's speech command is not run on this host
`tts.providers.<name>.command` and `stt.providers.<name>.command` are shell
command lines in the profile's own `config.yaml`, and one runner starts
both. The dashboard reaches it for a named profile without building an
agent: `POST /api/audio/speak?profile=<name>` ran a marked profile's TTS
command, and `POST /api/audio/transcribe?profile=<name>` ran its STT command
and returned what it printed. The backend a plugin runs elsewhere writes
that file, so this is the host starting a command line that backend wrote,
as with a provider's `key_cmd`.
`run_command_provider`, the one place both kinds run, now raises
`RuntimeError` with the run-elsewhere message for a marked profile. The
callers already turn a `RuntimeError` of the runner into their own failure
answer, so the speak request answers 400 with the message and the
transcribe request answers that the transcription failed.
* fix(profiles): the gateway's clients ask about a linked profile's home before they resolve it
`gateway ensure` and `gateway attach` now ask the marker about the home as
it was given. Two callers resolve the home before those functions see it,
so a marked profile whose directory is a link out of the Hermes root still
got past them:
- `connect_gateway`, which `hermes sessions discard` and `adopt` and the
cron and Kanban clients call. None of them passes the command line's own
refusal first, and for such a profile it went on to discovery and could
start a gateway.
- The TUI's bootstrap script, which an open TUI runs again whenever its
gateway is gone. A TUI that was open before a plugin took the profile
over started a gateway for it again.
`connect_gateway` asks about this process's home before it resolves it and
raises the error it already raises for a gateway it may not attach to
(`inaccessible`, `profile_runs_elsewhere`). The bootstrap script passes the
home to `attach_gateway` as the environment names it; `attach_gateway`
resolves it after its own check.
* fix(profiles): the plugin host takes no launcher and no package from a marked profile's home
With `plugins.isolation: host` every plugin of the profile loads in a child
process. Its command line began with `plugins.host.launcher` from the
profile's own `config.yaml`, and the child started in the profile home with
that folder first on its import path. For a profile a plugin runs elsewhere
the backend there writes both: `hermes -p <name> status` started the launcher
that file named, and a `hermes_cli` package placed in the home ran in the
child instead of Hermes's own.
For a marked profile `host_launcher()` now reads the launcher from the
managed overlay only, which that backend cannot write; with none set there,
the child starts without a launcher. The child is started with `-P`, as the
profile extraction already was, so the folder it starts in is no longer on
its import path. That part applies to every profile: a module that sits in
the profile home can no longer be imported by name from a hosted plugin.
Hermes's own packages still come from `PYTHONPATH`, and a plugin's own
package is loaded by its path as before.
The fix and its tests are the reviewer's patch from the review of
cd58d712aa6, taken as posted.
Co-authored-by: Bear Huddleston <196404565+BearHuddleston@users.noreply.github.com>
* fix(profiles): a marked profile's password manager binary is not run on this host
`vault.bitwarden.binary_path` and `vault.onepassword.binary_path` name a
password manager's command line program in the profile's own `config.yaml`.
The Settings dialog's `vault.unlock` request hands that program the master
password the person typed, without building an agent. For a profile a plugin
runs elsewhere the backend there writes that file, and nothing on this path
asked the marker: the request ran a marked profile's program and gave it the
password.
`_bw` and `_op`, the one place each manager's program is looked up for
unlock, list and fill, now raise `RuntimeError` with the run-elsewhere
message for a marked profile. `vault.unlock` answers with its usual error
5095 carrying that message. The local vault does not pass either function.
The fix and its test are the reviewer's patch from the review of
cd58d712aa6, taken as posted.
Co-authored-by: Bear Huddleston <196404565+BearHuddleston@users.noreply.github.com>
* fix(profiles): a marked profile's browser executable is not started on this host
`browser.executable_path` names the Chromium a local browser session starts,
in the profile's own `config.yaml`. `hermes doctor --live` launches it to
check that a browser can start, without building an agent. For a profile a
plugin runs elsewhere the backend there writes that file, and nothing on this
path asked the marker: `hermes -p <name> doctor --live` started the program a
marked profile named.
`launch_chromium`, the one place a local Chromium is started, now returns its
usual `(None, error)` with the run-elsewhere message for a marked profile.
`doctor --live` reports the browser probe as failed with that message.
The fix and its test are the reviewer's patch from the review of
cd58d712aa6, taken as posted.
Co-authored-by: Bear Huddleston <196404565+BearHuddleston@users.noreply.github.com>
* fix(profiles): the cron registry count sees a marked default beside a standalone gateway
Whether an external cron provider's registry may be shared was decided from
the larger of two counts: the profiles the gateway ticks and the installed
ones. A gateway that runs as a standalone profile ticks only itself, and the
installed list leaves a standalone profile out. With `default` marked and the
gateway running as a standalone `ops`, both counts were 1, so the gateway
took the external provider and reconciled its registry toward `ops`'s jobs
alone, although the marked `default`'s backend may arm jobs there too.
The count is now the number of different profile names in the two lists
together. With no marker every profile in the installed list is one the
gateway ticks, so the count is the number of profiles it ticks, as before.
The fix and its test case are the reviewer's patch from the review of
cd58d712aa6, taken as posted.
Co-authored-by: Bear Huddleston <196404565+BearHuddleston@users.noreply.github.com>
* fix(profiles): a managed launcher expands its env refs for a marked profile too
For a profile a plugin runs elsewhere the plugin host's launcher is read
from the managed overlay alone. That read took the overlay's file as
parsed, so a ${VAR} in plugins.host.launcher reached the child's command
line unexpanded, while every other profile got the expanded value.
host_launcher() now asks apply_managed_overlay({}), which expands refs
against the process env the way the config loader does.
* fix(profiles): a marked profile linked out of the root does not get its own launcher
`hermes -p ops` names the home `<root>/profiles/ops`. When that is a link
to a directory outside the Hermes root, the plugin manager is keyed by the
directory the link leads to, and the plugin host asked the marker about
that directory, which has no marker folder above it. So the host child of
such a profile still started under the `plugins.host.launcher` its own
`config.yaml` names.
The manager now keeps the home as it was named (`owner_home`), and the
host passes it to `host_launcher()`, which asks the marker about that
home. Other callers of `host_launcher()` are unchanged.
The fix and its test are the reviewer's patch from the review of
b3d3693bb6a, taken as posted.
Co-authored-by: Bear Huddleston <196404565+BearHuddleston@users.noreply.github.com>
* fix(profiles): an empty PYTHONPATH entry does not put the profile home on the host's path
The plugin host's child starts in the profile home, with `-P` so that
folder is not on its import path. `-P` drops only Python's own first
entry: an empty entry in `PYTHONPATH` (`PYTHONPATH=:/x`, or a trailing
separator) still means the current directory, and the child inherited
such entries as they were. A module placed in the profile home then ran
in the host child again, ahead of the standard library.
The inherited entries are now made absolute against the parent's working
directory before the child gets them, so an empty or relative entry means
for the child what it means for the parent. This applies to every
profile, like `-P` itself.
The fix and its test are the reviewer's patch from the review of
b3d3693bb6a, taken as posted.
Co-authored-by: Bear Huddleston <196404565+BearHuddleston@users.noreply.github.com>
---------
Co-authored-by: Bear Huddleston <196404565+BearHuddleston@users.noreply.github.com>
|
||
|
|
3829eed29e |
feat(plugins): plugins can read the turn's client and who is attached to its session
A notification plugin uses these to skip a phone alert while the user is active at the client that sent the turn. `hermes_cli.plugin_session.turn_client()` (and `ctx.turn_client()`) returns the label the submitting connection announced, from the turn's own admission stamp, or None outside a turn, in a delegated child, and for unannounced, messaging and cron turns. `session_viewers()` (and `ctx.session_viewers()`) lists the connections attached to the calling session with their idle data (`gateway.session_presence.viewers`). The session comes only from what the calling task-local context bound (never `os.environ`): a turn's, or the one a plugin's own slash command was typed in, which the gateway binds the same way (no turn runs there, so `turn_client()` is None). A context with only a route bound names no session and reads []. The live session must answer to the bound route, so another session's id is never borrowed. A delegated child, which runs in a copy of its parent's context, reads []. The authority is the one `TurnRunner` binds its owner with: the active runtime scope's, so a routed profile's turn reads its own authority, never the launch profile's. No gateway in the process (CLI, managed worker, plugin host): []. Both are labels and reports clients chose: attribution only. Listed in plugin_api.json (public-api.md regenerated) and the plugin guide. |
||
|
|
8f239226bc |
fix(plugins): plugin writes refuse a deleted or renamed profile home
A session still bound to profile b survives `hermes profile delete b` and `hermes profile rename b c`. Its next plugin write recreated profiles/b through a raw mkdir, and nothing raised. Seven plugin state writers now create their directories through mkdir_under_hermes_home, which refuses a missing or tombstoned named home with its existing FileNotFoundError: plugin_data_dir (and the hermes-achievements fallback that duplicates it), the CLI plugins dir, the update-check markers, disk-cleanup state, the Discord recovery ledger, the Weixin account dir and the A2A audit log. Callers that already catch keep skipping the write (Discord recovery, the update-check writers, the disk-cleanup session-end hook and audit log, the A2A audit). The disk-cleanup slash commands reply that the profile no longer exists instead of raising. plugin_data_dir documents the refusal. |
||
|
|
f998a982cb |
feat(ci): warn, never fail, naming each lost core name and the plugins' catalog records
Some checks failed
Deploy Site / deploy-vercel (push) Has been cancelled
Deploy Site / deploy-docs (push) Has been cancelled
Skills Index Freshness Check / check-freshness (push) Has been cancelled
Skills Index Freshness Check / check-catalog-cors (push) Has been cancelled
Docs Search Monitor / probe (push) Has been cancelled
Build Skills Index / build-index (push) Has been cancelled
Build Skills Index / trigger-deploy (push) Has been cancelled
The catalog check no longer blocks a core PR. It reports every break as a warning, in three places: a check annotation per plugin, the job summary, and a warning item in the live CI review comment. The report says: - each core name the change removes, whether it is private (needs a public interface) or already on plugin_api.json (judged against the base's copy), and which plugins import it; - for each affected plugin: its title, version, tier, category and maintainer; its repository, subdir and pin; links to its plugin-catalog/<name>.yaml and its marketplace page; and a link to each import line at the pin. The breaks-catalog-plugin label is gone: with nothing to block, there is nothing to override. The step runs after setup-pm because the catalog loader needs ruamel.yaml. Review fixes in the same pass: a try nested in a branch that still runs can lose its own feature and is reported (greptile, BearHuddleston); a lost branch only names imports that resolved on the base; a bare annotation binds nothing; the daily refresh parses with Python 3.14, the shipped runtime (BearHuddleston). Co-authored-by: Bear Huddleston <196404565+BearHuddleston@users.noreply.github.com> |
||
|
|
509a92c0aa |
fix(ci): a module __getattr__ answers only the names it spells, plus guard tests
A PEP 562 hook was treated as answering any name, so removing a name from hermes_cli/config.py or hermes_state.py (the modules catalog plugins import most) was never reported. A hook now answers the strings in import-time code, in the hook, and in the module functions it calls by name. Adds one test per guard the reviewers showed could be removed with every test still green, and points the documented local command at the merge base so a branch is not blamed for names main added after it was cut. Co-authored-by: Bear Huddleston <196404565+BearHuddleston@users.noreply.github.com> Co-authored-by: unsupportedpastels <274530371+unsupportedpastels@users.noreply.github.com> |
||
|
|
d45aac385e |
feat(ci): name the pinned catalog plugins a core PR breaks, before it merges
Catalog plugins live in their own repos, pinned by sha, and many import Hermes modules that are not on the published plugin API. When a core PR removes or renames such a module or name, nothing in this repository's CI sees it: the plugin's code is not here. This week the storage rewrite broke three that way (OpenViking via agent.message_content, Honcho via hermes_state_common, holographic via hermes_state_wal: #157818), each found only after users upgraded. - scripts/ci/catalog_core_imports/ (31 shards, ~780 KiB) records every Hermes import each of the 2,514 catalog entries makes at its pinned sha, parsed by plugin_validate_private_imports.hermes_import_sites (the same parser `hermes plugins validate` uses). An import inside a try that catches ImportError carries its alternatives, so a plugin that already falls back is not reported. - `catalog_core_imports.py check` (Repository guards, PR python lane) resolves each import against the base and the merge commit from git objects alone: no network, no plugin code, nothing imported. It only resolves imports whose module files the PR touches (every import when compat/moves.py changes): 0.3 s on a typical PR, 2-3 s on the storage-rewrite commits. - On failure it names plugin, file:line and import, and offers: open a PR for an official seam (ctx method, hook, plugin_api.json entry), keep the old name via compat/moves.py, or the breaks-catalog-plugin label. - catalog-core-imports.yml re-indexes added or repinned entries daily and opens a bot PR. The check asks only whether a name still exists; a name that stays but changes behaviour or signature passes. |
||
|
|
63102706e8 |
feat(plugins): hermes plugins config edits a plugin's settings in the terminal
Plugins declare their settings in config_schema and requires_env, and the Desktop renders them as a form, but the CLI had no way to see or change them short of hand-typing plugins.entries.<id>.settings.<key>. `hermes plugins config <name>` lists every declared setting with its current value and edits one at a time (choices and bool as pickers, numbers and JSON type-checked, secrets masked), saving through the same writers as the Desktop form: save_plugin_settings for config.yaml and the PUT /api/env credential route for .env. Without a TTY it prints the settings instead. plugins show and install point at it. plugins_settings.py becomes a package (fields.py unchanged, facade re-exports). |
||
|
|
c95fb6947f |
fix(compat): the holographic 0.29.x catalog pin opens its store again
#151855 folded hermes_state_wal into sqlite_support and removed the module. The catalog-pinned holographic memory plugin (0.29.2, plugin-catalog/holographic.yaml) does `from hermes_state_wal import apply_wal_with_fallback` when it opens memory_store.db, so on v0.23 every turn logs "holographic: cannot open memory_store.db (No module named 'hermes_state_wal')" and recall is dead. A catalog repin does not change an installed plugin's source, and `hermes plugins update` reinstalls the same pin. - hermes_agent/compat/moves.py: hermes_state_wal -> sqlite_support. Every name the old module published is in sqlite_support, unchanged, and apply_wal_with_fallback is already a published plugin API there. - plugin_validate_private_imports: a moved module is judged public under its current spelling as well, so the alias does not make `plugins validate` list the old import as private while the same call through sqlite_support passes. - Plugin guide: the kept-imports table names it, with the same v0.27.0 window. Fixes #157818. Part of #157077. |
||
|
|
b1db37d2b9 |
fix(compat): carry only the turn helpers pinned catalog plugins import, until v0.27.0
Some checks failed
Skills Index Freshness Check / check-freshness (push) Has been cancelled
Skills Index Freshness Check / check-catalog-cors (push) Has been cancelled
auto-fix lint issues & formatting / Generate eslint --fix patch (push) Has been cancelled
auto-fix lint issues & formatting / Apply patch (push) Has been cancelled
Deploy Site / deploy-vercel (push) Has been cancelled
Deploy Site / deploy-docs (push) Has been cancelled
Review follow-up. The compat layer now keeps exactly the old imports the catalog's OpenViking 2.1.2 and Honcho 1.2.0 pins make at load time, and says so: - agent.context_compressor_retry is no longer aliased (no catalog plugin imports it), and agent.skill_commands re-exports only extract_user_instruction_from_skill_message (neither pin imports register_auto_load_scaffold). - moves.py admits a folded module only when a catalog-pinned plugin imports it. - plugins/AGENTS.md and the plugin guide record the exception: which names, where they live now, and that they follow the hermes_state stand-in's window (removed no earlier than v0.27.0). |
||
|
|
95038c9bcd |
Merge pull request #151855 from NousResearch/refactor/storage-remove-sessiondb
refactor(storage)!: SessionDB and the hermes_state modules removed, with a stand-in for outside plugins |
||
|
|
5ebfa750c5 |
Merge pull request #149567 from NousResearch/refactor/storage-callers
refactor(storage): every caller on the storage interface |
||
|
|
dc98d24f0b |
F29: the hermes_state stand-in's SessionDB resolves a short session id, as the plugin guide's example calls it
Main's SessionDB.resolve_session_id returns the exact id, else the one id a prefix matches, else None. The plugin guide's own chat-frontend example (website/docs/user-guide/features/plugins.md, _session_to_resume) calls SessionDB(read_only=True).resolve_session_id(...), and the stand-in had no such method: the example raised AttributeError. The stand-in's SessionDB forwards resolve_session_id to the store's sessions.resolve_id, which answers the same way, and the guide's table lists it. Proof: the new case (a unique prefix, an exact id and an ambiguous prefix through a read-only SessionDB opened as the example opens it) red before (AttributeError: hermes_state.SessionDB has no attribute 'resolve_session_id'), green after. The guide's _session_to_resume, extracted from the page and run unchanged against a seeded store, resolves a short id and a title and refuses an ambiguous prefix (helper-b probe_f29_docs_example.py, logs/f29-docs-probe.log). tests/hermes_cli/test_plugin_docs_public_imports.py 6 passed. Import-only check passes; ruff clean. Reported-by: teknium1 |
||
|
|
30361082ae |
F39: the hermes_state stand-in carries the five writer and read-pool helpers main publishes
Main's hermes_state imports WriterMutexTimeout, maintain_after_commit, write_site and writer_mutex_until from hermes_state_write and note_read_pool_exhausted from hermes_state_readpool, so all five are importable from hermes_state; F39 at the swap level restores them there. The removal replaced hermes_state.py with a stand-in that forwards only its listed names, so the five raised AttributeError again from this level up. The stand-in now lists the five and forwards each to its home at this level (persistence/sqlite/_state/write.py and persistence/sqlite/_state/readpool.py), with a warning that names no public replacement. The plugin API list, its generated page and the plugin guide's table carry them, since the stand-in's names and the published list are pinned equal. A new case imports each from hermes_state and checks it is its home's object. Proof: tests/test_hermes_state_standin.py new case red before (AttributeError: module 'hermes_state' has no attribute 'WriterMutexTimeout'), green after; the plugin API list, docs-imports, published-API and backend-import-guard tests pass (12, 6, 173, 30). The one stand-in case still red is the callers-level append_batch keyword (see F20). Import-only check passes; scripts/ci/check_backend_imports.py clean; ruff clean. Reported-by: unsupportedpastels |
||
|
|
f328ed72bb |
docs(plugins): the hook fire-site table names session_retention.py for on_session_delete
The plugin guide's table of where each hook fires named hermes_state_common.py for on_session_delete. That module is gone at this level; emit_session_deleted now lives in session_retention.py, and the row names it there. |
||
|
|
9ad5718ab0 |
fix(state): a hermes_state_registry stand-in and list_gateway_sessions keep mcp-serve reading conversations
The official mcp-serve plugin gets its transcript handle from hermes_state_registry.acquire() and builds its routing index from SessionDB.list_gateway_sessions; with neither carried, its message reads answer "Session database unavailable", its event polling stops and the index comes back empty. hermes_state_registry.py returns as a stand-in: acquire(db_path=None) opens a hermes_state SessionDB of its own for the caller, release(db) closes it and returns True as main's did for a lent handle, and release_or_close(db) closes it. The first acquire in a process emits the stand-in's one deprecation warning in its own words, naming persistence_assembly.open_persistence and the removal release, at the plugin's call; a process that has already had the hermes_state warning gets no second one. The stand-in's SessionDB carries list_gateway_sessions(*, platform=None, active_only=True), main's keyword-only signature, held open for the call like its other methods, and returns each session row with its last_active as main did. Both are listed in the plugin guide's replacement table and in hermes_cli/data/plugin_api.json, public-api.md is regenerated, and the test that fires at the removal release names hermes_state_registry.py among the files to remove. |
||
|
|
b3d44ed9b1 |
fix(state): the stand-in carries the moved helpers and the plugin API lists its names one by one
The hermes_state stand-in now also forwards the nine public helpers main exported that live on in shared modules outside the backend: format_session_db_unavailable and get_last_init_error (storage_user_copy), resolved_max_resume_messages and resolved_max_export_messages (storage_limits), preflight_db_writability and read_only_db_uri (sqlite_support), holder_pid_checkable (process_identity), make_user_dir (hermes_dir_acl), and divert_session_transcript_jsonl, which supplies the profile's sessions folder under HERMES_HOME as main's did. Each one warns through the stand-in's once-per-process deprecation warning, naming its replacement. hermes_cli/data/plugin_api.json lists hermes_state name by name instead of as a whole module, and lists the nine replacements, so hermes plugins validate reports an import of any name the stand-in does not carry (the old class's mixins and the SQLite backend's own helpers) instead of passing a plugin that fails on import. The plugin guide's replacement table names the nine and their replacements, and public-api.md is regenerated from the data file. |
||
|
|
8fd1fcbe0c |
docs(agent): an agent built on a SessionDB borrows its handle
An agent given hermes_state.SessionDB as session_db writes through the handle that SessionDB holds when the agent is built. The stand_in_interface docstring and the plugin guide's SessionDB() row now say the caller keeps that SessionDB open for the agent's life: its close() releases the handle, and its reopen after close() gives the agent no new one. |
||
|
|
be3d6affc8 |
refactor(state)!: remove the old session store
hermes_state.py becomes the stand-in plugins import, the rest of the legacy store and its test folder go, and the per-process modules the backend imported from main move under persistence/sqlite/_state/. The backend checks PID namespaces and lease holders through process_identity and its WAL setup through sqlite_support, and its error module takes the shared predicates and classification from storage_errors, so neither helper set has a second copy. The backend, sqlite_support.py and the tests that pin those modules reach their final imports, and the backend-import guard allows no file outside persistence/. The modules no caller imports any more go with it: the agent's onboarding rules (now in session_rules) and gateway/session_admission.py. The stand-in's SessionDB releases its store on close() and, used again afterwards, opens it again with a warning, as the old class reopened its connection, unless the file at its path was replaced or the store is latched corrupt; a read-only one raises. A close during a call releases the store when the call returns. A named source wins over a source list in its session listing and count. An agent given a writable stand-in SessionDB as session_db= and no persistence= takes the store handle that SessionDB forwards to as its persistence, so its turn flush, token counts, compression and session row writes go through the storage interface, as an agent given the old SessionDB wrote through it. The backend-import guard also holds the backend's remaining reads of the process or task home, each with its reason, and refuses any other and any import of the stand-in inside persistence/sqlite/. Plugin context engines get the agent's store as persistence= beside the deprecated session_db=, in each hook whose signature accepts that keyword, including the rebind after /new, /resume and /branch, and the context engine guide and the plugin guide's replacement table name it. A test fails once the running release reaches the stand-in's removal release, listing what goes with the stand-in. release_unheld_media and collect_unheld_api_images take a store only: their SessionDB branches, which no caller reaches, go with the gateway's own copies of the admission and transcript queries. |
||
|
|
d321a00e91 |
docs(repo): docs, desktop app, skills and native code for the persistence interface
Documentation, the desktop app, skills and native code follow the interface. The published plugin API lists the storage interface names the plugin guide's replacement table gives, so the guide's examples and the bundled plugins that import them stay on the published list. |
||
|
|
fdc2a21a29 | docs: point catalog copy at Marketplace pages instead of /docs/plugins and /docs/skills | ||
|
|
c39520573f | docs: stop advertising legacy web catalogs during Marketplace work | ||
|
|
7c9b019ab5 |
fix(plugin api): publish hermes_cli.version_info:hermes_user_agent
Eight bundled plugins already build their User-Agent header with
hermes_user_agent: six model providers, the Slack adapter and the
Perplexity web provider. Each was a baselined private import. The name is
now on the published plugin list, with a section in the plugin guide, and
those eight baseline rows go.
The xAI plugins need the same name before tools/xai_http.py can be split:
its hermes_xai_user_agent returns the string
hermes_user_agent("Hermes-Agent") returns.
|
||
|
|
69cddd08f4 |
fix(plugin api): publish agent.retry_utils:parse_retry_after_seconds
Plugins that call a rate-limited HTTP API need to read the Retry-After header. Discord, Signal and Slack already import Hermes's parser as baselined private crossings, and the Microsoft Graph client needs it to move into the teams_pipeline plugin. - plugin_api.json lists the one name; public-api.md is regenerated. - plugins/index.md gains a short section with the contract and an example. - boundary_lint baseline drops the three crossings that are now public (Discord, Signal, Slack). No other line changes; a full --update would also drop two unrelated stale rows, so it was not used. - Test: a plugin importing the parser validates with no private-import warning, while another name from agent.retry_utils still warns. Red on main. |
||
|
|
6c025ab898 |
fix(plugins): pin liveness endpoint URL to loopback (salvage #125745) (#155387)
* fix(plugins): pin liveness endpoint URL to loopback, harden manifest liveness parsing A manifest's liveness.endpoint_path was concatenated verbatim onto the loopback URL read from the app's runtime server.json and re-parsed by the probe, so a crafted tail like '@attacker.example/' rewrote the URL authority and the initialize request carried the runtime file's bearer token to a manifest-chosen host. Now the declaration parser only admits a plain path charset (no '@', '?', '#', whitespace, scheme, or '..' segments), the resolver re-parses the fully composed URL and requires it to stay on a loopback host with the same port and no userinfo, and _mcp_initialize re-verifies scheme/host/port before the socket opens so the transport-facing endpoint() path is covered too. Adjacent hardening in the same surface: liveness.path must be a rooted filesystem path in both parse surfaces, server.json key overrides must be simple key names, malformed pids (bool, >int32) degrade instead of crashing os.kill, a non-mapping 'fields' value raises ValueError inside the fail-closed contract instead of TypeError, and a manifest whose liveness fails validation renders 'unknown' on the catalog card instead of 'present'. * test(plugins): satisfy ruff PLR0402 in salvaged liveness test Follow-up to the salvaged #125745 commit after rebasing onto main. Refs #125744 * test(plugins): build hostile-endpoint fixture with a valid AppLocation tuple AppDef.locations is tuple[AppLocation, ...]; the fixture passed a bare string, which only worked because endpoint() never reads locations. Refs #125744 --------- Co-authored-by: beardthelion <beardthelion@users.noreply.github.com> |
||
|
|
c711c2efe6 |
ci(plugin-catalog): maintainer allowlist for third-party tool downloads in the self-updater gate
The self-updater gate rejects any plugin script that both fetches from GitHub and writes or renames files. rom-studio (#153798) trips it on kit/kit.ts, which downloads the third-party poryscript 3.6.1 compiler from its own release, checks a fixed sha256 and unpacks it into kit/.cache. It never fetches or replaces rom-studio's own files, so the pin stays the only update path (README rule 3). Teknium ruled to allow it. A maintainer now lists such a file in scripts/ci/catalog_self_updater_allowlist.json by repo, pinned sha, path and the file's sha256: a re-pin, an edit to that file or a second fetching file is gated again. The list lives under scripts/ci/, which an entry PR may not touch (catalog_changed_entries.py), so a submitter cannot add themselves. Rule 3 in both rule blocks names the exception. |
||
|
|
2fac320c17 |
docs(plugin-catalog): admission rule 20, no coin or token promotion
Catalog listings were being used to promote individual tokens (a listed plugin's maker posting its contract address on X), and memecoin boards, coin launchpads and airdrop farmers passed review on clean code alone because no rule covered what a plugin is for. Rule 20 declines plugins built around one non-mainstream coin, token or NFT collection and plugins used to promote their maker's own token, while keeping stablecoins, payments, multi-coin wallets and markets, tickers, safety checks and Bitcoin/Ethereum/Solana-level assets welcome. Mirrored into the catalog-submission guide (rules mirror test). |
||
|
|
1cec6709ae |
fix(gateway): plugin idle-task runs stop with gateway housekeeping
Idle-task workers were detached threads that always wrote the task's state when the plugin's function returned, so a run still going when the gateway stopped (or the multiplexer restarted in the same process) wrote profile state after housekeeping had stopped. Gateway housekeeping now polls idle tasks under a stop fence tied to its stop event. Once housekeeping stops, no run starts under it; when the loop exits it waits a bounded time (inside the housekeeping drain budget) for its runs and returns. A run that ends after the stop records nothing: the task's state stays as it was before the run, so the task runs again on a later poll, and the run still releases its claim. Closing the fence waits for a record in progress, so none lands after the stop. Plugin code cannot be stopped; the idle-task contract now says so and states the guarantee. Hosts without a stop (CLI/TUI startup, the serve maintenance tick) are unchanged. |
||
|
|
aaf648e835 |
docs(plugins): mark fork_session and register_idle_task experimental
Both APIs may still change shape, so the plugin guide now says so and tells a plugin how to stay portable: keep the fork handle in one small function that returns plain data, and treat fork_session as optional. It returns None when the request is refused, and under plugins.isolation: host it raises PluginHostUnsupported, since the handle tracks a thread of the live session agent inside the Hermes process. The guide also states the idle-task contract: fn runs on its own thread and the host does not wait for it, so a run should keep its own time limit, work in small checkpointed batches and be safe to repeat. |
||
|
|
a7ac9bba45 |
fix(plugins): a slow plugin idle task no longer holds up the gateway's housekeeping
Plugin idle tasks ran synchronously on the thread that polled them. On the gateway that is the housekeeping thread: it also stamps the runtime heartbeat and runs the cron delivery drain, the misfire catch-up, the plugin update check and state.db maintenance. An idle task that made model calls for minutes stalled all of them, and after two minutes gateway status reported the live gateway as wedged. Each due task now starts on its own thread, carrying the poller's profile home and secret scope, and the poll returns at once. The run claim still keeps one run at a time across pollers and processes, and a run of this process is never doubled even when it outlasts the claim's stale age. The worker records the run and releases the claim when the task returns or raises. The curator's own pass is unchanged. |
||
|
|
3845dbb76c |
feat(plugins): ctx.register_idle_task runs a plugin job on the curator's idle schedule
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. |
||
|
|
32f9c1f6b3 |
feat(plugins): ctx.fork_session runs a bounded background copy of the session agent
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. |
||
|
|
674412b1fa |
feat(plugins): post_llm_call carries review_signals, the self-learning cadence
post_llm_call gains a read-only review_signals mapping: the skill and memory nudge counters, both intervals, whether each review trigger fired this turn and whether a due trigger actually forks the background review (enabled in config, not cron, not a subagent). A plugin doing its own after-turn work (Collective Wisdom's share suggestion) can then follow the cadence the user already tuned instead of counting tool calls itself. The hook fires before the review decision, so the finalizer now evaluates the skill trigger once (agent/review_signals.py::skill_review_due) and hands the same boolean to the hook and to the spawn; the memory trigger was already decided at turn start. The mapping is a dict subclass that refuses mutation (one instance reaches every callback) and stays a plain dict on the plugin-host wire and through copy/pickle. Computed only when post_llm_call has a subscriber. |
||
|
|
389cb74194 |
docs(plugins): publish create, restore and finish by name
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. |
||
|
|
83186333c9 |
refactor(cli): the -w worktree of a chat session is three functions any launcher can call
The Ink launcher made, restored and finished the `-w` worktree with private code, so a plugin that starts its own chat client could not offer `-w`, and a tree it made with `git worktree add` can be removed by the stale-tree sweep. That code moves into `hermes_cli/session_worktree.py` as `create()`, `restore(session_id)` and `finish(info, session_id, ask=...)`; the Ink launcher and `hermes_cli/main_resume_args.py` now call them, with the same questions and messages. The module is listed in `hermes_cli/data/plugin_api.json` and the generated public API page. |
||
|
|
9f6f0df93a |
docs(plugins): the chat-client example works without HERMES_HOME; publish the two functions by name
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. |