pub struct WasmPluginRuntime { /* private fields */ }Expand description
Owns the wasmtime engine and can load + call plugins.
Implementations§
Source§impl WasmPluginRuntime
impl WasmPluginRuntime
Sourcepub fn new() -> Result<Self, WasmPluginError>
pub fn new() -> Result<Self, WasmPluginError>
Create a new runtime with a fresh wasmtime engine.
Sourcepub fn with_log_sink(self, sink: LogSink) -> Self
pub fn with_log_sink(self, sink: LogSink) -> Self
Install a LogSink. Builder form so callers can chain on
the result of new(). The sink is cloned into every plugin
instance the runtime builds — set it before loading plugins.
Sourcepub async fn load(
&self,
path: &Path,
plugin_id: &str,
capabilities: Capabilities,
plugin_name: &str,
env_map: HashMap<String, String>,
) -> Result<LoadedPlugin, WasmPluginError>
pub async fn load( &self, path: &Path, plugin_id: &str, capabilities: Capabilities, plugin_name: &str, env_map: HashMap<String, String>, ) -> Result<LoadedPlugin, WasmPluginError>
Load a .wasm component file. Calls the plugin’s init
export and returns metadata + tool definitions.
Sourcepub async fn call_tool(
&self,
plugin_id: &str,
tool_name: &str,
args_json: &str,
host_rt_handle: Handle,
) -> Result<CallToolResult, WasmPluginError>
pub async fn call_tool( &self, plugin_id: &str, tool_name: &str, args_json: &str, host_rt_handle: Handle, ) -> Result<CallToolResult, WasmPluginError>
Call a tool on a loaded plugin from async code. Creates a fresh Store per call (isolation — no shared mutable state between invocations).
This wrapper is intended for lightweight direct callers. The
WasmTool adapter uses Self::call_tool_blocking inside
tokio::task::spawn_blocking so wasmtime execution never
blocks the async agent loop.
host_rt_handle is the runtime handle that the host imports
(http-get/http-post) will use to drive async work.
Sourcepub fn call_tool_blocking(
&self,
plugin_id: &str,
tool_name: &str,
args_json: &str,
host_rt_handle: Handle,
) -> Result<CallToolResult, WasmPluginError>
pub fn call_tool_blocking( &self, plugin_id: &str, tool_name: &str, args_json: &str, host_rt_handle: Handle, ) -> Result<CallToolResult, WasmPluginError>
Synchronous tool call used from a plain blocking thread.
This is the safe path for sync wasmtime guest execution plus
sync host imports that need to run async HTTP. The caller must
invoke it outside a Tokio runtime context; then http-get /
http-post can use host_rt_handle.block_on(...) without
tripping Tokio’s nested-runtime guard.
Sourcepub async fn call_hook(
&self,
plugin_id: &str,
point: HookPoint,
context_json: &str,
host_rt_handle: Handle,
) -> Result<Vec<HostAction>, WasmPluginError>
pub async fn call_hook( &self, plugin_id: &str, point: HookPoint, context_json: &str, host_rt_handle: Handle, ) -> Result<Vec<HostAction>, WasmPluginError>
Invoke a v2 orchestration hook on a loaded plugin.
The returned actions are untrusted intent. Callers must validate model ids, role names, tools, and lifecycle timing before applying them to an agent or harness.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for WasmPluginRuntime
impl !RefUnwindSafe for WasmPluginRuntime
impl Send for WasmPluginRuntime
impl Sync for WasmPluginRuntime
impl Unpin for WasmPluginRuntime
impl UnsafeUnpin for WasmPluginRuntime
impl !UnwindSafe for WasmPluginRuntime
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
Source§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
self file descriptor.Source§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
Source§fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
self file descriptor. Read moreSource§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more