Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Pass env vars with commands
Tomas Valenta0143ff25f2c3
diff --git a/api-service/app.py b/api-service/app.pyindex c28f41cd6..f0064a71f 100644--- a/api-service/app.py+++ b/api-service/app.py@@ -1,5 +1,6 @@import osimport uuid+from codegen.tools.playground.tools.process import encode_command_outputfrom dotenv import load_dotenvfrom typing import Listdiff --git a/api-service/session/env.py b/api-service/session/env.pyindex d61a56d54..310c4c70a 100644--- a/api-service/session/env.py+++ b/api-service/session/env.py@@ -16,3 +16,10 @@ def format_env_vars(envs: List[EnvVar]) -> dict[str, str]:envs,{},)++def cmd_with_env_vars(cmd: str, envs: dict[str, str]):+ return reduce(+ lambda acc, env: f"{env[0]}={env[1]} " + acc,+ envs.items(),+ cmd,+ )diff --git a/api-service/session/playground/base.py b/api-service/session/playground/base.pyindex c7d9f9912..46646e748 100644--- a/api-service/session/playground/base.py+++ b/api-service/session/playground/base.py@@ -1,5 +1,6 @@import timeimport math+from session.env import cmd_with_env_varsfrom session.session import GetEnvs, Sessionfrom playground_client.models.create_mock_body_data_request import (@@ -8,7 +9,6 @@ from playground_client.models.create_mock_body_data_request import (import playground_clientfrom playground_client.models.file import File-class Playground(Session):port_check_interval = 0.5 # 500msmax_port_checks = 10@@ -42,7 +42,8 @@ class Playground(Session):response = self.api.start_process(self.id,playground_client.StartProcessParams(- cmd=cmd,+ cmd=cmd_with_env_vars(cmd, self.env_vars),+ # TODO: Env vars are not correctly passed to the devbookd process - that's why we add them with cmd_with_env_vars.envVars=self.env_vars,rootdir=rootdir,),@@ -80,7 +81,8 @@ class Playground(Session):return self.api.start_process(self.id,playground_client.StartProcessParams(- cmd=cmd,+ cmd=cmd_with_env_vars(cmd, self.env_vars),+ # TODO: Env vars are not correctly passed to the devbookd process - that's why we add them with cmd_with_env_vars.envVars=self.env_vars,rootdir=rootdir,),