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 Mlejnsky3fc24a1f07b3
diff --git a/apps/web/src/app/(docs)/docs/commands/page.mdx b/apps/web/src/app/(docs)/docs/commands/page.mdx
new file mode 100644
index 000000000..c63dc0585
--- /dev/null
+++ b/apps/web/src/app/(docs)/docs/commands/page.mdx
@@ -0,0 +1,21 @@
+# Running commands in sandbox
+
+You can run terminal commands inside the sandbox using the `commands.run()` method.
+
+<CodeGroup>
+```js
+import { Sandbox } from '@e2b/code-interpreter'
+
+const sandbox = await Sandbox.create()
+const result = await sandbox.commands.run('ls -l')
+console.log(result)
+```
+```python
+from e2b_code_interpreter import Sandbox
+
+sandbox = Sandbox()
+
+result = sandbox.commands.run('ls -l')
+print(result)
+```
+</CodeGroup>
diff --git a/apps/web/src/app/(docs)/docs/commands/streaming/page.mdx b/apps/web/src/app/(docs)/docs/commands/streaming/page.mdx
new file mode 100644
index 000000000..b67f282b2
--- /dev/null
+++ b/apps/web/src/app/(docs)/docs/commands/streaming/page.mdx
@@ -0,0 +1,29 @@
+# Streaming command output
+
+To stream command output as it is being executed, pass the `onStdout`, `onStderr` callbacks to the `commands.run()` method in JavaScript
+or the `on_stdout`, `on_stderr` callbacks to the `commands.run()` method in Python.
+
+<CodeGroup>
+```js
+import { Sandbox } from '@e2b/code-interpreter'
+
+const sandbox = await Sandbox.create()
+const result = await sandbox.commands.run('echo hello; sleep 1; echo world', {
+ onStdout: (data) => {
+ console.log(data)
+ },
+ onStderr: (data) => {
+ console.log(data)
+ },
+})
+console.log(result)
+```
+```python
+from e2b_code_interpreter import Sandbox
+
+sandbox = Sandbox()
+
+result = sandbox.commands.run('echo hello; sleep 1; echo world', on_stdout=lambda data: print(data), on_stderr=lambda data: print(data))
+print(result)
+```
+</CodeGroup>
diff --git a/apps/web/src/components/Navigation/routes.tsx b/apps/web/src/components/Navigation/routes.tsx
index 7b2f7dafb..fe39d1faf 100644
--- a/apps/web/src/components/Navigation/routes.tsx
+++ b/apps/web/src/components/Navigation/routes.tsx
@@ -371,15 +371,15 @@ export const routes: NavGroup[] = [
items: [
{
title: '* Overview',
- href: '/docs/process/overview',
+ href: '/docs/commands',
},
{
title: '* Streaming',
- href: '/docs/process/streaming',
+ href: '/docs/commands/streaming',
},
{
title: '* Run commands in background',
- href: '/docs/process/overview',
+ href: '/docs/commands/background',
},
]
},