Skip to content

armgit / E2B

Public Imported from GitHub
0

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

Update docs

Vasek Mlejnsky5a81dab0a727
diff --git a/apps/web/src/app/(docs)/docs/sandbox/internet-access/page.mdx b/apps/web/src/app/(docs)/docs/sandbox/internet-access/page.mdx
new file mode 100644
index 000000000..40393dd82
--- /dev/null
+++ b/apps/web/src/app/(docs)/docs/sandbox/internet-access/page.mdx
@@ -0,0 +1,132 @@
+# Internet access
+
+Every sandbox has access to the internet and can be reached by a public URL.
+
+
+## Sandbox public URL
+Every sandbox has a public URL that can be used to access running services inside the sandbox.
+
+<CodeGroup>
+```js
+import { Sandbox } from '@e2b/code-interpeter'
+
+const sandbox = await Sandbox.create()
+
+// You need to always pass a port number to get the host
+const host = sandbox.getHost(3000) // $HighlightLine
+console.log(`https://${host}`)
+```
+```python
+from e2b_code_interpreter import Sandbox
+
+sandbox = Sandbox()
+
+# You need to always pass a port number to get the host
+host = sandbox.get_host(3000) # $HighlightLine
+print(f'https://{host}')
+```
+</CodeGroup>
+
+The code above will print something like this:
+
+<CodeGroup>
+```bash {{ language: 'js' }}
+http://3000-i62mff4ahtrdfdkyn2esc-b0b684e9.e2b.dev
+```
+```bash {{ language: 'python' }}
+http://3000-i62mff4ahtrdfdkyn2esc-b0b684e9.e2b.dev
+```
+</CodeGroup>
+
+The first leftmost part of the host is the port number we passed to the method.
+
+## Connecting to a server running inside the sandbox
+You can start a server inside the sandbox and connect to it using the approach above.
+
+In this example we will start a simple HTTP server that listens on port 3000 and responds with the content of the directory where the server is started.
+
+<CodeGroup>
+```js
+import { Sandbox } from '@e2b/code-interpeter'
+
+const sandbox = await Sandbox.create()
+
+// Start a simple HTTP server inside the sandbox.
+const process = await sandbox.commands.run('python -m http.server 3000', { background: true })
+const host = sandbox.getHost(3000)
+const url = `https://${host}`
+console.log('Server started at:', url)
+
+// Fetch data from the server inside the sandbox.
+const response = await fetch(url);
+const data = await response.text();
+console.log('Response from server inside sandbox:', data);
+
+// Kill the server process inside the sandbox.
+await process.kill()
+```
+```python
+from e2b_code_interpreter import Sandbox
+
+sandbox = Sandbox()
+
+# Start a simple HTTP server inside the sandbox.
+process = sandbox.commands.run("python -m http.server 3000", background=True)
+host = sandbox.get_host(3000)
+url = f"https://{host}"
+print('Server started at:', url)
+
+# Fetch data from the server inside the sandbox.
+response = sandbox.commands.run(f"curl {url}")
+data = response.stdout
+print("Response from server inside sandbox:", data)
+
+# Kill the server process inside the sandbox.
+process.kill()
+```
+</CodeGroup>
+
+
+This output will look like this:
+<CodeGroup>
+```bash {{ language: 'js' }}
+Server started at: https://3000-ip3nfrvajtqu5ktoxugc7-b0b684e9.e2b.dev
+Response from server inside sandbox: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<title>Directory listing for /</title>
+</head>
+<body>
+<h1>Directory listing for /</h1>
+<hr>
+<ul>
+<li><a href=".bash_logout">.bash_logout</a></li>
+<li><a href=".bashrc">.bashrc</a></li>
+<li><a href=".profile">.profile</a></li>
+</ul>
+<hr>
+</body>
+</html>
+```
+```bash {{ language: 'python' }}
+Server started at: https://3000-ip3nfrvajtqu5ktoxugc7-b0b684e9.e2b.dev
+Response from server inside sandbox: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<title>Directory listing for /</title>
+</head>
+<body>
+<h1>Directory listing for /</h1>
+<hr>
+<ul>
+<li><a href=".bash_logout">.bash_logout</a></li>
+<li><a href=".bashrc">.bashrc</a></li>
+<li><a href=".profile">.profile</a></li>
+</ul>
+<hr>
+</body>
+</html>
+```
+</CodeGroup>
diff --git a/apps/web/src/app/(docs)/docs/sandbox/persistence/page.mdx b/apps/web/src/app/(docs)/docs/sandbox/persistence/page.mdx
new file mode 100644
index 000000000..bde9784e1
--- /dev/null
+++ b/apps/web/src/app/(docs)/docs/sandbox/persistence/page.mdx
@@ -0,0 +1,16 @@
+# Sandbox persistence
+
+We're working on a feature that will allow you to persist sandboxes between runs.
+
+In the meantime, you can mount cloud storage like Amazon's S3, Google Cloud Storage, or Cloudflare's R2 to the sandbox's filesystem.
+
+**Prerequisites**
+- Famil
+
+
+
+## Amazon S3
+
+## Google Cloud Storage
+
+## Cloudflare R2
diff --git a/apps/web/src/components/Navigation/routes.tsx b/apps/web/src/components/Navigation/routes.tsx
index ff78c75e3..dcd049b06 100644
--- a/apps/web/src/components/Navigation/routes.tsx
+++ b/apps/web/src/components/Navigation/routes.tsx
@@ -179,6 +179,10 @@ export const routes: NavGroup[] = [
},
]
},
+ {
+ title: '* Streaming',
+ href: '/docs/code-interpreting/streaming',
+ },
{
title: '* Connect your data',
href: '/docs/code-interpreting/connect-your-data',
@@ -253,6 +257,10 @@ export const routes: NavGroup[] = [
// href: '/docs/code-execution/python',
// },
// {
+ // title: '* Streaming'
+ // href: '/docs/code-execution/streaming',
+ // },
+ // {
// title: '* Web frameworks',
// links: [
// {
@@ -306,6 +314,10 @@ export const routes: NavGroup[] = [
title: 'Connect to running sandbox',
href: '/docs/sandbox/connect',
},
+ {
+ title: 'Internet access',
+ href: '/docs/sandbox/internet-access',
+ },
{
title: '* Request timeouts',
href: '/docs/sandbox/request-timeouts',
@@ -365,6 +377,10 @@ export const routes: NavGroup[] = [
title: '* Overview',
href: '/docs/process/overview',
},
+ {
+ title: '* Streaming',
+ href: '/docs/process/streaming',
+ },
{
title: '* Run commands in background',
href: '/docs/process/overview',