Skip to content

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.

fix(platform): self-hosted signup grant, memory page and no-model chat (#15409)

Nicholas Tindlefb2e05ca7785
diff --git a/.github/scripts/platform-single-container-smoke.sh b/.github/scripts/platform-single-container-smoke.sh
index 08d437d4e6..38e7e1c338 100644
--- a/.github/scripts/platform-single-container-smoke.sh
+++ b/.github/scripts/platform-single-container-smoke.sh
@@ -663,9 +663,15 @@ SELECT has_column_privilege(current_user, 'platform."User"', 'id', 'SELECT')
AND has_column_privilege(current_user, 'platform."User"', 'email', 'SELECT')
AND has_column_privilege(current_user, 'platform."User"', 'email', 'UPDATE')
AND has_column_privilege(current_user, 'platform."User"', 'updatedAt', 'UPDATE')
+ AND has_column_privilege(current_user, 'platform."User"', 'id', 'INSERT')
+ AND has_column_privilege(current_user, 'platform."User"', 'email', 'INSERT')
+ AND has_column_privilege(current_user, 'platform."User"', 'name', 'INSERT')
+ AND has_column_privilege(current_user, 'platform."User"', 'updatedAt', 'INSERT')
AND NOT has_column_privilege(current_user, 'platform."User"', 'metadata', 'SELECT')
AND NOT has_column_privilege(current_user, 'platform."User"', 'metadata', 'UPDATE')
+ AND NOT has_column_privilege(current_user, 'platform."User"', 'metadata', 'INSERT')
AND NOT has_table_privilege(current_user, 'platform."User"', 'SELECT')
+ AND NOT has_table_privilege(current_user, 'platform."User"', 'INSERT')
AND NOT has_table_privilege(current_user, 'platform."User"', 'UPDATE');
SQL
)"
@@ -747,6 +753,26 @@ assert_email_auth_flow() {
--data "{\"name\":\"Single Container Smoke\",\"email\":\"${email}\",\"password\":\"${password}\"}" \
"${PUBLIC_URL}/api/auth/sign-up/email" >/dev/null
+ # Nothing has called the backend yet, so the row can only come from the
+ # sign-up hook, not from the backend's lazy provisioning on first request.
+ local platform_user_rows
+ platform_user_rows="$(
+ docker exec --interactive --user postgres "${CONTAINER_NAME}" \
+ /usr/bin/env -i \
+ PATH=/usr/lib/postgresql/15/bin:/usr/bin:/bin \
+ PGHOST=/run/postgresql \
+ PGDATABASE=postgres \
+ PGUSER=postgres \
+ psql --no-psqlrc --tuples-only --no-align --set=ON_ERROR_STOP=1 \
+ --set=email="${email}" <<'SQL'
+SELECT count(*) FROM platform."User" WHERE email = :'email';
+SQL
+ )"
+ [[ "${platform_user_rows}" == 1 ]] || {
+ echo "sign-up did not create the platform User row" >&2
+ return 1
+ }
+
curl --fail-with-body --silent --show-error --max-time 30 \
--cookie "${AUTH_COOKIE_FILE}" \
"${PUBLIC_URL}/api/auth/get-session" |
diff --git a/autogpt_platform/frontend/playwright.journeys.config.ts b/autogpt_platform/frontend/playwright.journeys.config.ts
new file mode 100644
index 0000000000..ab2edc5e0f
--- /dev/null
+++ b/autogpt_platform/frontend/playwright.journeys.config.ts
@@ -0,0 +1,19 @@
+import { defineConfig } from "@playwright/test";
+import baseConfig from "./playwright.config";
+
+// Journeys sign up their own users (src/playwright/journeys/journey-user.ts),
+// so unlike the smoke suite they skip the seeded-account global setup and run
+// against any PLAYWRIGHT_BASE_URL, including a `!deploy` preview.
+const baseURL = String(baseConfig.use?.baseURL);
+const { hostname } = new URL(baseURL);
+const isLocalApp = ["localhost", "127.0.0.1", "[::1]"].includes(hostname);
+
+export default defineConfig({
+ ...baseConfig,
+ testDir: "./src/playwright/journeys",
+ testMatch: /.*-journey\.spec\.ts/,
+ globalSetup: undefined,
+ timeout: 90_000,
+ expect: { timeout: 15_000 },
+ webServer: isLocalApp ? baseConfig.webServer : undefined,
+});
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/__tests__/CopilotPage.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/__tests__/CopilotPage.test.tsx
index a0bf087811..a75aca9ec2 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/__tests__/CopilotPage.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/__tests__/CopilotPage.test.tsx
@@ -60,6 +60,7 @@ vi.mock("@/components/ui/sidebar", () => ({
// Mock hooks that hit the network. Exercise the `select` callback so its
// line counts as covered alongside the rest of the options.
vi.mock("@/app/api/__generated__/endpoints/chat/chat", () => ({
+ useGetV2ListChatTransports: () => ({ data: undefined }),
useGetV2GetCopilotUsage: (opts: {
query?: { select?: (r: { data: unknown }) => unknown };
}) => {
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/__tests__/codex-session-route.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/__tests__/codex-session-route.test.tsx
index 299909e153..39f32e2b6c 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/__tests__/codex-session-route.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/__tests__/codex-session-route.test.tsx
@@ -213,7 +213,7 @@ describe("useChatSession transport route", () => {
expect(testState.toast).toHaveBeenCalledWith(
expect.objectContaining({
variant: "destructive",
- title: "Your expert needs an AI connection",
+ title: "No AI connection is set up",
}),
);
});
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/ChatInput.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/ChatInput.tsx
index 1e1e828e53..afbe3da4a6 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/ChatInput.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/ChatInput.tsx
@@ -39,6 +39,7 @@ import { DryRunToggleButton } from "./components/DryRunToggleButton";
import { FileChips } from "./components/FileChips";
import { MentionDropdown } from "./components/MentionDropdown";
import { ConnectionPicker } from "./components/ConnectionPicker/ConnectionPicker";
+import { NoAIConnectionNotice } from "./components/NoAIConnectionNotice/NoAIConnectionNotice";
import { RecordingButton } from "./components/RecordingButton";
import { RecordingIndicator } from "./components/RecordingIndicator";
import { TranscriptionErrorBar } from "./components/TranscriptionErrorBar";
@@ -356,6 +357,7 @@ export function ChatInput({
onHighlight={mentions.setHighlightedIndex}
/>
)}
+ <NoAIConnectionNotice enabled={!hasSession} />
{/* GPT-style composer: a single pill row — plus on the left, textarea
in the middle, quiet toggles + mic + send on the right. items-end
keeps the controls pinned to the bottom edge as the textarea grows. */}
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/__tests__/ChatInput.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/__tests__/ChatInput.test.tsx
index 272a36abbe..b2453aa96c 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/__tests__/ChatInput.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/__tests__/ChatInput.test.tsx
@@ -15,10 +15,13 @@ import { afterEach, describe, expect, it, vi } from "vitest";
import { ChatInput } from "../ChatInput";
import { sdkStopStream, useCopilotStop } from "../../../useCopilotStop";
import { toast } from "@/components/molecules/Toast/use-toast";
+import { ReportedSendError } from "@/app/(platform)/copilot/helpers/reportedSendError";
const mockCancel =
vi.fn<(sessionId: string) => Promise<{ status: number; data: unknown }>>();
+let mockTransports: unknown = undefined;
vi.mock("@/app/api/__generated__/endpoints/chat/chat", () => ({
+ useGetV2ListChatTransports: () => ({ data: mockTransports }),
postV2CancelSessionTask: (sessionId: string) => mockCancel(sessionId),
// A lone platform connection whose tiers resolve to one model: the picker
// presents nothing, which keeps these tests about the composer itself.
@@ -1338,3 +1341,72 @@ describe("ChatInput transcription failure", () => {
function isShown(element: HTMLElement): boolean {
return !element.closest(".hidden");
}
+
+describe("ChatInput with no AI connection", () => {
+ afterEach(() => {
+ mockTransports = undefined;
+ });
+
+ function serverWithNoModel() {
+ mockTransports = {
+ status: 200,
+ data: {
+ transports: [
+ {
+ auth_provider: "platform",
+ available: false,
+ credential_id: null,
+ },
+ ],
+ },
+ };
+ }
+
+ it("says how to connect a model, with the server setup guide", () => {
+ serverWithNoModel();
+ render(<ChatInput onSend={vi.fn()} />);
+
+ const notice = screen.getByRole("status", { name: "No AI connection" });
+ expect(notice.textContent).toContain("No AI model is connected");
+ expect(
+ screen.getByRole("link", { name: /setup guide/i }).getAttribute("href"),
+ ).toContain("single-container.md#models-and-memory");
+ });
+
+ it("stays out of the way once a model can answer", () => {
+ mockTransports = {
+ status: 200,
+ data: {
+ transports: [
+ { auth_provider: "platform", available: true, credential_id: null },
+ ],
+ },
+ };
+ render(<ChatInput onSend={vi.fn()} />);
+
+ expect(screen.queryByRole("status", { name: "No AI connection" })).toBe(
+ null,
+ );
+ });
+
+ it("keeps the draft and adds no second toast for a failure already shown", async () => {
+ serverWithNoModel();
+ const onSend = vi
+ .fn()
+ .mockRejectedValue(new ReportedSendError("No AI connection is set up"));
+ render(<ChatInput onSend={onSend} />);
+
+ const textarea = screen.getByTestId("textarea") as HTMLTextAreaElement;
+ fireEvent.change(textarea, { target: { value: "Hi there" } });
+ await act(async () => {
+ fireEvent.submit(textarea.closest("form")!);
+ });
+
+ expect(onSend).toHaveBeenCalledWith("Hi there", undefined, undefined);
+ await waitFor(() => expect(textarea.value).toBe("Hi there"));
+ expect(toast).not.toHaveBeenCalled();
+ expect(
+ screen.getByRole("status", { name: "No AI connection" }),
+ ).toBeDefined();
+ });
+});
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/__tests__/ChatInputAttachmentCap.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/__tests__/ChatInputAttachmentCap.test.tsx
index 65d9e64451..901f9c3cef 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/__tests__/ChatInputAttachmentCap.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/__tests__/ChatInputAttachmentCap.test.tsx
@@ -12,6 +12,7 @@ import { ChatInput } from "../ChatInput";
// the cap notice stay real, because the cap is a claim about what the user
// ends up seeing and being able to click.
vi.mock("@/app/api/__generated__/endpoints/chat/chat", () => ({
+ useGetV2ListChatTransports: () => ({ data: undefined }),
useGetV2ListChatConnections: () => ({
data: { status: 200, data: { offers: [] } },
isLoading: false,
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/__tests__/ChatInputComposerRow.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/__tests__/ChatInputComposerRow.test.tsx
index 4e9962177b..c39d3ff6ac 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/__tests__/ChatInputComposerRow.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/__tests__/ChatInputComposerRow.test.tsx
@@ -8,6 +8,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { ChatInput } from "../ChatInput";
vi.mock("@/app/api/__generated__/endpoints/chat/chat", () => ({
+ useGetV2ListChatTransports: () => ({ data: undefined }),
postV2CancelSessionTask: vi.fn(),
// A lone platform connection whose tiers resolve to one model: the picker
// presents nothing, which keeps these tests about the composer itself.
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/NoAIConnectionNotice/NoAIConnectionNotice.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/NoAIConnectionNotice/NoAIConnectionNotice.tsx
new file mode 100644
index 0000000000..01f4cbe48a
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/NoAIConnectionNotice/NoAIConnectionNotice.tsx
@@ -0,0 +1,58 @@
+"use client";
+
+import Link from "next/link";
+import { Alert02Icon } from "@hugeicons/core-free-icons";
+
+import { Icon } from "@/components/atoms/Icon/Icon";
+import { cn } from "@/lib/utils";
+import { SELF_HOSTED_MODELS_DOCS_URL } from "@/app/(platform)/copilot/helpers/reportedSendError";
+import { useNoAIConnectionNotice } from "./useNoAIConnectionNotice";
+
+interface Props {
+ enabled: boolean;
+ className?: string;
+}
+
+// Stays above the composer for as long as nothing can answer, so the fix is
+// still on screen after any toast about a failed send has gone.
+export function NoAIConnectionNotice({ enabled, className }: Props) {
+ const { hasNoConnection } = useNoAIConnectionNotice(enabled);
+ if (!hasNoConnection) return null;
+
+ return (
+ <div
+ role="status"
+ aria-label="No AI connection"
+ className={cn(
+ "mb-2 flex w-full items-start gap-2 rounded-2xl bg-amber-50 px-3 py-2 text-left text-sm text-amber-900",
+ className,
+ )}
+ >
+ <Icon
+ icon={Alert02Icon}
+ className="mt-0.5 h-4 w-4 shrink-0"
+ aria-hidden
+ />
+ <span className="min-w-0 flex-1">
+ No AI model is connected, so chat can&apos;t answer yet. Whoever runs
+ this server can add a model API key or a local model{" "}
+ <a
+ href={SELF_HOSTED_MODELS_DOCS_URL}
+ target="_blank"
+ rel="noopener noreferrer"
+ className="font-medium underline underline-offset-2"
+ >
+ (setup guide)
+ </a>
+ , or you can connect your own ChatGPT or Microsoft 365 Copilot plan in{" "}
+ <Link
+ href="/settings/integrations"
+ className="font-medium underline underline-offset-2"
+ >
+ Settings → Integrations
+ </Link>
+ .
+ </span>
+ </div>
+ );
+}
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/NoAIConnectionNotice/useNoAIConnectionNotice.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/NoAIConnectionNotice/useNoAIConnectionNotice.ts
new file mode 100644
index 0000000000..1c790dc901
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/NoAIConnectionNotice/useNoAIConnectionNotice.ts
@@ -0,0 +1,19 @@
+import { useGetV2ListChatTransports } from "@/app/api/__generated__/endpoints/chat/chat";
+import { getAvailableLLMTransports } from "@/app/(platform)/copilot/helpers/copilotLlmAuth";
+
+export function useNoAIConnectionNotice(enabled: boolean) {
+ const transportsQuery = useGetV2ListChatTransports({
+ query: { enabled },
+ });
+ const transports =
+ transportsQuery.data?.status === 200
+ ? transportsQuery.data.data.transports
+ : undefined;
+
+ return {
+ hasNoConnection:
+ enabled &&
+ transports !== undefined &&
+ getAvailableLLMTransports(transports).length === 0,
+ };
+}
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/useChatInput.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/useChatInput.ts
index d3cca2b924..985b120962 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/useChatInput.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/useChatInput.ts
@@ -1,4 +1,5 @@
import { useCopilotUIStore } from "@/app/(platform)/copilot/store";
+import { ReportedSendError } from "@/app/(platform)/copilot/helpers/reportedSendError";
import { describeSendFailure } from "./helpers";
import { toast } from "@/components/molecules/Toast/use-toast";
import { ChangeEvent, FormEvent, useEffect, useRef, useState } from "react";
@@ -88,6 +89,7 @@ export function useChatInput({
notifyMessageSent();
} catch (error) {
setValue((current) => restoreFailedDraft(current, message));
+ if (error instanceof ReportedSendError) return;
toast({
title: "Couldn't send message",
description: describeSendFailure(
@@ -118,6 +120,7 @@ export function useChatInput({
await onEnqueue(trimmedMessage);
} catch (error) {
setValue((current) => restoreFailedDraft(current, message));
+ if (error instanceof ReportedSendError) return;
toast({
title: "Couldn't send message",
description: describeSendFailure(
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/helpers/reportedSendError.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/helpers/reportedSendError.ts
new file mode 100644
index 0000000000..497de0da72
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/helpers/reportedSendError.ts
@@ -0,0 +1,9 @@
+// A send failure whose cause the user has already been shown (a toast or an
+// inline notice). The composer still restores the draft, but adds no second
+// toast that would only repeat the error.
+export class ReportedSendError extends Error {
+ readonly name = "ReportedSendError";
+}
+
+export const SELF_HOSTED_MODELS_DOCS_URL =
+ "https://github.com/Significant-Gravitas/AutoGPT/blob/master/docs/platform/single-container.md#models-and-memory";
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/useChatSession.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/useChatSession.ts
index 4ca046c23a..ca11c9be2d 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/useChatSession.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/useChatSession.ts
@@ -33,6 +33,7 @@ import {
compareShadowWithSession,
setStreamShadowRate,
} from "./stream/turnShadow";
+import { ReportedSendError } from "./helpers/reportedSendError";
interface UseChatSessionOptions {
dryRun?: boolean;
@@ -258,16 +259,18 @@ export function useChatSession({
title: "Could not check AI connections",
description: "Refresh the page and try again.",
});
- throw new Error("Could not load AI connections");
+ throw new ReportedSendError("Could not load AI connections");
}
if (chatTransports !== undefined && availableTransports.length === 0) {
+ // NoAIConnectionNotice above the composer says how to fix this and
+ // stays put; the toast only marks that this send went nowhere.
toast({
variant: "destructive",
- title: "Your expert needs an AI connection",
+ title: "No AI connection is set up",
description:
- "Connect ChatGPT or Microsoft 365 Copilot in Settings → Integrations, or configure a chat API or local model on this server.",
+ "Your message is back in the composer. See the notice above it for how to connect a model.",
});
- throw new Error("chat_transport_not_configured");
+ throw new ReportedSendError("No AI connection is set up");
}
if (!resolvedLLMAuth) {
const connectionsAreLoading = chatTransports === undefined;
@@ -280,7 +283,7 @@ export function useChatSession({
? "Wait a moment and try again."
: "Select the connection your expert should use before starting a new task.",
});
- throw new Error(
+ throw new ReportedSendError(
connectionsAreLoading
? "AI connections are still loading"
: "AI connection selection required",
diff --git a/autogpt_platform/frontend/src/playwright/journeys/selfhost-journey.spec.ts b/autogpt_platform/frontend/src/playwright/journeys/selfhost-journey.spec.ts
new file mode 100644
index 0000000000..76de4d5058
--- /dev/null
+++ b/autogpt_platform/frontend/src/playwright/journeys/selfhost-journey.spec.ts
@@ -0,0 +1,251 @@
+import type { BrowserContext, Locator, Page } from "@playwright/test";
+import { expect, test } from "../coverage-fixture";
+import { BuildPage, createUniqueAgentName } from "../pages/build.page";
+import {
+ clickRunButton,
+ dismissFeedbackDialog,
+ LibraryPage,
+} from "../pages/library.page";
+
+// A self-hoster's first hour on a fresh install with no model keys and no
+// hosted services: sign up, onboard, build and run an agent, look around
+// Settings. Nothing hosted-only may show up on the way, and the browser may
+// talk to no host but the instance itself.
+//
+// Run it against a self-hosted build (BEHAVE_AS=LOCAL, payments off, no LLM
+// key), e.g. the single-container appliance:
+// PLAYWRIGHT_BASE_URL=http://localhost:3400 \
+// PLAYWRIGHT_SELFHOST_EMAIL_DOMAIN=patrol.example.com \
+// pnpm exec playwright test --config playwright.journeys.config.ts selfhost
+// The email domain must be on the instance's AUTH_SIGNUP_ALLOWLIST.
+
+const EMAIL_DOMAIN =
+ process.env.PLAYWRIGHT_SELFHOST_EMAIL_DOMAIN ?? "patrol.example.com";
+const PASSWORD = `Selfhost-${Date.now()}-journey`;
+
+test.describe.configure({ mode: "serial" });
+test.setTimeout(300_000);
+
+test("selfhost journey: a self-hoster's first hour has nothing hosted-only in it", async ({
+ page,
+ context,
+}) => {
+ const thirdPartyRequests = recordThirdPartyRequests(context);
+ const runID = Date.now();
+ // New users are asked about browser notifications on their first visit.
+ await page.addLocatorHandler(
+ page.getByRole("dialog", { name: "Stay in the loop" }),
+ async () => {
+ await page.getByRole("button", { name: "Not now" }).click();
+ },
+ );
+
+ await test.step("an email off the allowlist gets the operator's answer, not the hosted waitlist", async () => {
+ await submitSignup(page, `stranger-${runID}@not-allowed.example.org`);
+ await expect
+ .soft(page.getByText(/only allows approved emails/i).first())
+ .toBeVisible();
+ await expect
+ .soft(page.getByText(/closed beta|join waitlist/i))
+ .toHaveCount(0);
+ });
+
+ await test.step("sign up and finish onboarding with no paywall", async () => {
+ await submitSignup(page, `selfhost-${runID}@${EMAIL_DOMAIN}`);
+ await page.waitForURL((url) => !url.pathname.startsWith("/signup"));
+ await finishOnboarding(page);
+ await expect(page).toHaveURL(/\/(home|copilot)/);
+ });
+
+ await test.step("home shows no credits, billing or developer tooling", async () => {
+ await expectNoHostedOnlyChrome(page);
+ });
+
+ await test.step("chat with no model configured says how to fix it, and keeps saying it", async () => {
+ const notice = page.getByRole("status", { name: "No AI connection" });
+ await expect.soft(notice).toBeVisible();
+ await expect
+ .soft(notice.getByRole("link", { name: /setup guide/i }))
+ .toHaveAttribute("href", /single-container\.md#models-and-memory/);
+
+ const composer = page.getByRole("textbox").first();
+ await composer.fill("Hi there");
+ await composer.press("Enter");
+ const toast = page
+ .getByText(/No AI connection is set up|Couldn't send message/)
+ .first();
+ await expect(toast).toBeVisible();
+ await expect
+ .soft(page.getByText(/chat_transport_not_configured/))
+ .toHaveCount(0);
+ await expect(composer).toHaveValue("Hi there");
+
+ await expect(toast).toBeHidden({ timeout: 20_000 });
+ await expect.soft(notice).toBeVisible();
+ });
+
+ const agentName = createUniqueAgentName("Selfhost Journey Agent");
+ const expectedOutput = `selfhost-output-${runID}`;
+ const outputName = `selfhost-result-${runID}`;
+
+ await test.step("build a tiny agent in the builder", async () => {
+ const buildPage = new BuildPage(page);
+ await buildPage.open();
+ await buildPage.addBlockByClick("Store Value");
+ await buildPage.waitForNodeOnCanvas(1);
+ await buildPage.fillBlockInputByPlaceholder(
+ "Enter string value...",
+ expectedOutput,
+ 0,
+ );
+ await buildPage.addBlockByClick("Agent Output");
+ await buildPage.waitForNodeOnCanvas(2);
+ await connectHandles(page, "output", "value");
+ await expect.poll(() => buildPage.getEdgeCount()).toBe(1);
+ await buildPage.fillLastNodeTextInput("Agent Output", outputName);
+ await expect.soft(page.locator(AGENTATION)).toHaveCount(0);
+ await buildPage.saveAgent(agentName, "Self-hosted first-hour journey");
+ await buildPage.waitForSaveComplete();
+ await buildPage.waitForSaveButton();
+ });
+
+ await test.step("run it from the Library and read its output, with no cost shown", async () => {
+ const libraryPage = new LibraryPage(page);
+ await libraryPage.openSavedAgent(agentName);
+ await clickRunButton(page);
+ await libraryPage.waitForRunToComplete();
+ await dismissFeedbackDialog(page);
+ await libraryPage.assertRunOutputValue(outputName, expectedOutput);
+ await expect.soft(page.getByText(/^Cost: \$/)).toHaveCount(0);
+ await expectNoHostedOnlyChrome(page);
+ });
+
+ await test.step("settings: memory is reachable, billing is not", async () => {
+ await page.goto("/settings/memory");
+ await expect
+ .soft(page.getByRole("heading", { name: "Memory", level: 1 }))
+ .toBeVisible();
+
+ await page.goto("/settings/account");
+ await expect(page.getByRole("link", { name: "Account" })).toBeVisible();
+ await expect
+ .soft(page.getByRole("link", { name: "Billing" }))
+ .toHaveCount(0);
+
+ await page.goto("/settings/billing");
+ await expect
+ .soft(page.getByText("This page could not be found.").first())
+ .toBeVisible();
+ await expect
+ .soft(page.getByText(/pick a plan|get pro|add credits/i))
+ .toHaveCount(0);
+ });
+
+ expect(
+ [...thirdPartyRequests].sort(),
+ "a self-hosted install must not make the browser call other hosts",
+ ).toEqual([]);
+});
+
+const AGENTATION = "[data-agentation-root], [data-agentation-toolbar]";
+
+// Drags from the first node's named output to the second node's named input.
+// BuildPage.connectNodes takes each node's first handle, which for Store Value
+// is ``error``.
+async function connectHandles(page: Page, output: string, input: string) {
+ const nodeIDs = await page
+ .locator('[data-id^="custom-node-"]')
+ .evaluateAll((nodes) =>
+ nodes.map((node) =>
+ (node.getAttribute("data-id") ?? "").replace("custom-node-", ""),
+ ),
+ );
+ const source = page.locator(
+ `[data-tutorial-id="output-handler-${nodeIDs[0]}-${output}"]`,
+ );
+ const target = page.locator(
+ `[data-tutorial-id="input-handler-${nodeIDs[1]}-${input}"]`,
+ );
+ const from = await centerOf(source);
+ const to = await centerOf(target);
+ await page.mouse.move(from.x, from.y);
+ await page.mouse.down();
+ const steps = 20;
+ for (let step = 1; step <= steps; step++) {
+ await page.mouse.move(
+ from.x + ((to.x - from.x) * step) / steps,
+ from.y + ((to.y - from.y) * step) / steps,
+ );
+ }
+ await page.mouse.up();
+}
+
+async function centerOf(locator: Locator) {
+ const box = await locator.boundingBox();
+ if (!box) throw new Error("handle is not on screen");
+ return { x: box.x + box.width / 2, y: box.y + box.height / 2 };
+}
+
+async function submitSignup(page: Page, email: string) {
+ await page.goto("/signup");
+ await expect(page.getByText("Create your account")).toBeVisible();
+ await page.getByLabel("Email").fill(email);
+ await page.locator("#password").fill(PASSWORD);
+ await page.locator("#confirmPassword").fill(PASSWORD);
+ await page.getByRole("button", { name: "Sign up" }).click();
+}
+
+// Role, pain points and the self-hosted "connect" step, then the workspace
+// is prepared and the app lands on Home. A plan or paywall step fails here.
+async function finishOnboarding(page: Page) {
+ await expect(
+ page.getByRole("heading", { name: "What best describes you?" }),
+ ).toBeVisible();
+ await page.getByRole("button", { name: "Engineering", exact: true }).click();
+ await page.getByRole("button", { name: "Next", exact: true }).click();
+
+ await expect(
+ page.getByRole("heading", { name: /What's eating your time\?/ }),
+ ).toBeVisible();
+ await page.getByText("Research", { exact: true }).click();
+ await page.getByRole("button", { name: "Continue", exact: true }).click();
+
+ await expect(
+ page.getByRole("heading", {
+ name: "Already paying for an AI subscription?",
+ }),
+ ).toBeVisible();
+ await page.getByRole("button", { name: "Next", exact: true }).click();
+
+ await page.waitForURL((url) => !url.pathname.startsWith("/onboarding"), {
+ timeout: 60_000,
+ });
+}
+
+async function expectNoHostedOnlyChrome(page: Page) {
+ const accountMenu = page.getByTestId("profile-popout-menu-trigger");
+ await expect(accountMenu).toBeVisible();
+ await expect.soft(page.getByText(/earn credits/i)).toHaveCount(0);
+ await expect.soft(page.locator(AGENTATION)).toHaveCount(0);
+
+ await accountMenu.click();
+ const menu = page.getByTestId("account-menu-popover");
+ await expect(menu.getByText("Settings")).toBeVisible();
+ await expect.soft(menu.getByText("Billing")).toHaveCount(0);
+ await page.keyboard.press("Escape");
+}
+
+function recordThirdPartyRequests(context: BrowserContext) {
+ const ownOrigin = new URL(
+ process.env.PLAYWRIGHT_BASE_URL ?? "http://localhost:3000",
+ ).origin;
+ const seen = new Set<string>();
+ context.on("request", (request) => {
+ const url = new URL(request.url());
+ if (!["http:", "https:", "ws:", "wss:"].includes(url.protocol)) return;
+ const origin = url.origin.replace(/^ws/, "http");
+ if (origin === ownOrigin) return;
+ seen.add(`${request.method()} ${url.host}${url.pathname}`);
+ });
+ return seen;
+}
diff --git a/autogpt_platform/single-container/Dockerfile b/autogpt_platform/single-container/Dockerfile
index b1b9b58546..e8282aec4b 100644
--- a/autogpt_platform/single-container/Dockerfile
+++ b/autogpt_platform/single-container/Dockerfile
@@ -23,6 +23,7 @@ ENV NODE_ENV=production \
NEXT_PUBLIC_APP_ENV=local \
NEXT_PUBLIC_BEHAVE_AS=LOCAL \
NEXT_PUBLIC_LAUNCHDARKLY_ENABLED=false \
+ NEXT_PUBLIC_FORCE_FLAG_GRAPHITI_MEMORY=true \
NEXT_PUBLIC_SOURCEMAPS=false \
NEXT_PUBLIC_TURNSTILE=disabled \
NEXT_PUBLIC_VAPID_PUBLIC_KEY="" \
@@ -231,6 +232,9 @@ RUN POETRY_VIRTUALENVS_CREATE=true POETRY_VIRTUALENVS_IN_PROJECT=true \
&& rm -f /app/autogpt_platform/backend/config.json \
&& ln -s /data/config/backend.json /app/autogpt_platform/backend/config.json
+# FORCE_FLAG_GRAPHITI_MEMORY keeps memory on; the frontend stage's
+# NEXT_PUBLIC_FORCE_FLAG_GRAPHITI_MEMORY must match it, or users can't open
+# /settings/memory to see or erase what was remembered.
ENV PATH="/opt/rabbitmq/sbin:/opt/erlang/bin:/opt/openssl/bin:/usr/lib/postgresql/15/bin:/app/autogpt_platform/backend/.venv/bin:${PATH}" \
ERLANG_INSTALL_PATH_PREFIX=/opt/erlang \
OPENSSL_INSTALL_PATH_PREFIX=/opt/openssl \
diff --git a/autogpt_platform/single-container/bootstrap.sh b/autogpt_platform/single-container/bootstrap.sh
index 8c48a68bd7..f3248a8c9e 100755
--- a/autogpt_platform/single-container/bootstrap.sh
+++ b/autogpt_platform/single-container/bootstrap.sh
@@ -245,7 +245,12 @@ GRANT SELECT, INSERT, UPDATE, DELETE ON TABLE
platform."UserAuthJwks"
TO autogpt_frontend;
-GRANT SELECT (id, email), UPDATE (email, "updatedAt")
+-- INSERT creates the platform User row from the sign-up hook
+-- (frontend/src/lib/auth/provision-platform-user.ts), so a session never
+-- exists before it. Every other column keeps its database default.
+GRANT SELECT (id, email),
+ INSERT (id, email, name, "updatedAt"),
+ UPDATE (email, "updatedAt")
ON TABLE platform."User"
TO autogpt_frontend;
diff --git a/autogpt_platform/single-container/tests/test_frontend_environment.py b/autogpt_platform/single-container/tests/test_frontend_environment.py
index 603ef1b8c2..6fa1ce112c 100644
--- a/autogpt_platform/single-container/tests/test_frontend_environment.py
+++ b/autogpt_platform/single-container/tests/test_frontend_environment.py
@@ -177,7 +177,12 @@ class FrontendEnvironmentTest(unittest.TestCase):
'platform."UserAuthJwks"',
):
self.assertEqual(policy.count(table), 1)
- self.assertIn('GRANT SELECT (id, email), UPDATE (email, "updatedAt")', policy)
+ self.assertIn(
+ 'GRANT SELECT (id, email),\n'
+ ' INSERT (id, email, name, "updatedAt"),\n'
+ ' UPDATE (email, "updatedAt")',
+ policy,
+ )
self.assertIn(
"ALTER ROLE autogpt_frontend IN DATABASE postgres RESET ALL", policy
)