Skip to content

armgit / E2B

Public Imported from GitHub
0

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

Improve fs write docstrings; Add python module description; Add links to docs and JS class description with example

Tomas Valenta06737a32ac72
diff --git a/packages/js-sdk/src/sandbox/index.ts b/packages/js-sdk/src/sandbox/index.ts
index 0808f184b..4bdab1b9c 100644
--- a/packages/js-sdk/src/sandbox/index.ts
+++ b/packages/js-sdk/src/sandbox/index.ts
@@ -33,6 +33,32 @@ export interface Action<T = { [key: string]: any }> {
(sandbox: Sandbox, args: T): string | Promise<string>
}
+/**
+ * E2B cloud sandbox gives your agent a full cloud development environment that's sandboxed.
+ *
+ * That means:
+ * - Access to Linux OS
+ * - Using filesystem (create, list, and delete files and dirs)
+ * - Run processes
+ * - Sandboxed - you can run any code
+ * - Access to the internet
+ *
+ * Check usage docs - https://e2b.dev/docs/sandbox/overview
+ *
+ * These cloud sandboxes are meant to be used for agents. Like a sandboxed playgrounds, where the agent can do whatever it wants.
+ *
+ * Use the {@link Sandbox.create} method to create a new sandbox.
+ *
+ * @example
+ * ```ts
+ * import { Sandbox } from '@e2b/sdk'
+ *
+ * const sandbox = await Sandbox.create()
+ *
+ * await sandbox.close()
+ * ```
+ *
+ */
export class Sandbox extends SandboxConnection {
readonly terminal: TerminalManager
readonly filesystem: FilesystemManager
@@ -95,6 +121,8 @@ export class Sandbox extends SandboxConnection {
},
/**
* Writes content to a new file on path.
+ *
+
* @param path Path to a new file. For example '/dirA/dirB/newFile.txt' when creating 'newFile.txt'
* @param content Content to write to a new file
* @param opts Call options
@@ -112,6 +140,9 @@ export class Sandbox extends SandboxConnection {
* Write array of bytes to a file.
* This can be used when you cannot represent the data as an UTF-8 string.
*
+ * A new file will be created if it doesn't exist.
+ * If the file already exists, it will be overwritten.
+ *
* @param path path to a file
* @param content byte array representing the content to write
*/
diff --git a/packages/python-sdk/e2b/__init__.py b/packages/python-sdk/e2b/__init__.py
index 323ee2ad5..e758b0bb7 100644
--- a/packages/python-sdk/e2b/__init__.py
+++ b/packages/python-sdk/e2b/__init__.py
@@ -1,3 +1,28 @@
+"""
+Secure sandboxed cloud environments made for AI agents and AI apps
+
+Check usage docs - https://e2b.dev/docs/sandbox/overview
+
+E2B Sandbox is a secure sandboxed cloud environment made for AI agents and AI
+apps. Sandboxes allow AI agents and apps to have long running cloud secure
+environments. In these environments, large language models can use the same
+tools as humans do.
+
+
+```py
+from e2b import Sandbox
+
+# Create sandbox
+sandbox = Sandbox()
+
+# Let an LLM use the sandbox here
+
+# Close sandbox once done
+sandbox.close()
+```
+"""
+
+
from .api import (
E2BApiClient,
client,
diff --git a/packages/python-sdk/e2b/sandbox/filesystem.py b/packages/python-sdk/e2b/sandbox/filesystem.py
index 0667a94e0..317dd947e 100644
--- a/packages/python-sdk/e2b/sandbox/filesystem.py
+++ b/packages/python-sdk/e2b/sandbox/filesystem.py
@@ -54,6 +54,9 @@ class FilesystemManager:
Write content to a file as a byte array.
This can be used when you cannot represent the data as an UTF-8 string.
+ A new file will be created if it doesn't exist.
+ If the file already exists, it will be overwritten.
+
:param path: path to a file
:param timeout: timeout for the call
:param content: byte array representing the content to write
@@ -90,6 +93,9 @@ class FilesystemManager:
"""
Write content to a file.
+ A new file will be created if it doesn't exist.
+ If the file already exists, it will be overwritten.
+
:param path: Path to a file
:param content: Content to write
:param timeout: Specify the duration, in seconds to give the method to finish its execution before it times out (default is 60 seconds). If set to None, the method will continue to wait until it completes, regardless of time
diff --git a/packages/python-sdk/e2b/sandbox/main.py b/packages/python-sdk/e2b/sandbox/main.py
index 91e39e65d..926dee1e5 100644
--- a/packages/python-sdk/e2b/sandbox/main.py
+++ b/packages/python-sdk/e2b/sandbox/main.py
@@ -22,13 +22,14 @@ class Sandbox(SandboxConnection):
E2B cloud sandbox gives your agent a full cloud development environment that's sandboxed.
That means:
-
- Access to Linux OS
- Using filesystem (create, list, and delete files and dirs)
- Run processes
- Sandboxed - you can run any code
- Access to the internet
+ Check usage docs - https://e2b.dev/docs/sandbox/overview
+
These cloud sandboxes are meant to be used for agents. Like a sandboxed playgrounds, where the agent can do whatever it wants.
"""