shell.exec runs on the gateway host, so the owner keeps refusing it for a
session whose frozen terminal backend is a sandbox. The refusal now carries
field=terminal.backend and detail=<backend>, and Ink renders it as a sentence
that names the backend and says to ask the agent instead, for both !cmd and
{!cmd}. Local sessions still run. An older gateway (no detail) still gets the
"ask the agent" wording.
Refs #134889 (TUI-16)
Refs #141321
Main made the strict ruff config the default (`ruff check .`, blocking), and
the branch's code carried 278 findings under it (main itself is clean). Fixed:
- PLW1510 (86): `check=False` on each subprocess.run, preserving behaviour,
as main's own sweep (0006a5e229) did.
- ASYNC220 (9, test fixtures only): `noqa` with the reason, main's convention
for a Popen that returns at once and whose handle the test drives.
- ruff's safe autofixes plus the narrow unsafe ones (UP006/UP037/RUF100/RUF013/
PLR0402/RUF059 underscore renames/UP031/UP041/UP017/FURB167/PIE807/RUF007/
RUF015/RUF022/FURB162), and by hand: four %-formats to f-strings, three
unused unpacked names, one fixture loop over `.items()`.
No behaviour change. `ruff check .` passes; scripts/check passes; the 412 test
files mirroring every edited file pass (3 tests/pm files that fail only under
that batch's uv lookup pass solo, before and after this commit).
Ink sends `shell.exec {command, session_id}`. The authority answered -32601 and the legacy
fallback's contract refused `session_id`, so `!cmd` always failed with "run `hermes update` and
restart both", and `{!cmd}` caught the error and sent the literal `(error)` to the model.
Dropping `session_id` would not have helped: the legacy handler runs `subprocess.run(
cwd=os.getcwd())`, the owner's directory (the install root for an auto-started daemon).
- gateway/session_shell.py (new, topical sibling): the owner serves `shell.exec` for exactly
one LOCAL session (authorize_local_source; API/messaging/A2A routes have no composer) under
session:control and open admission, in the session's frozen launch cwd. Same
hardline + dangerous-command refusal as before, Hermes-managed secrets scrubbed from the child
(build_subprocess_env, launch-profile residue stripped), output redacted before tailing,
30 s cap. A session frozen onto a sandbox backend (TERMINAL_ENV docker/ssh/...) is refused
rather than run on the host; a vanished cwd is refused, never the owner's cwd.
Nothing enters the transcript or the admission FIFO.
- Canonical `shell.exec` contract (session_id required); generated apps/shared outputs.
- Ink: a `{!cmd}` that fails (refusal, timeout, invalid reply) refuses the whole submit: the
staged row settles not-accepted (retained for Alt+K / edit), a notice names the reason, busy
clears. No placeholder text ever reaches the model.
Tests: tests/gateway/test_session_shell.py (real authority over a ticketed WS: pwd == session
cwd != owner cwd, exit code 3 surfaced, OPENROUTER_API_KEY scrubbed, a dangerous command
refused, sessionless refused) red on r10-base ("out of sync ... hermes update"), green after.
Vitest submissionDestinationRenderer "refuses the whole submit ..." red on base
useSubmission.ts (prompt.submit sent), green after.
Review: https://github.com/NousResearch/hermes-agent/pull/106742#pullrequestreview-5475590057