Skip to content

Host Functions

WASM modules access runtime capabilities through host function imports. Each import is declared explicitly per entry in the imports list.

ImportDescription
wasi:cliEnvironment, exit, stdin/stdout/stderr, terminal
wasi:ioStreams and error handling
wasi:pollAsync polling / cooperative yielding (interface wasi:io/poll)
wasi:clocksWall clock and monotonic clock
wasi:filesystemFile system access through mounted directories
wasi:randomCryptographically secure random numbers
wasi:socketsTCP/UDP networking and DNS resolution
wasi:httpOutgoing HTTP client requests

Enable imports in your entry configuration:

- name: my_function
kind: function.wasm
fs: myns:assets
path: /module.wasm
hash: sha256:...
method: run
imports:
- wasi:cli
- wasi:io
- wasi:clocks
- wasi:filesystem
pool:
type: inline

Only declare the imports your module actually needs.

Each wasi:* import enables a group of related WASI Preview 2 interfaces.

Interfaces: wasi:clocks/wall-clock, wasi:clocks/monotonic-clock

Wall clock and monotonic clock for time operations. Monotonic clock integrates with the Wippy dispatcher for async sleep.

Interfaces: wasi:io/error, wasi:io/streams

Stream read/write operations and error handling. The wasi:io/poll interface is provided separately by the wasi:poll import.

Interfaces: wasi:io/poll

Async polling. The poll interface enables cooperative yielding through the dispatcher.

Interfaces: wasi:cli/environment, wasi:cli/exit, wasi:cli/stdin, wasi:cli/stdout, wasi:cli/stderr, wasi:cli/terminal-stdin, wasi:cli/terminal-stdout, wasi:cli/terminal-stderr

Access to environment variables, process exit codes, and standard I/O streams. Environment variables are mapped from the Wippy environment registry through WASI configuration.

Interfaces: wasi:filesystem/types, wasi:filesystem/preopens

File system access through mounted directories. Mounts are configured per-entry and map Wippy filesystem entries to guest paths.

wasi:
mounts:
- fs: myns:data
guest: /data
read_only: true

Interfaces: wasi:random/random, wasi:random/insecure, wasi:random/insecure-seed

Cryptographically secure and insecure random number generation.

Interfaces: wasi:sockets/instance-network, wasi:sockets/ip-name-lookup, wasi:sockets/tcp, wasi:sockets/tcp-create-socket, wasi:sockets/udp, wasi:sockets/udp-create-socket

TCP and UDP networking with DNS resolution. Socket operations integrate with the dispatcher for async I/O.

Interfaces: wasi:http/types, wasi:http/outgoing-handler

Outgoing HTTP client requests from within WASM modules. Supports request/response types defined by the WASI HTTP specification.