Spaces:
Paused
Paused
Download lib/sandbox/types.ts from Leon4gr45/paper2code-cli: direct link, hf CLI and curl.
- Browser
- Download file 1.93 kB
-
https://huggingface.co/spaces/Leon4gr45/paper2code-cli/resolve/main/lib/sandbox/types.ts
- Command line
-
hf download hf://spaces/Leon4gr45/paper2code-cli/lib/sandbox/types.ts
-
curl -L -o types.ts https://huggingface.co/spaces/Leon4gr45/paper2code-cli/resolve/main/lib/sandbox/types.ts
1.93 kB
| 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 setupPythonEnv(): Promise<void> { | |
| // Default implementation for setting up a Python environment | |
| throw new Error('setupPythonEnv not implemented for this provider'); | |
| } | |
| async restartViteServer(): Promise<void> { | |
| // Default implementation for restarting Vite | |
| throw new Error('restartViteServer not implemented for this provider'); | |
| } | |
| } |