@elizaos/core 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,14 +1,1161 @@
1
- export * from './types';
2
- export * from './actions';
3
- export * from './database';
4
- export * from './entities';
5
- export * from './logger';
6
- export * from './prompts';
7
- export * from './roles';
8
- export * from './runtime';
9
- export * from './settings';
10
- export * from './utils';
11
- export * from './services';
12
- export * from './instrumentation/types';
13
- export * from './instrumentation/service';
14
- export * from './sentry/instrument';
1
+ import { A as Action, I as IDatabaseAdapter, U as UUID, E as Entity, C as Component, M as Memory, L as Log, a as MemoryMetadata, W as World, R as Room, P as Participant, b as Relationship, c as Agent, T as Task, d as IAgentRuntime, S as State, e as Role, f as Service, g as Character, h as Evaluator, i as Provider, j as Plugin, k as ServiceTypeName, l as ModelHandler, m as Route, n as RuntimeSettings, H as HandlerCallback, o as ChannelType, p as ModelTypeName, q as ModelResultMap, r as ModelParamsMap, s as TaskWorker, t as SendHandlerFunction, u as TargetInfo, v as Content, w as Setting, x as WorldSettings, O as OnboardingConfig, y as TemplateType, z as v2 } from './index-DVKkCFlY.js';
2
+ export { a_ as ActionEventPayload, D as ActionExample, ah as AgentStatus, aO as AudioProcessingParams, a0 as BaseMetadata, aG as BaseModelParams, aq as CacheKeyPrefix, as as ChunkRow, bn as ComponentData, ad as ContentType, bu as ControlMessage, a5 as CustomMetadata, bq as DbConnection, aA as DeriveKeyAttestationData, a4 as DescriptionMetadata, au as DetokenizeTextParams, ar as DirectoryItem, a1 as DocumentMetadata, ai as EmbeddingSearchResult, bm as EnhancedState, aW as EntityPayload, a9 as EvaluationExample, a$ as EvaluatorEventPayload, bo as EventDataObject, b3 as EventHandler, aU as EventPayload, b2 as EventPayloadMap, aS as EventType, a2 as FragmentMetadata, at as GenerateTextParams, a7 as Handler, aL as ImageDescriptionParams, aK as ImageGenerationParams, aY as InvokePayload, K as IsValidServiceType, aQ as JSONSchema, ao as KnowledgeItem, ap as KnowledgeScope, ac as Media, aj as MemoryRetrievalOptions, $ as MemoryScope, ak as MemorySearchOptions, _ as MemoryType, Z as MemoryTypeAlias, a6 as MessageExample, b5 as MessageMemory, a3 as MessageMetadata, aX as MessagePayload, b1 as MessageReceivedHandlerParams, br as MetadataObject, b0 as ModelEventPayload, F as ModelType, al as MultiRoomMemoryOptions, aR as ObjectGenerationParams, aT as PlatformPrefix, ae as PluginEvents, ag as Project, af as ProjectAgent, aa as ProviderResult, aB as RemoteAttestationMessage, az as RemoteAttestationQuote, ab as RoomMetadata, aZ as RunEventPayload, b4 as SOCKET_MESSAGE_TYPE, bv as ServiceBuilder, Q as ServiceClassMap, bs as ServiceConfig, bx as ServiceDefinition, be as ServiceError, V as ServiceInstance, X as ServiceRegistry, Y as ServiceType, G as ServiceTypeRegistry, J as ServiceTypeValue, bl as StateArray, bk as StateObject, bj as StateValue, ay as TEEMode, aF as TaskMetadata, ax as TeeAgent, aE as TeePluginConfig, aC as TeeType, aD as TeeVendorConfig, av as TestCase, aw as TestSuite, aI as TextEmbeddingParams, aH as TextGenerationParams, aN as TextToSpeechParams, aJ as TokenizeTextParams, aM as TranscriptionParams, bp as TypedEventHandler, b7 as TypedService, N as TypedServiceClass, am as UnifiedMemoryOptions, an as UnifiedSearchOptions, bt as VECTOR_DIMS, a8 as Validator, aP as VideoProcessingParams, aV as WorldPayload, B as asUUID, b6 as createMessageMemory, bw as createService, bi as createServiceError, by as defineService, bh as getMemoryText, b8 as getTypedService, bd as isCustomMetadata, bc as isDescriptionMetadata, bf as isDocumentMemory, b9 as isDocumentMetadata, bg as isFragmentMemory, ba as isFragmentMetadata, bb as isMessageMetadata } from './index-DVKkCFlY.js';
3
+ import { Pool } from 'pg';
4
+ import { PGlite } from '@electric-sql/pglite';
5
+ import * as pino from 'pino';
6
+ import { Tracer, Meter, Span, Context } from '@opentelemetry/api';
7
+ import * as browser from '@sentry/browser';
8
+ export { browser as Sentry };
9
+ export { i as v1 } from './index-Cy9ZgQIe.js';
10
+ import './types-DzoA9aTJ.js';
11
+ import 'stream';
12
+
13
+ /**
14
+ * Composes a set of example conversations based on provided actions and a specified count.
15
+ * It randomly selects examples from the provided actions and formats them with generated names.
16
+ *
17
+ * @param actionsData - An array of `Action` objects from which to draw examples.
18
+ * @param count - The number of examples to generate.
19
+ * @returns A string containing formatted examples of conversations.
20
+ */
21
+ declare const composeActionExamples: (actionsData: Action[], count: number) => string;
22
+ /**
23
+ * Formats the names of the provided actions into a comma-separated string.
24
+ * @param actions - An array of `Action` objects from which to extract names.
25
+ * @returns A comma-separated string of action names.
26
+ */
27
+ declare function formatActionNames(actions: Action[]): string;
28
+ /**
29
+ * Formats the provided actions into a detailed string listing each action's name and description.
30
+ * @param actions - An array of `Action` objects to format.
31
+ * @returns A detailed string of actions, including names and descriptions.
32
+ */
33
+ declare function formatActions(actions: Action[]): string;
34
+
35
+ /**
36
+ * An abstract class representing a database adapter for managing various entities
37
+ * like entities, memories, entities, goals, and rooms.
38
+ */
39
+ /**
40
+ * Database adapter class to be extended by individual database adapters.
41
+ *
42
+ * @template DB - The type of the database instance.
43
+ * @abstract
44
+ * implements IDatabaseAdapter
45
+ */
46
+ declare abstract class DatabaseAdapter<DB = unknown> implements IDatabaseAdapter {
47
+ /**
48
+ * The database instance.
49
+ */
50
+ db: DB;
51
+ /**
52
+ * Initialize the database adapter.
53
+ * @returns A Promise that resolves when initialization is complete.
54
+ */
55
+ abstract init(): Promise<void>;
56
+ /**
57
+ * Optional close method for the database adapter.
58
+ * @returns A Promise that resolves when closing is complete.
59
+ */
60
+ abstract close(): Promise<void>;
61
+ /**
62
+ * Retrieves a connection to the database.
63
+ * @returns A Promise that resolves to the database connection.
64
+ */
65
+ abstract getConnection(): Promise<PGlite | Pool>;
66
+ /**
67
+ * Retrieves an account by its ID.
68
+ * @param entityIds The UUIDs of the user account to retrieve.
69
+ * @returns A Promise that resolves to the Entity object or null if not found.
70
+ */
71
+ abstract getEntityByIds(entityIds: UUID[]): Promise<Entity[] | null>;
72
+ abstract getEntitiesForRoom(roomId: UUID, includeComponents?: boolean): Promise<Entity[]>;
73
+ /**
74
+ * Creates a new entities in the database.
75
+ * @param entities The entity objects to create.
76
+ * @returns A Promise that resolves when the account creation is complete.
77
+ */
78
+ abstract createEntities(entities: Entity[]): Promise<boolean>;
79
+ /**
80
+ * Updates an existing entity in the database.
81
+ * @param entity The entity object with updated properties.
82
+ * @returns A Promise that resolves when the account update is complete.
83
+ */
84
+ abstract updateEntity(entity: Entity): Promise<void>;
85
+ /**
86
+ * Retrieves a single component by entity ID and type.
87
+ * @param entityId The UUID of the entity the component belongs to
88
+ * @param type The type identifier for the component
89
+ * @param worldId Optional UUID of the world the component belongs to
90
+ * @param sourceEntityId Optional UUID of the source entity
91
+ * @returns Promise resolving to the Component if found, null otherwise
92
+ */
93
+ abstract getComponent(entityId: UUID, type: string, worldId?: UUID, sourceEntityId?: UUID): Promise<Component | null>;
94
+ /**
95
+ * Retrieves all components for an entity.
96
+ * @param entityId The UUID of the entity to get components for
97
+ * @param worldId Optional UUID of the world to filter components by
98
+ * @param sourceEntityId Optional UUID of the source entity to filter by
99
+ * @returns Promise resolving to array of Component objects
100
+ */
101
+ abstract getComponents(entityId: UUID, worldId?: UUID, sourceEntityId?: UUID): Promise<Component[]>;
102
+ /**
103
+ * Creates a new component in the database.
104
+ * @param component The component object to create
105
+ * @returns Promise resolving to true if creation was successful
106
+ */
107
+ abstract createComponent(component: Component): Promise<boolean>;
108
+ /**
109
+ * Updates an existing component in the database.
110
+ * @param component The component object with updated properties
111
+ * @returns Promise that resolves when the update is complete
112
+ */
113
+ abstract updateComponent(component: Component): Promise<void>;
114
+ /**
115
+ * Deletes a component from the database.
116
+ * @param componentId The UUID of the component to delete
117
+ * @returns Promise that resolves when the deletion is complete
118
+ */
119
+ abstract deleteComponent(componentId: UUID): Promise<void>;
120
+ /**
121
+ * Retrieves memories based on the specified parameters.
122
+ * @param params An object containing parameters for the memory retrieval.
123
+ * @returns A Promise that resolves to an array of Memory objects.
124
+ */
125
+ abstract getMemories(params: {
126
+ entityId?: UUID;
127
+ agentId?: UUID;
128
+ count?: number;
129
+ unique?: boolean;
130
+ tableName: string;
131
+ start?: number;
132
+ end?: number;
133
+ roomId?: UUID;
134
+ worldId?: UUID;
135
+ }): Promise<Memory[]>;
136
+ abstract getMemoriesByRoomIds(params: {
137
+ roomIds: UUID[];
138
+ tableName: string;
139
+ limit?: number;
140
+ }): Promise<Memory[]>;
141
+ abstract getMemoryById(id: UUID): Promise<Memory | null>;
142
+ /**
143
+ * Retrieves multiple memories by their IDs
144
+ * @param memoryIds Array of UUIDs of the memories to retrieve
145
+ * @param tableName Optional table name to filter memories by type
146
+ * @returns Promise resolving to array of Memory objects
147
+ */
148
+ abstract getMemoriesByIds(memoryIds: UUID[], tableName?: string): Promise<Memory[]>;
149
+ /**
150
+ * Retrieves cached embeddings based on the specified query parameters.
151
+ * @param params An object containing parameters for the embedding retrieval.
152
+ * @returns A Promise that resolves to an array of objects containing embeddings and levenshtein scores.
153
+ */
154
+ abstract getCachedEmbeddings({ query_table_name, query_threshold, query_input, query_field_name, query_field_sub_name, query_match_count, }: {
155
+ query_table_name: string;
156
+ query_threshold: number;
157
+ query_input: string;
158
+ query_field_name: string;
159
+ query_field_sub_name: string;
160
+ query_match_count: number;
161
+ }): Promise<{
162
+ embedding: number[];
163
+ levenshtein_score: number;
164
+ }[]>;
165
+ /**
166
+ * Logs an event or action with the specified details.
167
+ * @param params An object containing parameters for the log entry.
168
+ * @returns A Promise that resolves when the log entry has been saved.
169
+ */
170
+ abstract log(params: {
171
+ body: {
172
+ [key: string]: unknown;
173
+ };
174
+ entityId: UUID;
175
+ roomId: UUID;
176
+ type: string;
177
+ }): Promise<void>;
178
+ /**
179
+ * Retrieves logs based on the specified parameters.
180
+ * @param params An object containing parameters for the log retrieval.
181
+ * @returns A Promise that resolves to an array of Log objects.
182
+ */
183
+ abstract getLogs(params: {
184
+ entityId: UUID;
185
+ roomId?: UUID;
186
+ type?: string;
187
+ count?: number;
188
+ offset?: number;
189
+ }): Promise<Log[]>;
190
+ /**
191
+ * Deletes a log from the database.
192
+ * @param logId The UUID of the log to delete.
193
+ * @returns A Promise that resolves when the log has been deleted.
194
+ */
195
+ abstract deleteLog(logId: UUID): Promise<void>;
196
+ /**
197
+ * Searches for memories based on embeddings and other specified parameters.
198
+ * @param params An object containing parameters for the memory search.
199
+ * @returns A Promise that resolves to an array of Memory objects.
200
+ */
201
+ abstract searchMemories(params: {
202
+ tableName: string;
203
+ embedding: number[];
204
+ match_threshold?: number;
205
+ count?: number;
206
+ unique?: boolean;
207
+ query?: string;
208
+ roomId?: UUID;
209
+ worldId?: UUID;
210
+ entityId?: UUID;
211
+ }): Promise<Memory[]>;
212
+ /**
213
+ * Creates a new memory in the database.
214
+ * @param memory The memory object to create.
215
+ * @param tableName The table where the memory should be stored.
216
+ * @param unique Indicates if the memory should be unique.
217
+ * @returns A Promise that resolves when the memory has been created.
218
+ */
219
+ abstract createMemory(memory: Memory, tableName: string, unique?: boolean): Promise<UUID>;
220
+ /**
221
+ * Updates an existing memory in the database.
222
+ * @param memory The memory object with updated content and optional embedding
223
+ * @returns Promise resolving to boolean indicating success
224
+ */
225
+ abstract updateMemory(memory: Partial<Memory> & {
226
+ id: UUID;
227
+ metadata?: MemoryMetadata;
228
+ }): Promise<boolean>;
229
+ /**
230
+ * Removes a specific memory from the database.
231
+ * @param memoryId The UUID of the memory to remove.
232
+ * @returns A Promise that resolves when the memory has been removed.
233
+ */
234
+ abstract deleteMemory(memoryId: UUID): Promise<void>;
235
+ /**
236
+ * Removes all memories associated with a specific room.
237
+ * @param roomId The UUID of the room whose memories should be removed.
238
+ * @param tableName The table from which the memories should be removed.
239
+ * @returns A Promise that resolves when all memories have been removed.
240
+ */
241
+ abstract deleteAllMemories(roomId: UUID, tableName: string): Promise<void>;
242
+ /**
243
+ * Counts the number of memories in a specific room.
244
+ * @param roomId The UUID of the room for which to count memories.
245
+ * @param unique Specifies whether to count only unique memories.
246
+ * @param tableName Optional table name to count memories from.
247
+ * @returns A Promise that resolves to the number of memories.
248
+ */
249
+ abstract countMemories(roomId: UUID, unique?: boolean, tableName?: string): Promise<number>;
250
+ /**
251
+ * Retrieves a world by its ID.
252
+ * @param id The UUID of the world to retrieve.
253
+ * @returns A Promise that resolves to the World object or null if not found.
254
+ */
255
+ abstract getWorld(id: UUID): Promise<World | null>;
256
+ /**
257
+ * Retrieves all worlds for an agent.
258
+ * @returns A Promise that resolves to an array of World objects.
259
+ */
260
+ abstract getAllWorlds(): Promise<World[]>;
261
+ /**
262
+ * Creates a new world in the database.
263
+ * @param world The world object to create.
264
+ * @returns A Promise that resolves to the UUID of the created world.
265
+ */
266
+ abstract createWorld(world: World): Promise<UUID>;
267
+ /**
268
+ * Updates an existing world in the database.
269
+ * @param world The world object with updated properties.
270
+ * @returns A Promise that resolves when the world has been updated.
271
+ */
272
+ abstract updateWorld(world: World): Promise<void>;
273
+ /**
274
+ * Removes a specific world from the database.
275
+ * @param id The UUID of the world to remove.
276
+ * @returns A Promise that resolves when the world has been removed.
277
+ */
278
+ abstract removeWorld(id: UUID): Promise<void>;
279
+ /**
280
+ * Retrieves the room ID for a given room, if it exists.
281
+ * @param roomId The UUID of the room to retrieve.
282
+ * @returns A Promise that resolves to the room ID or null if not found.
283
+ */
284
+ abstract getRoomsByIds(roomIds: UUID[]): Promise<Room[] | null>;
285
+ /**
286
+ * Retrieves all rooms for a given world.
287
+ * @param worldId The UUID of the world to retrieve rooms for.
288
+ * @returns A Promise that resolves to an array of Room objects.
289
+ */
290
+ abstract getRoomsByWorld(worldId: UUID): Promise<Room[]>;
291
+ /**
292
+ * Creates a new rooms with an optional specified ID.
293
+ * @param roomId Optional UUID to assign to the new room.
294
+ * @returns A Promise that resolves to the UUID of the created rooms.
295
+ */
296
+ abstract createRooms(rooms: Room[]): Promise<UUID[]>;
297
+ /**
298
+ * Updates a specific room in the database.
299
+ * @param room The room object with updated properties.
300
+ * @returns A Promise that resolves when the room has been updated.
301
+ */
302
+ abstract updateRoom(room: Room): Promise<void>;
303
+ /**
304
+ * Removes a specific room from the database.
305
+ * @param roomId The UUID of the room to remove.
306
+ * @returns A Promise that resolves when the room has been removed.
307
+ */
308
+ abstract deleteRoom(roomId: UUID): Promise<void>;
309
+ /**
310
+ * Retrieves room IDs for which a specific user is a participant.
311
+ * @param entityId The UUID of the user.
312
+ * @returns A Promise that resolves to an array of room IDs.
313
+ */
314
+ abstract getRoomsForParticipant(entityId: UUID): Promise<UUID[]>;
315
+ /**
316
+ * Retrieves room IDs for which specific users are participants.
317
+ * @param userIds An array of UUIDs of the users.
318
+ * @returns A Promise that resolves to an array of room IDs.
319
+ */
320
+ abstract getRoomsForParticipants(userIds: UUID[]): Promise<UUID[]>;
321
+ /**
322
+ * Adds users as a participant to a specific room.
323
+ * @param entityIds The UUIDs of the users to add as a participant.
324
+ * @param roomId The UUID of the room to which the user will be added.
325
+ * @returns A Promise that resolves to a boolean indicating success or failure.
326
+ */
327
+ abstract addParticipantsRoom(entityIds: UUID[], roomId: UUID): Promise<boolean>;
328
+ /**
329
+ * Removes a user as a participant from a specific room.
330
+ * @param entityId The UUID of the user to remove as a participant.
331
+ * @param roomId The UUID of the room from which the user will be removed.
332
+ * @returns A Promise that resolves to a boolean indicating success or failure.
333
+ */
334
+ abstract removeParticipant(entityId: UUID, roomId: UUID): Promise<boolean>;
335
+ /**
336
+ * Retrieves participants associated with a specific account.
337
+ * @param entityId The UUID of the account.
338
+ * @returns A Promise that resolves to an array of Participant objects.
339
+ */
340
+ abstract getParticipantsForEntity(entityId: UUID): Promise<Participant[]>;
341
+ /**
342
+ * Retrieves participants for a specific room.
343
+ * @param roomId The UUID of the room for which to retrieve participants.
344
+ * @returns A Promise that resolves to an array of UUIDs representing the participants.
345
+ */
346
+ abstract getParticipantsForRoom(roomId: UUID): Promise<UUID[]>;
347
+ abstract getParticipantUserState(roomId: UUID, entityId: UUID): Promise<'FOLLOWED' | 'MUTED' | null>;
348
+ abstract setParticipantUserState(roomId: UUID, entityId: UUID, state: 'FOLLOWED' | 'MUTED' | null): Promise<void>;
349
+ /**
350
+ * Creates a new relationship between two users.
351
+ * @param params Object containing the relationship details including entity IDs, agent ID, optional tags and metadata
352
+ * @returns A Promise that resolves to a boolean indicating success or failure of the creation.
353
+ */
354
+ abstract createRelationship(params: {
355
+ sourceEntityId: UUID;
356
+ targetEntityId: UUID;
357
+ tags?: string[];
358
+ metadata?: Record<string, unknown>;
359
+ }): Promise<boolean>;
360
+ /**
361
+ * Retrieves a relationship between two users if it exists.
362
+ * @param params Object containing the entity IDs and agent ID
363
+ * @returns A Promise that resolves to the Relationship object or null if not found.
364
+ */
365
+ abstract getRelationship(params: {
366
+ sourceEntityId: UUID;
367
+ targetEntityId: UUID;
368
+ }): Promise<Relationship | null>;
369
+ /**
370
+ * Retrieves all relationships for a specific user.
371
+ * @param params Object containing the user ID, agent ID and optional tags to filter by
372
+ * @returns A Promise that resolves to an array of Relationship objects.
373
+ */
374
+ abstract getRelationships(params: {
375
+ entityId: UUID;
376
+ tags?: string[];
377
+ }): Promise<Relationship[]>;
378
+ /**
379
+ * Updates an existing relationship between two users.
380
+ * @param params Object containing the relationship details to update including entity IDs, agent ID, optional tags and metadata
381
+ * @returns A Promise that resolves to a boolean indicating success or failure of the update.
382
+ */
383
+ abstract updateRelationship(params: {
384
+ sourceEntityId: UUID;
385
+ targetEntityId: UUID;
386
+ tags?: string[];
387
+ metadata?: Record<string, unknown>;
388
+ }): Promise<void>;
389
+ /**
390
+ * Retrieves an agent by its ID.
391
+ * @param agentId The UUID of the agent to retrieve.
392
+ * @returns A Promise that resolves to the Agent object or null if not found.
393
+ */
394
+ abstract getAgent(agentId: UUID): Promise<Agent | null>;
395
+ /**
396
+ * Retrieves all agents from the database.
397
+ * @returns A Promise that resolves to an array of Agent objects.
398
+ */
399
+ abstract getAgents(): Promise<Partial<Agent>[]>;
400
+ /**
401
+ * Creates a new agent in the database.
402
+ * @param agent The agent object to create.
403
+ * @returns A Promise that resolves to a boolean indicating success or failure of the creation.
404
+ */
405
+ abstract createAgent(agent: Partial<Agent>): Promise<boolean>;
406
+ /**
407
+ * Updates an existing agent in the database.
408
+ * @param agentId The UUID of the agent to update.
409
+ * @param agent The agent object with updated properties.
410
+ * @returns A Promise that resolves to a boolean indicating success or failure of the update.
411
+ */
412
+ abstract updateAgent(agentId: UUID, agent: Partial<Agent>): Promise<boolean>;
413
+ /**
414
+ * Deletes an agent from the database.
415
+ * @param agentId The UUID of the agent to delete.
416
+ * @returns A Promise that resolves to a boolean indicating success or failure of the deletion.
417
+ */
418
+ abstract deleteAgent(agentId: UUID): Promise<boolean>;
419
+ /**
420
+ * Ensures an agent exists in the database.
421
+ * @param agent The agent object to ensure exists.
422
+ * @returns A Promise that resolves when the agent has been ensured to exist.
423
+ */
424
+ abstract ensureAgentExists(agent: Partial<Agent>): Promise<Agent>;
425
+ /**
426
+ * Ensures an embedding dimension exists in the database.
427
+ * @param dimension The dimension to ensure exists.
428
+ * @returns A Promise that resolves when the embedding dimension has been ensured to exist.
429
+ */
430
+ abstract ensureEmbeddingDimension(dimension: number): Promise<void>;
431
+ /**
432
+ * Retrieves a cached value by key from the database.
433
+ * @param key The key to look up in the cache
434
+ * @returns Promise resolving to the cached string value
435
+ */
436
+ abstract getCache<T>(key: string): Promise<T | undefined>;
437
+ /**
438
+ * Sets a value in the cache with the given key.
439
+ * @param params Object containing the cache key and value
440
+ * @param key The key to store the value under
441
+ * @param value The string value to cache
442
+ * @returns Promise resolving to true if the cache was set successfully
443
+ */
444
+ abstract setCache<T>(key: string, value: T): Promise<boolean>;
445
+ /**
446
+ * Deletes a value from the cache by key.
447
+ * @param key The key to delete from the cache
448
+ * @returns Promise resolving to true if the value was successfully deleted
449
+ */
450
+ abstract deleteCache(key: string): Promise<boolean>;
451
+ /**
452
+ * Creates a new task instance in the database.
453
+ * @param task The task object to create
454
+ * @returns Promise resolving to the UUID of the created task
455
+ */
456
+ abstract createTask(task: Task): Promise<UUID>;
457
+ /**
458
+ * Retrieves tasks based on specified parameters.
459
+ * @param params Object containing optional roomId and tags to filter tasks
460
+ * @returns Promise resolving to an array of Task objects
461
+ */
462
+ abstract getTasks(params: {
463
+ roomId?: UUID;
464
+ tags?: string[];
465
+ entityId?: UUID;
466
+ }): Promise<Task[]>;
467
+ /**
468
+ * Retrieves a specific task by its ID.
469
+ * @param id The UUID of the task to retrieve
470
+ * @returns Promise resolving to the Task object if found, null otherwise
471
+ */
472
+ abstract getTask(id: UUID): Promise<Task | null>;
473
+ /**
474
+ * Retrieves a specific task by its name.
475
+ * @param name The name of the task to retrieve
476
+ * @returns Promise resolving to the Task object if found, null otherwise
477
+ */
478
+ abstract getTasksByName(name: string): Promise<Task[]>;
479
+ /**
480
+ * Updates an existing task in the database.
481
+ * @param id The UUID of the task to update
482
+ * @param task Partial Task object containing the fields to update
483
+ * @returns Promise resolving when the update is complete
484
+ */
485
+ abstract updateTask(id: UUID, task: Partial<Task>): Promise<void>;
486
+ /**
487
+ * Deletes a task from the database.
488
+ * @param id The UUID of the task to delete
489
+ * @returns Promise resolving when the deletion is complete
490
+ */
491
+ abstract deleteTask(id: UUID): Promise<void>;
492
+ abstract getMemoriesByWorldId(params: {
493
+ worldId: UUID;
494
+ count?: number;
495
+ tableName?: string;
496
+ }): Promise<Memory[]>;
497
+ abstract deleteRoomsByWorldId(worldId: UUID): Promise<void>;
498
+ }
499
+
500
+ /**
501
+ * Finds an entity by name in the given runtime environment.
502
+ *
503
+ * @param {IAgentRuntime} runtime - The agent runtime environment.
504
+ * @param {Memory} message - The memory message containing relevant information.
505
+ * @param {State} state - The current state of the system.
506
+ * @returns {Promise<Entity | null>} A promise that resolves to the found entity or null if not found.
507
+ */
508
+ declare function findEntityByName(runtime: IAgentRuntime, message: Memory, state: State): Promise<Entity | null>;
509
+ /**
510
+ * Function to create a unique UUID based on the runtime and base user ID.
511
+ *
512
+ * @param {RuntimeContext} runtime - The runtime context object.
513
+ * @param {UUID|string} baseUserId - The base user ID to use in generating the UUID.
514
+ * @returns {UUID} - The unique UUID generated based on the runtime and base user ID.
515
+ */
516
+ declare const createUniqueUuid: (runtime: any, baseUserId: UUID | string) => UUID;
517
+ /**
518
+ * Get details for a list of entities.
519
+ */
520
+ /**
521
+ * Retrieves entity details for a specific room from the database.
522
+ *
523
+ * @param {Object} params - The input parameters
524
+ * @param {IAgentRuntime} params.runtime - The Agent Runtime instance
525
+ * @param {UUID} params.roomId - The ID of the room to retrieve entity details for
526
+ * @returns {Promise<Array>} - A promise that resolves to an array of unique entity details
527
+ */
528
+ declare function getEntityDetails({ runtime, roomId, }: {
529
+ runtime: IAgentRuntime;
530
+ roomId: UUID;
531
+ }): Promise<any[]>;
532
+ /**
533
+ * Format entities into a string
534
+ * @param entities - list of entities
535
+ * @returns string
536
+ */
537
+ /**
538
+ * Format the given entities into a string representation.
539
+ *
540
+ * @param {Object} options - The options object.
541
+ * @param {Entity[]} options.entities - The list of entities to format.
542
+ * @returns {string} A formatted string representing the entities.
543
+ */
544
+ declare function formatEntities({ entities }: {
545
+ entities: Entity[];
546
+ }): string;
547
+
548
+ declare let logger: pino.Logger<string, boolean>;
549
+ declare const createLogger: (bindings?: {}) => pino.Logger<never, boolean>;
550
+
551
+ declare const elizaLogger: pino.Logger<string, boolean>;
552
+
553
+ declare const shouldRespondTemplate = "<task>Decide on behalf of {{agentName}} whether they should respond to the message, ignore it or stop the conversation.</task>\n\n<providers>\n{{providers}}\n</providers>\n\n<instructions>Decide if {{agentName}} should respond to or interact with the conversation.\nIf the message is directed at or relevant to {{agentName}}, respond with RESPOND action.\nIf a user asks {{agentName}} to be quiet, respond with STOP action.\nIf {{agentName}} should ignore the message, respond with IGNORE action.</instructions>\n\n<output>\nDo NOT include any thinking, reasoning, or <think> sections in your response. \nGo directly to the XML response format without any preamble or explanation.\n\nRespond using XML format like this:\n<response>\n <name>{{agentName}}</name>\n <reasoning>Your reasoning here</reasoning>\n <action>RESPOND | IGNORE | STOP</action>\n</response>\n\nIMPORTANT: Your response must ONLY contain the <response></response> XML block above. Do not include any text, thinking, or reasoning before or after this XML block. Start your response immediately with <response> and end with </response>.\n</output>";
554
+ declare const messageHandlerTemplate = "<task>Generate dialog and actions for the character {{agentName}}.</task>\n\n<providers>\n{{providers}}\n</providers>\n\nThese are the available valid actions:\n<actionNames>\n{{actionNames}}\n</actionNames>\n\n<instructions>\nWrite a thought and plan for {{agentName}} and decide what actions to take. Also include the providers that {{agentName}} will use to have the right context for responding and acting, if any.\n\nIMPORTANT PROVIDER SELECTION RULES:\n- If the message mentions images, photos, pictures, attachments, or visual content, OR if you see \"(Attachments:\" in the conversation, you MUST include \"ATTACHMENTS\" in your providers list\n- If the message asks about or references specific people, include \"ENTITIES\" in your providers list \n- If the message asks about relationships or connections between people, include \"RELATIONSHIPS\" in your providers list\n- If the message asks about facts or specific information, include \"FACTS\" in your providers list\n- If the message asks about the environment or world context, include \"WORLD\" in your providers list\n- If you need external knowledge, information, or context beyond the current conversation to provide a helpful response, include \"KNOWLEDGE\" in your providers list\n\nFirst, think about what you want to do next and plan your actions. Then, write the next message and include the actions you plan to take.\n</instructions>\n\n<keys>\n\"thought\" should be a short description of what the agent is thinking about and planning.\n\"actions\" should be a comma-separated list of the actions {{agentName}} plans to take based on the thought (if none, use IGNORE, if simply responding with text, use REPLY)\n\"providers\" should be a comma-separated list of the providers that {{agentName}} will use to have the right context for responding and acting (NEVER use \"IGNORE\" as a provider - use specific provider names like ATTACHMENTS, ENTITIES, FACTS, KNOWLEDGE, etc.)\n\"evaluators\" should be an optional comma-separated list of the evaluators that {{agentName}} will use to evaluate the conversation after responding\n\"text\" should be the text of the next message for {{agentName}} which they will send to the conversation.\n</keys>\n\n<output>\nDo NOT include any thinking, reasoning, or <think> sections in your response. \nGo directly to the XML response format without any preamble or explanation.\n\nRespond using XML format like this:\n<response>\n <thought>Your thought here</thought>\n <actions>ACTION1,ACTION2</actions>\n <providers>PROVIDER1,PROVIDER2</providers>\n <text>Your response text here</text>\n</response>\n\nIMPORTANT: Your response must ONLY contain the <response></response> XML block above. Do not include any text, thinking, or reasoning before or after this XML block. Start your response immediately with <response> and end with </response>.\n</output>";
555
+ declare const postCreationTemplate = "# Task: Create a post in the voice and style and perspective of {{agentName}} @{{twitterUserName}}.\n\nExample task outputs:\n1. A post about the importance of AI in our lives\n<response>\n <thought>I am thinking about writing a post about the importance of AI in our lives</thought>\n <post>AI is changing the world and it is important to understand how it works</post>\n <imagePrompt>A futuristic cityscape with flying cars and people using AI to do things</imagePrompt>\n</response>\n\n2. A post about dogs\n<response>\n <thought>I am thinking about writing a post about dogs</thought>\n <post>Dogs are man's best friend and they are loyal and loving</post>\n <imagePrompt>A dog playing with a ball in a park</imagePrompt>\n</response>\n\n3. A post about finding a new job\n<response>\n <thought>Getting a job is hard, I bet there's a good tweet in that</thought>\n <post>Just keep going!</post>\n <imagePrompt>A person looking at a computer screen with a job search website</imagePrompt>\n</response>\n\n{{providers}}\n\nWrite a post that is {{adjective}} about {{topic}} (without mentioning {{topic}} directly), from the perspective of {{agentName}}. Do not add commentary or acknowledge this request, just write the post.\nYour response should be 1, 2, or 3 sentences (choose the length at random).\nYour response should not contain any questions. Brief, concise statements only. The total character count MUST be less than 280. No emojis. Use \\n\\n (double spaces) between statements if there are multiple statements in your response.\n\nYour output should be formatted in XML like this:\n<response>\n <thought>Your thought here</thought>\n <post>Your post text here</post>\n <imagePrompt>Optional image prompt here</imagePrompt>\n</response>\n\nThe \"post\" field should be the post you want to send. Do not including any thinking or internal reflection in the \"post\" field.\nThe \"imagePrompt\" field is optional and should be a prompt for an image that is relevant to the post. It should be a single sentence that captures the essence of the post. ONLY USE THIS FIELD if it makes sense that the post would benefit from an image.\nThe \"thought\" field should be a short description of what the agent is thinking about before responding, inlcuding a brief justification for the response. Includate an explanation how the post is relevant to the topic but unique and different than other posts.\n\nDo NOT include any thinking, reasoning, or <think> sections in your response. \nGo directly to the XML response format without any preamble or explanation.\n\nIMPORTANT: Your response must ONLY contain the <response></response> XML block above. Do not include any text, thinking, or reasoning before or after this XML block. Start your response immediately with <response> and end with </response>.";
556
+ declare const booleanFooter = "Respond with only a YES or a NO.";
557
+ declare const imageDescriptionTemplate = "<task>Analyze the provided image and generate a comprehensive description with multiple levels of detail.</task>\n\n<instructions>\nCarefully examine the image and provide:\n1. A concise, descriptive title that captures the main subject or scene\n2. A brief summary description (1-2 sentences) highlighting the key elements\n3. An extensive, detailed description that covers all visible elements, composition, lighting, colors, mood, and any other relevant details\n\nBe objective and descriptive. Focus on what you can actually see in the image rather than making assumptions about context or meaning.\n</instructions>\n\n<output>\nDo NOT include any thinking, reasoning, or <think> sections in your response. \nGo directly to the XML response format without any preamble or explanation.\n\nRespond using XML format like this:\n<response>\n <title>A concise, descriptive title for the image</title>\n <description>A brief 1-2 sentence summary of the key elements in the image</description>\n <text>An extensive, detailed description covering all visible elements, composition, lighting, colors, mood, setting, objects, people, activities, and any other relevant details you can observe in the image</text>\n</response>\n\nIMPORTANT: Your response must ONLY contain the <response></response> XML block above. Do not include any text, thinking, or reasoning before or after this XML block. Start your response immediately with <response> and end with </response>.\n</output>";
558
+
559
+ /**
560
+ * Represents the state of server ownership, including a mapping of server IDs to their respective World objects.
561
+ */
562
+ /**
563
+ * Interface representing the ownership state of servers.
564
+ * @property {Object.<string, World>} servers - The servers and their corresponding worlds, where the key is the server ID and the value is the World object.
565
+ */
566
+ interface ServerOwnershipState {
567
+ servers: {
568
+ [serverId: string]: World;
569
+ };
570
+ }
571
+ /**
572
+ * Gets a user's role from world metadata
573
+ */
574
+ /**
575
+ * Retrieve the server role of a specified user entity within a given server.
576
+ *
577
+ * @param {IAgentRuntime} runtime - The runtime object containing necessary configurations and services.
578
+ * @param {string} entityId - The unique identifier of the user entity.
579
+ * @param {string} serverId - The unique identifier of the server.
580
+ * @returns {Promise<Role>} The role of the user entity within the server, resolved as a Promise.
581
+ */
582
+ declare function getUserServerRole(runtime: IAgentRuntime, entityId: string, serverId: string): Promise<Role>;
583
+ /**
584
+ * Finds a server where the given user is the owner
585
+ */
586
+ declare function findWorldsForOwner(runtime: IAgentRuntime, entityId: string): Promise<World[] | null>;
587
+
588
+ interface InstrumentationConfig {
589
+ serviceName?: string;
590
+ otlpEndpoint?: string;
591
+ enabled?: boolean;
592
+ }
593
+ interface IInstrumentationService {
594
+ readonly name: string;
595
+ readonly capabilityDescription: string;
596
+ instrumentationConfig: InstrumentationConfig;
597
+ isEnabled(): boolean;
598
+ getTracer(name?: string, version?: string): Tracer | null;
599
+ getMeter(name?: string, version?: string): Meter | null;
600
+ flush(): Promise<void>;
601
+ stop(): Promise<void>;
602
+ }
603
+
604
+ declare class InstrumentationService extends Service implements IInstrumentationService {
605
+ static serviceType: "instrumentation";
606
+ readonly name = "INSTRUMENTATION";
607
+ readonly capabilityDescription = "Provides OpenTelemetry tracing and metrics capabilities.";
608
+ instrumentationConfig: InstrumentationConfig;
609
+ private resource;
610
+ private tracerProvider;
611
+ private meterProvider;
612
+ private isShutdown;
613
+ constructor(config?: InstrumentationConfig);
614
+ private initializeProviders;
615
+ isEnabled(): boolean;
616
+ getTracer(name?: string, version?: string): Tracer | null;
617
+ getMeter(name?: string, version?: string): Meter | null;
618
+ flush(): Promise<void>;
619
+ stop(): Promise<void>;
620
+ static start(runtime: IAgentRuntime, config?: InstrumentationConfig): Promise<InstrumentationService>;
621
+ }
622
+
623
+ declare class Semaphore {
624
+ private permits;
625
+ private waiting;
626
+ constructor(count: number);
627
+ acquire(): Promise<void>;
628
+ release(): void;
629
+ }
630
+ declare class AgentRuntime implements IAgentRuntime {
631
+ #private;
632
+ readonly agentId: UUID;
633
+ readonly character: Character;
634
+ adapter: IDatabaseAdapter;
635
+ readonly actions: Action[];
636
+ readonly evaluators: Evaluator[];
637
+ readonly providers: Provider[];
638
+ readonly plugins: Plugin[];
639
+ private isInitialized;
640
+ events: Map<string, ((params: any) => Promise<void>)[]>;
641
+ stateCache: Map<`${string}-${string}-${string}-${string}-${string}`, {
642
+ values: {
643
+ [key: string]: any;
644
+ };
645
+ data: {
646
+ [key: string]: any;
647
+ };
648
+ text: string;
649
+ }>;
650
+ readonly fetch: typeof fetch;
651
+ services: Map<ServiceTypeName, Service>;
652
+ private serviceTypes;
653
+ models: Map<string, ModelHandler[]>;
654
+ routes: Route[];
655
+ private taskWorkers;
656
+ private sendHandlers;
657
+ private eventHandlers;
658
+ private allAvailablePlugins;
659
+ private characterPlugins;
660
+ logger: any;
661
+ private settings;
662
+ private servicesInitQueue;
663
+ instrumentationService: InstrumentationService;
664
+ tracer: any;
665
+ constructor(opts: {
666
+ conversationLength?: number;
667
+ agentId?: UUID;
668
+ character?: Character;
669
+ plugins?: Plugin[];
670
+ fetch?: typeof fetch;
671
+ adapter?: IDatabaseAdapter;
672
+ settings?: RuntimeSettings;
673
+ events?: {
674
+ [key: string]: ((params: any) => void)[];
675
+ };
676
+ allAvailablePlugins?: Plugin[];
677
+ });
678
+ startSpan<T>(name: string, fn: (span: Span) => Promise<T>, parentContext?: Context): Promise<T>;
679
+ endSpan(ctx: Context | undefined, name: string): void;
680
+ startActiveSpan(name: string, options?: any): Span;
681
+ registerPlugin(plugin: Plugin): Promise<void>;
682
+ private resolvePluginDependencies;
683
+ getAllServices(): Map<ServiceTypeName, Service>;
684
+ stop(): Promise<void>;
685
+ initialize(): Promise<void>;
686
+ getConnection(): Promise<PGlite | Pool>;
687
+ setSetting(key: string, value: string | boolean | null | any, secret?: boolean): void;
688
+ getSetting(key: string): string | boolean | null | any;
689
+ getConversationLength(): number;
690
+ registerDatabaseAdapter(adapter: IDatabaseAdapter): void;
691
+ registerProvider(provider: Provider): void;
692
+ registerAction(action: Action): void;
693
+ registerEvaluator(evaluator: Evaluator): void;
694
+ processActions(message: Memory, responses: Memory[], state?: State, callback?: HandlerCallback): Promise<void>;
695
+ evaluate(message: Memory, state: State, didRespond?: boolean, callback?: HandlerCallback, responses?: Memory[]): Promise<Evaluator[]>;
696
+ ensureConnection({ entityId, roomId, worldId, worldName, userName, name, source, type, channelId, serverId, userId, metadata, }: {
697
+ entityId: UUID;
698
+ roomId: UUID;
699
+ worldId: UUID;
700
+ worldName?: string;
701
+ userName?: string;
702
+ name?: string;
703
+ source?: string;
704
+ type?: ChannelType;
705
+ channelId?: string;
706
+ serverId?: string;
707
+ userId?: UUID;
708
+ metadata?: Record<string, any>;
709
+ }): Promise<void>;
710
+ ensureParticipantInRoom(entityId: UUID, roomId: UUID): Promise<void>;
711
+ removeParticipant(entityId: UUID, roomId: UUID): Promise<boolean>;
712
+ getParticipantsForEntity(entityId: UUID): Promise<Participant[]>;
713
+ getParticipantsForRoom(roomId: UUID): Promise<UUID[]>;
714
+ addParticipant(entityId: UUID, roomId: UUID): Promise<boolean>;
715
+ addParticipantsRoom(entityIds: UUID[], roomId: UUID): Promise<boolean>;
716
+ /**
717
+ * Ensure the existence of a world.
718
+ */
719
+ ensureWorldExists({ id, name, serverId, metadata }: World): Promise<void>;
720
+ ensureRoomExists({ id, name, source, type, channelId, serverId, worldId, metadata }: Room): Promise<void>;
721
+ composeState(message: Memory, includeList?: string[] | null, onlyInclude?: boolean, skipCache?: boolean): Promise<State>;
722
+ getService<T extends Service = Service>(serviceName: ServiceTypeName | string): T | null;
723
+ /**
724
+ * Type-safe service getter that ensures the correct service type is returned
725
+ * @template T - The expected service class type
726
+ * @param serviceName - The service type name
727
+ * @returns The service instance with proper typing, or null if not found
728
+ */
729
+ getTypedService<T extends Service = Service>(serviceName: ServiceTypeName | string): T | null;
730
+ /**
731
+ * Get all registered service types
732
+ * @returns Array of registered service type names
733
+ */
734
+ getRegisteredServiceTypes(): ServiceTypeName[];
735
+ /**
736
+ * Check if a service type is registered
737
+ * @param serviceType - The service type to check
738
+ * @returns true if the service is registered
739
+ */
740
+ hasService(serviceType: ServiceTypeName | string): boolean;
741
+ registerService(serviceDef: typeof Service): Promise<void>;
742
+ registerModel(modelType: ModelTypeName, handler: (params: any) => Promise<any>, provider: string, priority?: number): void;
743
+ getModel(modelType: ModelTypeName, provider?: string): ((runtime: IAgentRuntime, params: any) => Promise<any>) | undefined;
744
+ useModel<T extends ModelTypeName, R = ModelResultMap[T]>(modelType: T, params: Omit<ModelParamsMap[T], 'runtime'> | any, provider?: string): Promise<R>;
745
+ registerEvent(event: string, handler: (params: any) => Promise<void>): void;
746
+ getEvent(event: string): ((params: any) => Promise<void>)[] | undefined;
747
+ emitEvent(event: string | string[], params: any): Promise<void>;
748
+ ensureEmbeddingDimension(): Promise<void>;
749
+ registerTaskWorker(taskHandler: TaskWorker): void;
750
+ getTaskWorker(name: string): TaskWorker | undefined;
751
+ get db(): any;
752
+ init(): Promise<void>;
753
+ close(): Promise<void>;
754
+ getAgent(agentId: UUID): Promise<Agent | null>;
755
+ getAgents(): Promise<Partial<Agent>[]>;
756
+ createAgent(agent: Partial<Agent>): Promise<boolean>;
757
+ updateAgent(agentId: UUID, agent: Partial<Agent>): Promise<boolean>;
758
+ deleteAgent(agentId: UUID): Promise<boolean>;
759
+ ensureAgentExists(agent: Partial<Agent>): Promise<Agent>;
760
+ getEntityById(entityId: UUID): Promise<Entity | null>;
761
+ getEntityByIds(entityIds: UUID[]): Promise<Entity[] | null>;
762
+ getEntitiesForRoom(roomId: UUID, includeComponents?: boolean): Promise<Entity[]>;
763
+ createEntity(entity: Entity): Promise<boolean>;
764
+ createEntities(entities: Entity[]): Promise<boolean>;
765
+ updateEntity(entity: Entity): Promise<void>;
766
+ getComponent(entityId: UUID, type: string, worldId?: UUID, sourceEntityId?: UUID): Promise<Component | null>;
767
+ getComponents(entityId: UUID, worldId?: UUID, sourceEntityId?: UUID): Promise<Component[]>;
768
+ createComponent(component: Component): Promise<boolean>;
769
+ updateComponent(component: Component): Promise<void>;
770
+ deleteComponent(componentId: UUID): Promise<void>;
771
+ addEmbeddingToMemory(memory: Memory): Promise<Memory>;
772
+ getMemories(params: {
773
+ entityId?: UUID;
774
+ agentId?: UUID;
775
+ roomId?: UUID;
776
+ count?: number;
777
+ unique?: boolean;
778
+ tableName: string;
779
+ start?: number;
780
+ end?: number;
781
+ }): Promise<Memory[]>;
782
+ getMemoryById(id: UUID): Promise<Memory | null>;
783
+ getMemoriesByIds(ids: UUID[], tableName?: string): Promise<Memory[]>;
784
+ getMemoriesByRoomIds(params: {
785
+ tableName: string;
786
+ roomIds: UUID[];
787
+ limit?: number;
788
+ }): Promise<Memory[]>;
789
+ getCachedEmbeddings(params: {
790
+ query_table_name: string;
791
+ query_threshold: number;
792
+ query_input: string;
793
+ query_field_name: string;
794
+ query_field_sub_name: string;
795
+ query_match_count: number;
796
+ }): Promise<{
797
+ embedding: number[];
798
+ levenshtein_score: number;
799
+ }[]>;
800
+ log(params: {
801
+ body: {
802
+ [key: string]: unknown;
803
+ };
804
+ entityId: UUID;
805
+ roomId: UUID;
806
+ type: string;
807
+ }): Promise<void>;
808
+ searchMemories(params: {
809
+ embedding: number[];
810
+ query?: string;
811
+ match_threshold?: number;
812
+ count?: number;
813
+ roomId?: UUID;
814
+ unique?: boolean;
815
+ worldId?: UUID;
816
+ entityId?: UUID;
817
+ tableName: string;
818
+ }): Promise<Memory[]>;
819
+ rerankMemories(query: string, memories: Memory[]): Promise<Memory[]>;
820
+ createMemory(memory: Memory, tableName: string, unique?: boolean): Promise<UUID>;
821
+ updateMemory(memory: Partial<Memory> & {
822
+ id: UUID;
823
+ metadata?: MemoryMetadata;
824
+ }): Promise<boolean>;
825
+ deleteMemory(memoryId: UUID): Promise<void>;
826
+ deleteAllMemories(roomId: UUID, tableName: string): Promise<void>;
827
+ countMemories(roomId: UUID, unique?: boolean, tableName?: string): Promise<number>;
828
+ getLogs(params: {
829
+ entityId: UUID;
830
+ roomId?: UUID;
831
+ type?: string;
832
+ count?: number;
833
+ offset?: number;
834
+ }): Promise<Log[]>;
835
+ deleteLog(logId: UUID): Promise<void>;
836
+ createWorld(world: World): Promise<UUID>;
837
+ getWorld(id: UUID): Promise<World | null>;
838
+ removeWorld(worldId: UUID): Promise<void>;
839
+ getAllWorlds(): Promise<World[]>;
840
+ updateWorld(world: World): Promise<void>;
841
+ getRoom(roomId: UUID): Promise<Room | null>;
842
+ getRoomsByIds(roomIds: UUID[]): Promise<Room[] | null>;
843
+ createRoom({ id, name, source, type, channelId, serverId, worldId }: Room): Promise<UUID>;
844
+ createRooms(rooms: Room[]): Promise<UUID[]>;
845
+ deleteRoom(roomId: UUID): Promise<void>;
846
+ deleteRoomsByWorldId(worldId: UUID): Promise<void>;
847
+ updateRoom(room: Room): Promise<void>;
848
+ getRoomsForParticipant(entityId: UUID): Promise<UUID[]>;
849
+ getRoomsForParticipants(userIds: UUID[]): Promise<UUID[]>;
850
+ getRooms(worldId: UUID): Promise<Room[]>;
851
+ getRoomsByWorld(worldId: UUID): Promise<Room[]>;
852
+ getParticipantUserState(roomId: UUID, entityId: UUID): Promise<'FOLLOWED' | 'MUTED' | null>;
853
+ setParticipantUserState(roomId: UUID, entityId: UUID, state: 'FOLLOWED' | 'MUTED' | null): Promise<void>;
854
+ createRelationship(params: {
855
+ sourceEntityId: UUID;
856
+ targetEntityId: UUID;
857
+ tags?: string[];
858
+ metadata?: {
859
+ [key: string]: any;
860
+ };
861
+ }): Promise<boolean>;
862
+ updateRelationship(relationship: Relationship): Promise<void>;
863
+ getRelationship(params: {
864
+ sourceEntityId: UUID;
865
+ targetEntityId: UUID;
866
+ }): Promise<Relationship | null>;
867
+ getRelationships(params: {
868
+ entityId: UUID;
869
+ tags?: string[];
870
+ }): Promise<Relationship[]>;
871
+ getCache<T>(key: string): Promise<T | undefined>;
872
+ setCache<T>(key: string, value: T): Promise<boolean>;
873
+ deleteCache(key: string): Promise<boolean>;
874
+ createTask(task: Task): Promise<UUID>;
875
+ getTasks(params: {
876
+ roomId?: UUID;
877
+ tags?: string[];
878
+ entityId?: UUID;
879
+ }): Promise<Task[]>;
880
+ getTask(id: UUID): Promise<Task | null>;
881
+ getTasksByName(name: string): Promise<Task[]>;
882
+ updateTask(id: UUID, task: Partial<Task>): Promise<void>;
883
+ deleteTask(id: UUID): Promise<void>;
884
+ on(event: string, callback: (data: any) => void): void;
885
+ off(event: string, callback: (data: any) => void): void;
886
+ emit(event: string, data: any): void;
887
+ sendControlMessage(params: {
888
+ roomId: UUID;
889
+ action: 'enable_input' | 'disable_input';
890
+ target?: string;
891
+ }): Promise<void>;
892
+ registerSendHandler(source: string, handler: SendHandlerFunction): void;
893
+ sendMessageToTarget(target: TargetInfo, content: Content): Promise<void>;
894
+ getMemoriesByWorldId(params: {
895
+ worldId: UUID;
896
+ count?: number;
897
+ tableName?: string;
898
+ }): Promise<Memory[]>;
899
+ }
900
+
901
+ /**
902
+ * Creates a new Setting object based on provided config settings.
903
+ * @param {Omit<Setting, "value">} configSetting - The configuration settings for the new Setting object.
904
+ * @returns {Setting} - The newly created Setting object.
905
+ */
906
+ /**
907
+ * Creates a Setting object from a configSetting object by omitting the 'value' property.
908
+ *
909
+ * @param {Omit<Setting, 'value'>} configSetting - The configSetting object to create the Setting from.
910
+ * @returns {Setting} A new Setting object created from the provided configSetting object.
911
+ */
912
+ declare function createSettingFromConfig(configSetting: Omit<Setting, 'value'>): Setting;
913
+ /**
914
+ * Retrieves the salt based on env variable SECRET_SALT
915
+ *
916
+ * @returns {string} The salt for the agent.
917
+ */
918
+ declare function getSalt(): string;
919
+ /**
920
+ * Common encryption function for string values
921
+ * @param {string} value - The string value to encrypt
922
+ * @param {string} salt - The salt to use for encryption
923
+ * @returns {string} - The encrypted value in 'iv:encrypted' format
924
+ */
925
+ declare function encryptStringValue(value: string, salt: string): string;
926
+ /**
927
+ * Common decryption function for string values
928
+ * @param {string} value - The encrypted value in 'iv:encrypted' format
929
+ * @param {string} salt - The salt to use for decryption
930
+ * @returns {string} - The decrypted string value
931
+ */
932
+ declare function decryptStringValue(value: string, salt: string): string;
933
+ /**
934
+ * Applies salt to the value of a setting
935
+ * Only applies to secret settings with string values
936
+ */
937
+ declare function saltSettingValue(setting: Setting, salt: string): Setting;
938
+ /**
939
+ * Removes salt from the value of a setting
940
+ * Only applies to secret settings with string values
941
+ */
942
+ declare function unsaltSettingValue(setting: Setting, salt: string): Setting;
943
+ /**
944
+ * Applies salt to all settings in a WorldSettings object
945
+ */
946
+ declare function saltWorldSettings(worldSettings: WorldSettings, salt: string): WorldSettings;
947
+ /**
948
+ * Removes salt from all settings in a WorldSettings object
949
+ */
950
+ declare function unsaltWorldSettings(worldSettings: WorldSettings, salt: string): WorldSettings;
951
+ /**
952
+ * Updates settings state in world metadata
953
+ */
954
+ declare function updateWorldSettings(runtime: IAgentRuntime, serverId: string, worldSettings: WorldSettings): Promise<boolean>;
955
+ /**
956
+ * Gets settings state from world metadata
957
+ */
958
+ declare function getWorldSettings(runtime: IAgentRuntime, serverId: string): Promise<WorldSettings | null>;
959
+ /**
960
+ * Initializes settings configuration for a server
961
+ */
962
+ declare function initializeOnboarding(runtime: IAgentRuntime, world: World, config: OnboardingConfig): Promise<WorldSettings | null>;
963
+ /**
964
+ * Encrypts sensitive data in a Character object
965
+ * @param {Character} character - The character object to encrypt secrets for
966
+ * @returns {Character} - A copy of the character with encrypted secrets
967
+ */
968
+ declare function encryptedCharacter(character: Character): Character;
969
+ /**
970
+ * Decrypts sensitive data in a Character object
971
+ * @param {Character} character - The character object with encrypted secrets
972
+ * @param {IAgentRuntime} runtime - The runtime information needed for salt generation
973
+ * @returns {Character} - A copy of the character with decrypted secrets
974
+ */
975
+ declare function decryptedCharacter(character: Character, runtime: IAgentRuntime): Character;
976
+ /**
977
+ * Helper function to encrypt all string values in an object
978
+ * @param {Record<string, any>} obj - Object with values to encrypt
979
+ * @param {string} salt - The salt to use for encryption
980
+ * @returns {Record<string, any>} - Object with encrypted values
981
+ */
982
+ declare function encryptObjectValues(obj: Record<string, any>, salt: string): Record<string, any>;
983
+ /**
984
+ * Helper function to decrypt all string values in an object
985
+ * @param {Record<string, any>} obj - Object with encrypted values
986
+ * @param {string} salt - The salt to use for decryption
987
+ * @returns {Record<string, any>} - Object with decrypted values
988
+ */
989
+ declare function decryptObjectValues(obj: Record<string, any>, salt: string): Record<string, any>;
990
+
991
+ /**
992
+ * Composes a context string by replacing placeholders in a template with corresponding values from the state.
993
+ *
994
+ * This function takes a template string with placeholders in the format `{{placeholder}}` and a state object.
995
+ * It replaces each placeholder with the value from the state object that matches the placeholder's name.
996
+ * If a matching key is not found in the state object for a given placeholder, the placeholder is replaced with an empty string.
997
+ *
998
+ * @param {Object} params - The parameters for composing the context.
999
+ * @param {State} params.state - The state object containing values to replace the placeholders in the template.
1000
+ * @param {TemplateType} params.template - The template string or function containing placeholders to be replaced with state values.
1001
+ * @returns {string} The composed context string with placeholders replaced by corresponding state values.
1002
+ *
1003
+ * @example
1004
+ * // Given a state object and a template
1005
+ * const state = { userName: "Alice", userAge: 30 };
1006
+ * const template = "Hello, {{userName}}! You are {{userAge}} years old";
1007
+ *
1008
+ * // Composing the context with simple string replacement will result in:
1009
+ * // "Hello, Alice! You are 30 years old."
1010
+ * const contextSimple = composePromptFromState({ state, template });
1011
+ *
1012
+ * // Using composePromptFromState with a template function for dynamic template
1013
+ * const template = ({ state }) => {
1014
+ * const tone = Math.random() > 0.5 ? "kind" : "rude";
1015
+ * return `Hello, {{userName}}! You are {{userAge}} years old. Be ${tone}`;
1016
+ * };
1017
+ * const contextSimple = composePromptFromState({ state, template });
1018
+ */
1019
+ /**
1020
+ * Function to compose a prompt using a provided template and state.
1021
+ * It compiles the template (upgrading double braces to triple braces for non-HTML escaping)
1022
+ * and then populates it with values from the state. Additionally, it processes the
1023
+ * resulting string with `composeRandomUser` to replace placeholders like `{{nameX}}`.
1024
+ *
1025
+ * @param {Object} options - Object containing state and template information.
1026
+ * @param {State} options.state - The state object containing values to fill the template.
1027
+ * @param {TemplateType} options.template - The template string or function to be used for composing the prompt.
1028
+ * @returns {string} The composed prompt output, with state values and random user names populated.
1029
+ */
1030
+ declare const composePrompt: ({ state, template, }: {
1031
+ state: {
1032
+ [key: string]: string;
1033
+ };
1034
+ template: TemplateType;
1035
+ }) => string;
1036
+ /**
1037
+ * Function to compose a prompt using a provided template and state.
1038
+ *
1039
+ * @param {Object} options - Object containing state and template information.
1040
+ * @param {State} options.state - The state object containing values to fill the template.
1041
+ * @param {TemplateType} options.template - The template to be used for composing the prompt.
1042
+ * @returns {string} The composed prompt output.
1043
+ */
1044
+ declare const composePromptFromState: ({ state, template, }: {
1045
+ state: State;
1046
+ template: TemplateType;
1047
+ }) => string;
1048
+ /**
1049
+ * Adds a header to a body of text.
1050
+ *
1051
+ * This function takes a header string and a body string and returns a new string with the header prepended to the body.
1052
+ * If the body string is empty, the header is returned as is.
1053
+ *
1054
+ * @param {string} header - The header to add to the body.
1055
+ * @param {string} body - The body to which to add the header.
1056
+ * @returns {string} The body with the header prepended.
1057
+ *
1058
+ * @example
1059
+ * // Given a header and a body
1060
+ * const header = "Header";
1061
+ * const body = "Body";
1062
+ *
1063
+ * // Adding the header to the body will result in:
1064
+ * // "Header\nBody"
1065
+ * const text = addHeader(header, body);
1066
+ */
1067
+ declare const addHeader: (header: string, body: string) => string;
1068
+ declare const formatPosts: ({ messages, entities, conversationHeader, }: {
1069
+ messages: Memory[];
1070
+ entities: Entity[];
1071
+ conversationHeader?: boolean;
1072
+ }) => string;
1073
+ /**
1074
+ * Format messages into a string
1075
+ * @param {Object} params - The formatting parameters
1076
+ * @param {Memory[]} params.messages - List of messages to format
1077
+ * @param {Entity[]} params.entities - List of entities for name resolution
1078
+ * @returns {string} Formatted message string with timestamps and user information
1079
+ */
1080
+ declare const formatMessages: ({ messages, entities, }: {
1081
+ messages: Memory[];
1082
+ entities: Entity[];
1083
+ }) => string;
1084
+ declare const formatTimestamp: (messageDate: number) => string;
1085
+ /**
1086
+ * Parses key-value pairs from a simple XML structure within a given text.
1087
+ * It looks for an XML block (e.g., <response>...</response>) and extracts
1088
+ * text content from direct child elements (e.g., <key>value</key>).
1089
+ *
1090
+ * Note: This uses regex and is suitable for simple, predictable XML structures.
1091
+ * For complex XML, a proper parsing library is recommended.
1092
+ *
1093
+ * @param text - The input text containing the XML structure.
1094
+ * @returns An object with key-value pairs extracted from the XML, or null if parsing fails.
1095
+ */
1096
+ declare function parseKeyValueXml(text: string): Record<string, any> | null;
1097
+ /**
1098
+ * Parses a JSON object from a given text. The function looks for a JSON block wrapped in triple backticks
1099
+ * with `json` language identifier, and if not found, it searches for an object pattern within the text.
1100
+ * It then attempts to parse the JSON string into a JavaScript object. If parsing is successful and the result
1101
+ * is an object (but not an array), it returns the object; otherwise, it tries to parse an array if the result
1102
+ * is an array, or returns null if parsing is unsuccessful or the result is neither an object nor an array.
1103
+ *
1104
+ * @param text - The input text from which to extract and parse the JSON object.
1105
+ * @returns An object parsed from the JSON string if successful; otherwise, null or the result of parsing an array.
1106
+ */
1107
+ declare function parseJSONObjectFromText(text: string): Record<string, any> | null;
1108
+ /**
1109
+ * Normalizes a JSON-like string by correcting formatting issues:
1110
+ * - Removes extra spaces after '{' and before '}'.
1111
+ * - Wraps unquoted values in double quotes.
1112
+ * - Converts single-quoted values to double-quoted.
1113
+ * - Ensures consistency in key-value formatting.
1114
+ * - Normalizes mixed adjacent quote pairs.
1115
+ *
1116
+ * This is useful for cleaning up improperly formatted JSON strings
1117
+ * before parsing them into valid JSON.
1118
+ *
1119
+ * @param str - The JSON-like string to normalize.
1120
+ * @returns A properly formatted JSON string.
1121
+ */
1122
+ declare const normalizeJsonString: (str: string) => string;
1123
+ /**
1124
+ * Truncate text to fit within the character limit, ensuring it ends at a complete sentence.
1125
+ */
1126
+ declare function truncateToCompleteSentence(text: string, maxLength: number): string;
1127
+ declare function splitChunks(content: string, chunkSize?: number, bleed?: number): Promise<string[]>;
1128
+ /**
1129
+ * Trims the provided text prompt to a specified token limit using a tokenizer model and type.
1130
+ */
1131
+ declare function trimTokens(prompt: string, maxTokens: number, runtime: IAgentRuntime): Promise<string>;
1132
+ declare function safeReplacer(): (key: string, value: any) => any;
1133
+ /**
1134
+ * Parses a string to determine its boolean equivalent.
1135
+ *
1136
+ * Recognized affirmative values: "YES", "Y", "TRUE", "T", "1", "ON", "ENABLE"
1137
+ * Recognized negative values: "NO", "N", "FALSE", "F", "0", "OFF", "DISABLE"
1138
+ *
1139
+ * @param {string | undefined | null} value - The input text to parse
1140
+ * @returns {boolean} - Returns `true` for affirmative inputs, `false` for negative or unrecognized inputs
1141
+ */
1142
+ declare function parseBooleanFromText(value: string | undefined | null): boolean;
1143
+ /**
1144
+ * Validates a UUID value.
1145
+ *
1146
+ * @param {unknown} value - The value to validate.
1147
+ * @returns {UUID | null} Returns the validated UUID value or null if validation fails.
1148
+ */
1149
+ declare function validateUuid(value: unknown): UUID | null;
1150
+ /**
1151
+ * Converts a string or number to a UUID.
1152
+ *
1153
+ * @param {string | number} target - The string or number to convert to a UUID.
1154
+ * @returns {UUID} The UUID generated from the input target.
1155
+ * @throws {TypeError} Throws an error if the input target is not a string.
1156
+ */
1157
+ declare function stringToUuid(target: string | number): UUID;
1158
+
1159
+ declare const defaultSpec: typeof v2;
1160
+
1161
+ export { Action, Agent, AgentRuntime, ChannelType, Character, Component, Content, DatabaseAdapter, Entity, Evaluator, HandlerCallback, IAgentRuntime, IDatabaseAdapter, type IInstrumentationService, type InstrumentationConfig, InstrumentationService, Log, Memory, MemoryMetadata, ModelHandler, ModelParamsMap, ModelResultMap, ModelTypeName, OnboardingConfig, Participant, Plugin, Provider, Relationship, Role, Room, Route, RuntimeSettings, Semaphore, SendHandlerFunction, type ServerOwnershipState, Service, ServiceTypeName, Setting, State, TargetInfo, Task, TaskWorker, TemplateType, UUID, World, WorldSettings, addHeader, booleanFooter, composeActionExamples, composePrompt, composePromptFromState, createLogger, createSettingFromConfig, createUniqueUuid, decryptObjectValues, decryptStringValue as decryptSecret, decryptStringValue, decryptedCharacter, defaultSpec, elizaLogger, encryptObjectValues, encryptStringValue, encryptedCharacter, findEntityByName, findWorldsForOwner, formatActionNames, formatActions, formatEntities, formatMessages, formatPosts, formatTimestamp, getEntityDetails, getSalt, getUserServerRole, getWorldSettings, imageDescriptionTemplate, initializeOnboarding, logger, messageHandlerTemplate, normalizeJsonString, parseBooleanFromText, parseJSONObjectFromText, parseKeyValueXml, postCreationTemplate, safeReplacer, saltSettingValue, saltWorldSettings, shouldRespondTemplate, splitChunks, stringToUuid, trimTokens, truncateToCompleteSentence, unsaltSettingValue, unsaltWorldSettings, updateWorldSettings, v2, validateUuid };