Skip to content

armgit / E2B

Public Imported from GitHub
0

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

Remove leftout testing code

Tomas Valenta5e7b328c62a0
diff --git a/packages/js-sdk/example.mts b/packages/js-sdk/example.mts
index 66e319a83..1394d744a 100644
--- a/packages/js-sdk/example.mts
+++ b/packages/js-sdk/example.mts
@@ -1,21 +1,16 @@
-async function* iter() {
- try {
+import { config } from 'dotenv'
- for (let i = 0; i < 10; i++) {
- console.log(i)
- yield i
- }
- } finally {
- console.log('done')
- }
-}
+import { Sandbox } from './dist'
+config()
-async function main() {
- for await (const a of iter()) {
- console.log(a)
- throw new Error('test')
- }
-}
+const sandbox = await Sandbox.create({
+ logger: {
+ error: console.error,
+ warn: console.warn,
+ info: console.info,
+ },
+})
+console.log(sandbox.id)
-main()
\ No newline at end of file
+await sandbox.close()
diff --git a/packages/js-sdk/src/sandbox/filesystem/watchHandle.ts b/packages/js-sdk/src/sandbox/filesystem/watchHandle.ts
index e41a7267f..939341800 100644
--- a/packages/js-sdk/src/sandbox/filesystem/watchHandle.ts
+++ b/packages/js-sdk/src/sandbox/filesystem/watchHandle.ts
@@ -17,7 +17,7 @@ export class WatchHandle {
iterator?: boolean,
) {
if (!iterator) {
- this.wait(this.onEvent)
+ this.handleEvents()
}
}
@@ -37,9 +37,9 @@ export class WatchHandle {
}
}
- private async wait(onEvent?: (event: FilesystemEvent) => void | Promise<void>) {
+ private async handleEvents() {
for await (const event of this) {
- onEvent?.(event)
+ this.onEvent?.(event)
}
}
}
diff --git a/packages/js-sdk/src/sandbox/process/index.ts b/packages/js-sdk/src/sandbox/process/index.ts
index 535f90836..5186bc305 100644
--- a/packages/js-sdk/src/sandbox/process/index.ts
+++ b/packages/js-sdk/src/sandbox/process/index.ts
@@ -130,12 +130,6 @@ export class Process {
async run(cmd: string, opts?: ProcessStartOpts & { background?: boolean }): Promise<unknown> {
const proc = await this.start(cmd, opts)
- for await (const [stdout] of proc) {
- if (stdout) {
- opts?.onStdout?.(stdout)
- }
- }
-
return opts?.background
? proc
: proc.wait()