Skip to main content

PluginService

Trait PluginService 

Source
pub trait PluginService {
    // Required methods
    async fn init(&self, ctx: SessionCtx);
    async fn hook(&self, req: HookReq) -> HookResult;
    async fn tool_call(&self, call: ToolCallReq) -> PluginToolResult;
    async fn cancel_tool_call(&self, tool_call_id: String);
    async fn session_start(&self, ctx: SessionCtx);
    async 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§

Source

async fn init(&self, ctx: SessionCtx)

Initialise the plugin with session context. Sent once after the plugin has called register on the server side.

Source

async fn hook(&self, req: HookReq) -> HookResult

Execute a hook (e.g. before_llm_turn).

Source

async 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.

Source

async 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.

Source

async fn session_start(&self, ctx: SessionCtx)

Notify the plugin that a (sub-)session is starting.

Source

async fn idle(&self)

Notify the plugin it has been idle long enough to consider exiting.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§