From c40ce6c8ded521f22f644e14638d1e4541490bd4 Mon Sep 17 00:00:00 2001 From: Max Korp Date: Mon, 27 Oct 2025 12:32:08 -0700 Subject: [PATCH 1/2] bump langgraph just to test --- apps/angular/demo-server/package.json | 2 +- pnpm-lock.yaml | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/apps/angular/demo-server/package.json b/apps/angular/demo-server/package.json index b47cc43f..6122b2b3 100644 --- a/apps/angular/demo-server/package.json +++ b/apps/angular/demo-server/package.json @@ -9,7 +9,7 @@ }, "dependencies": { "@ag-ui/client": "0.0.40-alpha.6", - "@ag-ui/langgraph": "^0.0.11", + "@ag-ui/langgraph": "^0.0.12-alpha.0", "@copilotkitnext/demo-agents": "workspace:^", "@copilotkitnext/runtime": "workspace:^", "@hono/node-server": "^1.13.6", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5631172e..2ff61841 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -97,8 +97,8 @@ importers: specifier: 0.0.40-alpha.6 version: 0.0.40-alpha.6 '@ag-ui/langgraph': - specifier: ^0.0.11 - version: 0.0.11(@opentelemetry/api@1.9.0)(openai@4.104.0(encoding@0.1.13)(ws@8.18.3)(zod@3.25.75))(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + specifier: ^0.0.12-alpha.0 + version: 0.0.12(@ag-ui/client@0.0.40-alpha.6)(@ag-ui/core@0.0.36)(@opentelemetry/api@1.9.0)(openai@4.104.0(encoding@0.1.13)(ws@8.18.3)(zod@3.25.75))(react-dom@18.3.1(react@18.3.1))(react@18.3.1) '@copilotkitnext/demo-agents': specifier: workspace:^ version: link:../../../packages/demo-agents @@ -1025,8 +1025,11 @@ packages: '@ag-ui/encoder@0.0.40-alpha.6': resolution: {integrity: sha512-q+bpJGp4fMjQplHowmbNaOQrICHzmk1J394jZXmTv/RjysNHtcDrWHythXBiPAnNRutYeqsG6bQJ5PASbQYiqg==} - '@ag-ui/langgraph@0.0.11': - resolution: {integrity: sha512-3xUkaOelnpQ5tbsbuoOTin71tTgWEN0GDZBjGs/7xAwly2Dn4fahbBAoscXullO/pH9kTGGgbuJ0rWDUgo6fKQ==} + '@ag-ui/langgraph@0.0.12': + resolution: {integrity: sha512-2j7IqIUYh0WAdvCXH65hd5aSHi23EOKVo78BauXa2vZI8Pricpkq9Adr2coZB2cwCbTV37lMn5yVlpDV0iQvOA==} + peerDependencies: + '@ag-ui/client': '>=0.0.37' + '@ag-ui/core': '>=0.0.37' '@ag-ui/proto@0.0.36': resolution: {integrity: sha512-yaWLwJQmBaCtFstSoZEALztVckCYv+RD8guU91kL5AvywRXvZPP5mjiN+bEwvtw8VU3idXoee1ZbJGpSlSAQ8A==} @@ -12541,9 +12544,10 @@ snapshots: '@ag-ui/core': 0.0.40-alpha.6 '@ag-ui/proto': 0.0.40-alpha.6 - '@ag-ui/langgraph@0.0.11(@opentelemetry/api@1.9.0)(openai@4.104.0(encoding@0.1.13)(ws@8.18.3)(zod@3.25.75))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)': + '@ag-ui/langgraph@0.0.12(@ag-ui/client@0.0.40-alpha.6)(@ag-ui/core@0.0.36)(@opentelemetry/api@1.9.0)(openai@4.104.0(encoding@0.1.13)(ws@8.18.3)(zod@3.25.75))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)': dependencies: - '@ag-ui/client': 0.0.36 + '@ag-ui/client': 0.0.40-alpha.6 + '@ag-ui/core': 0.0.36 '@langchain/core': 0.3.73(@opentelemetry/api@1.9.0)(openai@4.104.0(encoding@0.1.13)(ws@8.18.3)(zod@3.25.75)) '@langchain/langgraph-sdk': 0.0.105(@langchain/core@0.3.73(@opentelemetry/api@1.9.0)(openai@4.104.0(encoding@0.1.13)(ws@8.18.3)(zod@3.25.75)))(react-dom@18.3.1(react@18.3.1))(react@18.3.1) partial-json: 0.1.7 From a6880c6ee6f542b0f94bc005682b45a75a83ab2d Mon Sep 17 00:00:00 2001 From: Max Korp Date: Mon, 27 Oct 2025 12:32:17 -0700 Subject: [PATCH 2/2] add headers and middleware --- apps/angular/demo-server/src/index.ts | 53 +++++++++++++++++++++++-- apps/angular/demo/src/app/app.config.ts | 5 +++ 2 files changed, 54 insertions(+), 4 deletions(-) diff --git a/apps/angular/demo-server/src/index.ts b/apps/angular/demo-server/src/index.ts index 62978319..76adf88e 100644 --- a/apps/angular/demo-server/src/index.ts +++ b/apps/angular/demo-server/src/index.ts @@ -3,13 +3,58 @@ import { Hono } from "hono"; import { cors } from "hono/cors"; import { CopilotRuntime, createCopilotEndpoint, InMemoryAgentRunner } from "@copilotkitnext/runtime"; import { OpenAIAgent, SlowToolCallStreamingAgent } from "@copilotkitnext/demo-agents"; +import { HttpAgent, HttpAgentConfig, RunAgentInput } from "@ag-ui/client"; +import { LangGraphHttpAgent } from "@ag-ui/langgraph"; + + + +class SplendidAgent extends LangGraphHttpAgent { + constructor(config: HttpAgentConfig) { + super(config); + console.log('🚀 SplendidAgent initialized with config:', { + url: config.url, + headers: config.headers ? Object.keys(config.headers) : 'none', + debug: config.debug + }); + } + + requestInit(input: RunAgentInput) { + const request = super.requestInit(input); + + console.log('📤 Outgoing Request Details:'); + console.log(' URL:', this.url); + console.log(' Method:', request.method || 'POST'); + console.log(' Headers:', JSON.stringify(request.headers, null, 2)); + // console.log(' Body:', request.body ? JSON.stringify(JSON.parse(request.body), null, 2) : 'none'); + + return request; + } + + run(input: RunAgentInput) { + + const request = super.requestInit(input); + console.log('🚀 SplendidAgent running with request:', request); + return super.run({ + ...input, + forwardedProps: { + ...input.forwardedProps, + stream_subgraphs: true, + streamSubgraphs: true, + } + }); + } +} + const runtime = new CopilotRuntime({ agents: { // @ts-ignore - default: new SlowToolCallStreamingAgent(), - // @ts-ignore - openai: new OpenAIAgent(), + openai: new SplendidAgent({ + url: 'localhost:8000' + "/agent/agentic_chat", + + headers: {'x-chz': "whiz"}, + debug: true, + }), }, runner: new InMemoryAgentRunner(), }); @@ -23,7 +68,7 @@ app.use( cors({ origin: "http://localhost:4200", allowMethods: ["GET", "POST", "OPTIONS", "PUT", "DELETE"], - allowHeaders: ["Content-Type", "Authorization", "X-Requested-With"], + allowHeaders: ["Content-Type", "Authorization", "X-Requested-With", "X-Max-wuzhear"], exposeHeaders: ["Content-Type"], credentials: true, maxAge: 86400, diff --git a/apps/angular/demo/src/app/app.config.ts b/apps/angular/demo/src/app/app.config.ts index d2c2747d..3bf8e4ba 100644 --- a/apps/angular/demo/src/app/app.config.ts +++ b/apps/angular/demo/src/app/app.config.ts @@ -19,11 +19,16 @@ export const appConfig: ApplicationConfig = { ], frontendTools: [], humanInTheLoop: [], + headers: { + 'authorization': 'MAX SANDWICH', + 'x-Max-wuzhear': "CHEEZBORGER", + }, }), provideCopilotChatLabels({ chatInputPlaceholder: "Ask me anything...", chatDisclaimerText: "CopilotKit Angular Demo - AI responses may need verification.", }), + ], };