Under plugins.isolation: host, discover_and_load(force=True) (reload-plugins,
and every plugin install, enable or update) loads a plugin again into the same
host process under the same plugin_key. A task the first load spawned kept
running, and its emit_plugin_session_event was taken for the new load and
published to the session's viewers.
- Hermes numbers each load of a plugin in the host (load), sends it with the
load request, and forgets it at unload.
- The host binds that load, with the plugin, to each request it serves, so it
follows the request's code onto the tasks it spawns; session_event carries it.
- The gateway process publishes only when that load is the plugin's current
one; otherwise it logs and returns False, as the hosted call did before this
PR forwarded it. A category plugin's fresh instance keeps its key's load.
- ctx.emit_to_session reads the manager's home_path directly: every manager
sets it, as the other readers of the plugin's own profile assume.
Suggested by @BearHuddleston in review.
- The late-event test now covers a same-host reload and waits with
tests.waiting.wait_until and Events instead of sleep loops.
ctx.emit_to_session from such a task is unchanged (it reached viewers on
main too).
Refs #142005, #141982
A client could not tell "no such plugin method" from "this server has no
plugin RPC": runtime.describe advertised nothing, and plugin.* was in no
contract or ledger. Under plugins.isolation: host the module-level
emit_plugin_session_event returned False and sent nothing, and an
in-process ctx.emit_to_session from a plugin's own thread on a multiplexed
gateway looked the session up in the launch profile.
- runtime.describe lists plugin-rpc-v1.
- tui_gateway/contracts gains CANONICAL_NAMESPACES (canonical_namespace):
plugin.{plugin_id}.{name} with open params, rendered as
CanonicalRpcNamespaces in the TS contract and x-canonical-namespaces in
OpenRPC; the serve handler ledger gets one row for it.
- The plugin host forwards emit_plugin_session_event to the gateway process
(host->parent request session_event), looked up in the host's profile.
- ctx.emit_to_session binds the plugin manager's home before the lookup.
Refs #142005, #141982
A plugin frontend that is a JSON-RPC client of the gateway could not call
its own Python half, and the Python half could not reach the viewers of one
session. Plugins passed data through shared files and tool.complete payloads.
ctx.register_rpc(name, handler) serves plugin.<plugin_id>.<name> on the
session authority, after the core handler table, with the gate of a plugin
slash command: session:control, plus the session authorization when the call
names a session_id. The handler runs off the loop in the owning profile scope;
a failure answers 4001 plugin_rpc_failed. The ownership ledger removes the
methods on unload and force rediscovery.
ctx.emit_to_session(session_id, event, payload) (and
plugin_events.emit_plugin_session_event) publishes plugin.<plugin_id>.<event>
on that live session event stream only. The session is found by its
conversation id or its resident agent current id, so an id from after
compression still reaches the viewers.
Salvages the idea of #66874 as a smaller redo on the canonical gateway.
Co-authored-by: eiritsu <yoeiritsu@gmail.com>