@computesdk/ec2-firecrab

中文文档
1.0.5发布于 2026/11/06MITTypeScriptESM + CJS近 30 天下载 3480

Firecracker microVMs on self-hosted EC2 as a ComputeSDK sandbox provider

原始使用文档
文档目录6 节
  1. Installation
  2. Prerequisites
  3. Configuration
  4. Usage
  5. Supported runtimes and features
  6. Limitations

@computesdk/ec2-firecrab

Firecracker microVMs on self-hosted AWS EC2 as a ComputeSDK sandbox provider, driven by a firecrab host. Each sandbox is a Firecracker microVM built from an OCI image, carved out of a shared EC2 hypervisor host.

Installation

npm install @computesdk/ec2-firecrab

Prerequisites

  • An EC2 host on a nested-virtualization-capable Intel type (m8i/c8i/r8i, m7i/c7i/r7i, i7i, or any .metal) launched with CpuOptions.NestedVirtualization=enabled
  • firecrab installed on the host (firecrab-api on 127.0.0.1:5523)
  • A MicroNetwork created on the host (POST /api/micro-networks) — its CIDR must not overlap the VPC's
  • At least one OCI image imported (firecrab image import <ref>)
  • A path to the loopback API: SSH/SSM port-forward, or run the adapter on the host

Configuration

import { ec2Firecrab } from '@computesdk/ec2-firecrab';

const provider = ec2Firecrab({
  // Off-host operation: one SSH target + key. The adapter lazily opens an
  // SSH local-forward to the host's loopback API and derives the guest-exec
  // jumphost from the same credentials — no manual tunnel or ProxyCommand.
  sshTarget: 'ubuntu@<host-public-ip>',       // or EC2_FIRECRAB_SSH_TARGET
  // sshTargets: ['ubuntu@ip1', 'ubuntu@ip2'], // host pool — or EC2_FIRECRAB_SSH_TARGETS (csv);
                                              // creates round-robin across hosts
  sshIdentityPem: process.env.SSH_KEY_PEM,    // or EC2_FIRECRAB_SSH_KEY (key material)
  // sshIdentityPath: '~/.ssh/firecrab.pem',  // or EC2_FIRECRAB_SSH_KEY_PATH

  microNetwork: 'lab',                        // name or EC2_FIRECRAB_MICRO_NETWORK;
                                              // or microNetworkId / EC2_FIRECRAB_MICRO_NETWORK_ID
  template: 'catthehacker-ubuntu-act-latest', // or EC2_FIRECRAB_TEMPLATE
  cpus: 2,
  memoryMib: 4096,
  diskGb: 16,
  egressPolicy: 'internet',                   // or 'isolated'
  sshUser: 'root',                            // or EC2_FIRECRAB_SSH_USER
});

Already on the host or tunneled yourself? Omit sshTarget and use apiUrl (EC2_FIRECRAB_API_URL, default http://127.0.0.1:5523); sshProxyCommand (EC2_FIRECRAB_SSH_PROXY_COMMAND) remains an escape hatch for custom jumphosts.

Usage

const sandbox = await provider.instances.create();
const result = await sandbox.runCommand('echo hello from the microVM');
console.log(result.stdout);
await provider.instances.destroy(sandbox.instanceId);

Supported runtimes and features

  • Any OCI image works as the guest rootfs — firecrab converts it to ext4 and pairs a kernel. docker run images like node:22, alpine, or catthehacker/ubuntu:act-latest boot directly.
  • ~50ms Firecracker boot; ~19s cold create→running dominated by rootfs materialization (verified 2026-10-23 on m8i.xlarge).

Limitations

  • Exec is SSH — runCommand uses the per-VM managed SSH key (GET /api/vms/{id}/ssh-key) and the guest's sshd. Off-host callers must set sshProxyCommand since guest bridge IPs are only routable from the host. A computesdk-runtime guest agent is planned to replace this with the standard HTTP exec/fs surface.
  • No filesystem block yet — file ops fall back to "not supported"; they run over SSH today and land formally with runtime injection.
  • No getUrl/preview URLs — guest port publishing is not wired yet.
  • No snapshots, pause/resume, or background mode — current firecrab builds don't expose these endpoints.
  • destroy is slow (~30s) — stop is a graceful ACPI shutdown with no force flag; DELETE on a running VM returns 409.
  • firecrab's API is unauthenticated loopback by design — you own the transport (SSM/SSH tunnel).

版本与发布记录

@computesdk/ec2-firecrab 共发布 6 个版本,首次发布于 2026/10/24;过去 12 个月发布了 6 个版本。

版本发布日期距今
1.0.5latest2026/11/064 天前
1.0.42026/11/046 天前
1.0.32026/10/2813 天前
1.0.22026/10/2417 天前
1.0.12026/10/2417 天前
0.0.0-stage2026/10/2417 天前

关于 @computesdk/ec2-firecrab 的常见问题

@computesdk/ec2-firecrab 是什么?

Firecracker microVMs on self-hosted EC2 as a ComputeSDK sandbox provider

如何安装 @computesdk/ec2-firecrab?

在项目目录运行 npm install @computesdk/ec2-firecrab,或使用 pnpm add / yarn add / bun add。

@computesdk/ec2-firecrab 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@computesdk/ec2-firecrab 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@computesdk/ec2-firecrab 可以商用吗?

@computesdk/ec2-firecrab 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@computesdk/ec2-firecrab 的下载量有多少?

根据 npm 官方下载统计,@computesdk/ec2-firecrab 在 2026/10/11 – 2026/11/09 这 30 天内被下载 3,480 次,日均约 116 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@computesdk/ec2-firecrab 还在维护吗?

最新版本 1.0.5 发布于 2026/11/06(4 天前);至今共发布 6 个版本,其中过去 12 个月发布了 6 个;首次发布于 2026/10/24。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。