Skip to content

Commit 4a8c98a

Browse files
committed
adds ability to pass user to the createCodeContext SDK method
1 parent 23f58ea commit 4a8c98a

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

js/src/sandbox.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ export interface CreateCodeContextOpts {
7878
* @default python
7979
*/
8080
language?: string,
81+
/**
82+
* User for the context.
83+
*
84+
* @default root
85+
*/
86+
user?: "root" | "user",
8187
/**
8288
* Timeout for the request in **milliseconds**.
8389
*
@@ -269,6 +275,7 @@ export class Sandbox extends BaseSandbox {
269275
body: JSON.stringify({
270276
language: opts?.language,
271277
cwd: opts?.cwd,
278+
user: opts?.user,
272279
}),
273280
keepalive: true,
274281
signal: this.connectionConfig.getSignal(opts?.requestTimeoutMs),

python/e2b_code_interpreter/code_interpreter_async.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,15 @@ async def create_code_context(
231231
self,
232232
cwd: Optional[str] = None,
233233
language: Optional[str] = None,
234+
user: Optional[Literal["root", "user"]] = None,
234235
request_timeout: Optional[float] = None,
235236
) -> Context:
236237
"""
237238
Creates a new context to run code in.
238239
239240
:param cwd: Set the current working directory for the context, defaults to `/home/user`
240241
:param language: Language of the context. If not specified, defaults to Python
242+
:param user: User of the context. If not specified, defaults to `root`
241243
:param request_timeout: Timeout for the request in **milliseconds**
242244
243245
:return: Context object
@@ -249,6 +251,8 @@ async def create_code_context(
249251
data["language"] = language
250252
if cwd:
251253
data["cwd"] = cwd
254+
if user:
255+
data["user"] = user
252256

253257
try:
254258
response = await self._client.post(

0 commit comments

Comments
 (0)