wasm

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 14, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package wasm implements the TierWASM sandbox using wazero (WASI preview1).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Tool

func Tool(name, desc string, module []byte, caps []policy.Capability) (runtime.ToolDescriptor, runtime.ToolExecutor)

Tool is a helper that wraps a WASM module as a ToolExecutor + ToolDescriptor. It creates a ToolExecutor that routes to a WASM sandbox.

Types

type WASM

type WASM struct {
	// PrecompileModule can be used to optimize repeated executions.
	// If nil, modules are compiled on-demand.
	PrecompiledModules map[string]wazero.CompiledModule
}

WASM is a sandbox that executes WASM modules with wazero (TierWASM). It enforces WASI preview1 with configurable capabilities and resource limits.

func New

func New() *WASM

New creates a new WASM sandbox.

func (*WASM) Run

Run executes a WASM module in an isolated environment with WASI preview1. stdin/stdout are set from spec.Input/result.Output. Capabilities in spec.Caps determine filesystem mounts (fs:read:<dir> → read-only preopen). MemoryLimitPages limits WASM memory; deadline from ctx kills execution.

Context cancellation / deadline is respected: the runtime is configured with WithCloseOnContextDone, so wazero injects cancellation checks into compiled code — even a tight WASM busy-loop is forcibly terminated when ctx is done. No goroutine is leaked.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL