Revert "Vercel sandbox support"

This commit is contained in:
Developers Digest
2025-09-02 18:27:04 -04:00
committed by GitHub
parent d7ae41ba9d
commit 8996e717df
22 changed files with 1662 additions and 1065 deletions
+20 -21
View File
@@ -1,4 +1,5 @@
import { NextRequest, NextResponse } from 'next/server';
import { Sandbox } from '@e2b/code-interpreter';
// Get active sandbox from global state (in production, use a proper state management solution)
declare global {
@@ -25,32 +26,30 @@ export async function POST(request: NextRequest) {
console.log(`[run-command] Executing: ${command}`);
// Parse command and arguments
const commandParts = command.trim().split(/\s+/);
const cmd = commandParts[0];
const args = commandParts.slice(1);
const result = await global.activeSandbox.runCode(`
import subprocess
import os
os.chdir('/home/user/app')
result = subprocess.run(${JSON.stringify(command.split(' '))},
capture_output=True,
text=True,
shell=False)
print("STDOUT:")
print(result.stdout)
if result.stderr:
print("\\nSTDERR:")
print(result.stderr)
print(f"\\nReturn code: {result.returncode}")
`);
// Execute command using Vercel Sandbox
const result = await global.activeSandbox.runCommand({
cmd,
args
});
// Get output streams
const stdout = await result.stdout();
const stderr = await result.stderr();
const output = [
stdout ? `STDOUT:\n${stdout}` : '',
stderr ? `\nSTDERR:\n${stderr}` : '',
`\nExit code: ${result.exitCode}`
].filter(Boolean).join('');
const output = result.logs.stdout.join('\n');
return NextResponse.json({
success: true,
output,
exitCode: result.exitCode,
message: result.exitCode === 0 ? 'Command executed successfully' : 'Command completed with non-zero exit code'
message: 'Command executed successfully'
});
} catch (error) {