Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Refactor
Jakub Novakf9169e588b6e
diff --git a/packages/js-sdk/src/sandbox/sandboxConnection.ts b/packages/js-sdk/src/sandbox/sandboxConnection.tsindex a0b223bef..7a3e156a0 100644--- a/packages/js-sdk/src/sandbox/sandboxConnection.ts+++ b/packages/js-sdk/src/sandbox/sandboxConnection.ts@@ -315,7 +315,14 @@ export class SandboxConnection {}}this.refresh(this.sandbox.instanceID)- const hostname = this.getHostname(this.opts.__debug_port || ENVD_PORT)+ await this.connectRpc()+ return this+ }+ return await withTimeout(open, opts?.timeout)()+ }++ private async connectRpc() {+ const hostname = this.getHostname(this.opts.__debug_port || ENVD_PORT)if (!hostname) {throw new Error('Cannot get sandbox\'s hostname')@@ -404,11 +411,7 @@ export class SandboxConnection {}await openingPromise- return this- }- return await withTimeout(open, opts?.timeout)()}-private handleNotification(data: IRpcNotification) {this.logger.debug?.('Handling notification:', data)this.subscribersdiff --git a/packages/js-sdk/testground/basic.cjs b/packages/js-sdk/testground/basic.cjsindex f7e28aa7b..bd9524751 100644--- a/packages/js-sdk/testground/basic.cjs+++ b/packages/js-sdk/testground/basic.cjs@@ -14,16 +14,14 @@ async function main() {)const sandboxID = sandbox.id- await sandbox.keepAlive(60)+ await sandbox.keepAlive(30)await sandbox.close()- await wait(20000)+ await wait(15000)const sandbox2 = await e2b.Sandbox.reconnect(sandboxID)const files = await sandbox2.filesystem.read('/code/hello.txt')- console.log(- files- )+ console.log(files)await sandbox2.close()}diff --git a/packages/python-sdk/e2b/templates/data_analysis.py b/packages/python-sdk/e2b/templates/data_analysis.pyindex 6b9c43f1a..421598cde 100644--- a/packages/python-sdk/e2b/templates/data_analysis.py+++ b/packages/python-sdk/e2b/templates/data_analysis.py@@ -1,11 +1,11 @@import loggingimport time-from typing import Optional, Callable, Any, Tuple, List, Union, Literal+from typing import Optional, Callable, Any, Tuple, List, Unionfrom e2b.sandbox.process import ProcessMessagefrom pydantic import BaseModel, PrivateAttr-from e2b import EnvVars, Sandbox, OpenPort+from e2b import EnvVars, Sandboxfrom e2b.constants import TIMEOUTlogger = logging.getLogger(__name__)diff --git a/packages/python-sdk/example.py b/packages/python-sdk/example.pyindex 84b699021..958744059 100644--- a/packages/python-sdk/example.py+++ b/packages/python-sdk/example.py@@ -18,7 +18,7 @@ def main():a = s.process.start("ls -la /home/user")s.filesystem.write("/home/user/test.txt", "Hello World!")a.wait()- s.keep_alive(60)+ s.keep_alive(30)s.close()sleep(20)