import { RetryConfig } from '../tools/utils/resilience.js';

/**
 * Types for Morph Git SDK
 */

interface MorphGitConfig {
    apiKey?: string;
    proxyUrl?: string;
    /** Retry configuration for API calls */
    retryConfig?: RetryConfig;
}
interface CloneOptions {
    repoId: string;
    dir: string;
    branch?: string;
    depth?: number;
    singleBranch?: boolean;
}
interface PushOptions {
    dir: string;
    remote?: string;
    branch: string;
    waitForEmbeddings?: boolean;
    /** Generate embeddings for this push. Default: false (opt-in) */
    index?: boolean;
}
interface EmbeddingProgress {
    filesProcessed: number;
    totalFiles: number;
    chunksGenerated: number;
    chunksStored: number;
}
interface WaitForEmbeddingsOptions {
    repoId: string;
    commitHash?: string;
    timeout?: number;
    onProgress?: (progress: EmbeddingProgress) => void;
}
interface PullOptions {
    dir: string;
    remote?: string;
    branch: string;
}
interface AddOptions {
    dir: string;
    filepath: string;
}
interface ChatMessage {
    role: string;
    content: string;
    [key: string]: any;
}
/**
 * Schema for data stored in git notes (refs/notes/morph-metadata).
 * All fields optional. Single source of truth for note structure.
 */
interface MorphNotesSchema {
    /** Arbitrary user-defined key-value metadata (must be valid JSON) */
    metadata?: Record<string, unknown>;
    /** Chat/conversation history that led to this commit */
    chatHistory?: ChatMessage[];
    /** Browser recording session ID for replay */
    recordingId?: string;
    /** Schema version for future migrations */
    _version?: number;
}
/** @deprecated Use MorphNotesSchema instead */
type CommitMetadata = MorphNotesSchema;
interface CommitOptions {
    dir: string;
    message: string;
    author?: {
        name: string | "Morph AI Agent";
        email: string | "ai@morphllm.com";
    };
    /** Arbitrary user-defined key-value metadata (must be valid JSON) */
    metadata?: Record<string, unknown>;
    /** Chat/conversation history that led to this commit */
    chatHistory?: ChatMessage[];
    /** Browser recording session ID for replay */
    recordingId?: string;
}
interface StatusOptions {
    dir: string;
    filepath?: string;
}
interface LogOptions {
    dir: string;
    depth?: number;
    ref?: string;
}
interface CheckoutOptions {
    dir: string;
    ref: string;
}
interface BranchOptions {
    dir: string;
    name: string;
    checkout?: boolean;
}
interface DiffOptions {
    dir: string;
    ref1?: string;
    ref2?: string;
    filepath?: string;
}
interface GitUser {
    name: string;
    email: string;
}
interface CommitObject {
    oid: string;
    commit: {
        message: string;
        author: {
            name: string | "Morph AI Agent";
            email: string | "ai@morphllm.com";
            timestamp: number;
        };
        committer: {
            name: string | "Morph AI Agent";
            email: string | "ai@morphllm.com";
            timestamp: number;
        };
    };
}
interface StatusResult {
    filepath: string;
    status: 'unmodified' | 'modified' | '*modified' | 'added' | '*added' | 'deleted' | '*deleted' | 'absent';
}

export type { AddOptions, BranchOptions, ChatMessage, CheckoutOptions, CloneOptions, CommitMetadata, CommitObject, CommitOptions, DiffOptions, EmbeddingProgress, GitUser, LogOptions, MorphGitConfig, MorphNotesSchema, PullOptions, PushOptions, StatusOptions, StatusResult, WaitForEmbeddingsOptions };
