@copilotkit/runtime
Version:
<img src="https://github.com/user-attachments/assets/0a6b64d9-e193-4940-a3f6-60334ac34084" alt="banner" style="border-radius: 12px; border: 2px solid #d6d4fa;" />
28 lines (26 loc) • 1.06 kB
JavaScript
import "reflect-metadata";
import { createCopilotRuntimeHandler } from "../core/fetch-handler.mjs";
import { toFetchCorsConfig } from "./hono.mjs";
import { Hono } from "hono";
//#region src/v2/runtime/endpoints/hono-single.ts
/** @deprecated Use `createCopilotHonoHandler` with `mode: "single-route"` instead. */
function createCopilotEndpointSingleRoute({ runtime, basePath, cors: corsConfig, hooks }) {
const routePath = normalizePath(basePath);
const handler = createCopilotRuntimeHandler({
runtime,
basePath: routePath,
mode: "single-route",
cors: corsConfig ? toFetchCorsConfig(corsConfig) : true,
hooks
});
return new Hono().basePath(routePath).all("*", async (c) => handler(c.req.raw));
}
function normalizePath(path) {
if (!path) throw new Error("basePath must be provided for single-route endpoint");
if (!path.startsWith("/")) return `/${path}`;
if (path.length > 1 && path.endsWith("/")) return path.slice(0, -1);
return path;
}
//#endregion
export { createCopilotEndpointSingleRoute };
//# sourceMappingURL=hono-single.mjs.map