Skip to content

Feature-gated Wasm host tools for the CLI#91

Open
cachebag wants to merge 9 commits into
hyperlight-dev:mainfrom
cachebag:main
Open

Feature-gated Wasm host tools for the CLI#91
cachebag wants to merge 9 commits into
hyperlight-dev:mainfrom
cachebag:main

Conversation

@cachebag

@cachebag cachebag commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

This adds --tool name=./handler.wasm support behind a new wasm-host-fns Cargo feature. The CLI now can register WASIp1 modules as custom host tools and route guest __dispatch calls to them through the existing ToolRegistry path.

Each Wasm tool is compiled and linked before the VM boots, then invoked as a fresh WASIp1 command per tool call. The handler gets the normal dispatch envelope on stdin, {"name":"...","args":...}, and writes either a raw JSON result or a {"result": ...} / {"error": "..."} envelope to stdout. WASI filesystem and env access are capability-based and off by default, with explicit --tool-wasi-dir, --tool-wasi-dir-ro, --tool-wasi-env, and --tool-wasi-env-inherit flags. Calls also have fuel and stdout/stderr capture limits.

Closes #84

cachebag added 4 commits June 8, 2026 22:21
Signed-off-by: akrm al-hakimi <alhakimiakrmj@gmail.com>
Signed-off-by: akrm al-hakimi <alhakimiakrmj@gmail.com>
Signed-off-by: akrm al-hakimi <alhakimiakrmj@gmail.com>
Signed-off-by: akrm al-hakimi <alhakimiakrmj@gmail.com>
Copilot AI review requested due to automatic review settings June 9, 2026 02:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds support for registering and invoking host-side custom tools implemented as WASI Preview1 WebAssembly modules (behind an optional Cargo feature), including CLI flags and documentation updates.

Changes:

  • Introduces a wasm-host-fns feature with optional wasmtime/wasmtime-wasi dependencies and a new Wasm tool runner (WasmTool).
  • Extends the host CLI to register --tool NAME=WASM tools and configure their WASI capabilities/limits (--tool-wasi-*).
  • Updates docs and README to describe the new tool mechanism and its security/limits model.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
host/src/wasm_host_fns.rs New Wasm tool loader/invoker with WASI Preview1 wiring, option parsing, stdout parsing, and tests.
host/src/main.rs Adds feature-gated CLI flags for Wasm tools and registers tools into SandboxBuilder.
host/Cargo.toml Adds wasm-host-fns feature and optional wasmtime / wasmtime-wasi deps.
docs/host_functions.md Documents --tool and --tool-wasi-* behavior, protocol, and limits.
README.md Updates dispatch surface description and adds usage docs for Wasm host tools.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread host/src/wasm_host_fns.rs Outdated
Comment thread host/src/wasm_host_fns.rs
Comment thread host/src/wasm_host_fns.rs
@cachebag cachebag requested a review from Copilot June 9, 2026 02:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 6 changed files in this pull request and generated 5 comments.

Comment thread host/src/wasm_host_fns.rs
Comment thread host/Cargo.toml
Comment thread host/Cargo.toml
Comment thread host/src/wasm_host_fns.rs
Comment thread host/src/wasm_host_fns.rs
Signed-off-by: akrm al-hakimi <alhakimiakrmj@gmail.com>

@danbugs danbugs left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is AWESOME!! Thank you so much for the contribution! Just ggot some comments here and there for you to consider.

Comment thread docs/host_functions.md Outdated
Comment thread docs/host_functions.md Outdated
Comment thread docs/host_functions.md
Comment thread docs/host_functions.md Outdated
Comment thread host/src/main.rs
Comment thread host/src/wasm_host_fns.rs Outdated
Comment thread host/src/wasm_host_fns.rs
cachebag added 2 commits June 11, 2026 22:04
Signed-off-by: Akrm Al-Hakimi <alhakimiakrmj@gmail.com>
Signed-off-by: Akrm Al-Hakimi <alhakimiakrmj@gmail.com>

@danbugs danbugs left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly LGTM. I think this should be good to merge after addressing the echo tool comment. Thanks!

Comment thread host/src/main.rs
Signed-off-by: Akrm Al-Hakimi <alk9fh@bosch.com>

@danbugs danbugs left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for rebasing. Mostly LGTM. I think we just need to remove leftover --enable-tools references from the host functions doc and main README as well as modify the existing python-host-tools example to use a wasm host function. You can commit the echo Wasm host fxn to the repo under smt like: examples/echo-wasm-host-fxn or smt like that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expand --enable-tools to support user-provided host functions

3 participants