Skip to content

armgit / E2B

Public Imported from GitHub
0

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

Fix connection opts

Tomas Valenta29af728da847
diff --git a/packages/js-sdk/src/index.ts b/packages/js-sdk/src/index.ts
index 7d2cb01ce..824f1e202 100644
--- a/packages/js-sdk/src/index.ts
+++ b/packages/js-sdk/src/index.ts
@@ -36,6 +36,7 @@ export type {
Pty,
ProcessHandle,
} from './sandbox/process/processHandle'
+export type { SandboxApiOpts } from './sandbox/sandboxApi'
export type {
ProcessInfo,
diff --git a/packages/js-sdk/src/sandbox/process/processHandle.ts b/packages/js-sdk/src/sandbox/process/processHandle.ts
index af7812d82..aa29735a5 100644
--- a/packages/js-sdk/src/sandbox/process/processHandle.ts
+++ b/packages/js-sdk/src/sandbox/process/processHandle.ts
@@ -83,12 +83,12 @@ export class ProcessHandle implements Omit<ProcessResult, 'exitCode' | 'error'>,
return this._wait
}
- disconnect() {
+ async disconnect() {
this.handleDisconnect()
}
async kill() {
- this.handleDisconnect()
+ await this.disconnect()
await this.handleKill()
}
diff --git a/packages/js-sdk/src/sandbox/sandboxApi.ts b/packages/js-sdk/src/sandbox/sandboxApi.ts
index 5ab502c40..128a7b1d5 100644
--- a/packages/js-sdk/src/sandbox/sandboxApi.ts
+++ b/packages/js-sdk/src/sandbox/sandboxApi.ts
@@ -1,6 +1,7 @@
import { ApiClient, handleApiError } from '../api'
import { ConnectionConfig, ConnectionOpts } from '../connectionConfig'
+export interface SandboxApiOpts extends Partial<Pick<ConnectionOpts, 'apiKey' | 'debug' | 'domain' | 'requestTimeoutMs'>> { }
/**
* Information about a sandbox.
@@ -41,7 +42,7 @@ export class SandboxApi {
* @param sandboxID - Sandbox ID.
* @param opts - Connection options.
*/
- static async kill(sandboxID: string, opts?: ConnectionOpts): Promise<void> {
+ static async kill(sandboxID: string, opts?: SandboxApiOpts): Promise<void> {
const config = new ConnectionConfig(opts)
const client = new ApiClient(config)
@@ -59,7 +60,7 @@ export class SandboxApi {
}
}
- static async list(opts?: ConnectionOpts): Promise<SandboxInfo[]> {
+ static async list(opts?: SandboxApiOpts): Promise<SandboxInfo[]> {
const config = new ConnectionConfig(opts)
const client = new ApiClient(config)
@@ -79,7 +80,7 @@ export class SandboxApi {
})) ?? []
}
- static async setTimeout(sandboxID: string, timeoutMs: number, opts?: ConnectionOpts): Promise<void> {
+ static async setTimeout(sandboxID: string, timeoutMs: number, opts?: SandboxApiOpts): Promise<void> {
const config = new ConnectionConfig(opts)
const client = new ApiClient(config)
@@ -103,7 +104,7 @@ export class SandboxApi {
protected static async createSandbox(
template: string,
timeoutMs: number,
- opts?: ConnectionOpts & {
+ opts?: SandboxApiOpts & {
metadata?: Record<string, string>,
}): Promise<string> {
const config = new ConnectionConfig(opts)