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 Mlejnsky955efc6b4743
diff --git a/apps/web/src/app/(docs)/docs/sandbox/page.mdx b/apps/web/src/app/(docs)/docs/sandbox/page.mdx
new file mode 100644
index 000000000..d6599f1c3
--- /dev/null
+++ b/apps/web/src/app/(docs)/docs/sandbox/page.mdx
@@ -0,0 +1,82 @@
+# Sandbox lifecycle
+
+When you start the sandbox, it stays alive for 5 minutes by default but you can change it by passing the `timeout` parameter.
+After the time passes, the sandbox will be automatically shutdown.
+<CodeGroup>
+```js
+import { Sandbox } from '@e2b/code-interpreter'
+
+// Create sandbox with and keep it running for 60 seconds.
+// 🚨 Note: The units are milliseconds.
+const sandbox = await Sandbox.create({
+ timeoutMs: 60_000, // $HighlightLine
+})
+```
+```python
+from e2b_code_interpreter import Sandbox
+
+# Create sandbox with and keep it running for 60 seconds.
+# 🚨 Note: The units are seconds.
+sandbox = Sandbox(
+ timeout=60, # $HighlightLine
+)
+```
+</CodeGroup>
+
+
+## Change sandbox timeout during runtime
+
+You can change the sandbox timeout when it's running by calling the the `setTimeout` method in JavaScript or `set_timeout` method in Python.
+
+When you call the set timeout method, the sandbox timeout will be reset to the new value that you specified.
+
+This can be useful if you want to extend the sandbox lifetime when it's already running.
+You can for example start with a sandbox with 1 minute timeout and then periodically call set timout every time user interacts with it in your app.
+
+<CodeGroup>
+```js
+import { Sandbox } from '@e2b/code-interpreter'
+
+// Create sandbox with and keep it running for 60 seconds.
+const sandbox = await Sandbox.create({ timeoutMs: 60_000 })
+
+// Change the sandbox timeout to 30 seconds.
+// 🚨 The new timeout will be 30 seconds from now.
+await sandbox.setTimeout(30_000)
+```
+```python
+from e2b_code_interpreter import Sandbox
+
+# Create sandbox with and keep it running for 60 seconds.
+sandbox = Sandbox(timeout=60)
+
+# Change the sandbox timeout to 30 seconds.
+# 🚨 The new timeout will be 30 seconds from now.
+sandbox.set_timeout(30)
+```
+</CodeGroup>
+
+## Shutdown sandbox
+
+You can shutdown the sandbox any time even before the timeout is up by calling the `kill` method.
+
+<CodeGroup>
+```js
+import { Sandbox } from '@e2b/code-interpreter'
+
+// Create sandbox with and keep it running for 60 seconds.
+const sandbox = await Sandbox.create({ timeoutMs: 60_000 })
+
+// Shutdown the sandbox immediately.
+await sandbox.kill()
+```
+```python
+from e2b_code_interpreter import Sandbox
+
+# Create sandbox with and keep it running for 60 seconds.
+sandbox = Sandbox(timeout=60)
+
+# Shutdown the sandbox immediately.
+sandbox.kill()
+```
+</CodeGroup>
diff --git a/apps/web/src/components/Code.tsx b/apps/web/src/components/Code.tsx
index dfc6a0bb5..3a19d7995 100644
--- a/apps/web/src/components/Code.tsx
+++ b/apps/web/src/components/Code.tsx
@@ -96,7 +96,7 @@ export function CodeGroupHeader({
selectedIndex: number;
isTerminalCommand?: boolean;
}) {
- const hasTabs = Children.count(children) > 1
+ const hasTabs = Children.count(children) > 0
if (!title && !hasTabs && !isTerminalCommand) return null
return (
@@ -178,7 +178,7 @@ function CodeGroupPanels({
children,
...props
}: React.ComponentPropsWithoutRef<typeof CodePanel>) {
- const hasTabs = Children.count(children) > 1
+ const hasTabs = Children.count(children) > 0
/* <INTERNAL> */
// @ts-ignore
@@ -302,7 +302,7 @@ export function CodeGroup({
isFileName?: boolean;
path?: string; // For analytics
}) {
- const hasTabs = Children.count(children) > 1
+ const hasTabs = Children.count(children) > 0
const containerClassName =
'not-prose my-6 overflow-hidden rounded-2xl bg-zinc-900 shadow-md dark:ring-1 dark:ring-white/10'
const languages =
diff --git a/apps/web/src/components/Header.tsx b/apps/web/src/components/Header.tsx
index 5130d8441..b70a1bc7e 100644
--- a/apps/web/src/components/Header.tsx
+++ b/apps/web/src/components/Header.tsx
@@ -4,6 +4,10 @@ import { forwardRef, useEffect } from 'react'
import Link from 'next/link'
import clsx from 'clsx'
import { motion, useScroll, useTransform } from 'framer-motion'
+import dynamic from 'next/dynamic'
+import { usePathname } from 'next/navigation'
+
+import { Auth } from '@/components/Auth'
import {
MobileBurgerMenu,
useIsInsideMobileNavigation,
@@ -13,10 +17,7 @@ import { Logo } from '@/components/Logo'
import { useLocalStorage } from 'usehooks-ts'
import { GitHubIcon } from '@/components/icons/GitHubIcon'
-import dynamic from 'next/dynamic'
import { config } from '../../config'
-import { usePathname } from 'next/navigation'
-
function DocumentationTypeLink({ pathname, href, title }: { pathname: string | null, href: string, title: string }) {
if (!pathname) return null
@@ -127,16 +128,16 @@ export const Header = forwardRef(function Header({ className }, ref) {
</ul>
</nav>
{/* {isDocs && <MobileSearch />} */}
- {/* <div className="hidden min-[540px]:contents">
- <Link className='hover:text-white hover:cursor-pointer text-sm text-neutral-400' href='/docs'>
+ <div className="hidden min-[540px]:contents">
+ {/* <Link className='hover:text-white hover:cursor-pointer text-sm text-neutral-400' href='/docs'>
Docs
</Link>
<Link className='hover:text-white hover:cursor-pointer text-sm text-neutral-400' href='/dashboard'>
Dashboard
</Link>
- <HeaderSeparator />
+ <HeaderSeparator /> */}
<Auth />
- </div> */}
+ </div>
</div>
}
</motion.div>
diff --git a/apps/web/src/components/Navigation/routes.tsx b/apps/web/src/components/Navigation/routes.tsx
index d26437b8b..6c0f2ee7b 100644
--- a/apps/web/src/components/Navigation/routes.tsx
+++ b/apps/web/src/components/Navigation/routes.tsx
@@ -2,6 +2,7 @@ import {
Home,
CheckCircle,
MessagesSquare,
+ Braces,
} from 'lucide-react'
@@ -82,6 +83,11 @@ export const routes: NavGroup[] = [
},
],
},
+ {
+ title: 'Cookbook',
+ href: 'https://github.com/e2b-dev/e2b-cookbook',
+ icon: <Braces size={16} />,
+ },
{
title: 'Need help?',
href: '/docs/support',
@@ -277,8 +283,8 @@ export const routes: NavGroup[] = [
title: '* Sandbox',
items: [
{
- title: '* Lifecycle',
- href: '/docs/sandbox/lifecycle',
+ title: 'Lifecycle',
+ href: '/docs/sandbox',
},
{
title: '* Metadata',
@@ -343,55 +349,51 @@ export const routes: NavGroup[] = [
title: '* Overview',
href: '/docs/process/overview',
},
- {
- title: '* Run commands',
- href: '/docs/process/overview',
- },
{
title: '* Run commands in background',
href: '/docs/process/overview',
},
]
},
- {
- title: '* Async Python SDK',
- items: [
- {
- title: '* Overview',
- href: '/docs/sdk/overview',
- },
- ]
- },
- {
- title: '* Limits',
- items: [
- {
- title: '* Sandbox',
- href: '/docs/limits/sandbox',
- },
- {
- title: '* Filesystem',
- href: '/docs/limits/overview',
- },
- {
- title: '* File upload & download',
- href: '/docs/limits/file-upload-download',
- },
- ]
- },
- {
- title: '* Latency',
- items: [
- {
- title: '* Start times',
- href: '/docs/latency/start-times',
- },
- {
- title: '* Sandbox operations',
- href: '/docs/latency/sandbox-operations',
- },
- ]
- },
+ // {
+ // title: '* Async Python SDK',
+ // items: [
+ // {
+ // title: '* Overview',
+ // href: '/docs/sdk/overview',
+ // },
+ // ]
+ // },
+ // {
+ // title: '* Limits',
+ // items: [
+ // {
+ // title: '* Sandbox',
+ // href: '/docs/limits/sandbox',
+ // },
+ // {
+ // title: '* Filesystem',
+ // href: '/docs/limits/overview',
+ // },
+ // {
+ // title: '* File upload & download',
+ // href: '/docs/limits/file-upload-download',
+ // },
+ // ]
+ // },
+ // {
+ // title: '* Latency',
+ // items: [
+ // {
+ // title: '* Start times',
+ // href: '/docs/latency/start-times',
+ // },
+ // {
+ // title: '* Sandbox operations',
+ // href: '/docs/latency/sandbox-operations',
+ // },
+ // ]
+ // },
{
title: '* CLI',
items: [