@computesdk/railway

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

Railway Sandboxes provider for ComputeSDK - run commands in Railway-hosted sandboxes

原始使用文档
文档目录9 节
  1. Installation
  2. Setup
  3. Quick Start
  4. Configuration
  5. Environment Variables
  6. Config options
  7. Supported Features
  8. Limitations
  9. License

@computesdk/railway

Railway provider for ComputeSDK - run commands in Railway Sandboxes, ephemeral compute environments backed by the Railway platform.

Installation

npm install @computesdk/railway

Requires Node.js >= 22 — the underlying railway SDK depends on Node 22 APIs (e.g. global WebSocket).

Setup

  1. Create a Railway API token at railway.com/account/tokens.
  2. Find the environment ID you want sandboxes to run in (Railway project → environment settings).
  3. Set the environment variables:
export RAILWAY_API_TOKEN=your_token_here
export RAILWAY_ENVIRONMENT_ID=your_environment_id_here

Quick Start

Configure compute with the Railway provider and create a sandbox:

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

compute.setConfig({
  provider: railway({
    token: process.env.RAILWAY_API_TOKEN,
    environmentId: process.env.RAILWAY_ENVIRONMENT_ID,
  }),
});

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

const result = await sandbox.runCommand('echo "hello from Railway"');
console.log(result.stdout);

await sandbox.destroy();

Alternatively, call the provider factory directly when you only need one provider:

import { railway } from '@computesdk/railway';

const sdk = railway({ token: process.env.RAILWAY_API_TOKEN });
const sandbox = await sdk.sandbox.create();

Configuration

Environment Variables

VariableRequiredDescription
RAILWAY_API_TOKENYesRailway API token used to authenticate.
RAILWAY_ENVIRONMENT_IDRecommendedRailway environment the sandbox runs in.

Config options

railway({
  token: '...',          // defaults to RAILWAY_API_TOKEN
  environmentId: '...',  // defaults to RAILWAY_ENVIRONMENT_ID
});

Per-command execution timeouts are supported via runCommand's options ({ timeout: ms }), which maps to Railway's timeoutSec.

Supported Features

FeatureSupportedNotes
Command execution (runCommand)✅Backed by sandbox.exec. timeout is mapped to Railway's timeoutSec.
Filesystem (filesystem.*)✅Implemented over the shell (cat/base64/mkdir/ls/rm) since Railway has no dedicated filesystem API.
List sandboxes (list)✅Enumerates sandboxes in the configured environment.
Get / destroy by ID✅Via Sandbox.connect / sandbox.destroy.
Port exposure (getUrl)❌Railway sandboxes do not expose public per-port URLs.
Templates / snapshots❌Railway templates are a build-time builder (Sandbox.template()), not an ID-addressable resource, so they are not mapped to ComputeSDK templates/snapshots.

Limitations

  • No port exposure. getUrl throws — Railway sandboxes don't publish public URLs per port.
  • Filesystem is shell-based. File operations run shell commands inside the sandbox, so they require a POSIX shell with base64, ls, and the usual coreutils (present on Railway's default image).
  • Templates/snapshots are not exposed. Use the underlying railway SDK's Sandbox.template() builder directly if you need custom base images.

License

MIT

版本与发布记录

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

版本发布日期距今
2.0.19latest2026/11/064 天前
2.0.182026/11/046 天前
2.0.172026/10/2812 天前
2.0.162026/10/2317 天前
2.0.152026/10/2318 天前
2.0.142026/10/2218 天前

关于 @computesdk/railway 的常见问题

@computesdk/railway 是什么?

Railway Sandboxes provider for ComputeSDK - run commands in Railway-hosted sandboxes

如何安装 @computesdk/railway?

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

@computesdk/railway 支持 TypeScript 吗?

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

@computesdk/railway 支持 ESM 还是 CommonJS?

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

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

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

@computesdk/railway 可以商用吗?

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

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

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

@computesdk/railway 还在维护吗?

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