
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
wasi.team/client
This shows an example implementation of the Wasimoff Client as a commandline interface. To build the CLI run go build
. (You can also use go install wasi.team/client@latest
but this currently clobbers the very generic executable name client
. Sorry, I need to rename this package.)
go build -o wasimoff client.go
The main operations of this CLI are -upload <file>
, -exec <filename> [<args>]
and -run <jobfile>
.
Other options include -broker <url>
to use a different Broker, -ws
to use a WebSocket for asynchronous task submission with -run
, and -verbose
to print a few more intermediate steps.
First, upload your WebAssembly WASI preview 1 executable (and optional rootfs ZIP) with:
./wasimoff -upload <file>
For example ./wasimoff -upload tsp.wasm
for the travelling salesman example. The command will also print a sha256:..
reference, which you can use instead of the filename later. The Broker currently only accepts application/wasm
and application/zip
content-types.
You can then start a single invocation as if you were starting the WebAssembly binary locally with:
./wasimoff -exec <filename> [<args>]
Again, using the TSP example, you could calculate the route for ten random cities using ./wasimoff -exec tsp.wasm rand 10
and get the output back on stdout. This is approximately equivalent to running wasmtime tsp.wasm ...
. If you need data from stdin, use -stdin
, which will read until EOF and send it as a binary blob in the request.
Finally, you can write a JSON job file to start multiple tasks at the same time. The job file looks like this:
{
// tasks is a list of wasimoff.Task_Wasip1_Params
"tasks": [{
// the executable to start; use either "ref" with a filename / sha256 reference
// or "blob" with a base64-encoded binary blob as a string
"binary": { "ref": "hello.wasm" },
// optional: rootfs can contain a ZIP file that is extracted in the virtual
// WASI filesystem before execution; use "ref" or "blob" as above
"rootfs": { "ref": "hello.zip" },
// environment variables and commandline arguments, pretty straightforward;
// the first string in "args" is actually "arg0", i.e. the filename as seen
// by the executable itself
"envs": [ "DOS=demonstration" ],
"args": [ "hello.wasm", "print_envs", "print_rootfs", "file:hello.txt" ],
// optional: data to be passed to the application on stdin; must be base64
// encoded, as it is not necessarily a valid string
"stdin": "SGVsbG8sIFdvcmxkIQo=",
// optional: artifacts can be a list of files to return to the client in a
// ZIP file after execution; useful if the app writes results "to disk"
"artifacts": [ "hello.txt" ]
}]
}
The file is parsed as a wasimoff.Task_Wasip1_JobRequest
, where the parent
and each element in tasks
is a wasimoff.Task_Wasip1_Params
. The tasks use a very simple inheritance: each empty / nil
field is copied straight from the parent (that means envs
do not get concatenated either, for example). The following is an example job, which starts three identical TSP tasks, each computing a path for ten random cities:
{
"parent": {
"binary": { "ref": "tsp.wasm" },
"args": [ "tsp.wasm", "rand", "10" ]
},
"tasks": [ {}, {}, {} ]
}
In your own application, you'd rather construct these Protobuf messages directly instead of serializing JSON first. To that end, you can import the message definitions via the wasi.team
vanity import, which points to the root of this repository:
go get -u wasi.team/proto
package main
import (
...
wasimoff "wasi.team/proto/v1"
)
wasi.team/proto/v1/wasimoffv1connect
.wasi.team/broker/net/transport
and use transport.DialWasimoff()
.At the moment, I can only direct you towards the client.go
as an implementation example, sorry. The imports should work form anywhere though, so you can just copy the entire file to get started.
wasi.team/client/cmd/wasimoff
.FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.