Skip to main content

Module peer_support

Module peer_support 

Source
Expand description

Generic adoption helpers for messaging ONE connection of a server.

The server-side mirror of client/command_support.rs: the dashboard’s “message this peer” (and any programmatic caller) injects an action into a specific live connection via AppState::send_to_peer. A protocol opts in per connection:

ⓘ
// In the accept loop, once the connection is registered:
let peer_rx = peer_support::register_peer_channel(&app_state, server_id, conn.as_u32()).await;
peer_support::spawn_peer_command_task(
    peer_rx, protocol.clone(), app_state.clone(), server_id, connection_id,
    write_half_arc.clone(), status_tx.clone(),
);
// In the connection's close paths:
app_state.remove_peer_handle(server_id, connection_id.as_u32()).await;

The command task executes the action through the same central executor the LLM path uses (execute_actions + the protocol’s own execute_action), so an injected send_tcp_data is encoded by exactly the code that encodes the model’s. ActionResult::Output bytes are written to the connection’s write half; everything else is reported as executed.

Only protocols that adopt this offer the affordance — the UI shows “message this peer” exactly where a handle exists, which is the honest rendering of “only if the protocol permits it”.

Functions§

register_peer_channel
Create and register the command channel for one live connection.
spawn_peer_command_task
Drive a connection’s command channel until it closes. The worker is also owned by its connection, so either peer close or server teardown cancels blocked work.