mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-11-17 04:11:35 +00:00
preview.read / preview.act / terminal.read / window.read / tour are answered only by the Desktop window that shows the requesting session (#114981). When no attached window showed it, every window stayed silent and the agent waited out the full 30-45s bridge deadline, then got the generic "No preview tab is open, or the read timed out." A window not hosting the session now declines with JSON-RPC error 4404 instead of staying silent. The gateway counts a decline as that client's vote, not as the answer: the request stays open for the owner window and settles only once every attached answering client declined, with a distinct refusal ("No Hermes Desktop window is showing this chat ... Ask the user to open this chat in the Desktop app, then retry."). A bystander window therefore still cannot beat the owner (#113348). The backend advertises the counting via client.capabilities (declines_not_shown); the shared channel only sends a decline to a backend that did, so a new app against an older backend keeps today's silence. Fixes #119333
48 lines
1.9 KiB
Python
48 lines
1.9 KiB
Python
"""Transport liveness + build capability probes (``methods_voice.py`` hosts them)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from .base import Params, Result
|
|
from .registry import method
|
|
|
|
|
|
class PingParams(Params):
|
|
pass
|
|
|
|
|
|
class PingResult(Result):
|
|
pong: bool
|
|
|
|
|
|
method("ping", params=PingParams, result=PingResult,
|
|
doc="Cheapest liveness probe; answered on the WS reader thread even while every agent is mid-turn.")
|
|
|
|
|
|
class GatewayCapabilitiesResult(Result):
|
|
per_session_exclusive_submit: bool
|
|
|
|
|
|
method("gateway.capabilities", params=PingParams, result=GatewayCapabilitiesResult,
|
|
doc="What THIS build enforces (a client withholds a feature unless advertised).")
|
|
|
|
|
|
class ClientCapabilitiesParams(Params):
|
|
#: The client answers server→client requests (clarify, approval, sudo, …) — with a result or a -32601
|
|
#: error for methods it has no handler for. A WebSocket client that never says so is treated as a
|
|
#: build older than server→client requests and every such request fails fast for it.
|
|
server_requests: bool = False
|
|
|
|
|
|
class ClientCapabilitiesResult(Result):
|
|
#: Server→client request methods this backend may send.
|
|
server_requests: list[str]
|
|
#: This backend counts a ``4404`` "no window here shows this session" error from a window-owned
|
|
#: bridge (preview/terminal/window read, preview act, tour) as that client declining, not as the
|
|
#: answer: the request settles only once every attached client declined (server_requests.py).
|
|
#: An older backend settles on the first error, so a client sends the decline only when this is true.
|
|
declines_not_shown: bool = False
|
|
|
|
|
|
method("client.capabilities", params=ClientCapabilitiesParams, result=ClientCapabilitiesResult,
|
|
doc="What the calling client handles, sent once per connection (after gateway.ready); returns the "
|
|
"server→client request methods this backend may send.")
|