/**
 * @fileoverview Cloudflare Worker entry point factory. `createWorkerHandler()`
 * returns a standard Workers export object (`{ fetch, scheduled }`) that handles
 * env injection, binding storage, singleton init caching, per-request server
 * creation (GHSA-345p-7cg4-v4c7), and error responses.
 *
 * Note: OpenTelemetry `NodeSDK` is unavailable in Workers (`canUseNodeSDK()`
 * returns false), so no telemetry flush is needed. If a Worker-compatible OTEL
 * exporter is added in the future, `ctx.waitUntil()` should be wired for flush.
 * @module src/core/worker
 */
import type { Ai, D1Database, KVNamespace, R2Bucket, ScheduledController } from '@cloudflare/workers-types';
import { type CreateAppOptions } from '../core/app.js';
/**
 * Cloudflare Worker Bindings with proper type safety.
 * No index signature — servers extend via intersection types.
 */
export interface CloudflareBindings {
    AI?: Ai;
    /**
     * DataCanvas provider type. Surfaced here so an explicit
     * `CANVAS_PROVIDER_TYPE=duckdb` set in `wrangler.toml` triggers the
     * factory's fail-closed path (DuckDB has no V8-isolate build) instead
     * of silently no-opping.
     */
    CANVAS_PROVIDER_TYPE?: string;
    DB?: D1Database;
    ENVIRONMENT?: string;
    KV_NAMESPACE?: KVNamespace;
    LOG_LEVEL?: string;
    MCP_ALLOWED_ORIGINS?: string;
    MCP_AUTH_MODE?: string;
    MCP_AUTH_SECRET_KEY?: string;
    MCP_PUBLIC_URL?: string;
    OAUTH_AUDIENCE?: string;
    OAUTH_ISSUER_URL?: string;
    OAUTH_JWKS_URI?: string;
    OPENROUTER_API_KEY?: string;
    OTEL_ENABLED?: string;
    OTEL_EXPORTER_OTLP_METRICS_ENDPOINT?: string;
    OTEL_EXPORTER_OTLP_TRACES_ENDPOINT?: string;
    R2_BUCKET?: R2Bucket;
    SPEECH_STT_API_KEY?: string;
    SPEECH_STT_ENABLED?: string;
    SPEECH_TTS_API_KEY?: string;
    SPEECH_TTS_ENABLED?: string;
    STORAGE_PROVIDER_TYPE?: string;
    SUPABASE_ANON_KEY?: string;
    SUPABASE_SERVICE_ROLE_KEY?: string;
    SUPABASE_URL?: string;
}
/**
 * Options for {@link createWorkerHandler}.
 *
 * Worker-specific override on `instructions`: accepts a `(env)` resolver so
 * deployment env injected at request time can shape the orientation text
 * without eager top-level env reads. The resolver is invoked during
 * single-flight init the first time `fetch` is called, after binding
 * injection. A plain string is also accepted (same semantics as `createApp`).
 */
export interface WorkerHandlerOptions extends Omit<CreateAppOptions, 'instructions'> {
    /** Extra string CF bindings to inject into process.env (beyond the core set). */
    extraEnvBindings?: Array<[string, string]>;
    /** Extra object CF bindings (KV, R2, D1, etc.) to store on globalThis. */
    extraObjectBindings?: Array<[string, string]>;
    /**
     * Server-level orientation text — see {@link CreateAppOptions.instructions}.
     * Accepts a resolver function so env-derived instructions can be built from
     * `env` at the first request rather than at module load (env isn't
     * available until then in Workers).
     */
    instructions?: string | ((env: CloudflareBindings) => string);
    /** Handler for scheduled/cron events. Called after app init and binding refresh. */
    onScheduled?: (controller: ScheduledController, env: CloudflareBindings, ctx: ExecutionContext) => Promise<void>;
}
/**
 * Returns a standard Cloudflare Workers export object (`{ fetch, scheduled }`).
 * Handles env injection, binding storage, singleton init caching, per-request
 * server creation, and error responses.
 */
export declare function createWorkerHandler(options?: WorkerHandlerOptions): {
    fetch(request: Request, env: CloudflareBindings, ctx: ExecutionContext): Promise<Response>;
    scheduled(controller: ScheduledController, env: CloudflareBindings, ctx: ExecutionContext): Promise<void>;
};
//# sourceMappingURL=worker.d.ts.map