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

47 lines (46 loc) 1.83 kB
import "reflect-metadata"; import { ChannelsControl } from "../core/channel-manager.mjs"; import { CopilotRuntimeHandlerOptions } from "../core/fetch-handler.mjs"; import { NodeFetchHandler } from "./node-fetch-handler.mjs"; //#region src/v2/runtime/endpoints/node.d.ts /** * A Node.js HTTP request listener that is also a callable object carrying an * optional {@link ChannelsControl} surface, mirroring * `CopilotRuntimeFetchHandler.channels`. Node is the long-running, * lifecycle-owning entry point for the runtime, so it is the surface that * exposes `.channels` for callers that need to observe or stop managed * Channel activation. */ type NodeCopilotListener = NodeFetchHandler & { channels?: ChannelsControl; }; /** * Convenience wrapper for creating a Node.js HTTP request listener * from CopilotKit runtime handler options. * * When the runtime declares managed Channels (and activation was not opted * out of via `activateChannels: false`), the returned listener exposes * `.channels` — the same {@link ChannelsControl} surface the underlying * fetch handler activates at creation time. * * @example * ```typescript * import { createServer } from "node:http"; * import { CopilotRuntime } from "@copilotkit/runtime/v2"; * import { createCopilotNodeListener } from "@copilotkit/runtime/v2/node"; * * const listener = createCopilotNodeListener({ * runtime: new CopilotRuntime({ agents: { ... } }), * basePath: "/api/copilotkit", * cors: true, * }); * createServer(listener).listen(3000); * * // Optional: observe/stop managed Channel activation. * await listener.channels?.ready(); * ``` */ declare function createCopilotNodeListener(options: CopilotRuntimeHandlerOptions): NodeCopilotListener; //#endregion export { createCopilotNodeListener }; //# sourceMappingURL=node.d.mts.map