Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Add push [WIP]
Tomas Valentac8698d8275e9
diff --git a/api-service/poetry.lock b/api-service/poetry.lockindex 590e9a9d6..ed1de11af 100644--- a/api-service/poetry.lock+++ b/api-service/poetry.lock@@ -2908,6 +2908,17 @@ brotli = ["brotli (>=1.0.9)", "brotlicffi (>=0.8.0)", "brotlipy (>=0.6.0)"]secure = ["certifi", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "ipaddress", "pyOpenSSL (>=0.14)", "urllib3-secure-extra"]socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"]+[[package]]+name = "uuid"+version = "1.30"+description = "UUID object and generation functions (Python 2.3 or higher)"+category = "main"+optional = false+python-versions = "*"+files = [+ {file = "uuid-1.30.tar.gz", hash = "sha256:1f87cc004ac5120466f36c5beae48b4c48cc411968eed0eaecd3da82aa96193f"},+]+[[package]]name = "uvicorn"version = "0.22.0"@@ -3244,4 +3255,4 @@ cffi = ["cffi (>=1.11)"][metadata]lock-version = "2.0"python-versions = ">=3.10,<4.0"-content-hash = "ee258824f88936140db1334b00417ee185c68aba1e03eedced9daa25445a1e16"+content-hash = "3747b2a601b49aaa1b335f73c90bdf3422e03db902a08a41dff88442b406b262"diff --git a/api-service/pyproject.toml b/api-service/pyproject.tomlindex c9088d9de..76284e8b7 100644--- a/api-service/pyproject.toml+++ b/api-service/pyproject.toml@@ -24,6 +24,7 @@ chevron = "^0.14.0"chromadb = "^0.3.22"openai = "^0.27.6"tiktoken = "^0.4.0"+uuid = "^1.30"[tool.poetry.group.dev]optional = truediff --git a/api-service/session/playground/base.py b/api-service/session/playground/base.pyindex 1cc872f01..d5568cea7 100644--- a/api-service/session/playground/base.py+++ b/api-service/session/playground/base.py@@ -1,4 +1,5 @@import math+import uuidfrom typing import Any, Listfrom asyncio import sleep@@ -42,15 +43,15 @@ class Playground(Session):async def checkout_repo(self, repo_url: str, rootdir: str):# WIPawait 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"')+ # 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"')res = await self.run_command(f"git clone {repo_url} /repo && npm install --prefix /repo",rootdir="/",@@ -59,14 +60,27 @@ apk add \async def push_repo(self, repo_url: str):await self.run_command(- """-apk add \- --no-cache \- --allow-untrusted \- --repository http://dl-cdn.alpinelinux.org/alpine/v3.15/main github-cli- """+ """wget http://github.com/cli/cli/releases/download/v2.29.0/gh_2.29.0_linux_amd64.tar.gz --no-check-certificate && tar -xzf gh_2.29.0_linux_amd64.tar.gz && mv gh_2.29.0_linux_amd64 gh""",+ rootdir="/",)- await self.run_command(f"git push")++ gh = "/gh/bin/gh"+ # Restricted token+ await self.write_file(+ "/github_token",+ "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",+ )++ id = str(uuid.uuid4())[:8]++ await self.run_command(f"{gh} auth login --with-token < /github_token")+ await self.run_command(f"git config --global user.email agent1")+ await self.run_command(f"git checkout -b pr-{id}")+ await self.run_command(f"git add .", rootdir="/repo")+ await self.run_command(f"git commit -m", rootdir="/repo")+ await self.run_command(f"{gh} auth setup-git")+ await self.run_command(f"git push --set-upstream origin {id}")+ await self.run_command(f"{gh} pr create --title 'PR-{id}' --body 'PR-{id}'")async def change_rootdir(self, rootdir: str):self.rootdir = rootdirdiff --git a/api-service/session/playground/nodejs.py b/api-service/session/playground/nodejs.pyindex 16bfd5ec5..67b6b140c 100644--- a/api-service/session/playground/nodejs.py+++ b/api-service/session/playground/nodejs.py@@ -5,7 +5,7 @@ from session.session import GetEnvsclass NodeJSPlayground(Playground):- node_js_env_id = "QFNlQVCzcKxD"+ node_js_env_id = "QJ5rs6J23K7e"rootdir = "/repo"default_javascript_code_file = os.path.join(rootdir, "index.mjs")run_code_timeout = 3 # 3sdiff --git a/components/Editor/Sidebar/Deploy.tsx b/components/Editor/Sidebar/Deploy.tsxindex 8988dec77..a87d23216 100644--- a/components/Editor/Sidebar/Deploy.tsx+++ b/components/Editor/Sidebar/Deploy.tsx@@ -21,6 +21,22 @@ export interface Props {project: projects}++function getSnippet(hostname: string, deploymentId: string) {+ return `curl --request POST \+ --url http://${hostname}/deployments/${deploymentId}/interactions \+ --data '{+ "type": "start",+ "data": {+ "instructions": {+ "Description": "Add Stripe Checkout",+ "RepoURL": "https://github.com/e2b-dev/test.git"+ }+ }+}'`+}++function Deploy({ project }: Props) {const [selectors] = useStateStore()const modelConfig = selectors.use.getSelectedModelConfig()()diff --git a/hooks/useDeployment.ts b/hooks/useDeployment.tsindex 56295c9f0..9888a18a1 100644--- a/hooks/useDeployment.ts+++ b/hooks/useDeployment.ts@@ -12,8 +12,7 @@ function useDeployment(project: projects) {const client = useSupabaseClient<Database>()useEffect(function init() {- (async function () {- // TODO: SECURITY - Enable row security for all tables and secure access to deployments.+ const i = setInterval(async () => {const deployment = await client.from(deploymentsTable).select('*')@@ -25,7 +24,11 @@ function useDeployment(project: projects) {if (!deployment) returnif (deployment.error) returnsetInitDeployment(deployment.data as unknown as deployments)- }())+ }, 1000)++ return () => {+ clearInterval(i)+ }}, [client, project.id])// Sometimes a large field from realtime server can be missing because of the internal POSTGRES/TOAST workings.@@ -46,8 +49,21 @@ function useDeployment(project: projects) {}).subscribe()+ const updateSub = client.channel('any')+ .on('postgres_changes',+ {+ event: 'UPDATE',+ schema: 'public',+ table: deploymentsTable,+ filter: `project_id=eq.${project.id}`,+ }, payload => {+ setDeployment(payload.new as deployments)+ })+ .subscribe()+return () => {insertSub.unsubscribe()+ updateSub.unsubscribe()}}, [client,