codetether_rlm/router/host.rs
1//! Host-provided trait for RLM tool dispatch.
2//!
3//! The router needs three host-defined capabilities that live in
4//! `codetether-agent`: the REPL context, structured tool dispatch,
5//! and tool-definition generation. This trait exposes them without
6//! coupling the crate to concrete types.
7
8use crate::traits::ToolDefinition;
9
10/// Result of dispatching a single RLM tool call.
11#[derive(Debug, Clone)]
12pub enum HostToolResult {
13 /// Normal output, fed back to the LLM.
14 Output(String),
15 /// Final answer — terminates the RLM loop.
16 Final(String),
17}
18
19/// Narrow interface the router needs from the host environment.
20///
21/// Implemented by `codetether-agent` with `RlmRepl` and the
22/// `dispatch_tool_call` function from `src/rlm/tools.rs`.
23pub trait RouterHost: Send {
24 /// Return the `rlm_head/tail/grep/…` tool definitions.
25 fn tool_definitions(&self) -> Vec<ToolDefinition>;
26
27 /// Dispatch one tool call. Returns `None` for unknown tools.
28 fn dispatch(&mut self, name: &str, arguments: &str) -> Option<HostToolResult>;
29}