/**
 * Cursor Executor
 * Handles HTTP/2 requests to Cursor API with protobuf encoding/decoding
 */
/// <reference types="bun-types" />
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
import type { IncomingHttpHeaders } from 'http';
import { type CursorTool, type CursorApiCredentials } from './cursor-protobuf-schema.js';
/** Executor parameters */
interface ExecutorParams {
    model: string;
    body: {
        messages: Array<{
            role: string;
            content: string | Array<{
                type: string;
                text?: string;
            }>;
            name?: string;
            tool_call_id?: string;
            tool_calls?: Array<{
                id: string;
                type: string;
                function: {
                    name: string;
                    arguments: string;
                };
            }>;
        }>;
        tools?: CursorTool[];
        reasoning_effort?: string;
    };
    stream: boolean;
    credentials: CursorApiCredentials;
    signal?: AbortSignal;
}
/** HTTP/2 response structure */
interface Http2Response {
    status: number;
    headers: IncomingHttpHeaders;
    body: Buffer;
}
export declare class CursorExecutor {
    private readonly baseUrl;
    private readonly chatPath;
    buildUrl(): string;
    /**
     * Generate checksum using Jyh cipher (time-based XOR with rolling key seed=165)
     */
    generateChecksum(machineId: string): string;
    buildHeaders(credentials: CursorApiCredentials): Record<string, string>;
    transformRequest(model: string, body: ExecutorParams['body'], stream: boolean, credentials: CursorApiCredentials): Uint8Array;
    makeFetchRequest(url: string, headers: Record<string, string>, body: Uint8Array, signal?: AbortSignal): Promise<Http2Response>;
    makeHttp2Request(url: string, headers: Record<string, string>, body: Uint8Array, signal?: AbortSignal): Promise<Http2Response>;
    execute(params: ExecutorParams): Promise<{
        response: Response;
        url: string;
        headers: Record<string, string>;
        transformedBody: ExecutorParams['body'];
    }>;
    /**
     * Execute a streaming request, piping HTTP/2 data events through
     * StreamingFrameParser for incremental SSE output.
     * Falls back to buffered transformProtobufToSSE when http2 is unavailable.
     */
    private executeStreaming;
    /**
     * Parse protobuf buffer into frames and extract text/toolcalls.
     * Shared logic between JSON and SSE transformers.
     */
    private parseProtobufFrames;
    transformProtobufToJSON(buffer: Buffer, model: string, _body: ExecutorParams['body']): Response;
    /** @deprecated Use executeStreaming() for real-time SSE. Retained for fetch fallback. */
    transformProtobufToSSE(buffer: Buffer, model: string, _body: ExecutorParams['body']): Response;
}
export default CursorExecutor;
//# sourceMappingURL=cursor-executor.d.ts.map