Skip to content

feat: expose host print function to Node.js API#55

Open
simongdavies wants to merge 1 commit intohyperlight-dev:mainfrom
simongdavies:expose-host-print-to-node-js
Open

feat: expose host print function to Node.js API#55
simongdavies wants to merge 1 commit intohyperlight-dev:mainfrom
simongdavies:expose-host-print-to-node-js

Conversation

@simongdavies
Copy link
Contributor

Add setHostPrintFn() to SandboxBuilder allowing Node.js callers to receive guest console.log/print output via a callback.

  • New setHostPrintFn(callback) method on SandboxBuilder (NAPI layer)
  • Uses ThreadsafeFunction in blocking mode for synchronous print semantics
  • Supports method chaining (returns this)
  • Added to lib.js sync wrapper list for error code extraction
  • 4 new vitest tests: chaining, single log, multiple logs, consumed error
  • index.d.ts auto-generated by napi build with correct TypeScript types

@simongdavies simongdavies added the kind/enhancement New feature or improvement label Mar 18, 2026
Add setHostPrintFn() to SandboxBuilder allowing Node.js callers to
receive guest console.log/print output via a callback.

- New setHostPrintFn(callback) method on SandboxBuilder (NAPI layer)
- Uses ThreadsafeFunction<String> in blocking mode for synchronous
  print semantics
- Supports method chaining (returns this)
- Added to lib.js sync wrapper list for error code extraction
- 4 new vitest tests: chaining, single log, multiple logs, consumed error
- index.d.ts auto-generated by napi build with correct TypeScript types

Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com>
@simongdavies simongdavies force-pushed the expose-host-print-to-node-js branch from 54b4d31 to 0e553bc Compare March 18, 2026 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/enhancement New feature or improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant