@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;" />
83 lines (81 loc) • 3.36 kB
text/typescript
import { CopilotServiceAdapter } from "../../service-adapters/service-adapter.cjs";
import "../../service-adapters/index.cjs";
import { LogLevel } from "../logger.cjs";
import { CopilotRuntime } from "../runtime/copilot-runtime.cjs";
import { CopilotCloudOptions } from "../cloud/index.cjs";
import * as pino from "pino";
import * as graphql from "graphql";
//#region src/v1-deprecated/lib/integrations/shared.d.ts
/**
* CORS configuration for CopilotKit endpoints.
*/
interface CopilotEndpointCorsConfig {
/**
* Allowed origin(s). Can be a string, array of strings, or a function that returns the origin.
*/
origin: string | string[] | ((origin: string, c: any) => string | undefined | null);
/**
* Whether to include credentials (cookies, authorization headers) in CORS requests.
* When true, origin cannot be "*" - must be an explicit origin.
*/
credentials?: boolean;
}
declare const logger: pino.Logger<never, boolean>;
type AnyPrimitive = string | boolean | number | null;
type CopilotRequestContextProperties = Record<string, AnyPrimitive | Record<string, AnyPrimitive>>;
/**
* The request-scoped fields the v1 middleware hooks read off the GraphQL
* context.
*
* Declared here rather than imported as Yoga's `YogaInitialContext`. Nothing in
* this package serves GraphQL any more -- every v1 integration entry point
* delegates to the v2 Hono endpoint -- but that one type reference was enough to
* pull the whole `graphql-yoga` barrel, and with it `lru-cache@10`, into every
* consumer's program. `lru-cache@10` declares `implements Map`, which costs five
* TS2416 errors under `strict` with `skipLibCheck: false` (OSS-899).
*
* Structurally identical to `YogaInitialContext`, so a real Yoga context still
* satisfies it.
*/
interface GraphQLRequestContext {
/** GraphQL parameters parsed from the request. */
params: {
operationName?: string;
query?: string;
variables?: Record<string, any>;
extensions?: Record<string, any>;
};
/** The incoming HTTP request. */
request: Request;
/** Defers work past the response, where the host runtime supports it. */
waitUntil(promise: Promise<unknown> | void): void;
}
type GraphQLContext = GraphQLRequestContext & {
_copilotkit: CreateCopilotRuntimeServerOptions;
properties: CopilotRequestContextProperties;
logger: typeof logger;
};
interface CreateCopilotRuntimeServerOptions {
runtime: CopilotRuntime<any>;
serviceAdapter?: CopilotServiceAdapter;
endpoint: string;
baseUrl?: string;
cloud?: CopilotCloudOptions;
properties?: CopilotRequestContextProperties;
logLevel?: LogLevel;
/**
* 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;
}
declare function buildSchema(options?: {
emitSchemaFile?: string;
}): graphql.GraphQLSchema;
type CommonConfig = {
logging: typeof logger;
};
declare function getCommonConfig(options: CreateCopilotRuntimeServerOptions): CommonConfig;
//#endregion
export { CommonConfig, CopilotEndpointCorsConfig, CopilotRequestContextProperties, CreateCopilotRuntimeServerOptions, GraphQLContext, GraphQLRequestContext, buildSchema, getCommonConfig };
//# sourceMappingURL=shared.d.cts.map