用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/shreed27/DAIN --skill sandbox命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
| name | sandbox |
| description | Safe code execution in Docker containers with resource limits |
| emoji | 📦 |
| gates | {"envs":{"anyOf":["DOCKER_HOST"]}} |
Execute code safely in isolated Docker containers with resource limits and timeout protection.
/run python "print('Hello')" Run Python code
/run node "console.log('Hi')" Run JavaScript
/run bash "ls -la" Run shell command
/run ruby "puts 'Hello'" Run Ruby code
/run python "code" --timeout 30 Set timeout (seconds)
/run node "code" --memory 512 Memory limit (MB)
/run python "code" --file script.py From file
/sandbox status Container status
/sandbox images Available images
/sandbox cleanup Remove old containers
import { createSandbox } from 'clodds/sandbox';
const sandbox = createSandbox({
// Docker settings
dockerHost: process.env.DOCKER_HOST,
// Default limits
defaultTimeoutMs: 30000,
defaultMemoryMB: 256,
defaultCpuShares: 512,
// Cleanup
autoCleanup: true,
maxContainerAgeMs: 3600000,
});
// Run Python
const result = await sandbox.run({
language: 'python',
code: `
import math
print(f"Pi is {math.pi}")
`,
});
console.log(`Output: ${result.stdout}`);
console.log(`Exit code: ${result.exitCode}`);
console.log(`Duration: ${result.durationMs}ms`);
// Run with limits
const result = await sandbox.run({
language: 'node',
code: `console.log('Hello from Node.js')`,
timeout: 10000,
memoryMB: 128,
});
// Python
await sandbox.run({ language: 'python', code: 'print("Hello")' });
// JavaScript (Node.js)
await sandbox.run({ language: 'node', code: 'console.log("Hello")' });
// Bash
await sandbox.run({ language: 'bash', code: 'echo "Hello"' });
// Ruby
await sandbox.run({ language: 'ruby', code: 'puts "Hello"' });
// Go
await sandbox.run({ language: 'go', code: 'package main\nimport "fmt"\nfunc main() { fmt.Println("Hello") }' });
const result = await sandbox.runFile({
language: 'python',
filePath: '/path/to/script.py',
args: ['--input', 'data.csv'],
});
// Python packages
const result = await sandbox.run({
language: 'python',
code: `
import pandas as pd
print(pd.__version__)
`,
packages: ['pandas', 'numpy'],
});
// Node packages
const result = await sandbox.run({
language: 'node',
code: `
const _ = require('lodash');
console.log(_.VERSION);
`,
packages: ['lodash'],
});
const result = await sandbox.run({
language: 'python',
code: 'import time; time.sleep(100)',
// Limits
timeout: 5000, // 5 second timeout
memoryMB: 256, // 256 MB RAM
cpuShares: 512, // CPU shares (default 1024)
networkDisabled: true, // No network access
});
// Get status
const status = await sandbox.getStatus();
console.log(`Running containers: ${status.running}`);
console.log(`Total containers: ${status.total}`);
// List available images
const images = await sandbox.listImages();
for (const img of images) {
console.log(`${img.language}: ${img.image}`);
}
// Cleanup old containers
await sandbox.cleanup({
olderThan: '1h',
status: 'exited',
});
| Language | Image | Version |
|---|---|---|
| python | python:3.11-slim | 3.11 |
| node | node:20-slim | 20.x |
| bash | alpine:latest | Alpine |
| ruby | ruby:3.2-slim | 3.2 |
| go | golang:1.21-alpine | 1.21 |
| Resource | Default | Max |
|---|---|---|
| Timeout | 30s | 300s |
| Memory | 256 MB | 2048 MB |
| CPU | 512 shares | 2048 shares |
| Disk | 100 MB | 1 GB |
| Feature | Description |
|---|---|
| Isolation | Each run in separate container |
| No network | Network disabled by default |
| No volumes | No host filesystem access |
| Read-only | Filesystem is read-only |
| Resource caps | Memory and CPU limits |
| Timeout | Force kill after timeout |
const result = await sandbox.run({
language: 'python',
code: backtestCode,
packages: ['pandas', 'numpy', 'ta'],
timeout: 60000,
memoryMB: 512,
});
const result = await sandbox.run({
language: 'python',
code: `
import json
data = ${JSON.stringify(inputData)}
result = process(data)
print(json.dumps(result))
`,
});
const output = JSON.parse(result.stdout);
基于 SOC 职业分类