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:

  1. Typechecking: tsc compiles TypeScript to JavaScript.
  2. Bundling: esbuild bundles the code and the SDK into a single ESM module.
  3. Componentization: ComponentizeJS converts the bundle into a wasm32-wasip2 component using StarlingMonkey.
  4. Packaging: A Rust-based tool packs the resulting Wasm file and a Capsule.toml configuration into a .capsule archive.

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 @install to define capsule behavior and lifecycle hooks.
  • Language Agnostic: Produces the same .capsule archive 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