e2b-code-interpreter 2.8.1__tar.gz → 2.9.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: e2b-code-interpreter
3
- Version: 2.8.1
3
+ Version: 2.9.0
4
4
  Summary: E2B Code Interpreter - Stateful code execution
5
5
  Home-page: https://e2b.dev/
6
6
  License: MIT
@@ -61,6 +61,11 @@ class AsyncSandbox(BaseAsyncSandbox):
61
61
 
62
62
  @property
63
63
  def _jupyter_url(self) -> str:
64
+ # Honors the `sandbox_url` option and the `E2B_SANDBOX_URL` environment
65
+ # variable, same as the base SDK does for envd requests.
66
+ sandbox_url = self.connection_config._sandbox_url
67
+ if sandbox_url:
68
+ return sandbox_url
64
69
  return f"{'http' if self.connection_config.debug else 'https'}://{self.get_host(JUPYTER_PORT)}"
65
70
 
66
71
  @property
@@ -196,6 +201,8 @@ class AsyncSandbox(BaseAsyncSandbox):
196
201
  try:
197
202
  headers = {
198
203
  "Content-Type": "application/json",
204
+ "E2b-Sandbox-Id": self.sandbox_id,
205
+ "E2b-Sandbox-Port": str(JUPYTER_PORT),
199
206
  }
200
207
  if self._envd_access_token:
201
208
  headers["X-Access-Token"] = self._envd_access_token
@@ -265,6 +272,8 @@ class AsyncSandbox(BaseAsyncSandbox):
265
272
  try:
266
273
  headers = {
267
274
  "Content-Type": "application/json",
275
+ "E2b-Sandbox-Id": self.sandbox_id,
276
+ "E2b-Sandbox-Port": str(JUPYTER_PORT),
268
277
  }
269
278
  if self.traffic_access_token:
270
279
  headers["E2B-Traffic-Access-Token"] = self.traffic_access_token
@@ -304,6 +313,8 @@ class AsyncSandbox(BaseAsyncSandbox):
304
313
  try:
305
314
  headers = {
306
315
  "Content-Type": "application/json",
316
+ "E2b-Sandbox-Id": self.sandbox_id,
317
+ "E2b-Sandbox-Port": str(JUPYTER_PORT),
307
318
  }
308
319
  if self.traffic_access_token:
309
320
  headers["E2B-Traffic-Access-Token"] = self.traffic_access_token
@@ -332,6 +343,8 @@ class AsyncSandbox(BaseAsyncSandbox):
332
343
  try:
333
344
  headers = {
334
345
  "Content-Type": "application/json",
346
+ "E2b-Sandbox-Id": self.sandbox_id,
347
+ "E2b-Sandbox-Port": str(JUPYTER_PORT),
335
348
  }
336
349
  if self.traffic_access_token:
337
350
  headers["E2B-Traffic-Access-Token"] = self.traffic_access_token
@@ -369,6 +382,8 @@ class AsyncSandbox(BaseAsyncSandbox):
369
382
  try:
370
383
  headers = {
371
384
  "Content-Type": "application/json",
385
+ "E2b-Sandbox-Id": self.sandbox_id,
386
+ "E2b-Sandbox-Port": str(JUPYTER_PORT),
372
387
  }
373
388
  if self.traffic_access_token:
374
389
  headers["E2B-Traffic-Access-Token"] = self.traffic_access_token
@@ -58,6 +58,11 @@ class Sandbox(BaseSandbox):
58
58
 
59
59
  @property
60
60
  def _jupyter_url(self) -> str:
61
+ # Honors the `sandbox_url` option and the `E2B_SANDBOX_URL` environment
62
+ # variable, same as the base SDK does for envd requests.
63
+ sandbox_url = self.connection_config._sandbox_url
64
+ if sandbox_url:
65
+ return sandbox_url
61
66
  return f"{'http' if self.connection_config.debug else 'https'}://{self.get_host(JUPYTER_PORT)}"
62
67
 
63
68
  @property
@@ -189,7 +194,11 @@ class Sandbox(BaseSandbox):
189
194
  context_id = context.id if context else None
190
195
 
191
196
  try:
192
- headers: Dict[str, str] = {"Content-Type": "application/json"}
197
+ headers: Dict[str, str] = {
198
+ "Content-Type": "application/json",
199
+ "E2b-Sandbox-Id": self.sandbox_id,
200
+ "E2b-Sandbox-Port": str(JUPYTER_PORT),
201
+ }
193
202
  if self._envd_access_token:
194
203
  headers["X-Access-Token"] = self._envd_access_token
195
204
  if self.traffic_access_token:
@@ -256,9 +265,11 @@ class Sandbox(BaseSandbox):
256
265
  data["cwd"] = cwd
257
266
 
258
267
  try:
259
- headers: Dict[str, str] = {"Content-Type": "application/json"}
260
- if self._envd_access_token:
261
- headers["X-Access-Token"] = self._envd_access_token
268
+ headers: Dict[str, str] = {
269
+ "Content-Type": "application/json",
270
+ "E2b-Sandbox-Id": self.sandbox_id,
271
+ "E2b-Sandbox-Port": str(JUPYTER_PORT),
272
+ }
262
273
  if self.traffic_access_token:
263
274
  headers["E2B-Traffic-Access-Token"] = self.traffic_access_token
264
275
 
@@ -295,9 +306,11 @@ class Sandbox(BaseSandbox):
295
306
  context_id = context.id if isinstance(context, Context) else context
296
307
 
297
308
  try:
298
- headers: Dict[str, str] = {"Content-Type": "application/json"}
299
- if self._envd_access_token:
300
- headers["X-Access-Token"] = self._envd_access_token
309
+ headers: Dict[str, str] = {
310
+ "Content-Type": "application/json",
311
+ "E2b-Sandbox-Id": self.sandbox_id,
312
+ "E2b-Sandbox-Port": str(JUPYTER_PORT),
313
+ }
301
314
  if self.traffic_access_token:
302
315
  headers["E2B-Traffic-Access-Token"] = self.traffic_access_token
303
316
 
@@ -323,9 +336,11 @@ class Sandbox(BaseSandbox):
323
336
  :return: List of contexts.
324
337
  """
325
338
  try:
326
- headers: Dict[str, str] = {"Content-Type": "application/json"}
327
- if self._envd_access_token:
328
- headers["X-Access-Token"] = self._envd_access_token
339
+ headers: Dict[str, str] = {
340
+ "Content-Type": "application/json",
341
+ "E2b-Sandbox-Id": self.sandbox_id,
342
+ "E2b-Sandbox-Port": str(JUPYTER_PORT),
343
+ }
329
344
  if self.traffic_access_token:
330
345
  headers["E2B-Traffic-Access-Token"] = self.traffic_access_token
331
346
 
@@ -361,9 +376,11 @@ class Sandbox(BaseSandbox):
361
376
  context_id = context.id if isinstance(context, Context) else context
362
377
 
363
378
  try:
364
- headers: Dict[str, str] = {"Content-Type": "application/json"}
365
- if self._envd_access_token:
366
- headers["X-Access-Token"] = self._envd_access_token
379
+ headers: Dict[str, str] = {
380
+ "Content-Type": "application/json",
381
+ "E2b-Sandbox-Id": self.sandbox_id,
382
+ "E2b-Sandbox-Port": str(JUPYTER_PORT),
383
+ }
367
384
  if self.traffic_access_token:
368
385
  headers["E2B-Traffic-Access-Token"] = self.traffic_access_token
369
386
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "e2b-code-interpreter"
3
- version = "2.8.1"
3
+ version = "2.9.0"
4
4
  description = "E2B Code Interpreter - Stateful code execution"
5
5
  authors = ["e2b <hello@e2b.dev>"]
6
6
  license = "MIT"