Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Add possibility to add env vars on sandbox create
Jakub Novak2357fa3da742
diff --git a/Makefile b/Makefileindex bb1562fa8..77bb1fdb1 100644--- a/Makefile+++ b/Makefile@@ -7,9 +7,9 @@ update-api-spec:generate: generate-api generate-envdgenerate-api:- cd packages/python-sdk && make generate+ cd packages/python-sdk && make generate-apicd packages/js-sdk && pnpm generate && pnpm generate-envd-apigenerate-envd:cd packages/js-sdk && pnpm generate-envd-api- cd spec/envd && buf generate && cd ../../packages/python-sdk && ./scripts/fix-python-pb.sh\ No newline at end of file+ cd spec/envd && buf generate && cd ../../packages/python-sdk && ./scripts/fix-python-pb.shdiff --git a/packages/js-sdk/src/api/schema.gen.ts b/packages/js-sdk/src/api/schema.gen.tsindex 4d657f1a3..def96599c 100644--- a/packages/js-sdk/src/api/schema.gen.ts+++ b/packages/js-sdk/src/api/schema.gen.ts@@ -154,9 +154,29 @@ export interface paths {};};};+ "/teams": {+ /** @description List all teams */+ get: {+ responses: {+ /** @description Successfully returned all teams */+ 200: {+ content: {+ "application/json": components["schemas"]["Team"][];+ };+ };+ 401: components["responses"]["401"];+ 500: components["responses"]["500"];+ };+ };+ };"/templates": {/** @description List all templates */get: {+ parameters: {+ query?: {+ teamID?: string;+ };+ };responses: {/** @description Successfully returned all templates */200: {@@ -284,6 +304,9 @@ export interface components {* @description CPU cores for the sandbox*/CPUCount: number;+ EnvVars: {+ [key: string]: string;+ };Error: {/*** Format: int32@@ -299,6 +322,7 @@ export interface components {*/MemoryMB: number;NewSandbox: {+ envVars?: components["schemas"]["SandboxMetadata"];metadata?: components["schemas"]["SandboxMetadata"];/** @description Identifier of the required template */templateID: string;@@ -315,6 +339,11 @@ export interface components {/** @description Identifier of the client */clientID: string;cpuCount: components["schemas"]["CPUCount"];+ /**+ * Format: date-time+ * @description Time when the sandbox will expire+ */+ endAt: string;memoryMB: components["schemas"]["MemoryMB"];metadata?: components["schemas"]["SandboxMetadata"];/** @description Identifier of the sandbox */@@ -356,6 +385,16 @@ export interface components {SandboxMetadata: {[key: string]: string;};+ Team: {+ /** @description API key for the team */+ apiKey: string;+ /** @description Whether the team is the default team */+ isDefault: boolean;+ /** @description Name of the team */+ name: string;+ /** @description Identifier of the team */+ teamID: string;+ };Template: {/** @description Aliases of the template */aliases?: string[];@@ -393,6 +432,8 @@ export interface components {memoryMB?: components["schemas"]["MemoryMB"];/** @description Start command to execute in the template after the build */startCmd?: string;+ /** @description Identifier of the team */+ teamID?: string;};};responses: {diff --git a/packages/js-sdk/src/envd/schema.gen.ts b/packages/js-sdk/src/envd/schema.gen.tsindex 3c0f5b875..d415c0789 100644--- a/packages/js-sdk/src/envd/schema.gen.ts+++ b/packages/js-sdk/src/envd/schema.gen.ts@@ -51,11 +51,18 @@ export interface paths {};};};- "/sync": {- /** Ensure the time and metadata is synced with the host */+ "/init": {+ /** Set env vars, ensure the time and metadata is synced with the host */post: {+ requestBody?: {+ content: {+ "application/json": {+ envVars?: components["schemas"]["EnvVars"];+ };+ };+ };responses: {- /** @description The time and metadata is synced with the host */+ /** @description Env vars set, the time and metadata is synced with the host */204: {content: never;};@@ -79,6 +86,10 @@ export interface components {*/type: "file";};+ /** @description Environment variables to set */+ EnvVars: {+ [key: string]: string;+ };Error: {/** @description Error code */code: number;diff --git a/packages/python-sdk/e2b/api/client/api/templates/get_templates.py b/packages/python-sdk/e2b/api/client/api/templates/get_templates.pyindex c871c41b8..d50150950 100644--- a/packages/python-sdk/e2b/api/client/api/templates/get_templates.py+++ b/packages/python-sdk/e2b/api/client/api/templates/get_templates.py@@ -6,13 +6,23 @@ import httpxfrom ... import errorsfrom ...client import AuthenticatedClient, Clientfrom ...models.template import Template-from ...types import Response+from ...types import UNSET, Response, Unset-def _get_kwargs() -> Dict[str, Any]:+def _get_kwargs(+ *,+ team_id: Union[Unset, str] = UNSET,+) -> Dict[str, Any]:+ params: Dict[str, Any] = {}++ params["teamID"] = team_id++ params = {k: v for k, v in params.items() if v is not UNSET and v is not None}+_kwargs: Dict[str, Any] = {"method": "get","url": "/templates",+ "params": params,}return _kwargs@@ -56,9 +66,13 @@ def _build_response(def sync_detailed(*,client: AuthenticatedClient,+ team_id: Union[Unset, str] = UNSET,) -> Response[Union[Any, List["Template"]]]:"""List all templates+ Args:+ team_id (Union[Unset, str]): Identifier of the team+Raises:errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.httpx.TimeoutException: If the request takes longer than Client.timeout.@@ -67,7 +81,9 @@ def sync_detailed(Response[Union[Any, List['Template']]]"""- kwargs = _get_kwargs()+ kwargs = _get_kwargs(+ team_id=team_id,+ )response = client.get_httpx_client().request(**kwargs,@@ -79,9 +95,13 @@ def sync_detailed(def sync(*,client: AuthenticatedClient,+ team_id: Union[Unset, str] = UNSET,) -> Optional[Union[Any, List["Template"]]]:"""List all templates+ Args:+ team_id (Union[Unset, str]): Identifier of the team+Raises:errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.httpx.TimeoutException: If the request takes longer than Client.timeout.@@ -92,15 +112,20 @@ def sync(return sync_detailed(client=client,+ team_id=team_id,).parsedasync def asyncio_detailed(*,client: AuthenticatedClient,+ team_id: Union[Unset, str] = UNSET,) -> Response[Union[Any, List["Template"]]]:"""List all templates+ Args:+ team_id (Union[Unset, str]): Identifier of the team+Raises:errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.httpx.TimeoutException: If the request takes longer than Client.timeout.@@ -109,7 +134,9 @@ async def asyncio_detailed(Response[Union[Any, List['Template']]]"""- kwargs = _get_kwargs()+ kwargs = _get_kwargs(+ team_id=team_id,+ )response = await client.get_async_httpx_client().request(**kwargs)@@ -119,9 +146,13 @@ async def asyncio_detailed(async def asyncio(*,client: AuthenticatedClient,+ team_id: Union[Unset, str] = UNSET,) -> Optional[Union[Any, List["Template"]]]:"""List all templates+ Args:+ team_id (Union[Unset, str]): Identifier of the team+Raises:errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.httpx.TimeoutException: If the request takes longer than Client.timeout.@@ -133,5 +164,6 @@ async def asyncio(return (await asyncio_detailed(client=client,+ team_id=team_id,)).parseddiff --git a/packages/python-sdk/e2b/api/client/models/__init__.py b/packages/python-sdk/e2b/api/client/models/__init__.pyindex aa3a57865..d55b958c2 100644--- a/packages/python-sdk/e2b/api/client/models/__init__.py+++ b/packages/python-sdk/e2b/api/client/models/__init__.py@@ -8,6 +8,7 @@ from .running_sandbox import RunningSandboxfrom .sandbox import Sandboxfrom .sandbox_log import SandboxLogfrom .sandbox_logs import SandboxLogs+from .team import Teamfrom .template import Templatefrom .template_build import TemplateBuildfrom .template_build_request import TemplateBuildRequest@@ -22,6 +23,7 @@ __all__ = ("Sandbox","SandboxLog","SandboxLogs",+ "Team","Template","TemplateBuild","TemplateBuildRequest",diff --git a/packages/python-sdk/e2b/api/client/models/new_sandbox.py b/packages/python-sdk/e2b/api/client/models/new_sandbox.pyindex 46736c4e9..2094bb5a6 100644--- a/packages/python-sdk/e2b/api/client/models/new_sandbox.py+++ b/packages/python-sdk/e2b/api/client/models/new_sandbox.py@@ -15,11 +15,13 @@ class NewSandbox:template_id (str): Identifier of the required templatetimeout (Union[Unset, int]): Time to live for the sandbox in seconds. Default: 15.metadata (Union[Unset, Any]):+ env_vars (Union[Unset, Any]):"""template_id: strtimeout: Union[Unset, int] = 15metadata: Union[Unset, Any] = UNSET+ env_vars: Union[Unset, Any] = UNSETadditional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict)def to_dict(self) -> Dict[str, Any]:@@ -29,6 +31,8 @@ class NewSandbox:metadata = self.metadata+ env_vars = self.env_vars+field_dict: Dict[str, Any] = {}field_dict.update(self.additional_properties)field_dict.update(@@ -40,6 +44,8 @@ class NewSandbox:field_dict["timeout"] = timeoutif metadata is not UNSET:field_dict["metadata"] = metadata+ if env_vars is not UNSET:+ field_dict["envVars"] = env_varsreturn field_dict@@ -52,10 +58,13 @@ class NewSandbox:metadata = d.pop("metadata", UNSET)+ env_vars = d.pop("envVars", UNSET)+new_sandbox = cls(template_id=template_id,timeout=timeout,metadata=metadata,+ env_vars=env_vars,)new_sandbox.additional_properties = ddiff --git a/packages/python-sdk/e2b/api/client/models/running_sandbox.py b/packages/python-sdk/e2b/api/client/models/running_sandbox.pyindex 831e012e6..46c6757a6 100644--- a/packages/python-sdk/e2b/api/client/models/running_sandbox.py+++ b/packages/python-sdk/e2b/api/client/models/running_sandbox.py@@ -18,6 +18,7 @@ class RunningSandbox:sandbox_id (str): Identifier of the sandboxclient_id (str): Identifier of the clientstarted_at (datetime.datetime): Time when the sandbox was started+ end_at (datetime.datetime): Time when the sandbox will expirecpu_count (int): CPU cores for the sandboxmemory_mb (int): Memory for the sandbox in MBalias (Union[Unset, str]): Alias of the template@@ -28,6 +29,7 @@ class RunningSandbox:sandbox_id: strclient_id: strstarted_at: datetime.datetime+ end_at: datetime.datetimecpu_count: intmemory_mb: intalias: Union[Unset, str] = UNSET@@ -43,6 +45,8 @@ class RunningSandbox:started_at = self.started_at.isoformat()+ end_at = self.end_at.isoformat()+cpu_count = self.cpu_countmemory_mb = self.memory_mb@@ -59,6 +63,7 @@ class RunningSandbox:"sandboxID": sandbox_id,"clientID": client_id,"startedAt": started_at,+ "endAt": end_at,"cpuCount": cpu_count,"memoryMB": memory_mb,}@@ -81,6 +86,8 @@ class RunningSandbox:started_at = isoparse(d.pop("startedAt"))+ end_at = isoparse(d.pop("endAt"))+cpu_count = d.pop("cpuCount")memory_mb = d.pop("memoryMB")@@ -94,6 +101,7 @@ class RunningSandbox:sandbox_id=sandbox_id,client_id=client_id,started_at=started_at,+ end_at=end_at,cpu_count=cpu_count,memory_mb=memory_mb,alias=alias,diff --git a/packages/python-sdk/e2b/api/client/models/template_build_request.py b/packages/python-sdk/e2b/api/client/models/template_build_request.pyindex 6d2dfd56a..d93c68fb6 100644--- a/packages/python-sdk/e2b/api/client/models/template_build_request.py+++ b/packages/python-sdk/e2b/api/client/models/template_build_request.py@@ -14,6 +14,7 @@ class TemplateBuildRequest:Attributes:dockerfile (str): Dockerfile for the templatealias (Union[Unset, str]): Alias of the template+ team_id (Union[Unset, str]): Identifier of the teamstart_cmd (Union[Unset, str]): Start command to execute in the template after the buildcpu_count (Union[Unset, int]): CPU cores for the sandboxmemory_mb (Union[Unset, int]): Memory for the sandbox in MB@@ -21,6 +22,7 @@ class TemplateBuildRequest:dockerfile: stralias: Union[Unset, str] = UNSET+ team_id: Union[Unset, str] = UNSETstart_cmd: Union[Unset, str] = UNSETcpu_count: Union[Unset, int] = UNSETmemory_mb: Union[Unset, int] = UNSET@@ -31,6 +33,8 @@ class TemplateBuildRequest:alias = self.alias+ team_id = self.team_id+start_cmd = self.start_cmdcpu_count = self.cpu_count@@ -46,6 +50,8 @@ class TemplateBuildRequest:)if alias is not UNSET:field_dict["alias"] = alias+ if team_id is not UNSET:+ field_dict["teamID"] = team_idif start_cmd is not UNSET:field_dict["startCmd"] = start_cmdif cpu_count is not UNSET:@@ -62,6 +68,8 @@ class TemplateBuildRequest:alias = d.pop("alias", UNSET)+ team_id = d.pop("teamID", UNSET)+start_cmd = d.pop("startCmd", UNSET)cpu_count = d.pop("cpuCount", UNSET)@@ -71,6 +79,7 @@ class TemplateBuildRequest:template_build_request = cls(dockerfile=dockerfile,alias=alias,+ team_id=team_id,start_cmd=start_cmd,cpu_count=cpu_count,memory_mb=memory_mb,diff --git a/packages/python-sdk/e2b/sandbox_async/main.py b/packages/python-sdk/e2b/sandbox_async/main.pyindex 747739e81..d3c8988da 100644--- a/packages/python-sdk/e2b/sandbox_async/main.py+++ b/packages/python-sdk/e2b/sandbox_async/main.py@@ -110,6 +110,7 @@ class AsyncSandbox(SandboxSetup, SandboxApi):template: Optional[str] = None,timeout: Optional[int] = None,metadata: Optional[Dict[str, str]] = None,+ env_vars: Optional[Dict[str, str]] = None,api_key: Optional[str] = None,domain: Optional[str] = None,debug: Optional[bool] = None,@@ -123,9 +124,7 @@ class AsyncSandbox(SandboxSetup, SandboxApi):)sandbox_id = (- "debug_sandbox_id"- if connection_config.debug- else await SandboxApi._create_sandbox(+ await SandboxApi._create_sandbox(template=template or cls.default_template,api_key=api_key,timeout=timeout or cls.default_sandbox_timeout,@@ -133,6 +132,7 @@ class AsyncSandbox(SandboxSetup, SandboxApi):domain=domain,debug=debug,request_timeout=request_timeout,+ env_vars=env_vars,))diff --git a/packages/python-sdk/e2b/sandbox_async/sandbox_api.py b/packages/python-sdk/e2b/sandbox_async/sandbox_api.pyindex bd016b214..fb76841cd 100644--- a/packages/python-sdk/e2b/sandbox_async/sandbox_api.py+++ b/packages/python-sdk/e2b/sandbox_async/sandbox_api.py@@ -124,6 +124,7 @@ class SandboxApi(SandboxApiBase):template: str,timeout: int,metadata: Optional[Dict[str, str]] = None,+ env_vars: Optional[Dict[str, str]] = None,api_key: Optional[str] = None,domain: Optional[str] = None,debug: Optional[bool] = None,@@ -142,6 +143,7 @@ class SandboxApi(SandboxApiBase):template_id=template,metadata=metadata or {},timeout=timeout,+ env_vars=env_vars or {},),client=api_client,)diff --git a/packages/python-sdk/e2b/sandbox_sync/main.py b/packages/python-sdk/e2b/sandbox_sync/main.pyindex 84c2e7818..5f4e76df1 100644--- a/packages/python-sdk/e2b/sandbox_sync/main.py+++ b/packages/python-sdk/e2b/sandbox_sync/main.py@@ -57,6 +57,7 @@ class Sandbox(SandboxSetup, SandboxApi):template: Optional[str] = None,timeout: Optional[int] = None,metadata: Optional[Dict[str, str]] = None,+ env_vars: Optional[Dict[str, str]] = None,api_key: Optional[str] = None,domain: Optional[str] = None,debug: Optional[bool] = None,@@ -90,6 +91,7 @@ class Sandbox(SandboxSetup, SandboxApi):api_key=api_key,timeout=timeout,metadata=metadata,+ env_vars=env_vars,domain=domain,debug=debug,request_timeout=request_timeout,diff --git a/packages/python-sdk/e2b/sandbox_sync/sandbox_api.py b/packages/python-sdk/e2b/sandbox_sync/sandbox_api.pyindex b76c804ca..4c0a1bbbf 100644--- a/packages/python-sdk/e2b/sandbox_sync/sandbox_api.py+++ b/packages/python-sdk/e2b/sandbox_sync/sandbox_api.py@@ -127,6 +127,7 @@ class SandboxApi(SandboxApiBase):template: str,timeout: int,metadata: Optional[Dict[str, str]] = None,+ env_vars: Optional[Dict[str, str]] = None,api_key: Optional[str] = None,domain: Optional[str] = None,debug: Optional[bool] = None,@@ -145,6 +146,7 @@ class SandboxApi(SandboxApiBase):template_id=template,metadata=metadata or {},timeout=timeout,+ env_vars=env_vars or {},),client=api_client,)diff --git a/spec/envd/envd.yaml b/spec/envd/envd.yamlindex 3ff4dcc47..4b7d49f8d 100644--- a/spec/envd/envd.yaml+++ b/spec/envd/envd.yaml@@ -1,7 +1,7 @@openapi: 3.0.0info:title: envd- version: 0.1.0+ version: 0.1.1description: API for managing files' content and controlling envdtags:@@ -15,12 +15,20 @@ paths:"204":description: The service is healthy- /sync:+ /init:post:- summary: Ensure the time and metadata is synced with the host+ summary: Set env vars, ensure the time and metadata is synced with the host+ requestBody:+ content:+ application/json:+ schema:+ type: object+ properties:+ envVars:+ $ref: "#/components/schemas/EnvVars"responses:"204":- description: The time and metadata is synced with the host+ description: Env vars set, the time and metadata is synced with the host/files:get:@@ -96,7 +104,6 @@ components:content:application/json:schema:- required:type: arrayitems:$ref: "#/components/schemas/EntryInfo"@@ -169,3 +176,8 @@ components:description: Type of the fileenum:- file+ EnvVars:+ type: object+ description: Environment variables to set+ additionalProperties:+ type: stringdiff --git a/spec/openapi.yml b/spec/openapi.ymlindex a0d48fa80..98f45c846 100644--- a/spec/openapi.yml+++ b/spec/openapi.yml@@ -65,6 +65,26 @@ components:$ref: "#/components/schemas/Error"schemas:+ Team:+ required:+ - teamID+ - name+ - apiKey+ - isDefault+ properties:+ teamID:+ type: string+ description: Identifier of the team+ name:+ type: string+ description: Name of the team+ apiKey:+ type: string+ description: API key for the team+ isDefault:+ type: boolean+ description: Whether the team is the default team+CPUCount:type: integerformat: int32@@ -84,6 +104,11 @@ components:type: stringdescription: Metadata of the sandbox+ EnvVars:+ additionalProperties:+ type: string+ description: Metadata of the sandbox+SandboxLog:description: Log entry with timestamp and linerequired:@@ -139,6 +164,7 @@ components:- startedAt- cpuCount- memoryMB+ - endAtproperties:templateID:type: string@@ -156,6 +182,10 @@ components:type: stringformat: date-timedescription: Time when the sandbox was started+ endAt:+ type: string+ format: date-time+ description: Time when the sandbox will expirecpuCount:$ref: "#/components/schemas/CPUCount"memoryMB:@@ -178,6 +208,8 @@ components:description: Time to live for the sandbox in seconds.metadata:$ref: "#/components/schemas/SandboxMetadata"+ envVars:+ $ref: "#/components/schemas/SandboxMetadata"Template:required:@@ -216,6 +248,9 @@ components:dockerfile:description: Dockerfile for the templatetype: string+ teamID:+ type: string+ description: Identifier of the teamstartCmd:description: Start command to execute in the template after the buildtype: string@@ -267,6 +302,7 @@ components:tags:- name: templates- name: sandboxes+ - name: authpaths:/health:@@ -278,6 +314,27 @@ paths:"401":$ref: "#/components/responses/401"+ /teams:+ get:+ description: List all teams+ tags: [auth]+ security:+ - AccessTokenAuth: []+ responses:+ "200":+ description: Successfully returned all teams+ content:+ application/json:+ schema:+ type: array+ items:+ allOf:+ - $ref: "#/components/schemas/Team"+ "401":+ $ref: "#/components/responses/401"+ "500":+ $ref: "#/components/responses/500"+/sandboxes:get:description: List all running sandboxes@@ -418,7 +475,6 @@ paths:- ApiKeyAuth: []tags: [sandboxes]requestBody:- required: falsecontent:application/json:schema:@@ -445,6 +501,13 @@ paths:tags: [templates]security:- AccessTokenAuth: []+ parameters:+ - in: query+ required: false+ name: teamID+ schema:+ type: string+ description: Identifier of the teamresponses:"200":description: Successfully returned all templates