返回 Skill 列表
extension
分类: 开发与工程无需 API Key

railway-sandbox

使用ComputeSDK创建和管理Railway沙箱的指南。在构建需要在Railway基础设施上自托管沙箱环境的应用程序时使用,适用于代码执行、容器化开发或持久服务。

person作者: jakexiaohubgithub

Railway Sandboxes with ComputeSDK

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

Setup

npm install computesdk @computesdk/railway

Set your credentials:

# .env
RAILWAY_API_TOKEN=your_railway_api_token
RAILWAY_ENVIRONMENT_ID=your_railway_environment_id

Quick Start

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.sandbox.create();

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

await sandbox.destroy();

You can also call the provider factory directly:

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

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

Railway Configuration

interface RailwayConfig {

  /** Railway API token - falls back to the RAILWAY_API_TOKEN environment variable */
  token?: string;
  /** Railway environment ID - falls back to the RAILWAY_ENVIRONMENT_ID environment variable */
  environmentId?: string;

}

Full API

ComputeSDK exposes the same universal sandbox API across providers: sandbox.create(), sandbox.getById(), sandbox.destroy(), sandbox.runCommand(), sandbox.getInfo(), sandbox.getUrl(), and sandbox.filesystem.*.

Install the main skill for the complete reference:

npx skills add https://github.com/computesdk/sandbox-skills --skill computesdk

Or see https://www.computesdk.com/docs/reference/sandbox/.