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

40 lines (31 loc) 1.18 kB
import { CreateCopilotRuntimeServerOptions, getCommonConfig } from "../shared"; import telemetry, { getRuntimeInstanceTelemetryInfo } from "../../telemetry-client"; import { copilotRuntimeNodeHttpEndpoint } from "../node-http"; export const config = { api: { bodyParser: false, }, }; // This import is needed to fix the type error // Fix is currently in TypeScript 5.5 beta, waiting for stable version // https://github.com/microsoft/TypeScript/issues/42873#issuecomment-2066874644 export type {} from "@whatwg-node/server"; export function copilotRuntimeNextJSPagesRouterEndpoint( options: CreateCopilotRuntimeServerOptions, ) { const commonConfig = getCommonConfig(options); telemetry.setGlobalProperties({ runtime: { framework: "nextjs-pages-router", }, }); if (options.properties?._copilotkit) { telemetry.setGlobalProperties({ _copilotkit: options.properties._copilotkit, }); } telemetry.capture("oss.runtime.instance_created", getRuntimeInstanceTelemetryInfo(options)); const logger = commonConfig.logging; logger.debug("Creating NextJS Pages Router endpoint"); return copilotRuntimeNodeHttpEndpoint(options); }