feat(runtime): add weft:app/notify WIT package and notify-ready host interface

Adds crates/weft-runtime/wit/weft-app.wit defining package weft:app@0.1.0
with interface notify { ready: func() }.

In the wasmtime-runtime path:
- Registers weft:app/notify@0.1.0 in the component linker before instantiation
- ready() prints
This commit is contained in:
Marco Allegretti 2026-03-11 15:15:11 +01:00
parent b2ac279dc5
commit 84eb39db96
2 changed files with 18 additions and 2 deletions

View file

@ -127,6 +127,14 @@ fn run_module(
let mut linker: Linker<State> = Linker::new(&engine);
add_to_linker_sync(&mut linker).context("add WASI to linker")?;
linker
.instance("weft:app/notify@0.1.0")
.context("define weft:app/notify instance")?
.func_wrap("ready", |_: wasmtime::StoreContextMut<'_, State>, ()| {
println!("READY");
Ok::<(), wasmtime::Error>(())
})
.context("define weft:app/notify#ready")?;
let mut ctx_builder = WasiCtxBuilder::new();
ctx_builder.inherit_stdout().inherit_stderr();
@ -150,8 +158,6 @@ fn run_module(
},
);
println!("READY");
let command =
Command::instantiate(&mut store, &component, &linker).context("instantiate component")?;

View file

@ -0,0 +1,10 @@
package weft:app@0.1.0;
/// Host interface that a WEFT app component imports to signal lifecycle events.
interface notify {
/// Signal to the runtime that the application has finished initialising
/// and is ready to serve requests. The runtime forwards this signal to
/// the session supervisor (appd), which transitions the session to the
/// Running state.
ready: func();
}