forked from CopilotKit/CopilotKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.ts
More file actions
50 lines (45 loc) · 1.42 KB
/
Copy pathserver.ts
File metadata and controls
50 lines (45 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { serve } from "@hono/node-server";
import {
CopilotRuntime,
CopilotKitIntelligence,
createCopilotHonoHandler,
} from "@copilotkit/runtime/v2";
import { LangGraphAgent } from "@copilotkit/runtime/langgraph";
const intelligence = new CopilotKitIntelligence({
apiKey:
process.env.INTELLIGENCE_API_KEY ?? "cpk_sPRVSEED_seed0privat0longtoken00",
apiUrl: process.env.INTELLIGENCE_API_URL ?? "http://localhost:4201",
wsUrl: process.env.INTELLIGENCE_GATEWAY_WS_URL ?? "ws://localhost:4401",
});
const agent = new LangGraphAgent({
deploymentUrl:
process.env.LANGGRAPH_DEPLOYMENT_URL ?? "http://localhost:8123",
graphId: "sample_agent",
langsmithApiKey: process.env.LANGSMITH_API_KEY ?? "",
});
const app = createCopilotHonoHandler({
basePath: "/api/copilotkit",
runtime: new CopilotRuntime({
intelligence,
identifyUser: () => ({ id: "jordan-beamson", name: "Jordan Beamson" }),
licenseToken: process.env.COPILOTKIT_LICENSE_TOKEN,
agents: { default: agent },
openGenerativeUI: true,
a2ui: {
injectA2UITool: false,
},
mcpApps: {
servers: [
{
type: "http",
url: process.env.MCP_SERVER_URL || "https://mcp.excalidraw.com",
serverId: "example_mcp_app",
},
],
},
}),
});
const port = Number(process.env.PORT) || 4000;
serve({ fetch: app.fetch, port }, () => {
console.log(`BFF ready at http://localhost:${port}`);
});