Ben Fornefeld 5370d54bfa feat(cli): replace access token auth with Hydra OAuth flow (#1481)
## Summary

Restructures the CLI config schema to v1 with nested , , and sections.
Replaces the legacy e2b access token auth with a Hydra OAuth flow using
refresh tokens. Token expiry is decoded from the JWT claim at runtime
instead of being stored.

## Changes

- **New config schema (v1)**: , , , , ,  (ISO timestamp)
- **Token refresh**: decodes from the JWT access token, refreshes via
Hydra when expired, writes only (not )
- **Deprecated config handling**: Old flat configs without are deleted
with a re-login prompt. No migration path — users re-authenticate.
- ****: Set on  and , not on token refresh
- ****: New helper for direct error throwing without type narrowing;
auth commands use it instead of
- **Type-safe team responses**: Removed  casts, use  type extraction
- **Logout**: Revokes refresh token via Hydra before deleting config;
fixed crash when deprecated config already deleted by
- **Removed**: Token expiry display from ,  from 

## Config example

```json
{
  "version": 1,
  "identity": { "email": "user@example.com" },
  "oauth": { "token_endpoint": "https://hydra.../oauth2/token", "client_id": "..." },
  "tokens": { "access_token": "...", "refresh_token": "..." },
  "last_refresh": "2024-06-24T12:00:00.000Z",
  "teamName": "...", "teamId": "...", "teamApiKey": "..."
}
```

## Test plan

- [x] `pnpm run typecheck` passes
- [x] `pnpm exec eslint` passes on changed files
- [x] `pnpm exec prettier --check` passes
- [x] `pnpm exec vitest run tests/user_config_permissions.test.ts`
passes
- [ ] Manual: `e2b auth login` writes v1 config
- [ ] Manual: token refresh via `e2b auth configure` with expired JWT
- [ ] Manual: old flat config triggers deprecation and re-login

Depends on: dashboard PR adding the Hydra OAuth CLI flow

---------

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
2026-06-24 18:03:55 -07:00
2024-10-15 08:29:46 -07:00
2024-10-15 10:39:10 -07:00
2024-10-15 11:52:54 -07:00
2026-05-28 23:50:01 +00:00
2026-06-04 19:37:25 +02:00
2023-07-01 17:08:01 -07:00
2023-05-21 10:51:33 -07:00
2025-10-14 05:34:43 -07:00

E2B Logo E2B Logo

Last 1 month downloads for the Python SDK Last 1 month downloads for the JavaScript SDK

What is E2B?

E2B is an open-source infrastructure that allows you to run AI-generated code in secure isolated sandboxes in the cloud. To start and control sandboxes, use our JavaScript SDK or Python SDK.

Run your first Sandbox

1. Install SDK

JavaScript / TypeScript

npm i e2b

Python

pip install e2b

2. Get your E2B API key

  1. Sign up to E2B here.
  2. Get your API key here.
  3. Set environment variable with your API key
E2B_API_KEY=e2b_***

3. Start a sandbox and run commands

JavaScript / TypeScript

import Sandbox from 'e2b'

const sandbox = await Sandbox.create()
const result = await sandbox.commands.run('echo "Hello from E2B!"')
console.log(result.stdout) // Hello from E2B!

Python

from e2b import Sandbox

with Sandbox.create() as sandbox:
    result = sandbox.commands.run('echo "Hello from E2B!"')
    print(result.stdout)  # Hello from E2B!

4. Code execution with Code Interpreter

If you need to execute code with runCode()/run_code(), install the Code Interpreter SDK:

npm i @e2b/code-interpreter  # JavaScript/TypeScript
pip install e2b-code-interpreter  # Python
import { Sandbox } from '@e2b/code-interpreter'

const sandbox = await Sandbox.create()
const execution = await sandbox.runCode('x = 1; x += 1; x')
console.log(execution.text)  // outputs 2

5. Check docs

Visit E2B documentation.

6. E2B cookbook

Visit our Cookbook to get inspired by examples with different LLMs and AI frameworks.

Self-hosting

Read the self-hosting guide to learn how to set up the E2B infrastructure on your own. The infrastructure is deployed using Terraform.

Supported cloud providers:

  • 🟢 AWS
  • 🟢 Google Cloud (GCP)
  • Azure
  • General Linux machine
S
Description
E2B 是开源的安全运行时环境,为企业级 AI Agent 提供真实工具支持。|GitHub 镜像 13.6k · 🍴 1k
https://github.com/e2b-dev/e2b Readme Apache-2.0 129 MiB
Languages
Python 57.1%
TypeScript 42.2%
Dockerfile 0.3%
JavaScript 0.1%
Makefile 0.1%
Other 0.1%