import { AgentSideConnection } from '@agentclientprotocol/sdk';
import { PostHogAPIClient } from './posthog-api.js';
import { AgentConfig, TaskExecutionOptions } from './types.js';

type StreamPair = {
    readable: globalThis.ReadableStream<Uint8Array>;
    writable: globalThis.WritableStream<Uint8Array>;
};

type AcpConnection = {
    agentConnection?: AgentSideConnection;
    clientStreams: StreamPair;
    cleanup: () => Promise<void>;
};
type InProcessAcpConnection = AcpConnection;

declare class Agent {
    private posthogAPI?;
    private logger;
    private acpConnection?;
    private taskRunId?;
    private sessionLogWriter?;
    constructor(config: AgentConfig);
    private _configureLlmGateway;
    run(taskId: string, taskRunId: string, options?: TaskExecutionOptions): Promise<InProcessAcpConnection>;
    attachPullRequestToTask(taskId: string, prUrl: string, branchName?: string): Promise<void>;
    getPosthogAPI(): PostHogAPIClient | undefined;
    flushAllLogs(): Promise<void>;
    cleanup(): Promise<void>;
}

export { Agent };
