UNPKG

@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;" />

38 lines (36 loc) 1.38 kB
require("reflect-metadata"); const require_runtime = require('../../../_virtual/_rolldown/runtime.cjs'); const require_fetch_handler = require('../core/fetch-handler.cjs'); let hono = require("hono"); //#region src/v2/runtime/endpoints/hono.ts /** @deprecated Use `createCopilotHonoHandler` instead. */ const createCopilotEndpoint = createCopilotHonoHandler; function createCopilotHonoHandler({ runtime, basePath, mode = "multi-route", cors: corsConfig, hooks, activateChannels, __channelEngine }) { const handler = require_fetch_handler.createCopilotRuntimeHandler({ runtime, basePath, mode, cors: corsConfig ? toFetchCorsConfig(corsConfig) : true, hooks, activateChannels, __channelEngine }); const scopedApp = new hono.Hono().basePath(basePath).all("*", async (c) => handler(c.req.raw)); scopedApp.channels = handler.channels; return scopedApp; } /** * Convert Hono-specific CORS config to the fetch handler's CopilotCorsConfig. */ function toFetchCorsConfig(config) { const origin = config.origin; return { origin: typeof origin === "function" ? (reqOrigin) => origin(reqOrigin, void 0) ?? null : origin, credentials: config.credentials }; } //#endregion exports.createCopilotEndpoint = createCopilotEndpoint; exports.createCopilotHonoHandler = createCopilotHonoHandler; exports.toFetchCorsConfig = toFetchCorsConfig; //# sourceMappingURL=hono.cjs.map