export interface SandboxFile { path: string; content: string; lastModified?: number; } export interface SandboxInfo { sandboxId: string; url: string; provider: 'e2b' | 'vercel'; createdAt: Date; } export interface CommandResult { stdout: string; stderr: string; exitCode: number; success: boolean; } export interface SandboxProviderConfig { e2b?: { apiKey: string; timeoutMs?: number; template?: string; }; vercel?: { teamId?: string; projectId?: string; token?: string; authMethod?: 'oidc' | 'pat'; }; } export abstract class SandboxProvider { protected config: SandboxProviderConfig; protected sandbox: any; protected sandboxInfo: SandboxInfo | null = null; constructor(config: SandboxProviderConfig) { this.config = config; } abstract createSandbox(): Promise; abstract runCommand(command: string): Promise; abstract writeFile(path: string, content: string): Promise; abstract readFile(path: string): Promise; abstract listFiles(directory?: string): Promise; abstract installPackages(packages: string[]): Promise; abstract getSandboxUrl(): string | null; abstract getSandboxInfo(): SandboxInfo | null; abstract terminate(): Promise; abstract isAlive(): boolean; // Optional methods that providers can override async setupViteApp(): Promise { // Default implementation for setting up a Vite React app throw new Error('setupViteApp not implemented for this provider'); } async setupPythonEnv(): Promise { // Default implementation for setting up a Python environment throw new Error('setupPythonEnv not implemented for this provider'); } async restartViteServer(): Promise { // Default implementation for restarting Vite throw new Error('restartViteServer not implemented for this provider'); } }