Skip to main content

Crate grain_plugin_wasm

Crate grain_plugin_wasm 

Source
Expand description

WebAssembly Component Model plugin runtime for grain.

Loads .wasm files compiled against the grain:plugin WIT world, instantiates them via wasmtime, and wraps each plugin-declared tool as a grain_agent_core::AgentTool implementation.

§Architecture

.grain/plugins/my-tool/
+-- plugin.toml          # manifest (extended with [wasm])
+-- plugin.wasm          # compiled Component Model module

The host provides logging, env-var access, and HTTP primitives. Each host function is gated by the plugin’s declared capabilities in plugin.toml — calls into a denied capability return an error to the guest.

Re-exports§

pub use exports::grain::plugin::plugin as wit_plugin;
pub use grain::plugin::host as wit_host;

Modules§

exports
grain

Structs§

CallToolResult
Owned result from a tool call (mirrors the WIT tool-result).
Capabilities
Per-plugin capabilities the host enforces.
GrainPlugin
Auto-generated bindings for an instance a component which implements the world grain-plugin.
GrainPluginIndices
Auto-generated bindings for index of the exports of grain-plugin.
GrainPluginPre
Auto-generated bindings for a pre-instantiated version of a component which implements the world grain-plugin.
HookDef
One hook subscription declared by a v2 plugin.
LoadedPlugin
A successfully loaded WASM plugin.
OrchestrationDef
Optional orchestration metadata exported by v2 plugins.
PluginInfo
Plugin metadata (mirrors the WIT plugin-info record but is owned / cloneable for storage outside the store).
PluginState
State stored in the wasmtime Store<T>.
RoleDef
One model-role slot declared by a v2 plugin.
ToolDef
Tool definition (mirrors the WIT tool-def record, owned).
UiHeader
Optional UI header override requested by a v2 plugin.
WasmPluginRuntime
Owns the wasmtime engine and can load + call plugins.
WasmTool
One tool exported by a WASM plugin, presented as an AgentTool.

Enums§

HookPoint
Lifecycle point names supported by the v2 orchestration surface.
HostAction
Host action requested by a v2 plugin hook.
WasmPluginError

Type Aliases§

LogSink
Host log callback. Called for every log host import the guest invokes (after the log capability gate). Arguments: severity tag ("debug" | "info" | "warn" | "error"), plugin name, message.