AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
Revert "feat(docker): add frontend service to docker-compose with env config improvements" (#10577)
Nicholas Tindlec972f347130c
diff --git a/.github/workflows/platform-frontend-ci.yml b/.github/workflows/platform-frontend-ci.ymlindex f951ed15fd..4e3357ffb3 100644--- a/.github/workflows/platform-frontend-ci.yml+++ b/.github/workflows/platform-frontend-ci.yml@@ -195,7 +195,7 @@ jobs:- name: Run docker composerun: |- NEXT_PUBLIC_PW_TEST=true docker compose -f ../docker-compose.yml up -d+ docker compose -f ../docker-compose.yml up -denv:DOCKER_BUILDKIT: 1BUILDX_CACHE_FROM: type=local,src=/tmp/.buildx-cache@@ -258,6 +258,8 @@ jobs:- name: Build frontendrun: pnpm build --turbo# uses Turbopack, much faster and safe enough for a test pipeline+ env:+ NEXT_PUBLIC_PW_TEST: true- name: Install Browser 'chromium'run: pnpm playwright install --with-deps chromiumdiff --git a/autogpt_platform/README.md b/autogpt_platform/README.mdindex dd9f344af0..8422a29f0e 100644--- a/autogpt_platform/README.md+++ b/autogpt_platform/README.md@@ -8,6 +8,7 @@ Welcome to the AutoGPT Platform - a powerful system for creating and running AI- Docker- Docker Compose V2 (comes with Docker Desktop, or can be installed separately)+- Node.js & NPM (for running the frontend application)### Running the System@@ -36,7 +37,44 @@ To run the AutoGPT Platform, follow these steps:This command will start all the necessary backend services defined in the `docker-compose.yml` file in detached mode.-4. After all the services are in ready state, open your browser and navigate to `http://localhost:3000` to access the AutoGPT Platform frontend.+4. Navigate to `frontend` within the `autogpt_platform` directory:++ ```+ cd frontend+ ```++ You will need to run your frontend application separately on your local machine.++5. Run the following command:++ ```+ cp .env.example .env.local+ ```++ This command will copy the `.env.example` file to `.env.local` in the `frontend` directory. You can modify the `.env.local` within this folder to add your own environment variables for the frontend application.++6. Run the following command:++ Enable corepack and install dependencies by running:++ ```+ corepack enable+ pnpm i+ ```++ Generate the API client (this step is required before running the frontend):++ ```+ pnpm generate:api-client+ ```++ Then start the frontend application in development mode:++ ```+ pnpm dev+ ```++7. Open your browser and navigate to `http://localhost:3000` to access the AutoGPT Platform frontend.### Docker Compose Commandsdiff --git a/autogpt_platform/docker-compose.platform.yml b/autogpt_platform/docker-compose.platform.ymlindex 46fa40873e..12a1ffc647 100644--- a/autogpt_platform/docker-compose.platform.yml+++ b/autogpt_platform/docker-compose.platform.yml@@ -277,47 +277,34 @@ services:networks:- app-network- # Frontend environment variables- x-frontend-vars: &frontend-vars- NEXT_PUBLIC_SUPABASE_URL: http://localhost:8000- NEXT_PUBLIC_SUPABASE_ANON_KEY: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJhbm9uIiwKICAgICJpc3MiOiAic3VwYWJhc2UtZGVtbyIsCiAgICAiaWF0IjogMTY0MTc2OTIwMCwKICAgICJleHAiOiAxNzk5NTM1NjAwCn0.dc_X5iR_VP_qT0zsiyj_I_OZ2T9FtRU2BBNWN8Bu4GE- NEXT_PUBLIC_AGPT_SERVER_URL: http://localhost:8006/api- NEXT_PUBLIC_AGPT_WS_SERVER_URL: ws://localhost:8001/ws- NEXT_PUBLIC_FRONTEND_BASE_URL: http://localhost:3000- NEXT_PUBLIC_BEHAVE_AS: LOCAL- NEXT_PUBLIC_LAUNCHDARKLY_ENABLED: false- NEXT_PUBLIC_LAUNCHDARKLY_CLIENT_ID: 687ab1372f497809b131e06e- NEXT_PUBLIC_APP_ENV: local- NEXT_PUBLIC_DEFAULT_LOCALE: en- NEXT_PUBLIC_LOCALES: en,es- NEXT_PUBLIC_SHOW_BILLING_PAGE: false- NEXT_PUBLIC_TURNSTILE: disabled- NEXT_PUBLIC_REACT_QUERY_DEVTOOL: true- NEXT_PUBLIC_GA_MEASUREMENT_ID: G-FH2XK2W4GN- NEXT_PUBLIC_PW_TEST: "${NEXT_PUBLIC_PW_TEST:-}"+# frontend:+# build:+# context: ../+# dockerfile: autogpt_platform/frontend/Dockerfile+# target: dev+# depends_on:+# db:+# condition: service_healthy+# rest_server:+# condition: service_started+# websocket_server:+# condition: service_started+# migrate:+# condition: service_completed_successfully+# environment:+# - NEXT_PUBLIC_SUPABASE_URL=http://kong:8000+# - NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJhbm9uIiwKICAgICJpc3MiOiAic3VwYWJhc2UtZGVtbyIsCiAgICAiaWF0IjogMTY0MTc2OTIwMCwKICAgICJleHAiOiAxNzk5NTM1NjAwCn0.dc_X5iR_VP_qT0zsiyj_I_OZ2T9FtRU2BBNWN8Bu4GE+# - DATABASE_URL=postgresql://agpt_user:pass123@postgres:5432/postgres?connect_timeout=60&schema=platform+# - DIRECT_URL=postgresql://agpt_user:pass123@postgres:5432/postgres?connect_timeout=60&schema=platform+# - NEXT_PUBLIC_AGPT_SERVER_URL=http://localhost:8006/api+# - NEXT_PUBLIC_AGPT_WS_SERVER_URL=ws://localhost:8001/ws+# - NEXT_PUBLIC_AGPT_MARKETPLACE_URL=http://localhost:8015/api/v1/market+# - NEXT_PUBLIC_BEHAVE_AS=LOCAL+# ports:+# - "3000:3000"+# networks:+# - app-network- frontend:- build:- context: ../- dockerfile: autogpt_platform/frontend/Dockerfile- target: prod- args: *frontend-vars- depends_on:- db:- condition: service_healthy- migrate:- condition: service_completed_successfully- ports:- - "3000:3000"- networks:- - app-network- environment:- <<: *frontend-vars- # Server-side environment variables (Docker service names)- AUTH_CALLBACK_URL: http://rest_server:8006/auth/callback- SUPABASE_URL: http://kong:8000- AGPT_SERVER_URL: http://rest_server:8006/api- AGPT_WS_SERVER_URL: ws://websocket_server:8001/wsnetworks:app-network:driver: bridgediff --git a/autogpt_platform/docker-compose.yml b/autogpt_platform/docker-compose.ymlindex 706ac807fb..5eb1e2928d 100644--- a/autogpt_platform/docker-compose.yml+++ b/autogpt_platform/docker-compose.yml@@ -90,11 +90,11 @@ services:timeout: 10sretries: 3- frontend:- <<: *agpt-services- extends:- file: ./docker-compose.platform.yml- service: frontend+ # frontend:+ # <<: *agpt-services+ # extends:+ # file: ./docker-compose.platform.yml+ # service: frontend# Supabase servicesstudio:@@ -190,17 +190,3 @@ services:- redis- rabbitmq- clamav- - migrate-- deps_backend:- <<: *agpt-services- profiles:- - local- image: busybox- command: /bin/true- depends_on:- - deps- - rest_server- - executor- - websocket_server- - database_managerdiff --git a/autogpt_platform/frontend/.env.example b/autogpt_platform/frontend/.env.exampleindex 9a9b4ad037..6532e200b3 100644--- a/autogpt_platform/frontend/.env.example+++ b/autogpt_platform/frontend/.env.example@@ -3,10 +3,13 @@ NEXT_PUBLIC_FRONTEND_BASE_URL=http://localhost:3000NEXT_PUBLIC_AUTH_CALLBACK_URL=http://localhost:8006/auth/callbackNEXT_PUBLIC_AGPT_SERVER_URL=http://localhost:8006/apiNEXT_PUBLIC_AGPT_WS_SERVER_URL=ws://localhost:8001/ws+NEXT_PUBLIC_AGPT_MARKETPLACE_URL=http://localhost:8015/api/v1/marketNEXT_PUBLIC_LAUNCHDARKLY_ENABLED=falseNEXT_PUBLIC_LAUNCHDARKLY_CLIENT_ID=687ab1372f497809b131e06e # Local environment on Launch darklyNEXT_PUBLIC_APP_ENV=local+NEXT_PUBLIC_AGPT_SERVER_BASE_URL=http://localhost:8006+## Locale settingsNEXT_PUBLIC_DEFAULT_LOCALE=en@@ -17,10 +20,15 @@ NEXT_PUBLIC_LOCALES=en,esNEXT_PUBLIC_SUPABASE_URL=http://localhost:8000NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJhbm9uIiwKICAgICJpc3MiOiAic3VwYWJhc2UtZGVtbyIsCiAgICAiaWF0IjogMTY0MTc2OTIwMCwKICAgICJleHAiOiAxNzk5NTM1NjAwCn0.dc_X5iR_VP_qT0zsiyj_I_OZ2T9FtRU2BBNWN8Bu4GE+## OAuth Callback URL+## This should be {domain}/auth/callback+## Only used if you're using Supabase and OAuth+AUTH_CALLBACK_URL="${NEXT_PUBLIC_FRONTEND_BASE_URL}/auth/callback"+GA_MEASUREMENT_ID=G-FH2XK2W4GN+# When running locally, set NEXT_PUBLIC_BEHAVE_AS=CLOUD to use the a locally hosted marketplace (as is typical in development, and the cloud deployment), otherwise set it to LOCAL to have the marketplace open in a new tabNEXT_PUBLIC_BEHAVE_AS=LOCALNEXT_PUBLIC_SHOW_BILLING_PAGE=false-NEXT_PUBLIC_GA_MEASUREMENT_ID=G-FH2XK2W4GN## Cloudflare Turnstile (CAPTCHA) Configuration## Get these from the Cloudflare Turnstile dashboard: https://dash.cloudflare.com/?to=/:account/turnstilediff --git a/autogpt_platform/frontend/Dockerfile b/autogpt_platform/frontend/Dockerfileindex 3def4f2c6b..583dbcada9 100644--- a/autogpt_platform/frontend/Dockerfile+++ b/autogpt_platform/frontend/Dockerfile@@ -15,42 +15,6 @@ CMD ["pnpm", "run", "dev", "--hostname", "0.0.0.0"]# Build stage for prodFROM base AS build-# Accept build args for NEXT_PUBLIC_* variables-ARG NEXT_PUBLIC_SUPABASE_URL-ARG NEXT_PUBLIC_SUPABASE_ANON_KEY-ARG NEXT_PUBLIC_AGPT_SERVER_URL-ARG NEXT_PUBLIC_AGPT_WS_SERVER_URL-ARG NEXT_PUBLIC_FRONTEND_BASE_URL-ARG NEXT_PUBLIC_BEHAVE_AS-ARG NEXT_PUBLIC_LAUNCHDARKLY_ENABLED-ARG NEXT_PUBLIC_LAUNCHDARKLY_CLIENT_ID-ARG NEXT_PUBLIC_APP_ENV-ARG NEXT_PUBLIC_DEFAULT_LOCALE-ARG NEXT_PUBLIC_LOCALES-ARG NEXT_PUBLIC_SHOW_BILLING_PAGE-ARG NEXT_PUBLIC_TURNSTILE-ARG NEXT_PUBLIC_REACT_QUERY_DEVTOOL-ARG NEXT_PUBLIC_GA_MEASUREMENT_ID-ARG NEXT_PUBLIC_PW_TEST--# Set environment variables from build args-ENV NEXT_PUBLIC_SUPABASE_URL=$NEXT_PUBLIC_SUPABASE_URL-ENV NEXT_PUBLIC_SUPABASE_ANON_KEY=$NEXT_PUBLIC_SUPABASE_ANON_KEY-ENV NEXT_PUBLIC_AGPT_SERVER_URL=$NEXT_PUBLIC_AGPT_SERVER_URL-ENV NEXT_PUBLIC_AGPT_WS_SERVER_URL=$NEXT_PUBLIC_AGPT_WS_SERVER_URL-ENV NEXT_PUBLIC_FRONTEND_BASE_URL=$NEXT_PUBLIC_FRONTEND_BASE_URL-ENV NEXT_PUBLIC_BEHAVE_AS=$NEXT_PUBLIC_BEHAVE_AS-ENV NEXT_PUBLIC_LAUNCHDARKLY_ENABLED=$NEXT_PUBLIC_LAUNCHDARKLY_ENABLED-ENV NEXT_PUBLIC_LAUNCHDARKLY_CLIENT_ID=$NEXT_PUBLIC_LAUNCHDARKLY_CLIENT_ID-ENV NEXT_PUBLIC_APP_ENV=$NEXT_PUBLIC_APP_ENV-ENV NEXT_PUBLIC_DEFAULT_LOCALE=$NEXT_PUBLIC_DEFAULT_LOCALE-ENV NEXT_PUBLIC_LOCALES=$NEXT_PUBLIC_LOCALES-ENV NEXT_PUBLIC_SHOW_BILLING_PAGE=$NEXT_PUBLIC_SHOW_BILLING_PAGE-ENV NEXT_PUBLIC_TURNSTILE=$NEXT_PUBLIC_TURNSTILE-ENV NEXT_PUBLIC_REACT_QUERY_DEVTOOL=$NEXT_PUBLIC_REACT_QUERY_DEVTOOL-ENV NEXT_PUBLIC_GA_MEASUREMENT_ID=$NEXT_PUBLIC_GA_MEASUREMENT_ID-ENV NEXT_PUBLIC_PW_TEST=$NEXT_PUBLIC_PW_TEST-COPY autogpt_platform/frontend/ .ENV SKIP_STORYBOOK_TESTS=trueRUN pnpm builddiff --git a/autogpt_platform/frontend/playwright.config.ts b/autogpt_platform/frontend/playwright.config.tsindex 66a76a910b..910b2fefb2 100644--- a/autogpt_platform/frontend/playwright.config.ts+++ b/autogpt_platform/frontend/playwright.config.ts@@ -45,7 +45,7 @@ export default defineConfig({webServer: {command: "pnpm start",url: "http://localhost:3000",- reuseExistingServer: true,+ reuseExistingServer: !process.env.CI,},/* Configure projects for major browsers */diff --git a/autogpt_platform/frontend/src/app/api/proxy/[...path]/route.ts b/autogpt_platform/frontend/src/app/api/proxy/[...path]/route.tsindex 9623a4fe4a..d6965656e2 100644--- a/autogpt_platform/frontend/src/app/api/proxy/[...path]/route.ts+++ b/autogpt_platform/frontend/src/app/api/proxy/[...path]/route.ts@@ -3,11 +3,14 @@ import {makeAuthenticatedFileUpload,makeAuthenticatedRequest,} from "@/lib/autogpt-server-api/helpers";-import { getAgptServerUrl } from "@/lib/env-config";import { NextRequest, NextResponse } from "next/server";function getBackendBaseUrl() {- return getAgptServerUrl().replace("/api", "");+ if (process.env.NEXT_PUBLIC_AGPT_SERVER_URL) {+ return process.env.NEXT_PUBLIC_AGPT_SERVER_URL.replace("/api", "");+ }++ return "http://localhost:8006";}function buildBackendUrl(path: string[], queryString: string): string {diff --git a/autogpt_platform/frontend/src/app/layout.tsx b/autogpt_platform/frontend/src/app/layout.tsxindex 93649bc52d..b7ffc804a0 100644--- a/autogpt_platform/frontend/src/app/layout.tsx+++ b/autogpt_platform/frontend/src/app/layout.tsx@@ -28,7 +28,7 @@ export default async function RootLayout({><head><GoogleAnalytics- gaId={process.env.NEXT_PUBLIC_GA_MEASUREMENT_ID || "G-FH2XK2W4GN"} // This is the measurement Id for the Google Analytics dev project+ gaId={process.env.GA_MEASUREMENT_ID || "G-FH2XK2W4GN"} // This is the measurement Id for the Google Analytics dev project/></head><body>diff --git a/autogpt_platform/frontend/src/lib/autogpt-server-api/client.ts b/autogpt_platform/frontend/src/lib/autogpt-server-api/client.tsindex eefa9442a8..78605bd361 100644--- a/autogpt_platform/frontend/src/lib/autogpt-server-api/client.ts+++ b/autogpt_platform/frontend/src/lib/autogpt-server-api/client.ts@@ -3,12 +3,6 @@ import { getServerSupabase } from "@/lib/supabase/server/getServerSupabase";import { createBrowserClient } from "@supabase/ssr";import type { SupabaseClient } from "@supabase/supabase-js";import { Key, storage } from "@/services/storage/local-storage";-import {- getAgptServerUrl,- getAgptWsServerUrl,- getSupabaseUrl,- getSupabaseAnonKey,-} from "@/lib/env-config";import * as Sentry from "@sentry/nextjs";import type {AddUserCreditsResponse,@@ -92,8 +86,10 @@ export default class BackendAPI {heartbeatTimeoutID: number | null = null;constructor(- baseUrl: string = getAgptServerUrl(),- wsUrl: string = getAgptWsServerUrl(),+ baseUrl: string = process.env.NEXT_PUBLIC_AGPT_SERVER_URL ||+ "http://localhost:8006/api",+ wsUrl: string = process.env.NEXT_PUBLIC_AGPT_WS_SERVER_URL ||+ "ws://localhost:8001/ws",) {this.baseUrl = baseUrl;this.wsUrl = wsUrl;@@ -101,9 +97,11 @@ export default class BackendAPI {private async getSupabaseClient(): Promise<SupabaseClient | null> {return isClient- ? createBrowserClient(getSupabaseUrl(), getSupabaseAnonKey(), {- isSingleton: true,- })+ ? createBrowserClient(+ process.env.NEXT_PUBLIC_SUPABASE_URL!,+ process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,+ { isSingleton: true },+ ): await getServerSupabase();}diff --git a/autogpt_platform/frontend/src/lib/autogpt-server-api/helpers.ts b/autogpt_platform/frontend/src/lib/autogpt-server-api/helpers.tsindex baa749b8f2..28cbc7d11a 100644--- a/autogpt_platform/frontend/src/lib/autogpt-server-api/helpers.ts+++ b/autogpt_platform/frontend/src/lib/autogpt-server-api/helpers.ts@@ -1,6 +1,5 @@import { getServerSupabase } from "@/lib/supabase/server/getServerSupabase";import { Key, storage } from "@/services/storage/local-storage";-import { getAgptServerUrl } from "@/lib/env-config";import { isServerSide } from "../utils/is-server-side";import { GraphValidationErrorResponse } from "./types";@@ -57,7 +56,9 @@ export function buildClientUrl(path: string): string {}export function buildServerUrl(path: string): string {- return `${getAgptServerUrl()}${path}`;+ const baseUrl =+ process.env.NEXT_PUBLIC_AGPT_SERVER_URL || "http://localhost:8006/api";+ return `${baseUrl}${path}`;}export function buildUrlWithQuery(diff --git a/autogpt_platform/frontend/src/lib/autogpt-server-api/proxy-action.ts b/autogpt_platform/frontend/src/lib/autogpt-server-api/proxy-action.tsindex 0157bece0e..74a5d3de91 100644--- a/autogpt_platform/frontend/src/lib/autogpt-server-api/proxy-action.ts+++ b/autogpt_platform/frontend/src/lib/autogpt-server-api/proxy-action.ts@@ -6,7 +6,8 @@ import {makeAuthenticatedFileUpload,makeAuthenticatedRequest,} from "./helpers";-import { getAgptServerUrl } from "@/lib/env-config";++const DEFAULT_BASE_URL = "http://localhost:8006/api";export interface ProxyRequestOptions {method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";@@ -20,7 +21,7 @@ export async function proxyApiRequest({method,path,payload,- baseUrl = getAgptServerUrl(),+ baseUrl = process.env.NEXT_PUBLIC_AGPT_SERVER_URL || DEFAULT_BASE_URL,contentType = "application/json",}: ProxyRequestOptions) {return await Sentry.withServerActionInstrumentation(@@ -36,7 +37,8 @@ export async function proxyApiRequest({export async function proxyFileUpload(path: string,formData: FormData,- baseUrl = getAgptServerUrl(),+ baseUrl = process.env.NEXT_PUBLIC_AGPT_SERVER_URL ||+ "http://localhost:8006/api",): Promise<string> {return await Sentry.withServerActionInstrumentation("proxyFileUpload",diff --git a/autogpt_platform/frontend/src/lib/env-config.ts b/autogpt_platform/frontend/src/lib/env-config.tsdeleted file mode 100644index 0bf5cfa711..0000000000--- a/autogpt_platform/frontend/src/lib/env-config.ts+++ /dev/null@@ -1,53 +0,0 @@-/**- * Environment configuration helper- *- * Provides unified access to environment variables with server-side priority.- * Server-side code uses Docker service names, client-side falls back to localhost.- */--/**- * Gets the AGPT server URL with server-side priority- * Server-side: Uses AGPT_SERVER_URL (http://rest_server:8006/api)- * Client-side: Falls back to NEXT_PUBLIC_AGPT_SERVER_URL (http://localhost:8006/api)- */-export function getAgptServerUrl(): string {- return (- process.env.AGPT_SERVER_URL ||- process.env.NEXT_PUBLIC_AGPT_SERVER_URL ||- "http://localhost:8006/api"- );-}--/**- * Gets the AGPT WebSocket URL with server-side priority- * Server-side: Uses AGPT_WS_SERVER_URL (ws://websocket_server:8001/ws)- * Client-side: Falls back to NEXT_PUBLIC_AGPT_WS_SERVER_URL (ws://localhost:8001/ws)- */-export function getAgptWsServerUrl(): string {- return (- process.env.AGPT_WS_SERVER_URL ||- process.env.NEXT_PUBLIC_AGPT_WS_SERVER_URL ||- "ws://localhost:8001/ws"- );-}--/**- * Gets the Supabase URL with server-side priority- * Server-side: Uses SUPABASE_URL (http://kong:8000)- * Client-side: Falls back to NEXT_PUBLIC_SUPABASE_URL (http://localhost:8000)- */-export function getSupabaseUrl(): string {- return (- process.env.SUPABASE_URL ||- process.env.NEXT_PUBLIC_SUPABASE_URL ||- "http://localhost:8000"- );-}--/**- * Gets the Supabase anon key- * Uses NEXT_PUBLIC_SUPABASE_ANON_KEY since anon keys are public and same across environments- */-export function getSupabaseAnonKey(): string {- return process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY || "";-}diff --git a/autogpt_platform/frontend/src/lib/supabase/hooks/useSupabase.ts b/autogpt_platform/frontend/src/lib/supabase/hooks/useSupabase.tsindex 025919391e..8b35a07839 100644--- a/autogpt_platform/frontend/src/lib/supabase/hooks/useSupabase.ts+++ b/autogpt_platform/frontend/src/lib/supabase/hooks/useSupabase.ts@@ -4,7 +4,6 @@ import { User } from "@supabase/supabase-js";import { usePathname, useRouter } from "next/navigation";import { useEffect, useMemo, useRef, useState } from "react";import { useBackendAPI } from "@/lib/autogpt-server-api/context";-import { getSupabaseUrl, getSupabaseAnonKey } from "@/lib/env-config";import {getCurrentUser,refreshSession,@@ -33,12 +32,16 @@ export function useSupabase() {const supabase = useMemo(() => {try {- return createBrowserClient(getSupabaseUrl(), getSupabaseAnonKey(), {- isSingleton: true,- auth: {- persistSession: false, // Don't persist session on client with httpOnly cookies+ return createBrowserClient(+ process.env.NEXT_PUBLIC_SUPABASE_URL!,+ process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,+ {+ isSingleton: true,+ auth: {+ persistSession: false, // Don't persist session on client with httpOnly cookies+ },},- });+ );} catch (error) {console.error("Error creating Supabase client", error);return null;diff --git a/autogpt_platform/frontend/src/lib/supabase/middleware.ts b/autogpt_platform/frontend/src/lib/supabase/middleware.tsindex 05b911c7ef..d2d32e389f 100644--- a/autogpt_platform/frontend/src/lib/supabase/middleware.ts+++ b/autogpt_platform/frontend/src/lib/supabase/middleware.ts@@ -1,43 +1,47 @@import { createServerClient } from "@supabase/ssr";import { NextResponse, type NextRequest } from "next/server";import { getCookieSettings, isAdminPage, isProtectedPage } from "./helpers";-import { getSupabaseUrl, getSupabaseAnonKey } from "../env-config";export async function updateSession(request: NextRequest) {let supabaseResponse = NextResponse.next({request,});- const supabaseUrl = getSupabaseUrl();- const supabaseKey = getSupabaseAnonKey();- const isAvailable = Boolean(supabaseUrl && supabaseKey);+ const isAvailable = Boolean(+ process.env.NEXT_PUBLIC_SUPABASE_URL &&+ process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY,+ );if (!isAvailable) {return supabaseResponse;}try {- const supabase = createServerClient(supabaseUrl, supabaseKey, {- cookies: {- getAll() {- return request.cookies.getAll();- },- setAll(cookiesToSet) {- cookiesToSet.forEach(({ name, value }) =>- request.cookies.set(name, value),- );- supabaseResponse = NextResponse.next({- request,- });- cookiesToSet.forEach(({ name, value, options }) => {- supabaseResponse.cookies.set(name, value, {- ...options,- ...getCookieSettings(),+ const supabase = createServerClient(+ process.env.NEXT_PUBLIC_SUPABASE_URL!,+ process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,+ {+ cookies: {+ getAll() {+ return request.cookies.getAll();+ },+ setAll(cookiesToSet) {+ cookiesToSet.forEach(({ name, value }) =>+ request.cookies.set(name, value),+ );+ supabaseResponse = NextResponse.next({+ request,+ });+ cookiesToSet.forEach(({ name, value, options }) => {+ supabaseResponse.cookies.set(name, value, {+ ...options,+ ...getCookieSettings(),+ });});- });+ },},},- });+ );const userResponse = await supabase.auth.getUser();const user = userResponse.data.user;diff --git a/autogpt_platform/frontend/src/lib/supabase/server/getServerSupabase.ts b/autogpt_platform/frontend/src/lib/supabase/server/getServerSupabase.tsindex 0faa8ec9b8..e0acc6a600 100644--- a/autogpt_platform/frontend/src/lib/supabase/server/getServerSupabase.ts+++ b/autogpt_platform/frontend/src/lib/supabase/server/getServerSupabase.ts@@ -1,6 +1,5 @@import { createServerClient, type CookieOptions } from "@supabase/ssr";import { getCookieSettings } from "../helpers";-import { getSupabaseUrl, getSupabaseAnonKey } from "../../env-config";type Cookies = { name: string; value: string; options?: CookieOptions }[];@@ -12,8 +11,8 @@ export async function getServerSupabase() {try {const supabase = createServerClient(- getSupabaseUrl(),- getSupabaseAnonKey(),+ process.env.NEXT_PUBLIC_SUPABASE_URL!,+ process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,{cookies: {getAll() {diff --git a/autogpt_platform/frontend/src/lib/turnstile.ts b/autogpt_platform/frontend/src/lib/turnstile.tsindex 8418bf60b4..35f5b1e271 100644--- a/autogpt_platform/frontend/src/lib/turnstile.ts+++ b/autogpt_platform/frontend/src/lib/turnstile.ts@@ -2,7 +2,6 @@* Utility functions for working with Cloudflare Turnstile*/import { BehaveAs, getBehaveAs } from "@/lib/utils";-import { getAgptServerUrl } from "@/lib/env-config";export async function verifyTurnstileToken(token: string,@@ -20,16 +19,19 @@ export async function verifyTurnstileToken(}try {- const response = await fetch(`${getAgptServerUrl()}/turnstile/verify`, {- method: "POST",- headers: {- "Content-Type": "application/json",+ const response = await fetch(+ `${process.env.NEXT_PUBLIC_AGPT_SERVER_URL}/turnstile/verify`,+ {+ method: "POST",+ headers: {+ "Content-Type": "application/json",+ },+ body: JSON.stringify({+ token,+ action,+ }),},- body: JSON.stringify({- token,- action,- }),- });+ );if (!response.ok) {console.error("Turnstile verification failed:", await response.text());diff --git a/docs/content/platform/getting-started.md b/docs/content/platform/getting-started.mdindex c6f814db93..7719c2ade3 100644--- a/docs/content/platform/getting-started.md+++ b/docs/content/platform/getting-started.md@@ -107,9 +107,9 @@ If you get stuck, follow [this guide](https://docs.github.com/en/repositories/crOnce that's complete you can continue the setup process.-### Running the AutoGPT Platform+### Running the backend services-To run the platform, follow these steps:+To run the backend services, follow these steps:* Navigate to the `autogpt_platform` directory inside the AutoGPT folder:```bash@@ -120,13 +120,40 @@ To run the platform, follow these steps:```cp .env.example .env```- This command will copy the `.env.example` file to `.env` in the `autogpt_platform` directory. You can modify the `.env` file to add your own environment variables.+ This command will copy the `.env.example` file to `.env` in the `supabase` directory. You can modify the `.env` file to add your own environment variables.-* Run the platform services:+* Run the backend services:```docker compose up -d --build```- This command will start all the necessary backend services defined in the `docker-compose.yml` file in detached mode.+ This command will start all the necessary backend services defined in the `docker-compose.combined.yml` file in detached mode.+++### Running the frontend application++To run the frontend application open a new terminal and follow these steps:++- Navigate to `frontend` folder within the `autogpt_platform` directory:++ ```+ cd frontend+ ```++- Copy the `.env.example` file available in the `frontend` directory to `.env` in the same directory:++ ```+ cp .env.example .env+ ```++ You can modify the `.env` within this folder to add your own environment variables for the frontend application.++- Run the following command:+ ```+ corepack enable+ pnpm install+ pnpm dev+ ```+ This command will enable corepack, install the necessary dependencies with pnpm, and start the frontend application in development mode.### Checking if the application is running@@ -158,118 +185,161 @@ poetry run cli gen-encrypt-keyThen, replace the existing key in the `autogpt_platform/backend/.env` file with the new one.-### 📌 Windows Installation Note--When installing Docker on Windows, it is **highly recommended** to select **WSL 2** instead of Hyper-V. Using Hyper-V can cause compatibility issues with Supabase, leading to the `supabase-db` container being marked as **unhealthy**.--#### **Steps to enable WSL 2 for Docker:**-1. Install [WSL 2](https://learn.microsoft.com/en-us/windows/wsl/install).-2. Ensure that your Docker settings use WSL 2 as the default backend:- - Open **Docker Desktop**.- - Navigate to **Settings > General**.- - Check **Use the WSL 2 based engine**.-3. Restart **Docker Desktop**.--#### **Already Installed Docker with Hyper-V?**-If you initially installed Docker with Hyper-V, you **don’t need to reinstall** it. You can switch to WSL 2 by following these steps:-1. Open **Docker Desktop**.-2. Go to **Settings > General**.-3. Enable **Use the WSL 2 based engine**.-4. Restart Docker.--🚨 **Warning:** Enabling WSL 2 may **erase your existing containers and build history**. If you have important containers, consider backing them up before switching.+!!! Note+ *The steps below are an alternative to [Running the backend services](#running-the-backend-services)*-For more details, refer to [Docker's official documentation](https://docs.docker.com/desktop/windows/wsl/).+<details>+<summary><strong>Alternate Steps</strong></summary>+#### AutoGPT Agent Server (OLD)+This is an initial project for creating the next generation of agent execution, which is an AutoGPT agent server.+The agent server will enable the creation of composite multi-agent systems that utilize AutoGPT agents and other non-agent components as its primitives.-## Development+##### Docs-### Frontend Development+You can access the docs for the [AutoGPT Agent Server here](https://docs.agpt.co/#1-autogpt-server).-#### Running the frontend locally+##### Setup-To run the frontend locally, you need to have Node.js and PNPM installed on your machine.+We use the Poetry to manage the dependencies. To set up the project, follow these steps inside this directory:-Install [Node.js](https://nodejs.org/en/download/) to manage dependencies and run the frontend application.+0. Install Poetry-Install [PNPM](https://pnpm.io/installation) to manage the frontend dependencies.+```sh+pip install poetry+```++1. Configure Poetry to use .venv in your project directory-Run the service dependencies (backend, database, message queues, etc.):```sh-docker compose --profile local up deps_backend --build --detach+ poetry config virtualenvs.in-project true```-Go to the `autogpt_platform/frontend` directory:+2. Enter the poetry shell+```sh-cd frontend+poetry shell```-Install the dependencies:+3. Install dependencies+```sh-pnpm install+poetry install```-Generate the API client:+4. Copy .env.example to .env+```sh-pnpm generate:api-client+cp .env.example .env```-Run the frontend application:+5. Generate the Prisma client+```sh-pnpm dev+poetry run prisma generate```-#### Formatting & Linting+> In case Prisma generates the client for the global Python installation instead of the virtual environment, the current mitigation is to just uninstall the global Prisma package:+>+> ```sh+> pip uninstall prisma+> ```+>+> Then run the generation again. The path *should* look something like this:+> `<some path>/pypoetry/virtualenvs/backend-TQIRSwR6-py3.12/bin/prisma`++6. Migrate the database. Be careful because this deletes current data in the database.-Auto formatter and linter are set up in the project. To run them:-Format the code:```sh-pnpm format+docker compose up db -d+poetry run prisma migrate deploy```++</details>+++### Starting the AutoGPT server without Docker++To run the server locally, start in the autogpt_platform folder:-Lint the code:```sh-pnpm lint+cd ..```-#### Testing+Run the following command to run database in docker but the application locally:-To run the tests, you can use the following command:```sh-pnpm test+docker compose --profile local up deps --build --detach+cd backend+poetry run app```-### Backend Development+### Starting the AutoGPT server with Docker-#### Running the backend locally+Run the following command to build the dockerfiles:-To run the backend locally, you need to have Python 3.10 or higher installed on your machine.+```sh+docker compose build+```-Install [Poetry](https://python-poetry.org/docs/#installation) to manage dependencies and virtual environments.+Run the following command to run the app:-Run the backend dependencies (database, message queues, etc.):```sh-docker compose --profile local up deps --build --detach+docker compose up```-Go to the `autogpt_platform/backend` directory:+Run the following to automatically rebuild when code changes, in another terminal:+```sh-cd backend+docker compose watch```-Install the dependencies:+Run the following command to shut down:+```sh-poetry install --with dev+docker compose down```-Run the backend server:+If you run into issues with dangling orphans, try:+```sh-poetry run app+docker compose down --volumes --remove-orphans && docker-compose up --force-recreate --renew-anon-volumes --remove-orphans```-#### Formatting & Linting+### 📌 Windows Installation Note++When installing Docker on Windows, it is **highly recommended** to select **WSL 2** instead of Hyper-V. Using Hyper-V can cause compatibility issues with Supabase, leading to the `supabase-db` container being marked as **unhealthy**.++#### **Steps to enable WSL 2 for Docker:**+1. Install [WSL 2](https://learn.microsoft.com/en-us/windows/wsl/install).+2. Ensure that your Docker settings use WSL 2 as the default backend:+ - Open **Docker Desktop**.+ - Navigate to **Settings > General**.+ - Check **Use the WSL 2 based engine**.+3. Restart **Docker Desktop**.++#### **Already Installed Docker with Hyper-V?**+If you initially installed Docker with Hyper-V, you **don’t need to reinstall** it. You can switch to WSL 2 by following these steps:+1. Open **Docker Desktop**.+2. Go to **Settings > General**.+3. Enable **Use the WSL 2 based engine**.+4. Restart Docker.++🚨 **Warning:** Enabling WSL 2 may **erase your existing containers and build history**. If you have important containers, consider backing them up before switching.++For more details, refer to [Docker's official documentation](https://docs.docker.com/desktop/windows/wsl/).+++## Development++### Formatting & LintingAuto formatter and linter are set up in the project. To run them:+Install:+```sh+poetry install --with dev+```+Format the code:```shpoetry run format@@ -280,14 +350,71 @@ Lint the code:poetry run lint```-#### Testing+### TestingTo run the tests:```sh-poetry run pytest -s+poetry run test```+To update stored snapshots after intentional API changes:++```sh+pytest --snapshot-update+```++## Project Outline++The current project has the following main modules:++#### **blocks**++This module stores all the Agent Blocks, which are reusable components to build a graph that represents the agent's behavior.++#### **data**++This module stores the logical model that is persisted in the database.+It abstracts the database operations into functions that can be called by the service layer.+Any code that interacts with Prisma objects or the database should reside in this module.+The main models are:+* `block`: anything related to the block used in the graph+* `execution`: anything related to the execution graph execution+* `graph`: anything related to the graph, node, and its relations++#### **execution**++This module stores the business logic of executing the graph.+It currently has the following main modules:+* `manager`: A service that consumes the queue of the graph execution and executes the graph. It contains both pieces of logic.+* `scheduler`: A service that triggers scheduled graph execution based on a cron expression. It pushes an execution request to the manager.++#### **server**++This module stores the logic for the server API.+It contains all the logic used for the API that allows the client to create, execute, and monitor the graph and its execution.+This API service interacts with other services like those defined in `manager` and `scheduler`.++#### **utils**++This module stores utility functions that are used across the project.+Currently, it has two main modules:+* `process`: A module that contains the logic to spawn a new process.+* `service`: A module that serves as a parent class for all the services in the project.++## Service Communication++Currently, there are only 3 active services:++- AgentServer (the API, defined in `server.py`)+- ExecutionManager (the executor, defined in `manager.py`)+- Scheduler (the scheduler, defined in `scheduler.py`)++The services run in independent Python processes and communicate through an IPC.+A communication layer (`service.py`) is created to decouple the communication library from the implementation.++Currently, the IPC is done using Pyro5 and abstracted in a way that allows a function decorated with `@expose` to be called from a different process.+## Adding a New Agent BlockTo add a new agent block, you need to create a new class that inherits from `Block` and provides the following information:@@ -297,5 +424,4 @@ To add a new agent block, you need to create a new class that inherits from `Blo* `run` method: the main logic of the block.* `test_input` & `test_output`: the sample input and output data for the block, which will be used to auto-test the block.* You can mock the functions declared in the block using the `test_mock` field for your unit tests.-* Once you finish creating the block, you can test it by running `poetry run pytest backend/blocks/test/test_block.py -s`.-* Create a Pull Request to the `dev` branch of the repository with your changes so you can share it with the community :)+* Once you finish creating the block, you can test it by running `poetry run pytest -s test/block/test_block.py`.