Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Fix CLI compilation (#747)
Jakub Dobry4ffb21115586
diff --git a/packages/cli/src/commands/auth/configure.ts b/packages/cli/src/commands/auth/configure.tsindex b27629aa7..c7bd2e6b3 100644--- a/packages/cli/src/commands/auth/configure.ts+++ b/packages/cli/src/commands/auth/configure.ts@@ -5,12 +5,7 @@ import * as e2b from 'e2b'import * as path from 'path'import { USER_CONFIG_PATH } from 'src/user'-import {- client,- connectionConfig,- ensureAccessToken,- ensureUserConfig,-} from 'src/api'+import { client, connectionConfig, ensureAccessToken, ensureUserConfig } from 'src/api'import { asBold, asFormattedTeam } from '../../utils/format'import { handleE2BRequestError } from '../../utils/errors'@@ -32,7 +27,7 @@ export const configureCommand = new commander.Command('configure')const res = await client.api.GET('/teams', { signal })- handleE2BRequestError(res.error, 'Error getting teams')+ handleE2BRequestError(res, 'Error getting teams')const team = (await inquirer.default.prompt([diff --git a/packages/cli/src/commands/auth/login.ts b/packages/cli/src/commands/auth/login.tsindex 32ed48efe..d14d2fc84 100644--- a/packages/cli/src/commands/auth/login.ts+++ b/packages/cli/src/commands/auth/login.ts@@ -52,7 +52,7 @@ export const loginCommand = new commander.Command('login')const client = new e2b.ApiClient(config)const res = await client.api.GET('/teams', { signal })- handleE2BRequestError(res.error, 'Error getting teams')+ handleE2BRequestError(res, 'Error getting teams')const defaultTeam = res.data.find((team: e2b.components['schemas']['Team']) => team.isDefaultdiff --git a/packages/cli/src/commands/sandbox/list.ts b/packages/cli/src/commands/sandbox/list.tsindex 6eea00107..100ee261b 100644--- a/packages/cli/src/commands/sandbox/list.ts+++ b/packages/cli/src/commands/sandbox/list.ts@@ -2,7 +2,7 @@ import * as tablePrinter from 'console-table-printer'import * as commander from 'commander'import * as e2b from 'e2b'-import { ensureAPIKey, client, connectionConfig } from 'src/api'+import { client, connectionConfig, ensureAPIKey } from 'src/api'import { handleE2BRequestError } from '../../utils/errors'export const listCommand = new commander.Command('list')@@ -89,7 +89,7 @@ export async function listSandboxes(): Promise<const signal = connectionConfig.getSignal()const res = await client.api.GET('/sandboxes', { signal })- handleE2BRequestError(res.error, 'Error getting running sandboxes')+ handleE2BRequestError(res, 'Error getting running sandboxes')return res.data}diff --git a/packages/cli/src/commands/sandbox/logs.ts b/packages/cli/src/commands/sandbox/logs.tsindex 28f916357..846259e43 100644--- a/packages/cli/src/commands/sandbox/logs.ts+++ b/packages/cli/src/commands/sandbox/logs.ts@@ -311,7 +311,7 @@ export async function listSandboxLogs({},})- handleE2BRequestError(res.error, 'Error while getting sandbox logs')+ handleE2BRequestError(res, 'Error while getting sandbox logs')return res.data.logs}diff --git a/packages/cli/src/commands/template/build.ts b/packages/cli/src/commands/template/build.tsindex cbdc87d7f..b4eaa7ecb 100644--- a/packages/cli/src/commands/template/build.ts+++ b/packages/cli/src/commands/template/build.ts@@ -6,7 +6,7 @@ import * as stripAnsi from 'strip-ansi'import * as boxen from 'boxen'import commandExists from 'command-exists'import { wait } from 'src/utils/wait'-import { connectionConfig, ensureAccessToken } from 'src/api'+import { client, connectionConfig, ensureAccessToken } from 'src/api'import { getRoot } from 'src/utils/filesystem'import {asBold,@@ -20,14 +20,9 @@ import {withDelimiter,} from 'src/utils/format'import { configOption, pathOption, teamOption } from 'src/options'-import {- defaultDockerfileName,- fallbackDockerfileName,-} from 'src/docker/constants'+import { defaultDockerfileName, fallbackDockerfileName } from 'src/docker/constants'import { configName, getConfigPath, loadConfig, saveConfig } from 'src/config'import * as child_process from 'child_process'--import { client } from 'src/api'import { handleE2BRequestError } from '../../utils/errors'import { getUserConfig } from 'src/user'import { buildWithProxy } from './buildWithProxy'@@ -60,12 +55,12 @@ async function getTemplateBuildLogs({})- handleE2BRequestError(res.error, 'Error getting template build status')+ handleE2BRequestError(res, 'Error getting template build status')return res.data as e2b.paths['/templates/{templateID}/builds/{buildID}/status']['get']['responses']['200']['content']['application/json']}async function requestTemplateBuild(- args?: e2b.paths['/templates']['post']['requestBody']['content']['application/json']+ args: e2b.paths['/templates']['post']['requestBody']['content']['application/json']) {return await client.api.POST('/templates', {body: args,@@ -74,7 +69,7 @@ async function requestTemplateBuild(async function requestTemplateRebuild(templateID: string,- args?: e2b.paths['/templates/{templateID}']['post']['requestBody']['content']['application/json']+ args: e2b.paths['/templates/{templateID}']['post']['requestBody']['content']['application/json']) {return await client.api.POST('/templates/{templateID}', {body: args,@@ -118,8 +113,8 @@ async function triggerTemplateBuild(templateID: string, buildID: string) {throw new Error('Error triggering template build')}- handleE2BRequestError(res?.error, 'Error triggering template build')- return res?.data+ handleE2BRequestError(res, 'Error triggering template build')+ return res.data}export const buildCommand = new commander.Command('build')@@ -605,7 +600,7 @@ async function requestBuildTemplate(res = await requestTemplateBuild(args)}- handleE2BRequestError(res.error, 'Error requesting template build')+ handleE2BRequestError(res, 'Error requesting template build')return res.data}diff --git a/packages/cli/src/commands/template/delete.ts b/packages/cli/src/commands/template/delete.tsindex b71330ad5..69534d098 100644--- a/packages/cli/src/commands/template/delete.ts+++ b/packages/cli/src/commands/template/delete.ts@@ -40,7 +40,7 @@ async function deleteTemplate(templateID: string) {},})- handleE2BRequestError(res.error, 'Error deleting sandbox template')+ handleE2BRequestError(res, 'Error deleting sandbox template')return}diff --git a/packages/cli/src/commands/template/list.ts b/packages/cli/src/commands/template/list.tsindex 46666944f..d9a4c1205 100644--- a/packages/cli/src/commands/template/list.ts+++ b/packages/cli/src/commands/template/list.ts@@ -107,6 +107,6 @@ export async function listSandboxTemplates({},})- handleE2BRequestError(templates.error, 'Error getting templates')+ handleE2BRequestError(templates, 'Error getting templates')return templates.data}diff --git a/packages/cli/src/commands/template/publish.ts b/packages/cli/src/commands/template/publish.tsindex 47cb5cefc..2058d433c 100644--- a/packages/cli/src/commands/template/publish.ts+++ b/packages/cli/src/commands/template/publish.ts@@ -2,20 +2,9 @@ import * as commander from 'commander'import * as chalk from 'chalk'import * as fs from 'fs'-import {- asBold,- asFormattedError,- asFormattedSandboxTemplate,- asLocal,- asLocalRelative,-} from 'src/utils/format'-import {- configOption,- pathOption,- selectMultipleOption,- teamOption,-} from 'src/options'-import { E2BConfig, configName, getConfigPath, loadConfig } from 'src/config'+import { asBold, asFormattedError, asFormattedSandboxTemplate, asLocal, asLocalRelative } from 'src/utils/format'+import { configOption, pathOption, selectMultipleOption, teamOption } from 'src/options'+import { configName, E2BConfig, getConfigPath, loadConfig } from 'src/config'import { getRoot } from 'src/utils/filesystem'import { listSandboxTemplates } from './list'import { getPromptTemplates } from 'src/utils/templatePrompt'@@ -37,7 +26,7 @@ async function publishTemplate(templateID: string, publish: boolean) {})handleE2BRequestError(- res.error,+ res,`Error ${publish ? 'publishing' : 'unpublishing'} sandbox template`)returndiff --git a/packages/cli/src/utils/errors.ts b/packages/cli/src/utils/errors.tsindex 0974f474f..f5840c4c2 100644--- a/packages/cli/src/utils/errors.ts+++ b/packages/cli/src/utils/errors.ts@@ -8,16 +8,17 @@ export class E2BRequestError extends Error {}}-export function handleE2BRequestError(- err?: { code: number; message: string },+export function handleE2BRequestError<T>(+ res: { data?: T | null | undefined; error?: { code: number; message: string } },errMsg?: string,-) {- if (!err) {+): asserts res is { data: T; error?: undefined } {+ if (!res.error && res.data != null) {return}- let message = ''- switch (err.code) {+ let message = 'unknown error'+ const code = res.error?.code ?? 0+ switch (code) {case 400:message = 'bad request'break@@ -36,8 +37,8 @@ export function handleE2BRequestError(}throw new E2BRequestError(- `${errMsg && `${errMsg}: `}[${err.code}] ${message && `${message}: `}${- err.message ?? 'no message'+ `${errMsg && `${errMsg}: `}[${code}] ${message && `${message}: `}${+ res.error?.message ?? 'no message'}`,)}diff --git a/packages/js-sdk/src/api/schema.gen.ts b/packages/js-sdk/src/api/schema.gen.tsindex 1107f25d3..82954ee37 100644--- a/packages/js-sdk/src/api/schema.gen.ts+++ b/packages/js-sdk/src/api/schema.gen.ts@@ -446,6 +446,44 @@ export interface paths {patch?: never;trace?: never;};+ "/teams": {+ parameters: {+ query?: never;+ header?: never;+ path?: never;+ cookie?: never;+ };+ /** @description List all teams */+ get: {+ parameters: {+ query?: never;+ header?: never;+ path?: never;+ cookie?: never;+ };+ requestBody?: never;+ responses: {+ /** @description Successfully returned all teams */+ 200: {+ headers: {+ [name: string]: unknown;+ };+ content: {+ "application/json": components["schemas"]["Team"][];+ };+ };+ 401: components["responses"]["401"];+ 500: components["responses"]["500"];+ };+ };+ put?: never;+ post?: never;+ delete?: never;+ options?: never;+ head?: never;+ patch?: never;+ trace?: never;+ };"/templates": {parameters: {query?: never;