import { AgentMode } from '../types.js';
import { RemoteMcpServer } from './schemas.js';
import '@posthog/git/handoff';
import 'zod/v4';

interface ClaudeCodeConfig {
    systemPrompt?: string | {
        type: "preset";
        preset: "claude_code";
        append?: string;
    };
    plugins?: {
        type: "local";
        path: string;
    }[];
}
interface AgentServerConfig {
    port: number;
    repositoryPath?: string;
    apiUrl: string;
    apiKey: string;
    projectId: number;
    jwtPublicKey: string;
    eventIngestToken?: string;
    eventIngestStreamWindowMs?: number;
    mode: AgentMode;
    taskId: string;
    runId: string;
    createPr?: boolean;
    version?: string;
    mcpServers?: RemoteMcpServer[];
    baseBranch?: string;
    claudeCode?: ClaudeCodeConfig;
    allowedDomains?: string[];
    runtimeAdapter?: "claude" | "codex";
    model?: string;
    reasoningEffort?: "low" | "medium" | "high" | "xhigh" | "max";
}

declare const UPSTREAM_PROVIDER_FAILURE_MESSAGE = "The upstream AI provider failed to process the request. Please retry the task in a few minutes.";
declare const SSE_KEEPALIVE_INTERVAL_MS = 25000;
declare class AgentServer {
    private config;
    private logger;
    private server;
    private session;
    private app;
    private posthogAPI;
    private eventStreamSender;
    private questionRelayedToSlack;
    private detectedPrUrl;
    private lastReportedBranch;
    private resumeState;
    private initializationPromise;
    private pendingEvents;
    private pendingPermissions;
    private detachSseController;
    private emitConsoleLog;
    constructor(config: AgentServerConfig);
    private getRuntimeAdapter;
    private getEffectiveMode;
    private getSessionPermissionMode;
    private shouldRelayPermissionToClient;
    private createApp;
    start(): Promise<void>;
    private loadResumeState;
    stop(): Promise<void>;
    private authenticateRequest;
    private executeCommand;
    private initializeSession;
    private _doInitializeSession;
    private extractErrorClassification;
    private classifyAndSignalFailure;
    private sendInitialTaskMessage;
    private sendResumeMessage;
    private getInitialPromptOverride;
    private getPendingUserPrompt;
    private getClearedPendingUserState;
    private clearPendingInitialPromptState;
    private buildPromptFromContentAndArtifacts;
    private getArtifactsById;
    private hydrateArtifactsToPrompt;
    private hydrateArtifactToPromptBlock;
    private getSafeArtifactName;
    private autoInitializeSession;
    private getResumeRunId;
    private buildSessionSystemPrompt;
    private buildCodexInstructions;
    private getCloudInteractionOrigin;
    /**
     * Automated-origin cloud runs auto-publish by default. Every other origin is
     * review-first unless the user explicitly asks, and createPr=false always
     * disables publishing.
     */
    private shouldAutoPublishCloudChanges;
    private buildDetectedPrContext;
    private buildCloudSystemPrompt;
    private getCurrentGitBranch;
    private syncCloudBranchMetadata;
    private signalTaskComplete;
    private enqueueTaskTerminalEvent;
    private configureEnvironment;
    private buildSlackQuestionRelayResponse;
    private shouldBlockPublishPermission;
    private createCloudClient;
    private relayAgentResponse;
    private relaySlackQuestion;
    private getFirstQuestionMeta;
    private isQuestionMeta;
    private detectAndAttachPrUrl;
    private cleanupSession;
    private captureCheckpointState;
    private extractHandoffLocalGitState;
    private broadcastTurnComplete;
    private broadcastEvent;
    private replayPendingEvents;
    private sendSseEvent;
    /**
     * Relay a permission request (e.g., plan approval) to the connected desktop
     * app via SSE and wait for a response via the `/command` endpoint.
     *
     * The promise waits indefinitely — if SSE is disconnected, the event is
     * buffered by broadcastEvent and replayed when the client reconnects. Session
     * cleanup force-resolves all pending permissions, so there is no leak.
     */
    private relayPermissionToClient;
    private resolvePermission;
}

export { AgentServer, SSE_KEEPALIVE_INTERVAL_MS, UPSTREAM_PROVIDER_FAILURE_MESSAGE };
