Pi coding agent for Wasmer
Pi 1.0.0 is prepared locally for review before publication. It uses published Edge.js, coreutils, fd, ripgrep, grep, sed, findutils and curl packages. Its command runs upstream's bundled CLI directly. Pi's JavaScript and package metadata are unchanged; the package contains no Bash adapter or embedded runtime/search-tool modules.
| Dependency | Version | Purpose |
|---|---|---|
wasmer/edgejs | =0.2.4 | Node.js runtime, npm and pnpm |
wasmer/bash | =1.0.25 | Shell |
wasmer/coreutils | =1.0.27 | uutils commands including tail and nohup |
wasmer/fd | =10.5.1 | Pi's find tool |
wasmer/ripgrep | =15.2.1 | Pi's grep tool |
wasmer/grep | =3.12.0 | GNU grep for shell commands |
wasmer/sed | =4.9.0 | GNU sed for shell commands |
wasmer/findutils | =0.10.1 | uutils find, xargs, locate and updatedb |
curl/curl | =8.4.0 | HTTP/HTTPS requests and server checks |
The tool packages are available on both wasmer.io and wasmer.wtf. Their source
and reproducible build instructions live in wasix-org/fd,
wasix-org/ripgrep,
wasix-org/findutils,
and wasix-org/coreutils.
The existing GNU grep and sed packages are reused. Package license notices are
mounted under /opt/<package>/licenses, leaving /usr available for command installation.
Use the published package
The previous package is published as wasmer/pi@0.87.1 on both
wasmer.io and
wasmer.wtf. The wasmer.sh and WasmerShell Pi
examples load wasmer/pi@=0.87.1 from the registry; select Pi and run pi.
No local package build is required to use either example.
Build from source
Install Node.js, npm and the Wasmer CLI, then run from the SDK repository root:
bash packages/pi/build.sh
The output is target/pi-1.0.0.webc. Pass another output path as the first
argument to build.sh. To build directly into the browser example's assets:
bash packages/pi/build.sh wasmer-sh/public/packages/pi-1.0.0.webc
No Edge.js checkout or Rust build is required. Local WebC files are useful for package development; the browser and Swift example catalogs use the published registry package by default.
The build installs the locked Pi dependencies with lifecycle scripts disabled
and omits native optional binaries. It then uses pinned optimize-deps@0.1.2
with NFT 1.11.0 to trace the shipped CLI, bundle, public SDK and dynamic worker
entrypoints. exportsOnly avoids copying unused alternate module entrypoints.
All provider and OAuth entrypoints, the public
SDK runtime, extension support, image processing, themes, HTML export assets,
docs, examples and license notices are preserved. Source maps and TypeScript
declarations are omitted; runnable TypeScript examples remain.
For Pi 1.0.0 this reduces the WebC from 35.47 MiB to 32.22 MiB (9.1%). These sizes exclude the shared runtime and command dependencies. The optimization preserves the feature set and does not modify upstream JavaScript.
Generated payloads live in .build/runtime and .build/licenses.
.build/inventory.json records every retained runtime file's size and SHA-256;
.build/build.json records optimizer versions and tracing warnings. The build
verifies that retained files are byte-identical to the locked npm install.
LICENSE.pi is the MIT license from upstream Pi's v1.0.0 tag.
Review Pi 1.0 locally
The shared browser and Swift catalogs continue to use published Pi 0.87.1 until 1.0.0 has been reviewed and published. The local overrides below load the new WebC while resolving its shared runtime and command dependencies from the registry.
For the browser, run from the SDK repository root:
VITE_PI_WEBC_URL="/@fs$(pwd)/target/pi-1.0.0.webc" npm --prefix wasmer-sh run dev
Open http://127.0.0.1:5173/?example=pi, then run pi --version and pi.
The override applies only in development. Production builds use the catalog.
Pi 1.0 defaults to fullscreen; pi --tui-mode regular retains normal scrollback.
For WasmerShell on the iOS simulator:
python3 swift/Examples/WasmerShell/build.py run --example pi --pi-webc target/pi-1.0.0.webc
The new package also preserves the MCP modules and codemode worker and QuickJS Wasm. The build verifies their presence alongside its byte-for-byte upstream inventory. Dynamic OAuth loaders and the QuickJS Wasm are explicitly retained where NFT cannot infer them, and their loading and execution are tested. Optional native Kerberos, esbuild and WebSocket accelerators remain outside this package's supported paths.
Test and use
The SDK pins Wasmer's codex/pi-sdk-runtime
integration at 5bd2b7d3182e816bd0ea330acc88e4e4733e167f. This includes the complete
child-reaping fix (#6982), the filesystem
timestamp fix, merged N-API fixes, exec signal ownership, corrected redirected
stdio/socket-pair types, decoded Fetch response headers, and independent registration
of package command aliases so an unavailable /usr/bin path does not break /bin/pi.
It also includes missing-PID signal errors (#7045).
Edge.js 0.2.4 handles detached spawning and signal errors in its native WASIX
bindings, so no JavaScript preload is needed. A normal SDK build uses the pinned sources;
WASMER_REPO is optional for local runtime development.
Both npm and pnpm invoke pnpm 10.34.5. Edge.js keeps real npm under
edge-npm-internal for pnpm's delegated operations without recursing into the alias.
To test:
WASMER_PI_SDK=/absolute/path/to/js/dist/node.js node packages/pi/test-sdk.mjs
The test loads only the Pi WebC, resolves its dependencies from the registry,
checks the commands, search behavior, shell pipelines, curl, nohup, tail and
nonblocking child waits, verifies shell launches with provider arguments, abort and
timeout, then exercises
all seven agent tools through pi with a local streaming model fixture. It also checks
codemode workers, stored values and timeouts, MCP stdio, the MCP CLI, and nested
agent tool execution. Distribution checks load all provider/OAuth bundle chunks,
load a TypeScript extension, resize an image, check shipped assets and export
the saved session to HTML. It uses no provider credentials or
paid API calls. For the native CLI, set WASMER_BIN to a compatible Wasmer build
and run node packages/pi/test.mjs.
The Bash tool runs without an adapter or NODE_OPTIONS preload. WASIX accepts
detached: true as ordinary spawning; it does not create a Unix process group.
Pi's cancellation falls back to terminating the immediate child, so descendant
processes may remain. Use Restart to stop the entire sandbox.
In wasmer.sh, select Pi and run pi. Pi is ready from its WebC
package, with the published runtime and tool dependencies. No npm installation
or local pi-tools.webc is needed.
The example's browser regression is:
cd wasmer-sh
WASMER_EXAMPLE=pi WASMER_PI_VERSION=1.0.0 VITE_PI_WEBC_URL="/@fs$(pwd)/../target/pi-1.0.0.webc" npm run test:examples
Use /login inside Pi to connect an AI provider with a subscription or API key,
then /model to choose a model. To expose all built-in tools,
pass --tools read,write,edit,bash,grep,find,ls.
Pi 1.0 treats --tools as a strict allowlist, including MCP tools. To enable
codemode while preserving MCP discovery, add "defaultTools": ["+codemode"]
to Pi's settings rather than supplying an allowlist that omits those tools.
The size study documents remaining runtime limits: unbundled SDK JSON imports on the JavaScript N-API host, the experimental plugin bundler's native esbuild requirement, and tools such as Git that must be supplied by the surrounding environment. Moving fd and ripgrep to dependencies does not change those limits. The build and tests do not publish Pi.
After local review, release the prepared wasmer/pi@1.0.0 package to both registries,
then update the shared catalog and production version checks:
wasmer publish packages/pi --registry https://registry.wasmer.io/graphql --non-interactive --wait=container
wasmer publish packages/pi --registry https://registry.wasmer.wtf/graphql --non-interactive --wait=container
After publication, test the published package instead of a local WebC:
node packages/pi/test-sdk.mjs wasmer/pi@=1.0.0
Runtime development
build-runtime.sh remains available for source work on Edge.js and the host.
Set EDGEJS_REPO and WASMER_REPO to their source checkouts. The Pi package
build itself uses the published Edge.js dependency.
The relevant runtime changes are Edge.js #155 and #156, libuv #15, Wasmer #7035, and N-API #76/#77. The standard WISP transport and released WASIX libc work with the example.