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

64 lines (63 loc) 2.37 kB
import "reflect-metadata"; import { CopilotRuntimeLike } from "../core/runtime.mjs"; import { CopilotRuntimeHooks } from "../core/hooks.mjs"; import { ActivateChannelEngine, ChannelsControl } from "../core/channel-manager.mjs"; import { Router } from "express"; import { CorsOptions } from "cors"; //#region src/v2/runtime/endpoints/express.d.ts /** * An Express {@link Router} that may also carry an optional * {@link ChannelsControl} surface. Express's Router is a request-scoped * middleware object, not a long-running process owner — Node * (`createCopilotNodeListener`) is the lifecycle-owning surface for * `.channels`. It is attached here too, best-effort, for callers that mount * the router directly and want to observe/stop managed Channel activation * without also standing up a Node listener. */ type CopilotExpressRouter = Router & { channels?: ChannelsControl; }; interface CopilotExpressEndpointParams { runtime: CopilotRuntimeLike; basePath: string; /** * Endpoint mode. * - `"multi-route"` (default): separate routes for each operation * - `"single-route"`: single POST endpoint with JSON envelope dispatch */ mode?: "multi-route" | "single-route"; /** * CORS configuration for the Express router. * - `true` (default): permissive CORS (`origin: "*"`, all methods, all headers). * - `false`: no CORS middleware is applied — handle it yourself. * - object: passed directly to the Express `cors()` middleware. */ cors?: boolean | CorsOptions; /** * Lifecycle hooks for request processing. */ hooks?: CopilotRuntimeHooks; /** * Whether the underlying handler activates the runtime's declared managed * Channels at creation time. Defaults to `true`. See * `CopilotRuntimeHandlerOptions.activateChannels`. */ activateChannels?: boolean; /** * @internal Test seam: inject a fake Channel activation engine. Forwarded * to `createCopilotRuntimeHandler`. Not part of the public API. */ __channelEngine?: ActivateChannelEngine; } declare function createCopilotExpressHandler({ runtime, basePath, mode, cors: corsOption, hooks, activateChannels, __channelEngine }: CopilotExpressEndpointParams): CopilotExpressRouter; //#endregion export { CopilotExpressEndpointParams, CopilotExpressRouter, createCopilotExpressHandler }; //# sourceMappingURL=express.d.mts.map