feat(wasm): host-backed filesystem for the wasm bindings - #2275
Merged
Conversation
`new Bash({ fs })` runs scripts directly against storage the embedder
owns — a Durable Object, OPFS, IndexedDB — instead of the in-memory VFS.
Nothing is copied in or diffed back out: every read and write during a
run is a call into the host object, so there is no workspace-size ceiling
beyond the host's own and no lost-update window between runs.
The bridge implements `FsBackend` and wraps it in `PosixFs`, so hosts
supply raw storage (seven required methods, validated at construction)
and inherit POSIX semantics. `append`, `copy`, and `rename` are
synthesized when omitted, `chmod` is accepted and ignored so `chmod +x`
works against hosts with no permission model, and host errors carrying a
`code` map onto the matching `io::ErrorKind` so builtins that branch on
kind behave as they do over the built-in VFS.
Host calls may return promises, so a host filesystem implies `execute()`;
`executeSync` reports the suspension rather than blocking, and `files` is
rejected alongside `fs` because seeding cannot complete synchronously.
A host that answers `undefined` is broken, and reading that as "missing" turns every existence probe into a silent miss — a redirect reports the workspace as gone rather than reporting the host. Fail with a message that names the contract instead. Also documents the host filesystem as TM-FS-017: it widens the sandbox to whatever the embedder's object exposes, and its bytes live outside the VFS quotas, so scoping and storage limits are the embedder's.
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
bashkit | 70e9d47 | Commit Preview URL Branch Preview URL |
Aug 06 2026, 05:39 AM |
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
new Bash({ fs })in the wasm bindings now runs scripts directly against embedder-owned storage such as a Durable Object, IndexedDB, or OPFS. Reads and writes stay live; no workspace copy or write-back diff is required.Hosts implement seven required raw-storage methods, validated at construction.
PosixFssupplies parent, directory, and symlink semantics. Optional append/copy/rename operations have fallbacks, host POSIX error codes map to matching I/O kinds, and malformed host responses fail explicitly.The async contract is enforced: host-backed filesystems require
execute(), andfilescannot be combined withfs.Why
Embedders previously had to copy their storage into the in-memory VFS before every run and diff it back afterward. That was O(workspace), text-oriented, and exposed a lost-update window. The new adapter lets Bashkit operate on the embedder's authoritative bytes.
Before / After
Before: scripts only saw Bashkit's in-memory VFS; external storage required seeding and write-back.
After:
The wasm integration suite proves redirects, reads, text tools, directories, copy/move fallbacks, error mapping, invalid host responses, async suspension, and constructor validation against an always-async fake host.
Risk
fsis supplied.ENOSYSfor symlink operations.Checklist