Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Deprecate spawn instead of remove (#885)
Jakub Novák99b9ed768d40
diff --git a/.changeset/perfect-sheep-type.md b/.changeset/perfect-sheep-type.mdnew file mode 100644index 000000000..3c175e52b--- /dev/null+++ b/.changeset/perfect-sheep-type.md@@ -0,0 +1,5 @@+---+'@e2b/cli': patch+---++Add deprecated spawn commanddiff --git a/packages/cli/src/commands/sandbox/create.ts b/packages/cli/src/commands/sandbox/create.tsindex e60057878..3bde93783 100644--- a/packages/cli/src/commands/sandbox/create.ts+++ b/packages/cli/src/commands/sandbox/create.ts@@ -10,66 +10,77 @@ import { getConfigPath, loadConfig } from '../../config'import fs from 'fs'import { configOption, pathOption } from '../../options'-export const createCommand = new commander.Command('create')- .description('create sandbox and connect terminal to it')- .argument(- '[template]',- `create and connect to sandbox specified by ${asBold('[template]')}`- )- .addOption(pathOption)- .addOption(configOption)- .alias('cr')- .action(- async (- template: string | undefined,- opts: {- name?: string- path?: string- config?: string- }- ) => {- try {- const apiKey = ensureAPIKey()- let templateID = template+export function createCommand(+ name: string,+ alias: string,+ deprecated: boolean+) {+ return new commander.Command(name)+ .description('create sandbox and connect terminal to it')+ .argument(+ '[template]',+ `create and connect to sandbox specified by ${asBold('[template]')}`+ )+ .addOption(pathOption)+ .addOption(configOption)+ .alias(alias)+ .action(+ async (+ template: string | undefined,+ opts: {+ name?: string+ path?: string+ config?: string+ }+ ) => {+ if (deprecated) {+ console.warn(+ `Warning: The '${name}' command is deprecated and will be removed in future releases. Please use 'e2b sandbox create' instead.`+ )+ }+ try {+ const apiKey = ensureAPIKey()+ let templateID = template- const root = getRoot(opts.path)- const configPath = getConfigPath(root, opts.config)+ const root = getRoot(opts.path)+ const configPath = getConfigPath(root, opts.config)- const config = fs.existsSync(configPath)- ? await loadConfig(configPath)- : undefined- const relativeConfigPath = path.relative(root, configPath)+ const config = fs.existsSync(configPath)+ ? await loadConfig(configPath)+ : undefined+ const relativeConfigPath = path.relative(root, configPath)- if (!templateID && config) {- console.log(- `Found sandbox template ${asFormattedSandboxTemplate(- {- templateID: config.template_id,- aliases: config.template_name- ? [config.template_name]- : undefined,- },- relativeConfigPath- )}`- )- templateID = config.template_id- }+ if (!templateID && config) {+ console.log(+ `Found sandbox template ${asFormattedSandboxTemplate(+ {+ templateID: config.template_id,+ aliases: config.template_name+ ? [config.template_name]+ : undefined,+ },+ relativeConfigPath+ )}`+ )+ templateID = config.template_id+ }- if (!templateID) {- console.error(- 'You need to specify sandbox template ID or path to sandbox template config'- )+ if (!templateID) {+ console.error(+ 'You need to specify sandbox template ID or path to sandbox template config'+ )+ process.exit(1)+ }++ await connectSandbox({ apiKey, template: { templateID } })+ process.exit(0)+ } catch (err: any) {+ console.error(err)process.exit(1)}-- await connectSandbox({ apiKey, template: { templateID } })- process.exit(0)- } catch (err: any) {- console.error(err)- process.exit(1)}- }- )+ )+}export async function connectSandbox({apiKey,diff --git a/packages/cli/src/commands/sandbox/index.ts b/packages/cli/src/commands/sandbox/index.tsindex a911cdcba..0e29368ad 100644--- a/packages/cli/src/commands/sandbox/index.ts+++ b/packages/cli/src/commands/sandbox/index.ts@@ -13,6 +13,7 @@ export const sandboxCommand = new commander.Command('sandbox').addCommand(connectCommand).addCommand(listCommand).addCommand(killCommand)- .addCommand(createCommand)+ .addCommand(createCommand('create', 'cr', false))+ .addCommand(createCommand('spawn', 'sp', true), { hidden: true }).addCommand(logsCommand).addCommand(metricsCommand)