mcpField
E
e2b-sandbox

e2b-sandbox

github.com/computesdk云与 DevOps182 次安装3 天前更新
代码仓库

关于 e2b-sandbox

e2b-sandbox 是面向开发者的 ComputeSDK 技能,用于创建和管理 E2B 云沙箱,在隔离的 Linux 环境中执行命令和处理文件。它采用 ComputeSDK 的统一沙箱 API。

主要功能

  1. 01创建和获取沙箱
  2. 02在沙箱中运行命令
  3. 03访问沙箱文件系统
  4. 04查看信息、获取 URL 并销毁沙箱
  5. 05配置 API 密钥和执行超时

适用场景

  1. 01在隔离的 Linux 环境中运行命令
  2. 02在云沙箱中读写文件

安装

复制下面的命令,在终端中运行。

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

安装后在 Claude Code 中输入/e2b-sandbox确认已加载。

详细介绍

使用 ComputeSDK 的 E2B 沙箱

ComputeSDK 的 E2B 提供商——具备完整 Linux 环境、文件系统访问权限和 microVM 隔离的云沙箱。

设置

npm install computesdk @computesdk/e2b

设置凭据:

# .env
E2B_API_KEY=your_e2b_api_key

快速开始

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

compute.setConfig({
  provider: e2b({
    apiKey: process.env.E2B_API_KEY,
  }),
});

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

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

await sandbox.destroy();

你也可以直接调用提供商工厂:

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

const sdk = e2b({
    apiKey: process.env.E2B_API_KEY,
  });
const sandbox = await sdk.sandbox.create();

E2B 配置

interface E2BConfig {

  /** E2B API key - if not provided, will fallback to E2B_API_KEY environment variable */
  apiKey?: string;
  /** Execution timeout in milliseconds */
  timeout?: number;

}

完整 API

ComputeSDK 在各个提供商之间提供相同的通用沙箱 API:sandbox.create()、sandbox.getById()、sandbox.destroy()、sandbox.runCommand()、sandbox.getInfo()、sandbox.getUrl() 和 sandbox.filesystem.*。

安装主技能以查看完整参考:

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

或者参阅 https://www.computesdk.com/docs/reference/sandbox/。

评论

支持 Markdown