Skip to content

armgit / E2B

Public Imported from GitHub
0

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

Fix minor issues, raise error on incorrect values

Jakub Novakf636bdb997f9
diff --git a/apps/docs/src/app/sandbox/api/reconnect/page.mdx b/apps/docs/src/app/sandbox/api/reconnect/page.mdx
index df42eaf0e..cbec64456 100644
--- a/apps/docs/src/app/sandbox/api/reconnect/page.mdx
+++ b/apps/docs/src/app/sandbox/api/reconnect/page.mdx
@@ -6,7 +6,7 @@ Disconnect and reconnect to the same sandbox {{ className: 'lead' }}
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.
+If you want to keep the sandbox alive for even after disconnecting from it, you can explicitly say for how long you want to keep it alive. You can then disconnect from the sandbox and reconnect to it later. 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.
diff --git a/apps/docs/src/app/sandbox/resources/page.mdx b/apps/docs/src/app/sandbox/resources/page.mdx
index 7fa9c57f2..7a73c7386 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 sandbox 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 sandbox 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/packages/js-sdk/src/sandbox/sandboxConnection.ts b/packages/js-sdk/src/sandbox/sandboxConnection.ts
index 903b10776..b1b06cfd4 100644
--- a/packages/js-sdk/src/sandbox/sandboxConnection.ts
+++ b/packages/js-sdk/src/sandbox/sandboxConnection.ts
@@ -114,7 +114,12 @@ export class SandboxConnection {
* @returns Promise that resolves when the sandbox is kept alive
*/
public async keepAlive(duration: number) {
- duration = duration / 1000
+ duration = Math.round(duration / 1000)
+
+ if (duration < 0 || duration > 3600) {
+ throw new Error('Duration must be between 0 and 3600 seconds')
+ }
+
if (!this.sandbox) {
throw new Error('Cannot keep alive - sandbox is not initialized')
}
diff --git a/packages/python-sdk/e2b/api/v1/client/api/instances_api.py b/packages/python-sdk/e2b/api/v1/client/api/instances_api.py
index 308f76bcc..c23b67f22 100644
--- a/packages/python-sdk/e2b/api/v1/client/api/instances_api.py
+++ b/packages/python-sdk/e2b/api/v1/client/api/instances_api.py
@@ -21,6 +21,8 @@ from typing_extensions import Annotated
from pydantic import StrictStr
+from typing import Optional
+
from e2b.api.v1.client.models.instance import Instance
from e2b.api.v1.client.models.instances_instance_id_refreshes_post_request import (
InstancesInstanceIDRefreshesPostRequest,
@@ -48,7 +50,9 @@ class InstancesApi(object):
def instances_instance_id_refreshes_post(
self,
instance_id: StrictStr,
- instances_instance_id_refreshes_post_request: InstancesInstanceIDRefreshesPostRequest,
+ instances_instance_id_refreshes_post_request: Optional[
+ InstancesInstanceIDRefreshesPostRequest
+ ] = None,
**kwargs
) -> None: # noqa: E501
"""instances_instance_id_refreshes_post # noqa: E501
@@ -62,7 +66,7 @@ class InstancesApi(object):
:param instance_id: (required)
:type instance_id: str
- :param instances_instance_id_refreshes_post_request: (required)
+ :param instances_instance_id_refreshes_post_request:
:type instances_instance_id_refreshes_post_request: InstancesInstanceIDRefreshesPostRequest
:param async_req: Whether to execute the request asynchronously.
:type async_req: bool, optional
@@ -88,7 +92,9 @@ class InstancesApi(object):
def instances_instance_id_refreshes_post_with_http_info(
self,
instance_id: StrictStr,
- instances_instance_id_refreshes_post_request: InstancesInstanceIDRefreshesPostRequest,
+ instances_instance_id_refreshes_post_request: Optional[
+ InstancesInstanceIDRefreshesPostRequest
+ ] = None,
**kwargs
) -> ApiResponse: # noqa: E501
"""instances_instance_id_refreshes_post # noqa: E501
@@ -102,7 +108,7 @@ class InstancesApi(object):
:param instance_id: (required)
:type instance_id: str
- :param instances_instance_id_refreshes_post_request: (required)
+ :param instances_instance_id_refreshes_post_request:
:type instances_instance_id_refreshes_post_request: InstancesInstanceIDRefreshesPostRequest
:param async_req: Whether to execute the request asynchronously.
:type async_req: bool, optional
diff --git a/packages/python-sdk/e2b/api/v1/client_README.md b/packages/python-sdk/e2b/api/v1/client_README.md
index 1f7cee6d9..62b0b8973 100644
--- a/packages/python-sdk/e2b/api/v1/client_README.md
+++ b/packages/python-sdk/e2b/api/v1/client_README.md
@@ -57,10 +57,10 @@ with e2b.api.v1.client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = e2b.api.v1.client.InstancesApi(api_client)
instance_id = 'instance_id_example' # str |
- instances_instance_id_refreshes_post_request = e2b.api.v1.client.InstancesInstanceIDRefreshesPostRequest() # InstancesInstanceIDRefreshesPostRequest |
+ instances_instance_id_refreshes_post_request = e2b.api.v1.client.InstancesInstanceIDRefreshesPostRequest() # InstancesInstanceIDRefreshesPostRequest | (optional)
try:
- api_instance.instances_instance_id_refreshes_post(instance_id, instances_instance_id_refreshes_post_request)
+ api_instance.instances_instance_id_refreshes_post(instance_id, instances_instance_id_refreshes_post_request=instances_instance_id_refreshes_post_request)
except ApiException as e:
print("Exception when calling InstancesApi->instances_instance_id_refreshes_post: %s\n" % e)
diff --git a/packages/python-sdk/e2b/api/v2/client/api/instances_api.py b/packages/python-sdk/e2b/api/v2/client/api/instances_api.py
index 437b70ac0..b4e2cea50 100644
--- a/packages/python-sdk/e2b/api/v2/client/api/instances_api.py
+++ b/packages/python-sdk/e2b/api/v2/client/api/instances_api.py
@@ -21,6 +21,8 @@ from typing_extensions import Annotated
from pydantic import StrictStr
+from typing import Optional
+
from e2b.api.v2.client.models.instance import Instance
from e2b.api.v2.client.models.instances_instance_id_refreshes_post_request import (
InstancesInstanceIDRefreshesPostRequest,
@@ -48,7 +50,9 @@ class InstancesApi:
def instances_instance_id_refreshes_post(
self,
instance_id: StrictStr,
- instances_instance_id_refreshes_post_request: InstancesInstanceIDRefreshesPostRequest,
+ instances_instance_id_refreshes_post_request: Optional[
+ InstancesInstanceIDRefreshesPostRequest
+ ] = None,
**kwargs
) -> None: # noqa: E501
"""instances_instance_id_refreshes_post # noqa: E501
@@ -62,7 +66,7 @@ class InstancesApi:
:param instance_id: (required)
:type instance_id: str
- :param instances_instance_id_refreshes_post_request: (required)
+ :param instances_instance_id_refreshes_post_request:
:type instances_instance_id_refreshes_post_request: InstancesInstanceIDRefreshesPostRequest
:param async_req: Whether to execute the request asynchronously.
:type async_req: bool, optional
@@ -87,7 +91,9 @@ class InstancesApi:
def instances_instance_id_refreshes_post_with_http_info(
self,
instance_id: StrictStr,
- instances_instance_id_refreshes_post_request: InstancesInstanceIDRefreshesPostRequest,
+ instances_instance_id_refreshes_post_request: Optional[
+ InstancesInstanceIDRefreshesPostRequest
+ ] = None,
**kwargs
) -> ApiResponse: # noqa: E501
"""instances_instance_id_refreshes_post # noqa: E501
@@ -101,7 +107,7 @@ class InstancesApi:
:param instance_id: (required)
:type instance_id: str
- :param instances_instance_id_refreshes_post_request: (required)
+ :param instances_instance_id_refreshes_post_request:
:type instances_instance_id_refreshes_post_request: InstancesInstanceIDRefreshesPostRequest
:param async_req: Whether to execute the request asynchronously.
:type async_req: bool, optional
diff --git a/packages/python-sdk/e2b/api/v2/client_README.md b/packages/python-sdk/e2b/api/v2/client_README.md
index 32f28c3a8..7c17b796e 100644
--- a/packages/python-sdk/e2b/api/v2/client_README.md
+++ b/packages/python-sdk/e2b/api/v2/client_README.md
@@ -57,10 +57,10 @@ with e2b.api.v2.client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = e2b.api.v2.client.InstancesApi(api_client)
instance_id = 'instance_id_example' # str |
- instances_instance_id_refreshes_post_request = e2b.api.v2.client.InstancesInstanceIDRefreshesPostRequest() # InstancesInstanceIDRefreshesPostRequest |
+ instances_instance_id_refreshes_post_request = e2b.api.v2.client.InstancesInstanceIDRefreshesPostRequest() # InstancesInstanceIDRefreshesPostRequest | (optional)
try:
- api_instance.instances_instance_id_refreshes_post(instance_id, instances_instance_id_refreshes_post_request)
+ api_instance.instances_instance_id_refreshes_post(instance_id, instances_instance_id_refreshes_post_request=instances_instance_id_refreshes_post_request)
except ApiException as e:
print("Exception when calling InstancesApi->instances_instance_id_refreshes_post: %s\n" % e)
diff --git a/packages/python-sdk/e2b/sandbox/sandbox_connection.py b/packages/python-sdk/e2b/sandbox/sandbox_connection.py
index e4d897c94..223fc0b7f 100644
--- a/packages/python-sdk/e2b/sandbox/sandbox_connection.py
+++ b/packages/python-sdk/e2b/sandbox/sandbox_connection.py
@@ -155,6 +155,9 @@ class SandboxConnection:
return hostname
def keep_alive(self, duration: int) -> None:
+ if not 0 <= duration < 3600:
+ raise ValueError("Duration must be between 0 and 3600 seconds")
+
with E2BApiClient(api_key=self._api_key) as api_client:
api = client.InstancesApi(api_client)
try:
diff --git a/spec/openapi.yml b/spec/openapi.yml
index f015acd90..e3e7139b6 100644
--- a/spec/openapi.yml
+++ b/spec/openapi.yml
@@ -196,7 +196,7 @@ paths:
- ApiKeyAuth: []
tags: [instances]
requestBody:
- required: true
+ required: false
content:
application/json:
schema: