@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;" />
29 lines (27 loc) • 1.2 kB
JavaScript
require("reflect-metadata");
const require_runtime = require('../../../_virtual/_rolldown/runtime.cjs');
const require_fetch_handler = require('../core/fetch-handler.cjs');
const require_hono = require('./hono.cjs');
let hono = require("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 = require_fetch_handler.createCopilotRuntimeHandler({
runtime,
basePath: routePath,
mode: "single-route",
cors: corsConfig ? require_hono.toFetchCorsConfig(corsConfig) : true,
hooks
});
return new hono.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
exports.createCopilotEndpointSingleRoute = createCopilotEndpointSingleRoute;
//# sourceMappingURL=hono-single.cjs.map