# Description
The bug where extra fields in envd response caused an exception was
fixed in #738. As we're also ignoring new fields in envd (implemented in
https://github.com/e2b-dev/infra/pull/847). We now have to update the
`user-agent` header.
# Description
Fixes an issue in generating files in Docker. There has been an
incompatibility of `buf` (version `29.5`) and `protoc-gen-es` (version
`2.2.2`).
I updated `protoc-gen-es@` to `2.6.2`
Also refactored the code a little so it's easier to read
Added a CI pipeline job to check all files are properly generated
- CLI spawn, connect, and logs work with and without the client part
provided
- JavaScript and Python SDKs are no longer returning IDs with client
part
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.
## 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>
## 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
```
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.
# 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>