Skip to content

armgit / E2B

Public Imported from GitHub
0

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

Add teams endpoint

Jakub Novak3485e74d384c
diff --git a/packages/js-sdk/src/api/schema.gen.ts b/packages/js-sdk/src/api/schema.gen.ts
index 747c1d6a0..b69500ff5 100644
--- a/packages/js-sdk/src/api/schema.gen.ts
+++ b/packages/js-sdk/src/api/schema.gen.ts
@@ -14,6 +14,21 @@ export interface paths {
};
};
};
+ "/teams": {
+ /** List all teams */
+ get: {
+ responses: {
+ /** Successfully returned all teams */
+ 200: {
+ content: {
+ "application/json": components["schemas"]["Team"][];
+ };
+ };
+ 401: components["responses"]["401"];
+ 500: components["responses"]["500"];
+ };
+ };
+ };
"/sandboxes": {
/** List all running sandboxes */
get: {
@@ -21,7 +36,7 @@ export interface paths {
/** Successfully returned all running sandboxes */
200: {
content: {
- "application/json": components["schemas"]["RunningSandboxes"][];
+ "application/json": components["schemas"]["RunningSandbox"][];
};
};
400: components["responses"]["400"];
@@ -57,7 +72,7 @@ export interface paths {
sandboxID: components["parameters"]["sandboxID"];
};
query: {
- /** Starting timestamp of the logs that should be returned */
+ /** Starting timestamp of the logs that should be returned in milliseconds */
start?: number;
/** Maximum number of logs that should be returned */
limit?: number;
@@ -93,6 +108,34 @@ export interface paths {
};
};
};
+ "/sandboxes/{sandboxID}/timeout": {
+ /** Set the timeout for the sandbox. The sandbox will expire x seconds from the time of the request. Calling this method multiple times overwrites the TTL, each time using the current timestamp as the starting point to measure the timeout duration. */
+ post: {
+ parameters: {
+ path: {
+ sandboxID: components["parameters"]["sandboxID"];
+ };
+ };
+ responses: {
+ /** Successfully set the sandbox timeout */
+ 204: never;
+ 401: components["responses"]["401"];
+ 404: components["responses"]["404"];
+ 500: components["responses"]["500"];
+ };
+ requestBody: {
+ content: {
+ "application/json": {
+ /**
+ * Format: int32
+ * @description Timeout in seconds from the current time after which the sandbox should expire
+ */
+ timeout: number;
+ };
+ };
+ };
+ };
+ };
"/sandboxes/{sandboxID}/refreshes": {
/** Refresh the sandbox extending its time to live */
post: {
@@ -130,6 +173,11 @@ export interface paths {
401: components["responses"]["401"];
500: components["responses"]["500"];
};
+ requestBody: {
+ content: {
+ "application/json": components["schemas"]["TemplatesListRequest"];
+ };
+ };
};
/** Create a new template */
post: {
@@ -206,32 +254,6 @@ export interface paths {
};
};
};
- "/templates/{templateID}/builds/{buildID}/logs": {
- /** Add a build log */
- post: {
- parameters: {
- path: {
- templateID: components["parameters"]["templateID"];
- buildID: components["parameters"]["buildID"];
- };
- };
- responses: {
- /** Successfully added log */
- 201: unknown;
- 401: components["responses"]["401"];
- 404: components["responses"]["404"];
- };
- requestBody: {
- content: {
- "application/json": {
- /** @description API secret */
- apiSecret: string;
- logs: string[];
- };
- };
- };
- };
- };
"/templates/{templateID}/builds/{buildID}/status": {
/** Get template build info */
get: {
@@ -262,6 +284,26 @@ export interface paths {
export interface components {
schemas: {
+ Team: {
+ /** @description Identifier of the team */
+ teamID: string;
+ /** @description Name of the team */
+ name: string;
+ /** @description API key for the team */
+ apiKey: string;
+ /** @description Whether the team is the default team */
+ isDefault: boolean;
+ };
+ /**
+ * Format: int32
+ * @description CPU cores for the sandbox
+ */
+ CPUCount: number;
+ /**
+ * Format: int32
+ * @description Memory for the sandbox in MB
+ */
+ MemoryMB: number;
SandboxMetadata: { [key: string]: string };
/** @description Log entry with timestamp and line */
SandboxLog: {
@@ -286,8 +328,10 @@ export interface components {
alias?: string;
/** @description Identifier of the client */
clientID: string;
+ /** @description Version of the envd running in the sandbox */
+ envdVersion: string;
};
- RunningSandboxes: {
+ RunningSandbox: {
/** @description Identifier of the template from which is the sandbox created */
templateID: string;
/** @description Alias of the template */
@@ -301,15 +345,19 @@ export interface components {
* @description Time when the sandbox was started
*/
startedAt: string;
- /** @description CPU cores for the sandbox */
- cpuCount: number;
- /** @description Memory limit for the sandbox in MB */
- memoryMB: number;
+ cpuCount: components["schemas"]["CPUCount"];
+ memoryMB: components["schemas"]["MemoryMB"];
metadata?: components["schemas"]["SandboxMetadata"];
};
NewSandbox: {
/** @description Identifier of the required template */
templateID: string;
+ /**
+ * Format: int32
+ * @description Time to live for the sandbox in seconds.
+ * @default 15
+ */
+ timeout?: number;
metadata?: components["schemas"]["SandboxMetadata"];
};
Template: {
@@ -317,28 +365,28 @@ export interface components {
templateID: string;
/** @description Identifier of the last successful build for given template */
buildID: string;
- /** @description CPU cores for the sandbox */
- cpuCount: number;
- /** @description Memory limit for the sandbox in MB */
- memoryMB: number;
+ cpuCount: components["schemas"]["CPUCount"];
+ memoryMB: components["schemas"]["MemoryMB"];
/** @description Whether the template is public or only accessible by the team */
public: boolean;
/** @description Aliases of the template */
aliases?: string[];
- } & {
- storageGB: unknown;
};
TemplateBuildRequest: {
/** @description Alias of the template */
alias?: string;
/** @description Dockerfile for the template */
dockerfile: string;
+ /** @description Identifier of the team */
+ teamID?: string;
/** @description Start command to execute in the template after the build */
startCmd?: string;
- /** @description CPU cores for the template */
- cpuCount?: number;
- /** @description Memory limit for the template in MB */
- memoryMB?: number;
+ cpuCount?: components["schemas"]["CPUCount"];
+ memoryMB?: components["schemas"]["MemoryMB"];
+ };
+ TemplatesListRequest: {
+ /** @description Identifier of the team */
+ teamID: string;
};
TemplateBuild: {
/**
@@ -354,9 +402,7 @@ export interface components {
* @description Status of the template
* @enum {string}
*/
- status?: "building" | "ready" | "error";
- } & {
- finished: unknown;
+ status: "building" | "ready" | "error";
};
Error: {
/**
diff --git a/packages/js-sdk/src/sandbox/index.ts b/packages/js-sdk/src/sandbox/index.ts
index f12c6fe76..b757e4558 100644
--- a/packages/js-sdk/src/sandbox/index.ts
+++ b/packages/js-sdk/src/sandbox/index.ts
@@ -518,7 +518,7 @@ export class Sandbox extends SandboxConnection {
const sandboxIDAndClientID = id.split('-')
const sandboxID = sandboxIDAndClientID[0]
const clientID = sandboxIDAndClientID[1]
- opts.__sandbox = { sandboxID, clientID, templateID: 'unknown' }
+ opts.__sandbox = { sandboxID, clientID, templateID: 'unknown', envdVersion: 'unknown' }
const sandbox = new this(opts, true) as InstanceType<S>
await sandbox._open({ timeout: opts?.timeout })
diff --git a/spec/openapi.yml b/spec/openapi.yml
index 8fdbb8b15..e2963f994 100644
--- a/spec/openapi.yml
+++ b/spec/openapi.yml
@@ -38,26 +38,26 @@ components:
type: string
responses:
- 400:
+ "400":
description: Bad request
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
- 401:
+ "401":
description: Authentication error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
- 404:
+ "404":
description: Not found
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
- 500:
+ "500":
description: Server error
content:
application/json:
@@ -65,6 +65,40 @@ 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: integer
+ format: int32
+ minimum: 1
+ maximum: 8
+ description: CPU cores for the sandbox
+
+ MemoryMB:
+ type: integer
+ format: int32
+ minimum: 128
+ maximum: 8192
+ description: Memory for the sandbox in MB
+
SandboxMetadata:
additionalProperties:
type: string
@@ -99,6 +133,7 @@ components:
- templateID
- sandboxID
- clientID
+ - envdVersion
properties:
templateID:
type: string
@@ -112,8 +147,11 @@ components:
clientID:
type: string
description: Identifier of the client
+ envdVersion:
+ type: string
+ description: Version of the envd running in the sandbox
- RunningSandboxes:
+ RunningSandbox:
required:
- templateID
- sandboxID
@@ -139,11 +177,9 @@ components:
format: date-time
description: Time when the sandbox was started
cpuCount:
- type: integer
- description: CPU cores for the sandbox
+ $ref: "#/components/schemas/CPUCount"
memoryMB:
- type: integer
- description: Memory limit for the sandbox in MB
+ $ref: "#/components/schemas/MemoryMB"
metadata:
$ref: "#/components/schemas/SandboxMetadata"
@@ -154,6 +190,12 @@ components:
templateID:
type: string
description: Identifier of the required template
+ timeout:
+ type: integer
+ format: int32
+ minimum: 0
+ default: 15
+ description: Time to live for the sandbox in seconds.
metadata:
$ref: "#/components/schemas/SandboxMetadata"
@@ -163,7 +205,6 @@ components:
- buildID
- cpuCount
- memoryMB
- - storageGB
- public
properties:
templateID:
@@ -173,11 +214,9 @@ components:
type: string
description: Identifier of the last successful build for given template
cpuCount:
- type: integer
- description: CPU cores for the sandbox
+ $ref: "#/components/schemas/CPUCount"
memoryMB:
- type: integer
- description: Memory limit for the sandbox in MB
+ $ref: "#/components/schemas/MemoryMB"
public:
type: boolean
description: Whether the template is public or only accessible by the team
@@ -197,23 +236,30 @@ components:
dockerfile:
description: Dockerfile for the template
type: string
+ teamID:
+ type: string
+ description: Identifier of the team
startCmd:
description: Start command to execute in the template after the build
type: string
cpuCount:
- description: CPU cores for the template
- type: integer
- minimum: 1
+ $ref: "#/components/schemas/CPUCount"
memoryMB:
- description: Memory limit for the template in MB
- type: integer
- minimum: 128
+ $ref: "#/components/schemas/MemoryMB"
+
+ TemplatesListRequest:
+ required:
+ - teamID
+ properties:
+ teamID:
+ type: string
+ description: Identifier of the team
TemplateBuild:
required:
- templateID
- buildID
- - finished
+ - status
- logs
properties:
logs:
@@ -252,16 +298,38 @@ components:
tags:
- name: templates
- name: sandboxes
+ - name: auth
paths:
/health:
get:
description: Health check
responses:
- 200:
+ "200":
description: Request was successful
- 401:
+ "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:
@@ -270,7 +338,7 @@ paths:
security:
- ApiKeyAuth: []
responses:
- 200:
+ "200":
description: Successfully returned all running sandboxes
content:
application/json:
@@ -278,12 +346,12 @@ paths:
type: array
items:
allOf:
- - $ref: "#/components/schemas/RunningSandboxes"
- 401:
+ - $ref: "#/components/schemas/RunningSandbox"
+ "401":
$ref: "#/components/responses/401"
- 400:
+ "400":
$ref: "#/components/responses/400"
- 500:
+ "500":
$ref: "#/components/responses/500"
post:
description: Create a sandbox from the template
@@ -297,17 +365,17 @@ paths:
schema:
$ref: "#/components/schemas/NewSandbox"
responses:
- 201:
+ "201":
description: The sandbox was created successfully
content:
application/json:
schema:
$ref: "#/components/schemas/Sandbox"
- 401:
+ "401":
$ref: "#/components/responses/401"
- 400:
+ "400":
$ref: "#/components/responses/400"
- 500:
+ "500":
$ref: "#/components/responses/500"
/sandboxes/{sandboxID}/logs:
@@ -322,25 +390,29 @@ paths:
name: start
schema:
type: integer
+ format: int64
+ minimum: 0
description: Starting timestamp of the logs that should be returned in milliseconds
- in: query
name: limit
schema:
default: 1000
+ format: int32
+ minimum: 0
type: integer
description: Maximum number of logs that should be returned
responses:
- 200:
+ "200":
description: Successfully returned the sandbox logs
content:
application/json:
schema:
$ref: "#/components/schemas/SandboxLogs"
- 404:
+ "404":
$ref: "#/components/responses/404"
- 401:
+ "401":
$ref: "#/components/responses/401"
- 500:
+ "500":
$ref: "#/components/responses/500"
/sandboxes/{sandboxID}:
@@ -352,13 +424,44 @@ paths:
parameters:
- $ref: "#/components/parameters/sandboxID"
responses:
- 204:
+ "204":
description: The sandbox was killed successfully
- 404:
+ "404":
$ref: "#/components/responses/404"
- 401:
+ "401":
$ref: "#/components/responses/401"
- 500:
+ "500":
+ $ref: "#/components/responses/500"
+
+ /sandboxes/{sandboxID}/timeout:
+ post:
+ description: Set the timeout for the sandbox. The sandbox will expire x seconds from the time of the request. Calling this method multiple times overwrites the TTL, each time using the current timestamp as the starting point to measure the timeout duration.
+ security:
+ - ApiKeyAuth: []
+ tags: [sandboxes]
+ requestBody:
+ content:
+ application/json:
+ schema:
+ type: object
+ required:
+ - timeout
+ properties:
+ timeout:
+ description: Timeout in seconds from the current time after which the sandbox should expire
+ type: integer
+ format: int32
+ minimum: 0
+ parameters:
+ - $ref: "#/components/parameters/sandboxID"
+ responses:
+ "204":
+ description: Successfully set the sandbox timeout
+ "401":
+ $ref: "#/components/responses/401"
+ "404":
+ $ref: "#/components/responses/404"
+ "500":
$ref: "#/components/responses/500"
/sandboxes/{sandboxID}/refreshes:
@@ -368,7 +471,6 @@ paths:
- ApiKeyAuth: []
tags: [sandboxes]
requestBody:
- required: false
content:
application/json:
schema:
@@ -382,11 +484,11 @@ paths:
parameters:
- $ref: "#/components/parameters/sandboxID"
responses:
- 204:
+ "204":
description: Successfully refreshed the sandbox
- 401:
+ "401":
$ref: "#/components/responses/401"
- 404:
+ "404":
$ref: "#/components/responses/404"
/templates:
@@ -395,8 +497,15 @@ paths:
tags: [templates]
security:
- AccessTokenAuth: []
+ requestBody:
+ required: false
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/TemplatesListRequest"
+
responses:
- 200:
+ "200":
description: Successfully returned all templates
content:
application/json:
@@ -405,9 +514,9 @@ paths:
items:
allOf:
- $ref: "#/components/schemas/Template"
- 401:
+ "401":
$ref: "#/components/responses/401"
- 500:
+ "500":
$ref: "#/components/responses/500"
post:
description: Create a new template
@@ -422,15 +531,15 @@ paths:
$ref: "#/components/schemas/TemplateBuildRequest"
responses:
- 202:
+ "202":
description: The build was accepted
content:
application/json:
schema:
$ref: "#/components/schemas/Template"
- 401:
+ "401":
$ref: "#/components/responses/401"
- 500:
+ "500":
$ref: "#/components/responses/500"
/templates/{templateID}:
@@ -449,15 +558,15 @@ paths:
$ref: "#/components/schemas/TemplateBuildRequest"
responses:
- 202:
+ "202":
description: The build was accepted
content:
application/json:
schema:
$ref: "#/components/schemas/Template"
- 401:
+ "401":
$ref: "#/components/responses/401"
- 500:
+ "500":
$ref: "#/components/responses/500"
delete:
description: Delete a template
@@ -467,11 +576,11 @@ paths:
parameters:
- $ref: "#/components/parameters/templateID"
responses:
- 204:
+ "204":
description: The template was deleted successfully
- 401:
+ "401":
$ref: "#/components/responses/401"
- 500:
+ "500":
$ref: "#/components/responses/500"
/templates/{templateID}/builds/{buildID}:
@@ -484,45 +593,13 @@ paths:
- $ref: "#/components/parameters/templateID"
- $ref: "#/components/parameters/buildID"
responses:
- 202:
+ "202":
description: The build has started
- 401:
+ "401":
$ref: "#/components/responses/401"
- 500:
+ "500":
$ref: "#/components/responses/500"
- /templates/{templateID}/builds/{buildID}/logs:
- post:
- description: Add a build log
- tags: [templates]
- parameters:
- - $ref: "#/components/parameters/templateID"
- - $ref: "#/components/parameters/buildID"
- requestBody:
- required: true
- content:
- application/json:
- schema:
- type: object
- required:
- - apiSecret
- - logs
- properties:
- apiSecret:
- description: API secret
- type: string
- logs:
- type: array
- items:
- type: string
- responses:
- 201:
- description: Successfully added log
- 401:
- $ref: "#/components/responses/401"
- 404:
- $ref: "#/components/responses/404"
-
/templates/{templateID}/builds/{buildID}/status:
get:
description: Get template build info
@@ -537,17 +614,19 @@ paths:
schema:
default: 0
type: integer
+ format: int32
+ minimum: 0
description: Index of the starting build log that should be returned with the template
responses:
- 200:
+ "200":
description: Successfully returned the template
content:
application/json:
schema:
$ref: "#/components/schemas/TemplateBuild"
- 401:
+ "401":
$ref: "#/components/responses/401"
- 404:
+ "404":
$ref: "#/components/responses/404"
- 500:
+ "500":
$ref: "#/components/responses/500"