Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

feat(js-sdk,py-sdk): Add Bash support to runCode (#187)

Pavel 'Strajk' Dolecek2f2f02ce65b1
diff --git a/.changeset/poor-rules-appear.md b/.changeset/poor-rules-appear.md
new file mode 100644
index 000000000..ff2df2640
--- /dev/null
+++ b/.changeset/poor-rules-appear.md
@@ -0,0 +1,6 @@
+---
+'@e2b/python-sdk': minor
+'@e2b/sdk': minor
+---
+
+Add Bash support to runCode
diff --git a/packages/js-sdk/src/runCode.ts b/packages/js-sdk/src/runCode.ts
index c38f67e09..ee57977cd 100644
--- a/packages/js-sdk/src/runCode.ts
+++ b/packages/js-sdk/src/runCode.ts
@@ -3,6 +3,14 @@ import { Session } from './session'
export enum CodeRuntime {
Node16 = 'Node16',
Python3 = 'Python3',
+ Bash = 'Bash',
+ // TODO: Support all runtimes that our infra supports
+ // DotNET = 'DotNET',
+ // Go = 'Go',
+ // Java = 'Java',
+ // Perl = 'Perl',
+ // PHP = 'PHP',
+ // Rust = 'Rust',
}
/**
@@ -39,6 +47,11 @@ export async function runCode(
binary = 'python3'
filepath = '/main.py'
break
+ case CodeRuntime.Bash:
+ envID = 'Bash'
+ binary = 'bash'
+ filepath = '/main.sh'
+ break
default:
throw new Error(
`The "${runtime}" runtime isn't supported. Please contact us ([email protected]) if you need support for this runtime`,
diff --git a/packages/python-sdk/e2b/session/run_code.py b/packages/python-sdk/e2b/session/run_code.py
index 7fcd528b6..ec93c1fba 100644
--- a/packages/python-sdk/e2b/session/run_code.py
+++ b/packages/python-sdk/e2b/session/run_code.py
@@ -8,6 +8,14 @@ from .exception import UnsupportedRuntimeException
CodeRuntime = Literal[
"Node16",
"Python3",
+ "Bash",
+ # TODO: Support all runtimes that our infra supports
+ # DotNET = 'DotNET',
+ # Go = 'Go',
+ # Java = 'Java',
+ # Perl = 'Perl',
+ # PHP = 'PHP',
+ # Rust = 'Rust',
]
@@ -40,6 +48,10 @@ async def run_code(
env_id = "Python3"
binary = "python3"
filepath = "/index.py"
+ elif runtime == "Bash":
+ env_id = "Bash"
+ binary = "bash"
+ filepath = "/main.sh"
else:
raise UnsupportedRuntimeException(
f'Invalid runtime "{runtime}". Please contact us ([email protected]) if you need support for this runtime'