Skip to content

armgit / E2B

Public Imported from GitHub
0

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

Deprecate wait in JS SDK; Add .wait() in JS SDK

Tomas Valenta2d7fef062af2
diff --git a/packages/js-sdk/src/session/process.ts b/packages/js-sdk/src/session/process.ts
index ee185f946..d04af04cb 100644
--- a/packages/js-sdk/src/session/process.ts
+++ b/packages/js-sdk/src/session/process.ts
@@ -93,13 +93,20 @@ export class ProcessOutput {
* A process running in the environment.
*/
export class Process {
+ /**
+ * @deprecated use .wait() instead
+ */
+ readonly finished: Promise<ProcessOutput>
+
constructor(
readonly processID: string,
private readonly session: SessionConnection,
private readonly triggerExit: () => void,
- readonly finished: Promise<ProcessOutput>,
+ finished: Promise<ProcessOutput>,
readonly output: ProcessOutput,
- ) {}
+ ) {
+ this.finished = finished
+ }
/**
* Kills the process.
@@ -113,6 +120,13 @@ export class Process {
}
}
+ /**
+ * Waits for the process to finish.
+ */
+ async wait(): Promise<ProcessOutput> {
+ return this.finished
+ }
+
/**
* Sends data to the process stdin.
*
diff --git a/packages/js-sdk/src/session/terminal.ts b/packages/js-sdk/src/session/terminal.ts
index 07f5eed92..935a3bcb5 100644
--- a/packages/js-sdk/src/session/terminal.ts
+++ b/packages/js-sdk/src/session/terminal.ts
@@ -17,15 +17,23 @@ export class TerminalOutput {
/**
* A terminal session running in the environment.
+ *
*/
export class Terminal {
+ /**
+ * @deprecated use .wait() instead
+ */
+ readonly finished: Promise<TerminalOutput>
+
constructor(
readonly terminalID: string,
private readonly session: SessionConnection,
private readonly triggerExit: () => void,
- readonly finished: Promise<TerminalOutput>,
+ finished: Promise<TerminalOutput>,
readonly output: TerminalOutput,
- ) {}
+ ) {
+ this.finished = finished
+ }
get data() {
return this.output.data
@@ -44,6 +52,13 @@ export class Terminal {
}
}
+ /**
+ * Waits for the terminal to finish.
+ */
+ async wait(): Promise<TerminalOutput> {
+ return this.finished
+ }
+
/**
* Sends data to the terminal standard input.
*