Parent: #9
Summary
Extend Tier 1 WASM plugins to support node:fs, node:path, and node:os via polyfills in the shim and new host functions.
Blocked By
Nothing — can start immediately.
Deliverables
C1. Shim Polyfills
Modify: crates/openclaw-bridge/src/shim.rs
Add to generated shim header:
require() polyfill dispatching node:fs → _virtualFs, node:path → _virtualPath, node:os → _virtualOs
_virtualFs: readFileSync → hostReadFile, writeFileSync → hostWriteFile, existsSync, mkdirSync, readdirSync, statSync, unlinkSync
_virtualPath: pure JS join, resolve, dirname, basename, extname, sep, normalize
_virtualOs: homedir() → /data, platform() → "wasm", tmpdir() → /tmp
C2. New Host Functions
Modify: crates/astrid-plugins/src/wasm/host_functions.rs
Add (all through resolve_within_workspace() + SecurityGate):
astrid_fs_exists(path: PTR) → i32
astrid_fs_mkdir(path: PTR)
astrid_fs_readdir(path: PTR) → PTR (JSON array)
astrid_fs_stat(path: PTR) → PTR (JSON: {size, isDir, mtime})
astrid_fs_unlink(path: PTR)
Update alphabetical host function index and QuickJS dispatch table.
C3. Transpiler Relaxation
Modify: crates/openclaw-bridge/src/transpiler.rs
Allow imports from node:fs, node:path, node:os (polyfilled). Rewrite to require() calls during transpilation. Continue rejecting other runtime imports.
Acceptance Criteria
Parent: #9
Summary
Extend Tier 1 WASM plugins to support
node:fs,node:path, andnode:osvia polyfills in the shim and new host functions.Blocked By
Nothing — can start immediately.
Deliverables
C1. Shim Polyfills
Modify:
crates/openclaw-bridge/src/shim.rsAdd to generated shim header:
require()polyfill dispatchingnode:fs→_virtualFs,node:path→_virtualPath,node:os→_virtualOs_virtualFs:readFileSync→hostReadFile,writeFileSync→hostWriteFile,existsSync,mkdirSync,readdirSync,statSync,unlinkSync_virtualPath: pure JSjoin,resolve,dirname,basename,extname,sep,normalize_virtualOs:homedir()→/data,platform()→"wasm",tmpdir()→/tmpC2. New Host Functions
Modify:
crates/astrid-plugins/src/wasm/host_functions.rsAdd (all through
resolve_within_workspace()+ SecurityGate):astrid_fs_exists(path: PTR) → i32astrid_fs_mkdir(path: PTR)astrid_fs_readdir(path: PTR) → PTR(JSON array)astrid_fs_stat(path: PTR) → PTR(JSON:{size, isDir, mtime})astrid_fs_unlink(path: PTR)Update alphabetical host function index and QuickJS dispatch table.
C3. Transpiler Relaxation
Modify:
crates/openclaw-bridge/src/transpiler.rsAllow imports from
node:fs,node:path,node:os(polyfilled). Rewrite torequire()calls during transpilation. Continue rejecting other runtime imports.Acceptance Criteria
require("node:fs").readFileSync(...)works through host functionsnode:pathoperations work as pure JS (no host function needed)node:osreturns virtual values (homedir→/data)node:fs,node:path,node:osimports