You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Replace legacy python tools echo with Wasm host function
Remove leftover --enable-tools references from the README and host
functions docs. Add a small echo WASIp1 host function example and update
the Python tools example plus CI runtime args to register it via
--tool echo=... instead of using the legacy built-in echo path.
Signed-off-by: akrm al-hakimi <alhakimiakrmj@gmail.com>
Copy file name to clipboardExpand all lines: README.md
+7-4Lines changed: 7 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,7 +49,7 @@ This project enables running Linux applications (Python, Node.js, Go, Rust, C/C+
49
49
50
50
### Key Features
51
51
52
-
-**Thin, opt-in host surface** — by default, the guest has no access to the host filesystem, network, or any host functions. When you enable features like `--mount`, `--net`, `--enable-tools`, or `--tool`, a single `__dispatch` JSON-RPC bridge is registered as the only guest→host channel. See [host_functions.md](docs/host_functions.md) for the full list of dispatchable operations
52
+
-**Thin, opt-in host surface** — by default, the guest has no access to the host filesystem, network, or custom host tools. When you enable capabilities like `--mount`, `--net`, or `--tool`, a single `__dispatch` JSON-RPC bridge is registered as the only guest→host channel. See [host_functions.md](docs/host_functions.md) for the full list of dispatchable operations
The guest still calls the existing `__dispatch` envelope, for example `{"name":"greet","args":{"who":"Ada"}}`. The Wasm handler runs on the host in Wasmtime, receives that request JSON on stdin, and writes either a raw JSON result or `{"result": ...}` / `{"error": "..."}` to stdout. WASI filesystem and environment access are off unless granted with `--tool-wasi-dir`, `--tool-wasi-dir-ro`, `--tool-wasi-env`, or `--tool-wasi-env-inherit`.
324
+
The guest still calls the existing `__dispatch` envelope, for example `{"name":"echo","args":{"message":"hello"}}`. The Wasm handler runs on the host in Wasmtime, receives that request JSON on stdin, and writes either a raw JSON result or `{"result": ...}` / `{"error": "..."}` to stdout. WASI filesystem and environment access are off unless granted with `--tool-wasi-dir`, `--tool-wasi-dir-ro`, `--tool-wasi-env`, or `--tool-wasi-env-inherit`.
| Custom tools |**Off**|`--tool NAME=WASM` with `wasm-host-fns`, `SandboxBuilder::tool()`, or legacy/demo `--enable-tools` echo|
18
+
| Custom tools |**Off**|`--tool NAME=WASM` with `wasm-host-fns` or `SandboxBuilder::tool()`|
19
19
20
20
With **no flags**, the guest cannot reach the host filesystem or network through dispatch. Only internal plumbing (`__hl_exit`, `__hl_sleep`) is wired.
|`--net-block HOST_OR_IP`| Block-list; all other destinations allowed (implies `--net`). Mutually exclusive with `--net-allow`. |
87
87
|`--port PORT`| Allow `net_bind` / listen on `PORT` (implies `--net`). Without `--port`, outbound-only: bind is rejected. |
88
-
|`--enable-tools`| Registers only the built-in `echo` demo tool. It does not load user code; prefer `--tool NAME=WASM` for CLI custom tools or `SandboxBuilder::tool()` for library users. |
89
88
|`--tool NAME=WASM`| With the Cargo feature `wasm-host-fns`, registers `WASM` as a host-side WASIp1 custom tool named `NAME`. Repeatable. |
90
89
|`--tool-wasi-dir HOST[:GUEST]`| Preopens a read-write host directory for every CLI Wasm tool. Default guest path is `/host`. Repeatable. |
91
90
|`--tool-wasi-dir-ro HOST[:GUEST]`| Preopens a read-only host directory for every CLI Wasm tool. Default guest path is `/host`. Repeatable. |
@@ -200,19 +199,20 @@ Sockets are host-side (`socket2`); the guest sees opaque numeric **`fd`** handle
200
199
201
200
## Custom tools
202
201
203
-
**CLI demo tool:**`--enable-tools` registers only a built-in `echo` tool that returns `args` unchanged. It is useful as a smoke test and compatibility path, but it is not the CLI extension mechanism for user-provided host functions. CLI examples should prefer a Wasm `echo.wasm` registered with `--tool echo=...`; library examples should register an echo handler with `SandboxBuilder::tool()`.
204
-
205
-
**CLI Wasm tools:** build with the optional feature and pass one or more `--tool` flags:
202
+
**CLI Wasm tools:** build with the optional feature and pass one or more `--tool` flags. The `examples/echo-wasm-host-fxn` module is a minimal echo handler used by `examples/python-tools`:
Each `--tool NAME=WASM` module is compiled and linked before VM boot, then invoked as a fresh WASIp1 command for every matching guest `__dispatch` call. The handler receives the existing dispatch request on stdin:
213
213
214
214
```json
215
-
{"name":"NAME","args":<json_value>}
215
+
{"name":"echo","args":<json_value>}
216
216
```
217
217
218
218
The handler writes JSON to stdout. It may write either a raw JSON result value or the normal dispatch envelope:
0 commit comments