Skip to main content

@elizaos/core v1.0.6 / v2 / IAgentRuntime

Interface: IAgentRuntime

Represents the core runtime environment for an agent. Defines methods for database interaction, plugin management, event handling, state composition, model usage, and task management.

Extends​

Properties​

db​

db: any

Database instance

Inherited from​

IDatabaseAdapter.db

Defined in​

packages/core/src/specs/v2/types.ts:814

Methods​

init()​

init(): Promise<void>

Initialize database connection

Returns​

Promise<void>

Inherited from​

IDatabaseAdapter.init

Defined in​

packages/core/src/specs/v2/types.ts:817


close()​

close(): Promise<void>

Close database connection

Returns​

Promise<void>

Inherited from​

IDatabaseAdapter.close

Defined in​

packages/core/src/specs/v2/types.ts:820


getAgents()​

getAgents(): Promise<Partial<Agent>[]>

Get all agents

Returns​

Promise<Partial<Agent>[]>

Inherited from​

IDatabaseAdapter.getAgents

Defined in​

packages/core/src/specs/v2/types.ts:827


getEntityByIds()​

getEntityByIds(entityIds): Promise<Entity[]>

Get entity by IDs

Parameters​

• entityIds: `${string}-${string}-${string}-${string}-${string}`[]

Returns​

Promise<Entity[]>

Inherited from​

IDatabaseAdapter.getEntityByIds

Defined in​

packages/core/src/specs/v2/types.ts:838


getEntitiesForRoom()​

getEntitiesForRoom(roomId, includeComponents?): Promise<Entity[]>

Get entities for room

Parameters​

• roomId: `${string}-${string}-${string}-${string}-${string}`

• includeComponents?: boolean

Returns​

Promise<Entity[]>

Inherited from​

IDatabaseAdapter.getEntitiesForRoom

Defined in​

packages/core/src/specs/v2/types.ts:841


createEntities()​

createEntities(entities): Promise<boolean>

Create new entities

Parameters​

• entities: Entity[]

Returns​

Promise<boolean>

Inherited from​

IDatabaseAdapter.createEntities

Defined in​

packages/core/src/specs/v2/types.ts:844


updateEntity()​

updateEntity(entity): Promise<void>

Update entity

Parameters​

• entity: Entity

Returns​

Promise<void>

Inherited from​

IDatabaseAdapter.updateEntity

Defined in​

packages/core/src/specs/v2/types.ts:847


getComponent()​

getComponent(entityId, type, worldId?, sourceEntityId?): Promise<Component>

Get component by ID

Parameters​

• entityId: `${string}-${string}-${string}-${string}-${string}`

• type: string

• worldId?: `${string}-${string}-${string}-${string}-${string}`

• sourceEntityId?: `${string}-${string}-${string}-${string}-${string}`

Returns​

Promise<Component>

Inherited from​

IDatabaseAdapter.getComponent

Defined in​

packages/core/src/specs/v2/types.ts:850


getComponents()​

getComponents(entityId, worldId?, sourceEntityId?): Promise<Component[]>

Get all components for an entity

Parameters​

• entityId: `${string}-${string}-${string}-${string}-${string}`

• worldId?: `${string}-${string}-${string}-${string}-${string}`

• sourceEntityId?: `${string}-${string}-${string}-${string}-${string}`

Returns​

Promise<Component[]>

Inherited from​

IDatabaseAdapter.getComponents

Defined in​

packages/core/src/specs/v2/types.ts:858


createComponent()​

createComponent(component): Promise<boolean>

Create component

Parameters​

• component: Component

Returns​

Promise<boolean>

Inherited from​

IDatabaseAdapter.createComponent

Defined in​

packages/core/src/specs/v2/types.ts:861


updateComponent()​

updateComponent(component): Promise<void>

Update component

Parameters​

• component: Component

Returns​

Promise<void>

Inherited from​

IDatabaseAdapter.updateComponent

Defined in​

packages/core/src/specs/v2/types.ts:864


deleteComponent()​

deleteComponent(componentId): Promise<void>

Delete component

Parameters​

• componentId: `${string}-${string}-${string}-${string}-${string}`

Returns​

Promise<void>

Inherited from​

IDatabaseAdapter.deleteComponent

Defined in​

packages/core/src/specs/v2/types.ts:867


getMemories()​

getMemories(params): Promise<Memory[]>

Get memories matching criteria

Parameters​

• params

• params.entityId?: `${string}-${string}-${string}-${string}-${string}`

• params.agentId?: `${string}-${string}-${string}-${string}-${string}`

• params.count?: number

• params.unique?: boolean

• params.tableName: string

• params.start?: number

• params.end?: number

• params.roomId?: `${string}-${string}-${string}-${string}-${string}`

• params.worldId?: `${string}-${string}-${string}-${string}-${string}`

Returns​

Promise<Memory[]>

Inherited from​

IDatabaseAdapter.getMemories

Defined in​

packages/core/src/specs/v2/types.ts:870


createRelationship()​

createRelationship(params): Promise<boolean>

Creates a new relationship between two entities.

Parameters​

• params

Object containing the relationship details

• params.sourceEntityId: `${string}-${string}-${string}-${string}-${string}`

• params.targetEntityId: `${string}-${string}-${string}-${string}-${string}`

• params.tags?: string[]

• params.metadata?

Returns​

Promise<boolean>

Promise resolving to boolean indicating success

Inherited from​

IDatabaseAdapter.createRelationship

Defined in​

packages/core/src/specs/v2/types.ts:989


updateRelationship()​

updateRelationship(relationship): Promise<void>

Updates an existing relationship between two entities.

Parameters​

• relationship: Relationship

The relationship object with updated data

Returns​

Promise<void>

Promise resolving to void

Inherited from​

IDatabaseAdapter.updateRelationship

Defined in​

packages/core/src/specs/v2/types.ts:1001


getRelationship()​

getRelationship(params): Promise<Relationship>

Retrieves a relationship between two entities if it exists.

Parameters​

• params

Object containing the entity IDs and agent ID

• params.sourceEntityId: `${string}-${string}-${string}-${string}-${string}`

• params.targetEntityId: `${string}-${string}-${string}-${string}-${string}`

Returns​

Promise<Relationship>

Promise resolving to the Relationship object or null if not found

Inherited from​

IDatabaseAdapter.getRelationship

Defined in​

packages/core/src/specs/v2/types.ts:1008


getRelationships()​

getRelationships(params): Promise<Relationship[]>

Retrieves all relationships for a specific entity.

Parameters​

• params

Object containing the user ID, agent ID and optional tags to filter by

• params.entityId: `${string}-${string}-${string}-${string}-${string}`

• params.tags?: string[]

Returns​

Promise<Relationship[]>

Promise resolving to an array of Relationship objects

Inherited from​

IDatabaseAdapter.getRelationships

Defined in​

packages/core/src/specs/v2/types.ts:1018


useModel()​

useModel<T, R>(modelType, params): Promise<R>

Use a model with strongly typed parameters and return values based on model type

Type Parameters​

• T extends string

The model type to use

• R = ModelResultMap[T]

The expected return type, defaults to the type defined in ModelResultMap[T]

Parameters​

• modelType: T

The type of model to use

• params: any

The parameters for the model, typed based on model type

Returns​

Promise<R>

  • The model result, typed based on the provided generic type parameter

Defined in​

packages/core/src/specs/v2/types.ts:1236


registerSendHandler()​

registerSendHandler(source, handler): void

Registers a handler function responsible for sending messages to a specific source/platform.

Parameters​

• source: string

The unique identifier string for the source (e.g., 'discord', 'telegram').

• handler: SendHandlerFunction

The SendHandlerFunction to be called for this source.

Returns​

void

Defined in​

packages/core/src/specs/v2/types.ts:1285


sendMessageToTarget()​

sendMessageToTarget(target, content): Promise<void>

Sends a message to a specified target using the appropriate registered handler.

Parameters​

• target: TargetInfo

Information describing the target recipient and platform.

• content: Content

The message content to send.

Returns​

Promise<void>

Promise resolving when the message sending process is initiated or completed.

Defined in​

packages/core/src/specs/v2/types.ts:1293