Class: abstract
DatabaseAdapter
An abstract class representing a database adapter for managing various entities like accounts, memories, actors, goals, and rooms.
Implements
Constructors
new DatabaseAdapter()
new DatabaseAdapter():
DatabaseAdapter
Returns
Properties
db
db:
any
The database instance.
Implementation of
Defined in
packages/core/src/database.ts:21
Methods
addParticipant()
abstract
addParticipant(userId
,roomId
):Promise
<boolean
>
Adds a user as a participant to a specific room.
Parameters
• userId: `${string}-${string}-${string}-${string}-${string}`
The UUID of the user to add as a participant.
• roomId: `${string}-${string}-${string}-${string}-${string}`
The UUID of the room to which the user will be added.
Returns
Promise
<boolean
>
A Promise that resolves to a boolean indicating success or failure.
Implementation of
IDatabaseAdapter
.addParticipant
Defined in
packages/core/src/database.ts:266
countMemories()
abstract
countMemories(roomId
,unique
?,tableName
?):Promise
<number
>
Counts the number of memories in a specific room.
Parameters
• roomId: `${string}-${string}-${string}-${string}-${string}`
The UUID of the room for which to count memories.
• unique?: boolean
Specifies whether to count only unique memories.
• tableName?: string
Optional table name to count memories from.
Returns
Promise
<number
>
A Promise that resolves to the number of memories.
Implementation of
IDatabaseAdapter
.countMemories
Defined in
packages/core/src/database.ts:179
createAccount()
abstract
createAccount(account
):Promise
<boolean
>
Creates a new account in the database.
Parameters
• account: Account
The account object to create.
Returns
Promise
<boolean
>
A Promise that resolves when the account creation is complete.
Implementation of
IDatabaseAdapter
.createAccount
Defined in
packages/core/src/database.ts:34
createGoal()
abstract
createGoal(goal
):Promise
<void
>
Creates a new goal in the database.
Parameters
• goal: Goal
The goal object to create.
Returns
Promise
<void
>
A Promise that resolves when the goal has been created.
Implementation of
Defined in
packages/core/src/database.ts:209
createMemory()
abstract
createMemory(memory
,tableName
,unique
?):Promise
<void
>
Creates a new memory in the database.
Parameters
• memory: Memory
The memory object to create.
• tableName: string
The table where the memory should be stored.
• unique?: boolean
Indicates if the memory should be unique.
Returns
Promise
<void
>
A Promise that resolves when the memory has been created.
Implementation of
Defined in
packages/core/src/database.ts:150
createRelationship()
abstract
createRelationship(params
):Promise
<boolean
>
Creates a new relationship between two users.
Parameters
• params
An object containing the UUIDs of the two users (userA and userB).
• params.userA: `${string}-${string}-${string}-${string}-${string}`
• params.userB: `${string}-${string}-${string}-${string}-${string}`
Returns
Promise
<boolean
>
A Promise that resolves to a boolean indicating success or failure of the creation.
Implementation of
IDatabaseAdapter
.createRelationship
Defined in
packages/core/src/database.ts:312
createRoom()
abstract
createRoom(roomId
?):Promise
<`${string}-${string}-${string}-${string}-${string}`>
Creates a new room with an optional specified ID.
Parameters
• roomId?: `${string}-${string}-${string}-${string}-${string}`
Optional UUID to assign to the new room.
Returns
Promise
<`${string}-${string}-${string}-${string}-${string}`>
A Promise that resolves to the UUID of the created room.
Implementation of
Defined in
packages/core/src/database.ts:237
getAccountById()
abstract
getAccountById(userId
):Promise
<Account
>
Retrieves an account by its ID.
Parameters
• userId: `${string}-${string}-${string}-${string}-${string}`
The UUID of the user account to retrieve.
Returns
Promise
<Account
>
A Promise that resolves to the Account object or null if not found.
Implementation of
IDatabaseAdapter
.getAccountById
Defined in
packages/core/src/database.ts:27
getActorDetails()
abstract
getActorDetails(params
):Promise
<Actor
[]>
Retrieves details of actors in a given room.
Parameters
• params
An object containing the roomId to search for actors.
• params.roomId: `${string}-${string}-${string}-${string}-${string}`
Returns
Promise
<Actor
[]>
A Promise that resolves to an array of Actor objects.
Implementation of
IDatabaseAdapter
.getActorDetails
Defined in
packages/core/src/database.ts:99
getCachedEmbeddings()
abstract
getCachedEmbeddings(params
):Promise
<object
[]>
Retrieves cached embeddings based on the specified query parameters.
Parameters
• params
An object containing parameters for the embedding retrieval.
• params.query_field_name: string
• params.query_field_sub_name: string
• params.query_input: string
• params.query_match_count: number
• params.query_table_name: string
• params.query_threshold: number
Returns
Promise
<object
[]>
A Promise that resolves to an array of objects containing embeddings and levenshtein scores.
Implementation of
IDatabaseAdapter
.getCachedEmbeddings
Defined in
packages/core/src/database.ts:61
getGoals()
abstract
getGoals(params
):Promise
<Goal
[]>
Retrieves goals based on specified parameters.
Parameters
• params
An object containing parameters for goal retrieval.
• params.count?: number
• params.onlyInProgress?: boolean
• params.roomId: `${string}-${string}-${string}-${string}-${string}`
• params.userId?: `${string}-${string}-${string}-${string}-${string}`
Returns
Promise
<Goal
[]>
A Promise that resolves to an array of Goal objects.
Implementation of
Defined in
packages/core/src/database.ts:190
getMemories()
abstract
getMemories(params
):Promise
<Memory
[]>
Retrieves memories based on the specified parameters.
Parameters
• params
An object containing parameters for the memory retrieval.
• params.count?: number
• params.roomId: `${string}-${string}-${string}-${string}-${string}`
• params.tableName: string
• params.unique?: boolean
Returns
Promise
<Memory
[]>
A Promise that resolves to an array of Memory objects.
Implementation of
Defined in
packages/core/src/database.ts:41
getMemoriesByRoomIds()
abstract
getMemoriesByRoomIds(params
):Promise
<Memory
[]>
Parameters
• params
• params.agentId?: `${string}-${string}-${string}-${string}-${string}`
• params.roomIds: `${string}-${string}-${string}-${string}-${string}`[]
• params.tableName: string
Returns
Promise
<Memory
[]>
Implementation of
IDatabaseAdapter
.getMemoriesByRoomIds
Defined in
packages/core/src/database.ts:48
getMemoryById()
abstract
getMemoryById(id
):Promise
<Memory
>
Parameters
• id: `${string}-${string}-${string}-${string}-${string}`
Returns
Promise
<Memory
>
Implementation of
IDatabaseAdapter
.getMemoryById
Defined in
packages/core/src/database.ts:54
getParticipantsForAccount()
getParticipantsForAccount(userId)
abstract
getParticipantsForAccount(userId
):Promise
<Participant
[]>
Retrieves participants associated with a specific account.
Parameters
• userId: `${string}-${string}-${string}-${string}-${string}`
The UUID of the account.
Returns
Promise
<Participant
[]>
A Promise that resolves to an array of Participant objects.
Implementation of
IDatabaseAdapter
.getParticipantsForAccount
Defined in
packages/core/src/database.ts:281
getParticipantsForAccount(userId)
abstract
getParticipantsForAccount(userId
):Promise
<Participant
[]>
Retrieves participants associated with a specific account.
Parameters
• userId: `${string}-${string}-${string}-${string}-${string}`
The UUID of the account.
Returns
Promise
<Participant
[]>
A Promise that resolves to an array of Participant objects.
Implementation of
IDatabaseAdapter.getParticipantsForAccount
Defined in
packages/core/src/database.ts:288
getParticipantsForRoom()
abstract
getParticipantsForRoom(roomId
):Promise
<`${string}-${string}-${string}-${string}-${string}`[]>
Retrieves participants for a specific room.
Parameters
• roomId: `${string}-${string}-${string}-${string}-${string}`
The UUID of the room for which to retrieve participants.
Returns
Promise
<`${string}-${string}-${string}-${string}-${string}`[]>
A Promise that resolves to an array of UUIDs representing the participants.
Implementation of
IDatabaseAdapter
.getParticipantsForRoom
Defined in
packages/core/src/database.ts:295
getParticipantUserState()
abstract
getParticipantUserState(roomId
,userId
):Promise
<"FOLLOWED"
|"MUTED"
>
Parameters
• roomId: `${string}-${string}-${string}-${string}-${string}`
• userId: `${string}-${string}-${string}-${string}-${string}`
Returns
Promise
<"FOLLOWED"
| "MUTED"
>
Implementation of
IDatabaseAdapter
.getParticipantUserState
Defined in
packages/core/src/database.ts:297
getRelationship()
abstract
getRelationship(params
):Promise
<Relationship
>
Retrieves a relationship between two users if it exists.
Parameters
• params
An object containing the UUIDs of the two users (userA and userB).
• params.userA: `${string}-${string}-${string}-${string}-${string}`
• params.userB: `${string}-${string}-${string}-${string}-${string}`
Returns
Promise
<Relationship
>
A Promise that resolves to the Relationship object or null if not found.
Implementation of
IDatabaseAdapter
.getRelationship
Defined in
packages/core/src/database.ts:322
getRelationships()
abstract
getRelationships(params
):Promise
<Relationship
[]>
Retrieves all relationships for a specific user.
Parameters
• params
An object containing the UUID of the user.
• params.userId: `${string}-${string}-${string}-${string}-${string}`
Returns
Promise
<Relationship
[]>
A Promise that resolves to an array of Relationship objects.
Implementation of
IDatabaseAdapter
.getRelationships
Defined in
packages/core/src/database.ts:332
getRoom()
abstract
getRoom(roomId
):Promise
<`${string}-${string}-${string}-${string}-${string}`>
Retrieves the room ID for a given room, if it exists.
Parameters
• roomId: `${string}-${string}-${string}-${string}-${string}`
The UUID of the room to retrieve.
Returns
Promise
<`${string}-${string}-${string}-${string}-${string}`>
A Promise that resolves to the room ID or null if not found.
Implementation of
Defined in
packages/core/src/database.ts:230
getRoomsForParticipant()
abstract
getRoomsForParticipant(userId
):Promise
<`${string}-${string}-${string}-${string}-${string}`[]>
Retrieves room IDs for which a specific user is a participant.
Parameters
• userId: `${string}-${string}-${string}-${string}-${string}`
The UUID of the user.
Returns
Promise
<`${string}-${string}-${string}-${string}-${string}`[]>
A Promise that resolves to an array of room IDs.
Implementation of
IDatabaseAdapter
.getRoomsForParticipant
Defined in
packages/core/src/database.ts:251
getRoomsForParticipants()
abstract
getRoomsForParticipants(userIds
):Promise
<`${string}-${string}-${string}-${string}-${string}`[]>
Retrieves room IDs for which specific users are participants.
Parameters
• userIds: `${string}-${string}-${string}-${string}-${string}`[]
An array of UUIDs of the users.
Returns
Promise
<`${string}-${string}-${string}-${string}-${string}`[]>
A Promise that resolves to an array of room IDs.
Implementation of
IDatabaseAdapter
.getRoomsForParticipants
Defined in
packages/core/src/database.ts:258
log()
abstract
log(params
):Promise
<void
>
Logs an event or action with the specified details.
Parameters
• params
An object containing parameters for the log entry.
• params.body
• params.roomId: `${string}-${string}-${string}-${string}-${string}`
• params.type: string
• params.userId: `${string}-${string}-${string}-${string}-${string}`
Returns
Promise
<void
>
A Promise that resolves when the log entry has been saved.
Implementation of
Defined in
packages/core/src/database.ts:87
removeAllGoals()
abstract
removeAllGoals(roomId
):Promise
<void
>
Removes all goals associated with a specific room.
Parameters
• roomId: `${string}-${string}-${string}-${string}-${string}`
The UUID of the room whose goals should be removed.
Returns
Promise
<void
>
A Promise that resolves when all goals have been removed.
Implementation of
IDatabaseAdapter
.removeAllGoals
Defined in
packages/core/src/database.ts:223
removeAllMemories()
abstract
removeAllMemories(roomId
,tableName
):Promise
<void
>
Removes all memories associated with a specific room.
Parameters
• roomId: `${string}-${string}-${string}-${string}-${string}`
The UUID of the room whose memories should be removed.
• tableName: string
The table from which the memories should be removed.
Returns
Promise
<void
>
A Promise that resolves when all memories have been removed.
Implementation of
IDatabaseAdapter
.removeAllMemories
Defined in
packages/core/src/database.ts:170
removeGoal()
abstract
removeGoal(goalId
):Promise
<void
>
Removes a specific goal from the database.
Parameters
• goalId: `${string}-${string}-${string}-${string}-${string}`
The UUID of the goal to remove.
Returns
Promise
<void
>
A Promise that resolves when the goal has been removed.
Implementation of
Defined in
packages/core/src/database.ts:216
removeMemory()
abstract
removeMemory(memoryId
,tableName
):Promise
<void
>
Removes a specific memory from the database.
Parameters
• memoryId: `${string}-${string}-${string}-${string}-${string}`
The UUID of the memory to remove.
• tableName: string
The table from which the memory should be removed.
Returns
Promise
<void
>
A Promise that resolves when the memory has been removed.
Implementation of
Defined in
packages/core/src/database.ts:162
removeParticipant()
abstract
removeParticipant(userId
,roomId
):Promise
<boolean
>
Removes a user as a participant from a specific room.
Parameters
• userId: `${string}-${string}-${string}-${string}-${string}`
The UUID of the user to remove as a participant.
• roomId: `${string}-${string}-${string}-${string}-${string}`
The UUID of the room from which the user will be removed.
Returns
Promise
<boolean
>
A Promise that resolves to a boolean indicating success or failure.
Implementation of
IDatabaseAdapter
.removeParticipant
Defined in
packages/core/src/database.ts:274
removeRoom()
abstract
removeRoom(roomId
):Promise
<void
>
Removes a specific room from the database.
Parameters
• roomId: `${string}-${string}-${string}-${string}-${string}`
The UUID of the room to remove.
Returns
Promise
<void
>
A Promise that resolves when the room has been removed.
Implementation of
Defined in
packages/core/src/database.ts:244
searchMemories()
abstract
searchMemories(params
):Promise
<Memory
[]>
Searches for memories based on embeddings and other specified parameters.
Parameters
• params
An object containing parameters for the memory search.
• params.embedding: number
[]
• params.match_count: number
• params.match_threshold: number
• params.roomId: `${string}-${string}-${string}-${string}-${string}`
• params.tableName: string
• params.unique: boolean
Returns
Promise
<Memory
[]>
A Promise that resolves to an array of Memory objects.
Implementation of
IDatabaseAdapter
.searchMemories
Defined in
packages/core/src/database.ts:106
searchMemoriesByEmbedding()
abstract
searchMemoriesByEmbedding(embedding
,params
):Promise
<Memory
[]>
Searches for memories by embedding and other specified parameters.
Parameters
• embedding: number
[]
The embedding vector to search with.
• params
Additional parameters for the search.
• params.agentId?: `${string}-${string}-${string}-${string}-${string}`
• params.count?: number
• params.match_threshold?: number
• params.roomId?: `${string}-${string}-${string}-${string}-${string}`
• params.tableName: string
• params.unique?: boolean
Returns
Promise
<Memory
[]>
A Promise that resolves to an array of Memory objects.
Implementation of
IDatabaseAdapter
.searchMemoriesByEmbedding
Defined in
packages/core/src/database.ts:131
setParticipantUserState()
abstract
setParticipantUserState(roomId
,userId
,state
):Promise
<void
>
Parameters
• roomId: `${string}-${string}-${string}-${string}-${string}`
• userId: `${string}-${string}-${string}-${string}-${string}`
• state: "FOLLOWED"
| "MUTED"
Returns
Promise
<void
>
Implementation of
IDatabaseAdapter
.setParticipantUserState
Defined in
packages/core/src/database.ts:301
updateGoal()
abstract
updateGoal(goal
):Promise
<void
>
Updates a specific goal in the database.
Parameters
• goal: Goal
The goal object with updated properties.
Returns
Promise
<void
>
A Promise that resolves when the goal has been updated.
Implementation of
Defined in
packages/core/src/database.ts:202
updateGoalStatus()
abstract
updateGoalStatus(params
):Promise
<void
>
Updates the status of a specific goal.
Parameters
• params
An object containing the goalId and the new status.
• params.goalId: `${string}-${string}-${string}-${string}-${string}`
• params.status: GoalStatus
Returns
Promise
<void
>
A Promise that resolves when the goal status has been updated.
Implementation of
IDatabaseAdapter
.updateGoalStatus