@elizaos/core 1.0.0-alpha.2 → 1.0.0-alpha.21

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 DELETED
@@ -1,2368 +0,0 @@
1
- import { z } from 'zod';
2
- import * as pino from 'pino';
3
-
4
- /**
5
- * Represents a UUID string in the format "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
6
- */
7
- type UUID = `${string}-${string}-${string}-${string}-${string}`;
8
- /**
9
- * Represents the content of a message or communication
10
- */
11
- interface Content {
12
- thought?: string;
13
- /** The agent's plan for the next message */
14
- plan?: string;
15
- /** The main text content */
16
- text?: string;
17
- /** Optional action associated with the message */
18
- actions?: string[];
19
- /** Optional providers associated with the message */
20
- providers?: string[];
21
- /** Optional source/origin of the content */
22
- source?: string;
23
- /** URL of the original message/post (e.g. tweet URL, Discord message link) */
24
- url?: string;
25
- /** UUID of parent message if this is a reply/thread */
26
- inReplyTo?: UUID;
27
- /** Array of media attachments */
28
- attachments?: Media[];
29
- /** Additional dynamic properties */
30
- [key: string]: unknown;
31
- }
32
- /**
33
- * Example content with associated user for demonstration purposes
34
- */
35
- interface ActionExample {
36
- /** User associated with the example */
37
- name: string;
38
- /** Content of the example */
39
- content: Content;
40
- }
41
- /**
42
- * Example conversation content with user ID
43
- */
44
- interface ConversationExample {
45
- /** UUID of user in conversation */
46
- entityId: UUID;
47
- /** Content of the conversation */
48
- content: Content;
49
- }
50
- /**
51
- * Represents a single objective within a goal
52
- */
53
- interface Objective {
54
- /** Optional unique identifier */
55
- id?: string;
56
- /** Description of what needs to be achieved */
57
- description: string;
58
- /** Whether objective is completed */
59
- completed: boolean;
60
- }
61
- /**
62
- * Status enum for goals
63
- */
64
- declare enum GoalStatus {
65
- DONE = "DONE",
66
- FAILED = "FAILED",
67
- IN_PROGRESS = "IN_PROGRESS"
68
- }
69
- /**
70
- * Represents a high-level goal composed of objectives
71
- */
72
- interface Goal {
73
- /** Optional unique identifier */
74
- id?: UUID;
75
- /** Room ID where goal exists */
76
- roomId: UUID;
77
- /** User ID of goal owner */
78
- entityId: UUID;
79
- /** Name/title of the goal */
80
- name: string;
81
- /** Current status */
82
- status: GoalStatus;
83
- /** Component objectives */
84
- objectives: Objective[];
85
- }
86
- type ModelType = (typeof ModelTypes)[keyof typeof ModelTypes] | string;
87
- /**
88
- * Model size/type classification
89
- */
90
- declare const ModelTypes: {
91
- readonly SMALL: "text_small";
92
- readonly MEDIUM: "text_large";
93
- readonly LARGE: "text_large";
94
- readonly TEXT_SMALL: "text_small";
95
- readonly TEXT_LARGE: "text_large";
96
- readonly TEXT_EMBEDDING: "text_embedding";
97
- readonly TEXT_TOKENIZER_ENCODE: "TEXT_TOKENIZER_ENCODE";
98
- readonly TEXT_TOKENIZER_DECODE: "TEXT_TOKENIZER_DECODE";
99
- readonly TEXT_REASONING_SMALL: "reasoning_small";
100
- readonly TEXT_REASONING_LARGE: "reasoning_large";
101
- readonly IMAGE: "image";
102
- readonly IMAGE_DESCRIPTION: "image_description";
103
- readonly TRANSCRIPTION: "transcription";
104
- readonly TEXT_TO_SPEECH: "text_to_speech";
105
- readonly AUDIO: "audio";
106
- readonly VIDEO: "video";
107
- };
108
- type ServiceType = (typeof ServiceTypes)[keyof typeof ServiceTypes];
109
- declare const ServiceTypes: {
110
- readonly TRANSCRIPTION: "transcription";
111
- readonly VIDEO: "video";
112
- readonly BROWSER: "browser";
113
- readonly PDF: "pdf";
114
- readonly REMOTE_FILES: "aws_s3";
115
- readonly WEB_SEARCH: "web_search";
116
- readonly EMAIL: "email";
117
- readonly TEE: "tee";
118
- readonly TASK: "task";
119
- };
120
- /**
121
- * Represents the current state/context of a conversation
122
- */
123
- interface State {
124
- /** Additional dynamic properties */
125
- [key: string]: any;
126
- values: {
127
- [key: string]: any;
128
- };
129
- data: {
130
- [key: string]: any;
131
- };
132
- text: string;
133
- }
134
- type MemoryTypeAlias = string;
135
- declare enum MemoryType {
136
- DOCUMENT = "document",
137
- FRAGMENT = "fragment",
138
- MESSAGE = "message",
139
- DESCRIPTION = "description",
140
- CUSTOM = "custom"
141
- }
142
- interface BaseMetadata {
143
- type: MemoryTypeAlias;
144
- source?: string;
145
- sourceId?: UUID;
146
- scope?: string;
147
- timestamp?: number;
148
- tags?: string[];
149
- }
150
- interface DocumentMetadata extends BaseMetadata {
151
- type: MemoryType.DOCUMENT;
152
- }
153
- interface FragmentMetadata extends BaseMetadata {
154
- type: MemoryType.FRAGMENT;
155
- documentId: UUID;
156
- position: number;
157
- }
158
- interface MessageMetadata extends BaseMetadata {
159
- type: MemoryType.MESSAGE;
160
- }
161
- interface DescriptionMetadata extends BaseMetadata {
162
- type: MemoryType.DESCRIPTION;
163
- }
164
- interface CustomMetadata extends BaseMetadata {
165
- type: MemoryTypeAlias;
166
- [key: string]: unknown;
167
- }
168
- type MemoryMetadata = DocumentMetadata | FragmentMetadata | MessageMetadata | DescriptionMetadata | CustomMetadata | any;
169
- /**
170
- * Represents a stored memory/message
171
- */
172
- interface Memory {
173
- /** Optional unique identifier */
174
- id?: UUID;
175
- /** Associated user ID */
176
- entityId: UUID;
177
- /** Associated agent ID */
178
- agentId?: UUID;
179
- /** Optional creation timestamp */
180
- createdAt?: number;
181
- /** Memory content */
182
- content: Content;
183
- /** Optional embedding vector */
184
- embedding?: number[];
185
- /** Associated room ID */
186
- roomId: UUID;
187
- /** Whether memory is unique */
188
- unique?: boolean;
189
- /** Embedding similarity score */
190
- similarity?: number;
191
- /** Metadata for the knowledge */
192
- metadata?: MemoryMetadata;
193
- }
194
- /**
195
- * Example message for demonstration
196
- */
197
- interface MessageExample {
198
- /** Associated user */
199
- name: string;
200
- /** Message content */
201
- content: Content;
202
- }
203
- /**
204
- * Handler function type for processing messages
205
- */
206
- type Handler = (runtime: IAgentRuntime, message: Memory, state?: State, options?: {
207
- [key: string]: unknown;
208
- }, callback?: HandlerCallback, responses?: Memory[]) => Promise<unknown>;
209
- /**
210
- * Callback function type for handlers
211
- */
212
- type HandlerCallback = (response: Content, files?: any) => Promise<Memory[]>;
213
- /**
214
- * Validator function type for actions/evaluators
215
- */
216
- type Validator = (runtime: IAgentRuntime, message: Memory, state?: State) => Promise<boolean>;
217
- /**
218
- * Represents an action the agent can perform
219
- */
220
- interface Action {
221
- /** Similar action descriptions */
222
- similes?: string[];
223
- /** Detailed description */
224
- description: string;
225
- /** Example usages */
226
- examples?: ActionExample[][];
227
- /** Handler function */
228
- handler: Handler;
229
- /** Action name */
230
- name: string;
231
- /** Validation function */
232
- validate: Validator;
233
- }
234
- /**
235
- * Example for evaluating agent behavior
236
- */
237
- interface EvaluationExample {
238
- /** Evaluation context */
239
- prompt: string;
240
- /** Example messages */
241
- messages: Array<ActionExample>;
242
- /** Expected outcome */
243
- outcome: string;
244
- }
245
- /**
246
- * Evaluator for assessing agent responses
247
- */
248
- interface Evaluator {
249
- /** Whether to always run */
250
- alwaysRun?: boolean;
251
- /** Detailed description */
252
- description: string;
253
- /** Similar evaluator descriptions */
254
- similes?: string[];
255
- /** Example evaluations */
256
- examples: EvaluationExample[];
257
- /** Handler function */
258
- handler: Handler;
259
- /** Evaluator name */
260
- name: string;
261
- /** Validation function */
262
- validate: Validator;
263
- }
264
- interface ProviderResult {
265
- values?: {
266
- [key: string]: any;
267
- };
268
- data?: {
269
- [key: string]: any;
270
- };
271
- text?: string;
272
- }
273
- /**
274
- * Provider for external data/services
275
- */
276
- interface Provider {
277
- /** Provider name */
278
- name: string;
279
- /** Description of the provider */
280
- description?: string;
281
- /** Whether the provider is dynamic */
282
- dynamic?: boolean;
283
- /** Position of the provider in the provider list, positive or negative */
284
- position?: number;
285
- /**
286
- * Whether the provider is private
287
- *
288
- * Private providers are not displayed in the regular provider list, they have to be called explicitly
289
- */
290
- private?: boolean;
291
- /** Data retrieval function */
292
- get: (runtime: IAgentRuntime, message: Memory, state: State) => Promise<ProviderResult>;
293
- }
294
- /**
295
- * Represents a relationship between users
296
- */
297
- interface Relationship {
298
- /** Unique identifier */
299
- id: UUID;
300
- /** First user ID */
301
- sourceEntityId: UUID;
302
- /** Second user ID */
303
- targetEntityId: UUID;
304
- /** Agent ID */
305
- agentId: UUID;
306
- /** Tags for filtering/categorizing relationships */
307
- tags: string[];
308
- /** Additional metadata about the relationship */
309
- metadata: {
310
- [key: string]: any;
311
- };
312
- /** Optional creation timestamp */
313
- createdAt?: string;
314
- }
315
- interface Component {
316
- id: UUID;
317
- entityId: UUID;
318
- agentId: UUID;
319
- roomId: UUID;
320
- worldId: UUID;
321
- sourceEntityId: UUID;
322
- type: string;
323
- data: {
324
- [key: string]: any;
325
- };
326
- }
327
- /**
328
- * Represents a user account
329
- */
330
- interface Entity {
331
- /** Unique identifier, optional on creation */
332
- id?: UUID;
333
- /** Names of the entity */
334
- names: string[];
335
- /** Optional additional metadata */
336
- metadata?: {
337
- [key: string]: any;
338
- };
339
- /** Agent ID this account is related to, for agents should be themselves */
340
- agentId: UUID;
341
- /** Optional array of components */
342
- components?: Component[];
343
- }
344
- type World = {
345
- id: UUID;
346
- name?: string;
347
- agentId: UUID;
348
- serverId: string;
349
- metadata?: {
350
- ownership?: {
351
- ownerId: string;
352
- };
353
- roles?: {
354
- [entityId: UUID]: Role;
355
- };
356
- [key: string]: unknown;
357
- };
358
- };
359
- type Room = {
360
- id: UUID;
361
- name?: string;
362
- agentId?: UUID;
363
- source: string;
364
- type: ChannelType;
365
- channelId?: string;
366
- serverId?: string;
367
- worldId?: UUID;
368
- metadata?: Record<string, unknown>;
369
- };
370
- /**
371
- * Room participant with account details
372
- */
373
- interface Participant {
374
- /** Unique identifier */
375
- id: UUID;
376
- /** Associated account */
377
- entity: Entity;
378
- }
379
- /**
380
- * Represents a media attachment
381
- */
382
- type Media = {
383
- /** Unique identifier */
384
- id: string;
385
- /** Media URL */
386
- url: string;
387
- /** Media title */
388
- title: string;
389
- /** Media source */
390
- source: string;
391
- /** Media description */
392
- description: string;
393
- /** Text content */
394
- text: string;
395
- /** Content type */
396
- contentType?: string;
397
- };
398
- declare enum ChannelType {
399
- SELF = "SELF",
400
- DM = "DM",
401
- GROUP = "GROUP",
402
- VOICE_DM = "VOICE_DM",
403
- VOICE_GROUP = "VOICE_GROUP",
404
- FEED = "FEED",
405
- THREAD = "THREAD",
406
- WORLD = "WORLD",
407
- API = "API",
408
- FORUM = "FORUM"
409
- }
410
- /**
411
- * Client instance
412
- */
413
- declare abstract class Service {
414
- /** Runtime instance */
415
- protected runtime: IAgentRuntime;
416
- constructor(runtime?: IAgentRuntime);
417
- abstract stop(): Promise<void>;
418
- /** Service type */
419
- static serviceType: string;
420
- /** Service name */
421
- abstract capabilityDescription: string;
422
- /** Service configuration */
423
- config?: {
424
- [key: string]: any;
425
- };
426
- /** Start service connection */
427
- static start(_runtime: IAgentRuntime): Promise<Service>;
428
- /** Stop service connection */
429
- static stop(_runtime: IAgentRuntime): Promise<unknown>;
430
- }
431
- type Route = {
432
- type: "GET" | "POST" | "PUT" | "DELETE";
433
- path: string;
434
- handler: (req: any, res: any, runtime: IAgentRuntime) => Promise<void>;
435
- };
436
- /**
437
- * Plugin for extending agent functionality
438
- */
439
- interface Plugin {
440
- name: string;
441
- description: string;
442
- init?: (config: Record<string, string>, runtime: IAgentRuntime) => Promise<void>;
443
- config?: {
444
- [key: string]: any;
445
- };
446
- memoryManagers?: IMemoryManager[];
447
- services?: (typeof Service)[];
448
- componentTypes?: {
449
- name: string;
450
- schema: Record<string, unknown>;
451
- validator?: (data: any) => boolean;
452
- }[];
453
- actions?: Action[];
454
- providers?: Provider[];
455
- evaluators?: Evaluator[];
456
- adapters?: IDatabaseAdapter[];
457
- models?: {
458
- [key: string]: (...args: any[]) => Promise<any>;
459
- };
460
- events?: {
461
- [key: string]: ((params: any) => Promise<any>)[];
462
- };
463
- routes?: Route[];
464
- tests?: TestSuite[];
465
- }
466
- interface ProjectAgent {
467
- character: Character;
468
- init?: (runtime: IAgentRuntime) => Promise<void>;
469
- plugins?: Plugin[];
470
- }
471
- interface Project {
472
- agents: ProjectAgent[];
473
- }
474
- interface ModelConfiguration {
475
- temperature?: number;
476
- maxOutputTokens?: number;
477
- frequency_penalty?: number;
478
- presence_penalty?: number;
479
- maxInputTokens?: number;
480
- }
481
- type TemplateType = string | ((options: {
482
- state: State;
483
- }) => string);
484
- /**
485
- * Configuration for an agent character
486
- */
487
- interface Character {
488
- /** Optional unique identifier */
489
- id?: UUID;
490
- /** Character name */
491
- name: string;
492
- /** Optional username */
493
- username?: string;
494
- /** Optional system prompt */
495
- system?: string;
496
- /** Optional prompt templates */
497
- templates?: {
498
- [key: string]: TemplateType;
499
- };
500
- /** Character biography */
501
- bio: string | string[];
502
- /** Example messages */
503
- messageExamples?: MessageExample[][];
504
- /** Example posts */
505
- postExamples?: string[];
506
- /** Known topics */
507
- topics?: string[];
508
- /** Character traits */
509
- adjectives?: string[];
510
- /** Optional knowledge base */
511
- knowledge?: (string | {
512
- path: string;
513
- shared?: boolean;
514
- })[];
515
- /** Available plugins */
516
- plugins?: string[];
517
- /** Optional configuration */
518
- settings?: {
519
- [key: string]: any | string | boolean | number;
520
- };
521
- /** Optional secrets */
522
- secrets?: {
523
- [key: string]: string | boolean | number;
524
- };
525
- /** Writing style guides */
526
- style?: {
527
- all?: string[];
528
- chat?: string[];
529
- post?: string[];
530
- };
531
- }
532
- interface Agent extends Character {
533
- enabled: boolean;
534
- createdAt: number;
535
- updatedAt: number;
536
- }
537
- /**
538
- * Interface for database operations
539
- */
540
- interface IDatabaseAdapter {
541
- /** Database instance */
542
- db: any;
543
- /** Close database connection */
544
- close(): Promise<void>;
545
- getAgent(agentId: UUID): Promise<Agent | null>;
546
- /** Get all agents */
547
- getAgents(): Promise<Agent[]>;
548
- createAgent(agent: Partial<Agent>): Promise<boolean>;
549
- updateAgent(agentId: UUID, agent: Partial<Agent>): Promise<boolean>;
550
- deleteAgent(agentId: UUID): Promise<boolean>;
551
- ensureAgentExists(agent: Partial<Agent>): Promise<void>;
552
- ensureEmbeddingDimension(dimension: number): Promise<void>;
553
- /** Get entity by ID */
554
- getEntityById(entityId: UUID): Promise<Entity | null>;
555
- /** Get entities for room */
556
- getEntitiesForRoom(roomId: UUID, includeComponents?: boolean): Promise<Entity[]>;
557
- /** Create new entity */
558
- createEntity(entity: Entity): Promise<boolean>;
559
- /** Update entity */
560
- updateEntity(entity: Entity): Promise<void>;
561
- /** Get component by ID */
562
- getComponent(entityId: UUID, type: string, worldId?: UUID, sourceEntityId?: UUID): Promise<Component | null>;
563
- /** Get all components for an entity */
564
- getComponents(entityId: UUID, worldId?: UUID, sourceEntityId?: UUID): Promise<Component[]>;
565
- /** Create component */
566
- createComponent(component: Component): Promise<boolean>;
567
- /** Update component */
568
- updateComponent(component: Component): Promise<void>;
569
- /** Delete component */
570
- deleteComponent(componentId: UUID): Promise<void>;
571
- /** Get memories matching criteria */
572
- getMemories(params: {
573
- roomId: UUID;
574
- count?: number;
575
- unique?: boolean;
576
- tableName: string;
577
- start?: number;
578
- end?: number;
579
- }): Promise<Memory[]>;
580
- getMemoryById(id: UUID): Promise<Memory | null>;
581
- getMemoriesByIds(ids: UUID[], tableName?: string): Promise<Memory[]>;
582
- getMemoriesByRoomIds(params: {
583
- tableName: string;
584
- roomIds: UUID[];
585
- limit?: number;
586
- }): Promise<Memory[]>;
587
- getCachedEmbeddings(params: {
588
- query_table_name: string;
589
- query_threshold: number;
590
- query_input: string;
591
- query_field_name: string;
592
- query_field_sub_name: string;
593
- query_match_count: number;
594
- }): Promise<{
595
- embedding: number[];
596
- levenshtein_score: number;
597
- }[]>;
598
- log(params: {
599
- body: {
600
- [key: string]: unknown;
601
- };
602
- entityId: UUID;
603
- roomId: UUID;
604
- type: string;
605
- }): Promise<void>;
606
- updateGoalStatus(params: {
607
- goalId: UUID;
608
- status: GoalStatus;
609
- }): Promise<void>;
610
- searchMemories(params: {
611
- embedding: number[];
612
- match_threshold?: number;
613
- count?: number;
614
- roomId?: UUID;
615
- unique?: boolean;
616
- tableName: string;
617
- }): Promise<Memory[]>;
618
- createMemory(memory: Memory, tableName: string, unique?: boolean): Promise<UUID>;
619
- removeMemory(memoryId: UUID, tableName: string): Promise<void>;
620
- removeAllMemories(roomId: UUID, tableName: string): Promise<void>;
621
- countMemories(roomId: UUID, unique?: boolean, tableName?: string): Promise<number>;
622
- getGoals(params: {
623
- roomId: UUID;
624
- entityId?: UUID | null;
625
- onlyInProgress?: boolean;
626
- count?: number;
627
- }): Promise<Goal[]>;
628
- updateGoal(goal: Goal): Promise<void>;
629
- createGoal(goal: Goal): Promise<void>;
630
- removeGoal(goalId: UUID): Promise<void>;
631
- removeAllGoals(roomId: UUID): Promise<void>;
632
- createWorld(world: World): Promise<UUID>;
633
- getWorld(id: UUID): Promise<World | null>;
634
- getAllWorlds(): Promise<World[]>;
635
- updateWorld(world: World): Promise<void>;
636
- getRoom(roomId: UUID): Promise<Room | null>;
637
- createRoom({ id, name, source, type, channelId, serverId, worldId, }: Room): Promise<UUID>;
638
- deleteRoom(roomId: UUID): Promise<void>;
639
- updateRoom(room: Room): Promise<void>;
640
- getRoomsForParticipant(entityId: UUID): Promise<UUID[]>;
641
- getRoomsForParticipants(userIds: UUID[]): Promise<UUID[]>;
642
- getRooms(worldId: UUID): Promise<Room[]>;
643
- addParticipant(entityId: UUID, roomId: UUID): Promise<boolean>;
644
- removeParticipant(entityId: UUID, roomId: UUID): Promise<boolean>;
645
- getParticipantsForEntity(entityId: UUID): Promise<Participant[]>;
646
- getParticipantsForRoom(roomId: UUID): Promise<UUID[]>;
647
- getParticipantUserState(roomId: UUID, entityId: UUID): Promise<"FOLLOWED" | "MUTED" | null>;
648
- setParticipantUserState(roomId: UUID, entityId: UUID, state: "FOLLOWED" | "MUTED" | null): Promise<void>;
649
- /**
650
- * Creates a new relationship between two entities.
651
- * @param params Object containing the relationship details
652
- * @returns Promise resolving to boolean indicating success
653
- */
654
- createRelationship(params: {
655
- sourceEntityId: UUID;
656
- targetEntityId: UUID;
657
- tags?: string[];
658
- metadata?: {
659
- [key: string]: any;
660
- };
661
- }): Promise<boolean>;
662
- /**
663
- * Updates an existing relationship between two entities.
664
- * @param relationship The relationship object with updated data
665
- * @returns Promise resolving to void
666
- */
667
- updateRelationship(relationship: Relationship): Promise<void>;
668
- /**
669
- * Retrieves a relationship between two entities if it exists.
670
- * @param params Object containing the entity IDs and agent ID
671
- * @returns Promise resolving to the Relationship object or null if not found
672
- */
673
- getRelationship(params: {
674
- sourceEntityId: UUID;
675
- targetEntityId: UUID;
676
- }): Promise<Relationship | null>;
677
- /**
678
- * Retrieves all relationships for a specific entity.
679
- * @param params Object containing the user ID, agent ID and optional tags to filter by
680
- * @returns Promise resolving to an array of Relationship objects
681
- */
682
- getRelationships(params: {
683
- entityId: UUID;
684
- tags?: string[];
685
- }): Promise<Relationship[]>;
686
- ensureEmbeddingDimension(dimension: number): void;
687
- getCache<T>(key: string): Promise<T | undefined>;
688
- setCache<T>(key: string, value: T): Promise<boolean>;
689
- deleteCache(key: string): Promise<boolean>;
690
- createTask(task: Task): Promise<UUID>;
691
- getTasks(params: {
692
- roomId?: UUID;
693
- tags?: string[];
694
- }): Promise<Task[]>;
695
- getTask(id: UUID): Promise<Task | null>;
696
- getTasksByName(name: string): Promise<Task[]>;
697
- updateTask(id: UUID, task: Partial<Task>): Promise<void>;
698
- deleteTask(id: UUID): Promise<void>;
699
- }
700
- interface IMemoryManager {
701
- runtime: IAgentRuntime;
702
- tableName: string;
703
- constructor: Function;
704
- addEmbeddingToMemory(memory: Memory): Promise<Memory>;
705
- getMemories(opts: {
706
- roomId: UUID;
707
- count?: number;
708
- unique?: boolean;
709
- start?: number;
710
- end?: number;
711
- }): Promise<Memory[]>;
712
- searchMemories(params: {
713
- embedding: number[];
714
- match_threshold?: number;
715
- count?: number;
716
- roomId?: UUID;
717
- unique?: boolean;
718
- metadata?: MemoryMetadata;
719
- }): Promise<Memory[]>;
720
- getCachedEmbeddings(content: string): Promise<{
721
- embedding: number[];
722
- levenshtein_score: number;
723
- }[]>;
724
- getMemoryById(id: UUID): Promise<Memory | null>;
725
- getMemoriesByRoomIds(params: {
726
- roomIds: UUID[];
727
- limit?: number;
728
- }): Promise<Memory[]>;
729
- createMemory(memory: Memory, unique?: boolean): Promise<UUID>;
730
- removeMemory(memoryId: UUID): Promise<void>;
731
- removeAllMemories(roomId: UUID): Promise<void>;
732
- countMemories(roomId: UUID, unique?: boolean): Promise<number>;
733
- }
734
- type CacheOptions = {
735
- expires?: number;
736
- };
737
- interface IAgentRuntime {
738
- agentId: UUID;
739
- databaseAdapter: IDatabaseAdapter;
740
- character: Character;
741
- providers: Provider[];
742
- actions: Action[];
743
- evaluators: Evaluator[];
744
- plugins: Plugin[];
745
- services: Map<ServiceType, Service>;
746
- events: Map<string, ((params: any) => void)[]>;
747
- fetch?: typeof fetch | null;
748
- routes: Route[];
749
- registerPlugin(plugin: Plugin): Promise<void>;
750
- initialize(): Promise<void>;
751
- getKnowledge(message: Memory): Promise<KnowledgeItem[]>;
752
- addKnowledge(item: KnowledgeItem, options: {
753
- targetTokens: number;
754
- overlap: number;
755
- modelContextSize: number;
756
- }): Promise<void>;
757
- getMemoryManager(tableName: string): IMemoryManager | null;
758
- getService<T extends Service>(service: ServiceType | string): T | null;
759
- getAllServices(): Map<ServiceType, Service>;
760
- registerService(service: typeof Service): void;
761
- registerDatabaseAdapter(adapter: IDatabaseAdapter): void;
762
- getDatabaseAdapters(): IDatabaseAdapter[];
763
- getDatabaseAdapter(): IDatabaseAdapter | null;
764
- setSetting(key: string, value: string | boolean | null | any, secret: boolean): void;
765
- getSetting(key: string): string | boolean | null | any;
766
- getConversationLength(): number;
767
- processActions(message: Memory, responses: Memory[], state?: State, callback?: HandlerCallback): Promise<void>;
768
- evaluate(message: Memory, state?: State, didRespond?: boolean, callback?: HandlerCallback, responses?: Memory[]): Promise<Evaluator[] | null>;
769
- registerProvider(provider: Provider): void;
770
- registerAction(action: Action): void;
771
- registerEvaluator(evaluator: Evaluator): void;
772
- ensureConnection({ entityId, roomId, userName, name, source, channelId, serverId, type, worldId, }: {
773
- entityId: UUID;
774
- roomId: UUID;
775
- userName?: string;
776
- name?: string;
777
- source?: string;
778
- channelId?: string;
779
- serverId?: string;
780
- type: ChannelType;
781
- worldId?: UUID;
782
- }): Promise<void>;
783
- ensureParticipantInRoom(entityId: UUID, roomId: UUID): Promise<void>;
784
- ensureWorldExists(world: World): Promise<void>;
785
- ensureRoomExists(room: Room): Promise<void>;
786
- composeState(message: Memory, filterList?: string[], includeList?: string[]): Promise<State>;
787
- useModel<T = any>(modelType: ModelType | string, params: T): Promise<any>;
788
- registerModel(modelType: ModelType | string, handler: (params: any) => Promise<any>): void;
789
- getModel(modelType: ModelType | string): ((runtime: IAgentRuntime, params: any) => Promise<any>) | undefined;
790
- registerEvent(event: string, handler: (params: any) => void): void;
791
- getEvent(event: string): ((params: any) => void)[] | undefined;
792
- emitEvent(event: string | string[], params: any): void;
793
- registerTaskWorker(taskHandler: TaskWorker): void;
794
- getTaskWorker(name: string): TaskWorker | undefined;
795
- stop(): Promise<void>;
796
- ensureEmbeddingDimension(): Promise<void>;
797
- }
798
- type KnowledgeItem = {
799
- id: UUID;
800
- content: Content;
801
- };
802
- declare enum KnowledgeScope {
803
- SHARED = "shared",
804
- PRIVATE = "private"
805
- }
806
- declare enum CacheKeyPrefix {
807
- KNOWLEDGE = "knowledge"
808
- }
809
- interface DirectoryItem {
810
- directory: string;
811
- shared?: boolean;
812
- }
813
- interface ChunkRow {
814
- id: string;
815
- }
816
- type GenerateTextParams = {
817
- runtime: IAgentRuntime;
818
- prompt: string;
819
- modelType: ModelType;
820
- maxTokens?: number;
821
- temperature?: number;
822
- frequencyPenalty?: number;
823
- presencePenalty?: number;
824
- stopSequences?: string[];
825
- };
826
- interface TokenizeTextParams {
827
- prompt: string;
828
- modelType: ModelType;
829
- }
830
- interface DetokenizeTextParams {
831
- tokens: number[];
832
- modelType: ModelType;
833
- }
834
- interface IVideoService extends Service {
835
- isVideoUrl(url: string): boolean;
836
- fetchVideoInfo(url: string): Promise<Media>;
837
- downloadVideo(videoInfo: Media): Promise<string>;
838
- processVideo(url: string, runtime: IAgentRuntime): Promise<Media>;
839
- }
840
- interface IBrowserService extends Service {
841
- getPageContent(url: string, runtime: IAgentRuntime): Promise<{
842
- title: string;
843
- description: string;
844
- bodyContent: string;
845
- }>;
846
- }
847
- interface IPdfService extends Service {
848
- convertPdfToText(pdfBuffer: Buffer): Promise<string>;
849
- }
850
- interface IFileService extends Service {
851
- uploadFile(imagePath: string, subDirectory: string, useSignedUrl: boolean, expiresIn: number): Promise<{
852
- success: boolean;
853
- url?: string;
854
- error?: string;
855
- }>;
856
- generateSignedUrl(fileName: string, expiresIn: number): Promise<string>;
857
- }
858
- interface ITeeLogService extends Service {
859
- log(agentId: string, roomId: string, entityId: string, type: string, content: string): Promise<boolean>;
860
- generateAttestation<T>(reportData: string, hashAlgorithm?: T | any): Promise<string>;
861
- getAllAgents(): Promise<TeeAgent[]>;
862
- getAgent(agentId: string): Promise<TeeAgent | null>;
863
- getLogs(query: TeeLogQuery, page: number, pageSize: number): Promise<TeePageQuery<TeeLog[]>>;
864
- }
865
- interface TestCase {
866
- name: string;
867
- fn: (runtime: IAgentRuntime) => Promise<void> | void;
868
- }
869
- interface TestSuite {
870
- name: string;
871
- tests: TestCase[];
872
- }
873
- interface TeeLog {
874
- id: string;
875
- agentId: string;
876
- roomId: string;
877
- entityId: string;
878
- type: string;
879
- content: string;
880
- timestamp: number;
881
- signature: string;
882
- }
883
- interface TeeLogQuery {
884
- agentId?: string;
885
- roomId?: string;
886
- entityId?: string;
887
- type?: string;
888
- containsContent?: string;
889
- startTimestamp?: number;
890
- endTimestamp?: number;
891
- }
892
- interface TeeAgent {
893
- id: string;
894
- agentId: string;
895
- agentName: string;
896
- createdAt: number;
897
- publicKey: string;
898
- attestation: string;
899
- }
900
- interface TeePageQuery<Result = any> {
901
- page: number;
902
- pageSize: number;
903
- total?: number;
904
- data?: Result;
905
- }
906
- declare abstract class TeeLogDAO<DB = any> {
907
- db: DB;
908
- abstract initialize(): Promise<void>;
909
- abstract addLog(log: TeeLog): Promise<boolean>;
910
- abstract getPagedLogs(query: TeeLogQuery, page: number, pageSize: number): Promise<TeePageQuery<TeeLog[]>>;
911
- abstract addAgent(agent: TeeAgent): Promise<boolean>;
912
- abstract getAgent(agentId: string): Promise<TeeAgent>;
913
- abstract getAllAgents(): Promise<TeeAgent[]>;
914
- }
915
- declare enum TEEMode {
916
- OFF = "OFF",
917
- LOCAL = "LOCAL",// For local development with simulator
918
- DOCKER = "DOCKER",// For docker development with simulator
919
- PRODUCTION = "PRODUCTION"
920
- }
921
- interface RemoteAttestationQuote {
922
- quote: string;
923
- timestamp: number;
924
- }
925
- interface DeriveKeyAttestationData {
926
- agentId: string;
927
- publicKey: string;
928
- subject?: string;
929
- }
930
- interface RemoteAttestationMessage {
931
- agentId: string;
932
- timestamp: number;
933
- message: {
934
- entityId: string;
935
- roomId: string;
936
- content: string;
937
- };
938
- }
939
- interface SgxAttestation {
940
- quote: string;
941
- timestamp: number;
942
- }
943
- declare enum TeeType {
944
- SGX_GRAMINE = "sgx_gramine",
945
- TDX_DSTACK = "tdx_dstack"
946
- }
947
- interface TeeVendorConfig {
948
- [key: string]: unknown;
949
- }
950
- interface TeePluginConfig {
951
- vendor?: string;
952
- vendorConfig?: TeeVendorConfig;
953
- }
954
- interface TaskWorker {
955
- name: string;
956
- execute: (runtime: IAgentRuntime, options: {
957
- [key: string]: unknown;
958
- }) => Promise<void>;
959
- validate?: (runtime: IAgentRuntime, message: Memory, state: State) => Promise<boolean>;
960
- }
961
- interface Task {
962
- id?: UUID;
963
- name: string;
964
- updatedAt?: number;
965
- metadata?: {
966
- updateInterval?: number;
967
- options?: {
968
- name: string;
969
- description: string;
970
- }[];
971
- [key: string]: unknown;
972
- };
973
- description: string;
974
- roomId?: UUID;
975
- worldId?: UUID;
976
- tags: string[];
977
- }
978
- declare enum Role {
979
- OWNER = "OWNER",
980
- ADMIN = "ADMIN",
981
- NONE = "NONE"
982
- }
983
- interface Setting {
984
- name: string;
985
- description: string;
986
- usageDescription: string;
987
- value: string | boolean | null;
988
- required: boolean;
989
- public?: boolean;
990
- secret?: boolean;
991
- validation?: (value: any) => boolean;
992
- dependsOn?: string[];
993
- onSetAction?: (value: any) => string;
994
- visibleIf?: (settings: {
995
- [key: string]: Setting;
996
- }) => boolean;
997
- }
998
- interface WorldSettings {
999
- [key: string]: Setting;
1000
- }
1001
- interface OnboardingConfig {
1002
- settings: {
1003
- [key: string]: Omit<Setting, "value">;
1004
- };
1005
- }
1006
-
1007
- /**
1008
- * Composes a set of example conversations based on provided actions and a specified count.
1009
- * It randomly selects examples from the provided actions and formats them with generated names.
1010
- * @param actionsData - An array of `Action` objects from which to draw examples.
1011
- * @param count - The number of examples to generate.
1012
- * @returns A string containing formatted examples of conversations.
1013
- */
1014
- declare const composeActionExamples: (actionsData: Action[], count: number) => string;
1015
- /**
1016
- * Formats the names of the provided actions into a comma-separated string.
1017
- * @param actions - An array of `Action` objects from which to extract names.
1018
- * @returns A comma-separated string of action names.
1019
- */
1020
- declare function formatActionNames(actions: Action[]): string;
1021
- /**
1022
- * Formats the provided actions into a detailed string listing each action's name and description, separated by commas and newlines.
1023
- * @param actions - An array of `Action` objects to format.
1024
- * @returns A detailed string of actions, including names and descriptions.
1025
- */
1026
- declare function formatActions(actions: Action[]): string;
1027
-
1028
- /**
1029
- * An abstract class representing a database adapter for managing various entities
1030
- * like entities, memories, entities, goals, and rooms.
1031
- */
1032
- declare abstract class DatabaseAdapter<DB = unknown> implements IDatabaseAdapter {
1033
- /**
1034
- * The database instance.
1035
- */
1036
- db: DB;
1037
- /**
1038
- * Optional close method for the database adapter.
1039
- * @returns A Promise that resolves when closing is complete.
1040
- */
1041
- abstract close(): Promise<void>;
1042
- /**
1043
- * Retrieves an account by its ID.
1044
- * @param entityId The UUID of the user account to retrieve.
1045
- * @returns A Promise that resolves to the Entity object or null if not found.
1046
- */
1047
- abstract getEntityById(entityId: UUID): Promise<Entity | null>;
1048
- abstract getEntitiesForRoom(roomId: UUID, includeComponents?: boolean): Promise<Entity[]>;
1049
- /**
1050
- * Creates a new entity in the database.
1051
- * @param entity The entity object to create.
1052
- * @returns A Promise that resolves when the account creation is complete.
1053
- */
1054
- abstract createEntity(entity: Entity): Promise<boolean>;
1055
- /**
1056
- * Updates an existing entity in the database.
1057
- * @param entity The entity object with updated properties.
1058
- * @returns A Promise that resolves when the account update is complete.
1059
- */
1060
- abstract updateEntity(entity: Entity): Promise<void>;
1061
- /**
1062
- * Retrieves a single component by entity ID and type.
1063
- * @param entityId The UUID of the entity the component belongs to
1064
- * @param type The type identifier for the component
1065
- * @param worldId Optional UUID of the world the component belongs to
1066
- * @param sourceEntityId Optional UUID of the source entity
1067
- * @returns Promise resolving to the Component if found, null otherwise
1068
- */
1069
- abstract getComponent(entityId: UUID, type: string, worldId?: UUID, sourceEntityId?: UUID): Promise<Component | null>;
1070
- /**
1071
- * Retrieves all components for an entity.
1072
- * @param entityId The UUID of the entity to get components for
1073
- * @param worldId Optional UUID of the world to filter components by
1074
- * @param sourceEntityId Optional UUID of the source entity to filter by
1075
- * @returns Promise resolving to array of Component objects
1076
- */
1077
- abstract getComponents(entityId: UUID, worldId?: UUID, sourceEntityId?: UUID): Promise<Component[]>;
1078
- /**
1079
- * Creates a new component in the database.
1080
- * @param component The component object to create
1081
- * @returns Promise resolving to true if creation was successful
1082
- */
1083
- abstract createComponent(component: Component): Promise<boolean>;
1084
- /**
1085
- * Updates an existing component in the database.
1086
- * @param component The component object with updated properties
1087
- * @returns Promise that resolves when the update is complete
1088
- */
1089
- abstract updateComponent(component: Component): Promise<void>;
1090
- /**
1091
- * Deletes a component from the database.
1092
- * @param componentId The UUID of the component to delete
1093
- * @returns Promise that resolves when the deletion is complete
1094
- */
1095
- abstract deleteComponent(componentId: UUID): Promise<void>;
1096
- /**
1097
- * Retrieves memories based on the specified parameters.
1098
- * @param params An object containing parameters for the memory retrieval.
1099
- * @returns A Promise that resolves to an array of Memory objects.
1100
- */
1101
- abstract getMemories(params: {
1102
- roomId: UUID;
1103
- count?: number;
1104
- unique?: boolean;
1105
- tableName: string;
1106
- }): Promise<Memory[]>;
1107
- abstract getMemoriesByRoomIds(params: {
1108
- roomIds: UUID[];
1109
- tableName: string;
1110
- limit?: number;
1111
- }): Promise<Memory[]>;
1112
- abstract getMemoryById(id: UUID): Promise<Memory | null>;
1113
- /**
1114
- * Retrieves multiple memories by their IDs
1115
- * @param memoryIds Array of UUIDs of the memories to retrieve
1116
- * @param tableName Optional table name to filter memories by type
1117
- * @returns Promise resolving to array of Memory objects
1118
- */
1119
- abstract getMemoriesByIds(memoryIds: UUID[], tableName?: string): Promise<Memory[]>;
1120
- /**
1121
- * Retrieves cached embeddings based on the specified query parameters.
1122
- * @param params An object containing parameters for the embedding retrieval.
1123
- * @returns A Promise that resolves to an array of objects containing embeddings and levenshtein scores.
1124
- */
1125
- abstract getCachedEmbeddings({ query_table_name, query_threshold, query_input, query_field_name, query_field_sub_name, query_match_count, }: {
1126
- query_table_name: string;
1127
- query_threshold: number;
1128
- query_input: string;
1129
- query_field_name: string;
1130
- query_field_sub_name: string;
1131
- query_match_count: number;
1132
- }): Promise<{
1133
- embedding: number[];
1134
- levenshtein_score: number;
1135
- }[]>;
1136
- /**
1137
- * Logs an event or action with the specified details.
1138
- * @param params An object containing parameters for the log entry.
1139
- * @returns A Promise that resolves when the log entry has been saved.
1140
- */
1141
- abstract log(params: {
1142
- body: {
1143
- [key: string]: unknown;
1144
- };
1145
- entityId: UUID;
1146
- roomId: UUID;
1147
- type: string;
1148
- }): Promise<void>;
1149
- /**
1150
- * Searches for memories based on embeddings and other specified parameters.
1151
- * @param params An object containing parameters for the memory search.
1152
- * @returns A Promise that resolves to an array of Memory objects.
1153
- */
1154
- abstract searchMemories(params: {
1155
- tableName: string;
1156
- roomId: UUID;
1157
- embedding: number[];
1158
- match_threshold: number;
1159
- count: number;
1160
- unique: boolean;
1161
- }): Promise<Memory[]>;
1162
- /**
1163
- * Updates the status of a specific goal.
1164
- * @param params An object containing the goalId and the new status.
1165
- * @returns A Promise that resolves when the goal status has been updated.
1166
- */
1167
- abstract updateGoalStatus(params: {
1168
- goalId: UUID;
1169
- status: GoalStatus;
1170
- }): Promise<void>;
1171
- /**
1172
- * Creates a new memory in the database.
1173
- * @param memory The memory object to create.
1174
- * @param tableName The table where the memory should be stored.
1175
- * @param unique Indicates if the memory should be unique.
1176
- * @returns A Promise that resolves when the memory has been created.
1177
- */
1178
- abstract createMemory(memory: Memory, tableName: string, unique?: boolean): Promise<UUID>;
1179
- /**
1180
- * Removes a specific memory from the database.
1181
- * @param memoryId The UUID of the memory to remove.
1182
- * @param tableName The table from which the memory should be removed.
1183
- * @returns A Promise that resolves when the memory has been removed.
1184
- */
1185
- abstract removeMemory(memoryId: UUID, tableName: string): Promise<void>;
1186
- /**
1187
- * Removes all memories associated with a specific room.
1188
- * @param roomId The UUID of the room whose memories should be removed.
1189
- * @param tableName The table from which the memories should be removed.
1190
- * @returns A Promise that resolves when all memories have been removed.
1191
- */
1192
- abstract removeAllMemories(roomId: UUID, tableName: string): Promise<void>;
1193
- /**
1194
- * Counts the number of memories in a specific room.
1195
- * @param roomId The UUID of the room for which to count memories.
1196
- * @param unique Specifies whether to count only unique memories.
1197
- * @param tableName Optional table name to count memories from.
1198
- * @returns A Promise that resolves to the number of memories.
1199
- */
1200
- abstract countMemories(roomId: UUID, unique?: boolean, tableName?: string): Promise<number>;
1201
- /**
1202
- * Retrieves goals based on specified parameters.
1203
- * @param params An object containing parameters for goal retrieval.
1204
- * @returns A Promise that resolves to an array of Goal objects.
1205
- */
1206
- abstract getGoals(params: {
1207
- roomId: UUID;
1208
- entityId?: UUID | null;
1209
- onlyInProgress?: boolean;
1210
- count?: number;
1211
- }): Promise<Goal[]>;
1212
- /**
1213
- * Updates a specific goal in the database.
1214
- * @param goal The goal object with updated properties.
1215
- * @returns A Promise that resolves when the goal has been updated.
1216
- */
1217
- abstract updateGoal(goal: Goal): Promise<void>;
1218
- /**
1219
- * Creates a new goal in the database.
1220
- * @param goal The goal object to create.
1221
- * @returns A Promise that resolves when the goal has been created.
1222
- */
1223
- abstract createGoal(goal: Goal): Promise<void>;
1224
- /**
1225
- * Removes a specific goal from the database.
1226
- * @param goalId The UUID of the goal to remove.
1227
- * @returns A Promise that resolves when the goal has been removed.
1228
- */
1229
- abstract removeGoal(goalId: UUID): Promise<void>;
1230
- /**
1231
- * Removes all goals associated with a specific room.
1232
- * @param roomId The UUID of the room whose goals should be removed.
1233
- * @returns A Promise that resolves when all goals have been removed.
1234
- */
1235
- abstract removeAllGoals(roomId: UUID): Promise<void>;
1236
- /**
1237
- * Retrieves a world by its ID.
1238
- * @param id The UUID of the world to retrieve.
1239
- * @returns A Promise that resolves to the World object or null if not found.
1240
- */
1241
- abstract getWorld(id: UUID): Promise<World | null>;
1242
- /**
1243
- * Retrieves all worlds for an agent.
1244
- * @returns A Promise that resolves to an array of World objects.
1245
- */
1246
- abstract getAllWorlds(): Promise<World[]>;
1247
- /**
1248
- * Creates a new world in the database.
1249
- * @param world The world object to create.
1250
- * @returns A Promise that resolves to the UUID of the created world.
1251
- */
1252
- abstract createWorld(world: World): Promise<UUID>;
1253
- /**
1254
- * Updates an existing world in the database.
1255
- * @param world The world object with updated properties.
1256
- * @returns A Promise that resolves when the world has been updated.
1257
- */
1258
- abstract updateWorld(world: World): Promise<void>;
1259
- /**
1260
- * Removes a specific world from the database.
1261
- * @param id The UUID of the world to remove.
1262
- * @returns A Promise that resolves when the world has been removed.
1263
- */
1264
- abstract removeWorld(id: UUID): Promise<void>;
1265
- /**
1266
- * Retrieves the room ID for a given room, if it exists.
1267
- * @param roomId The UUID of the room to retrieve.
1268
- * @returns A Promise that resolves to the room ID or null if not found.
1269
- */
1270
- abstract getRoom(roomId: UUID): Promise<Room | null>;
1271
- /**
1272
- * Retrieves all rooms for a given world.
1273
- * @param worldId The UUID of the world to retrieve rooms for.
1274
- * @returns A Promise that resolves to an array of Room objects.
1275
- */
1276
- abstract getRooms(worldId: UUID): Promise<Room[]>;
1277
- /**
1278
- * Creates a new room with an optional specified ID.
1279
- * @param roomId Optional UUID to assign to the new room.
1280
- * @returns A Promise that resolves to the UUID of the created room.
1281
- */
1282
- abstract createRoom({ id, source, type, channelId, serverId, worldId, }: Room): Promise<UUID>;
1283
- /**
1284
- * Updates a specific room in the database.
1285
- * @param room The room object with updated properties.
1286
- * @returns A Promise that resolves when the room has been updated.
1287
- */
1288
- abstract updateRoom(room: Room): Promise<void>;
1289
- /**
1290
- * Removes a specific room from the database.
1291
- * @param roomId The UUID of the room to remove.
1292
- * @returns A Promise that resolves when the room has been removed.
1293
- */
1294
- abstract deleteRoom(roomId: UUID): Promise<void>;
1295
- /**
1296
- * Retrieves room IDs for which a specific user is a participant.
1297
- * @param entityId The UUID of the user.
1298
- * @returns A Promise that resolves to an array of room IDs.
1299
- */
1300
- abstract getRoomsForParticipant(entityId: UUID): Promise<UUID[]>;
1301
- /**
1302
- * Retrieves room IDs for which specific users are participants.
1303
- * @param userIds An array of UUIDs of the users.
1304
- * @returns A Promise that resolves to an array of room IDs.
1305
- */
1306
- abstract getRoomsForParticipants(userIds: UUID[]): Promise<UUID[]>;
1307
- /**
1308
- * Adds a user as a participant to a specific room.
1309
- * @param entityId The UUID of the user to add as a participant.
1310
- * @param roomId The UUID of the room to which the user will be added.
1311
- * @returns A Promise that resolves to a boolean indicating success or failure.
1312
- */
1313
- abstract addParticipant(entityId: UUID, roomId: UUID): Promise<boolean>;
1314
- /**
1315
- * Removes a user as a participant from a specific room.
1316
- * @param entityId The UUID of the user to remove as a participant.
1317
- * @param roomId The UUID of the room from which the user will be removed.
1318
- * @returns A Promise that resolves to a boolean indicating success or failure.
1319
- */
1320
- abstract removeParticipant(entityId: UUID, roomId: UUID): Promise<boolean>;
1321
- /**
1322
- * Retrieves participants associated with a specific account.
1323
- * @param entityId The UUID of the account.
1324
- * @returns A Promise that resolves to an array of Participant objects.
1325
- */
1326
- abstract getParticipantsForEntity(entityId: UUID): Promise<Participant[]>;
1327
- /**
1328
- * Retrieves participants for a specific room.
1329
- * @param roomId The UUID of the room for which to retrieve participants.
1330
- * @returns A Promise that resolves to an array of UUIDs representing the participants.
1331
- */
1332
- abstract getParticipantsForRoom(roomId: UUID): Promise<UUID[]>;
1333
- abstract getParticipantUserState(roomId: UUID, entityId: UUID): Promise<"FOLLOWED" | "MUTED" | null>;
1334
- abstract setParticipantUserState(roomId: UUID, entityId: UUID, state: "FOLLOWED" | "MUTED" | null): Promise<void>;
1335
- /**
1336
- * Creates a new relationship between two users.
1337
- * @param params Object containing the relationship details including entity IDs, agent ID, optional tags and metadata
1338
- * @returns A Promise that resolves to a boolean indicating success or failure of the creation.
1339
- */
1340
- abstract createRelationship(params: {
1341
- sourceEntityId: UUID;
1342
- targetEntityId: UUID;
1343
- tags?: string[];
1344
- metadata?: Record<string, unknown>;
1345
- }): Promise<boolean>;
1346
- /**
1347
- * Retrieves a relationship between two users if it exists.
1348
- * @param params Object containing the entity IDs and agent ID
1349
- * @returns A Promise that resolves to the Relationship object or null if not found.
1350
- */
1351
- abstract getRelationship(params: {
1352
- sourceEntityId: UUID;
1353
- targetEntityId: UUID;
1354
- }): Promise<Relationship | null>;
1355
- /**
1356
- * Retrieves all relationships for a specific user.
1357
- * @param params Object containing the user ID, agent ID and optional tags to filter by
1358
- * @returns A Promise that resolves to an array of Relationship objects.
1359
- */
1360
- abstract getRelationships(params: {
1361
- entityId: UUID;
1362
- tags?: string[];
1363
- }): Promise<Relationship[]>;
1364
- /**
1365
- * Updates an existing relationship between two users.
1366
- * @param params Object containing the relationship details to update including entity IDs, agent ID, optional tags and metadata
1367
- * @returns A Promise that resolves to a boolean indicating success or failure of the update.
1368
- */
1369
- abstract updateRelationship(params: {
1370
- sourceEntityId: UUID;
1371
- targetEntityId: UUID;
1372
- tags?: string[];
1373
- metadata?: Record<string, unknown>;
1374
- }): Promise<void>;
1375
- /**
1376
- * Retrieves an agent by its ID.
1377
- * @param agentId The UUID of the agent to retrieve.
1378
- * @returns A Promise that resolves to the Agent object or null if not found.
1379
- */
1380
- abstract getAgent(agentId: UUID): Promise<Agent | null>;
1381
- /**
1382
- * Retrieves all agents from the database.
1383
- * @returns A Promise that resolves to an array of Agent objects.
1384
- */
1385
- abstract getAgents(): Promise<Agent[]>;
1386
- /**
1387
- * Creates a new agent in the database.
1388
- * @param agent The agent object to create.
1389
- * @returns A Promise that resolves to a boolean indicating success or failure of the creation.
1390
- */
1391
- abstract createAgent(agent: Partial<Agent>): Promise<boolean>;
1392
- /**
1393
- * Updates an existing agent in the database.
1394
- * @param agentId The UUID of the agent to update.
1395
- * @param agent The agent object with updated properties.
1396
- * @returns A Promise that resolves to a boolean indicating success or failure of the update.
1397
- */
1398
- abstract updateAgent(agentId: UUID, agent: Partial<Agent>): Promise<boolean>;
1399
- /**
1400
- * Deletes an agent from the database.
1401
- * @param agentId The UUID of the agent to delete.
1402
- * @returns A Promise that resolves to a boolean indicating success or failure of the deletion.
1403
- */
1404
- abstract deleteAgent(agentId: UUID): Promise<boolean>;
1405
- /**
1406
- * Ensures an agent exists in the database.
1407
- * @param agent The agent object to ensure exists.
1408
- * @returns A Promise that resolves when the agent has been ensured to exist.
1409
- */
1410
- abstract ensureAgentExists(agent: Partial<Agent>): Promise<void>;
1411
- /**
1412
- * Ensures an embedding dimension exists in the database.
1413
- * @param dimension The dimension to ensure exists.
1414
- * @returns A Promise that resolves when the embedding dimension has been ensured to exist.
1415
- */
1416
- abstract ensureEmbeddingDimension(dimension: number): Promise<void>;
1417
- /**
1418
- * Retrieves a cached value by key from the database.
1419
- * @param key The key to look up in the cache
1420
- * @returns Promise resolving to the cached string value
1421
- */
1422
- abstract getCache<T>(key: string): Promise<T | undefined>;
1423
- /**
1424
- * Sets a value in the cache with the given key.
1425
- * @param params Object containing the cache key and value
1426
- * @param key The key to store the value under
1427
- * @param value The string value to cache
1428
- * @returns Promise resolving to true if the cache was set successfully
1429
- */
1430
- abstract setCache<T>(key: string, value: T): Promise<boolean>;
1431
- /**
1432
- * Deletes a value from the cache by key.
1433
- * @param key The key to delete from the cache
1434
- * @returns Promise resolving to true if the value was successfully deleted
1435
- */
1436
- abstract deleteCache(key: string): Promise<boolean>;
1437
- /**
1438
- * Creates a new task instance in the database.
1439
- * @param task The task object to create
1440
- * @returns Promise resolving to the UUID of the created task
1441
- */
1442
- abstract createTask(task: Task): Promise<UUID>;
1443
- /**
1444
- * Retrieves tasks based on specified parameters.
1445
- * @param params Object containing optional roomId and tags to filter tasks
1446
- * @returns Promise resolving to an array of Task objects
1447
- */
1448
- abstract getTasks(params: {
1449
- roomId?: UUID;
1450
- tags?: string[];
1451
- }): Promise<Task[]>;
1452
- /**
1453
- * Retrieves a specific task by its ID.
1454
- * @param id The UUID of the task to retrieve
1455
- * @returns Promise resolving to the Task object if found, null otherwise
1456
- */
1457
- abstract getTask(id: UUID): Promise<Task | null>;
1458
- /**
1459
- * Retrieves a specific task by its name.
1460
- * @param name The name of the task to retrieve
1461
- * @returns Promise resolving to the Task object if found, null otherwise
1462
- */
1463
- abstract getTasksByName(name: string): Promise<Task[]>;
1464
- /**
1465
- * Updates an existing task in the database.
1466
- * @param id The UUID of the task to update
1467
- * @param task Partial Task object containing the fields to update
1468
- * @returns Promise resolving when the update is complete
1469
- */
1470
- abstract updateTask(id: UUID, task: Partial<Task>): Promise<void>;
1471
- /**
1472
- * Deletes a task from the database.
1473
- * @param id The UUID of the task to delete
1474
- * @returns Promise resolving when the deletion is complete
1475
- */
1476
- abstract deleteTask(id: UUID): Promise<void>;
1477
- }
1478
-
1479
- declare function findEntityByName(runtime: IAgentRuntime, message: Memory, state: State): Promise<Entity | null>;
1480
- declare const createUniqueUuid: (runtime: any, baseUserId: UUID | string) => UUID;
1481
- /**
1482
- * Get details for a list of entities.
1483
- */
1484
- declare function getEntityDetails({ runtime, roomId, }: {
1485
- runtime: IAgentRuntime;
1486
- roomId: UUID;
1487
- }): Promise<any[]>;
1488
-
1489
- interface Settings {
1490
- [key: string]: string | undefined;
1491
- }
1492
- /**
1493
- * Recursively searches for a .env file starting from the current directory
1494
- * and moving up through parent directories (Node.js only)
1495
- * @param {string} [startDir=process.cwd()] - Starting directory for the search
1496
- * @returns {string|null} Path to the nearest .env file or null if not found
1497
- */
1498
- declare function findNearestEnvFile(startDir?: string): string;
1499
- /**
1500
- * Configures environment settings for browser usage
1501
- * @param {Settings} settings - Object containing environment variables
1502
- */
1503
- declare function configureSettings(settings: Settings): void;
1504
- /**
1505
- * Loads environment variables from the nearest .env file in Node.js
1506
- * or returns configured settings in browser
1507
- * @returns {Settings} Environment variables object
1508
- * @throws {Error} If no .env file is found in Node.js environment
1509
- */
1510
- declare function loadEnvConfig(): Settings;
1511
- /**
1512
- * Gets a specific environment variable
1513
- * @param {string} key - The environment variable key
1514
- * @param {string} [defaultValue] - Optional default value if key doesn't exist
1515
- * @returns {string|undefined} The environment variable value or default value
1516
- */
1517
- declare function getEnvVariable(key: string, defaultValue?: string): string | undefined;
1518
- /**
1519
- * Checks if a specific environment variable exists
1520
- * @param {string} key - The environment variable key
1521
- * @returns {boolean} True if the environment variable exists
1522
- */
1523
- declare function hasEnvVariable(key: string): boolean;
1524
- declare const settings: Settings;
1525
- declare const MessageExampleSchema: z.ZodObject<{
1526
- name: z.ZodString;
1527
- content: z.ZodIntersection<z.ZodObject<{
1528
- text: z.ZodString;
1529
- action: z.ZodOptional<z.ZodString>;
1530
- source: z.ZodOptional<z.ZodString>;
1531
- url: z.ZodOptional<z.ZodString>;
1532
- inReplyTo: z.ZodOptional<z.ZodString>;
1533
- attachments: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
1534
- }, "strip", z.ZodTypeAny, {
1535
- text?: string;
1536
- source?: string;
1537
- url?: string;
1538
- inReplyTo?: string;
1539
- attachments?: any[];
1540
- action?: string;
1541
- }, {
1542
- text?: string;
1543
- source?: string;
1544
- url?: string;
1545
- inReplyTo?: string;
1546
- attachments?: any[];
1547
- action?: string;
1548
- }>, z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1549
- }, "strip", z.ZodTypeAny, {
1550
- name?: string;
1551
- content?: {
1552
- text?: string;
1553
- source?: string;
1554
- url?: string;
1555
- inReplyTo?: string;
1556
- attachments?: any[];
1557
- action?: string;
1558
- } & Record<string, unknown>;
1559
- }, {
1560
- name?: string;
1561
- content?: {
1562
- text?: string;
1563
- source?: string;
1564
- url?: string;
1565
- inReplyTo?: string;
1566
- attachments?: any[];
1567
- action?: string;
1568
- } & Record<string, unknown>;
1569
- }>;
1570
- declare const PluginSchema: z.ZodObject<{
1571
- name: z.ZodString;
1572
- description: z.ZodString;
1573
- actions: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
1574
- providers: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
1575
- evaluators: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
1576
- services: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
1577
- clients: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
1578
- }, "strip", z.ZodTypeAny, {
1579
- actions?: any[];
1580
- providers?: any[];
1581
- description?: string;
1582
- name?: string;
1583
- evaluators?: any[];
1584
- services?: any[];
1585
- clients?: any[];
1586
- }, {
1587
- actions?: any[];
1588
- providers?: any[];
1589
- description?: string;
1590
- name?: string;
1591
- evaluators?: any[];
1592
- services?: any[];
1593
- clients?: any[];
1594
- }>;
1595
- declare const CharacterSchema: z.ZodObject<{
1596
- id: z.ZodOptional<z.ZodString>;
1597
- name: z.ZodString;
1598
- system: z.ZodOptional<z.ZodString>;
1599
- templates: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
1600
- bio: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
1601
- messageExamples: z.ZodArray<z.ZodArray<z.ZodObject<{
1602
- name: z.ZodString;
1603
- content: z.ZodIntersection<z.ZodObject<{
1604
- text: z.ZodString;
1605
- action: z.ZodOptional<z.ZodString>;
1606
- source: z.ZodOptional<z.ZodString>;
1607
- url: z.ZodOptional<z.ZodString>;
1608
- inReplyTo: z.ZodOptional<z.ZodString>;
1609
- attachments: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
1610
- }, "strip", z.ZodTypeAny, {
1611
- text?: string;
1612
- source?: string;
1613
- url?: string;
1614
- inReplyTo?: string;
1615
- attachments?: any[];
1616
- action?: string;
1617
- }, {
1618
- text?: string;
1619
- source?: string;
1620
- url?: string;
1621
- inReplyTo?: string;
1622
- attachments?: any[];
1623
- action?: string;
1624
- }>, z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1625
- }, "strip", z.ZodTypeAny, {
1626
- name?: string;
1627
- content?: {
1628
- text?: string;
1629
- source?: string;
1630
- url?: string;
1631
- inReplyTo?: string;
1632
- attachments?: any[];
1633
- action?: string;
1634
- } & Record<string, unknown>;
1635
- }, {
1636
- name?: string;
1637
- content?: {
1638
- text?: string;
1639
- source?: string;
1640
- url?: string;
1641
- inReplyTo?: string;
1642
- attachments?: any[];
1643
- action?: string;
1644
- } & Record<string, unknown>;
1645
- }>, "many">, "many">;
1646
- postExamples: z.ZodArray<z.ZodString, "many">;
1647
- topics: z.ZodArray<z.ZodString, "many">;
1648
- adjectives: z.ZodArray<z.ZodString, "many">;
1649
- knowledge: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodObject<{
1650
- path: z.ZodString;
1651
- shared: z.ZodOptional<z.ZodBoolean>;
1652
- }, "strip", z.ZodTypeAny, {
1653
- shared?: boolean;
1654
- path?: string;
1655
- }, {
1656
- shared?: boolean;
1657
- path?: string;
1658
- }>, z.ZodObject<{
1659
- directory: z.ZodString;
1660
- shared: z.ZodOptional<z.ZodBoolean>;
1661
- }, "strip", z.ZodTypeAny, {
1662
- shared?: boolean;
1663
- directory?: string;
1664
- }, {
1665
- shared?: boolean;
1666
- directory?: string;
1667
- }>]>, "many">>;
1668
- plugins: z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodArray<z.ZodObject<{
1669
- name: z.ZodString;
1670
- description: z.ZodString;
1671
- actions: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
1672
- providers: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
1673
- evaluators: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
1674
- services: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
1675
- clients: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
1676
- }, "strip", z.ZodTypeAny, {
1677
- actions?: any[];
1678
- providers?: any[];
1679
- description?: string;
1680
- name?: string;
1681
- evaluators?: any[];
1682
- services?: any[];
1683
- clients?: any[];
1684
- }, {
1685
- actions?: any[];
1686
- providers?: any[];
1687
- description?: string;
1688
- name?: string;
1689
- evaluators?: any[];
1690
- services?: any[];
1691
- clients?: any[];
1692
- }>, "many">]>;
1693
- settings: z.ZodOptional<z.ZodObject<{
1694
- secrets: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
1695
- voice: z.ZodOptional<z.ZodObject<{
1696
- model: z.ZodOptional<z.ZodString>;
1697
- url: z.ZodOptional<z.ZodString>;
1698
- }, "strip", z.ZodTypeAny, {
1699
- url?: string;
1700
- model?: string;
1701
- }, {
1702
- url?: string;
1703
- model?: string;
1704
- }>>;
1705
- model: z.ZodOptional<z.ZodString>;
1706
- modelConfig: z.ZodOptional<z.ZodObject<{
1707
- maxInputTokens: z.ZodOptional<z.ZodNumber>;
1708
- maxOutputTokens: z.ZodOptional<z.ZodNumber>;
1709
- temperature: z.ZodOptional<z.ZodNumber>;
1710
- frequency_penalty: z.ZodOptional<z.ZodNumber>;
1711
- presence_penalty: z.ZodOptional<z.ZodNumber>;
1712
- }, "strip", z.ZodTypeAny, {
1713
- maxInputTokens?: number;
1714
- maxOutputTokens?: number;
1715
- temperature?: number;
1716
- frequency_penalty?: number;
1717
- presence_penalty?: number;
1718
- }, {
1719
- maxInputTokens?: number;
1720
- maxOutputTokens?: number;
1721
- temperature?: number;
1722
- frequency_penalty?: number;
1723
- presence_penalty?: number;
1724
- }>>;
1725
- embeddingModel: z.ZodOptional<z.ZodString>;
1726
- }, "strip", z.ZodTypeAny, {
1727
- secrets?: Record<string, string>;
1728
- model?: string;
1729
- voice?: {
1730
- url?: string;
1731
- model?: string;
1732
- };
1733
- modelConfig?: {
1734
- maxInputTokens?: number;
1735
- maxOutputTokens?: number;
1736
- temperature?: number;
1737
- frequency_penalty?: number;
1738
- presence_penalty?: number;
1739
- };
1740
- embeddingModel?: string;
1741
- }, {
1742
- secrets?: Record<string, string>;
1743
- model?: string;
1744
- voice?: {
1745
- url?: string;
1746
- model?: string;
1747
- };
1748
- modelConfig?: {
1749
- maxInputTokens?: number;
1750
- maxOutputTokens?: number;
1751
- temperature?: number;
1752
- frequency_penalty?: number;
1753
- presence_penalty?: number;
1754
- };
1755
- embeddingModel?: string;
1756
- }>>;
1757
- style: z.ZodObject<{
1758
- all: z.ZodArray<z.ZodString, "many">;
1759
- chat: z.ZodArray<z.ZodString, "many">;
1760
- post: z.ZodArray<z.ZodString, "many">;
1761
- }, "strip", z.ZodTypeAny, {
1762
- all?: string[];
1763
- chat?: string[];
1764
- post?: string[];
1765
- }, {
1766
- all?: string[];
1767
- chat?: string[];
1768
- post?: string[];
1769
- }>;
1770
- }, "strip", z.ZodTypeAny, {
1771
- id?: string;
1772
- name?: string;
1773
- knowledge?: (string | {
1774
- shared?: boolean;
1775
- path?: string;
1776
- } | {
1777
- shared?: boolean;
1778
- directory?: string;
1779
- })[];
1780
- settings?: {
1781
- secrets?: Record<string, string>;
1782
- model?: string;
1783
- voice?: {
1784
- url?: string;
1785
- model?: string;
1786
- };
1787
- modelConfig?: {
1788
- maxInputTokens?: number;
1789
- maxOutputTokens?: number;
1790
- temperature?: number;
1791
- frequency_penalty?: number;
1792
- presence_penalty?: number;
1793
- };
1794
- embeddingModel?: string;
1795
- };
1796
- system?: string;
1797
- templates?: Record<string, string>;
1798
- bio?: string | string[];
1799
- messageExamples?: {
1800
- name?: string;
1801
- content?: {
1802
- text?: string;
1803
- source?: string;
1804
- url?: string;
1805
- inReplyTo?: string;
1806
- attachments?: any[];
1807
- action?: string;
1808
- } & Record<string, unknown>;
1809
- }[][];
1810
- postExamples?: string[];
1811
- topics?: string[];
1812
- adjectives?: string[];
1813
- plugins?: string[] | {
1814
- actions?: any[];
1815
- providers?: any[];
1816
- description?: string;
1817
- name?: string;
1818
- evaluators?: any[];
1819
- services?: any[];
1820
- clients?: any[];
1821
- }[];
1822
- style?: {
1823
- all?: string[];
1824
- chat?: string[];
1825
- post?: string[];
1826
- };
1827
- }, {
1828
- id?: string;
1829
- name?: string;
1830
- knowledge?: (string | {
1831
- shared?: boolean;
1832
- path?: string;
1833
- } | {
1834
- shared?: boolean;
1835
- directory?: string;
1836
- })[];
1837
- settings?: {
1838
- secrets?: Record<string, string>;
1839
- model?: string;
1840
- voice?: {
1841
- url?: string;
1842
- model?: string;
1843
- };
1844
- modelConfig?: {
1845
- maxInputTokens?: number;
1846
- maxOutputTokens?: number;
1847
- temperature?: number;
1848
- frequency_penalty?: number;
1849
- presence_penalty?: number;
1850
- };
1851
- embeddingModel?: string;
1852
- };
1853
- system?: string;
1854
- templates?: Record<string, string>;
1855
- bio?: string | string[];
1856
- messageExamples?: {
1857
- name?: string;
1858
- content?: {
1859
- text?: string;
1860
- source?: string;
1861
- url?: string;
1862
- inReplyTo?: string;
1863
- attachments?: any[];
1864
- action?: string;
1865
- } & Record<string, unknown>;
1866
- }[][];
1867
- postExamples?: string[];
1868
- topics?: string[];
1869
- adjectives?: string[];
1870
- plugins?: string[] | {
1871
- actions?: any[];
1872
- providers?: any[];
1873
- description?: string;
1874
- name?: string;
1875
- evaluators?: any[];
1876
- services?: any[];
1877
- clients?: any[];
1878
- }[];
1879
- style?: {
1880
- all?: string[];
1881
- chat?: string[];
1882
- post?: string[];
1883
- };
1884
- }>;
1885
- type CharacterConfig = z.infer<typeof CharacterSchema>;
1886
- declare function validateCharacterConfig(json: unknown): CharacterConfig;
1887
-
1888
- declare const dynamicImport: (specifier: string) => Promise<any>;
1889
- declare const registerDynamicImport: (specifier: string, module: any) => void;
1890
- declare function handlePluginImporting(plugins: string[]): Promise<any[]>;
1891
-
1892
- declare const logger: pino.Logger<string, boolean>;
1893
- declare const elizaLogger: pino.Logger<string, boolean>;
1894
-
1895
- /**
1896
- * Manage memories in the database.
1897
- */
1898
- declare class MemoryManager implements IMemoryManager {
1899
- /**
1900
- * The AgentRuntime instance associated with this manager.
1901
- */
1902
- runtime: IAgentRuntime;
1903
- /**
1904
- * The name of the database table this manager operates on.
1905
- */
1906
- tableName: string;
1907
- /**
1908
- * Constructs a new MemoryManager instance.
1909
- * @param opts Options for the manager.
1910
- * @param opts.tableName The name of the table this manager will operate on.
1911
- * @param opts.runtime The AgentRuntime instance associated with this manager.
1912
- */
1913
- constructor(opts: {
1914
- tableName: string;
1915
- runtime: IAgentRuntime;
1916
- });
1917
- private validateMetadata;
1918
- /**
1919
- * Adds an embedding vector to a memory object. If the memory already has an embedding, it is returned as is.
1920
- * @param memory The memory object to add an embedding to.
1921
- * @returns A Promise resolving to the memory object, potentially updated with an embedding vector.
1922
- */
1923
- /**
1924
- * Adds an embedding vector to a memory object if one doesn't already exist.
1925
- * The embedding is generated from the memory's text content using the runtime's
1926
- * embedding model. If the memory has no text content, an error is thrown.
1927
- *
1928
- * @param memory The memory object to add an embedding to
1929
- * @returns The memory object with an embedding vector added
1930
- * @throws Error if the memory content is empty
1931
- */
1932
- addEmbeddingToMemory(memory: Memory): Promise<Memory>;
1933
- /**
1934
- * Retrieves a list of memories by user IDs, with optional deduplication.
1935
- * @param opts Options including user IDs, count, and uniqueness.
1936
- * @param opts.roomId The room ID to retrieve memories for.
1937
- * @param opts.count The number of memories to retrieve.
1938
- * @param opts.unique Whether to retrieve unique memories only.
1939
- * @returns A Promise resolving to an array of Memory objects.
1940
- */
1941
- getMemories(opts: {
1942
- roomId: UUID;
1943
- count?: number;
1944
- unique?: boolean;
1945
- start?: number;
1946
- end?: number;
1947
- agentId?: UUID;
1948
- }): Promise<Memory[]>;
1949
- getCachedEmbeddings(content: string): Promise<{
1950
- embedding: number[];
1951
- levenshtein_score: number;
1952
- }[]>;
1953
- /**
1954
- * Searches for memories similar to a given embedding vector.
1955
- * @param opts Options for the memory search
1956
- * @param opts.match_threshold The similarity threshold for matching memories.
1957
- * @param opts.count The maximum number of memories to retrieve.
1958
- * @param opts.roomId The room ID to retrieve memories for.
1959
- * @param opts.agentId The agent ID to retrieve memories for.
1960
- * @param opts.unique Whether to retrieve unique memories only.
1961
- * @returns A Promise resolving to an array of Memory objects that match the embedding.
1962
- */
1963
- searchMemories(opts: {
1964
- embedding: number[];
1965
- match_threshold?: number;
1966
- count?: number;
1967
- roomId: UUID;
1968
- agentId?: UUID;
1969
- unique?: boolean;
1970
- }): Promise<Memory[]>;
1971
- /**
1972
- * Creates a new memory in the database, with an option to check for similarity before insertion.
1973
- * @param memory The memory object to create.
1974
- * @param unique Whether to check for similarity before insertion.
1975
- * @returns A Promise that resolves when the operation completes.
1976
- */
1977
- createMemory(memory: Memory, unique?: boolean): Promise<UUID>;
1978
- getMemoriesByRoomIds(params: {
1979
- roomIds: UUID[];
1980
- limit?: number;
1981
- agentId?: UUID;
1982
- }): Promise<Memory[]>;
1983
- getMemoryById(id: UUID): Promise<Memory | null>;
1984
- /**
1985
- * Removes a memory from the database by its ID.
1986
- * @param memoryId The ID of the memory to remove.
1987
- * @returns A Promise that resolves when the operation completes.
1988
- */
1989
- removeMemory(memoryId: UUID): Promise<void>;
1990
- /**
1991
- * Removes all memories associated with a set of user IDs.
1992
- * @param roomId The room ID to remove memories for.
1993
- * @returns A Promise that resolves when the operation completes.
1994
- */
1995
- removeAllMemories(roomId: UUID): Promise<void>;
1996
- /**
1997
- * Counts the number of memories associated with a set of user IDs, with an option for uniqueness.
1998
- * @param roomId The room ID to count memories for.
1999
- * @param unique Whether to count unique memories only.
2000
- * @returns A Promise resolving to the count of memories.
2001
- */
2002
- countMemories(roomId: UUID, unique?: boolean): Promise<number>;
2003
- private validateMetadataRequirements;
2004
- }
2005
-
2006
- /**
2007
- * Composes a context string by replacing placeholders in a template with corresponding values from the state.
2008
- *
2009
- * This function takes a template string with placeholders in the format `{{placeholder}}` and a state object.
2010
- * It replaces each placeholder with the value from the state object that matches the placeholder's name.
2011
- * If a matching key is not found in the state object for a given placeholder, the placeholder is replaced with an empty string.
2012
- *
2013
- * @param {Object} params - The parameters for composing the context.
2014
- * @param {State} params.state - The state object containing values to replace the placeholders in the template.
2015
- * @param {TemplateType} params.template - The template string or function containing placeholders to be replaced with state values.
2016
- * @returns {string} The composed context string with placeholders replaced by corresponding state values.
2017
- *
2018
- * @example
2019
- * // Given a state object and a template
2020
- * const state = { userName: "Alice", userAge: 30 };
2021
- * const template = "Hello, {{userName}}! You are {{userAge}} years old";
2022
- *
2023
- * // Composing the context with simple string replacement will result in:
2024
- * // "Hello, Alice! You are 30 years old."
2025
- * const contextSimple = composePrompt({ state, template });
2026
- *
2027
- * // Using composePrompt with a template function for dynamic template
2028
- * const template = ({ state }) => {
2029
- * const tone = Math.random() > 0.5 ? "kind" : "rude";
2030
- * return `Hello, {{userName}}! You are {{userAge}} years old. Be ${tone}`;
2031
- * };
2032
- * const contextSimple = composePrompt({ state, template });
2033
- */
2034
- declare const composePrompt: ({ state, template, }: {
2035
- state: State;
2036
- template: TemplateType;
2037
- }) => string;
2038
- /**
2039
- * Adds a header to a body of text.
2040
- *
2041
- * This function takes a header string and a body string and returns a new string with the header prepended to the body.
2042
- * If the body string is empty, the header is returned as is.
2043
- *
2044
- * @param {string} header - The header to add to the body.
2045
- * @param {string} body - The body to which to add the header.
2046
- * @returns {string} The body with the header prepended.
2047
- *
2048
- * @example
2049
- * // Given a header and a body
2050
- * const header = "Header";
2051
- * const body = "Body";
2052
- *
2053
- * // Adding the header to the body will result in:
2054
- * // "Header\nBody"
2055
- * const text = addHeader(header, body);
2056
- */
2057
- declare const addHeader: (header: string, body: string) => string;
2058
- /**
2059
- * Generates a string with random user names populated in a template.
2060
- *
2061
- * This function generates random user names and populates placeholders
2062
- * in the provided template with these names. Placeholders in the template should follow the format `{{userX}}`
2063
- * where `X` is the position of the user (e.g., `{{name1}}`, `{{name2}}`).
2064
- *
2065
- * @param {string} template - The template string containing placeholders for random user names.
2066
- * @param {number} length - The number of random user names to generate.
2067
- * @returns {string} The template string with placeholders replaced by random user names.
2068
- *
2069
- * @example
2070
- * // Given a template and a length
2071
- * const template = "Hello, {{name1}}! Meet {{name2}} and {{name3}}.";
2072
- * const length = 3;
2073
- *
2074
- * // Composing the random user string will result in:
2075
- * // "Hello, John! Meet Alice and Bob."
2076
- * const result = composeRandomUser(template, length);
2077
- */
2078
- declare const composeRandomUser: (template: string, length: number) => string;
2079
- declare const formatPosts: ({ messages, entities, conversationHeader, }: {
2080
- messages: Memory[];
2081
- entities: Entity[];
2082
- conversationHeader?: boolean;
2083
- }) => string;
2084
- /**
2085
- * Format messages into a string
2086
- * @param {Object} params - The formatting parameters
2087
- * @param {Memory[]} params.messages - List of messages to format
2088
- * @param {Entity[]} params.entities - List of entities for name resolution
2089
- * @returns {string} Formatted message string with timestamps and user information
2090
- */
2091
- declare const formatMessages: ({ messages, entities, }: {
2092
- messages: Memory[];
2093
- entities: Entity[];
2094
- }) => string;
2095
- declare const formatTimestamp: (messageDate: number) => string;
2096
- declare const shouldRespondTemplate = "# Task: Decide on behalf of {{agentName}} whether they should respond to the message, ignore it or stop the conversation.\n{{providers}}\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.\nIf responding with the RESPOND action, include a list of optional providers that could be relevant to the response.\nResponse format should be formatted in a valid JSON block like this:\n```json\n{\n \"name\": \"{{agentName}}\",\n \"action\": \"RESPOND\" | \"IGNORE\" | \"STOP\",\n \"providers\": [\"<string>\", \"<string>\", ...]\n}\n```\nYour response should include the valid JSON block and nothing else.";
2097
- declare const messageHandlerTemplate = "# Task: Generate dialog and actions for the character {{agentName}}.\n{{providers}}\n# Instructions: Write 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.\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\"thought\" should be a short description of what the agent is thinking about and planning.\n\"actions\" should be an array 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 an optional array of the providers that {{agentName}} will use to have the right context for responding and acting\n\"evaluators\" should be an optional array of the evaluators that {{agentName}} will use to evaluate the conversation after responding\n\"plan\" should be explanation of the message you plan to send, the actions you plan to take, and the data providers you plan to use.\nThese are the available valid actions: {{actionNames}}\n\nResponse format should be formatted in a valid JSON block like this:\n```json\n{\n \"thought\": \"<string>\",\n \"plan\": \"<string>\",\n \"actions\": [\"<string>\", \"<string>\", ...],\n \"providers\": [\"<string>\", \"<string>\", ...]\n}\n```\n\nYour response should include the valid JSON block and nothing else.";
2098
- declare const booleanFooter = "Respond with only a YES or a NO.";
2099
- /**
2100
- * Parses a string to determine its boolean equivalent.
2101
- *
2102
- * Recognized affirmative values: "YES", "Y", "TRUE", "T", "1", "ON", "ENABLE"
2103
- * Recognized negative values: "NO", "N", "FALSE", "F", "0", "OFF", "DISABLE"
2104
- *
2105
- * @param {string | undefined | null} value - The input text to parse
2106
- * @returns {boolean} - Returns `true` for affirmative inputs, `false` for negative or unrecognized inputs
2107
- */
2108
- declare function parseBooleanFromText(value: string | undefined | null): boolean;
2109
- declare const stringArrayFooter = "Respond with a JSON array containing the values in a valid JSON block formatted for markdown with this structure:\n```json\n[\n 'value',\n 'value'\n]\n```\n\nYour response must include the valid JSON block.";
2110
- /**
2111
- * Parses a JSON array from a given text. The function looks for a JSON block wrapped in triple backticks
2112
- * with `json` language identifier, and if not found, it searches for an array pattern within the text.
2113
- * It then attempts to parse the JSON string into a JavaScript object. If parsing is successful and the result
2114
- * is an array, it returns the array; otherwise, it returns null.
2115
- *
2116
- * @param text - The input text from which to extract and parse the JSON array.
2117
- * @returns An array parsed from the JSON string if successful; otherwise, null.
2118
- */
2119
- declare function parseJsonArrayFromText(text: string): any[];
2120
- /**
2121
- * Parses a JSON object from a given text. The function looks for a JSON block wrapped in triple backticks
2122
- * with `json` language identifier, and if not found, it searches for an object pattern within the text.
2123
- * It then attempts to parse the JSON string into a JavaScript object. If parsing is successful and the result
2124
- * is an object (but not an array), it returns the object; otherwise, it tries to parse an array if the result
2125
- * is an array, or returns null if parsing is unsuccessful or the result is neither an object nor an array.
2126
- *
2127
- * @param text - The input text from which to extract and parse the JSON object.
2128
- * @returns An object parsed from the JSON string if successful; otherwise, null or the result of parsing an array.
2129
- */
2130
- declare function parseJSONObjectFromText(text: string): Record<string, any> | null;
2131
- /**
2132
- * Extracts specific attributes (e.g., user, text, action) from a JSON-like string using regex.
2133
- * @param response - The cleaned string response to extract attributes from.
2134
- * @param attributesToExtract - An array of attribute names to extract.
2135
- * @returns An object containing the extracted attributes.
2136
- */
2137
- declare function extractAttributes(response: string, attributesToExtract?: string[]): {
2138
- [key: string]: string | undefined;
2139
- };
2140
- /**
2141
- * Normalizes a JSON-like string by correcting formatting issues:
2142
- * - Removes extra spaces after '{' and before '}'.
2143
- * - Wraps unquoted values in double quotes.
2144
- * - Converts single-quoted values to double-quoted.
2145
- * - Ensures consistency in key-value formatting.
2146
- * - Normalizes mixed adjacent quote pairs.
2147
- *
2148
- * This is useful for cleaning up improperly formatted JSON strings
2149
- * before parsing them into valid JSON.
2150
- *
2151
- * @param str - The JSON-like string to normalize.
2152
- * @returns A properly formatted JSON string.
2153
- */
2154
- declare const normalizeJsonString: (str: string) => string;
2155
- /**
2156
- * Cleans a JSON-like response string by removing unnecessary markers, line breaks, and extra whitespace.
2157
- * This is useful for handling improperly formatted JSON responses from external sources.
2158
- *
2159
- * @param response - The raw JSON-like string response to clean.
2160
- * @returns The cleaned string, ready for parsing or further processing.
2161
- */
2162
- declare function cleanJsonResponse(response: string): string;
2163
- declare const postActionResponseFooter = "Choose any combination of [LIKE], [RETWEET], [QUOTE], and [REPLY] that are appropriate. Each action must be on its own line. Your response must only include the chosen actions.";
2164
- type ActionResponse = {
2165
- like: boolean;
2166
- retweet: boolean;
2167
- quote?: boolean;
2168
- reply?: boolean;
2169
- };
2170
- declare const parseActionResponseFromText: (text: string) => {
2171
- actions: ActionResponse;
2172
- };
2173
- /**
2174
- * Truncate text to fit within the character limit, ensuring it ends at a complete sentence.
2175
- */
2176
- declare function truncateToCompleteSentence(text: string, maxLength: number): string;
2177
- declare function splitChunks(content: string, chunkSize?: number, bleed?: number): Promise<string[]>;
2178
- /**
2179
- * Trims the provided text prompt to a specified token limit using a tokenizer model and type.
2180
- */
2181
- declare function trimTokens(prompt: string, maxTokens: number, runtime: IAgentRuntime): Promise<any>;
2182
-
2183
- interface ServerOwnershipState {
2184
- servers: {
2185
- [serverId: string]: World;
2186
- };
2187
- }
2188
- /**
2189
- * Gets a user's role from world metadata
2190
- */
2191
- declare function getUserServerRole(runtime: IAgentRuntime, entityId: string, serverId: string): Promise<Role>;
2192
- /**
2193
- * Finds a server where the given user is the owner
2194
- */
2195
- declare function findWorldForOwner(runtime: IAgentRuntime, entityId: string): Promise<World | null>;
2196
-
2197
- /**
2198
- * Represents the runtime environment for an agent, handling message processing,
2199
- * action registration, and interaction with external services like OpenAI and Supabase.
2200
- */
2201
- declare class AgentRuntime implements IAgentRuntime {
2202
- #private;
2203
- readonly agentId: UUID;
2204
- readonly character: Character;
2205
- databaseAdapter: IDatabaseAdapter;
2206
- readonly actions: Action[];
2207
- readonly evaluators: Evaluator[];
2208
- readonly providers: Provider[];
2209
- readonly plugins: Plugin[];
2210
- events: Map<string, ((params: any) => void)[]>;
2211
- stateCache: Map<`${string}-${string}-${string}-${string}-${string}`, {
2212
- values: {
2213
- [key: string]: any;
2214
- };
2215
- data: {
2216
- [key: string]: any;
2217
- };
2218
- text: string;
2219
- }>;
2220
- readonly fetch: typeof fetch;
2221
- services: Map<ServiceType, Service>;
2222
- adapters: IDatabaseAdapter[];
2223
- private readonly knowledgeRoot;
2224
- models: Map<string, ((params: any) => Promise<any>)[]>;
2225
- routes: Route[];
2226
- private taskWorkers;
2227
- constructor(opts: {
2228
- conversationLength?: number;
2229
- agentId?: UUID;
2230
- character?: Character;
2231
- plugins?: Plugin[];
2232
- fetch?: typeof fetch;
2233
- databaseAdapter?: IDatabaseAdapter;
2234
- adapters?: IDatabaseAdapter[];
2235
- events?: {
2236
- [key: string]: ((params: any) => void)[];
2237
- };
2238
- ignoreBootstrap?: boolean;
2239
- });
2240
- /**
2241
- * Registers a plugin with the runtime and initializes its components
2242
- * @param plugin The plugin to register
2243
- */
2244
- registerPlugin(plugin: Plugin): Promise<void>;
2245
- getAllServices(): Map<ServiceType, Service>;
2246
- stop(): Promise<void>;
2247
- initialize(): Promise<void>;
2248
- private handleProcessingError;
2249
- private checkExistingKnowledge;
2250
- getKnowledge(message: Memory): Promise<KnowledgeItem[]>;
2251
- addKnowledge(item: KnowledgeItem, options?: {
2252
- targetTokens: number;
2253
- overlap: number;
2254
- modelContextSize: number;
2255
- }): Promise<void>;
2256
- processCharacterKnowledge(items: string[]): Promise<void>;
2257
- setSetting(key: string, value: string | boolean | null | any, secret?: boolean): void;
2258
- getSetting(key: string): string | boolean | null | any;
2259
- /**
2260
- * Get the number of messages that are kept in the conversation buffer.
2261
- * @returns The number of recent messages to be kept in memory.
2262
- */
2263
- getConversationLength(): number;
2264
- registerDatabaseAdapter(adapter: IDatabaseAdapter): void;
2265
- getDatabaseAdapters(): IDatabaseAdapter[];
2266
- getDatabaseAdapter(): IDatabaseAdapter;
2267
- /**
2268
- * Register a provider for the agent to use.
2269
- * @param provider The provider to register.
2270
- */
2271
- registerProvider(provider: Provider): void;
2272
- /**
2273
- * Register an action for the agent to perform.
2274
- * @param action The action to register.
2275
- */
2276
- registerAction(action: Action): void;
2277
- /**
2278
- * Register an evaluator to assess and guide the agent's responses.
2279
- * @param evaluator The evaluator to register.
2280
- */
2281
- registerEvaluator(evaluator: Evaluator): void;
2282
- /**
2283
- * Register a context provider to provide context for message generation.
2284
- * @param provider The context provider to register.
2285
- */
2286
- registerContextProvider(provider: Provider): void;
2287
- /**
2288
- * Process the actions of a message.
2289
- * @param message The message to process.
2290
- * @param responses The array of response memories to process actions from.
2291
- * @param state Optional state object for the action processing.
2292
- * @param callback Optional callback handler for action results.
2293
- */
2294
- processActions(message: Memory, responses: Memory[], state?: State, callback?: HandlerCallback): Promise<void>;
2295
- /**
2296
- * Evaluate the message and state using the registered evaluators.
2297
- * @param message The message to evaluate.
2298
- * @param state The state of the agent.
2299
- * @param didRespond Whether the agent responded to the message.~
2300
- * @param callback The handler callback
2301
- * @returns The results of the evaluation.
2302
- */
2303
- evaluate(message: Memory, state: State, didRespond?: boolean, callback?: HandlerCallback, responses?: Memory[]): Promise<Evaluator[]>;
2304
- ensureParticipantInRoom(entityId: UUID, roomId: UUID): Promise<void>;
2305
- ensureConnection({ entityId, roomId, userName, name, source, type, channelId, serverId, worldId, }: {
2306
- entityId: UUID;
2307
- roomId: UUID;
2308
- userName?: string;
2309
- name?: string;
2310
- source?: string;
2311
- type?: ChannelType;
2312
- channelId?: string;
2313
- serverId?: string;
2314
- worldId?: UUID;
2315
- }): Promise<void>;
2316
- /**
2317
- * Ensure the existence of a world.
2318
- */
2319
- ensureWorldExists({ id, name, serverId, metadata }: World): Promise<void>;
2320
- /**
2321
- * Ensure the existence of a room between the agent and a user. If no room exists, a new room is created and the user
2322
- * and agent are added as participants. The room ID is returned.
2323
- * @param entityId - The user ID to create a room with.
2324
- * @returns The room ID of the room between the agent and the user.
2325
- * @throws An error if the room cannot be created.
2326
- */
2327
- ensureRoomExists({ id, name, source, type, channelId, serverId, worldId, }: Room): Promise<void>;
2328
- /**
2329
- * Composes the agent's state by gathering data from enabled providers.
2330
- * @param message - The message to use as context for state composition
2331
- * @param filterList - Optional list of provider names to include, filtering out all others
2332
- * @param includeList - Optional list of private provider names to include that would otherwise be filtered out
2333
- * @returns A State object containing provider data, values, and text
2334
- */
2335
- composeState(message: Memory, filterList?: string[] | null, // only get providers that are in the filterList
2336
- includeList?: string[] | null): Promise<State>;
2337
- getMemoryManager(tableName: string): IMemoryManager | null;
2338
- getService<T extends Service>(service: ServiceType): T | null;
2339
- registerService(service: typeof Service): Promise<void>;
2340
- registerModel(modelType: ModelType, handler: (params: any) => Promise<any>): void;
2341
- getModel(modelType: ModelType): ((runtime: IAgentRuntime, params: any) => Promise<any>) | undefined;
2342
- useModel(modelType: ModelType, params: any): Promise<any>;
2343
- registerEvent(event: string, handler: (params: any) => void): void;
2344
- getEvent(event: string): ((params: any) => void)[] | undefined;
2345
- emitEvent(event: string | string[], params: any): void;
2346
- ensureEmbeddingDimension(): Promise<void>;
2347
- registerTaskWorker(taskHandler: TaskWorker): void;
2348
- getTaskWorker(name: string): TaskWorker | undefined;
2349
- }
2350
-
2351
- /**
2352
- * Updates settings state in world metadata
2353
- */
2354
- declare function updateWorldSettings(runtime: IAgentRuntime, serverId: string, worldSettings: WorldSettings): Promise<boolean>;
2355
- /**
2356
- * Gets settings state from world metadata
2357
- */
2358
- declare function getWorldSettings(runtime: IAgentRuntime, serverId: string): Promise<WorldSettings | null>;
2359
- /**
2360
- * Initializes settings configuration for a server
2361
- */
2362
- declare function initializeOnboarding(runtime: IAgentRuntime, world: World, config: OnboardingConfig): Promise<WorldSettings | null>;
2363
-
2364
- declare const uuidSchema: z.ZodType<UUID>;
2365
- declare function validateUuid(value: unknown): UUID | null;
2366
- declare function stringToUuid(target: string | number): UUID;
2367
-
2368
- export { type Action, type ActionExample, type Agent, AgentRuntime, type BaseMetadata, CacheKeyPrefix, type CacheOptions, ChannelType, type Character, type CharacterConfig, CharacterSchema, type ChunkRow, type Component, type Content, type ConversationExample, type CustomMetadata, DatabaseAdapter, type DeriveKeyAttestationData, type DescriptionMetadata, type DetokenizeTextParams, type DirectoryItem, type DocumentMetadata, type Entity, type EvaluationExample, type Evaluator, type FragmentMetadata, type GenerateTextParams, type Goal, GoalStatus, type Handler, type HandlerCallback, type IAgentRuntime, type IBrowserService, type IDatabaseAdapter, type IFileService, type IMemoryManager, type IPdfService, type ITeeLogService, type IVideoService, type KnowledgeItem, KnowledgeScope, type Media, type Memory, MemoryManager, type MemoryMetadata, MemoryType, type MemoryTypeAlias, type MessageExample, MessageExampleSchema, type MessageMetadata, type ModelConfiguration, type ModelType, ModelTypes, type Objective, type OnboardingConfig, type Participant, type Plugin, PluginSchema, type Project, type ProjectAgent, type Provider, type ProviderResult, type Relationship, type RemoteAttestationMessage, type RemoteAttestationQuote, Role, type Room, type Route, type ServerOwnershipState, Service, type ServiceType, ServiceTypes, type Setting, type SgxAttestation, type State, TEEMode, type Task, type TaskWorker, type TeeAgent, type TeeLog, TeeLogDAO, type TeeLogQuery, type TeePageQuery, type TeePluginConfig, TeeType, type TeeVendorConfig, type TemplateType, type TestCase, type TestSuite, type TokenizeTextParams, type UUID, type Validator, type World, type WorldSettings, addHeader, booleanFooter, cleanJsonResponse, composeActionExamples, composePrompt, composeRandomUser, configureSettings, createUniqueUuid, dynamicImport, elizaLogger, extractAttributes, findEntityByName, findNearestEnvFile, findWorldForOwner, formatActionNames, formatActions, formatMessages, formatPosts, formatTimestamp, getEntityDetails, getEnvVariable, getUserServerRole, getWorldSettings, handlePluginImporting, hasEnvVariable, initializeOnboarding, loadEnvConfig, logger, messageHandlerTemplate, normalizeJsonString, parseActionResponseFromText, parseBooleanFromText, parseJSONObjectFromText, parseJsonArrayFromText, postActionResponseFooter, registerDynamicImport, settings, shouldRespondTemplate, splitChunks, stringArrayFooter, stringToUuid, trimTokens, truncateToCompleteSentence, updateWorldSettings, uuidSchema, validateCharacterConfig, validateUuid };