Skip to content

Commit baa67ea

Browse files
committed
integrate vnext chat
1 parent 86a7cbb commit baa67ea

File tree

9 files changed

+1525
-56
lines changed

9 files changed

+1525
-56
lines changed

apps/dojo/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
"@copilotkit/runtime": "1.10.6",
3434
"@copilotkit/runtime-client-gql": "1.10.6",
3535
"@copilotkit/shared": "1.10.6",
36+
"@copilotkitnext/react": "0.0.19-alpha.0",
37+
"@copilotkitnext/runtime": "0.0.19-alpha.0",
3638
"@mastra/client-js": "^0.15.2",
3739
"@mastra/core": "^0.20.2",
3840
"@mastra/dynamodb": "^0.15.6",
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
"use client";
2+
3+
import React from "react";
4+
import "@copilotkitnext/react/styles.css";
5+
import { CopilotChat, CopilotKitProvider } from "@copilotkitnext/react";
6+
7+
export const dynamic = "force-dynamic";
8+
9+
interface PageProps {
10+
params: Promise<{
11+
integrationId: string;
12+
}>;
13+
}
14+
15+
export default function Page({ params }: PageProps) {
16+
const { integrationId } = React.use(params);
17+
18+
return (
19+
<CopilotKitProvider
20+
runtimeUrl={`/api/copilotkitnext/${integrationId}`}
21+
showDevConsole="auto"
22+
>
23+
<main
24+
className="flex min-h-screen flex-1 flex-col overflow-hidden"
25+
style={{ minHeight: "100dvh" }}
26+
>
27+
<Chat threadId={`${integrationId}-vnext_chat`} />
28+
</main>
29+
</CopilotKitProvider>
30+
);
31+
}
32+
33+
function Chat({ threadId }: { threadId: string }) {
34+
return (
35+
<div className="flex flex-1 flex-col overflow-hidden">
36+
<CopilotChat style={{ flex: 1, minHeight: "100%" }} threadId={threadId} />
37+
</div>
38+
);
39+
}

apps/dojo/src/app/api/copilotkit/[integrationId]/route.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,18 @@ import {
33
ExperimentalEmptyAdapter,
44
copilotRuntimeNextJSAppRouterEndpoint,
55
} from "@copilotkit/runtime";
6-
import { agentsIntegrations } from "@/agents";
7-
86
import { NextRequest } from "next/server";
97

8+
import { agentsIntegrations } from "@/agents";
9+
1010
export async function POST(request: NextRequest) {
1111
const integrationId = request.url.split("/").pop();
1212

1313
const integration = agentsIntegrations.find((i) => i.id === integrationId);
1414
if (!integration) {
1515
return new Response("Integration not found", { status: 404 });
1616
}
17+
1718
const agents = await integration.agents();
1819
const runtime = new CopilotRuntime({
1920
// @ts-ignore for now
@@ -27,3 +28,4 @@ export async function POST(request: NextRequest) {
2728

2829
return handleRequest(request);
2930
}
31+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import {
2+
CopilotRuntime,
3+
InMemoryAgentRunner,
4+
createCopilotEndpoint,
5+
} from "@copilotkitnext/runtime";
6+
import { handle } from "hono/vercel";
7+
8+
const runtime = new CopilotRuntime({
9+
agents: {
10+
default: null as any,
11+
},
12+
runner: new InMemoryAgentRunner(),
13+
});
14+
15+
const app = createCopilotEndpoint({
16+
runtime,
17+
basePath: "/api/copilotkit",
18+
});
19+
20+
export const GET = handle(app);
21+
export const POST = handle(app);
22+
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import {
2+
CopilotRuntime,
3+
InMemoryAgentRunner,
4+
createCopilotEndpoint,
5+
} from "@copilotkitnext/runtime";
6+
import { handle } from "hono/vercel";
7+
import type { NextRequest } from "next/server";
8+
9+
type RouteParams = {
10+
params: {
11+
integrationId: string;
12+
slug?: string[];
13+
};
14+
};
15+
16+
function createHandler(integrationId: string) {
17+
const runtime = new CopilotRuntime({
18+
agents: {
19+
default: null as any,
20+
},
21+
runner: new InMemoryAgentRunner(),
22+
});
23+
24+
const app = createCopilotEndpoint({
25+
runtime,
26+
basePath: `/api/copilotkitnext/${integrationId}`,
27+
});
28+
29+
return handle(app);
30+
}
31+
32+
export function GET(request: NextRequest, context: RouteParams) {
33+
const handler = createHandler(context.params.integrationId);
34+
return handler(request);
35+
}
36+
37+
export function POST(request: NextRequest, context: RouteParams) {
38+
const handler = createHandler(context.params.integrationId);
39+
return handler(request);
40+
}
41+

apps/dojo/src/config.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,15 @@ export const featureConfig: FeatureConfig[] = [
3232
createFeatureConfig({
3333
id: "human_in_the_loop",
3434
name: "Human in the loop",
35-
description: "Plan a task together and direct the Copilot to take the right steps",
35+
description:
36+
"Plan a task together and direct the Copilot to take the right steps",
3637
tags: ["HITL", "Interactivity"],
3738
}),
3839
createFeatureConfig({
3940
id: "agentic_generative_ui",
4041
name: "Agentic Generative UI",
41-
description: "Assign a long running task to your Copilot and see how it performs!",
42+
description:
43+
"Assign a long running task to your Copilot and see how it performs!",
4244
tags: ["Generative ui (agent)", "Long running task"],
4345
}),
4446
createFeatureConfig({
@@ -56,7 +58,8 @@ export const featureConfig: FeatureConfig[] = [
5658
createFeatureConfig({
5759
id: "predictive_state_updates",
5860
name: "Predictive State Updates",
59-
description: "Use collaboration to edit a document in real time with your Copilot",
61+
description:
62+
"Use collaboration to edit a document in real time with your Copilot",
6063
tags: ["State", "Streaming", "Tools"],
6164
}),
6265
createFeatureConfig({
@@ -68,7 +71,8 @@ export const featureConfig: FeatureConfig[] = [
6871
createFeatureConfig({
6972
id: "subgraphs",
7073
name: "Subgraphs",
71-
description: "Have your tasks performed by multiple agents, working together",
74+
description:
75+
"Have your tasks performed by multiple agents, working together",
7276
tags: ["Chat", "Multi-agent architecture", "Streaming", "Subgraphs"],
7377
}),
7478
createFeatureConfig({
@@ -77,6 +81,12 @@ export const featureConfig: FeatureConfig[] = [
7781
description: "Chat with your Copilot and call frontend tools",
7882
tags: ["Chat", "Tools", "Streaming"],
7983
}),
84+
createFeatureConfig({
85+
id: "vnext_chat",
86+
name: "VNext Chat",
87+
description: "Chat based on CopilotKit vnext",
88+
tags: ["Chat", "VNext", "Streaming"],
89+
}),
8090
];
8191

8292
export default featureConfig;

apps/dojo/src/menu.ts

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ export const menuIntegrations: MenuIntegrationConfig[] = [
4747
{
4848
id: "mastra",
4949
name: "Mastra",
50-
features: ["agentic_chat", "backend_tool_rendering", "tool_based_generative_ui"],
50+
features: [
51+
"agentic_chat",
52+
"backend_tool_rendering",
53+
"tool_based_generative_ui",
54+
],
5155
},
5256
{
5357
id: "mastra-agent-local",
@@ -60,15 +64,15 @@ export const menuIntegrations: MenuIntegrationConfig[] = [
6064
],
6165
},
6266
{
63-
id: 'spring-ai',
64-
name: 'Spring AI',
67+
id: "spring-ai",
68+
name: "Spring AI",
6569
features: [
66-
'agentic_chat',
67-
'shared_state',
68-
'tool_based_generative_ui',
69-
'human_in_the_loop',
70-
'agentic_generative_ui'
71-
]
70+
"agentic_chat",
71+
"shared_state",
72+
"tool_based_generative_ui",
73+
"human_in_the_loop",
74+
"agentic_generative_ui",
75+
],
7276
},
7377
{
7478
id: "pydantic-ai",
@@ -99,7 +103,11 @@ export const menuIntegrations: MenuIntegrationConfig[] = [
99103
{
100104
id: "agno",
101105
name: "Agno",
102-
features: ["agentic_chat", "backend_tool_rendering", "tool_based_generative_ui"],
106+
features: [
107+
"agentic_chat",
108+
"backend_tool_rendering",
109+
"tool_based_generative_ui",
110+
],
103111
},
104112
{
105113
id: "llama-index",
@@ -128,7 +136,7 @@ export const menuIntegrations: MenuIntegrationConfig[] = [
128136
{
129137
id: "a2a-basic",
130138
name: "A2A (Direct)",
131-
features: ["agentic_chat"],
139+
features: ["vnext_chat"],
132140
},
133141
// Disabled until we can support Vercel AI SDK v5
134142
// {

apps/dojo/src/types/integration.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ export type Feature =
1010
| "backend_tool_rendering"
1111
| "agentic_chat_reasoning"
1212
| "subgraphs"
13-
| "a2a_chat";
13+
| "a2a_chat"
14+
| "vnext_chat";
1415

1516
export interface MenuIntegrationConfig {
1617
id: string;

0 commit comments

Comments
 (0)