import type { RequestMetadata } from '@vscode/copilot-api';
import { HTMLTracer, IChatEndpointInfo, Raw, RenderPromptResult } from '@vscode/prompt-tsx';
import type { Event } from 'vscode';
import { ChatFetchError, ChatLocation, ChatResponses, FetchSuccess } from '../../../platform/chat/common/commonTypes';
import { IResponseDelta, OptionalChatRequestParams } from '../../../platform/networking/common/fetch';
import { IChatEndpoint, IEndpointBody } from '../../../platform/networking/common/networking';
import { ThemeIcon } from '../../../util/vs/base/common/themables';
import { OffsetRange } from '../../../util/vs/editor/common/core/ranges/offsetRange';
import type { LanguageModelToolResult2 } from '../../../vscodeTypes';
import type { IModelAPIResponse } from '../../endpoint/common/endpointProvider';
import { APIUsage } from '../../networking/common/openai';
import { ThinkingData } from '../../thinking/common/thinking';
import { CapturingToken } from '../common/capturingToken';
export type UriData = {
    kind: 'request';
    id: string;
} | {
    kind: 'latest';
};
export declare class ChatRequestScheme {
    static readonly chatRequestScheme = "ccreq";
    static buildUri(data: UriData, format?: 'markdown' | 'json' | 'rawrequest'): string;
    static parseUri(uri: string): {
        data: UriData;
        format: 'markdown' | 'json' | 'rawrequest';
    } | undefined;
    static findAllUris(text: string): {
        uri: string;
        range: OffsetRange;
    }[];
}
export declare const enum LoggedInfoKind {
    Element = 0,
    Request = 1,
    ToolCall = 2
}
export interface ILoggedElementInfo {
    kind: LoggedInfoKind.Element;
    id: string;
    name: string;
    tokens: number;
    maxTokens: number;
    trace: HTMLTracer;
    token: CapturingToken | undefined;
    toJSON(): object;
}
export interface ILoggedRequestInfo {
    kind: LoggedInfoKind.Request;
    id: string;
    entry: LoggedRequest;
    token: CapturingToken | undefined;
    toJSON(): object;
}
export interface ILoggedToolCall {
    kind: LoggedInfoKind.ToolCall;
    id: string;
    name: string;
    args: unknown;
    response: LanguageModelToolResult2;
    token: CapturingToken | undefined;
    time: number;
    thinking?: ThinkingData;
    toolMetadata?: unknown;
    toJSON(): Promise<object>;
}
export interface ILoggedPendingRequest {
    messages: Raw.ChatMessage[];
    ourRequestId: string;
    model: string;
    location: ChatLocation;
    intent?: string;
    postOptions?: OptionalChatRequestParams;
    body?: IEndpointBody;
    ignoreStatefulMarker?: boolean;
    isConversationRequest?: boolean;
    /** Custom metadata to be displayed in the log document */
    customMetadata?: Record<string, string | number | boolean | undefined>;
}
export type LoggedInfo = ILoggedElementInfo | ILoggedRequestInfo | ILoggedToolCall;
export declare const IRequestLogger: import("../../../util/common/services").ServiceIdentifier<IRequestLogger>;
export interface IRequestLogger {
    readonly _serviceBrand: undefined;
    promptRendererTracing: boolean;
    captureInvocation<T>(request: CapturingToken, fn: () => Promise<T>): Promise<T>;
    logToolCall(id: string, name: string, args: unknown, response: LanguageModelToolResult2, thinking?: ThinkingData): void;
    logModelListCall(requestId: string, requestMetadata: RequestMetadata, models: IModelAPIResponse[]): void;
    logContentExclusionRules(repos: string[], rules: {
        patterns: string[];
        ifAnyMatch: string[];
        ifNoneMatch: string[];
    }[], durationMs: number): void;
    logChatRequest(debugName: string, chatEndpoint: IChatEndpointLogInfo, chatParams: ILoggedPendingRequest): PendingLoggedChatRequest;
    addPromptTrace(elementName: string, endpoint: IChatEndpointInfo, result: RenderPromptResult, trace: HTMLTracer): void;
    addEntry(entry: LoggedRequest): void;
    onDidChangeRequests: Event<void>;
    getRequests(): LoggedInfo[];
    getRequestById(id: string): LoggedInfo | undefined;
    enableWorkspaceEditTracing(): void;
    disableWorkspaceEditTracing(): void;
}
export declare const enum LoggedRequestKind {
    ChatMLSuccess = "ChatMLSuccess",
    ChatMLFailure = "ChatMLFailure",
    ChatMLCancelation = "ChatMLCancelation",
    MarkdownContentRequest = "MarkdownContentRequest"
}
export type IChatEndpointLogInfo = Partial<Pick<IChatEndpoint, 'model' | 'modelMaxPromptTokens' | 'urlOrRequestMetadata'>>;
export interface ILoggedChatMLRequest {
    debugName: string;
    chatEndpoint: IChatEndpointLogInfo;
    chatParams: ILoggedPendingRequest;
    startTime: Date;
    endTime: Date;
    isConversationRequest?: boolean;
    /** Custom metadata to be displayed in the log document */
    customMetadata?: Record<string, string | number | boolean | undefined>;
}
export interface ILoggedChatMLSuccessRequest extends ILoggedChatMLRequest {
    type: LoggedRequestKind.ChatMLSuccess;
    timeToFirstToken: number | undefined;
    usage: APIUsage | undefined;
    result: FetchSuccess<string[]>;
    deltas?: IResponseDelta[];
}
export interface ILoggedChatMLFailureRequest extends ILoggedChatMLRequest {
    type: LoggedRequestKind.ChatMLFailure;
    timeToFirstToken: number | undefined;
    result: ChatFetchError;
}
export interface ILoggedChatMLCancelationRequest extends ILoggedChatMLRequest {
    type: LoggedRequestKind.ChatMLCancelation;
}
export interface IMarkdownContentRequest {
    type: LoggedRequestKind.MarkdownContentRequest;
    startTimeMs: number;
    icon: ThemeIcon | undefined | (() => ThemeIcon | undefined);
    debugName: string;
    markdownContent: string | (() => string);
    isConversationRequest?: boolean;
    /**
     * When set, the log tree and virtual document will refresh when this event fires.
     * Used for "live" entries that update over time (e.g. in-progress NES requests).
     */
    onDidChange?: Event<void>;
    /**
     * When set, determines whether this entry should be visible in the log tree.
     * Used for live entries that may become hidden (e.g. skipped/cancelled NES requests).
     */
    isVisible?: () => boolean;
}
export declare function resolveMarkdownContent(entry: IMarkdownContentRequest): string;
export declare function resolveMarkdownIcon(entry: IMarkdownContentRequest): ThemeIcon | undefined;
export type LoggedRequest = (ILoggedChatMLSuccessRequest | ILoggedChatMLFailureRequest | ILoggedChatMLCancelationRequest | IMarkdownContentRequest);
declare class AbstractPendingLoggedRequest {
    protected _logbook: IRequestLogger;
    protected _debugName: string;
    protected _chatEndpoint: IChatEndpointLogInfo;
    protected _chatParams: ILoggedPendingRequest;
    protected _time: Date;
    protected _timeToFirstToken: number | undefined;
    constructor(_logbook: IRequestLogger, _debugName: string, _chatEndpoint: IChatEndpointLogInfo, _chatParams: ILoggedPendingRequest);
    markTimeToFirstToken(timeToFirstToken: number): void;
    resolveWithCancelation(): void;
}
export declare class PendingLoggedChatRequest extends AbstractPendingLoggedRequest {
    constructor(logbook: IRequestLogger, debugName: string, chatEndpoint: IChatEndpoint, chatParams: ILoggedPendingRequest);
    resolve(result: ChatResponses, deltas?: IResponseDelta[]): void;
}
export {};
//# sourceMappingURL=requestLogger.d.ts.map