Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

chore(sdk): remove dead constant/attribute and de-duplicate Commands handle setup (#1907)

devin-ai-integration[bot]4975149be0e1
diff --git a/.changeset/tidy-sdk-dead-code.md b/.changeset/tidy-sdk-dead-code.md
new file mode 100644
index 000000000..f19a30f43
--- /dev/null
+++ b/.changeset/tidy-sdk-dead-code.md
@@ -0,0 +1,6 @@
+---
+'e2b': patch
+'@e2b/python-sdk': patch
+---
+
+Remove unused internal constants and attributes, and share the command handle setup between `Commands.run` and `Commands.connect`
diff --git a/packages/js-sdk/src/connectionConfig.ts b/packages/js-sdk/src/connectionConfig.ts
index a9ef7fdf8..366c30d07 100644
--- a/packages/js-sdk/src/connectionConfig.ts
+++ b/packages/js-sdk/src/connectionConfig.ts
@@ -8,7 +8,6 @@ const supportedDomains = ['e2b.app', 'e2b.dev', 'e2b.pro', 'e2b-staging.dev']
export const REQUEST_TIMEOUT_MS = 60_000 // 60 seconds
export const DEFAULT_RETRIES = 3
-export const DEFAULT_SANDBOX_TIMEOUT_MS = 300_000 // 300 seconds
export const KEEPALIVE_PING_INTERVAL_SEC = 50 // 50 seconds
export const KEEPALIVE_PING_HEADER = 'Keepalive-Ping-Interval'
diff --git a/packages/js-sdk/src/sandbox/commands/index.ts b/packages/js-sdk/src/sandbox/commands/index.ts
index 22c9a4028..a9905d084 100644
--- a/packages/js-sdk/src/sandbox/commands/index.ts
+++ b/packages/js-sdk/src/sandbox/commands/index.ts
@@ -21,8 +21,10 @@ import {
handleProcessStartEvent,
} from '../../envd/api'
import {
+ ConnectResponse,
Process as ProcessService,
Signal,
+ StartResponse,
} from '../../envd/process/process_pb'
import {
authenticationHeader,
@@ -350,26 +352,7 @@ export class Commands {
}
)
- try {
- const pid = await handleProcessStartEvent(events)
- clearStartTimeout()
-
- return new CommandHandle(
- pid,
- cleanup,
- () => this.kill(pid),
- events,
- opts?.onStdout,
- opts?.onStderr,
- undefined,
- (data, stdinOpts) => this.sendStdin(pid, data, stdinOpts),
- (stdinOpts) => this.closeStdin(pid, stdinOpts),
- this.checkHealth
- )
- } catch (err) {
- cleanup()
- throw await handleRpcErrorWithHealthCheck(err, this.checkHealth)
- }
+ return this.createHandle(events, clearStartTimeout, cleanup, opts)
}
/**
@@ -465,6 +448,15 @@ export class Commands {
}
)
+ return this.createHandle(events, clearStartTimeout, cleanup, opts)
+ }
+
+ private async createHandle(
+ events: AsyncIterable<StartResponse | ConnectResponse>,
+ clearStartTimeout: () => void,
+ cleanup: () => void,
+ opts?: Pick<CommandStartOpts, 'onStdout' | 'onStderr'>
+ ): Promise<CommandHandle> {
try {
const pid = await handleProcessStartEvent(events)
clearStartTimeout()
diff --git a/packages/python-sdk/e2b/sandbox_async/filesystem/filesystem.py b/packages/python-sdk/e2b/sandbox_async/filesystem/filesystem.py
index 725662fad..76ca51e32 100644
--- a/packages/python-sdk/e2b/sandbox_async/filesystem/filesystem.py
+++ b/packages/python-sdk/e2b/sandbox_async/filesystem/filesystem.py
@@ -91,7 +91,6 @@ class Filesystem:
connection_config: ConnectionConfig,
envd_api: httpx.AsyncClient,
) -> None:
- self._envd_api_url = envd_api_url
self._envd_version = envd_version
self._connection_config = connection_config
self._rpc = create_rpc_client(
diff --git a/packages/python-sdk/e2b/sandbox_sync/filesystem/filesystem.py b/packages/python-sdk/e2b/sandbox_sync/filesystem/filesystem.py
index d3a2ba646..752d4999a 100644
--- a/packages/python-sdk/e2b/sandbox_sync/filesystem/filesystem.py
+++ b/packages/python-sdk/e2b/sandbox_sync/filesystem/filesystem.py
@@ -85,7 +85,6 @@ class Filesystem:
connection_config: ConnectionConfig,
envd_api: httpx.Client,
) -> None:
- self._envd_api_url = envd_api_url
self._envd_version = envd_version
self._connection_config = connection_config
self._rpc = create_rpc_client(