Commit Graph

251 Commits

Author SHA1 Message Date
github-actions[bot] 25526ff928 [skip ci] Release new versions 2025-09-29 12:53:44 +00:00
github-actions[bot] 138f85dd07 [skip ci] Release new versions 2025-09-19 19:03:53 +00:00
github-actions[bot] 8255ba42c0 [skip ci] Release new versions 2025-09-19 10:40:39 +00:00
github-actions[bot] 9cbcaa40c4 [skip ci] Release new versions 2025-09-09 19:57:39 +00:00
github-actions[bot] bee91610dc [skip ci] Release new versions 2025-09-06 10:58:21 +00:00
github-actions[bot] 9d82bd60fc [skip ci] Release new versions 2025-09-05 20:06:19 +00:00
Mish Ushakov 4a2a6c7051 Add Templates SDK (#871)
### Merge Templates SDK into E2B SDK.

This PR merges code from Templates SDK to E2B SDK.

**Changelog**

- Added new error classes: BuildError, FileUploadError.
- Added template API endpoints to API Client generation (Python).
- Updated API Clients error handling to throw BuildError in addition to
SandboxError.
- Exported Template and TemplateAsync classes.
- Moved `getRuntime` utility method from api to utils.
- Browser is supported except file operations (COPY). Incompatible
modules are not bundled, using dynamic imports (tar, glob) in supported
environments (Node, Deno, Bun) instead.
- Basic tests were added, subject to expansion in a follow-up PR.
- Breaking: Before, 401 error was raising `SandboxError`, which was
incorrect, now it will raise `AuthenticationError`. I have also changed
the `AuthenticationError` to extend Error class, not `SandboxError`
anymore as it's now thrown by both Sandbox and Template.

**Usage**

JavaScript

```js
import { Template } from 'e2b';

const template = Template()
  .fromImage('ubuntu:22.04')
  .copy('folder/*.txt', 'folder', { forceUpload: true })
  .setEnvs({
    ENV_1: 'value1',
    ENV_2: 'value2',
  })
  .runCmd('cat folder/test.txt')
  .setWorkdir('/app')
  .setStartCmd('echo "Hello, world!"', Template.waitForTimeout('10s'))

await Template.build(template, {
  alias: 'test-template',
  cpuCount: 1,
  memoryMB: 1024,
  onBuildLogs: (logEntry) => console.log(logEntry.toString()),
})

```

Python

```py
from e2b import Template

template = (
    Template()
    .from_image("ubuntu:22.04")
    .copy("folder/*.txt", "folder", force_upload=True)
    .set_envs(
        {
            "ENV_1": "value1",
            "ENV_2": "value2",
        }
    )
    .run_cmd("cat folder/test.txt")
    .set_workdir("/app")
    .set_start_cmd("echo 'Hello, world!'", Template.wait_for_timeout("10s"))
)

Template.build(
    template,
    alias="test-template",
    cpu_count=1,
    memory_mb=1024,
    on_build_logs=lambda log_entry: print(log_entry),
)
```

Python Async

```py
from e2b import AsyncTemplate

template = (
    AsyncTemplate()
    .from_image("ubuntu:22.04")
    .copy("folder/*.txt", "folder", force_upload=True)
    .set_envs(
        {
            "ENV_1": "value1",
            "ENV_2": "value2",
        }
    )
    .run_cmd("cat folder/test.txt")
    .set_workdir("/app")
    .set_start_cmd("echo 'Hello, world!'", Template.wait_for_timeout("10s"))
)

await AsyncTemplate.build(
    template,
    alias="test-template",
    cpu_count=1,
    memory_mb=1024,
    on_build_logs=lambda log_entry: print(log_entry),
)
```

---

Merge progress

- [x] JavaScript SDK
- [x] Python SDK
- [x] Tests
- [x] Split files for review
2025-09-05 22:00:22 +02:00
github-actions[bot] 2162c6191f [skip ci] Release new versions 2025-09-03 12:49:17 +00:00
github-actions[bot] 787a3192ce [skip ci] Release new versions 2025-09-03 12:01: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] 774dfd7667 [skip ci] Release new versions 2025-08-21 15:51:16 +00:00
github-actions[bot] 7540839268 [skip ci] Release new versions 2025-08-06 10:32:14 +00:00
Tomas Valenta 33b9467bef Allow more protobuf versions (#846)
- Allow protobuf `4.21.0`+ (we previously allowed this, and some users
in beta require this)
- Allow protobuf `6.0.0`+ (some other users need to use the SDK with the
latest versions)

The SDK should work with both of these, but we may want to smoke test it
somehow.

---------

Co-authored-by: Jakub Novak <jakub@e2b.dev>
2025-08-06 03:27:00 -07:00
github-actions[bot] 9d2b3c92a7 [skip ci] Release new versions 2025-08-04 12:40:16 +00:00
github-actions[bot] 115407cf1e [skip ci] Release new versions 2025-07-31 09:44:55 +00:00
github-actions[bot] 76d62ed070 [skip ci] Release new versions 2025-07-30 19:25:33 +00:00
github-actions[bot] 7f26f5536e [skip ci] Release new versions 2025-07-29 10:44:36 +00:00
Mish Ushakov edeafb1cdd Adds files.getInfo / files.get_info methods to retrieve information about directory/files (#724)
**Changelog**

- Adds `files.getInfo`, `files.get_info` methods to the SDKs.
- Adds tests for the new methods
- Adds documentation for the above.

**Examples**

JavaScript

```js
import { Sandbox } from '@e2b/code-interpreter'

const sandbox = await Sandbox.create()

// Create a new file
await sandbox.files.write('test_file.txt', 'Hello, world!')

// Get information about the file
const info = await sandbox.files.getInfo('test_file.txt')

console.log(info)
// {
//   name: 'test_file.txt',
//   type: 'file',
//   path: '/home/user/test_file.txt'
// }
```

Python

```py
from e2b_code_interpreter import Sandbox

sandbox = Sandbox()

# Create a new file
sandbox.files.write('test_file', 'Hello, world!')

# Get information about the file
info = sandbox.files.get_info('test_file')

print(info)
# EntryInfo(name='test_file.txt', type=<FileType.FILE: 'file'>, path='/home/user/test_file.txt')
```

---------

Co-authored-by: Jakub Novak <jakub@e2b.dev>
2025-07-29 03:39:42 -07:00
github-actions[bot] 37d69be891 [skip ci] Release new versions 2025-07-28 15:23:07 +00:00
github-actions[bot] e7538fb5cc [skip ci] Release new versions 2025-07-18 11:20:02 +00:00
github-actions[bot] 5f207ffa95 [skip ci] Release new versions 2025-07-17 13:16:31 +00:00
github-actions[bot] 5cf6c145a5 [skip ci] Release new versions 2025-07-10 13:45:42 +00:00
github-actions[bot] 083d5eefa8 [skip ci] Release new versions 2025-07-09 14:08:34 +00:00
github-actions[bot] 3547878756 [skip ci] Release new versions 2025-07-03 18:31:46 +00:00
github-actions[bot] 69eacc71bb [skip ci] Release new versions 2025-06-27 20:24:58 +00:00
github-actions[bot] 995c494d4a [skip ci] Release new versions 2025-06-16 18:46:47 +00:00
github-actions[bot] 6c0927e358 [skip ci] Release new versions 2025-06-05 14:15:25 +00:00
Mish Ushakov b21f86c543 Added lint workflow for JS, Python SDKs (#759)
- Linted all existing files
- Added GitHub workflow to check everything is linted correctly
2025-06-05 14:52:48 +02:00
github-actions[bot] 286e70d689 [skip ci] Release new versions 2025-05-14 15:19:57 +00:00
github-actions[bot] 41f42a1490 [skip ci] Release new versions 2025-05-05 16:34:23 +00:00
github-actions[bot] 67f5230532 [skip ci] Release new versions 2025-04-18 22:43:01 +00:00
github-actions[bot] 5a43e39579 [skip ci] Release new versions 2025-04-11 16:11:00 +00:00
0div e0c1bc752d Make codegen robust and deterministic for js and python SDKs (#664)
# Description 

This PR allows to codegen without worrying about your environment and
dependencies for consistent outcomes in what code is generated from
openapi and envd protobuf spec. Will generate files for `js-sdk` and
`python-sdk`

- [x] create Docker image with all the pinned deps needed to codegen
- [x] create codegen script using this container with mapped volumes
- [x] adapt Makefiles to this new approach
- [x] adapt where we install the connect-python protobuf binary for this
to work

# Test

```sh
make codegen # this command is similar to `make generate` but w/o the hassle

Generating SDK code from openapi and envd spec
cd packages/js-sdk && pnpm generate

> e2b@1.2.1 generate /workspace/packages/js-sdk
> python ./../../spec/remove_extra_tags.py sandboxes templates && openapi-typescript ../../spec/openapi_generated.yml -x api_key --arr
ay-length --alphabetize --output src/api/schema.gen.ts

 openapi-typescript 7.6.1
🚀 ../../spec/openapi_generated.yml → src/api/schema.gen.ts [44.2ms]
cd packages/js-sdk && pnpm generate-envd-api

> e2b@1.2.1 generate-envd-api /workspace/packages/js-sdk
> openapi-typescript ../../spec/envd/envd.yaml -x api_key --array-length --alphabetize --output src/envd/schema.gen.ts

 openapi-typescript 7.6.1
🚀 ../../spec/envd/envd.yaml → src/envd/schema.gen.ts [22.7ms]

[...]

cd packages/python-sdk && make generate-api

All done!  🍰 
```

---------

Co-authored-by: Jiri Sveceny <jiri.sveceny@icloud.com>
2025-04-07 17:00:31 +02:00
github-actions[bot] e8fadf947b [skip ci] Release new versions 2025-04-03 23:12:36 +00:00
github-actions[bot] 5ca2b9cc42 [skip ci] Release new versions 2025-03-26 18:15:28 +00:00
github-actions[bot] 8fdb429998 [skip ci] Release new versions 2025-03-24 13:33:20 +00:00
github-actions[bot] 5d8b719b21 [skip ci] Release new versions 2025-03-24 11:45:11 +00:00
github-actions[bot] b6b0ac6f97 [skip ci] Release new versions 2025-03-21 15:02:41 +00:00
github-actions[bot] b402327b6d [skip ci] Release new versions 2025-03-20 09:56:31 +00:00
github-actions[bot] 9f23f542d1 [skip ci] Release new versions 2025-02-22 00:00:40 +00:00
Jakub Novak eed7384da2 Drop support for Python 3.8 2025-02-05 20:31:50 -08:00
github-actions[bot] dde83b7986 [skip ci] Release new versions 2025-01-28 19:58:38 +00:00
github-actions[bot] e8fa4be096 [skip ci] Release new versions 2024-12-06 04:41:39 +00:00
Jakub Novak 7999815887 Update httpx version in dependencies 2024-12-05 20:30:39 -08:00
github-actions[bot] ff02ae9e98 [skip ci] Release new versions 2024-11-26 19:15:40 +00:00
Tomas Valenta eff5ff533d Add missing dependency 2024-11-23 21:58:59 -08:00
github-actions[bot] 6332979ff6 [skip ci] Release new versions 2024-11-03 23:55:22 +00:00
Jakub Novak a87098e979 Remove typing-extensions from dependencies, fix version of httpcore + httpx, update poetry lock 2024-11-03 15:48:28 -08:00
Brendan Maginnis d8b5b1acbd Make dependencies more lenient 2024-11-01 09:51:18 +00:00
github-actions[bot] 1405b6e1f7 [skip ci] Release new versions 2024-10-26 04:52:47 +00:00