An accepted steer or redirect into a running process-notification or
delegation-result turn (busy chat steer/redirect, the priority paths,
/steer, session.steer, session.redirect and an owned API run's steer)
now clears the running event's origin, so turn_origin() reads None for
the rest of that turn and the reply to the person is not muted. A
refused steer, or one that lands on an agent no longer owning the slot,
leaves it. Execution trust, authorization and the prompt are unchanged.
Reported-by: flrn-st
A detached fork (a plugin fork, a side question, a background review)
runs its own prompt in a copy of the turn's context, so turn_origin()
and ctx.turn_origin() named the parent's producer there. Both now read
None while fork_origin() is set, as they already do in a delegated child.
The committed automation row no longer records a turn_origin field.
Restore reads the origin from the producer identity every row already
carries ([type, producer id, incarnation] for a process-registry event),
so a watch notification an older build admitted and retried after the
upgrade matches its row instead of failing with admission_conflict, and
no row's fingerprint changes. The native and local automation paths
share the one restore.
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.
turn_internal() read a Bot Chat delivery's execution trust as its
origin: every delivery is admitted internal, so a person's `hermes peer
dm` and another bot's DM read True like a wake. A late /steer drained as
the next turn after a wake also ran under the wake's event and read True.
The Bot Chat door now records the origin at the producer, apart from
`internal`: an authored delivery or any peer dm is someone's message
(False), an unauthored producer report (cron job output) is Hermes' own
(True). The receipt keeps it as `started_by_hermes` for the one retry,
and the committed automation row stores it only when it is not True and
no turn_author already says so, so every other producer's row and retry
fingerprint is unchanged. A receipt or legacy ticket that recorded no
origin retries as None, never True.
An event-less follow-up turn binds its own answer: False for a late
/steer, None for interrupt text whose sender the drain no longer knows.
A /queue drain already rebinds its own event.
Execution trust, authorization, allow_gateway_control and what reaches
the model are unchanged.
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.
- adding-platform-adapters.md: the three published silence helpers
recognize and strip markers. Whether a turn may stay silent is the
gateway's decision, and where a reply is expected it can send a notice
in place of a bare marker, so an adapter must not use them to drop
text it is handed to send. The test is renamed to match.
- session_source(): `tool` is the label a third-party integration
launches with and `oneshot` a finite `chat -q` / `-z` run. The label
says how a session was launched, not that a person is waiting.
- fork_origin(): the skill curator's own agent runs under the
`background_review` label too.
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.
Under plugins.isolation: host the two documented forms of turn_client() and
session_viewers() answer differently. The module-level functions run in the
plugin's own process, which has no gateway and no turn, so they always return
None and []. ctx.turn_client() and ctx.session_viewers() call back into the
gateway in the calling hook's context and answer as they do in-process.
The plugins guide and the docstrings now say so and point a plugin that may
run hosted at the ctx form. The hosted-plugin test covers both forms: ctx
answers for the calling turn (and for no session when the caller has none
bound), and the module level answers None and [].
- Presence records are dropped by a report that leaves their session out, by
away, by a detach (reports) and by the per-source bound; no timer ages one.
- Observing input cannot fail a request because both callers log and carry on.
- can_alert is None only while no report of the connection counts for the
session; a report that leaves it out says true.
- resolve() notes any result frame to a replayable request, a skip or cancel
included, not only "a person's answer".
- A hello with an unknown key answers 4000 from the generic unknown-key
check; other problems answer 4001.
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.
A third-party client can now say who it is: session.create takes an optional
client {name, version?}. It is attribution only. source still picks the
policy, and no toolset, approval, permission, prompt text or telemetry reads
the label.
- Validated beside the editor check (bounded, safe charset); a malformed value
is invalid_params on field client.
- Kept inside the frozen creation request, so there is no new column, receipt
key or policy field: an older owner restores the session, and the label is
part of the exact-retry identity.
- session.info.client echoes it (absent when none was sent); runtime.describe
lists client in session_create.parameters and capability session-client-v1.
- Plugins read it with hermes_cli.plugin_session.session_client() (published
in plugin_api.json) and the client / client_version keys of prompt-section
session info ("" when none). No PluginContext method, no hook kwarg.
- The classic CLI's /new copies the frozen launch request but never the
creating client's label: the new session belongs to the terminal.
- Contracts regenerated; docs say the label is self-declared and must never
grant anything.
The session_cwd() docstring did not say that in ingress hooks such as
pre_gateway_dispatch, which run before the message reaches any session,
it returns the profile's terminal cwd rather than the workspace of the
session the message will reach. The user docs already say so; the
docstring now does too.
Refs #134889 (LC-5)
Refs #139523
Since the one-gateway runtime, plugin hooks and tools of classic CLI,
TUI and Desktop sessions run in the gateway process. Plugins written for
the CLI broke there:
- inject_message() with neither session_key nor origin was refused. A
hook or tool running for a classic CLI session now resolves that
session's key from the turn context, and the text is committed to its
FIFO through the local session's own source and adapter (local
sessions have no messaging allowlist). allow_gateway_injection is
still required. Keyed injection into a local session is refused unless
the session authority registered for the calling plugin's own profile
holds that live session; ownership is never resolved through the
ambient profile scope.
- Approval hooks and transports saw surface='gateway' for CLI sessions.
They now report 'cli' again for a classic CLI session's turn. TUI,
Desktop and messaging keep 'gateway', as documented.
- os.getcwd() is the gateway's install root. ctx.session_cwd() and
ctx.session_surface() read the calling session's recorded workspace
and client from the turn's task-local policy. The gateway process is
never chdir-ed.
print() going to gateway-stdio.log and input() getting EOF are intended
differences, now documented in the plugin guide.
Refs #134889 (LC-5)
Refs #139523