Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Change .finished to .wait() in docs
Jakub Novakbc837453aaaf
diff --git a/apps/docs/package.json b/apps/docs/package.jsonindex 7a40c7b4f..4c28efbda 100644--- a/apps/docs/package.json+++ b/apps/docs/package.json@@ -12,7 +12,7 @@"browserslist": "defaults, not ie <= 11","dependencies": {"@algolia/autocomplete-core": "^1.7.3",- "@e2b/sdk": "0.5.2",+ "@e2b/sdk": "^0.6.2","@headlessui/react": "^1.7.15","@headlessui/tailwindcss": "^0.2.0","@mdx-js/loader": "^2.1.5",diff --git a/apps/docs/src/code/js/agents/clone_repo.js b/apps/docs/src/code/js/agents/clone_repo.jsindex c7da09e15..d04b61b51 100644--- a/apps/docs/src/code/js/agents/clone_repo.js+++ b/apps/docs/src/code/js/agents/clone_repo.js@@ -14,7 +14,7 @@ let proc = await session.process.start({ // $HighlightLineonStdout: data => console.log(data.line), // $HighlightLine}) // $HighlightLine// 3. Wait for the process to finish-await proc.finished+await proc.wait()// Optional: 4. List the content of cloned repoconst content = await session.filesystem.list('/code/open-react-template')@@ -28,6 +28,6 @@ proc = await session.process.start({onStdout: data => console.log(data.line),onStderr: data => console.log(data.line),})-await proc.finished+await proc.wait()await session.close()diff --git a/apps/docs/src/code/js/agents/code_exec.js b/apps/docs/src/code/js/agents/code_exec.jsindex 320c3af55..70faadb9b 100644--- a/apps/docs/src/code/js/agents/code_exec.js+++ b/apps/docs/src/code/js/agents/code_exec.js@@ -28,7 +28,7 @@ const proc = await session.process.start({ // $HighlightLine}) // $HighlightLine// 4. Wait for the process to finish-await proc.finished+await proc.wait()// 5. Or you can access output after the process has finishedconst output = proc.outputdiff --git a/apps/docs/src/code/js/agents/install_deps_npm.js b/apps/docs/src/code/js/agents/install_deps_npm.jsindex 504baa31b..bb8f2932d 100644--- a/apps/docs/src/code/js/agents/install_deps_npm.js+++ b/apps/docs/src/code/js/agents/install_deps_npm.js@@ -17,7 +17,7 @@ const proc = await session.process.start({onStderr: (data) => console.log('[WARN | ERROR] ', data.line),})// Wait for the process to finish-await proc.finished+await proc.wait()// We can now use lodash in our codeconst code = `@@ -33,6 +33,6 @@ const codeRun = await session.process.start({onStdout: (data) => console.log('[INFO] ', data.line),onStderr: (data) => console.log('[WARN | ERROR] ', data.line),})-await codeRun.finished+await codeRun.wait()await session.close()diff --git a/apps/docs/src/code/js/agents/start_process.js b/apps/docs/src/code/js/agents/start_process.jsindex d443ba1c1..367dd3136 100644--- a/apps/docs/src/code/js/agents/start_process.js+++ b/apps/docs/src/code/js/agents/start_process.js@@ -17,7 +17,7 @@ let proc = await session.process.start({ // $HighlightLine}) // $HighlightLine// 3. Wait for the process to finish-await proc.finished+await proc.wait()// 4. Or you can access output after the process has finishedconst output = proc.outputdiff --git a/apps/docs/src/code/js/basics/process_exit.js b/apps/docs/src/code/js/basics/process_exit.jsindex 29148f182..d35988dd8 100644--- a/apps/docs/src/code/js/basics/process_exit.js+++ b/apps/docs/src/code/js/basics/process_exit.js@@ -7,14 +7,14 @@ const session = await Session.create({})const proc = await session.process.start({ cmd: 'echo "Hello World!"' })-await proc.finished+await proc.wait()// output: [session] process endedconst procWithCustomHandler = await session.process.start({cmd: 'echo "Hello World!"',onExit: () => console.log('[process]', 'process ended'), // $HighlightLine})-await procWithCustomHandler.finished+await procWithCustomHandler.wait()// output: [process] process endedawait session.close()diff --git a/apps/docs/src/code/js/basics/process_start.js b/apps/docs/src/code/js/basics/process_start.jsindex 5bd6db6ab..72444847e 100644--- a/apps/docs/src/code/js/basics/process_start.js+++ b/apps/docs/src/code/js/basics/process_start.js@@ -8,7 +8,7 @@ const session = await Session.create({const npmInit = await session.process.start({ // $HighlightLinecmd: 'npm init -y'})-await npmInit.finished+await npmInit.wait()console.log(npmInit.output.stdout)diff --git a/apps/docs/src/code/js/basics/process_stream_stderr.js b/apps/docs/src/code/js/basics/process_stream_stderr.jsindex 0ceb6edfb..e416369e6 100644--- a/apps/docs/src/code/js/basics/process_stream_stderr.js+++ b/apps/docs/src/code/js/basics/process_stream_stderr.js@@ -10,14 +10,14 @@ const golangVersion = await session.process.start({cmd: 'go version',onStderr: output => console.log('session', output.line), // $HighlightLine})-await golangVersion.finished+await golangVersion.wait()// output: [session] /bin/bash: line 1: go: command not foundconst procWithCustomHandler = await session.process.start({cmd: 'go version',onStderr: data => console.log('process', data.line), // $HighlightLine})-await procWithCustomHandler.finished+await procWithCustomHandler.wait()// output: process /bin/bash: line 1: go: command not foundawait session.close()diff --git a/apps/docs/src/code/js/basics/process_stream_stdout.js b/apps/docs/src/code/js/basics/process_stream_stdout.jsindex 5b1a225a6..9cb8cdda6 100644--- a/apps/docs/src/code/js/basics/process_stream_stdout.js+++ b/apps/docs/src/code/js/basics/process_stream_stdout.js@@ -9,14 +9,14 @@ const session = await Session.create({const proc = await session.process.start({cmd: 'echo "Hello World!"',})-await proc.finished+await proc.wait()// output: session Hello World!const procWithCustomHandler = await session.process.start({cmd: 'echo "Hello World!"',onStdout: data => console.log('process', data.line), // $HighlightLine})-await procWithCustomHandler.finished+await procWithCustomHandler.wait()// output: process Hello World!await session.close()diff --git a/apps/docs/src/code/js/basics/set_env_vars.js b/apps/docs/src/code/js/basics/set_env_vars.jsindex 9b4398a6c..8399be298 100644--- a/apps/docs/src/code/js/basics/set_env_vars.js+++ b/apps/docs/src/code/js/basics/set_env_vars.js@@ -12,7 +12,7 @@ const proc = await session.process.start({cmd: 'echo $FOO $BAR!',envVars: { BAR: 'World' }, // $HighlightLine})-await proc.finished+await proc.wait()console.log(proc.output.stdout)// output: Hello World!diff --git a/apps/docs/src/code/js/code_exec/process.js b/apps/docs/src/code/js/code_exec/process.jsindex b409142cd..944f4420c 100644--- a/apps/docs/src/code/js/code_exec/process.js+++ b/apps/docs/src/code/js/code_exec/process.js@@ -22,7 +22,7 @@ const proc = await session.process.start({ // $HighlightLine}) // $HighlightLine// 4. Wait for the process to finish-await proc.finished+await proc.wait()// 5. Or you can access output after the process has finishedconst output = proc.outputdiff --git a/apps/docs/src/code/js/cwd/filesystem.js b/apps/docs/src/code/js/cwd/filesystem.jsindex 51f361e66..685c16f47 100644--- a/apps/docs/src/code/js/cwd/filesystem.js+++ b/apps/docs/src/code/js/cwd/filesystem.js@@ -8,14 +8,14 @@ const session = await Session.create({await session.filesystem.write('hello.txt', 'Welcome to E2B!') // $HighlightLineconst proc = await session.process.start({ cmd: 'cat /home/user/code/hello.txt' })-await proc.finished+await proc.wait()const out = proc.output.stdoutconsole.log(out)// output: "Welcome to E2B!"await session.filesystem.write('../hello.txt', 'We hope you have a great day!') // $HighlightLineconst proc2 = await session.process.start({ cmd: 'cat /home/user/hello.txt' })-await proc2.finished+await proc2.wait()console.log(proc2.output.stdout)// output: "We hope you have a great day!"diff --git a/apps/docs/src/code/js/cwd/process.js b/apps/docs/src/code/js/cwd/process.jsindex ec21d6bcc..e284ef7bd 100644--- a/apps/docs/src/code/js/cwd/process.js+++ b/apps/docs/src/code/js/cwd/process.js@@ -7,12 +7,12 @@ const session = await Session.create({})const sessionCwd = await session.process.start({ cmd: 'pwd' }) // $HighlightLine-await sessionCwd.finished+await sessionCwd.wait()console.log(sessionCwd.output.stdout)// output: /codeconst processCwd = await session.process.start({ cmd: 'pwd', cwd: '/home' }) // $HighlightLine-await processCwd.finished+await processCwd.wait()console.log(processCwd.output.stdout)// output: /homediff --git a/apps/docs/src/code/js/processes/background_processes.js b/apps/docs/src/code/js/processes/background_processes.jsindex f17a8ec34..7b09d7093 100644--- a/apps/docs/src/code/js/processes/background_processes.js+++ b/apps/docs/src/code/js/processes/background_processes.js@@ -11,7 +11,8 @@ function sleep(ms) {// Start a server process in the background// We are not calling `await backgroundServer` - that would wait for the process to finish running-const backgroundServer = await session.process.start({ // $HighlightLine+const backgroundServer = await session.process.start({+ // $HighlightLinecmd: 'python3 -m http.server 8000', // $HighlightLineonStdout: output => console.log(output), // $HighlightLine}) // $HighlightLine@@ -23,12 +24,12 @@ await sleep(1000)const serverRequest = await session.process.start({ cmd: 'curl localhost:8000' })// Wait for the server request to finish running-const requestOutput = await serverRequest.finished+const requestOutput = await serverRequest.wait()// Stop the background process (it would otherwise run indefinitely)await backgroundServer.kill() // $HighlightLine// Access the server output after the server process is killed-const serverOutput = backgroundServer.output // $HighlightLine+const serverOutput = backgroundServer.output // $HighlightLineawait session.close()diff --git a/apps/docs/src/code/js/timeout/timeout_process.js b/apps/docs/src/code/js/timeout/timeout_process.jsindex 2a71ec6c9..efb77bd45 100644--- a/apps/docs/src/code/js/timeout/timeout_process.js+++ b/apps/docs/src/code/js/timeout/timeout_process.js@@ -10,6 +10,6 @@ const npmInit = await session.process.start({cmd: 'npm init -y',timeout: 3000, // $HighlightLine})-await npmInit.finished+await npmInit.wait()await session.close()diff --git a/apps/docs/src/code/python/processes/background_processes.py b/apps/docs/src/code/python/processes/background_processes.pyindex 364230899..1d8af11af 100644--- a/apps/docs/src/code/python/processes/background_processes.py+++ b/apps/docs/src/code/python/processes/background_processes.py@@ -25,7 +25,7 @@ async def main():server_request = await session.process.start("curl localhost:8000")# Wait for the server request to finish running- request_output = await server_request.finished+ request_output = await server_request# Stop the background process (it would otherwise run indefinitely)await background_server.kill() # $HighlightLinediff --git a/apps/docs/src/utils/useSessions.tsx b/apps/docs/src/utils/useSessions.tsxindex 71456c986..54eb88f2e 100644--- a/apps/docs/src/utils/useSessions.tsx+++ b/apps/docs/src/utils/useSessions.tsx@@ -68,9 +68,9 @@ export const useSessionsStore = create<SessionsStore>((set, get) => ({onStderr: stdHandler,cwd: '/code',})- await proc.finished // await prep process to finish+ await proc.wait() // await prep process to finishlog(`${lang} session created and started`)- // set session to store so it can be used instead of creating a new one+ // set session to store, so it can be used instead of creating a new oneset(state => ({sessions: {...state.sessions,diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex d3deff50c..1a14519a3 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -169,9 +169,6 @@ importers:'@algolia/autocomplete-core':specifier: ^1.7.3- '@e2b/sdk':- specifier: 0.5.2- version: 0.5.2'@headlessui/react':specifier: ^1.7.15version: 1.7.17([email protected])([email protected])@@ -341,7 +338,7 @@ importers:devDependencies:'@types/node':specifier: latest- version: 20.8.0+ version: 20.8.2'@types/react':specifier: latestversion: 18.2.24@@ -989,20 +986,6 @@ packages:- utf-8-validatedev: false- /@e2b/[email protected]:- resolution: {integrity: sha512-u3JzNE1ImSooPbrelS8bE5eldgLh5DD8vZknkrc25m84qeBALz++ZE6H1u7XX893GTfX9ZsyAyZEzkyRzrtg7A==}- dependencies:- bufferutil: 4.0.7- cross-fetch: 3.1.8- normalize-path: 3.0.0- openapi-typescript-fetch: 1.1.3- platform: 1.3.6- rpc-websocket-client: 1.1.4([email protected])([email protected])- utf-8-validate: 5.0.10- transitivePeerDependencies:- - encoding- dev: false-/@emotion/[email protected]:resolution: {integrity: sha512-u5WtneEAr5IDG2Wv65yhunPSMLIpuKsbuOktRojfrEiEvRyC85LgPMZI63cr7NUqT8ZIGdSVg8ZKGxIug4lXcA==}requiresBuild: true@@ -3231,8 +3214,9 @@ packages:/@types/[email protected]:resolution: {integrity: sha512-HksnYH4Ljr4VQgEy2lTStbCKv/P590tmPe5HqOnv9Gprffgv5WXAY+Y5Gqniu0GGqeTCUdBnzC3QSrzPkBkAMA==}- /@types/[email protected]:- resolution: {integrity: sha512-LzcWltT83s1bthcvjBmiBvGJiiUe84NWRHkw+ZV6Fr41z2FbIzvc815dk2nQ3RAKMuN2fkenM/z3Xv2QzEpYxQ==}+ /@types/[email protected]:+ resolution: {integrity: sha512-Vvycsc9FQdwhxE3y3DzeIxuEJbWGDsnrxvMADzTDF/lcdR9/K+AQIeAghTQsHtotg/q0j3WEOYS/jQgSdWue3w==}+ dev: true/@types/[email protected]:resolution: {integrity: sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==}@@ -3245,7 +3229,7 @@ packages:/@types/[email protected]:resolution: {integrity: sha512-GCL7NIxhUzJ1M5bp68T8DtDVTbQdw93MPIIII+YASs3icSozMEG9ZjX7pp7ldRJrVgrRtJBwy+/g+aBzCIttlg==}dependencies:- '@types/node': 20.8.0+ '@types/node': 18.17.18dev: true/@types/[email protected]:@@ -3267,7 +3251,7 @@ packages:/@types/[email protected]:resolution: {integrity: sha512-bAIvO5lN/U8sPGvs1Xm61rlRHHaq5rp5N3kp9C+NJ/Q41P8iqjkXSu0+/qu8POsjH9pNWb0OYabFez7taP7omw==}dependencies:- '@types/react': 18.2.24+ '@types/react': 18.2.28dev: true/@types/[email protected]:@@ -3299,10 +3283,18 @@ packages:csstype: 3.1.2dev: true+ /@types/[email protected]:+ resolution: {integrity: sha512-ad4aa/RaaJS3hyGz0BGegdnSRXQBkd1CCYDCdNjBPg90UUpLgo+WlJqb9fMYUxtehmzF3PJaTWqRZjko6BRzBg==}+ dependencies:+ '@types/prop-types': 15.7.6+ '@types/scheduler': 0.16.3+ csstype: 3.1.2+ dev: true+/@types/[email protected]:resolution: {integrity: sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw==}dependencies:- '@types/node': 20.8.0+ '@types/node': 18.17.18dev: true/@types/[email protected]:@@ -3320,7 +3312,7 @@ packages:/@types/[email protected]:resolution: {integrity: sha512-XuZRAvdo7FbDfgQCNkc8NOdSae5XtG+of2mTSgJ85G4OG0miN4E8BTGT+JBTLO87RQ7iCwsIDCqCsHnf2IaSXA==}dependencies:- '@types/node': 20.8.0+ '@types/node': 18.17.18'@types/tar-stream': 2.2.3dev: false@@ -3350,7 +3342,7 @@ packages:/@types/[email protected]:resolution: {integrity: sha512-O3hA/hKp1itPhn4RHBEFt9fos9j1jmebB5UV8iuq0Trr0qoIj+1DywNGLRGWQ+wxZagld4DGZPSVYi0pDniFMQ==}dependencies:- '@types/node': 20.8.0+ '@types/node': 18.17.18dev: true/@types/[email protected]:@@ -11287,7 +11279,7 @@ packages:vfile-message: 3.1.4dev: false- /[email protected](@types/[email protected]):+ /[email protected](@types/[email protected]):resolution: {integrity: sha512-ho8HtiLc+nsmbwZMw8SlghESEE3KxJNp04F/jPUCLVvaURwt0d+r9LxEqCX5hvrrOQ0GSyxbYr5ZfRYhQ0yVKQ==}engines: {node: '>=v14.18.0'}hasBin: true@@ -11297,7 +11289,7 @@ packages:mlly: 1.4.2pathe: 1.1.1picocolors: 1.0.0- vite: 4.4.9(@types/[email protected])+ vite: 4.4.9(@types/[email protected])transitivePeerDependencies:- '@types/node'- less@@ -11309,7 +11301,7 @@ packages:- terserdev: true- /[email protected](@types/[email protected]):+ /[email protected](@types/[email protected]):resolution: {integrity: sha512-2mbUn2LlUmNASWwSCNSJ/EG2HuSRTnVNaydp6vMCm5VIqJsjMfbIWtbH2kDuwUVW5mMUKKZvGPX/rqeqVvv1XA==}engines: {node: ^14.18.0 || >=16.0.0}hasBin: true@@ -11337,7 +11329,7 @@ packages:terser:optional: truedependencies:- '@types/node': 20.8.0+ '@types/node': 18.17.18esbuild: 0.18.20postcss: 8.4.30rollup: 3.29.2@@ -11378,7 +11370,7 @@ packages:dependencies:'@types/chai': 4.3.6'@types/chai-subset': 1.3.3- '@types/node': 20.8.0+ '@types/node': 18.17.18'@vitest/expect': 0.34.4'@vitest/runner': 0.34.4'@vitest/snapshot': 0.34.4@@ -11397,8 +11389,8 @@ packages:strip-literal: 1.3.0tinybench: 2.5.1tinypool: 0.7.0- vite: 4.4.9(@types/[email protected])- vite-node: 0.34.4(@types/[email protected])+ vite: 4.4.9(@types/[email protected])+ vite-node: 0.34.4(@types/[email protected])why-is-node-running: 2.2.2transitivePeerDependencies:- less