pass roles + debugging
All checks were successful
Build and Push Agent Docker Image / build (push) Successful in 1m3s
Build and Push Web Docker Image / build (push) Successful in 3m59s

This commit is contained in:
2025-12-13 17:23:52 +01:00
parent 0e24515303
commit c808f51eb7
9 changed files with 123 additions and 88 deletions

View File

@@ -6,18 +6,31 @@ import {
import { HttpAgent } from "@ag-ui/client";
import { NextRequest } from "next/server";
import { auth0 } from "@/lib/auth0";
const serviceAdapter = new ExperimentalEmptyAdapter();
const runtime = new CopilotRuntime({
agents: {
vpi_1000: new HttpAgent({
url: process.env.AGENT_URL || "http://localhost:8000/",
}),
},
});
export const POST = async (req: NextRequest) => {
// Get user session and roles
const session = await auth0.getSession();
const userRoles = (session?.user?.roles as string[]) || [];
console.log("DEBUG: User roles from session:", userRoles);
// Create HttpAgent with user roles header
const agent = new HttpAgent({
url: process.env.AGENT_URL || "http://localhost:8000/",
headers: {
"x-user-roles": JSON.stringify(userRoles),
},
});
const runtime = new CopilotRuntime({
agents: {
vpi_1000: agent,
},
});
const { handleRequest } = copilotRuntimeNextJSAppRouterEndpoint({
runtime,
serviceAdapter,