Skip to content

feat(plugins): WASM Node.js polyfills for node:fs, node:path, node:os#20

Merged
joshuajbouw merged 1 commit into
mainfrom
feat/stream-c-wasm-polyfills
Feb 16, 2026
Merged

feat(plugins): WASM Node.js polyfills for node:fs, node:path, node:os#20
joshuajbouw merged 1 commit into
mainfrom
feat/stream-c-wasm-polyfills

Conversation

@joshuajbouw

Copy link
Copy Markdown
Contributor

Summary

  • Adds 5 new host functions (astrid_fs_exists, astrid_fs_mkdir, astrid_fs_readdir, astrid_fs_stat, astrid_fs_unlink) — all security-gated through resolve_within_workspace() + SecurityGate
  • Adds _virtualFs, _virtualPath, _virtualOs polyfill objects in the JS shim, with a require() polyfill that dispatches node:fs, node:path, node:os to them
  • Relaxes the transpiler to allow imports from polyfilled Node.js modules; converts ESM imports to CJS require() calls
  • Updates the QuickJS shim dispatch table from 7 to 12 host functions (alphabetically ordered)

Test Plan

  • cargo test -p openclaw-bridge -- --quiet — transpiler tests for polyfilled import acceptance, ESM→CJS conversion of import statements, rejection of non-polyfilled modules
  • cargo test -p astrid-plugins -- --quiet — host function ordering test verifies all 12 functions are correctly indexed
  • Manual: compile a plugin using import { readFileSync } from "node:fs" — should succeed (previously rejected as unresolved import)

Closes #12

…e:os

Enables Tier 1 WASM plugins to use core Node.js APIs through virtual
implementations backed by host functions:

- 5 new host functions: astrid_fs_exists, astrid_fs_mkdir, astrid_fs_readdir,
  astrid_fs_stat, astrid_fs_unlink (all security-gated via resolve_within_workspace)
- Shim polyfills: _virtualFs (readFileSync, writeFileSync, existsSync, mkdirSync,
  readdirSync, statSync, unlinkSync), _virtualPath (join, resolve, dirname,
  basename, extname, normalize, isAbsolute), _virtualOs (homedir, platform, tmpdir)
- require() polyfill dispatching node:fs/path/os to virtual implementations
- Transpiler relaxation: imports from polyfilled modules (node:fs, node:path,
  node:os) are now allowed and converted to require() calls via ESM->CJS
- Updated QuickJS shim dispatch table from 7 to 12 host functions

Closes #12
@joshuajbouw
joshuajbouw marked this pull request as draft February 16, 2026 12:58
@joshuajbouw joshuajbouw self-assigned this Feb 16, 2026
@joshuajbouw
joshuajbouw marked this pull request as ready for review February 16, 2026 16:36
@joshuajbouw
joshuajbouw merged commit 84279c5 into main Feb 16, 2026
5 checks passed
@joshuajbouw
joshuajbouw deleted the feat/stream-c-wasm-polyfills branch February 16, 2026 16:36
joshuajbouw added a commit that referenced this pull request Jul 2, 2026
….1.0

Points the wit submodule at astrid-runtime/wit@278dbca (PR #20), so the
committed wit-staging matches the pinned contract and the CI drift check
passes. Pairs with the dual-version host serving in this branch.

Claude-Session: https://claude.ai/code/session_01NvX2tE7tgXuCRevqqiXTGU
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WASM Node.js polyfills for node:fs, node:path, node:os

1 participant