astrid-runtime/sdk-js
JavaScript and TypeScript SDK for building Astrid capsules.
What it solves
It provides a way for developers to build "capsules" (isolated, portable binaries) using JavaScript and TypeScript instead of Rust. This allows developers to use familiar Node.js-like APIs and TypeScript decorators to create modular components that can be executed by the Astrid runtime kernel without needing to change the host ABI.
How it works
The SDK uses a build pipeline that transforms TypeScript code into a WebAssembly (Wasm) component. The process involves:
- Typechecking:
tsccompiles TypeScript to JavaScript. - Bundling:
esbuildbundles the code and the SDK into a single ESM module. - Componentization: ComponentizeJS converts the bundle into a
wasm32-wasip2component using StarlingMonkey. - Packaging: A Rust-based tool packs the resulting Wasm file and a
Capsule.tomlconfiguration into a.capsulearchive.
Who it’s for
Developers who prefer the ergonomics of JavaScript and TypeScript over Rust for building Astrid capsules, and those who are building daemon-mode workloads where the larger binary size of JS capsules (compared to Rust) is an acceptable trade-off.
Highlights
- Familiar API: Uses
node:fs/promises,node:child_process, and WHATWG fetch. - TypeScript Decorators: Uses decorators like
@capsule,@tool, and@installto define capsule behavior and lifecycle hooks. - Language Agnostic: Produces the same
.capsulearchive format and WIT contract as the Rust SDK, making binaries interchangeable from the kernel's perspective. - Integrated Build Tooling: Includes a build orchestrator that manages the entire pipeline from source code to the final archive.
Related
- Project
- Project
- Project
- Project
- Project