Commit Graph

710 Commits

Author SHA1 Message Date
0div 9b4861d2ea Add sandbox metadata docs and update env var tests (#804)
# Description
- [x] update env var docs to include new default sandbox metadata env
vars
- [x] update js-sdk tests
- [x] update python tests

# Test
```sh
$ [packages/js-sdk] pnpm test env

$ [packages/python-sdk] poetry run pytest --verbose -x tests/async/sandbox_async/commands/test_env_vars.py

$ [packages/python-sdk] poetry run pytest --verbose -x tests/sync/sandbox_sync/commands/test_env_vars.py
```
2025-07-03 14:44:27 -07:00
github-actions[bot] 9704e2ff03 [skip ci] Release new versions 2025-06-24 17:08:34 +00:00
Mish Ushakov 89b8680c75 watchDir remove redundant "timeout" option in JS SDK (#796)
- removes redundant "timeout" option for watchDir method in the JS SDK
(we're using timeoutMs already)
2025-06-24 19:00:49 +02:00
github-actions[bot] 884e6b3917 [skip ci] Release new versions 2025-06-23 16:58:16 +00:00
Mish Ushakov 05948ed527 Use TextEncoder for crypto/signed URLs (#790)
- Replaces node:crypto with cross-runtime TextEncoder/TextDecoder API
- The uploadUrl/downloadUrl methods are now async
2025-06-23 09:51:54 -07:00
github-actions[bot] 40c73100bc [skip ci] Release new versions 2025-06-20 02:52:52 +00:00
Jiri Sveceny cb3a009ac7 Option for providing system user during upload/download url creation (#784) 2025-06-19 19:48:03 -07:00
github-actions[bot] 4aaeee2af4 [skip ci] Release new versions 2025-06-13 11:03:18 +00:00
Ben Fornefeld ab6140efc3 Fix(sdk): Export enums as non-const to support isolatedModules (#773)
Removes the `const` keyword from `FileType` and `FilesystemEventType`
enums.

This change prevents the enums from being inlined at compile time,
making them compatible with projects that have the `isolatedModules:
true` flag enabled in their `tsconfig.json`. This resolves the `Cannot
access ambient const enums` build error that occurs in environments like
Babel/Vite.
2025-06-13 12:58:22 +02:00
Jakub Dobry e244ba72c0 Add option for a template ready check (#750)
## Description
Add option for a template ready check. You can specify `ready_cmd` which
will be run until it exits with code 0. Max timeout is 5 minutes. After
exit code 0, the template will be marked as ready.

If no ready command is defined, `sleep 20` is assumed when the start
command is present, and `sleep 0` when none is defined. It is also
possible to define ready command without any start command. This might
be helpful if the filesystem contains self-booted services (e.g. using
systemd).

```
ready_cmd = "echo 'Starting ready check'; sleep 40; echo 'Template is ready'"
```

This adds possibility to configure the default 20 seconds wait time for
a start command.

New documentation can be found at `/docs/sandbox-template/ready-cmd`.

## Checklist
- [x] Make sure the https://github.com/e2b-dev/infra/pull/719 is
deployed

---------

Co-authored-by: Vasek Mlejnsky <vasek@e2b.dev>
Co-authored-by: Jakub Novák <jakub@e2b.dev>
2025-06-12 17:42:37 -07:00
github-actions[bot] 6c0927e358 [skip ci] Release new versions 2025-06-05 14:15:25 +00:00
Mish Ushakov fc182d63ef Added license sources to SDKs (#761)
- Added licenses source text to the SDKs, CLI
2025-06-05 07:10:07 -07: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] f1afba0d74 [skip ci] Release new versions 2025-06-03 10:13:57 +00:00
Ben Fornefeld 8c43806f81 Fix: TypeScript union type resolution for Commands.run() method (#753)
## Fix TypeScript union type resolution for Commands.run() method

### What's Changed
Improved TypeScript type safety for the `Commands.run()` method by
adding proper function overloads to handle the union case when the
`background` parameter type is not known at compile time.

### Key Improvements

**Better Type Safety**
- Added a third function overload to correctly handle the `background?:
boolean` union case
- TypeScript now correctly infers return types:
  - `background: true` → returns `CommandHandle`
  - `background: false | undefined` → returns `CommandResult`
- `background: boolean` (unknown at compile time) → returns
`CommandHandle | CommandResult`

**Enhanced Developer Experience**
- Added comprehensive JSDoc overloads that clearly document each usage
pattern
- IntelliSense now provides accurate type hints and autocompletion
- Eliminates ambiguous union types when the `background` value is known
at compile time

**Prevents Runtime Errors**
- When `background` is a literal value, developers get precise types and
can't accidentally call wrong methods
- When `background` is a runtime boolean, TypeScript correctly shows the
union type requiring proper type narrowing

### Why This Matters for SDK Users

Before this change, developers had to ignore ts warning & manually cast
union types when using `commands.run()`:
```typescript
// Before: typescript was complaining, because it expected `true` or `false` as literals. 
// Required manual casting:

// @ts-ignore
const result = await sbx.commands.run('ls', { background: isBackground }) as CommandHandle | CommandResult
```

After this change, TypeScript automatically infers the correct type:
```typescript
// After: TypeScript knows this is CommandHandle
const handle = await sbx.commands.run('ls', { background: true })
await handle.wait() //  TypeScript knows .wait() is available

// TypeScript knows this is CommandResult  
const result = await sbx.commands.run('ls')
console.log(result.stdout) //  TypeScript knows .stdout is available

// When background value is unknown at compile time, returns union type
const isBackground: boolean = Math.random() > 0.5
const result = await commands.run('ls', { background: isBackground })
// result is CommandHandle | CommandResult - requires type narrowing or casting
```
2025-06-03 10:09:31 +00:00
Jakub Dobry 4ffb211155 Fix CLI compilation (#747)
Fix CLI compilation. Fixes nullable res.data & non-existent /teams
endpoint in the OpenAPI generated client.
2025-05-28 05:42:23 -07:00
Jakub Dobry 78fae7712b Fix browser tests domain (#744)
Fix browser tests domain when used not against production
2025-05-26 06:20:52 -07:00
Mish Ushakov bf7e862a07 Added skip if debug for some tests (#737) 2025-05-20 03:15:31 -07:00
Ben Fornefeld 10db4e95e6 CLI: Improve auth login typing + browser sign in response usage (#733)
This pr improves the auth login code, to be more declarative and
realistic to the actual response that is sent by the dashboard sign in
flow.
2025-05-15 19:18:24 +02:00
github-actions[bot] 286e70d689 [skip ci] Release new versions 2025-05-14 15:19:57 +00:00
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
Jakub Novák 106d0a7715 Remove closed port tests (#722)
# Description

They will be moved to infra, they are integration tests
2025-05-12 13:32:30 -07:00
Tomas Valenta 209e3407da Fix sandbox not found test (#715)
- Fix error code in json
- Modify the error message to match the new returned error
2025-05-10 16:42:54 +00:00
0div 1d17b9d484 Fix and update integration test template (#712)
These changes were made while testing
https://github.com/e2b-dev/infra/pull/603
- fix and install [stress-ng](https://github.com/ColinIanKing/stress-ng)
in integration test template
- fix integration test e2b.toml
2025-05-07 10:12:36 -07:00
Tomas Valenta 88266d6ae6 Unify passing of template used in tests and log background commands output (#704)
- Show errors from background commands
- Unify passing of template used in tests
2025-05-06 00:55:03 -07:00
github-actions[bot] 41f42a1490 [skip ci] Release new versions 2025-05-05 16:34:23 +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
Mish Ushakov 2e6f3c6ae9 Vitest: continue after failing test (#711)
Like in pytest, we should be running all the tests before reporting test
results. Currently, vitest finishes after 1 test has failed, this could
cause confusion if your new test should be running after the failing
one.
2025-05-02 07:05:18 -07:00
github-actions[bot] 5cb2edc0d1 [skip ci] Release new versions 2025-04-29 15:28:51 +00:00
Jakub Dobry e3021758f1 Update JS SDK target to es2017 (#708)
Updates the JS SDK target to es2017 (from es2015). This change improves
error logs that include user code. This is happening because before
es2017 (e.g. es2015) tsup adds polyfill for async (which we use in the
API) obfuscating the code execution path.

(The previously generated code)
```
var __async = (__this, __arguments, generator) => {
  return new Promise((resolve, reject) => {
    var fulfilled = (value) => {
      try {
        step(generator.next(value));
      } catch (e) {
        reject(e);
      }
    };
    var rejected = (value) => {
      try {
        step(generator.throw(value));
      } catch (e) {
        reject(e);
      }
    };
    var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
    step((generator = generator.apply(__this, __arguments)).next());
  });
};
var __await = function(promise, isYieldStar) {
  this[0] = promise;
  this[1] = isYieldStar;
};
```
2025-04-29 08:23:47 -07:00
Jakub Novák 4ec6c82630 Security patches (#706)
# Description

Fixes:
https://github.com/e2b-dev/E2B/security/dependabot/163
https://github.com/e2b-dev/E2B/security/dependabot/157
https://github.com/e2b-dev/E2B/security/dependabot/156
https://github.com/e2b-dev/E2B/security/dependabot/148
https://github.com/e2b-dev/E2B/security/dependabot/147
2025-04-29 02:41:14 -07:00
0div 8bfd3c0eed Test new error handling indicating when the sandbox is not found (#540)
Added a test in `js-sdk` for https://github.com/e2b-dev/infra/pull/231

---------

Co-authored-by: Jakub Novák <jakub@e2b.dev>
2025-04-25 23:44:39 +02:00
github-actions[bot] 2822c7bec0 [skip ci] Release new versions 2025-04-10 16:09:43 +00:00
Mish Ushakov f4e0026583 Updates SandboxApiOpts type with added headers field (#677)
- Minor type fix
2025-04-10 18:04:25 +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
Jakub Novák e9f39b07f1 Remove order check from SDK. (#675)
# Description

The test was moved to integration tests directly in infra repo
2025-04-07 07:00:57 -07:00
Jakub Novák 2aada562d1 Update esbuild to 0.25.0 (#673)
# Description

https://github.com/e2b-dev/E2B/security/dependabot/147
2025-04-07 15:54:56 +02:00
github-actions[bot] b02f93e7f4 [skip ci] Release new versions 2025-04-05 20:21:53 +00:00
github-actions[bot] ac81f95529 [skip ci] Release new versions 2025-04-05 19:43:23 +00:00
Jakub Novák 74a6944140 Fix test for closed ports (#668)
# Description

The response from backend for port is actual integer
2025-04-05 20:38:38 +01:00
Mish Ushakov cf128195a5 (Workers) Patch connect-es fetch transport to always use redirect: follow (#671)
backports the changes from beta branch (#669)
2025-04-05 20:31:34 +01:00
github-actions[bot] e8fadf947b [skip ci] Release new versions 2025-04-03 23:12:36 +00: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
Mish c0efd6f322 added additional test coverage for getInfo, updated doc 2025-03-24 16:59:37 +01:00
github-actions[bot] 8fdb429998 [skip ci] Release new versions 2025-03-24 13:33:20 +00: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
github-actions[bot] 5d8b719b21 [skip ci] Release new versions 2025-03-24 11:45:11 +00:00
Jiri Sveceny 85c4505b9f Change default domain in sdks from e2b.dev to e2b.app (#635) 2025-03-24 12:40:22 +01:00
github-actions[bot] b6b0ac6f97 [skip ci] Release new versions 2025-03-21 15:02:41 +00:00