Files
Developers Digest b96d048dbd 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>
2025-09-04 10:21:28 -04:00

65 lines
1.7 KiB
TypeScript

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<SandboxInfo>;
abstract runCommand(command: string): Promise<CommandResult>;
abstract writeFile(path: string, content: string): Promise<void>;
abstract readFile(path: string): Promise<string>;
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;
// Optional methods that providers can override
async setupViteApp(): Promise<void> {
// Default implementation for setting up a Vite React app
throw new Error('setupViteApp not implemented for this provider');
}
async restartViteServer(): Promise<void> {
// Default implementation for restarting Vite
throw new Error('restartViteServer not implemented for this provider');
}
}