pub trait PluginServiceSync {
// Required methods
fn init(&self, ctx: SessionCtx);
fn hook(&self, req: HookReq) -> HookResult;
fn tool_call(&self, call: ToolCallReq) -> PluginToolResult;
fn cancel_tool_call(&self, tool_call_id: String);
fn session_start(&self, ctx: SessionCtx);
fn idle(&self);
}Expand description
Methods the server calls on the plugin.
The plugin process serves this trait; the server holds a generated
PluginClient over a DuplexClientHalf<_, _, …, PluginRequest, PluginResponse> bound to PLUGIN_API_ID.
Concurrent in-flight requests are first-class: tool_call and
cancel_tool_call may overlap (in fact cancel_tool_call is only
useful while a tool_call is pending — its purpose is to abort it).
Myelin’s MuxedSlots handles the slot routing for free; the plugin
must serve them concurrently (e.g. spawn tool_call as a background task
so the dispatch loop can pick up the cancel).
Required Methods§
Sourcefn init(&self, ctx: SessionCtx)
fn init(&self, ctx: SessionCtx)
Initialise the plugin with session context. Sent once after the
plugin has called register on the server side.
Sourcefn hook(&self, req: HookReq) -> HookResult
fn hook(&self, req: HookReq) -> HookResult
Execute a hook (e.g. before_llm_turn).
Sourcefn tool_call(&self, call: ToolCallReq) -> PluginToolResult
fn tool_call(&self, call: ToolCallReq) -> PluginToolResult
Execute a tool call. Returns the final result; intermediate output
is reported via output_delta on the PluginCallbackService
service.
Sourcefn cancel_tool_call(&self, tool_call_id: String)
fn cancel_tool_call(&self, tool_call_id: String)
Abort a tool call by id. The plugin should kill any associated
subprocess and return a normal tool_call response with
cancellation noted. No-op if the call already completed.
Sourcefn session_start(&self, ctx: SessionCtx)
fn session_start(&self, ctx: SessionCtx)
Notify the plugin that a (sub-)session is starting.