Commit Graph

382 Commits

Author SHA1 Message Date
github-actions[bot] 06aeae6a01 [skip ci] Release new versions 2025-10-27 18:52:30 +00:00
Mish Ushakov ad194b4f4a CLI migrate: Rename old template files no longer needed (#991)
Here's what it will look like. This highlights that the files are no
longer used.

```
🔄 Migrating template configuration to SDK format...

Using language: TypeScript

 Generated TypeScript template files:
   ./template.ts
   ./build.dev.ts
   ./build.prod.ts

📁 Old template files no longer needed:
   ./e2b.Dockerfile → ./e2b.Dockerfile.old
   ./e2b.toml → ./e2b.toml.old

🎉 Migration completed successfully!

🔨 You can now build your template using:
   npx tsx build.dev.ts (for development)
   npx tsx build.prod.ts (for production)

Learn more about Template SDK: https://e2b.dev/docs
```



<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Post-migration, the CLI renames `e2b.Dockerfile` and `e2b.toml` to
`.old` and refactors migration to use Dockerfile content directly.
> 
> - **CLI Template Migration
(`packages/cli/src/commands/template/migrate.ts`)**
> - **Refactor**: `migrateToLanguage` now accepts `dockerfileContent`
(string) instead of a path; Dockerfile retrieval moved to the command
action via `getDockerfile`.
> - **Post-migration cleanup**: Renames `e2b.Dockerfile` and `e2b.toml`
to `*.old` if present and logs old→new paths.
>   - Minor output tweaks (status messages/icons).
> - **Tests (`packages/cli/tests/commands/template/migrate.test.ts`)**
> - Add checks ensuring `e2b.Dockerfile.old` and `e2b.toml.old` exist
and originals are removed across fixtures/languages.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
5fc1add2ac8e688b7509c299211b53ac6b09188e. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
2025-10-27 09:31:07 -07:00
github-actions[bot] 5df9090f57 [skip ci] Release new versions 2025-10-20 22:16:19 +00:00
github-actions[bot] 546a2282fa [skip ci] Release new versions 2025-10-17 17:08:22 +00:00
Jonas Scholz 057f9027f0 Fix e2b tpl publish/delete --config flag (#968) 2025-10-17 10:04:21 -07:00
Jakub Dobry c2cc1469f6 fix: CLI tests setup (#969) 2025-10-17 05:03:18 -07:00
github-actions[bot] ace327e948 [skip ci] Release new versions 2025-10-16 11:50:51 +00:00
Jakub Dobry c05c8c6f24 Build System v2 Introduction (#957) 2025-10-16 04:41:21 -07:00
Jakub Dobry 3046491ea9 feat: set default user and workdir when using Dockerfile (#954)
Set default user for Dockerfiles. Includes also small migrate fixes.



<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Defaults Dockerfile-based templates to user 'user' and workdir
'/home/user', updates CLI templates (sudo start/ready, relative Python
import), and allows template migration without a config file.
> 
> - **SDKs (Dockerfile parsing)**:
> - JS (`packages/js-sdk/src/template/dockerfileParser.ts`) and Python
(`packages/python-sdk/e2b/template/dockerfile_parser.py`): after
parsing, set defaults `setUser('user')` and `setWorkdir('/home/user')`.
> - **CLI Templates**:
> - Python build scripts: switch to relative import `from .template
import template`.
> - Generated template hbs: start/ready commands now prefixed with
`sudo`; removed explicit root/workdir before start/ready.
> - **CLI Migrate**:
> - Supports migration without `e2b.toml`; uses default config values
and prints a warning instead of exiting.
> - Initializes default config when missing; success messaging adjusted.
> - **Tests**:
> - Update fixtures to reflect new defaults (`set_user('user')`,
`set_workdir('/home/user')`, `sudo` start/ready, relative imports).
>   - Relax error case to succeed with warning when config is missing.
> - Comment out stacktrace tests for `fromDockerfile` in JS/Python until
fixed.
> - **Changesets**: Patch bumps for `@e2b/cli`, `@e2b/python-sdk`, and
`e2b`.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
934dc3b23b5607f70d4a4f5b7a9413a9d04df28a. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
2025-10-15 05:51:40 -07:00
github-actions[bot] ebb3f08039 [skip ci] Release new versions 2025-10-14 10:07:23 +00:00
Jakub Dobry f12291272d fix: set correct Dockerfile user workdir defaults (#941) 2025-10-14 09:59:00 +00:00
github-actions[bot] e5ffc79f7a [skip ci] Release new versions 2025-10-09 12:52:02 +00:00
Jakub Dobry a01c2374a9 feat: pretty default logs for build helper (#925) 2025-10-09 05:44:03 -07:00
Tomas Valenta 1203ccbad3 Add MCP experimental feature to beta (#936)
<!-- CURSOR_SUMMARY -->
> [!NOTE]
> Adds beta MCP support to JS/Python SDKs with template auto-selection,
config POST, MCP URL helpers, and codegen for MCP types/schemas.
> 
> - **SDKs (Beta MCP support)**:
>   - **JS SDK**:
> - Add `McpServer` types and export; extend `Sandbox.betaCreate` with
`mcp` option that auto-selects `mcp-gateway-v0`, configures MCP via POST
`/config` on port `50005` with retries, and expose `betaGetMcpUrl()`.
> - Add `wait(ms)` util; generate MCP types from `spec/mcp-server.json`;
new `generate:mcp` script and dev dep `json-schema-to-typescript`.
>   - **Python SDK**:
> - Generate and export `McpServer` (TypedDict); extend sync/async
`beta_create` with `mcp` option, auto-select default MCP template, POST
MCP config with retries, and add `beta_get_mcp_url()`; define `mcp_port`
and `default_mcp_template`.
> - Makefile: add `generate-mcp` target; include
`datamodel-code-generator` in tooling; update lockfile/pyproject deps.
> - **Tooling**:
> - Add `spec/mcp-server.json` schema; update codegen Dockerfile to
install `datamodel-code-generator`.
> -
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
cf3f175d310d4c242cd2e867efd801f5c04f2099. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: Jonas Scholz <Jonas.Scholz@bbscholz.de>
2025-10-09 08:37:32 +00:00
Mish Ushakov edfcc63076 Improve method naming and consistency (#934)
<!-- CURSOR_SUMMARY -->
> [!NOTE]
> Unifies Template APIs across JS/Python with PathLike support, new
copyItems, option/name tweaks, and simpler registry auth via
credentials; updates parser, exports, and tests.
> 
> - **Template API (JS + Python)**
> - Add PathLike support for paths in `copy`, `remove`, `rename`,
`makeDir`, `makeSymlink`, `setWorkdir`, and `gitClone`.
> - Introduce `copyItems` and corresponding `CopyItem` typing; adjust
Dockerfile parser to use `copyItems` overload.
> - Simplify registry auth: `fromImage(baseImage, credentials)` accepts
`{username,password}`; remove `fromRegistry`; update
`fromAWSRegistry`/`fromGCPRegistry` to take credentials and set config
internally.
> - Rename options: `ignoreFilePaths` -> `fileIgnorePatterns`;
`fileContextPath` can be `PathLike`.
> - Ensure internal hashing/upload use stringified paths; minor
enum/type tweaks (e.g., `InstructionType` as string enum, `forceUpload?:
true`).
> - **Exports**
>   - Export `CopyItem` from JS `index.ts` and Python `__init__.py`.
> - **Tests**
> - Update stacktrace and build tests to new method names/signatures
(e.g., registry via `fromImage` credentials, new `copyItems` tests,
optional `skipCache` param).
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
95391030550a340fe99ebaac4494867b3e3e9507. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: Jakub Dobry <jakub.dobry8@gmail.com>
2025-10-09 00:51:02 +02:00
github-actions[bot] d7ba1e0828 [skip ci] Release new versions 2025-10-08 10:47:40 +00:00
Jakub Dobry a0b6104320 feat: add build v2 command that uses template SDK (#926)
Add template `build-v2` command that uses template SDK

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Introduce `template build-v2` command that builds templates directly
from a Dockerfile via the Template SDK and wire it into the CLI.
> 
> - **CLI - Template**:
> - **New Command**: `template build-v2`
(`packages/cli/src/commands/template/build-v2.ts`)
> - Builds from Dockerfile using SDK:
`Template(...).fromDockerfile(...)` and `Template.build(...)`.
> - Options: `--dockerfile`, `--cmd`, `--ready-cmd`, `--cpu-count`,
`--memory-mb`, `--no-cache`, path via `--path`; alias `bd-v2`.
>     - Validations: template name format, even `memory-mb`.
> - Auth/config: uses access token, API key, domain; streams build logs;
prints success examples.
> - **Wiring**: Add `buildV2Command` to
`packages/cli/src/commands/template/index.ts`.
> - **Release**: Changeset adds patch for `@e2b/cli`.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
33578b56dfbcd76c3bb2ecf7fdf6f2cb80c3d0dd. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
2025-10-08 12:44:21 +02:00
github-actions[bot] fb6dd8303f [skip ci] Release new versions 2025-10-08 01:00:08 +00:00
Tomas Valenta f5cfa6d897 Update node version in SDK and CLI (#935) 2025-10-08 00:46:01 +00:00
github-actions[bot] 2d62fdcc46 [skip ci] Release new versions 2025-10-03 22:10:01 +00:00
Jonas Scholz ad4b882bff Fix e2b sbx logs -f <id> not following (#930)
This PR fixes 2 bugs that made the follow option in `e2b sbx logs` not
work:

1. `e2b sbx logs -f <id>` failed to follow because the `isRunning`
function was always returning false due to the API call being
unauthenticated if you dont have the `E2B_API_KEY` environment variable
set.

This follows the existing pattern from other API calls:

https://github.com/e2b-dev/E2B/blob/c4ce97e9b9a1809e3419d64499c1e56f9138e3d0/packages/cli/src/commands/sandbox/list.ts#L138-L152

Eventually it would make sense to handle the error here, for now just a
hotfix to fix the --follow usage

2. Once it actually followed, it never stopped following because
`isRunning` was not inside the loop and always true. Now when you kill
the sandbox follow actually stops following

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Fixes `e2b sbx logs -f` by authenticating `isRunning` and re-checking
sandbox state each loop so following works and stops when closed.
> 
> - **CLI — `packages/cli/src/commands/sandbox`**:
>   - **Logs follow behavior (`logs.ts`)**:
> - Re-check `isRunning(sandboxID)` inside the loop (`isSandboxRunning`)
instead of using a cached promise, ensuring follow stops when sandbox is
closed or not found.
>   - **Sandbox state check auth (`utils.ts`)**:
> - Use `ensureAPIKey()` and pass `apiKey` to
`Sandbox.getInfo(getShortID(sandboxID), { apiKey })` so `isRunning` is
authenticated.
> - **Release**:
> - Changeset adds patch for `@e2b/cli` with note: fix sbx logs follow
option.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
5fbd87166b70aca7229ccc1ff8fa2c27f12b1641. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
2025-10-03 15:06:17 -07:00
github-actions[bot] 64e8f057d2 [skip ci] Release new versions 2025-09-30 15:53:06 +00:00
Jakub Dobry 4da865c1f3 fix: add queue for terminal input (#924) 2025-09-30 08:49:39 -07:00
Jakub Dobry ad7ad6f101 Scope template build for typescript and python (#922) 2025-09-29 04:47:24 -07:00
github-actions[bot] 4de9dabca0 [skip ci] Release new versions 2025-09-26 13:44:26 +00:00
Jakub Dobry 2ec9ea8a44 feat: add template init for new template SDK (#881) 2025-09-26 06:40:58 -07:00
github-actions[bot] ae19d941f0 [skip ci] Release new versions 2025-09-26 12:09:44 +00:00
Jakub Novák d90c201cf3 Update docstring in toml after CLI template build (#868)
Forgotten text with old way how to create sandbox in sync Python
2025-09-26 12:06:27 +00:00
github-actions[bot] 0726589667 [skip ci] Release new versions 2025-09-25 09:12:18 +00:00
Jakub Dobry b43793ceb9 Fix CLI template migrate copy target (#915) 2025-09-25 02:09:04 -07:00
github-actions[bot] 2eeca3f807 [skip ci] Release new versions 2025-09-19 15:44:52 +00:00
Jakub Dobry b9c4b16baa feat: add template migration to CLI (#880)
## 🔄 Add Template Migration to CLI

### Summary

This PR introduces a new `migrate` command to the E2B CLI that helps
users transition from the legacy Dockerfile + TOML configuration format
to the new Template SDK format. The migration tool automatically
converts existing `e2b.Dockerfile` and `e2b.toml` configurations into
SDK-compatible template files using Handlebars templates.

### What's Changed

####  New Features

- **Template Migration Command**: Added `e2b template migrate` command
for converting legacy configurations to SDK format
- **Multi-Language Support**: Supports migration to TypeScript, Python
(sync), and Python (async) formats
- **Interactive Language Selection**: CLI prompts for target language
when not specified
- **Multi-stage Dockerfile Support**: Added fallback handling for
complex multi-stage Dockerfiles

#### 🔧 Technical Improvements

- **Enhanced ENV Handling**: Improved parsing of multiple environment
variables from single ENV instructions
- **File Name Conflict Resolution**: Automatic unique filename
generation to prevent overwriting existing files
- **Comprehensive Template Generation**: Creates both development and
production build files

#### 📁 New Template Files

- `typescript-template.hbs` - TypeScript template generation
- `typescript-build.hbs` - TypeScript build script template
- `python-template.hbs` - Python template generation (supports both
sync/async)
- `python-build-async.hbs` - Python async build script template
- `python-build-sync.hbs` - Python sync build script template

### Usage

```bash
# Migrate with interactive language selection
e2b template migrate

# Migrate to specific language
e2b template migrate --language typescript
e2b template migrate --language python-sync
e2b template migrate --language python-async

# Custom paths
e2b template migrate --dockerfile custom.dockerfile --config custom.toml
```

### Generated Output

The migration command generates three files per target:
- `template.{ts|py}` - Template definition using SDK
- `build{.|_}dev.{ts|py}` - Development build script
- `build{.|_}prod.{ts|py}` - Production build script

### Migration Process

1. **Parse Configuration**: Reads `e2b.toml` for template settings
2. **Dockerfile Analysis**: Uses E2B SDK to parse Dockerfile
instructions
3. **Transformation**: Converts Docker instructions to SDK method calls
4. **Code Generation**: Uses Handlebars templates to generate target
language files
5. **File Creation**: Writes template and build files with conflict
resolution

### Error Handling

- **Graceful Dockerfile Parsing**: Falls back to custom image reference
for unparseable Dockerfiles
- **Clear User Guidance**: Provides manual build instructions when
automatic conversion fails
- **Validation**: Ensures required configuration files exist before
migration
2025-09-19 17:41:28 +02:00
github-actions[bot] fba88a7aea [skip ci] Release new versions 2025-09-15 05:30:29 +00:00
Mish Ushakov c6efe1f26c CLI: format table > pretty to match rest of DX, added docs (#905)
Follow up my last PR, improves DX consistency and added docs.

Changelog

- format "table" > "pretty" to match other commands (metrics, logs)
- added doc section
2025-09-14 22:27:29 -07:00
github-actions[bot] 742ed67a80 [skip ci] Release new versions 2025-09-12 19:51:16 +00:00
Mish Ushakov 2a346bfcd2 Added format option to CLI sandbox + templates list (#903)
This PR is based on https://github.com/e2b-dev/E2B/pull/902, please
proceed with that first

**Changelog**

- Added `--format` option to "e2b sandbox list" and "e2b template list".
Can either be "table" or "json"

Sandboxes list in JSON format

<img width="471" height="341" alt="Screenshot 2025-09-12 at 11 17 45"
src="https://github.com/user-attachments/assets/13455b62-5efb-4b11-8fe3-a39b3fb6dffc"
/>

Templates list in JSON format

<img width="449" height="377" alt="Screenshot 2025-09-12 at 11 18 55"
src="https://github.com/user-attachments/assets/47fa3c2b-2e4c-4854-a87f-65c325261521"
/>
2025-09-12 21:47:07 +02:00
Mish Ushakov a116679b87 CLI: Refactored sandbox kill command (#904)
**Changelog**

- Added ability to pass multiple sandbox ids to "sbx kill id1 id2 id3"
- Added ability to filter sandboxes to be killed by metadata and by
state using --state, --metadata (requires --all)
- Fixed metadata parser and moved to utils
2025-09-12 21:45:25 +02:00
github-actions[bot] 2162c6191f [skip ci] Release new versions 2025-09-03 12:49:17 +00:00
Mish Ushakov 67070bb9ea Synced spec + generated API client (#889)
Changelog

- Synced latest spec from e2b-dev/infra
- Regenerated API clients
2025-09-03 05:43:47 -07:00
github-actions[bot] 0070938d01 [skip ci] Release new versions 2025-09-01 07:47:17 +00:00
Jakub Novák 99b9ed768d Deprecate spawn instead of remove (#885)
Adds a deprecated `spawn` command to the CLI, ensuring backward
compatibility and guiding users toward the preferred `create` command.


```
$ e2b sandbox
Usage: index sandbox|sbx [options] [command]

work with sandboxes

Options:
  -h, --help                        display help for command

Commands:
  connect|cn <sandboxID>            connect terminal to already running sandbox
  list|ls [options]                 list all sandboxes, by default it list only running ones
  kill|kl [options] [sandboxID]     kill sandbox
  create|cr [options] [template]    create sandbox and connect terminal to it
  logs|lg [options] <sandboxID>     show logs for sandbox
  metrics|mt [options] <sandboxID>  show metrics for sandbox
  help [command]                    display help for command
  ```
  
  ```
$ sbx sp base
Warning: The 'spawn' command is deprecated and will be removed in future releases. Please use 'e2b sandbox create' instead.
Terminal connecting to template base with sandbox ID in897x2dqs7aws8h1x0in
```
2025-09-01 07:44:10 +00:00
Jakub Novák b42ab2a86b Add pipeline for linting and formatting (#883)
Setup linting and formatting in all packages
2025-08-31 12:06:00 -07:00
github-actions[bot] 663d832ddc [skip ci] Release new versions 2025-08-22 09:45:46 +00:00
Jakub Novák c2195d832f Fix API key check in JS SDK & remove deprecated fields (#869)
Fix the check and remove deprecated fields
2025-08-22 09:42:49 +00:00
github-actions[bot] 774dfd7667 [skip ci] Release new versions 2025-08-21 15:51:16 +00:00
Jakub Novák 74457ff1dd SDK v2 - Changeset and docs (#862)
SDK v2 release
2025-08-21 08:45:25 -07:00
Jakub Novák d117ba09e8 SDK v2 - Add beta pause and update Sandbox list (#854)
Introduce beta submodule with beta features - pause and resume
Update Sandbox list to also return paused sandboxes

---------

Co-authored-by: Tomas Valenta <valenta.and.thomas@gmail.com>
2025-08-19 00:37:07 -07:00
Jakub Dobry 41d909a4bb Update access token location readme (#852) 2025-08-07 04:23:22 -07:00
github-actions[bot] 64a5d52dd5 [skip ci] Release new versions 2025-07-31 10:43:16 +00:00
Jakub Novák ec1b831018 Fix byte shift in sandbox metrics (#837)
This pull request addresses a bug in the CLI related to incorrect byte
shifting for memory and disk metrics when dealing with sizes greater
than 4 GB.
2025-07-31 03:40:27 -07:00