Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Don't require user config if not really needed
Jakub Novak7ad5182c2752
diff --git a/.changeset/silly-garlics-design.md b/.changeset/silly-garlics-design.mdnew file mode 100644index 000000000..ef8d06328--- /dev/null+++ b/.changeset/silly-garlics-design.md@@ -0,0 +1,5 @@+---+"@e2b/cli": patch+---++Fix config bug in template builddiff --git a/packages/cli/src/commands/template/build.ts b/packages/cli/src/commands/template/build.tsindex 74fdb766d..7122ae593 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 { ensureAccessToken, ensureUserConfig } from 'src/api'+import { ensureAccessToken } from 'src/api'import { getRoot } from 'src/utils/filesystem'import {asBold,@@ -28,6 +28,7 @@ import { configName, getConfigPath, loadConfig, saveConfig } from 'src/config'import * as child_process from 'child_process'import { client } from 'src/api'+import { getUserConfig } from 'src/user'const templateCheckInterval = 500 // 0.5 sec@@ -138,8 +139,6 @@ export const buildCommand = new commander.Command('build')}const accessToken = ensureAccessToken()- const userConfig = ensureUserConfig()-process.stdout.write('\n')const newName = opts.name?.trim()@@ -186,7 +185,11 @@ export const buildCommand = new commander.Command('build')memoryMB = opts.memoryMb || config.memory_mbteamID = opts.team || config.team_id}- teamID = teamID || userConfig.teamId++ const userConfig = getUserConfig()+ if (userConfig) {+ teamID = teamID || userConfig.teamId+ }if (config && templateID && config.template_id !== templateID) {// error: you can't specify different ID than the one in configdiff --git a/packages/cli/src/commands/template/delete.ts b/packages/cli/src/commands/template/delete.tsindex 3bd3379be..3b35c728b 100644--- a/packages/cli/src/commands/template/delete.ts+++ b/packages/cli/src/commands/template/delete.ts@@ -3,7 +3,7 @@ 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,@@ -25,6 +25,7 @@ import { listSandboxTemplates } from './list'import { getPromptTemplates } from 'src/utils/templatePrompt'import { confirm } from 'src/utils/confirm'import { client } from 'src/api'+import { getUserConfig } from 'src/user'const deleteTemplate = e2b.withAccessToken(client.api.path('/templates/{templateID}').method('delete').create(),@@ -58,7 +59,8 @@ export const deleteCommand = new commander.Command('delete')},) => {try {- const userConfig = ensureUserConfig()+ let teamId = opts.team+const accessToken = ensureAccessToken()const root = getRoot(opts.path)@@ -71,9 +73,14 @@ export const deleteCommand = new commander.Command('delete')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({accessToken: accessToken,- teamID: opts.team || userConfig.teamId || userConfig.defaultTeamId! // default team ID is here for backwards compatibility+ teamID: teamId,})const selectedTemplates = await getPromptTemplates(allTemplates,diff --git a/packages/cli/src/commands/template/list.ts b/packages/cli/src/commands/template/list.tsindex e33916624..0aea5560a 100644--- a/packages/cli/src/commands/template/list.ts+++ b/packages/cli/src/commands/template/list.ts@@ -63,7 +63,7 @@ export const listCommand = new commander.Command('list')export async function listSandboxTemplates({accessToken, teamID-}: { accessToken: string, teamID: string }): Promise<e2b.components['schemas']['Template'][]> {+}: { accessToken: string, teamID?: string }): Promise<e2b.components['schemas']['Template'][]> {const templates = await listTemplates(accessToken, {teamID})return templates.data}