import { IChatRuntime, ChatRuntimeOptions } from './runtime.js';
import { W as WritableResponse, I as IChatTransport } from '../transport-Ciap4PWK.js';
import { I as IProviderStore, P as ProviderConfig } from '../provider-types-PTSlRPNB.js';
import { I as ITokenStore } from '../token-store-CSUBgYwn.js';
export { F as FileTokenStore, a as FileTokenStoreOptions, b as InMemoryTokenStore } from '../token-store-CSUBgYwn.js';
import { M as ModelInfo } from '../agent-CW9XbmG_.js';
import { C as CopilotAuthToken, b as ClaudeAuthToken, A as AuthToken } from '../types-BxggH0Yh.js';
import { b as TokenRefreshOptions, a as TokenRefreshManager } from '../refresh-manager-Dlv_iNZi.js';
import '../types-ajANVzf7.js';
import '../errors-C-so0M4t.js';
import './sessions.js';
import './storage.js';
import '../errors-CmVvczxZ.js';
import 'zod';
import './context.js';

/**
 * Provider storage default implementations.
 *
 * Types (ProviderConfig, IProviderStore) are defined in ../provider-types.ts
 * and re-exported here for backward compatibility.
 */

/** In-memory provider store for testing and ephemeral use */
declare class InMemoryProviderStore implements IProviderStore {
    private readonly providers;
    create(config: ProviderConfig): Promise<void>;
    get(id: string): Promise<ProviderConfig | null>;
    update(id: string, changes: Partial<Omit<ProviderConfig, "id" | "createdAt">>): Promise<void>;
    delete(id: string): Promise<void>;
    list(): Promise<ProviderConfig[]>;
}
/** Options for FileProviderStore */
interface FileProviderStoreOptions {
    /** Directory to store provider JSON files */
    directory: string;
}
/** Filesystem-based provider store using JSON files (one per provider) */
declare class FileProviderStore implements IProviderStore {
    private readonly dir;
    constructor(options: FileProviderStoreOptions);
    create(config: ProviderConfig): Promise<void>;
    get(id: string): Promise<ProviderConfig | null>;
    update(id: string, changes: Partial<Omit<ProviderConfig, "id" | "createdAt">>): Promise<void>;
    delete(id: string): Promise<void>;
    list(): Promise<ProviderConfig[]>;
    private filePath;
}

/**
 * Shared types for route modules.
 */

/**
 * Handler state — intentionally empty after stateless refactor (STAT-01).
 * Preserved as a type for backward compatibility with custom route modules.
 * Model resolution is now fully per-request via resolveRequestContext.
 * @deprecated Will be removed in next major version.
 */
interface HandlerState {
    /** @deprecated Model is now resolved per-request. This field is never set. */
    currentModel?: string | undefined;
}
/**
 * Shared context passed to every route module.
 */
interface RouteContext {
    readonly runtime: IChatRuntime;
    readonly maxBodySize: number;
    readonly heartbeatMs?: number;
    readonly hooks?: ChatServerHooks;
    readonly providerStore?: IProviderStore;
    readonly tokenStore?: ITokenStore;
    readonly transportFactory?: TransportFactory;
    readonly state: HandlerState;
}
/**
 * A route module handler.
 * Returns `true` if the request was handled, `false` to try next module.
 */
type RouteHandler = (method: string, path: string, req: ReadableRequest, res: WritableResponse, ctx: RouteContext) => Promise<boolean>;

/**
 * createChatHandler — maps RemoteChatClient contract endpoints to IChatRuntime calls.
 *
 * Routes are delegated to composable route modules in ./routes/.
 * This file is a thin router (~90 lines) that assembles modules and handles errors.
 */

/** Minimal readable request interface (node:http IncomingMessage subset) */
interface ReadableRequest {
    readonly method?: string;
    readonly url?: string;
    on(event: "data", listener: (chunk: Buffer | string) => void): unknown;
    on(event: "end", listener: () => void): unknown;
}

/**
 * Server-side hooks for customizing chat handler behavior.
 * Consolidates filter, guard, and lifecycle callbacks into a single interface.
 */
interface ChatServerHooks {
    /** Filter the model list before returning to client. */
    filterModels?(models: ModelInfo[]): ModelInfo[];
    /** Validate model selection on /model/switch and /send model override. Throw to reject. */
    onModelSwitch?(model: string): void | Promise<void>;
    /** Called before provider switch. Receives providerId and resolved backend name. Throw to reject. */
    onProviderSwitch?(info: {
        providerId: string;
        backend: string;
    }): void | Promise<void>;
    /** Called before backend switch. Throw to reject. */
    onBackendSwitch?(backend: string): void | Promise<void>;
    /** Called before sending a message. Throw to reject. */
    onBeforeSend?(sessionId: string, message: string): void | Promise<void>;
    /** Global error handler for unhandled route errors. */
    onError?(error: Error, context: {
        route: string;
        method: string;
    }): void;
}
/**
 * Factory for creating a chat transport for a /send request.
 * Return an IChatTransport instance that will receive the event stream.
 * Default: SSEChatTransport.
 */
type TransportFactory = (req: ReadableRequest, res: WritableResponse) => IChatTransport;
/** Configuration for createChatHandler */
interface ChatHandlerOptions {
    /** Route prefix to strip from URL before matching. Default: "" (no prefix) */
    prefix?: string;
    /** Maximum request body size in bytes. Default: 1MB (1048576) */
    maxBodySize?: number;
    /** SSE heartbeat interval in milliseconds. 0 or undefined disables heartbeat. */
    heartbeatMs?: number;
    /** Optional provider store for provider CRUD routes. */
    providerStore?: IProviderStore;
    /** Optional token store for resolveRequestContext in /send. */
    tokenStore?: ITokenStore;
    /** Consolidated server hooks. */
    hooks?: ChatServerHooks;
    /** Custom transport factory for /send endpoint. Default: SSEChatTransport. */
    transportFactory?: TransportFactory;
}
/**
 * Create an HTTP request handler that maps RemoteChatClient contract
 * endpoints to IChatRuntime method calls.
 *
 * Routes are handled by composable route modules (sessions, messages, config, providers).
 * Model state is managed in a shared HandlerState object.
 */
declare function createChatHandler(runtime: IChatRuntime, options?: ChatHandlerOptions): (req: ReadableRequest, res: WritableResponse) => Promise<void>;

/**
 * createAuthHandler — server-mediated authentication for all three backends.
 *
 * Routes:
 * - POST /auth/start            → Start auth flow (copilot device flow, claude OAuth, vercel-ai passthrough)
 * - POST /auth/copilot/poll     → Poll for Copilot device flow completion
 * - POST /auth/claude/complete  → Exchange Claude OAuth code for token
 * - POST /auth/vercel/complete  → Submit Vercel AI API key
 * - GET  /tokens/saved          → List providers with saved tokens
 * - POST /tokens/use            → Load and activate a saved token
 * - POST /tokens/clear          → Clear all saved tokens and invoke onLogout
 * - POST /auth/dispose          → Clear pending flows and invoke onLogout
 */

/** Auth provider names recognized by the handler */
type AuthProvider = "copilot" | "claude" | "vercel-ai";
/** Copilot auth class interface (matches CopilotAuth public API) */
interface ICopilotAuth {
    startDeviceFlow(options?: {
        scopes?: string;
        signal?: AbortSignal;
    }): Promise<{
        userCode: string;
        verificationUrl: string;
        waitForToken: (signal?: AbortSignal) => Promise<CopilotAuthToken>;
    }>;
}
/** Claude auth class interface (matches ClaudeAuth public API) */
interface IClaudeAuth {
    startOAuthFlow(options?: {
        redirectUri?: string;
        scopes?: string;
    }): {
        authorizeUrl: string;
        completeAuth: (codeOrUrl: string) => Promise<ClaudeAuthToken>;
    };
}
/** Callback invoked after successful authentication */
type OnAuthCallback = (provider: AuthProvider, token: AuthToken) => void | Promise<void>;
/** Configuration for createAuthHandler */
interface AuthHandlerOptions {
    /** Token storage implementation */
    tokenStore: ITokenStore;
    /** Factory for creating CopilotAuth instances */
    createCopilotAuth?: () => ICopilotAuth;
    /** Factory for creating ClaudeAuth instances */
    createClaudeAuth?: () => IClaudeAuth;
    /** Called after successful authentication for any provider */
    onAuth?: OnAuthCallback;
    /** Called when dispose/logout is requested */
    onLogout?: () => void | Promise<void>;
    /** Route prefix to strip from URL before matching. Default: "" */
    prefix?: string;
    /** Maximum request body size in bytes. Default: 1MB */
    maxBodySize?: number;
}
/**
 * Create an HTTP request handler for server-mediated authentication.
 *
 * @param options - Auth handler configuration (token store, auth factories, callbacks)
 * @returns Async request handler `(req, res) => Promise<void>`
 *
 * @example
 * ```ts
 * import { CopilotAuth, ClaudeAuth } from "@witqq/agent-sdk/auth";
 *
 * const authHandler = createAuthHandler({
 *   tokenStore: new FileTokenStore({ directory: ".tokens" }),
 *   createCopilotAuth: () => new CopilotAuth(),
 *   createClaudeAuth: () => new ClaudeAuth(),
 *   onAuth: (provider, token) => {
 *     // Rebuild runtime with new credentials
 *   },
 * });
 * ```
 */
declare function createAuthHandler(options: AuthHandlerOptions): (req: ReadableRequest, res: WritableResponse) => Promise<void>;

/**
 * createProviderHandler — CRUD handler for provider configurations.
 *
 * Routes (prefix already stripped by chat-server):
 * - GET    /providers           → List all providers
 * - GET    /providers/{id}      → Get single provider
 * - POST   /providers           → Create provider
 * - PUT    /providers/{id}      → Update provider
 * - DELETE /providers/{id}      → Delete provider
 */

/** Configuration for createProviderHandler */
interface ProviderHandlerOptions {
    /** Provider storage implementation */
    providerStore: IProviderStore;
}
/**
 * Create an HTTP request handler for provider CRUD operations.
 *
 * @param options - Provider handler configuration
 * @returns Async request handler `(req, res) => Promise<void>`
 */
declare function createProviderHandler(options: ProviderHandlerOptions): (req: ReadableRequest, res: WritableResponse) => Promise<void>;

/**
 * CORS middleware — standalone composable function.
 * Returns true if it fully handled the request (OPTIONS preflight),
 * false if the caller should continue processing.
 */
/** Configuration for CORS middleware */
interface CorsOptions {
    /** Allowed origins. Default: "*" (any origin) */
    origin?: string | string[];
    /** Allowed HTTP methods. Default: common REST methods */
    methods?: string[];
    /** Allowed request headers. Default: ["Content-Type"] */
    headers?: string[];
    /** Max age for preflight cache in seconds. Default: 86400 (24h) */
    maxAge?: number;
}
/** Minimal request interface for CORS */
interface CorsRequest {
    readonly method?: string;
    readonly headers?: Record<string, string | string[] | undefined>;
}
/** Minimal response interface for CORS */
interface CorsResponse {
    setHeader(name: string, value: string): void;
    writeHead(statusCode: number, headers?: Record<string, string>): unknown;
    end(): void;
}
/**
 * Create a CORS middleware function.
 *
 * @returns A function that sets CORS headers and handles OPTIONS preflight.
 *          Returns `true` if the request was fully handled (preflight),
 *          `false` if the caller should continue processing.
 */
declare function corsMiddleware(options?: CorsOptions): (req: CorsRequest, res: CorsResponse) => boolean;

/**
 * ServiceManager — manages IAgentService lifecycle (create, cache, dispose).
 *
 * Reduces boilerplate in apps that need to create/dispose services on auth events.
 * Pass to createChatServer to auto-wire onAuth/onLogout callbacks.
 *
 * @example
 * ```ts
 * const sm = new ServiceManager({
 *   createService: (backend, token) =>
 *     createAgentService(backend, { apiKey: token.accessToken }),
 * });
 *
 * // Manual usage:
 * await sm.handleAuth("copilot", token);
 * const service = sm.getService("copilot");
 *
 * // Or auto-wired via createChatServer:
 * createChatServer({ serviceManager: sm, auth: { tokenStore }, ... });
 * ```
 */

/** Minimal IAgentService interface (avoids importing from main package) */
interface ManagedService {
    dispose(): Promise<void> | void;
}
/** Callback for building a token refresh function per backend */
type RefreshFactory = (backend: string) => ((token: AuthToken) => Promise<AuthToken>) | undefined;
/** Configuration for ServiceManager */
interface ServiceManagerOptions {
    /**
     * Factory to create a service for a backend.
     * Called on every auth event (old service is disposed first).
     */
    createService: (backend: string, token: AuthToken) => ManagedService | Promise<ManagedService>;
    /**
     * Optional factory returning a refresh function per backend.
     * If provided and the token has expiresIn, a TokenRefreshManager is started.
     * On refresh → the stored token is updated and the service is recreated.
     * On expiry → handleLogout() for that backend is called.
     */
    refreshFactory?: RefreshFactory;
    /** Override TokenRefreshManager options (threshold, retries, etc.) */
    refreshOptions?: Partial<Pick<TokenRefreshOptions, "refreshThreshold" | "maxRetries" | "retryDelayMs">>;
    /** Called when a token expires (before logout). */
    onTokenExpired?: (backend: string) => void;
}
/**
 * Manages IAgentService lifecycle: create, cache, and dispose on re-auth or logout.
 * Optionally starts background token refresh when `refreshFactory` is configured.
 */
declare class ServiceManager {
    private readonly _services;
    private readonly _refreshManagers;
    private readonly _options;
    constructor(options: ServiceManagerOptions);
    /**
     * Handle auth event: dispose old service (if any) and create new one.
     * If the token is refreshable and refreshFactory is configured, starts a
     * TokenRefreshManager that auto-refreshes and recreates the service.
     */
    handleAuth(backend: string, token: AuthToken): Promise<ManagedService>;
    /**
     * Handle logout: dispose all services, stop all refresh managers, clear cache.
     */
    handleLogout(): Promise<void>;
    /**
     * Dispose the ServiceManager — stops all refresh managers and disposes all services.
     */
    dispose(): Promise<void>;
    /** Get cached service for a backend (undefined if not authenticated). */
    getService(backend: string): ManagedService | undefined;
    /** Check if a service exists for the given backend. */
    hasService(backend: string): boolean;
    /** Get all backend names with active services. */
    get activeBackends(): string[];
    /** Get active refresh manager for a backend (for testing/introspection). */
    getRefreshManager(backend: string): TokenRefreshManager | undefined;
    private _startRefreshManager;
    private _stopRefreshManager;
    private _recreateService;
    private _logoutBackend;
}

/**
 * createChatServer — one-call setup combining runtime, chat handler, auth handler, CORS,
 * and static file serving into a single HTTP request handler.
 *
 * Routes:
 * - CORS preflight (OPTIONS) on all paths
 * - {chatPrefix}/*   → createChatHandler routes
 * - {authPrefix}/*   → createAuthHandler routes (if tokenStore provided)
 * - {staticPrefix}/* → static file serving (if staticDir provided)
 * - Everything else  → 404
 */

/**
 * Configuration for auto-creating a ChatRuntime from options.
 * Alternative to providing a pre-built IChatRuntime instance.
 * Uses the same shape as ChatRuntimeOptions from the runtime module.
 */
type ChatRuntimeConfig = ChatRuntimeOptions;
/** Configuration for createChatServer */
interface ChatServerOptions {
    /** Pre-built runtime instance. Either `runtime` or `runtimeConfig` must be provided. */
    runtime?: IChatRuntime;
    /** Config to auto-create a runtime. Used when `runtime` is not provided. */
    runtimeConfig?: ChatRuntimeConfig;
    /** Server-side hooks for customizing handler behavior. */
    hooks?: ChatServerHooks;
    /** Prefix for chat API routes. Default: "/api/chat" */
    chatPrefix?: string;
    /** Auth handler options. If provided, auth routes are mounted. */
    auth?: AuthHandlerOptions;
    /** Prefix for auth routes. Default: "/api/auth" */
    authPrefix?: string;
    /** CORS options. Pass false to disable CORS. Default: enabled with permissive settings */
    cors?: CorsOptions | false;
    /** Directory to serve static files from. Omit to disable static serving. */
    staticDir?: string;
    /** Prefix for static file routes. Default: "/" */
    staticPrefix?: string;
    /** Provider handler options. If provided, provider routes are mounted. */
    providers?: ProviderHandlerOptions;
    /** Prefix for provider routes. Default: "/api/providers" */
    providerPrefix?: string;
    /** Chat handler options (maxBodySize, etc.) */
    chatHandlerOptions?: Omit<ChatHandlerOptions, "prefix">;
    /**
     * Path for the health check endpoint. Default: "/api/health".
     * Set to `false` to disable. Returns `{ ok: true }`.
     */
    healthPath?: string | false;
    /**
     * Auto-create a default provider when a backend authenticates for the first time.
     *
     * - `true` — uses built-in default models per backend
     * - `Record<string, string>` — custom backend→model mapping (e.g. `{ copilot: "gpt-5-mini" }`)
     * - `false` / omitted — disabled
     *
     * Requires both `auth` and `providers` to be configured.
     */
    autoCreateProviders?: boolean | Record<string, string>;
    /**
     * Service lifecycle manager. When provided with `auth`, automatically wires:
     * - `onAuth` → `serviceManager.handleAuth(backend, token)` (creates/caches service)
     * - `onLogout` → `serviceManager.handleLogout()` (disposes all services)
     *
     * User's own `onAuth`/`onLogout` callbacks in `auth` are still called first.
     */
    serviceManager?: ServiceManager;
}
/** Default model per backend for auto-created providers */
declare const DEFAULT_PROVIDER_MODELS: Record<string, string>;
/** Request handler type returned by createChatServer */
type RequestHandler = (req: ReadableRequest, res: WritableResponse) => Promise<void>;
/**
 * Create a combined HTTP request handler that routes to chat, auth, static, or 404.
 *
 * @param options - Server configuration
 * @returns Async request handler
 *
 * @example
 * ```ts
 * import http from "node:http";
 * import { createChatServer } from "@witqq/agent-sdk/chat/server";
 *
 * const handler = createChatServer({
 *   runtime,
 *   auth: { tokenStore },
 *   staticDir: "./public",
 * });
 *
 * http.createServer(handler).listen(3000);
 * ```
 */
declare function createChatServer(options: ChatServerOptions): RequestHandler;

/**
 * Shared server utilities — readBody and JSON response helpers.
 */

/** Error thrown by readBody with an HTTP status code */
declare class BodyParseError extends Error {
    readonly statusCode: number;
    constructor(message: string, statusCode: number);
}
/**
 * Read and parse JSON request body with size limit.
 * Throws BodyParseError on oversized, malformed, or errored requests.
 */
declare function readBody(req: ReadableRequest, maxSize?: number): Promise<Record<string, unknown>>;
/** Send a JSON response with given status code. */
declare function json(res: WritableResponse, data: unknown, status?: number): void;

/**
 * AdapterPool — lazy adapter creation with concurrent dedup and eviction.
 *
 * Replaces the pattern where ServiceManager + backend factories create adapters
 * eagerly on auth. AdapterPool creates adapters on first use, keyed by backend name.
 *
 * Key properties:
 * - Lazy: adapters created on first getAdapter() call
 * - Concurrent dedup: multiple concurrent getAdapter() calls for same backend share one creation
 * - Never cache failures: if factory throws, next call retries
 * - Eviction: evict(backend) disposes cached adapter (e.g. on token rotation)
 *
 * @example
 * ```ts
 * const pool = new AdapterPool({
 *   factory: async (backend) => {
 *     const token = await tokenStore.load(backend);
 *     const service = createAgentService(backend, { apiKey: token.accessToken });
 *     return new VercelAIChatAdapter({ agentConfig: { ... }, agentService: service });
 *   },
 * });
 *
 * const adapter = await pool.getAdapter("vercel-ai");
 * // On token rotation:
 * await pool.evict("vercel-ai");
 * ```
 */
/** Minimal adapter interface (avoids importing full IChatBackend) */
interface PooledAdapter {
    dispose(): Promise<void> | void;
}
/** Factory function to create an adapter for a given backend */
type AdapterFactory<T extends PooledAdapter = PooledAdapter> = (backend: string) => Promise<T>;
/** Configuration for AdapterPool */
interface AdapterPoolOptions<T extends PooledAdapter = PooledAdapter> {
    /** Factory to create an adapter for a backend. Called lazily on first getAdapter(). */
    factory: AdapterFactory<T>;
}
/**
 * Lazy adapter pool with concurrent dedup and eviction.
 * Thread-safe: concurrent getAdapter() calls for the same backend share a single creation promise.
 */
declare class AdapterPool<T extends PooledAdapter = PooledAdapter> {
    private readonly _cached;
    private readonly _pending;
    private readonly _factory;
    private _disposed;
    constructor(options: AdapterPoolOptions<T>);
    /**
     * Get or create an adapter for the given backend.
     * Concurrent calls for the same backend share one creation promise.
     * Failed creations are NOT cached — next call retries.
     */
    getAdapter(backend: string): Promise<T>;
    /**
     * Evict (dispose and remove) the cached adapter for a backend.
     * Use after token rotation to force re-creation on next getAdapter().
     */
    evict(backend: string): Promise<void>;
    /** Check if a backend has a cached adapter. */
    has(backend: string): boolean;
    /** Get all backend names with cached adapters. */
    get activeBackends(): string[];
    /** Dispose all cached adapters and mark pool as unusable. */
    dispose(): Promise<void>;
    private _create;
}

/**
 * Request context resolution — per-request credential + model lookup.
 *
 * Resolves a providerId into a RequestContext containing backend name,
 * credentials (AuthToken), and model identifier. This enables stateless
 * request handling where each request carries its own context.
 *
 * @example
 * ```ts
 * const ctx = await resolveRequestContext("my-copilot-provider", {
 *   providerStore,
 *   tokenStore,
 * });
 * // ctx = { backend: "copilot", credentials: { accessToken: "..." }, model: "gpt-5-mini" }
 * ```
 */

/** Per-request context carrying backend, credentials, and model */
interface RequestContext {
    /** Backend name (e.g. "copilot", "claude", "vercel-ai") */
    backend: string;
    /** Resolved authentication token */
    credentials: AuthToken;
    /** Model identifier from provider config */
    model: string;
    /** Original provider config for reference */
    provider: ProviderConfig;
}
/** Dependencies for context resolution */
interface RequestContextDeps {
    /** Provider store to look up provider config */
    providerStore: IProviderStore;
    /** Token store to load credentials for the backend */
    tokenStore: ITokenStore;
}
/**
 * Resolve a providerId into a full RequestContext.
 *
 * Flow: providerId → ProviderConfig (from providerStore) → AuthToken (from tokenStore) → RequestContext
 *
 * @throws ChatError with PROVIDER_NOT_FOUND if provider doesn't exist
 * @throws ChatError with AUTH_REQUIRED if no token found for the provider's backend
 */
declare function resolveRequestContext(providerId: string, deps: RequestContextDeps): Promise<RequestContext>;

/**
 * Session CRUD route handlers.
 *
 * Routes:
 * - POST   /sessions/create              → Create session
 * - GET    /sessions/:id                 → Get session
 * - GET    /sessions                     → List sessions
 * - DELETE /sessions/:id                 → Delete session
 * - GET    /sessions/:id/context-stats   → Get context window stats
 */

declare const sessionRoutes: RouteHandler;

/**
 * Message route handlers (send + abort).
 *
 * Routes:
 * - POST /send   → Stream response via transport (SSE by default)
 * - POST /abort  → Cancel in-flight stream
 */

declare const messageRoutes: RouteHandler;

/**
 * Configuration route handlers (model/backend/provider switching, listing).
 *
 * Routes:
 * - GET  /models          → List available models
 * - GET  /backends        → List available backends
 * - POST /model/switch    → Switch active model (handler state)
 * - POST /provider/switch → Switch provider (resolves backend + model)
 */

declare const configRoutes: RouteHandler;

/**
 * Provider CRUD route handlers.
 *
 * Routes:
 * - GET    /providers      → List all providers
 * - GET    /providers/:id  → Get single provider
 * - POST   /providers      → Create provider
 * - PUT    /providers/:id  → Update provider
 * - DELETE /providers/:id  → Delete provider
 */

declare const providerRoutes: RouteHandler;

export { type AdapterFactory, AdapterPool, type AdapterPoolOptions, type AuthHandlerOptions, type AuthProvider, BodyParseError, type ChatHandlerOptions, type ChatRuntimeConfig, type ChatServerHooks, type ChatServerOptions, type CorsOptions, DEFAULT_PROVIDER_MODELS, FileProviderStore, type FileProviderStoreOptions, type HandlerState, type IClaudeAuth, type ICopilotAuth, IProviderStore, ITokenStore, InMemoryProviderStore, type ManagedService, type OnAuthCallback, type PooledAdapter, ProviderConfig, type ProviderHandlerOptions, type ReadableRequest, type RefreshFactory, type RequestContext, type RequestContextDeps, type RequestHandler, type RouteContext, type RouteHandler, ServiceManager, type ServiceManagerOptions, type TransportFactory, WritableResponse, configRoutes, corsMiddleware, createAuthHandler, createChatHandler, createChatServer, createProviderHandler, json, messageRoutes, providerRoutes, readBody, resolveRequestContext, sessionRoutes };
