Skip to content

armgit / E2B

Public Imported from GitHub
0

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

Merge 'main'

Jakub Novak1d5ae303122a
diff --cc packages/cli/src/commands/template/build.ts
index da725172a,7122ae593..8ebdfb19c
--- a/packages/cli/src/commands/template/build.ts
+++ b/packages/cli/src/commands/template/build.ts
@@@ -28,7 -28,7 +28,8 @@@ import { configName, getConfigPath, loa
import * as child_process from 'child_process'
import { client } from 'src/api'
+import { handleE2BRequestError } from '../../utils/errors'
+ import { getUserConfig } from 'src/user'
const templateCheckInterval = 500 // 0.5 sec
diff --cc packages/cli/src/commands/template/delete.ts
index ebfa6fd06,3b35c728b..b71330ad5
--- a/packages/cli/src/commands/template/delete.ts
+++ b/packages/cli/src/commands/template/delete.ts
@@@ -1,8 -1,9 +1,7 @@@
import * as commander from 'commander'
import * as chalk from 'chalk'
-import * as e2b from 'e2b'
import * as fs from 'fs'
- import { ensureAccessToken, ensureUserConfig } from 'src/api'
-import { ensureAccessToken } from 'src/api'
import {
asBold,
@@@ -29,20 -25,11 +28,21 @@@ import { listSandboxTemplates } from '.
import { getPromptTemplates } from 'src/utils/templatePrompt'
import { confirm } from 'src/utils/confirm'
import { client } from 'src/api'
+import { handleE2BRequestError } from '../../utils/errors'
+ import { getUserConfig } from 'src/user'
-const deleteTemplate = e2b.withAccessToken(
- client.api.path('/templates/{templateID}').method('delete').create(),
-)
+async function deleteTemplate(templateID: string) {
+ const res = await client.api.DELETE('/templates/{templateID}', {
+ params: {
+ path: {
+ templateID,
+ },
+ },
+ })
+
+ handleE2BRequestError(res.error, 'Error deleting sandbox template')
+ return
+}
export const deleteCommand = new commander.Command('delete')
.description(`delete sandbox template and ${asLocal(configName)} config`)
@@@ -72,8 -59,9 +72,8 @@@
},
) => {
try {
- const userConfig = ensureUserConfig()
- const accessToken = ensureAccessToken()
+ let teamId = opts.team
+
- const accessToken = ensureAccessToken()
const root = getRoot(opts.path)
const templates: (Pick<E2BConfig, 'template_id'> & {
@@@ -85,10 -73,15 +85,15 @@@
template_id: template,
})
} else if (opts.select) {
+ const userConfig = getUserConfig()
+ if (userConfig) {
+ teamId = teamId || userConfig.teamId || userConfig.defaultTeamId! // default team ID is here for backwards compatibility
+ }
+
const allTemplates = await listSandboxTemplates({
- teamID: opts.team || userConfig.teamId || userConfig.defaultTeamId!, // default team ID is here for backwards compatibility
- accessToken: accessToken,
+ teamID: teamId,
})
+
const selectedTemplates = await getPromptTemplates(
allTemplates,
'Select sandbox templates to delete',
diff --cc packages/cli/src/commands/template/list.ts
index f8b158a56,0aea5560a..69ed7ed85
--- a/packages/cli/src/commands/template/list.ts
+++ b/packages/cli/src/commands/template/list.ts
@@@ -62,16 -62,8 +62,16 @@@ export const listCommand = new commande
})
export async function listSandboxTemplates({
- teamID,
- accessToken, teamID
-}: { accessToken: string, teamID?: string }): Promise<e2b.components['schemas']['Template'][]> {
- const templates = await listTemplates(accessToken, {teamID})
++ teamID
+}: {
- teamID: string
++ teamID?: string
+}): Promise<e2b.components['schemas']['Template'][]> {
+ const templates = await client.api.GET('/templates', {
+ params: {
+ query: { teamID },
+ },
+ })
+
+ handleE2BRequestError(templates.error, 'Error getting templates')
return templates.data
}