import { PostHogAPIConfig, Task, TaskRun, StoredEntry, ArtifactType, TaskRunArtifact } from './types.js';

type GatewayProduct = "posthog_code" | "background_agents";
declare function getLlmGatewayUrl(posthogHost: string, product?: GatewayProduct): string;

interface TaskArtifactUploadPayload {
    name: string;
    type: ArtifactType;
    content: string;
    content_type?: string;
}
type TaskRunUpdate = Partial<Pick<TaskRun, "status" | "branch" | "stage" | "error_message" | "output" | "state" | "environment">>;
declare class PostHogAPIClient {
    private config;
    constructor(config: PostHogAPIConfig);
    private get baseUrl();
    private get headers();
    private apiRequest;
    private getTeamId;
    getApiKey(): string;
    getLlmGatewayUrl(): string;
    getTask(taskId: string): Promise<Task>;
    getTaskRun(taskId: string, runId: string): Promise<TaskRun>;
    updateTaskRun(taskId: string, runId: string, payload: TaskRunUpdate): Promise<TaskRun>;
    appendTaskRunLog(taskId: string, runId: string, entries: StoredEntry[]): Promise<TaskRun>;
    relayMessage(taskId: string, runId: string, text: string): Promise<void>;
    uploadTaskArtifacts(taskId: string, runId: string, artifacts: TaskArtifactUploadPayload[]): Promise<TaskRunArtifact[]>;
    getArtifactPresignedUrl(taskId: string, runId: string, storagePath: string): Promise<string | null>;
    /**
     * Download artifact content by storage path
     * Gets a presigned URL and fetches the content
     */
    downloadArtifact(taskId: string, runId: string, storagePath: string): Promise<ArrayBuffer | null>;
    /**
     * Fetch logs for a task run via the logs API endpoint
     * @param taskRun - The task run to fetch logs for
     * @returns Array of stored entries, or empty array if no logs available
     */
    fetchTaskRunLogs(taskRun: TaskRun): Promise<StoredEntry[]>;
}

export { PostHogAPIClient, type TaskArtifactUploadPayload, type TaskRunUpdate, getLlmGatewayUrl };
