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

73 lines (72 loc) 2.58 kB
import "reflect-metadata"; import { CopilotRuntimeLike } from "../core/runtime.mjs"; import { CopilotCorsConfig } from "../core/fetch-cors.mjs"; import { CopilotRuntimeHooks } from "../core/hooks.mjs"; import * as hono_types0 from "hono/types"; import * as hono_utils_http_status0 from "hono/utils/http-status"; import * as hono_hono_base0 from "hono/hono-base"; //#region src/v2/runtime/endpoints/hono.d.ts /** * CORS configuration for CopilotKit endpoints. * When using credentials (e.g., HTTP-only cookies), you must specify an explicit origin. */ interface CopilotEndpointCorsConfig { /** * Allowed origin(s) for CORS. Can be: * - A string: exact origin (e.g., "https://myapp.com") * - An array: list of allowed origins * - A function: dynamic origin resolution * * Note: When credentials is true, origin cannot be "*" */ origin: string | string[] | ((origin: string, c: any) => string | undefined | null); /** * Whether to allow credentials (cookies, HTTP authentication). * When true, origin must be explicitly specified (not "*"). */ credentials?: boolean; } interface CopilotEndpointParams { 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"; /** * Optional CORS configuration. When not provided, defaults to allowing all origins without credentials. * To support HTTP-only cookies, provide cors config with credentials: true and explicit origin. */ cors?: CopilotEndpointCorsConfig; /** * Lifecycle hooks for request processing. */ hooks?: CopilotRuntimeHooks; } /** @deprecated Use `createCopilotHonoHandler` instead. */ declare const createCopilotEndpoint: typeof createCopilotHonoHandler; declare function createCopilotHonoHandler({ runtime, basePath, mode, cors: corsConfig, hooks }: CopilotEndpointParams): hono_hono_base0.HonoBase<hono_types0.BlankEnv, { [x: `${string}/*`]: { $all: { input: {}; output: {}; outputFormat: string; status: hono_utils_http_status0.StatusCode; }; }; }, string, `${string}/*`>; /** * Convert Hono-specific CORS config to the fetch handler's CopilotCorsConfig. */ declare function toFetchCorsConfig(config: CopilotEndpointCorsConfig): CopilotCorsConfig; //#endregion export { CopilotEndpointCorsConfig, createCopilotEndpoint, createCopilotHonoHandler, toFetchCorsConfig }; //# sourceMappingURL=hono.d.mts.map