@computesdk/tenki

中文文档
0.1.22发布于 2026/11/06MITTypeScriptESM + CJS构建来源已验证近 30 天下载 9622

Tenki Cloud provider for ComputeSDK - microVM sandboxes with native filesystem, preview URLs, snapshots, and SSH

原始使用文档
文档目录10 节
  1. Installation
  2. Setup
  3. Usage
  4. With ComputeSDK
  5. Filesystem operations
  6. Public preview URLs
  7. Configuration
  8. Feature support
  9. Notes
  10. License

@computesdk/tenki

Tenki Cloud provider for ComputeSDK - run code in fast microVM sandboxes with native filesystem operations, public preview URLs, snapshots, volumes, and SSH.

Installation

npm install @computesdk/tenki

Requires Node.js 20 or later (the Tenki SDK's gRPC transport depends on it).

Setup

  1. Sign up at app.tenki.cloud
  2. Create an API key in your workspace settings
  3. Set it as an environment variable:
export TENKI_API_KEY=tk_your_api_key

Usage

With ComputeSDK

import { compute } from 'computesdk';
import { tenki } from '@computesdk/tenki';

compute.setConfig({ provider: tenki({ apiKey: process.env.TENKI_API_KEY }) });

const sandbox = await compute.instances.create();

const result = await sandbox.runCommand('echo "Hello from Tenki!"');
console.log(result.stdout);

await sandbox.destroy();

Filesystem operations

Tenki exposes native file primitives over its data plane, so filesystem operations do not go through shell commands (no escaping hazards, works with any path or content):

await sandbox.filesystem.writeFile('/home/tenki/app.py', 'print("hi")');
const content = await sandbox.filesystem.readFile('/home/tenki/app.py');
const entries = await sandbox.filesystem.readdir('/home/tenki');
await sandbox.filesystem.mkdir('/home/tenki/data');
const exists = await sandbox.filesystem.exists('/home/tenki/app.py');
await sandbox.filesystem.remove('/home/tenki/app.py');

Public preview URLs

// Start a server (background commands are detached automatically)
await sandbox.runCommand('python3 -m http.server 3000', { background: true });

// Expose the port at a public URL
const url = await sandbox.getUrl({ port: 3000 });
// => https://<slug>.sb.tenki.sh

Configuration

OptionEnv varDefaultDescription
apiKeyTENKI_API_KEY / TENKI_AUTH_TOKENrequiredTenki API key (tk_...)
baseUrlTENKI_API_URLhttps://api.tenki.cloudAPI endpoint
workspaceIdTENKI_WORKSPACE_IDinferred from workspace API keyExplicit workspace for trusted service credentials
projectId-ignoredDeprecated; Tenki no longer scopes sandboxes by project
timeout-noneDefault runCommand timeout (ms)
cpuCores / memoryMb / diskSizeGb-Tenki defaultsDefault sandbox resources

Workspace API keys infer their workspace server-side. Set workspaceId, or TENKI_WORKSPACE_ID, only when using trusted service credentials that require explicit scope.

Per-sandbox resource overrides are accepted on create:

await compute.instances.create({ cpuCores: 4, memoryMb: 8192 });

Feature support

FeatureSupported
Commands (runCommand)Yes - via sh -lc, so pipes, globs, and env expansion work
FilesystemYes - native data-plane file API
Public URLs (getUrl)Yes - per-port preview URLs
List / getById / destroyYes
Background commandsYes - { background: true } detaches stdio automatically
Custom imagesVia Tenki templates (templateId maps to a Tenki image ref)
Pause / resumeYes - sandbox.pause() / sandbox.resume(); memory, processes and files (including /tmp) survive
SnapshotsYes - compute.snapshot.create(id), restore with create({ snapshotId }); memory snapshots that keep the rootfs except /tmp (emptied on the source too), source keeps running

Notes

  • runCommand wraps the command in sh -lc because Tenki's exec runs argv directly (execve, no shell).
  • A long-running process started with a bare & would hold the exec output stream open; use { background: true }, which detaches stdio for you.
  • For advanced features (SSH, tunnels, git operations), use the underlying SDK directly via sandbox.getInstance(), which returns the @tenkicloud/sandbox Session.

License

MIT

版本与发布记录

@computesdk/tenki 共发布 22 个版本,首次发布于 2026/07/01;过去 12 个月发布了 22 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.1.22latest2026/11/064 天前
0.1.212026/11/046 天前
0.1.202026/10/2812 天前
0.1.192026/10/2317 天前
0.1.182026/10/2318 天前
0.1.172026/10/2218 天前

关于 @computesdk/tenki 的常见问题

@computesdk/tenki 是什么?

Tenki Cloud provider for ComputeSDK - microVM sandboxes with native filesystem, preview URLs, snapshots, and SSH

如何安装 @computesdk/tenki?

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

@computesdk/tenki 支持 TypeScript 吗?

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

@computesdk/tenki 支持 ESM 还是 CommonJS?

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

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

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

@computesdk/tenki 可以商用吗?

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

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

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

@computesdk/tenki 还在维护吗?

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