Skip to Content
API ReferenceClassesClass: AiSessionStore

Class: AiSessionStore

Defined in: src/session/ai_session_store.ts:13 

SQLite-backed session store for conversation history. Suitable for production use with proper database management and backups. Each session is identified by a combination of userId and sessionName, allowing for multiple sessions per user if needed.

TODO - publish it as npm TODO - make a json file version TODO - make a session compression

Constructors

Constructor

new AiSessionStore(dbFilePath): AiSessionStore

Defined in: src/session/ai_session_store.ts:20 

Initializes a new instance of the AiSessionStore class.

Parameters

dbFilePath

string

The file path to the SQLite database.

Returns

AiSessionStore

Methods

close()

close(): Promise<void>

Defined in: src/session/ai_session_store.ts:39 

Returns

Promise<void>


deleteSession()

deleteSession(userId, sessionName): Promise<void>

Defined in: src/session/ai_session_store.ts:48 

Deletes all conversation items for a given user and session, effectively clearing the session history. This is a hard delete from the database.

Parameters

userId

string

The ID of the user whose session should be deleted.

sessionName

string

The name of the session to delete.

Returns

Promise<void>


getOpenAiSession()

getOpenAiSession(userId, sessionName): Promise<Session>

Defined in: src/session/ai_session_store.ts:80 

Returns an implementation of the OpenAiAgentsCore.Session interface for a specific user and session name. This allows the session to be used with the OpenAI Agents framework.

Parameters

userId

string

The ID of the user for whom the session is being retrieved.

sessionName

string

The name of the session to retrieve.

Returns

Promise<Session>

An instance of OpenAiAgentsCore.Session for the specified user and session name.


getSessionNamesForUser()

getSessionNamesForUser(userId): Promise<string[]>

Defined in: src/session/ai_session_store.ts:60 

Retrieves a list of all session names for a given user. This allows clients to discover existing sessions for that user.

Parameters

userId

string

The ID of the user whose session names should be retrieved.

Returns

Promise<string[]>

An array of session names associated with the specified user.

Last updated on