Commit Graph

347 Commits

Author SHA1 Message Date
Jiri Sveceny 2def1305f3 Flag for securing envd access with auth token (#688)
Waiting until secure flag will be available in production cluster.

---------

Co-authored-by: Jakub Novák <jakub@e2b.dev>
2025-05-14 15:15:18 +00:00
0div a5b08de85f Add optional depth parameter to SDK file listing methods. (#649)
# Description

Do not merge before https://github.com/e2b-dev/infra/pull/524 is merged
and deployed.

The DX would look like this:
```js
const files = await sandbox.files.list(dirName, { depth: 3 })
```
- [x] update `envd` pb spec 
- [x] generate for `js-sdk`
- [x] update `js-sdk` `file.list` method to include optional depth param
- [x] update `js-sdk` tests
- [x] generate for `python-sdk`
- [x] update `python-sdk` `file.list` method to include optional depth
param
  - [x] sync
  - [x] async
- [x] update `python-sdk` tests
  - [x] sync
  - [x] async

---------

Co-authored-by: Mish <10400064+mishushakov@users.noreply.github.com>
2025-05-05 09:17:08 -07:00
Tomas Valenta 74ff53c3bb Add option for proxying SDK requests to API and sandbox (#695)
PR that allows you to pass `proxy` (of the type ProxyTypes) when calling
methods in the SDK that send requests. Also, if you pass `proxy` when
creating a sandbox, all the sandbox requests (called on the
Sandbox/AsyncSandbox instance) will automatically use the same proxy.

The PR also contains a small bugfix—adding missing passing of limits and
passing these directly instead of through transport to be able to pass
the proxy parameter properly.

This change should also be compatible with the code interpreter—it uses
the client transport, which uses the passed proxy if there is any.
2025-04-19 01:12:25 +03:00
Penny Templeton a1e2274eca Fix minor issue in python filesystem SDK (#678)
One should now be able to use sb.filesystem.write(WriteEntry[]) in a
typesafe way.

---------

Co-authored-by: Mish <10400064+mishushakov@users.noreply.github.com>
2025-04-11 18:04:38 +02: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
Mish Ushakov 1bdf809e8b Make possible to pass custom headers in the SDKs (#656)
This feature allows passing custom headers in the Python and JS SDK. One
use-case for it currently is passing custom authorization (Supabase)
headers with the request.
2025-04-04 00:08:12 +01:00
Mish 7638231277 fix "sandbox id" naming consistency (uppercase) 2025-03-28 11:02:16 +01:00
0div bd4398f30d address PR comments 2025-03-25 15:53:42 -07:00
0div 6dd18e2832 allow writing files that are of type io.BufferedReader and update tests 2025-03-25 14:39:58 -07:00
Mish Ushakov d4f4352aa3 Add getInfo/get_info methods to the SDKs (#625)
- Rebased version of #517
2025-03-24 14:26:18 +01:00
Jiri Sveceny 85c4505b9f Change default domain in sdks from e2b.dev to e2b.app (#635) 2025-03-24 12:40:22 +01:00
Jakub Novák 5c4d07536f Add filtering option for listing sandboxes (#532)
# Description

Allow users to filter out sandbox based on metadata

---------

Co-authored-by: Mish Ushakov <10400064+mishushakov@users.noreply.github.com>
2025-03-21 15:57:48 +01:00
0div a8e88de846 fix merge conflict with main 2025-03-18 09:09:13 -07:00
Jakub Novák fe7ed15c61 Process time out returns incorrect exception in pythonsdk e2b 1476 (#550)
Handle the exception properly
2025-01-28 11:45:39 -08:00
Jakub Novak 359d17d0c4 Fix versions to match updated envd version 2025-01-28 11:28:35 -08:00
Jakub Dobrý ec9288a48b Add recursive watch envd version check python SDK, js SDK check 2025-01-28 11:28:18 -08:00
Jakub Dobrý 76b4ac02ad Regenerated python stubs with version 5.28.3
- Removed code runtime version check to prevent issues until further investigation
2025-01-28 11:26:32 -08:00
Jakub Dobrý 4adcfd83e9 Add python generated stubs 2025-01-28 11:26:30 -08:00
Jakub Dobrý 25c4539de6 Add watch dir recursive option (missing python client regeneration) 2025-01-28 11:25:42 -08:00
Jakub Novak fd45f0ef52 Handle exception when iterating over process output 2025-01-23 21:17:48 -08:00
Jakub Novak 61d147906e Add missing backticks 2025-01-23 15:24:00 -08:00
Jakub Novak 9282976628 Add envd version 2025-01-22 20:50:48 -08:00
Jakub Novak 4b5d17e8a4 Add missing files 2025-01-17 14:28:42 -08:00
Jakub Novak 594bb174d2 Generate only relevant api routes for the client in SDKs 2025-01-17 11:01:40 -08:00
0div 724fbc63cc remove WriteData type in python-sdk 2024-12-12 17:13:09 -08:00
0div 4ca24147f6 fixed typing syntax and watch tests 2024-12-12 15:18:06 -08:00
0div 97d0cc1ef5 merge main 2024-12-12 14:54:24 -08:00
0div bff11dc02e add the same fixes to python async 2024-12-11 17:29:46 -08:00
0div 3c525220d9 make stdout and stderr decode handle errors by replacing with unicode replacement char; add tests 2024-12-11 17:07:36 -08:00
Jakub Novak ba78ba09d5 Improve READMEs and links to get access token / api key 2024-11-04 10:53:40 -08:00
Jakub Novak f49a2ea38b Improve texting 2024-10-22 21:57:08 -07:00
Jakub Novak 80f2159cc7 Add rate limit error 2024-10-22 21:41:08 -07:00
Tomas Valenta aa302edc96 Change exception descriptions; Add TODO comment 2024-10-21 10:35:54 -07:00
Tomas Valenta 193b727dc9 Update example in docstrings 2024-10-16 02:21:03 -07:00
Tomas Valenta c688b267b4 Update sync Python docstrings 2024-10-16 01:31:03 -07:00
Tomas Valenta 95baca5d1b Update async Python docstrings 2024-10-16 00:52:13 -07:00
Jakub Novak 0f292860b1 Remove protobuf runtime checks 2024-10-14 21:38:14 -07:00
Jakub Novak 23ea4adfb1 Rename rpc methods for watcher 2024-10-14 19:51:05 -07:00
Jakub Novák e48574f69c Improve file watcher in Python Sync SDK (#457)
# Description

Current solution didn't work well with in sync Python. If you're unsure
whether a file has been created, you might end up waiting for a timeout
to exit the loop.

New implementation uses polling, you can ask for events whenever you
want and it will request envd to send all events (or only new ones).
This should make it much better for users with sync Python SDK

Example of a problematic usage before and after:
## Before
```python
sbx = Sandbox()
watcher = sbx.files.watch("/home/user")
sbx.files.make_dir("test")
for event in watcher:
    print(event)
     # !!! if you don't exit, you would be stuck for the rest of the timeout (default 60 seconds)
    break
watcher.close()
```
## After
```python
sbx = Sandbox()
watcher = sbx.files.watch("/home/user")
sbx.files.make_dir("test")
events = watcher.get_new_events()
watcher.stop()
for event in events:
    print(event)
```

Even worse case was if you don't know if anything will happen:
## Before
```python
sbx = Sandbox()
watcher = sbx.files.watch("/home/user")
if random.random() > 0.5:
    sbx.files.make_dir("test")
# There's 50% chance you will get stuck. The only workaround is to run in in separate thread and you kill it after a while (you aren't really sure when it's safe)
for event in watcher:
    print(event)
    #  !!! if you don't exit, you would be stuck for the rest of the timeout (default 60 seconds)
    break
watcher.close()
```
## After
```python
sbx = Sandbox()
watcher = sbx.files.watch("/home/user")
if random.random() > 0.5:
    sbx.files.make_dir("test")
events = watcher.get_new_events()
watcher.stop()
for event in events:
    print(event)
```
2024-10-14 23:09:53 +02:00
Jakub Novak bfc4bb51d8 Rename watch to watch dir 2024-10-14 14:01:34 -07:00
Jakub Novak 6e926ecb13 Remove timeout from sync watch dir 2024-10-14 13:40:08 -07:00
Jakub Novak bc42ba1e66 Refactor watch dir 2024-10-14 13:01:59 -07:00
Jakub Novak 5c31902cc4 Change close to stop for watch dir 2024-10-14 12:10:17 -07:00
Jakub Novak 5de5385533 Update the python sdk to match the new spec 2024-10-14 12:10:04 -07:00
Jakub Novak f9978611f3 Regenerate rpc client 2024-10-14 11:30:02 -07:00
Jakub Novak 81db2b1466 Add sync watch handler 2024-10-11 11:54:00 +02:00
0div 86262f1bc6 docstring for dataclass 2024-10-10 13:52:53 +02:00
0div 2956a6e7b9 better error messages in python-sdk 2024-10-10 12:04:42 +02:00
0div 834f84c8bb merge beta 2024-10-10 09:29:37 +02:00
0div 87e314ada5 Merge branch 'beta' of https://github.com/e2b-dev/E2B into generate-api-refs-workflow 2024-10-10 09:22:23 +02:00