UNPKG

recallrai

Version:

Official Node.js SDK for RecallrAI - Revolutionary contextual memory system that enables AI assistants to form meaningful connections between conversations, just like human memory.

88 lines (87 loc) 3.68 kB
/** * Main client class for the RecallrAI SDK. * * This module provides the RecallrAI class, which is the primary interface for the SDK. */ import { User } from "./user"; /** * Main client for interacting with the RecallrAI API. * * This class provides methods for creating and managing users, sessions, and memories. */ export declare class RecallrAI { private http; /** * Initialize the RecallrAI client. * * @param apiKey - Your RecallrAI API key. Must start with `rai_`. * @param projectId - Your project ID. * @param baseUrl - The base URL for the RecallrAI API. Defaults to `https://api.recallrai.com`. * @param timeout - Request timeout in seconds. Defaults to `30`. */ constructor({ apiKey, projectId, baseUrl, timeout, }: { apiKey: string; projectId: string; baseUrl?: string; timeout?: number; }); /** * Create a new user. * * @param userId - Unique identifier for the user. * @param metadata - Optional metadata to associate with the user. * @param mergeConflictEnabled - Per-user merge conflict override. * `true` = always raise merge conflicts for this user. * `false` = never raise merge conflicts for this user. * `undefined` (default) = inherit the project-level setting. * @returns The created user object. * @throws {UserAlreadyExistsError} If a user with the same ID already exists. * @throws {AuthenticationError} If the API key or project ID is invalid. * @throws {InternalServerError} If the server encounters an error. * @throws {NetworkError} If there are network issues. * @throws {TimeoutError} If the request times out. * @throws {RecallrAIError} For other API-related errors. */ createUser(userId: string, metadata?: Record<string, any>, mergeConflictEnabled?: boolean): Promise<User>; /** * Get a user by ID. * * @param userId - Unique identifier of the user. * @param options - Optional behavior flags. * @param options.validate - Whether to validate user existence via API before creating the instance. * Defaults to true. Set to false when userId is trusted. * @returns A User object representing the user. * @throws {UserNotFoundError} If the user is not found. * @throws {AuthenticationError} If the API key or project ID is invalid. * @throws {InternalServerError} If the server encounters an error. * @throws {NetworkError} If there are network issues. * @throws {TimeoutError} If the request times out. * @throws {RecallrAIError} For other API-related errors. */ getUser(userId: string, { validate }?: { validate?: boolean; }): Promise<User>; /** * List users with pagination. * * @param offset - Number of records to skip. Defaults to 0. * @param limit - Maximum number of records to return. Defaults to 10. * @param metadataFilter - Optional metadata filter for users. * @returns List of users with pagination info. * @throws {AuthenticationError} If the API key or project ID is invalid. * @throws {InternalServerError} If the server encounters an error. * @throws {NetworkError} If there are network issues. * @throws {TimeoutError} If the request times out. * @throws {RecallrAIError} For other API-related errors. */ listUsers({ offset, limit, metadataFilter, }?: { offset?: number; limit?: number; metadataFilter?: Record<string, any>; }): Promise<{ users: User[]; total: number; hasMore: boolean; }>; private parseUserResponse; }