Save current v2 sandbox implementation before styling refactor

- Modified sandbox API routes for v2 implementation
- Updated sandbox providers (E2B and Vercel)
- Added styling-reference directory with Firecrawl AI-ready website
- Preparing for styling system port from Firecrawl design

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Developers Digest
2025-09-04 10:21:28 -04:00
parent defd90a0ac
commit b96d048dbd
15 changed files with 340 additions and 172 deletions
+24 -10
View File
@@ -100,18 +100,28 @@ export class E2BProvider extends SandboxProvider {
const fullPath = path.startsWith('/') ? path : `/home/user/app/${path}`;
await this.sandbox.runCode(`
import os
// Use the E2B filesystem API to write the file
// Note: E2B SDK uses files.write() method
if ((this.sandbox as any).files && typeof (this.sandbox as any).files.write === 'function') {
// Use the files.write API if available
await (this.sandbox as any).files.write(fullPath, Buffer.from(content));
console.log(`[E2BProvider] Written file using files.write: ${fullPath}`);
} else {
// Fallback to Python code execution
await this.sandbox.runCode(`
import os
# Ensure directory exists
dir_path = os.path.dirname("${fullPath}")
os.makedirs(dir_path, exist_ok=True)
# Ensure directory exists
dir_path = os.path.dirname("${fullPath}")
os.makedirs(dir_path, exist_ok=True)
# Write file
with open("${fullPath}", 'w') as f:
f.write(${JSON.stringify(content)})
print(f"✓ Written: ${fullPath}")
`);
# Write file
with open("${fullPath}", 'w') as f:
f.write(${JSON.stringify(content)})
print(f"✓ Written: ${fullPath}")
`);
console.log(`[E2BProvider] Written file using Python: ${fullPath}`);
}
this.existingFiles.add(path);
}
@@ -475,6 +485,10 @@ print(f'✓ Vite restarted with PID: {process.pid}')
return this.sandboxInfo?.url || null;
}
getSandboxInfo(): SandboxInfo | null {
return this.sandboxInfo;
}
async terminate(): Promise<void> {
if (this.sandbox) {
console.log('[E2BProvider] Terminating sandbox...');
+4
View File
@@ -450,6 +450,10 @@ body {
return this.sandboxInfo?.url || null;
}
getSandboxInfo(): SandboxInfo | null {
return this.sandboxInfo;
}
async terminate(): Promise<void> {
if (this.sandbox) {
console.log('[VercelProvider] Terminating sandbox...');
+1
View File
@@ -48,6 +48,7 @@ export abstract class SandboxProvider {
abstract listFiles(directory?: string): Promise<string[]>;
abstract installPackages(packages: string[]): Promise<CommandResult>;
abstract getSandboxUrl(): string | null;
abstract getSandboxInfo(): SandboxInfo | null;
abstract terminate(): Promise<void>;
abstract isAlive(): boolean;