@ai16z/eliza v0.1.5-alpha.3 / AgentRuntime
Represents the runtime environment for an agent, handling message processing, action registration, and interaction with external services like OpenAI and Supabase.
new AgentRuntime(
opts
):AgentRuntime
Creates an instance of AgentRuntime.
• opts
The options for configuring the AgentRuntime.
• opts.conversationLength?: number
The number of messages to hold in the recent message cache.
• opts.agentId?: `${string}-${string}-${string}-${string}-${string}`
Optional ID of the agent.
• opts.character?: Character
• opts.token: string
The JWT token, can be a JWT token if outside worker, or an OpenAI token if inside worker.
• opts.serverUrl?: string
The URL of the worker.
• opts.actions?: Action
[]
Optional custom actions.
• opts.evaluators?: Evaluator
[]
Optional custom evaluators.
• opts.plugins?: Plugin
[]
• opts.providers?: Provider
[]
Optional context providers.
• opts.modelProvider: ModelProviderName
• opts.services?: Service
[]
Optional custom services.
• opts.managers?: IMemoryManager
[]
• opts.databaseAdapter: IDatabaseAdapter
The database adapter used for interacting with the database.
• opts.fetch?: unknown
Custom fetch function to use for making requests.
• opts.speechModelPath?: string
• opts.cacheManager: ICacheManager
• opts.logging?: boolean
packages/core/src/runtime.ts:208
agentId: `${string}-${string}-${string}-${string}-${string}`
The ID of the agent
packages/core/src/runtime.ts:63
serverUrl:
string
="http://localhost:7998"
The base URL of the server where the agent's requests are processed.
packages/core/src/runtime.ts:67
databaseAdapter:
IDatabaseAdapter
The database adapter used for interacting with the database.
packages/core/src/runtime.ts:72
token:
string
Authentication token used for securing requests.
packages/core/src/runtime.ts:77
actions:
Action
[] =[]
Custom actions that the agent can perform.
packages/core/src/runtime.ts:82
evaluators:
Evaluator
[] =[]
Evaluators used to assess and guide the agent's responses.
packages/core/src/runtime.ts:87
providers:
Provider
[] =[]
Context providers used to provide context for message generation.
packages/core/src/runtime.ts:92
plugins:
Plugin
[] =[]
packages/core/src/runtime.ts:94
modelProvider:
ModelProviderName
The model to use for generateText.
packages/core/src/runtime.ts:99
imageModelProvider:
ModelProviderName
The model to use for generateImage.
IAgentRuntime
.imageModelProvider
packages/core/src/runtime.ts:104
fetch: (
input
,init
?) =>Promise
<Response
>(input
,init
?) =>Promise
<Response
>
Fetch function to use Some environments may not have access to the global fetch function and need a custom fetch override.
• input: RequestInfo
| URL
• init?: RequestInit
Promise
<Response
>
• input: string
| Request
| URL
• init?: RequestInit
Promise
<Response
>
packages/core/src/runtime.ts:110
character:
Character
The character to use for the agent
packages/core/src/runtime.ts:115
messageManager:
IMemoryManager
Store messages that are sent and received by the agent.
packages/core/src/runtime.ts:120
descriptionManager:
IMemoryManager
Store and recall descriptions of users based on conversations.
IAgentRuntime
.descriptionManager
packages/core/src/runtime.ts:125
loreManager:
IMemoryManager
Manage the creation and recall of static information (documents, historical game lore, etc)
packages/core/src/runtime.ts:130
documentsManager:
IMemoryManager
Hold large documents that can be referenced
IAgentRuntime
.documentsManager
packages/core/src/runtime.ts:135
knowledgeManager:
IMemoryManager
Searchable document fragments
IAgentRuntime
.knowledgeManager
packages/core/src/runtime.ts:140
services:
Map
<ServiceType
,Service
>
packages/core/src/runtime.ts:142
memoryManagers:
Map
<string
,IMemoryManager
>
packages/core/src/runtime.ts:143
cacheManager:
ICacheManager
packages/core/src/runtime.ts:144
registerMemoryManager(
manager
):void
• manager: IMemoryManager
void
IAgentRuntime
.registerMemoryManager
packages/core/src/runtime.ts:146
getMemoryManager(
tableName
):IMemoryManager
• tableName: string
IAgentRuntime
.getMemoryManager
packages/core/src/runtime.ts:161
getService<
T
>(service
):T
• T extends Service
• service: ServiceType
T
packages/core/src/runtime.ts:165
registerService(
service
):Promise
<void
>
• service: Service
Promise
<void
>
packages/core/src/runtime.ts:174
initialize():
Promise
<void
>
Promise
<void
>
packages/core/src/runtime.ts:375
getSetting(
key
):any
• key: string
any
packages/core/src/runtime.ts:439
getConversationLength():
number
Get the number of messages that are kept in the conversation buffer.
number
The number of recent messages to be kept in memory.
IAgentRuntime
.getConversationLength
packages/core/src/runtime.ts:461
registerAction(
action
):void
Register an action for the agent to perform.
• action: Action
The action to register.
void
packages/core/src/runtime.ts:469
registerEvaluator(
evaluator
):void
Register an evaluator to assess and guide the agent's responses.
• evaluator: Evaluator
The evaluator to register.
void
packages/core/src/runtime.ts:478
registerContextProvider(
provider
):void
Register a context provider to provide context for message generation.
• provider: Provider
The context provider to register.
void
packages/core/src/runtime.ts:486
processActions(
message
,responses
,state
?,callback
?):Promise
<void
>
Process the actions of a message.
• message: Memory
The message to process.
• responses: Memory
[]
• state?: State
• callback?: HandlerCallback
Promise
<void
>
packages/core/src/runtime.ts:495
evaluate(
message
,state
?,didRespond
?):Promise
<string
[]>
Evaluate the message and state using the registered evaluators.
• message: Memory
The message to evaluate.
• state?: State
The state of the agent.
• didRespond?: boolean
Whether the agent responded to the message.
Promise
<string
[]>
The results of the evaluation.
packages/core/src/runtime.ts:572
ensureParticipantExists(
userId
,roomId
):Promise
<void
>
Ensure the existence of a participant in the room. If the participant does not exist, they are added to the room.
• userId: `${string}-${string}-${string}-${string}-${string}`
The user ID to ensure the existence of.
• roomId: `${string}-${string}-${string}-${string}-${string}`
Promise
<void
>
An error if the participant cannot be added.
IAgentRuntime
.ensureParticipantExists
packages/core/src/runtime.ts:642
ensureUserExists(
userId
,userName
,name
,source
?):Promise
<void
>
Ensure the existence of a user in the database. If the user does not exist, they are added to the database.
• userId: `${string}-${string}-${string}-${string}-${string}`
The user ID to ensure the existence of.
• userName: string
The user name to ensure the existence of.
• name: string
• email?: string
• source?: string
Promise
<void
>
IAgentRuntime
.ensureUserExists
packages/core/src/runtime.ts:658
ensureParticipantInRoom(
userId
,roomId
):Promise
<void
>
• userId: `${string}-${string}-${string}-${string}-${string}`
• roomId: `${string}-${string}-${string}-${string}-${string}`
Promise
<void
>
IAgentRuntime
.ensureParticipantInRoom
packages/core/src/runtime.ts:678
ensureConnection(
userId
,roomId
,userName
?,userScreenName
?,source
?):Promise
<void
>
• userId: `${string}-${string}-${string}-${string}-${string}`
• roomId: `${string}-${string}-${string}-${string}-${string}`
• userName?: string
• userScreenName?: string
• source?: string
Promise
<void
>
IAgentRuntime
.ensureConnection
packages/core/src/runtime.ts:695
ensureRoomExists(
roomId
):Promise
<void
>
Ensure the existence of a room between the agent and a user. If no room exists, a new room is created and the user and agent are added as participants. The room ID is returned.
• roomId: `${string}-${string}-${string}-${string}-${string}`
Promise
<void
>
The room ID of the room between the agent and the user.
An error if the room cannot be created.
IAgentRuntime
.ensureRoomExists
packages/core/src/runtime.ts:731
composeState(
message
,additionalKeys
):Promise
<State
>
Compose the state of the agent into an object that can be passed or used for response generation.
• message: Memory
The message to compose the state from.
• additionalKeys = {}
Promise
<State
>
The state of the agent.
packages/core/src/runtime.ts:744
updateRecentMessageState(
state
):Promise
<State
>
• state: State
Promise
<State
>