add in firecrawl search
This commit is contained in:
@@ -11,7 +11,6 @@ export class E2BProvider extends SandboxProvider {
|
||||
*/
|
||||
async reconnect(sandboxId: string): Promise<boolean> {
|
||||
try {
|
||||
console.log(`[E2BProvider] Attempting to reconnect to sandbox ${sandboxId}...`);
|
||||
|
||||
// Try to connect to existing sandbox
|
||||
// Note: E2B SDK doesn't directly support reconnection, but we can try to recreate
|
||||
@@ -27,11 +26,9 @@ export class E2BProvider extends SandboxProvider {
|
||||
|
||||
async createSandbox(): Promise<SandboxInfo> {
|
||||
try {
|
||||
console.log('[E2BProvider] Creating sandbox...');
|
||||
|
||||
// Kill existing sandbox if any
|
||||
if (this.sandbox) {
|
||||
console.log('[E2BProvider] Killing existing sandbox...');
|
||||
try {
|
||||
await this.sandbox.kill();
|
||||
} catch (e) {
|
||||
@@ -44,7 +41,6 @@ export class E2BProvider extends SandboxProvider {
|
||||
this.existingFiles.clear();
|
||||
|
||||
// Create base sandbox
|
||||
console.log(`[E2BProvider] Creating E2B sandbox with ${appConfig.e2b.timeoutMinutes} minute timeout...`);
|
||||
this.sandbox = await Sandbox.create({
|
||||
apiKey: this.config.e2b?.apiKey || process.env.E2B_API_KEY,
|
||||
timeoutMs: this.config.e2b?.timeoutMs || appConfig.e2b.timeoutMs
|
||||
@@ -53,8 +49,6 @@ export class E2BProvider extends SandboxProvider {
|
||||
const sandboxId = (this.sandbox as any).sandboxId || Date.now().toString();
|
||||
const host = (this.sandbox as any).getHost(appConfig.e2b.vitePort);
|
||||
|
||||
console.log(`[E2BProvider] Sandbox created: ${sandboxId}`);
|
||||
console.log(`[E2BProvider] Sandbox host: ${host}`);
|
||||
|
||||
this.sandboxInfo = {
|
||||
sandboxId,
|
||||
@@ -66,7 +60,6 @@ export class E2BProvider extends SandboxProvider {
|
||||
// Set extended timeout on the sandbox instance if method available
|
||||
if (typeof this.sandbox.setTimeout === 'function') {
|
||||
this.sandbox.setTimeout(appConfig.e2b.timeoutMs);
|
||||
console.log(`[E2BProvider] Set sandbox timeout to ${appConfig.e2b.timeoutMinutes} minutes`);
|
||||
}
|
||||
|
||||
return this.sandboxInfo;
|
||||
@@ -82,7 +75,6 @@ export class E2BProvider extends SandboxProvider {
|
||||
throw new Error('No active sandbox');
|
||||
}
|
||||
|
||||
console.log(`[E2BProvider] Executing: ${command}`);
|
||||
|
||||
const result = await this.sandbox.runCode(`
|
||||
import subprocess
|
||||
@@ -125,7 +117,6 @@ export class E2BProvider extends SandboxProvider {
|
||||
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(`
|
||||
@@ -140,7 +131,6 @@ export class E2BProvider extends SandboxProvider {
|
||||
f.write(${JSON.stringify(content)})
|
||||
print(f"✓ Written: ${fullPath}")
|
||||
`);
|
||||
console.log(`[E2BProvider] Written file using Python: ${fullPath}`);
|
||||
}
|
||||
|
||||
this.existingFiles.add(path);
|
||||
@@ -200,7 +190,6 @@ export class E2BProvider extends SandboxProvider {
|
||||
const packageList = packages.join(' ');
|
||||
const flags = appConfig.packages.useLegacyPeerDeps ? '--legacy-peer-deps' : '';
|
||||
|
||||
console.log(`[E2BProvider] Installing packages: ${packageList}`);
|
||||
|
||||
const result = await this.sandbox.runCode(`
|
||||
import subprocess
|
||||
@@ -244,7 +233,6 @@ export class E2BProvider extends SandboxProvider {
|
||||
throw new Error('No active sandbox');
|
||||
}
|
||||
|
||||
console.log('[E2BProvider] Setting up Vite React app...');
|
||||
|
||||
// Write all files in a single Python script
|
||||
const setupScript = `
|
||||
@@ -405,7 +393,6 @@ print('\\nAll files created successfully!')
|
||||
await this.sandbox.runCode(setupScript);
|
||||
|
||||
// Install dependencies
|
||||
console.log('[E2BProvider] Installing dependencies...');
|
||||
await this.sandbox.runCode(`
|
||||
import subprocess
|
||||
|
||||
@@ -424,7 +411,6 @@ else:
|
||||
`);
|
||||
|
||||
// Start Vite dev server
|
||||
console.log('[E2BProvider] Starting Vite dev server...');
|
||||
await this.sandbox.runCode(`
|
||||
import subprocess
|
||||
import os
|
||||
@@ -470,7 +456,6 @@ print('Waiting for server to be ready...')
|
||||
throw new Error('No active sandbox');
|
||||
}
|
||||
|
||||
console.log('[E2BProvider] Restarting Vite server...');
|
||||
|
||||
await this.sandbox.runCode(`
|
||||
import subprocess
|
||||
@@ -511,7 +496,6 @@ print(f'✓ Vite restarted with PID: {process.pid}')
|
||||
|
||||
async terminate(): Promise<void> {
|
||||
if (this.sandbox) {
|
||||
console.log('[E2BProvider] Terminating sandbox...');
|
||||
try {
|
||||
await this.sandbox.kill();
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user