import type { StorageScorerConfig } from '@mastra/core/storage';
export declare const DEFAULT_MAX_VERSIONS_PER_AGENT = 50;
/**
 * Generates a unique ID for a version using crypto.randomUUID()
 */
export declare function generateVersionId(): string;
/**
 * Compares two agent snapshots and returns an array of field names that changed.
 * Performs deep comparison for nested objects.
 */
export declare function calculateChangedFields(previous: Record<string, unknown> | null | undefined, current: Record<string, unknown>): string[];
/**
 * Enforces version retention limit by deleting oldest versions that exceed the maximum.
 * Never deletes the active version.
 *
 * @param agentsStore - The agents storage domain
 * @param agentId - The agent ID to enforce retention for
 * @param activeVersionId - The active version ID (will never be deleted)
 * @param maxVersions - Maximum number of versions to keep (default: 50)
 */
export declare function enforceRetentionLimit(agentsStore: {
    listVersions: (params: {
        agentId: string;
        page?: number;
        perPage?: number | false;
        orderBy?: {
            field?: 'versionNumber' | 'createdAt';
            direction?: 'ASC' | 'DESC';
        };
    }) => Promise<{
        versions: Array<{
            id: string;
            versionNumber: number;
        }>;
        total: number;
    }>;
    deleteVersion: (id: string) => Promise<void>;
}, agentId: string, activeVersionId: string | undefined | null, maxVersions?: number): Promise<{
    deletedCount: number;
}>;
/**
 * Type for the agents store with version-related methods.
 * Uses generic types to work with any StorageAgentType-compatible structure.
 *
 * AgentVersion config fields are top-level (no nested snapshot object).
 * getLatestVersion returns the version with config fields top-level.
 */
export interface AgentsStoreWithVersions<TAgent = any> {
    getLatestVersion: (agentId: string) => Promise<{
        id: string;
        versionNumber: number;
        name: string;
        description?: string;
        instructions: string;
        model: Record<string, unknown>;
        tools?: string[];
        defaultOptions?: Record<string, unknown>;
        workflows?: string[];
        agents?: string[];
        integrationTools?: string[];
        inputProcessors?: Record<string, unknown>[];
        outputProcessors?: Record<string, unknown>[];
        memory?: Record<string, unknown>;
        scorers?: Record<string, StorageScorerConfig>;
        [key: string]: any;
    } | null>;
    createVersion: (params: {
        id: string;
        agentId: string;
        versionNumber: number;
        name: string;
        description?: string;
        instructions: string;
        model: Record<string, unknown>;
        tools?: string[];
        defaultOptions?: Record<string, unknown>;
        workflows?: string[];
        agents?: string[];
        integrationTools?: string[];
        inputProcessors?: Record<string, unknown>[];
        outputProcessors?: Record<string, unknown>[];
        memory?: Record<string, unknown>;
        scorers?: Record<string, StorageScorerConfig>;
        changedFields?: string[];
        changeMessage?: string;
    }) => Promise<{
        id: string;
        versionNumber: number;
    }>;
    updateAgent: (params: {
        id: string;
        activeVersionId?: string;
        [key: string]: any;
    }) => Promise<TAgent>;
    listVersions: (params: {
        agentId: string;
        page?: number;
        perPage?: number | false;
        orderBy?: {
            field?: 'versionNumber' | 'createdAt';
            direction?: 'ASC' | 'DESC';
        };
    }) => Promise<{
        versions: Array<{
            id: string;
            versionNumber: number;
        }>;
        total: number;
    }>;
    deleteVersion: (id: string) => Promise<void>;
}
/**
 * Creates a new version with retry logic for race condition handling.
 * If a unique constraint violation occurs on versionNumber, retries with a fresh versionNumber.
 *
 * Config fields are passed top-level (not nested in a snapshot object).
 *
 * @param agentsStore - The agents storage domain
 * @param agentId - The agent ID to create a version for
 * @param snapshotConfig - The agent configuration fields (StorageAgentSnapshotType)
 * @param changedFields - Array of field names that changed
 * @param options - Optional settings for the version
 * @param options.changeMessage - Optional description of the changes
 * @param options.maxRetries - Maximum number of retry attempts (default: 3)
 * @returns The created version ID and version number
 */
export declare function createVersionWithRetry<TAgent>(agentsStore: AgentsStoreWithVersions<TAgent>, agentId: string, snapshotConfig: Record<string, unknown>, changedFields: string[], options?: {
    changeMessage?: string;
    maxRetries?: number;
}): Promise<{
    versionId: string;
    versionNumber: number;
}>;
/**
 * Handles auto-versioning after an agent update.
 * Creates a new version with retry logic, then updates the agent's activeVersionId,
 * and finally enforces the retention limit. These are separate operations - if updateAgent
 * fails after version creation, a created-but-not-activated version may remain.
 *
 * @param agentsStore - The agents storage domain
 * @param agentId - The agent ID
 * @param existingAgent - The agent state before the update (thin record)
 * @param updatedAgent - The agent state after the update (thin record)
 * @param configFields - The config fields that were provided in the update (StorageAgentSnapshotType fields)
 * @returns The updated agent with the new activeVersionId, or the original if no changes
 */
export declare function handleAutoVersioning<TAgent>(agentsStore: AgentsStoreWithVersions<TAgent>, agentId: string, existingAgent: TAgent, updatedAgent: TAgent, configFields?: Record<string, unknown>): Promise<{
    agent: TAgent;
    versionCreated: boolean;
}>;
/**
 * GET /stored/agents/:agentId/versions - List all versions for an agent
 */
export declare const LIST_AGENT_VERSIONS_ROUTE: import("../server-adapter").ServerRoute<import("../server-adapter").InferParams<import("zod").ZodObject<{
    agentId: import("zod").ZodString;
}, "strip", import("zod").ZodTypeAny, {
    agentId: string;
}, {
    agentId: string;
}>, import("zod").ZodObject<{
    perPage: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodNumber>>;
    page: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodNumber>>;
} & {
    orderBy: import("zod").ZodOptional<import("zod").ZodObject<{
        field: import("zod").ZodOptional<import("zod").ZodEnum<["versionNumber", "createdAt"]>>;
        direction: import("zod").ZodOptional<import("zod").ZodEnum<["ASC", "DESC"]>>;
    }, "strip", import("zod").ZodTypeAny, {
        field?: "createdAt" | "versionNumber" | undefined;
        direction?: "ASC" | "DESC" | undefined;
    }, {
        field?: "createdAt" | "versionNumber" | undefined;
        direction?: "ASC" | "DESC" | undefined;
    }>>;
}, "strip", import("zod").ZodTypeAny, {
    page: number;
    perPage: number;
    orderBy?: {
        field?: "createdAt" | "versionNumber" | undefined;
        direction?: "ASC" | "DESC" | undefined;
    } | undefined;
}, {
    page?: number | undefined;
    perPage?: number | undefined;
    orderBy?: {
        field?: "createdAt" | "versionNumber" | undefined;
        direction?: "ASC" | "DESC" | undefined;
    } | undefined;
}> | import("zod").ZodObject<{
    perPage: import("zod").ZodOptional<import("zod").ZodNumber>;
    page: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodNumber>>;
} & {
    orderBy: import("zod").ZodOptional<import("zod").ZodObject<{
        field: import("zod").ZodOptional<import("zod").ZodEnum<["versionNumber", "createdAt"]>>;
        direction: import("zod").ZodOptional<import("zod").ZodEnum<["ASC", "DESC"]>>;
    }, "strip", import("zod").ZodTypeAny, {
        field?: "createdAt" | "versionNumber" | undefined;
        direction?: "ASC" | "DESC" | undefined;
    }, {
        field?: "createdAt" | "versionNumber" | undefined;
        direction?: "ASC" | "DESC" | undefined;
    }>>;
}, "strip", import("zod").ZodTypeAny, {
    page: number;
    perPage?: number | undefined;
    orderBy?: {
        field?: "createdAt" | "versionNumber" | undefined;
        direction?: "ASC" | "DESC" | undefined;
    } | undefined;
}, {
    page?: number | undefined;
    perPage?: number | undefined;
    orderBy?: {
        field?: "createdAt" | "versionNumber" | undefined;
        direction?: "ASC" | "DESC" | undefined;
    } | undefined;
}>, undefined>, {
    total: number;
    page: number;
    perPage: number | false;
    hasMore: boolean;
    versions: {
        name: string;
        id: string;
        createdAt: Date;
        agentId: string;
        model: Record<string, unknown>;
        instructions: string;
        versionNumber: number;
        description?: string | undefined;
        tools?: string[] | undefined;
        agents?: string[] | undefined;
        workflows?: string[] | undefined;
        inputProcessors?: Record<string, unknown>[] | undefined;
        outputProcessors?: Record<string, unknown>[] | undefined;
        defaultOptions?: Record<string, unknown> | undefined;
        memory?: Record<string, unknown> | undefined;
        scorers?: Record<string, {
            sampling?: {
                type: "count" | "ratio";
                count?: number | undefined;
                rate?: number | undefined;
            } | undefined;
        }> | undefined;
        integrationTools?: string[] | undefined;
        changeMessage?: string | undefined;
        changedFields?: string[] | undefined;
    }[];
}, "json">;
/**
 * POST /stored/agents/:agentId/versions - Create a new version snapshot
 */
export declare const CREATE_AGENT_VERSION_ROUTE: import("../server-adapter").ServerRoute<import("../server-adapter").InferParams<import("zod").ZodObject<{
    agentId: import("zod").ZodString;
}, "strip", import("zod").ZodTypeAny, {
    agentId: string;
}, {
    agentId: string;
}>, undefined, import("zod").ZodObject<{
    changeMessage: import("zod").ZodOptional<import("zod").ZodString>;
}, "strip", import("zod").ZodTypeAny, {
    changeMessage?: string | undefined;
}, {
    changeMessage?: string | undefined;
}>>, {
    name: string;
    id: string;
    createdAt: Date;
    agentId: string;
    model: Record<string, unknown>;
    instructions: string;
    versionNumber: number;
    description?: string | undefined;
    tools?: string[] | undefined;
    agents?: string[] | undefined;
    workflows?: string[] | undefined;
    inputProcessors?: Record<string, unknown>[] | undefined;
    outputProcessors?: Record<string, unknown>[] | undefined;
    defaultOptions?: Record<string, unknown> | undefined;
    memory?: Record<string, unknown> | undefined;
    scorers?: Record<string, {
        sampling?: {
            type: "count" | "ratio";
            count?: number | undefined;
            rate?: number | undefined;
        } | undefined;
    }> | undefined;
    integrationTools?: string[] | undefined;
    changeMessage?: string | undefined;
    changedFields?: string[] | undefined;
}, "json">;
/**
 * GET /stored/agents/:agentId/versions/:versionId - Get a specific version
 */
export declare const GET_AGENT_VERSION_ROUTE: import("../server-adapter").ServerRoute<{
    agentId: string;
    versionId: string;
}, {
    name: string;
    id: string;
    createdAt: Date;
    agentId: string;
    model: Record<string, unknown>;
    instructions: string;
    versionNumber: number;
    description?: string | undefined;
    tools?: string[] | undefined;
    agents?: string[] | undefined;
    workflows?: string[] | undefined;
    inputProcessors?: Record<string, unknown>[] | undefined;
    outputProcessors?: Record<string, unknown>[] | undefined;
    defaultOptions?: Record<string, unknown> | undefined;
    memory?: Record<string, unknown> | undefined;
    scorers?: Record<string, {
        sampling?: {
            type: "count" | "ratio";
            count?: number | undefined;
            rate?: number | undefined;
        } | undefined;
    }> | undefined;
    integrationTools?: string[] | undefined;
    changeMessage?: string | undefined;
    changedFields?: string[] | undefined;
}, "json">;
/**
 * POST /stored/agents/:agentId/versions/:versionId/activate - Set a version as active
 */
export declare const ACTIVATE_AGENT_VERSION_ROUTE: import("../server-adapter").ServerRoute<{
    agentId: string;
    versionId: string;
}, {
    message: string;
    success: boolean;
    activeVersionId: string;
}, "json">;
/**
 * POST /stored/agents/:agentId/versions/:versionId/restore - Restore agent to a version
 */
export declare const RESTORE_AGENT_VERSION_ROUTE: import("../server-adapter").ServerRoute<{
    agentId: string;
    versionId: string;
}, {
    name: string;
    id: string;
    createdAt: Date;
    agentId: string;
    model: Record<string, unknown>;
    instructions: string;
    versionNumber: number;
    description?: string | undefined;
    tools?: string[] | undefined;
    agents?: string[] | undefined;
    workflows?: string[] | undefined;
    inputProcessors?: Record<string, unknown>[] | undefined;
    outputProcessors?: Record<string, unknown>[] | undefined;
    defaultOptions?: Record<string, unknown> | undefined;
    memory?: Record<string, unknown> | undefined;
    scorers?: Record<string, {
        sampling?: {
            type: "count" | "ratio";
            count?: number | undefined;
            rate?: number | undefined;
        } | undefined;
    }> | undefined;
    integrationTools?: string[] | undefined;
    changeMessage?: string | undefined;
    changedFields?: string[] | undefined;
}, "json">;
/**
 * DELETE /stored/agents/:agentId/versions/:versionId - Delete a version
 */
export declare const DELETE_AGENT_VERSION_ROUTE: import("../server-adapter").ServerRoute<{
    agentId: string;
    versionId: string;
}, {
    message: string;
    success: boolean;
}, "json">;
/**
 * GET /stored/agents/:agentId/versions/compare - Compare two versions
 */
export declare const COMPARE_AGENT_VERSIONS_ROUTE: import("../server-adapter").ServerRoute<import("../server-adapter").InferParams<import("zod").ZodObject<{
    agentId: import("zod").ZodString;
}, "strip", import("zod").ZodTypeAny, {
    agentId: string;
}, {
    agentId: string;
}>, import("zod").ZodObject<{
    from: import("zod").ZodString;
    to: import("zod").ZodString;
}, "strip", import("zod").ZodTypeAny, {
    from: string;
    to: string;
}, {
    from: string;
    to: string;
}>, undefined>, {
    diffs: {
        field: string;
        previousValue?: unknown;
        currentValue?: unknown;
    }[];
    fromVersion: {
        name: string;
        id: string;
        createdAt: Date;
        agentId: string;
        model: Record<string, unknown>;
        instructions: string;
        versionNumber: number;
        description?: string | undefined;
        tools?: string[] | undefined;
        agents?: string[] | undefined;
        workflows?: string[] | undefined;
        inputProcessors?: Record<string, unknown>[] | undefined;
        outputProcessors?: Record<string, unknown>[] | undefined;
        defaultOptions?: Record<string, unknown> | undefined;
        memory?: Record<string, unknown> | undefined;
        scorers?: Record<string, {
            sampling?: {
                type: "count" | "ratio";
                count?: number | undefined;
                rate?: number | undefined;
            } | undefined;
        }> | undefined;
        integrationTools?: string[] | undefined;
        changeMessage?: string | undefined;
        changedFields?: string[] | undefined;
    };
    toVersion: {
        name: string;
        id: string;
        createdAt: Date;
        agentId: string;
        model: Record<string, unknown>;
        instructions: string;
        versionNumber: number;
        description?: string | undefined;
        tools?: string[] | undefined;
        agents?: string[] | undefined;
        workflows?: string[] | undefined;
        inputProcessors?: Record<string, unknown>[] | undefined;
        outputProcessors?: Record<string, unknown>[] | undefined;
        defaultOptions?: Record<string, unknown> | undefined;
        memory?: Record<string, unknown> | undefined;
        scorers?: Record<string, {
            sampling?: {
                type: "count" | "ratio";
                count?: number | undefined;
                rate?: number | undefined;
            } | undefined;
        }> | undefined;
        integrationTools?: string[] | undefined;
        changeMessage?: string | undefined;
        changedFields?: string[] | undefined;
    };
}, "json">;
//# sourceMappingURL=agent-versions.d.ts.map