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

49 lines (48 loc) 1.6 kB
import "reflect-metadata"; import { CopilotRuntimeLike } from "../core/runtime.mjs"; import { CopilotRuntimeHooks } from "../core/hooks.mjs"; import { Router } from "express"; //#region src/v2/runtime/endpoints/express-single.d.ts interface CopilotSingleRouteExpressParams { runtime: CopilotRuntimeLike; basePath: string; /** * Lifecycle hooks for request processing. */ hooks?: CopilotRuntimeHooks; } /** * Creates an Express router that serves the CopilotKit runtime as a single * POST endpoint. Clients send a JSON envelope with `{ method, params, body }` * to dispatch to the appropriate handler. * * This is a convenience wrapper around {@link createCopilotExpressHandler} * with `mode: "single-route"` and `cors: true`. * * @example * ```typescript * import express from "express"; * import { CopilotRuntime } from "@copilotkit/runtime/v2"; * import { createCopilotEndpointSingleRouteExpress } from "@copilotkit/runtime/v2/express"; * * const runtime = new CopilotRuntime({ * agents: { default: new BuiltInAgent({ model: "openai/gpt-4o-mini" }) }, * }); * * const app = express(); * app.use(createCopilotEndpointSingleRouteExpress({ * runtime, * basePath: "/api/copilotkit", * })); * app.listen(4000); * ``` */ /** @deprecated Use `createCopilotExpressHandler` with `mode: "single-route"` instead. */ declare function createCopilotEndpointSingleRouteExpress({ runtime, basePath, hooks }: CopilotSingleRouteExpressParams): Router; //#endregion export { createCopilotEndpointSingleRouteExpress }; //# sourceMappingURL=express-single.d.mts.map