// Cloudflare D1 Database type declaration declare global { interface D1Database { prepare(query: string): D1PreparedStatement; dump(): Promise; batch(statements: D1PreparedStatement[]): Promise[]>; exec(query: string): Promise; } interface D1PreparedStatement { bind(...values: any[]): D1PreparedStatement; first(colName?: string): Promise; run(): Promise>; all(): Promise>; raw(): Promise; } interface D1Result { results: T[]; success: boolean; meta: { served_by?: string; duration?: number; changes?: number; last_row_id?: number; changed_db?: boolean; size_after?: number; rows_read?: number; rows_written?: number; }; error?: string; } interface D1ExecResult { count: number; duration: number; } } export interface ILlmHandler { execute(isStream: boolean, options: IPromptOptions): Promise; getConfig(generalConfig: IPromptGenericConfig): any; } export interface IPromptOptions { messages?: IConvMessage[]; systemPrompt?: string; config: IPromptGenericConfig; apiKeys?: Record; useBlackout?: boolean; useShield?: boolean; meta?: Record; } export interface IPromptGenericConfig { provider: string; model: string; temperature?: number; maxTokens?: number; topP?: number; frequencyPenalty?: number; presencePenalty?: number; stream?: boolean; plain?: boolean; stopSequences?: string[]; user?: string; } export interface IConvMessage { role: 'system' | 'user' | 'assistant'; content: string; name?: string; type?: IConvMessageType; files?: IFile[]; } export enum IConvMessageType { text = 0, image = 1, audio = 2, video = 3, } export interface IFile { url: string; type?: string; name?: string; } export interface ModuleOptions { apiKeys?: Record; baseUrl?: string; cloudflareAccountId?: string; } export interface Env { // Cloudflare Worker environment bindings OPENAI_API_KEY?: string; CLAUDE_API_KEY?: string; GOOGLE_AI_API_KEY?: string; GROQ_API_KEY?: string; OPENROUTER_API_KEY?: string; COHERE_API_KEY?: string; AI21_API_KEY?: string; XAI_API_KEY?: string; DEEPSEEK_API_KEY?: string; MISTRAL_API_KEY?: string; CLOUDFLARE_API_KEY?: string; CLOUDFLARE_ACCOUNT_ID?: string; STABILITY_AI_API_KEY?: string; FALAI_API_KEY?: string; FIREBASE_AUTH?: string; PINECONE_API_KEY?: string; QDRANT_API_KEY?: string; GCP_MAPS_API_KEY?: string; // API Key Management ASK_DB?: D1Database; API_KEY_ENCRYPTION_KEY?: string; } export interface ModelCapabilities { imageInput?: boolean; imageGen?: boolean; reasoning?: boolean; noSystem?: boolean; noTopPWithTemp?: boolean; audio?: boolean; video?: boolean; }