@computesdk/gravixlayer

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

GravixLayer provider for ComputeSDK — cloud runtimes with a native filesystem, live command streaming, and snapshots

原始使用文档

@computesdk/gravixlayer

GravixLayer provider for ComputeSDK — cloud runtimes with a native filesystem API, live command streaming, port publishing, templates, and snapshots.

npm install @computesdk/gravixlayer

Requires Node.js 20 or later.

import { gravixlayer } from '@computesdk/gravixlayer'

const compute = gravixlayer({
  apiKey: process.env.GRAVIXLAYER_API_KEY,
})

const sandbox = await compute.instances.create({
  templateId: 'base-small',
})
const result = await sandbox.runCommand('node --version')
console.log(result.stdout)
await sandbox.destroy()

Get an API key at https://gravixlayer.ai. The TypeScript SDK is gravixlayer; product docs live at https://docs.gravixlayer.ai.

Configuration

OptionEnvironment variableDescription
apiKeyGRAVIXLAYER_API_KEYGravixLayer API key (required).
baseUrlGRAVIXLAYER_BASE_URLAPI origin. Defaults to https://api.gravixlayer.ai.
cloudGRAVIXLAYER_CLOUDCloud for runtime and template placement. Defaults to aws.
regionGRAVIXLAYER_REGIONRegion for runtime and template placement. Defaults to us-east-1.
timeout—Request timeout in milliseconds.
maxRetries—Retry budget. Defaults to 0.
http2—Use HTTP/2. Defaults to true.

create takes templateId (an existing template), or snapshotId, plus envs, timeout, metadata, cloud, and region. Omitting templateId boots base-small. Omitting cloud and region uses aws and us-east-1. Sizing comes from the template. image is not accepted: build a template from an image with template.create({ name, fromImage }), then pass its name as templateId. sandbox.getInstance() returns the GravixLayer Runtime handle for filesystem, services, and other SDK APIs.

Snapshots require a name on snapshot.create and default to hot (filesystem and memory, so /tmp is restored); pass metadata: { kind: 'cold' } for a filesystem-only snapshot. Template builds need fromImage or dockerfile on template.create; select an existing template with templateId when creating a sandbox.

版本与发布记录

@computesdk/gravixlayer 共发布 17 个版本,首次发布于 2026/10/02;过去 12 个月发布了 17 个版本。

版本发布日期距今
1.0.17latest2026/11/064 天前
1.0.162026/11/046 天前
1.0.152026/10/2813 天前
1.0.142026/10/2318 天前
1.0.132026/10/2318 天前
1.0.122026/10/2219 天前

关于 @computesdk/gravixlayer 的常见问题

@computesdk/gravixlayer 是什么?

GravixLayer provider for ComputeSDK — cloud runtimes with a native filesystem, live command streaming, and snapshots

如何安装 @computesdk/gravixlayer?

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

@computesdk/gravixlayer 支持 TypeScript 吗?

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

@computesdk/gravixlayer 支持 ESM 还是 CommonJS?

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

@computesdk/gravixlayer 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@computesdk/gravixlayer 可以商用吗?

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

@computesdk/gravixlayer 的下载量有多少?

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

@computesdk/gravixlayer 还在维护吗?

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