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.
82 lines (81 loc) • 3.17 kB
TypeScript
import { HTTPClient } from './utils/http-client';
import { Context, Message, SessionStatus } from './models/session';
export declare class Session {
private http;
userId: string;
sessionId: string;
/**
* Initialize a session.
*
* @param httpClient HTTP client for API communication
* @param userId ID of the user who owns this session
* @param sessionId Unique identifier for the session
*/
constructor(httpClient: HTTPClient, userId: string, sessionId: string);
/**
* Add a user message to the session.
*
* @param message Content of the user message
* @throws {UserNotFoundError} If the user is not found
* @throws {SessionNotFoundError} If the session is not found
* @throws {InvalidSessionStateError} If the session is already processed or processing
*/
addUserMessage(message: string): Promise<void>;
/**
* Add an assistant message to the session.
*
* @param message Content of the assistant message
* @throws {UserNotFoundError} If the user is not found
* @throws {SessionNotFoundError} If the session is not found
* @throws {InvalidSessionStateError} If the session is already processed or processing
*/
addAssistantMessage(message: string): Promise<void>;
/**
* Internal helper to add a message to the session.
*
* @param message Content of the message
* @param role Role of the message sender
* @throws {UserNotFoundError} If the user is not found
* @throws {SessionNotFoundError} If the session is not found
* @throws {InvalidSessionStateError} If the session is already processed or processing
*/
private addMessage;
/**
* Get the current context for this session.
*
* The context contains information from the user's memory that is relevant
* to the current conversation.
*
* @returns Context information with the memory text and whether memory was used
* @throws {UserNotFoundError} If the user is not found
* @throws {SessionNotFoundError} If the session is not found
*/
getContext(): Promise<Context>;
/**
* Process the session to update the user's memory.
*
* This method triggers the processing of the conversation to extract and update
* the user's memory.
*
* @throws {UserNotFoundError} If the user is not found
* @throws {SessionNotFoundError} If the session is not found
* @throws {InvalidSessionStateError} If the session is already processed or being processed
*/
process(): Promise<void>;
/**
* Get the current status of the session.
*
* @returns The current status of the session
* @throws {UserNotFoundError} If the user is not found
* @throws {SessionNotFoundError} If the session is not found
*/
getStatus(): Promise<SessionStatus>;
/**
* Get all messages in the session.
*
* @returns List of messages in the session
* @throws {UserNotFoundError} If the user is not found
* @throws {SessionNotFoundError} If the session is not found
*/
getMessages(): Promise<Message[]>;
}