Skip to content

Windows support#18

Merged
simongdavies merged 6 commits intohyperlight-dev:mainfrom
simongdavies:windows-support
Mar 27, 2026
Merged

Windows support#18
simongdavies merged 6 commits intohyperlight-dev:mainfrom
simongdavies:windows-support

Conversation

@simongdavies
Copy link
Copy Markdown
Contributor

This pull request updates the build and packaging process to produce a cross-platform npm package with prebuilt native addons for multiple platforms. It also refines the GitHub Actions workflow to build and combine these native artifacts, and improves the logic for copying and resolving native modules. Minor fixes and improvements are included in scripts and tests.

- Justfile: [windows] recipes for build-hyperlight, resolve-hyperlight-dir, start-debug
- Justfile: runtime-cflags forward-slash fix for clang cross-compilation
- build-binary.js: .cmd launcher, platform-aware post-build output
- plugins: O_NOFOLLOW fallback (Windows lacks O_NOFOLLOW, relies on lstat pre-check)
- agent/index.ts: pathToFileURL for ESM plugin imports on Windows
- build.rs: forward-slash CFLAGS for clang on Windows
- code-validator/guest: win32-x64-msvc NAPI target
- .gitattributes: enforce LF line endings across platforms

VM resource management:
- sandbox/tool.js: invalidateSandbox() now calls dispose() on LoadedJSSandbox
  and JSSandbox for deterministic VM cleanup instead of relying on V8 GC
- Updated hyperlight-js dep to include dispose() API

Error handling:
- agent/event-handler.ts: suppress duplicate 'Tool execution failed' messages
- sandbox/tool.js: MMIO error detection in compilation and runtime paths
- agent/index.ts: surrogate pool env vars (HYPERLIGHT_INITIAL/MAX_SURROGATES)

Test fixes (Windows compatibility):
- tests: symlink EPERM skip for Windows (path-jail, fs-read, fs-write)
- tests/dts-sync: rmSync instead of shell rm -rf
- tests/pattern-loader: unique tmpdir per test to avoid Windows EBUSY locks

CI:
- pr-validate.yml: Windows WHP matrix
- publish.yml: Windows build support

Security:
- npm audit fix across all workspaces (picomatch, brace-expansion)
- plugin-system/manager.ts: simplified ternary

Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com>
- build-binary.js: use napi-rs generated index.js for platform detection
  instead of hardcoded triple shim. Copies all available .node files so
  the package works on any platform.
- publish.yml: build native addons on Linux AND Windows in parallel,
  upload as artifacts, combine in publish job. Tests run on each platform
  before upload. Follows same pattern as hyperlight-js PR #36.

Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 27, 2026 20:21
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates HyperAgent’s build/release pipeline to ship a single cross-platform npm package by producing and bundling prebuilt native addons (Linux + Windows), alongside a few Windows-focused robustness tweaks.

Changes:

  • Update scripts/build-binary.js to bundle all available platform .node addons into dist/ and improve Windows-safe launcher importing.
  • Refactor .github/workflows/publish.yml to build native addons per-platform, upload them as artifacts, then combine/publish from a single Ubuntu job.
  • Minor Windows stability fix in tests (more selective cleanup error swallowing) and a small postinstall script fix.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/pattern-loader.test.ts Tightens Windows temp-dir cleanup handling to only swallow known lock-related errors.
scripts/build-binary.js Copies multiple platform native addons into the packaged binary output; improves addon resolution and Windows path importing.
package.json Fixes postinstall inline script termination (adds trailing semicolon inside the conditional).
builtin-modules/src/types/ha-modules.d.ts Updates generated builtin-module typings (but currently introduces major API/type mismatches vs implementations).
builtin-modules/pptx.json Updates module metadata hashes.
builtin-modules/pptx-tables.json Updates module metadata hashes.
builtin-modules/pptx-charts.json Updates module metadata hashes.
builtin-modules/ooxml-core.json Updates module metadata hashes.
.github/workflows/publish.yml Splits build vs publish; adds Windows build target and combines native addon artifacts before publishing.

Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated 1 comment.

- Add x86_64-unknown-linux-musl to napi targets in package.json
- Add linux-musl build matrix entry in publish.yml (same Linux runner,
  installs musl-tools and adds Rust musl target)

Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 10 changed files in this pull request and generated 2 comments.

build-binary.js:
- Launcher detects musl vs glibc for hyperlight-analysis .node loading
  using ldd probe, tries platform-specific .node directly
- Uses napi-rs generated index.js for js-host-api (has full detection)
- Copies all available platform .node files via ALL_TRIPLES loop

publish.yml:
- musl build: cross-compiles from glibc runner with musl-tools,
  uses napi build --target x86_64-unknown-linux-musl, skips tests
  (musl .node can't run on glibc host)
- gnu/win32 builds: run tests natively on their platforms
- publish-npm: runs on self-hosted runner (needs Rust toolchain),
  downloads artifacts AFTER setup to avoid symlink clobber
- Verifies musl .node files are produced before artifact upload

Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com>
- ha-modules.d.ts: update return types to ShapeFragment (was string)
  to match upstream ShapeFragment safety system changes
- dts-sync.test.ts: add ha-modules.d.ts regeneration check that catches
  drift when module exports/types change but the generator isn't re-run

Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com>
@simongdavies simongdavies merged commit 6cd2fda into hyperlight-dev:main Mar 27, 2026
19 of 21 checks passed
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.

2 participants