Skip to content

armgit / E2B

Public Imported from GitHub
0

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

Fix compose config; Update readme; Add automatic sign in [WIP]

Tomas Valenta4631368b0c8c
diff --git a/README.md b/README.md
index 220ec7a88..9d71fb375 100644
--- a/README.md
+++ b/README.md
@@ -36,6 +36,59 @@ While e2b will offer the "batteries-included" solution, our goal is to let users
We think the AI-powered IDE for the future should be open-sourced and allow anybody to bring their models, customize the prompts, and develop custom tools for the agents. But we also plan to offer a cloud version with some features behind subscription though.
## Get started
+If you want to to try the IDE locally the fastest way is doing the following steps which starts the app in Docker.
+
+You will need:
+- GPT-4 access (support for more and custom models coming soon)
+- Docker
+- Node.js *16+*
+
+### 1. Add env vars
+Create `.env` file by copying the [`.env.example`](.env.example)
+```
+cp .env.example .env
+```
+and fill in the following variables:
+- `OPENAI_API_KEY` - your [OpenAI key](https://platform.openai.com/account/api-keys)
+
+### 2. Start the app
+```
+yarn start
+```
+or
+```
+npm run start
+```
+Then open the page on [http://localhost:3000](http://localhost:3000).
+
+> `yarn start` starts local Supabase in the background - to stop it you have to run `yarn stop`.
+
+> If you want run the project without using containers use the [guide here](#development). This is useful if you want to leverage hot reloading and develop the project.
+
+## Current state
+e2b is a work in progress. The `developer <--> AI agent` cooperation creates completely new paradigms. We're exploring how the ideal UX, UI, and cooperation with the agents should look like. The app will surely go through a lot of changes in the short and medium term.
+
+e2b currently support building only REST servers in Node.js. Specifically using the [Express](https://expressjs.com/) framework. We'll support more languages and frameworks with time. The goal for e2b is to eventually be able to handle any use-case.
+
+## How are we going to make money?
+You will always be able to self-host e2b for free. We will also offer a cloud version. The current idea is to offer the base cloud version for free while having some features for individuals behind a subscription. We'll share more on pricing for companies and enterprises in the future.
+
+## Early demos
+- [AI Agent using coding tools](https://twitter.com/mlejva/status/1636103084802822151)
+- [Build your custom "Just-In-Time" UI](https://twitter.com/mlejva/status/1641151421830529042)
+- [Agent coded a full Stripe customer checkout by following a technical spec provided by user](https://twitter.com/mlejva/status/1641072535163875330)
+
+## Roadmap
+Short-term goals, in no particular order.
+
+- ~Come up with the name~
+- ~Clean up codebase and provide instructions on how to run it locally~
+- ~Set up a website~
+- Launch the initial version
+
+## Development
+For developing and contributing to the project you may want to run the app locally without Docker Compose (`yarn start` command). Here are the steps for how to it.
+
You will need:
- GPT-4 access (support for more and custom models coming soon)
- Docker
@@ -79,25 +132,3 @@ Then open the page on [http://localhost:3000](http://localhost:3000) and sign in
**Password**
-
-
-## Current state
-e2b is a work in progress. The `developer <--> AI agent` cooperation creates completely new paradigms. We're exploring how the ideal UX, UI, and cooperation with the agents should look like. The app will surely go through a lot of changes in the short and medium term.
-
-e2b currently support building only REST servers in Node.js. Specifically using the [Express](https://expressjs.com/) framework. We'll support more languages and frameworks with time. The goal for e2b is to eventually be able to handle any use-case.
-
-## How are we going to make money?
-You will always be able to self-host e2b for free. We will also offer a cloud version. The current idea is to offer the base cloud version for free while having some features for individuals behind a subscription. We'll share more on pricing for companies and enterprises in the future.
-
-## Early demos
-- [AI Agent using coding tools](https://twitter.com/mlejva/status/1636103084802822151)
-- [Build your custom "Just-In-Time" UI](https://twitter.com/mlejva/status/1641151421830529042)
-- [Agent coded a full Stripe customer checkout by following a technical spec provided by user](https://twitter.com/mlejva/status/1641072535163875330)
-
-## Roadmap
-Short-term goals, in no particular order.
-
-- ~Come up with the name~
-- ~Clean up codebase and provide instructions on how to run it locally~
-- ~Set up a website~
-- Launch the initial version
diff --git a/api-service/playground/src/data/logOutput.ts b/api-service/playground/src/data/logOutput.ts
index 426e6b5ff..0d0bbb8af 100644
--- a/api-service/playground/src/data/logOutput.ts
+++ b/api-service/playground/src/data/logOutput.ts
@@ -9,7 +9,7 @@ dotenv.config({
path: '../../.env',
})
-const client = createClient<Database>(process.env.NEXT_PUBLIC_SUPABASE_URL!, process.env.SUPABASE_SERVICE_ROLE_KEY!)
+const client = createClient<Database>(process.env.SUPABASE_URL || process.env.NEXT_PUBLIC_SUPABASE_URL!, process.env.SUPABASE_SERVICE_ROLE_KEY!)
export const projectsTable = 'projects'
export const deploymentsTable = 'deployments'
diff --git a/components/AuthForm.tsx b/components/AuthForm.tsx
index 0b3e2fc48..b0d9c32ed 100644
--- a/components/AuthForm.tsx
+++ b/components/AuthForm.tsx
@@ -1,5 +1,5 @@
import clsx from 'clsx'
-import { useEffect, useRef, useState } from 'react'
+import { useEffect, useRef, useState, useCallback } from 'react'
import { useSupabaseClient } from '@supabase/auth-helpers-react'
import { useRouter } from 'next/router'
@@ -27,26 +27,11 @@ function AuthForm({ authType }: Props) {
const emailRef = useRef<HTMLInputElement>(null)
const passwordRef = useRef<HTMLInputElement>(null)
- useEffect(
- function autofocusEmailInput() {
- if (isLoading) return
-
- if (!emailRef.current?.value) {
- emailRef.current?.focus()
- } else if (!passwordRef.current?.value) {
- passwordRef.current?.focus()
- } else {
- emailRef.current?.focus()
- }
- },
- [isLoading],
- )
-
- async function authWithEmail() {
+ const authWithEmail = useCallback(async (email?: string, password?: string) => {
setIsLoading(true)
- const email = emailRef.current?.value
- const password = passwordRef.current?.value
+ email = email || emailRef.current?.value
+ password = password || passwordRef.current?.value
if (!email) {
setErrMessage('Email must not be empty')
@@ -83,7 +68,30 @@ function AuthForm({ authType }: Props) {
}
setIsLoading(false)
- }
+ }, [supabaseClient, router, authType])
+
+ useEffect(function autoSignIn() {
+ if (process.env.NEXT_PUBLIC_SIGN_IN_EMAIL && process.env.NEXT_PUBLIC_SIGN_IN_PASSWORD) {
+ console.log(process.env.NEXT_PUBLIC_SIGN_IN_PASSWORD)
+ authWithEmail(process.env.NEXT_PUBLIC_SIGN_IN_EMAIL, process.env.NEXT_PUBLIC_SIGN_IN_PASSWORD)
+ }
+ }, [authWithEmail])
+
+ useEffect(
+ function autofocusEmailInput() {
+ if (isLoading) return
+
+ if (!emailRef.current?.value) {
+ emailRef.current?.focus()
+ } else if (!passwordRef.current?.value) {
+ passwordRef.current?.focus()
+ } else {
+ emailRef.current?.focus()
+ }
+ },
+ [isLoading],
+ )
+
const title = authType === AuthFormType.SignUp ? 'Create a new account' : 'Sign in'
diff --git a/components/Editor/Sidebar/index.tsx b/components/Editor/Sidebar/index.tsx
index cea6df4ae..1d94195a5 100644
--- a/components/Editor/Sidebar/index.tsx
+++ b/components/Editor/Sidebar/index.tsx
@@ -24,7 +24,8 @@ export enum MenuSection {
// Deploy = 'Deploy',
}
-const apiHost = process.env.NODE_ENV === 'development'
+const apiHost = process.env.API_URL
+ || process.env.NODE_ENV === 'development'
? 'http://localhost:49155'
: 'https://ai-api-service-7d2cl2hooq-uc.a.run.app'
diff --git a/docker-compose.yml b/docker-compose.yml
index 7d0ccbd55..7fdd30dc5 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -7,37 +7,43 @@ services:
context: ./api-service
environment:
- PORT=49155
- - NEXT_PUBLIC_SUPABASE_URL=${NEXT_PUBLIC_SUPABASE_URL}
+ - NEXT_PUBLIC_SUPABASE_URL=http://supabase_kong_workspace:8000
- SUPABASE_SERVICE_ROLE_KEY=${SUPABASE_SERVICE_ROLE_KEY}
- OPENAI_API_KEY=${OPENAI_API_KEY}
expose:
- 49155
+ external_links:
+ - supabase_kong_workspace
+ - supabase_db_workspace
networks:
- supabase-local-net
- - api-net
app-dev:
image: gcr.io/e2b/app-dev:latest
build:
context: ./
+ external_links:
+ - supabase_kong_workspace
+ - supabase_db_workspace
depends_on:
- api
environment:
- NODE_ENV=development
+ - API_URL=http://api:49155
+ - SUPABASE_URL=http://supabase_kong_workspace:8000
+ - SUPABASE_POSTGRES_URL=postgresql://postgres:postgres@supabase_db_workspace:5432/postgres
- NEXT_PUBLIC_SUPABASE_URL=${NEXT_PUBLIC_SUPABASE_URL}
- - SUPABASE_POSTGRES_POOL_URL=${SUPABASE_POSTGRES_POOL_URL}
- SUPABASE_SERVICE_ROLE_KEY=${SUPABASE_SERVICE_ROLE_KEY}
- NEXT_PUBLIC_SUPABASE_ANON_KEY=${NEXT_PUBLIC_SUPABASE_ANON_KEY}
ports:
- 3000:3000
networks:
- supabase-local-net
- - api-net
networks:
- api-net:
- driver: bridge
supabase-local-net:
- # This name identified the network -
+ # This name identified the network with supabase containers started with `supabase start`.
name: supabase_network_workspace
external: true
\ No newline at end of file
diff --git a/package.json b/package.json
index 4ffa3dd7f..07fc70f35 100644
--- a/package.json
+++ b/package.json
@@ -10,7 +10,7 @@
"start:playground": "cd api-service/playground && yarn dev",
"install:api-service": "cd api-service && poetry install && cd playground && yarn",
"install:all": "yarn && yarn install:api-service",
- "start": "yarn db:start && docker compose up",
+ "start": "yarn db:start && docker compose up --build",
"stop": "docker compose down && yarn db:stop",
"lint": "next lint",
"lint:fix": "next lint --fix",