Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Add docs
Jakub Novak00b8e019a129
diff --git a/apps/docs/src/app/pricing/page.mdx b/apps/docs/src/app/pricing/page.mdxindex 0e3d56368..fbfbfdc02 100644--- a/apps/docs/src/app/pricing/page.mdx+++ b/apps/docs/src/app/pricing/page.mdx@@ -4,14 +4,14 @@- 2 vCPU {{ className: 'lead' }}- 512 MB RAM {{ className: 'lead' }}- 0.5 GB free disk storage {{ className: 'lead' }}-- 24 hours max session length {{ className: 'lead' }}+- 24 hours max sandbox session length {{ className: 'lead' }}- Up to 20 concurrently running sandboxes {{ className: 'lead' }}## Pro tier (paid)- 4 vCPU {{ className: 'lead' }}- 4 GB RAM {{ className: 'lead' }}- 5 GB free disk storage {{ className: 'lead' }}-- 24 hours max session length {{ className: 'lead' }}+- 24 hours max sandbox session length {{ className: 'lead' }}- Number of concurrently running sandboxes to suit your needs {{ className: 'lead' }}<Note>Please [reach out](/getting-help) if you're interested in the Pro tier.diff --git a/apps/docs/src/app/sandbox/api/reconnect/page.mdx b/apps/docs/src/app/sandbox/api/reconnect/page.mdxnew file mode 100644index 000000000..df42eaf0e--- /dev/null+++ b/apps/docs/src/app/sandbox/api/reconnect/page.mdx@@ -0,0 +1,21 @@+# Connect to running sandbox++Disconnect and reconnect to the same sandbox {{ className: 'lead' }}++## Description++The sandboxes are by default kept alive only when connected to them. When you disconnect from a sandbox, it will be destroyed.++If you want to keep the sandbox alive for longer time, you can extend the duration for which the sandbox is kept alive. This can be useful in for example in serverless environment or chat bot application.++The limit is 1 hour. If you need more, feel free to [reach out to us](/getting-help) with your use.++## Keep sandbox alive++The example bellow shows how to disconnect from a running sandbox and reconnect to it again.+You will have to call `keep_alive` method on the sandbox instance to keep it alive for specified time. You can then disconnect from the sandbox and reconnect to it from anywhere.++<CodeGroupAutoload+ path="reconnect/reconnect"+ isRunnable={false}+/>diff --git a/apps/docs/src/app/sandbox/overview/features.tsx b/apps/docs/src/app/sandbox/overview/features.tsxindex 0c040ac49..c1ca9cf94 100644--- a/apps/docs/src/app/sandbox/overview/features.tsx+++ b/apps/docs/src/app/sandbox/overview/features.tsx@@ -22,7 +22,7 @@ export const features = [</Link>, and more.</span>,- "Support for up to 24h long-running sessions",+ "Support for up to 24h long-running sandbox sessions",<span>Ability to <Link href="/sandbox/api/upload">upload files</Link> to the sandbox and <Link href="/sandbox/api/download">download files </Link>from the sandbox,</span>,diff --git a/apps/docs/src/app/sandbox/overview/page.mdx b/apps/docs/src/app/sandbox/overview/page.mdxindex a4d0ce705..e33ab195e 100644--- a/apps/docs/src/app/sandbox/overview/page.mdx+++ b/apps/docs/src/app/sandbox/overview/page.mdx@@ -26,7 +26,7 @@ With more features coming in the future:- LLM Access control to data, tools, and any internet requests- Statefull sandboxes- Resumable workflows (pause sandbox and load it later)-- Unlimited long-running sessions+- Unlimited long-running sandboxed## Comparison to other servicesWith LLMs, it's not safe to let the LLM run code and use tools in the same environment where your application is running.diff --git a/apps/docs/src/app/sandbox/resources/page.mdx b/apps/docs/src/app/sandbox/resources/page.mdxindex 1746da36b..7fa9c57f2 100644--- a/apps/docs/src/app/sandbox/resources/page.mdx+++ b/apps/docs/src/app/sandbox/resources/page.mdx@@ -4,14 +4,14 @@- 2 vCPU {{ className: 'lead' }}- 512 MB RAM {{ className: 'lead' }}- 0.5 GB free disk storage {{ className: 'lead' }}-- 24 hours max session length {{ className: 'lead' }}+- 24 hours max sandbox length {{ className: 'lead' }}- Up to 20 concurrently running sandboxes {{ className: 'lead' }}## Pro tier (paid)- 4 vCPU {{ className: 'lead' }}- 4 GB RAM {{ className: 'lead' }}- 5 GB free disk storage {{ className: 'lead' }}-- 24 hours max session length {{ className: 'lead' }}+- 24 hours max sandbox length {{ className: 'lead' }}- Number of concurrently running sandboxes to suit your needs {{ className: 'lead' }}<Note>Please [reach out](/getting-help) if you're interested in the Pro tier.diff --git a/apps/docs/src/code/js/reconnect/reconnect.js b/apps/docs/src/code/js/reconnect/reconnect.jsnew file mode 100644index 000000000..5c0ef3169--- /dev/null+++ b/apps/docs/src/code/js/reconnect/reconnect.js@@ -0,0 +1,32 @@+import { Sandbox } from '@e2b/sdk'++async function wait(ms) {+ return new Promise(resolve => setTimeout(resolve, ms))+}++const sandbox = await Sandbox.create({id: 'base'})++// Do something in the sandbox+await sandbox.filesystem.write('hello.txt', 'Hello World!')++// Get the sandbox ID, we'll need it later+const sandboxID = sandbox.id++// Keep alive the sandbox for 1 hour+await sandbox.keepAlive(60 * 60 * 1000) // 1 hour $HighlightLine++// Close the sandbox+await sandbox.close()++// Do something else...+await wait(60 * 1000)++// Reconnect to the sandbox+const sandbox2 = await Sandbox.reconnect(sandboxID) // $HighlightLine++// Continue in using the sandbox+const content = await sandbox2.filesystem.read('hello.txt')+console.log(content)++// Close the sandbox+await sandbox2.close()diff --git a/apps/docs/src/code/python/reconnect/reconnect.py b/apps/docs/src/code/python/reconnect/reconnect.pynew file mode 100644index 000000000..6c6550f51--- /dev/null+++ b/apps/docs/src/code/python/reconnect/reconnect.py@@ -0,0 +1,30 @@+import time+from e2b import Sandbox+++sandbox = Sandbox('base')++# Do something in the sandbox+sandbox.filesystem.write('hello.txt', 'Hello World!')++# Get the sandbox ID, we'll need it later+sandboxID = sandbox.id++# Keep alive the sandbox for 1 hour+sandbox.keep_alive(60 * 60) # $HighlightLine++# Close the sandbox+sandbox.close()++# Do something else...+time.sleep(60)++# Reconnect to the sandbox+sandbox2 = Sandbox.reconnect(sandboxID) # $HighlightLine++# Continue in using the sandbox+content = sandbox2.filesystem.read('hello.txt')+print(content)++# Close the sandbox+sandbox2.close()diff --git a/apps/docs/src/components/Navigation/routes.tsx b/apps/docs/src/components/Navigation/routes.tsxindex 323563107..27f83bcd0 100644--- a/apps/docs/src/components/Navigation/routes.tsx+++ b/apps/docs/src/components/Navigation/routes.tsx@@ -16,7 +16,7 @@ import {Timer,Variable,PencilRuler,- File, TerminalSquare,+ File, TerminalSquare, RefreshCw,} from 'lucide-react'export const routes = [@@ -245,6 +245,16 @@ export const routes = [title: 'Timeouts',href: '/sandbox/api/timeouts',},+ {+ icon: (+ <RefreshCw+ strokeWidth={1}+ size={20}+ />+ ),+ title: 'Connect to running sandbox',+ href: '/sandbox/api/reconnect',+ },],},{diff --git a/packages/js-sdk/src/sandbox/sandboxConnection.ts b/packages/js-sdk/src/sandbox/sandboxConnection.tsindex 0993d38cf..903b10776 100644--- a/packages/js-sdk/src/sandbox/sandboxConnection.ts+++ b/packages/js-sdk/src/sandbox/sandboxConnection.ts@@ -106,7 +106,15 @@ export class SandboxConnection {}+ /**+ * Keep the sandbox alive for the specified duration.+ *+ * `keepAlive` method requires `this` context - you may need to bind it.+ * @param duration Duration in milliseconds+ * @returns Promise that resolves when the sandbox is kept alive+ */public async keepAlive(duration: number) {+ duration = duration / 1000if (!this.sandbox) {throw new Error('Cannot keep alive - sandbox is not initialized')}diff --git a/packages/python-sdk/example.py b/packages/python-sdk/example.pyindex 958744059..20eb3cf8b 100644--- a/packages/python-sdk/example.py+++ b/packages/python-sdk/example.py@@ -4,7 +4,7 @@ from time import sleepfrom dotenv import load_dotenv-from e2b import DataAnalysis, Sandbox+from e2b import Sandboxload_dotenv()id = "Python3"