interface EntityOptions {
    userId?: string;
    agentId?: string;
    appId?: string;
    runId?: string;
}
interface AddMemoryOptions extends EntityOptions {
    metadata?: Record<string, any>;
    infer?: boolean;
    customCategories?: custom_categories[];
    customInstructions?: string;
    agentCustomInstructions?: string;
    timestamp?: number;
    expirationDate?: string;
    structuredDataSchema?: Record<string, any>;
}
interface SearchMemoryOptions {
    filters?: Record<string, any>;
    metadata?: Record<string, any>;
    topK?: number;
    threshold?: number;
    rerank?: boolean;
    latestOnly?: boolean;
    fields?: string[];
    categories?: string[];
    showExpired?: boolean;
    referenceDate?: string | number;
    keywordSearch?: boolean;
    /** Surface that produced the call, e.g. "OPENCLAW". Must be a value the
     *  backend's EventSource enum knows, or it buckets into OTHERS. */
    source?: string;
}
interface GetAllMemoryOptions {
    filters?: Record<string, any>;
    page?: number;
    pageSize?: number;
    startDate?: string;
    endDate?: string;
    latestOnly?: boolean;
    categories?: string[];
    showExpired?: boolean;
}
interface DeleteAllMemoryOptions extends EntityOptions {
}
interface DeleteMemoryOptions {
    /**
     * When `true`, also delete the older memories this one superseded (the v3
     * linked chain), transitively — the delete-side counterpart of `latestOnly`.
     * Off by default. Serialized as `delete_linked`.
     */
    deleteLinked?: boolean;
}
interface ProjectOptions {
    fields?: string[];
}
interface PromptUpdatePayload {
    customInstructions?: string;
    agentCustomInstructions?: string;
    customCategories?: custom_categories[];
    version?: string;
    memoryDepth?: string | null;
    usecaseSetting?: string | number;
    multilingual?: boolean;
    /**
     * Toggle Memory Decay for this project. When `true`, search-time ranking
     * boosts recently-used memories and gently dampens stale ones; when `false`,
     * ranking is restored to the pre-decay behaviour. Off by default.
     * See https://docs.mem0.ai/platform/features/memory-decay
     */
    decay?: boolean;
    [key: string]: any;
}
declare enum Feedback {
    POSITIVE = "POSITIVE",
    NEGATIVE = "NEGATIVE",
    VERY_NEGATIVE = "VERY_NEGATIVE"
}
interface MultiModalMessages {
    type: "image_url";
    image_url: {
        url: string;
    };
}
interface Messages {
    role: "user" | "assistant";
    content: string | MultiModalMessages;
}
interface Message extends Messages {
}
interface MemoryData {
    memory: string;
}
declare enum Event {
    ADD = "ADD",
    UPDATE = "UPDATE",
    DELETE = "DELETE",
    NOOP = "NOOP"
}
interface Memory {
    id: string;
    messages?: Array<Messages>;
    event?: Event | string;
    data?: MemoryData | null;
    memory?: string;
    userId?: string;
    hash?: string;
    categories?: Array<string>;
    createdAt?: Date;
    updatedAt?: Date;
    memoryType?: string;
    score?: number;
    metadata?: any | null;
    expirationDate?: string | null;
    owner?: string | null;
    agentId?: string | null;
    appId?: string | null;
    runId?: string | null;
}
interface MemoryHistory {
    id: string;
    memoryId: string;
    input: Array<Messages>;
    oldMemory: string | null;
    newMemory: string | null;
    userId: string;
    categories: Array<string>;
    event: Event | string;
    createdAt: Date;
    updatedAt: Date;
}
interface MemoryUpdateBody {
    memoryId: string;
    text: string;
}
interface User {
    id: string;
    name: string;
    createdAt: Date;
    updatedAt: Date;
    totalMemories: number;
    owner: string;
    type: string;
}
interface AllUsers {
    count: number;
    results: Array<User>;
    next: any;
    previous: any;
}
interface PaginatedMemories {
    count: number;
    next: string | null;
    previous: string | null;
    results: Array<Memory>;
}
interface ProjectResponse {
    customInstructions?: string;
    agentCustomInstructions?: string;
    customCategories?: custom_categories[];
    [key: string]: any;
}
interface custom_categories {
    [key: string]: any;
}
declare enum WebhookEvent {
    MEMORY_ADDED = "memory_add",
    MEMORY_UPDATED = "memory_update",
    MEMORY_DELETED = "memory_delete",
    MEMORY_CATEGORIZED = "memory_categorize"
}
interface Webhook {
    webhookId?: string;
    name: string;
    url: string;
    project?: string;
    createdAt?: Date;
    updatedAt?: Date;
    isActive?: boolean;
    eventTypes?: WebhookEvent[];
}
interface WebhookCreatePayload {
    name: string;
    url: string;
    eventTypes: WebhookEvent[];
}
interface WebhookUpdatePayload {
    webhookId: string;
    name?: string;
    url?: string;
    eventTypes?: WebhookEvent[];
}
interface FeedbackPayload {
    memoryId: string;
    feedback?: Feedback | null;
    feedbackReason?: string | null;
}
interface CreateMemoryExportPayload {
    schema: Record<string, any>;
    filters: Record<string, any>;
    exportInstructions?: string;
}
interface GetMemoryExportPayload {
    filters?: Record<string, any>;
    memoryExportId?: string;
}
/** The entity kind that carries a profile. */
type ProfileEntityType = "user";
/**
 * `succeeded` is the only state in which `profile` is guaranteed to hold content.
 *
 * These are values, not keys, so the client does not camel-case them: the wire
 * spelling is what a comparison has to match.
 */
type ProfileStatus = "succeeded" | "pending" | "failed" | "not_enabled" | "insufficient_data";
interface ProfileResponse {
    /** Shaped by the project's schema; keys are not camel-cased. */
    profile: Record<string, any>;
    status: ProfileStatus;
    entityType: ProfileEntityType;
    entityId: string;
    updatedAt: string | null;
    generationCount: number;
    /** The last generation's failure reason, when `status` is `failed`. */
    error?: string | null;
}
/** Every accepted generation. `statusUrl` is the server's own poll path. */
interface ProfileJobResponse {
    jobId: string;
    status: string;
    statusUrl: string;
    operation: string;
    entityType: ProfileEntityType;
    /** Entities reserved against usage for this job. */
    entityCountReserved?: number;
    /** Null when the job has no associated event. */
    eventId?: string | null;
    replayed?: boolean;
    /** Sample runs only: how many entities were picked. */
    sampled?: number;
    /** Sample runs only: the entity ids picked. Read each one with `getProfile`. */
    entityIds?: string[];
}
/** The settings to write. `schema` and `customInstructions` apply to user profiles. */
interface ProfileSettings {
    /** Turn profile generation on or off. Project-wide. */
    enabled?: boolean;
    /** JSON Schema for the profile. Every property needs a `description`. */
    schema?: Record<string, any> | null;
    customInstructions?: string | null;
}
/** One entity type's stored configuration. */
interface EntityProfileSettings {
    /** The customer's JSON Schema, with its property names verbatim. */
    schema?: Record<string, any> | null;
    customInstructions?: string | null;
    [key: string]: any;
}
/**
 * The settings as stored. `schema` and `customInstructions` are per entity
 * type and nest under `entities`; only `enabled` is project-wide.
 */
interface ProfileSettingsResponse {
    enabled?: boolean;
    entities?: Partial<Record<ProfileEntityType, EntityProfileSettings>>;
    capabilities?: Record<string, any>;
    [key: string]: any;
}
/** `GET /v2/profiles/jobs/{id}/`. The job nests under `job`. */
interface ProfileJobStatus {
    job: {
        id: string;
        operation: string;
        entityType: ProfileEntityType;
        status: string;
        /** Null until `enumerationComplete`. */
        total: number | null;
        enumerationComplete: boolean;
        /** succeeded + failed + skipped. */
        completed: number;
        succeeded: number;
        failed: number;
        skipped: number;
        [key: string]: any;
    };
}

interface ClientOptions {
    apiKey: string;
    host?: string;
    /** Max cached identities per process. Defaults to 50. */
    identityCacheMax?: number;
}
declare class MemoryClient {
    apiKey: string;
    host: string;
    private organizationId;
    private projectId;
    headers: Record<string, string>;
    client: any;
    telemetryId: string;
    private initialized;
    private identityCacheMax;
    _validateApiKey(): any;
    constructor(options: ClientOptions);
    private _resolveIdentity;
    private _awaitIdentity;
    private _initializeClient;
    private _maybeAliasAnonToEmail;
    private _captureEvent;
    /** Fetch with no key conversion, for payloads carrying user-controlled property names. */
    _fetchRawJson(url: string, options: any): Promise<any>;
    _fetchWithErrorHandling(url: string, options: any): Promise<any>;
    _preparePayload(messages: Array<Message>, options: Record<string, any>): object;
    _prepareParams(options: Record<string, any>): object;
    ping(): Promise<void>;
    add(messages: Array<Message>, options?: AddMemoryOptions & Record<string, any>): Promise<Array<Memory>>;
    update(memoryId: string, { text, metadata, timestamp, expirationDate, }: {
        text?: string;
        metadata?: Record<string, any>;
        timestamp?: number | string;
        expirationDate?: string | null;
    }): Promise<Array<Memory>>;
    get(memoryId: string): Promise<Memory>;
    getAll(options?: GetAllMemoryOptions): Promise<PaginatedMemories>;
    search(query: string, options?: SearchMemoryOptions): Promise<{
        results: Array<Memory>;
    }>;
    delete(memoryId: string, options?: DeleteMemoryOptions): Promise<{
        message: string;
    }>;
    deleteAll(options?: DeleteAllMemoryOptions): Promise<{
        message: string;
    }>;
    history(memoryId: string): Promise<Array<MemoryHistory>>;
    users(options?: {
        page?: number;
        pageSize?: number;
    }): Promise<AllUsers>;
    /**
     * @deprecated The method should not be used, use `deleteUsers` instead. This will be removed in version 2.2.0.
     */
    deleteUser(data: {
        entity_id: number;
        entity_type: string;
    }): Promise<{
        message: string;
    }>;
    deleteUsers(params?: {
        userId?: string;
        agentId?: string;
        appId?: string;
        runId?: string;
    }): Promise<{
        message: string;
    }>;
    batchUpdate(memories: Array<MemoryUpdateBody>): Promise<string>;
    batchDelete(memories: Array<string>): Promise<string>;
    getProject(options: ProjectOptions): Promise<ProjectResponse>;
    updateProject(prompts: PromptUpdatePayload): Promise<Record<string, any>>;
    getWebhooks(data?: {
        projectId?: string;
    }): Promise<Array<Webhook>>;
    createWebhook(webhook: WebhookCreatePayload): Promise<Webhook>;
    updateWebhook(webhook: WebhookUpdatePayload): Promise<{
        message: string;
    }>;
    deleteWebhook(data: {
        webhookId: string;
    }): Promise<{
        message: string;
    }>;
    feedback(data: FeedbackPayload): Promise<{
        message: string;
    }>;
    /**
     * Get the memory profile for a single user.
     *
     * Branch on `status`, not on an empty `profile`: generation is asynchronous,
     * so a known user without a profile yet is a normal response.
     */
    getProfile(data: {
        entityId: string;
    }): Promise<ProfileResponse>;
    /**
     * Generate or refresh the profile for one user, now.
     *
     * Profiles are otherwise built once a user crosses an internal message
     * threshold, so a new user has none for its first few memories. Returns as
     * soon as the work is queued: poll {@link getProfile} and branch on `status`.
     *
     * Pass `idempotencyKey` and reuse it to retry a lost request without starting
     * (and being billed for) a second job.
     */
    generateProfile(data: {
        entityId: string;
        idempotencyKey?: string;
    }): Promise<ProfileJobResponse>;
    /** Get the profile settings for the current project. */
    getProfileSettings(): Promise<ProfileSettingsResponse>;
    /**
     * The envelope keys are ours; the schema's property names are the customer's.
     *
     * Each entity type carries its own schema, so every one has to be restored
     * from the raw body — otherwise camel-casing rewrites the customer's field
     * names and a profile comes back under keys they never chose.
     */
    private _settingsWithVerbatimSchema;
    /**
     * Update profile settings. Only the fields you pass are written.
     *
     * `schema` and `customInstructions` are per user and are nested under
     * `entities` for the API; only `enabled` is project-wide. Sending them flat
     * is rejected with `Unsupported settings`.
     */
    updateProfileSettings(settings: ProfileSettings): Promise<ProfileSettingsResponse>;
    /**
     * Generate profiles for a few real users, to check a schema.
     *
     * Real generations against real memories, and the results are kept: the
     * profiles are written to those users and count toward usage.
     */
    sampleProfiles(data?: {
        limit?: number;
        idempotencyKey?: string;
    }): Promise<ProfileJobResponse>;
    /**
     * Read one generation job. Accepts the `statusUrl` from a create call, or a
     * bare job id. Prefer `statusUrl` so a route change needs no client update.
     */
    getProfileJob(jobIdOrStatusUrl: string): Promise<ProfileJobStatus>;
    createMemoryExport(data: CreateMemoryExportPayload): Promise<{
        message: string;
        id: string;
    }>;
    getMemoryExport(data: GetMemoryExportPayload): Promise<{
        message: string;
        id: string;
    }>;
}

/**
 * Structured exception classes for mem0 TypeScript SDK.
 *
 * Provides specific, actionable exceptions with error codes, suggestions,
 * and debug information. Maps HTTP status codes to appropriate exception types.
 *
 * @example
 * ```typescript
 * import { RateLimitError, MemoryNotFoundError } from 'mem0ai'
 *
 * try {
 *   await client.get(memoryId)
 * } catch (e) {
 *   if (e instanceof MemoryNotFoundError) {
 *     console.log(e.suggestion) // "The requested resource was not found"
 *   } else if (e instanceof RateLimitError) {
 *     await sleep(e.debugInfo.retryAfter ?? 60)
 *   }
 * }
 * ```
 */
interface MemoryErrorOptions {
    details?: Record<string, unknown>;
    suggestion?: string;
    debugInfo?: Record<string, unknown>;
}
/**
 * Base exception for all memory-related errors.
 *
 * Every mem0 exception includes an error code for programmatic handling,
 * optional details, a user-friendly suggestion, and debug information.
 */
declare class MemoryError extends Error {
    readonly errorCode: string;
    readonly details: Record<string, unknown>;
    readonly suggestion?: string;
    readonly debugInfo: Record<string, unknown>;
    constructor(message: string, errorCode: string, options?: MemoryErrorOptions);
}
/** Raised when authentication fails (401, 403). */
declare class AuthenticationError extends MemoryError {
    constructor(message: string, errorCode: string, options?: MemoryErrorOptions);
}
/** Raised when rate limits are exceeded (429). */
declare class RateLimitError extends MemoryError {
    constructor(message: string, errorCode: string, options?: MemoryErrorOptions);
}
/** Raised when input validation fails (400, 409, 422). */
declare class ValidationError extends MemoryError {
    constructor(message: string, errorCode: string, options?: MemoryErrorOptions);
}
/** Raised when a memory is not found (404). */
declare class MemoryNotFoundError extends MemoryError {
    constructor(message: string, errorCode: string, options?: MemoryErrorOptions);
}
/** Raised when network connectivity issues occur (408, 502, 503, 504). */
declare class NetworkError extends MemoryError {
    constructor(message: string, errorCode: string, options?: MemoryErrorOptions);
}
/** Raised when client configuration is invalid. */
declare class ConfigurationError extends MemoryError {
    constructor(message: string, errorCode: string, options?: MemoryErrorOptions);
}
/** Raised when memory quota is exceeded (413). */
declare class MemoryQuotaExceededError extends MemoryError {
    constructor(message: string, errorCode: string, options?: MemoryErrorOptions);
}
/**
 * Create an appropriate exception based on HTTP response status code.
 *
 * @param statusCode - HTTP status code from the response
 * @param responseText - Response body text
 * @param options - Additional error context (details, debugInfo)
 * @returns An instance of the appropriate MemoryError subclass
 */
declare function createExceptionFromResponse(statusCode: number, responseText: string, options?: Omit<MemoryErrorOptions, "suggestion">): MemoryError;

export { type AddMemoryOptions, type AllUsers, AuthenticationError, ConfigurationError, type CreateMemoryExportPayload, type DeleteAllMemoryOptions, type EntityProfileSettings, Feedback, type FeedbackPayload, type GetAllMemoryOptions, type GetMemoryExportPayload, type Memory, MemoryClient, MemoryError, type MemoryErrorOptions, type MemoryHistory, MemoryNotFoundError, MemoryQuotaExceededError, type MemoryUpdateBody, type Message, type Messages, NetworkError, type ProfileEntityType, type ProfileJobResponse, type ProfileJobStatus, type ProfileResponse, type ProfileSettings, type ProfileSettingsResponse, type ProfileStatus, type ProjectOptions, type ProjectResponse, type PromptUpdatePayload, RateLimitError, type SearchMemoryOptions, type User, ValidationError, type Webhook, type WebhookCreatePayload, WebhookEvent, type WebhookUpdatePayload, createExceptionFromResponse, MemoryClient as default };
