import { ContentBlock } from '@agentclientprotocol/sdk';
import { NativeGoalState } from './acp-extensions.js';
import { PostHogAPIClient } from './posthog-api.js';
import { GitCheckpointEvent, DeviceInfo } from './types.js';
import { L as Logger } from './logger-RC7sPv0S.js';
import '@posthog/shared';
import '@posthog/shared/domain-types';

/**
 * Resume - Restore agent state from persisted log
 *
 * Handles resuming a task from any point:
 * - Fetches log via the PostHog API
 * - Finds latest git_checkpoint event
 * - Rebuilds conversation from log events
 * - Restores working tree from checkpoint
 *
 * Uses Saga pattern for atomic operations with clear success/failure tracking.
 *
 * The log is the single source of truth for:
 * - Conversation history (user_message, agent_message_chunk, tool_call, tool_result)
 * - Working tree state (git_checkpoint events)
 * - Session metadata (device info, mode changes)
 */

interface ResumeState {
    conversation: ConversationTurn[];
    latestGitCheckpoint: GitCheckpointEvent | null;
    interrupted: boolean;
    lastDevice?: DeviceInfo;
    logEntryCount: number;
    sessionId: string | null;
    nativeGoal?: NativeGoalState | null;
}
interface ConversationTurn {
    role: "user" | "assistant";
    content: ContentBlock[];
    toolCalls?: ToolCallInfo[];
}
interface ToolCallInfo {
    toolCallId: string;
    toolName: string;
    input: unknown;
    result?: unknown;
}
interface ResumeConfig {
    taskId: string;
    runId: string;
    repositoryPath?: string;
    apiClient: PostHogAPIClient;
    logger?: Logger;
}
/**
 * Resume a task from its persisted log.
 * Returns the rebuilt state for the agent to continue from.
 * Checkpoint application happens in the agent server after SSE connects.
 */
declare function resumeFromLog(config: ResumeConfig): Promise<ResumeState>;
/**
 * Convert resumed conversation back to API format for continuation.
 */
declare function conversationToPromptHistory(conversation: ConversationTurn[]): Array<{
    role: "user" | "assistant";
    content: ContentBlock[];
}>;
declare function formatConversationForResume(conversation: ConversationTurn[]): string;

export { type ConversationTurn, type ResumeConfig, type ResumeState, type ToolCallInfo, conversationToPromptHistory, formatConversationForResume, resumeFromLog };
