Comment by fooker

3 hours ago

I meant: I want a program compiled to wasm capable of running in the sandbox calling another command line tool also compiled to wasm.

Right now the call is through an exec system call, but that can be changed.

In VSCode extensions this is trivial, this is how you create the 'executable':

https://github.com/floooh/vscode-kcide/blob/main/src/wasi.ts

...and this is how you run it:

https://github.com/floooh/vscode-kcide/blob/2dfc621aade4a2be...

The asmx.wasm file is a vanilla POSIX cmdline tool which loads and saves files via fopen/fread/frwrite/fclose, and the tool has been compiled with the WASI SDK: https://github.com/WebAssembly/wasi-sdk

The resulting VSCode extension (https://marketplace.visualstudio.com/items?itemName=floooh.v...) then even runs in the VSCode browser version (https://vscode.dev/)

But AFAIK there's currently no easy way to get a similar easy to use WASI wrapper in browsers (it's definitely possible though because the VSCode browser version does it - VSCode basically has a filesystem abstraction which works for native filesystems as well as virtualized web filesystems like github repositories).