Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Fix agent playground handling [WIP]
Tomas Valenta73a0017f8556
diff --git a/.github/workflows/api.yml b/.github/workflows/api.ymlindex a2580c4cb..69625f9f8 100644--- a/.github/workflows/api.yml+++ b/.github/workflows/api.yml@@ -1,4 +1,4 @@-name: Build and Deploy to Google Compute Engine+name: Build and Deploy API to Google Compute Engineon:push:diff --git a/api-service/agent/from_template.py b/api-service/agent/from_template.pyindex 0e9f0bd9f..e0e19bd6b 100644--- a/api-service/agent/from_template.py+++ b/api-service/agent/from_template.py@@ -5,9 +5,11 @@ from agent.smol_agent import SmolAgentdef get_agent_factory_from_template(template_id: str):match template_id:- case "smol":+ case "SmolDeveloper":return SmolAgent.create- case "stripe":+ case "StripeCheckout":return StripeAgent.create+ case "NodeJSExpress":+ return BasicAgent.createcase _:return BasicAgent.creatediff --git a/api-service/agent/smol_agent.py b/api-service/agent/smol_agent.pyindex 069dcc547..6982cec04 100644--- a/api-service/agent/smol_agent.py+++ b/api-service/agent/smol_agent.py@@ -60,7 +60,7 @@ class SmolAgent(AgentBase):)async def _dev(self, instructions: Any):- user_prompt: str = instructions["prompt"]+ user_prompt: str = instructions["Prompt"]file: str | None = instructions.get("file", None)playground = None@@ -70,7 +70,9 @@ class SmolAgent(AgentBase):playground = Playground(env_id="PPSrlH5TIvFx", get_envs=self.get_envs)- await playground.checkout_repo(instructions["RepoURL"], "/repo")+ rootdir = "/repo"+ await playground.change_rootdir(rootdir)+ await playground.checkout_repo(instructions["RepoURL"], False, rootdir)async def clean_dir():extensions_to_skip = [@@ -85,7 +87,7 @@ class SmolAgent(AgentBase):".tiff",] # Add more extensions if needed- files = await playground.get_filenames("/repo", [])+ files = await playground.get_filenames(rootdir, [])for file in files:_, extension = os.path.splitext(file.name)if extension not in extensions_to_skip:@@ -226,6 +228,7 @@ class SmolAgent(AgentBase):finally:if playground is not None:playground.close()+await self.on_interaction_request(AgentInteractionRequest(interaction_id=str(uuid.uuid4()),@@ -234,7 +237,7 @@ class SmolAgent(AgentBase):)async def _dev_in_background(self, instructions: Any):- print("Start agent run")+ print("Start agent run", self._dev_loop)if self._dev_loop:print("Agent run already in progress")diff --git a/api-service/agent/stripe_agent.py b/api-service/agent/stripe_agent.pyindex 76cdae63f..1a8c68c7d 100644--- a/api-service/agent/stripe_agent.py+++ b/api-service/agent/stripe_agent.py@@ -166,7 +166,7 @@ class StripeAgent(AgentBase):# Create playground for code toolsplayground = NodeJSPlayground(get_envs=self.get_envs)- await playground.checkout_repo(instructions["RepoURL"], "/repo")+ await playground.checkout_repo(instructions["RepoURL"], True, "/repo")tools = list(create_tools(playground=playground))self.tool_names = [tool.name for tool in tools]diff --git a/api-service/session/playground/base.py b/api-service/session/playground/base.pyindex e15a4e32d..7bf3e271b 100644--- a/api-service/session/playground/base.py+++ b/api-service/session/playground/base.py@@ -40,26 +40,21 @@ class Playground(Session):for open_port in open_ports)- async def checkout_repo(self, repo_url: str, rootdir: str):- # WIP- await self.make_dir("/repo")- # await self.run_command(- # """- # apk add \- # --no-cache \- # --allow-untrusted \- # --repository http://dl-cdn.alpinelinux.org/alpine/v3.15/main git- # """- # )- # await self.run_command('git config --global http.sslVerify "false"')+ async def install_deps(self, rootdir: str):await self.run_command("apk add npm")+ await self.run_command(f"npm install --prefix {rootdir}", rootdir="/")++ async def checkout_repo(self, repo_url: str, install: bool, rootdir: str):+ await self.make_dir(rootdir)+ if install:+ await self.install_deps(rootdir)res = await self.run_command(- f"git clone {repo_url} /repo && npm install --prefix /repo",+ f"git clone {repo_url} {rootdir}",rootdir="/",)print("res", res)- async def push_repo(self, access_token: str):+ async def push_repo(self):id = str(uuid.uuid4())[:8]print(await self.run_command(f"echo 2 > /repo/test.txt"))diff --git a/components/Editor/Sidebar/Deploy.tsx b/components/Editor/Sidebar/Deploy.tsxindex b01028f72..8d1caa62c 100644--- a/components/Editor/Sidebar/Deploy.tsx+++ b/components/Editor/Sidebar/Deploy.tsx@@ -22,13 +22,13 @@ export interface Props {}function getSnippet(hostname: string, deploymentID: string) {- return `curl --request POST \- --url http://${hostname}/deployments/${deploymentID}/interactions \- --data '{- "type": "start",+ return `curl --request POST \\+--url ${hostname}/deployments/${deploymentID}/interactions \\+--data '{+ "type": "","data": {- "instructions": {}- }+ "instructions": {}+ }}'`}@@ -160,37 +160,10 @@ function Deploy({ project }: Props) {text-xsbg-slate-100overflow-auto+ whitespace-pre-wrap"><code>- {`curl --request POST \\- --url ${baseDeploymentURL}/interactions \\- --data '{- "type": "start",- "data": {- "instructions": {- "Description": "Add Stripe Checkout",- "RepoURL": "https://github.com/e2b-dev/test.git"- }- }-}'`}- </code>- </pre>- </div>- <div>- <Text- text="Agent logs"- />- <pre className="- p-2- rounded- font-mono- text-xs- bg-slate-100- overflow-auto- ">- <code>- {`curl --request GET \\- --url ${baseDeploymentURL}/logs`}+ {getSnippet(process.env.NEXT_PUBLIC_API_URL!, deployment.id)}</code></pre></div>