forked from CopilotKit/CopilotKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
32 lines (26 loc) · 884 Bytes
/
Copy pathindex.ts
File metadata and controls
32 lines (26 loc) · 884 Bytes
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
import { Hono } from "hono";
import { serve } from "@hono/node-server";
import { CopilotRuntime, BuiltInAgent } from "@copilotkit/runtime/v2";
import { createCopilotHonoHandler } from "@copilotkit/runtime/v2/hono";
const runtime = new CopilotRuntime({
agents: {
default: new BuiltInAgent({ model: "openai/gpt-5-mini" }),
},
});
const app = new Hono();
// Root
app.get("/", (c) =>
c.json({ status: "ok", message: "CopilotKit Hono runtime" }),
);
// Health check
app.get("/health", (c) => c.json({ status: "healthy" }));
// CopilotKit endpoints
app.route(
"/",
createCopilotHonoHandler({ runtime, basePath: "/api/copilotkit" }),
);
const port = Number(process.env.PORT ?? 4003);
serve({ fetch: app.fetch, port }, () => {
console.log(`Hono runtime listening on http://localhost:${port}`);
console.log(` CopilotKit: http://localhost:${port}/api/copilotkit`);
});