From 4fd346cb2056f752bc3ad94b12eae4b037a9a092 Mon Sep 17 00:00:00 2001 From: Paul Walko Date: Sat, 13 Dec 2025 00:18:50 +0100 Subject: [PATCH] fix builds --- web/agent/server.py | 4 +++- web/src/app/api/copilotkit/route.ts | 32 +++++++---------------------- 2 files changed, 10 insertions(+), 26 deletions(-) diff --git a/web/agent/server.py b/web/agent/server.py index 939935c..a191327 100644 --- a/web/agent/server.py +++ b/web/agent/server.py @@ -17,8 +17,10 @@ app = FastAPI(title="Cavepedia Agent") def build_agents(context): - """Build agents with auth context from frontend.""" + """Build agents with auth context from properties.""" + # Get user roles from frontend properties user_roles = context.get("properties", {}).get("auth0_user_roles", []) + return [ LangGraphAgent( name="vpi_1000", diff --git a/web/src/app/api/copilotkit/route.ts b/web/src/app/api/copilotkit/route.ts index ae3baeb..9fe666d 100644 --- a/web/src/app/api/copilotkit/route.ts +++ b/web/src/app/api/copilotkit/route.ts @@ -5,36 +5,18 @@ import { } from "@copilotkit/runtime"; import { NextRequest } from "next/server"; -import { auth0 } from "@/lib/auth0"; -// 1. You can use any service adapter here for multi-agent support. We use -// the empty adapter since we're only using one agent. const serviceAdapter = new ExperimentalEmptyAdapter(); -// 3. Build a Next.js API route that handles the CopilotKit runtime requests. -export const POST = async (req: NextRequest) => { - // Get Auth0 session - const session = await auth0.getSession(); - - // Extract roles from session - const userRoles = session?.user?.roles || []; - - console.log("[copilotkit] session exists:", !!session); - console.log("[copilotkit] userRoles:", userRoles); - - // 2. Create the CopilotRuntime instance with remote endpoint - const runtime = new CopilotRuntime({ - remoteEndpoints: [ - { - url: `${process.env.LANGGRAPH_DEPLOYMENT_URL || "http://localhost:8000"}/copilotkit`, - }, - ], - // Pass auth context as properties to the remote endpoint - properties: { - auth0_user_roles: userRoles, +const runtime = new CopilotRuntime({ + remoteEndpoints: [ + { + url: `${process.env.LANGGRAPH_DEPLOYMENT_URL || "http://localhost:8000"}/copilotkit`, }, - }); + ], +}); +export const POST = async (req: NextRequest) => { const { handleRequest } = copilotRuntimeNextJSAppRouterEndpoint({ runtime, serviceAdapter,