Skip to content

Commit e1e7a5f

Browse files
mishushakovclaude
andcommitted
Add language autocomplete for js, ts, r, java, bash
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 52b5767 commit e1e7a5f

File tree

4 files changed

+12
-97
lines changed

4 files changed

+12
-97
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@e2b/code-interpreter": patch
3+
"e2b-code-interpreter": patch
4+
---
5+
6+
Add autocomplete support for javascript, typescript, r, java, and bash languages in runCode/run_code and createCodeContext/create_code_context

js/src/sandbox.ts

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export interface CreateCodeContextOpts {
8888
*
8989
* @default python
9090
*/
91-
language?: string
91+
language?: 'python' | 'javascript' | 'typescript' | 'r' | 'java' | 'bash' | (string & {})
9292
/**
9393
* Timeout for the request in **milliseconds**.
9494
*
@@ -128,29 +128,6 @@ export class Sandbox extends BaseSandbox {
128128
)}`
129129
}
130130

131-
/**
132-
* Run the code as Python.
133-
*
134-
* Specify the `language` or `context` option to run the code as a different language or in a different `Context`.
135-
*
136-
* You can reference previously defined variables, imports, and functions in the code.
137-
*
138-
* @param code code to execute.
139-
* @param opts options for executing the code.
140-
*
141-
* @returns `Execution` result object.
142-
*/
143-
async runCode(
144-
code: string,
145-
opts?: RunCodeOpts & {
146-
/**
147-
* Language to use for code execution.
148-
*
149-
* If not defined, the default Python context is used.
150-
*/
151-
language?: 'python'
152-
}
153-
): Promise<Execution>
154131
/**
155132
* Run the code for the specified language.
156133
*
@@ -172,7 +149,7 @@ export class Sandbox extends BaseSandbox {
172149
*
173150
* If not defined, the default Python context is used.
174151
*/
175-
language?: string
152+
language?: 'python' | 'javascript' | 'typescript' | 'r' | 'java' | 'bash' | (string & {})
176153
}
177154
): Promise<Execution>
178155
/**

python/e2b_code_interpreter/code_interpreter_async.py

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -68,41 +68,7 @@ def _client(self) -> AsyncClient:
6868
async def run_code(
6969
self,
7070
code: str,
71-
language: Union[Literal["python"], None] = None,
72-
on_stdout: Optional[OutputHandlerWithAsync[OutputMessage]] = None,
73-
on_stderr: Optional[OutputHandlerWithAsync[OutputMessage]] = None,
74-
on_result: Optional[OutputHandlerWithAsync[Result]] = None,
75-
on_error: Optional[OutputHandlerWithAsync[ExecutionError]] = None,
76-
envs: Optional[Dict[str, str]] = None,
77-
timeout: Optional[float] = None,
78-
request_timeout: Optional[float] = None,
79-
) -> Execution:
80-
"""
81-
Runs the code as Python.
82-
83-
Specify the `language` or `context` option to run the code as a different language or in a different `Context`.
84-
85-
You can reference previously defined variables, imports, and functions in the code.
86-
87-
:param code: Code to execute
88-
:param language: Language to use for code execution. If not defined, the default Python context is used.
89-
:param on_stdout: Callback for stdout messages
90-
:param on_stderr: Callback for stderr messages
91-
:param on_result: Callback for the `Result` object
92-
:param on_error: Callback for the `ExecutionError` object
93-
:param envs: Custom environment variables
94-
:param timeout: Timeout for the code execution in **seconds**
95-
:param request_timeout: Timeout for the request in **seconds**
96-
97-
:return: `Execution` result object
98-
"""
99-
...
100-
101-
@overload
102-
async def run_code(
103-
self,
104-
code: str,
105-
language: Optional[str] = None,
71+
language: Union[Literal["python", "javascript", "typescript", "r", "java", "bash"], str, None] = None,
10672
on_stdout: Optional[OutputHandlerWithAsync[OutputMessage]] = None,
10773
on_stderr: Optional[OutputHandlerWithAsync[OutputMessage]] = None,
10874
on_result: Optional[OutputHandlerWithAsync[Result]] = None,
@@ -236,7 +202,7 @@ async def run_code(
236202
async def create_code_context(
237203
self,
238204
cwd: Optional[str] = None,
239-
language: Optional[str] = None,
205+
language: Union[Literal["python", "javascript", "typescript", "r", "java", "bash"], str, None] = None,
240206
request_timeout: Optional[float] = None,
241207
) -> Context:
242208
"""

python/e2b_code_interpreter/code_interpreter_sync.py

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -65,41 +65,7 @@ def _client(self) -> Client:
6565
def run_code(
6666
self,
6767
code: str,
68-
language: Union[Literal["python"], None] = None,
69-
on_stdout: Optional[OutputHandler[OutputMessage]] = None,
70-
on_stderr: Optional[OutputHandler[OutputMessage]] = None,
71-
on_result: Optional[OutputHandler[Result]] = None,
72-
on_error: Optional[OutputHandler[ExecutionError]] = None,
73-
envs: Optional[Dict[str, str]] = None,
74-
timeout: Optional[float] = None,
75-
request_timeout: Optional[float] = None,
76-
) -> Execution:
77-
"""
78-
Runs the code as Python.
79-
80-
Specify the `language` or `context` option to run the code as a different language or in a different `Context`.
81-
82-
You can reference previously defined variables, imports, and functions in the code.
83-
84-
:param code: Code to execute
85-
:param language: Language to use for code execution. If not defined, the default Python context is used.
86-
:param on_stdout: Callback for stdout messages
87-
:param on_stderr: Callback for stderr messages
88-
:param on_result: Callback for the `Result` object
89-
:param on_error: Callback for the `ExecutionError` object
90-
:param envs: Custom environment variables
91-
:param timeout: Timeout for the code execution in **seconds**
92-
:param request_timeout: Timeout for the request in **seconds**
93-
94-
:return: `Execution` result object
95-
"""
96-
...
97-
98-
@overload
99-
def run_code(
100-
self,
101-
code: str,
102-
language: Optional[str] = None,
68+
language: Union[Literal["python", "javascript", "typescript", "r", "java", "bash"], str, None] = None,
10369
on_stdout: Optional[OutputHandler[OutputMessage]] = None,
10470
on_stderr: Optional[OutputHandler[OutputMessage]] = None,
10571
on_result: Optional[OutputHandler[Result]] = None,
@@ -232,7 +198,7 @@ def run_code(
232198
def create_code_context(
233199
self,
234200
cwd: Optional[str] = None,
235-
language: Optional[str] = None,
201+
language: Union[Literal["python", "javascript", "typescript", "r", "java", "bash"], str, None] = None,
236202
request_timeout: Optional[float] = None,
237203
) -> Context:
238204
"""

0 commit comments

Comments
 (0)