import { EventEmitter } from 'events'; type ApiRequestOptions = { readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH'; readonly url: string; readonly path?: Record; readonly cookies?: Record; readonly headers?: Record; readonly query?: Record; readonly formData?: Record; readonly body?: any; readonly mediaType?: string; readonly responseHeader?: string; readonly errors?: Record; }; declare class CancelError extends Error { constructor(message: string); get isCancelled(): boolean; } interface OnCancel { readonly isResolved: boolean; readonly isRejected: boolean; readonly isCancelled: boolean; (cancelHandler: () => void): void; } declare class CancelablePromise implements Promise { #private; constructor(executor: (resolve: (value: T | PromiseLike) => void, reject: (reason?: any) => void, onCancel: OnCancel) => void); get [Symbol.toStringTag](): string; then(onFulfilled?: ((value: T) => TResult1 | PromiseLike) | null, onRejected?: ((reason: any) => TResult2 | PromiseLike) | null): Promise; catch(onRejected?: ((reason: any) => TResult | PromiseLike) | null): Promise; finally(onFinally?: (() => void) | null): Promise; cancel(): void; get isCancelled(): boolean; } type Choice = { index: number; text: string; }; type CompletionResponse$1 = { id: string; choices: Array; }; type LogEventRequest$1 = { /** * Event type, should be `view` or `select`. */ type: string; completion_id: string; choice_index: number; }; type ApiResult = { readonly url: string; readonly ok: boolean; readonly status: number; readonly statusText: string; readonly body: any; }; declare class ApiError extends Error { readonly url: string; readonly status: number; readonly statusText: string; readonly body: any; readonly request: ApiRequestOptions; constructor(request: ApiRequestOptions, response: ApiResult, message: string); } type AgentConfig = { server?: { endpoint?: string; }; logs?: { level?: "debug" | "error" | "silent"; }; anonymousUsageTracking?: { disable?: boolean; }; }; type AgentInitOptions = { config?: AgentConfig; client?: string; }; type CompletionRequest = { filepath: string; language: string; text: string; position: number; }; type CompletionResponse = CompletionResponse$1; type LogEventRequest = LogEventRequest$1; interface AgentFunction { initialize(options?: AgentInitOptions): boolean; updateConfig(config: AgentConfig): boolean; getConfig(): AgentConfig; getStatus(): "connecting" | "ready" | "disconnected"; getCompletions(request: CompletionRequest): CancelablePromise; postEvent(event: LogEventRequest): CancelablePromise; } type StatusChangedEvent = { event: "statusChanged"; status: "connecting" | "ready" | "disconnected"; }; type ConfigUpdatedEvent = { event: "configUpdated"; config: AgentConfig; }; type AgentEvent = StatusChangedEvent | ConfigUpdatedEvent; declare const agentEventNames: AgentEvent["event"][]; interface AgentEventEmitter { on(eventName: T["event"], callback: (event: T) => void): this; } type Agent = AgentFunction & AgentEventEmitter; declare class TabbyAgent extends EventEmitter implements Agent { private readonly logger; private config; private status; private api; private completionCache; constructor(); private onConfigUpdated; private changeStatus; private ping; private callApi; private createSegments; initialize(params: AgentInitOptions): boolean; updateConfig(config: AgentConfig): boolean; getConfig(): AgentConfig; getStatus(): "connecting" | "ready" | "disconnected"; getCompletions(request: CompletionRequest): CancelablePromise; postEvent(request: LogEventRequest): CancelablePromise; } export { Agent, AgentConfig, AgentEvent, AgentFunction, ApiError, CancelError, CancelablePromise, Choice, CompletionRequest, CompletionResponse, StatusChangedEvent, TabbyAgent, agentEventNames };