import { MorphGitConfig, CloneOptions, PushOptions, PullOptions, WaitForEmbeddingsOptions, AddOptions, CommitOptions, StatusOptions, LogOptions, CommitObject, CheckoutOptions, BranchOptions, StatusResult, MorphNotesSchema } from './types.js';
import 'isomorphic-git';
import 'isomorphic-git/http/node';
import '../tools/utils/resilience.js';

/**
 * Morph Git Client - Simple, high-level Git operations
 * Built on isomorphic-git with explicit configuration
 */

/**
 * MorphGit - Git operations for AI agents with Morph backend
 *
 * @example
 * ```typescript
 * import { MorphGit } from 'morphsdk/git';
 *
 * const morphGit = new MorphGit({
 *   apiKey: process.env.MORPH_API_KEY!,
 *   proxyUrl: 'https://repos.morphllm.com' // Optional
 * });
 *
 * await morphGit.init({ repoId: 'my-project', dir: './my-project' });
 * await morphGit.push({ dir: './my-project' });
 * ```
 */
declare class MorphGit {
    private readonly apiKey;
    private readonly proxyUrl;
    constructor(config: MorphGitConfig);
    /**
     * Get auth callback for isomorphic-git operations
     * @private
     */
    private getAuthCallback;
    /**
     * Initialize a new repository
     * Creates the repo in the database and in the git provider
     *
     * @example
     * ```ts
     * await morphGit.init({
     *   repoId: 'my-project',
     *   dir: './my-project',
     *   defaultBranch: 'main'
     * });
     * ```
     */
    init(options: {
        repoId: string;
        dir: string;
        defaultBranch?: string;
    }): Promise<void>;
    /**
     * Clone a repository from Morph repos
     *
     * @example
     * ```ts
     * await morphGit.clone({
     *   repoId: 'my-project',
     *   dir: './my-project'
     * });
     * ```
     */
    clone(options: CloneOptions): Promise<void>;
    /**
     * Push changes to remote repository
     *
     * @example
     * ```ts
     * await morphGit.push({
     *   dir: './my-project',
     *   branch: 'main', // Required: explicit branch name
     *   index: true     // Optional: generate embeddings for semantic search
     * });
     * ```
     */
    push(options: PushOptions): Promise<void>;
    /**
     * Configure commit settings on the backend after push.
     * Sets the index flag to control embedding generation.
     * @private
     */
    private configureCommit;
    /**
     * Pull changes from remote repository
     *
     * @example
     * ```ts
     * await morphGit.pull({
     *   dir: './my-project',
     *   branch: 'main' // Required: explicit branch name
     * });
     * ```
     */
    pull(options: PullOptions): Promise<void>;
    /**
     * Wait for embeddings to complete after push.
     * Polls status endpoint until embeddings are done.
     *
     * @example
     * ```ts
     * await morphGit.push({ dir: './my-project', branch: 'main' });
     * await morphGit.waitForEmbeddings({
     *   repoId: 'my-project',
     *   onProgress: (p) => console.log(`${p.filesProcessed}/${p.totalFiles}`)
     * });
     * ```
     */
    waitForEmbeddings(options: WaitForEmbeddingsOptions): Promise<void>;
    /**
     * Stage a file for commit
     *
     * @example
     * ```ts
     * await morphGit.add({
     *   dir: './my-project',
     *   filepath: 'src/app.ts'
     * });
     * ```
     */
    add(options: AddOptions): Promise<void>;
    /**
     * Remove a file from staging
     *
     * @example
     * ```ts
     * await morphGit.remove({
     *   dir: './my-project',
     *   filepath: 'src/old-file.ts'
     * });
     * ```
     */
    remove(options: AddOptions): Promise<void>;
    /**
     * Commit staged changes
     *
     * @example
     * ```ts
     * await morphGit.commit({
     *   dir: './my-project',
     *   message: 'Add new feature',
     *   author: {
     *     name: 'AI Agent',
     *     email: 'ai@example.com'
     *   },
     *   metadata: { issueId: 'PROJ-123', source: 'agent' },
     *   chatHistory: [
     *     { role: 'user', content: 'Please add a new feature' },
     *     { role: 'assistant', content: 'I will add that feature' }
     *   ],
     *   recordingId: 'rec_123'
     * });
     * ```
     */
    commit(options: CommitOptions): Promise<string>;
    /**
     * Get status of a file
     *
     * @example
     * ```ts
     * const status = await morphGit.status({
     *   dir: './my-project',
     *   filepath: 'src/app.ts'
     * });
     * console.log(status); // 'modified', '*added', etc.
     * ```
     */
    status(options: StatusOptions): Promise<string>;
    /**
     * Get commit history
     *
     * @example
     * ```ts
     * const commits = await morphGit.log({
     *   dir: './my-project',
     *   depth: 10
     * });
     * ```
     */
    log(options: LogOptions): Promise<CommitObject[]>;
    /**
     * Checkout a branch or commit
     *
     * @example
     * ```ts
     * await morphGit.checkout({
     *   dir: './my-project',
     *   ref: 'feature-branch'
     * });
     * ```
     */
    checkout(options: CheckoutOptions): Promise<void>;
    /**
     * Create a new branch
     *
     * @example
     * ```ts
     * await morphGit.branch({
     *   dir: './my-project',
     *   name: 'feature-branch',
     *   checkout: true
     * });
     * ```
     */
    branch(options: BranchOptions): Promise<void>;
    /**
     * List all branches
     *
     * @example
     * ```ts
     * const branches = await morphGit.listBranches({
     *   dir: './my-project'
     * });
     * ```
     */
    listBranches(options: {
        dir: string;
    }): Promise<string[]>;
    /**
     * Get the current branch name
     *
     * @example
     * ```ts
     * const branch = await morphGit.currentBranch({
     *   dir: './my-project'
     * });
     * ```
     */
    currentBranch(options: {
        dir: string;
    }): Promise<string | undefined>;
    /**
     * Get list of changed files (similar to git diff --name-only)
     *
     * @example
     * ```ts
     * const changes = await morphGit.statusMatrix({
     *   dir: './my-project'
     * });
     * ```
     */
    statusMatrix(options: {
        dir: string;
    }): Promise<StatusResult[]>;
    /**
     * Get the current commit hash
     *
     * @example
     * ```ts
     * const hash = await morphGit.resolveRef({
     *   dir: './my-project',
     *   ref: 'HEAD'
     * });
     * ```
     */
    resolveRef(options: {
        dir: string;
        ref: string;
    }): Promise<string>;
    /**
     * Get notes (metadata, chat history, recording ID) attached to a commit
     *
     * @example
     * ```ts
     * const notes = await morphGit.getCommitMetadata({
     *   dir: './my-project',
     *   commitSha: 'abc123...'
     * });
     *
     * if (notes) {
     *   console.log('Metadata:', notes.metadata);
     *   console.log('Chat history:', notes.chatHistory);
     *   console.log('Recording ID:', notes.recordingId);
     * }
     * ```
     */
    getCommitMetadata(options: {
        dir: string;
        commitSha: string;
    }): Promise<MorphNotesSchema | null>;
}

export { MorphGit };
