@elizaos/core 0.25.8 → 1.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,4 @@
1
- import { Readable } from 'stream';
2
- import { CoreTool, StepResult as StepResult$1, GenerateObjectResult } from 'ai';
3
- import { ZodSchema, z } from 'zod';
1
+ import { z } from 'zod';
4
2
  import * as pino from 'pino';
5
3
 
6
4
  /**
@@ -11,10 +9,15 @@ type UUID = `${string}-${string}-${string}-${string}-${string}`;
11
9
  * Represents the content of a message or communication
12
10
  */
13
11
  interface Content {
12
+ thought?: string;
13
+ /** The agent's plan for the next message */
14
+ plan?: string;
14
15
  /** The main text content */
15
- text: string;
16
+ text?: string;
16
17
  /** Optional action associated with the message */
17
- action?: string;
18
+ actions?: string[];
19
+ /** Optional providers associated with the message */
20
+ providers?: string[];
18
21
  /** Optional source/origin of the content */
19
22
  source?: string;
20
23
  /** URL of the original message/post (e.g. tweet URL, Discord message link) */
@@ -31,7 +34,7 @@ interface Content {
31
34
  */
32
35
  interface ActionExample {
33
36
  /** User associated with the example */
34
- user: string;
37
+ name: string;
35
38
  /** Content of the example */
36
39
  content: Content;
37
40
  }
@@ -40,30 +43,10 @@ interface ActionExample {
40
43
  */
41
44
  interface ConversationExample {
42
45
  /** UUID of user in conversation */
43
- userId: UUID;
46
+ entityId: UUID;
44
47
  /** Content of the conversation */
45
48
  content: Content;
46
49
  }
47
- /**
48
- * Represents an actor/participant in a conversation
49
- */
50
- interface Actor {
51
- /** Display name */
52
- name: string;
53
- /** Username/handle */
54
- username: string;
55
- /** Additional profile details */
56
- details: {
57
- /** Short profile tagline */
58
- tagline: string;
59
- /** Longer profile summary */
60
- summary: string;
61
- /** Favorite quote */
62
- quote: string;
63
- };
64
- /** Unique identifier */
65
- id: UUID;
66
- }
67
50
  /**
68
51
  * Represents a single objective within a goal
69
52
  */
@@ -92,7 +75,7 @@ interface Goal {
92
75
  /** Room ID where goal exists */
93
76
  roomId: UUID;
94
77
  /** User ID of goal owner */
95
- userId: UUID;
78
+ entityId: UUID;
96
79
  /** Name/title of the goal */
97
80
  name: string;
98
81
  /** Current status */
@@ -100,204 +83,89 @@ interface Goal {
100
83
  /** Component objectives */
101
84
  objectives: Objective[];
102
85
  }
86
+ type ModelType = (typeof ModelTypes)[keyof typeof ModelTypes] | string;
103
87
  /**
104
88
  * Model size/type classification
105
89
  */
106
- declare enum ModelClass {
107
- SMALL = "small",
108
- MEDIUM = "medium",
109
- LARGE = "large",
110
- EMBEDDING = "embedding",
111
- IMAGE = "image"
112
- }
113
- /**
114
- * Model settings
115
- */
116
- type ModelSettings$1 = {
117
- /** Model name */
118
- name: string;
119
- /** Maximum input tokens */
120
- maxInputTokens: number;
121
- /** Maximum output tokens */
122
- maxOutputTokens: number;
123
- /** Optional frequency penalty */
124
- frequency_penalty?: number;
125
- /** Optional presence penalty */
126
- presence_penalty?: number;
127
- /** Optional repetition penalty */
128
- repetition_penalty?: number;
129
- /** Stop sequences */
130
- stop: string[];
131
- /** Temperature setting */
132
- temperature: number;
133
- /** Optional telemetry configuration (experimental) */
134
- experimental_telemetry?: TelemetrySettings;
135
- };
136
- /** Image model settings */
137
- type ImageModelSettings = {
138
- name: string;
139
- steps?: number;
140
- };
141
- /** Embedding model settings */
142
- type EmbeddingModelSettings = {
143
- name: string;
144
- dimensions?: number;
145
- };
146
- /**
147
- * Configuration for an AI model
148
- */
149
- type Model = {
150
- /** Optional API endpoint */
151
- endpoint?: string;
152
- /** Model names by size class */
153
- model: {
154
- [ModelClass.SMALL]?: ModelSettings$1;
155
- [ModelClass.MEDIUM]?: ModelSettings$1;
156
- [ModelClass.LARGE]?: ModelSettings$1;
157
- [ModelClass.EMBEDDING]?: EmbeddingModelSettings;
158
- [ModelClass.IMAGE]?: ImageModelSettings;
159
- };
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";
160
107
  };
161
- /**
162
- * Model configurations by provider
163
- */
164
- type Models = {
165
- [ModelProviderName.OPENAI]: Model;
166
- [ModelProviderName.ETERNALAI]: Model;
167
- [ModelProviderName.ANTHROPIC]: Model;
168
- [ModelProviderName.GROK]: Model;
169
- [ModelProviderName.GROQ]: Model;
170
- [ModelProviderName.LLAMACLOUD]: Model;
171
- [ModelProviderName.TOGETHER]: Model;
172
- [ModelProviderName.LLAMALOCAL]: Model;
173
- [ModelProviderName.LMSTUDIO]: Model;
174
- [ModelProviderName.GOOGLE]: Model;
175
- [ModelProviderName.MISTRAL]: Model;
176
- [ModelProviderName.CLAUDE_VERTEX]: Model;
177
- [ModelProviderName.REDPILL]: Model;
178
- [ModelProviderName.OPENROUTER]: Model;
179
- [ModelProviderName.OLLAMA]: Model;
180
- [ModelProviderName.HEURIST]: Model;
181
- [ModelProviderName.GALADRIEL]: Model;
182
- [ModelProviderName.FAL]: Model;
183
- [ModelProviderName.GAIANET]: Model;
184
- [ModelProviderName.ALI_BAILIAN]: Model;
185
- [ModelProviderName.VOLENGINE]: Model;
186
- [ModelProviderName.NANOGPT]: Model;
187
- [ModelProviderName.HYPERBOLIC]: Model;
188
- [ModelProviderName.VENICE]: Model;
189
- [ModelProviderName.NVIDIA]: Model;
190
- [ModelProviderName.NINETEEN_AI]: Model;
191
- [ModelProviderName.AKASH_CHAT_API]: Model;
192
- [ModelProviderName.LIVEPEER]: Model;
193
- [ModelProviderName.DEEPSEEK]: Model;
194
- [ModelProviderName.INFERA]: Model;
195
- [ModelProviderName.BEDROCK]: Model;
196
- [ModelProviderName.ATOMA]: Model;
197
- [ModelProviderName.SECRETAI]: Model;
198
- [ModelProviderName.NEARAI]: Model;
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";
199
119
  };
200
- /**
201
- * Available model providers
202
- */
203
- declare enum ModelProviderName {
204
- OPENAI = "openai",
205
- ETERNALAI = "eternalai",
206
- ANTHROPIC = "anthropic",
207
- GROK = "grok",
208
- GROQ = "groq",
209
- LLAMACLOUD = "llama_cloud",
210
- TOGETHER = "together",
211
- LLAMALOCAL = "llama_local",
212
- LMSTUDIO = "lmstudio",
213
- GOOGLE = "google",
214
- MISTRAL = "mistral",
215
- CLAUDE_VERTEX = "claude_vertex",
216
- REDPILL = "redpill",
217
- OPENROUTER = "openrouter",
218
- OLLAMA = "ollama",
219
- HEURIST = "heurist",
220
- GALADRIEL = "galadriel",
221
- FAL = "falai",
222
- GAIANET = "gaianet",
223
- ALI_BAILIAN = "ali_bailian",
224
- VOLENGINE = "volengine",
225
- NANOGPT = "nanogpt",
226
- HYPERBOLIC = "hyperbolic",
227
- VENICE = "venice",
228
- NVIDIA = "nvidia",
229
- NINETEEN_AI = "nineteen_ai",
230
- AKASH_CHAT_API = "akash_chat_api",
231
- LIVEPEER = "livepeer",
232
- LETZAI = "letzai",
233
- DEEPSEEK = "deepseek",
234
- INFERA = "infera",
235
- BEDROCK = "bedrock",
236
- ATOMA = "atoma",
237
- SECRETAI = "secret_ai",
238
- NEARAI = "nearai"
239
- }
240
120
  /**
241
121
  * Represents the current state/context of a conversation
242
122
  */
243
123
  interface State {
244
- /** ID of user who sent current message */
245
- userId?: UUID;
246
- /** ID of agent in conversation */
247
- agentId?: UUID;
248
- /** Agent's biography */
249
- bio: string;
250
- /** Agent's background lore */
251
- lore: string;
252
- /** Message handling directions */
253
- messageDirections: string;
254
- /** Post handling directions */
255
- postDirections: string;
256
- /** Current room/conversation ID */
257
- roomId: UUID;
258
- /** Optional agent name */
259
- agentName?: string;
260
- /** Optional message sender name */
261
- senderName?: string;
262
- /** String representation of conversation actors */
263
- actors: string;
264
- /** Optional array of actor objects */
265
- actorsData?: Actor[];
266
- /** Optional string representation of goals */
267
- goals?: string;
268
- /** Optional array of goal objects */
269
- goalsData?: Goal[];
270
- /** Recent message history as string */
271
- recentMessages: string;
272
- /** Recent message objects */
273
- recentMessagesData: Memory[];
274
- /** Optional valid action names */
275
- actionNames?: string;
276
- /** Optional action descriptions */
277
- actions?: string;
278
- /** Optional action objects */
279
- actionsData?: Action[];
280
- /** Optional action examples */
281
- actionExamples?: string;
282
- /** Optional provider descriptions */
283
- providers?: string;
284
- /** Optional response content */
285
- responseData?: Content;
286
- /** Optional recent interaction objects */
287
- recentInteractionsData?: Memory[];
288
- /** Optional recent interactions string */
289
- recentInteractions?: string;
290
- /** Optional formatted conversation */
291
- formattedConversation?: string;
292
- /** Optional formatted knowledge */
293
- knowledge?: string;
294
- /** Optional knowledge data */
295
- knowledgeData?: KnowledgeItem[];
296
- /** Optional knowledge data */
297
- ragKnowledgeData?: RAGKnowledgeItem[];
298
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;
299
166
  [key: string]: unknown;
300
167
  }
168
+ type MemoryMetadata = DocumentMetadata | FragmentMetadata | MessageMetadata | DescriptionMetadata | CustomMetadata | any;
301
169
  /**
302
170
  * Represents a stored memory/message
303
171
  */
@@ -305,9 +173,9 @@ interface Memory {
305
173
  /** Optional unique identifier */
306
174
  id?: UUID;
307
175
  /** Associated user ID */
308
- userId: UUID;
176
+ entityId: UUID;
309
177
  /** Associated agent ID */
310
- agentId: UUID;
178
+ agentId?: UUID;
311
179
  /** Optional creation timestamp */
312
180
  createdAt?: number;
313
181
  /** Memory content */
@@ -320,13 +188,15 @@ interface Memory {
320
188
  unique?: boolean;
321
189
  /** Embedding similarity score */
322
190
  similarity?: number;
191
+ /** Metadata for the knowledge */
192
+ metadata?: MemoryMetadata;
323
193
  }
324
194
  /**
325
195
  * Example message for demonstration
326
196
  */
327
197
  interface MessageExample {
328
198
  /** Associated user */
329
- user: string;
199
+ name: string;
330
200
  /** Message content */
331
201
  content: Content;
332
202
  }
@@ -335,7 +205,7 @@ interface MessageExample {
335
205
  */
336
206
  type Handler = (runtime: IAgentRuntime, message: Memory, state?: State, options?: {
337
207
  [key: string]: unknown;
338
- }, callback?: HandlerCallback) => Promise<unknown>;
208
+ }, callback?: HandlerCallback, responses?: Memory[]) => Promise<unknown>;
339
209
  /**
340
210
  * Callback function type for handlers
341
211
  */
@@ -349,26 +219,24 @@ type Validator = (runtime: IAgentRuntime, message: Memory, state?: State) => Pro
349
219
  */
350
220
  interface Action {
351
221
  /** Similar action descriptions */
352
- similes: string[];
222
+ similes?: string[];
353
223
  /** Detailed description */
354
224
  description: string;
355
225
  /** Example usages */
356
- examples: ActionExample[][];
226
+ examples?: ActionExample[][];
357
227
  /** Handler function */
358
228
  handler: Handler;
359
229
  /** Action name */
360
230
  name: string;
361
231
  /** Validation function */
362
232
  validate: Validator;
363
- /** Whether to suppress the initial message when this action is used */
364
- suppressInitialMessage?: boolean;
365
233
  }
366
234
  /**
367
235
  * Example for evaluating agent behavior
368
236
  */
369
237
  interface EvaluationExample {
370
238
  /** Evaluation context */
371
- context: string;
239
+ prompt: string;
372
240
  /** Example messages */
373
241
  messages: Array<ActionExample>;
374
242
  /** Expected outcome */
@@ -383,7 +251,7 @@ interface Evaluator {
383
251
  /** Detailed description */
384
252
  description: string;
385
253
  /** Similar evaluator descriptions */
386
- similes: string[];
254
+ similes?: string[];
387
255
  /** Example evaluations */
388
256
  examples: EvaluationExample[];
389
257
  /** Handler function */
@@ -393,12 +261,35 @@ interface Evaluator {
393
261
  /** Validation function */
394
262
  validate: Validator;
395
263
  }
264
+ interface ProviderResult {
265
+ values?: {
266
+ [key: string]: any;
267
+ };
268
+ data?: {
269
+ [key: string]: any;
270
+ };
271
+ text?: string;
272
+ }
396
273
  /**
397
274
  * Provider for external data/services
398
275
  */
399
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;
400
291
  /** Data retrieval function */
401
- get: (runtime: IAgentRuntime, message: Memory, state?: State) => Promise<any>;
292
+ get: (runtime: IAgentRuntime, message: Memory, state: State) => Promise<ProviderResult>;
402
293
  }
403
294
  /**
404
295
  * Represents a relationship between users
@@ -407,37 +298,75 @@ interface Relationship {
407
298
  /** Unique identifier */
408
299
  id: UUID;
409
300
  /** First user ID */
410
- userA: UUID;
301
+ sourceEntityId: UUID;
411
302
  /** Second user ID */
412
- userB: UUID;
413
- /** Primary user ID */
414
- userId: UUID;
415
- /** Associated room ID */
416
- roomId: UUID;
417
- /** Relationship status */
418
- status: string;
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
+ };
419
312
  /** Optional creation timestamp */
420
313
  createdAt?: string;
421
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
+ }
422
327
  /**
423
328
  * Represents a user account
424
329
  */
425
- interface Account {
426
- /** Unique identifier */
427
- id: UUID;
428
- /** Display name */
429
- name: string;
430
- /** Username */
431
- username: string;
432
- /** Optional additional details */
433
- details?: {
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?: {
434
337
  [key: string]: any;
435
338
  };
436
- /** Optional email */
437
- email?: string;
438
- /** Optional avatar URL */
439
- avatarUrl?: string;
339
+ /** Agent ID this account is related to, for agents should be themselves */
340
+ agentId: UUID;
341
+ /** Optional array of components */
342
+ components?: Component[];
440
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
+ };
441
370
  /**
442
371
  * Room participant with account details
443
372
  */
@@ -445,16 +374,7 @@ interface Participant {
445
374
  /** Unique identifier */
446
375
  id: UUID;
447
376
  /** Associated account */
448
- account: Account;
449
- }
450
- /**
451
- * Represents a conversation room
452
- */
453
- interface Room {
454
- /** Unique identifier */
455
- id: UUID;
456
- /** Room participants */
457
- participants: Participant[];
377
+ entity: Entity;
458
378
  }
459
379
  /**
460
380
  * Represents a media attachment
@@ -475,90 +395,88 @@ type Media = {
475
395
  /** Content type */
476
396
  contentType?: string;
477
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
+ }
478
410
  /**
479
411
  * Client instance
480
412
  */
481
- type ClientInstance = {
482
- /** Client name */
483
- /** Stop client connection */
484
- stop: (runtime: IAgentRuntime) => Promise<unknown>;
485
- };
486
- /**
487
- * Client interface for platform connections
488
- */
489
- type Client = {
490
- /** Client name */
491
- name: string;
492
- /** Client configuration */
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 */
493
423
  config?: {
494
424
  [key: string]: any;
495
425
  };
496
- /** Start client connection */
497
- start: (runtime: IAgentRuntime) => Promise<ClientInstance>;
498
- };
499
- type Adapter = {
500
- /** Initialize adapter */
501
- init: (runtime: IAgentRuntime) => IDatabaseAdapter & IDatabaseCacheAdapter;
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>;
502
435
  };
503
436
  /**
504
437
  * Plugin for extending agent functionality
505
438
  */
506
- type Plugin = {
507
- /** Plugin name */
439
+ interface Plugin {
508
440
  name: string;
509
- /** Plugin configuration */
441
+ description: string;
442
+ init?: (config: Record<string, string>, runtime: IAgentRuntime) => Promise<void>;
510
443
  config?: {
511
444
  [key: string]: any;
512
445
  };
513
- /** Plugin description */
514
- description: string;
515
- /** Optional actions */
446
+ memoryManagers?: IMemoryManager[];
447
+ services?: (typeof Service)[];
448
+ componentTypes?: {
449
+ name: string;
450
+ schema: Record<string, unknown>;
451
+ validator?: (data: any) => boolean;
452
+ }[];
516
453
  actions?: Action[];
517
- /** Optional providers */
518
454
  providers?: Provider[];
519
- /** Optional evaluators */
520
455
  evaluators?: Evaluator[];
521
- /** Optional services */
522
- services?: Service[];
523
- /** Optional clients */
524
- clients?: Client[];
525
- /** Optional adapters */
526
- adapters?: Adapter[];
527
- };
528
- interface IAgentConfig {
529
- [key: string]: string;
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[];
530
473
  }
531
- type TelemetrySettings = {
532
- /**
533
- * Enable or disable telemetry. Disabled by default while experimental.
534
- */
535
- isEnabled?: boolean;
536
- /**
537
- * Enable or disable input recording. Enabled by default.
538
- *
539
- * You might want to disable input recording to avoid recording sensitive
540
- * information, to reduce data transfers, or to increase performance.
541
- */
542
- recordInputs?: boolean;
543
- /**
544
- * Enable or disable output recording. Enabled by default.
545
- *
546
- * You might want to disable output recording to avoid recording sensitive
547
- * information, to reduce data transfers, or to increase performance.
548
- */
549
- recordOutputs?: boolean;
550
- /**
551
- * Identifier for this function. Used to group telemetry data by function.
552
- */
553
- functionId?: string;
554
- };
555
474
  interface ModelConfiguration {
556
475
  temperature?: number;
557
476
  maxOutputTokens?: number;
558
477
  frequency_penalty?: number;
559
478
  presence_penalty?: number;
560
479
  maxInputTokens?: number;
561
- experimental_telemetry?: TelemetrySettings;
562
480
  }
563
481
  type TemplateType = string | ((options: {
564
482
  state: State;
@@ -566,233 +484,55 @@ type TemplateType = string | ((options: {
566
484
  /**
567
485
  * Configuration for an agent character
568
486
  */
569
- type Character = {
487
+ interface Character {
570
488
  /** Optional unique identifier */
571
489
  id?: UUID;
572
490
  /** Character name */
573
491
  name: string;
574
492
  /** Optional username */
575
493
  username?: string;
576
- /** Optional email */
577
- email?: string;
578
494
  /** Optional system prompt */
579
495
  system?: string;
580
- /** Model provider to use */
581
- modelProvider: ModelProviderName;
582
- /** Image model provider to use, if different from modelProvider */
583
- imageModelProvider?: ModelProviderName;
584
- /** Image Vision model provider to use, if different from modelProvider */
585
- imageVisionModelProvider?: ModelProviderName;
586
- /** Optional model endpoint override */
587
- modelEndpointOverride?: string;
588
496
  /** Optional prompt templates */
589
497
  templates?: {
590
- goalsTemplate?: TemplateType;
591
- factsTemplate?: TemplateType;
592
- messageHandlerTemplate?: TemplateType;
593
- shouldRespondTemplate?: TemplateType;
594
- continueMessageHandlerTemplate?: TemplateType;
595
- evaluationTemplate?: TemplateType;
596
- twitterSearchTemplate?: TemplateType;
597
- twitterActionTemplate?: TemplateType;
598
- twitterPostTemplate?: TemplateType;
599
- twitterMessageHandlerTemplate?: TemplateType;
600
- twitterShouldRespondTemplate?: TemplateType;
601
- twitterVoiceHandlerTemplate?: TemplateType;
602
- instagramPostTemplate?: TemplateType;
603
- instagramMessageHandlerTemplate?: TemplateType;
604
- instagramShouldRespondTemplate?: TemplateType;
605
- farcasterPostTemplate?: TemplateType;
606
- lensPostTemplate?: TemplateType;
607
- farcasterMessageHandlerTemplate?: TemplateType;
608
- lensMessageHandlerTemplate?: TemplateType;
609
- farcasterShouldRespondTemplate?: TemplateType;
610
- lensShouldRespondTemplate?: TemplateType;
611
- telegramMessageHandlerTemplate?: TemplateType;
612
- telegramShouldRespondTemplate?: TemplateType;
613
- telegramAutoPostTemplate?: string;
614
- telegramPinnedMessageTemplate?: string;
615
- discordAutoPostTemplate?: string;
616
- discordAnnouncementHypeTemplate?: string;
617
- discordVoiceHandlerTemplate?: TemplateType;
618
- discordShouldRespondTemplate?: TemplateType;
619
- discordMessageHandlerTemplate?: TemplateType;
620
- slackMessageHandlerTemplate?: TemplateType;
621
- slackShouldRespondTemplate?: TemplateType;
622
- jeeterPostTemplate?: string;
623
- jeeterSearchTemplate?: string;
624
- jeeterInteractionTemplate?: string;
625
- jeeterMessageHandlerTemplate?: string;
626
- jeeterShouldRespondTemplate?: string;
627
- devaPostTemplate?: string;
498
+ [key: string]: TemplateType;
628
499
  };
629
500
  /** Character biography */
630
501
  bio: string | string[];
631
- /** Character background lore */
632
- lore: string[];
633
502
  /** Example messages */
634
- messageExamples: MessageExample[][];
503
+ messageExamples?: MessageExample[][];
635
504
  /** Example posts */
636
- postExamples: string[];
505
+ postExamples?: string[];
637
506
  /** Known topics */
638
- topics: string[];
507
+ topics?: string[];
639
508
  /** Character traits */
640
- adjectives: string[];
509
+ adjectives?: string[];
641
510
  /** Optional knowledge base */
642
511
  knowledge?: (string | {
643
512
  path: string;
644
513
  shared?: boolean;
645
514
  })[];
646
515
  /** Available plugins */
647
- plugins: Plugin[];
516
+ plugins?: string[];
648
517
  /** Optional configuration */
649
518
  settings?: {
650
- secrets?: {
651
- [key: string]: string;
652
- };
653
- intiface?: boolean;
654
- imageSettings?: {
655
- steps?: number;
656
- width?: number;
657
- height?: number;
658
- cfgScale?: number;
659
- negativePrompt?: string;
660
- numIterations?: number;
661
- guidanceScale?: number;
662
- seed?: number;
663
- modelId?: string;
664
- jobId?: string;
665
- count?: number;
666
- stylePreset?: string;
667
- hideWatermark?: boolean;
668
- safeMode?: boolean;
669
- };
670
- voice?: {
671
- model?: string;
672
- url?: string;
673
- elevenlabs?: {
674
- voiceId: string;
675
- model?: string;
676
- stability?: string;
677
- similarityBoost?: string;
678
- style?: string;
679
- useSpeakerBoost?: string;
680
- };
681
- };
682
- model?: string;
683
- modelConfig?: ModelConfiguration;
684
- embeddingModel?: string;
685
- chains?: {
686
- evm?: any[];
687
- solana?: any[];
688
- [key: string]: any[];
689
- };
690
- transcription?: TranscriptionProvider;
691
- ragKnowledge?: boolean;
519
+ [key: string]: any | string | boolean | number;
692
520
  };
693
- /** Optional client-specific config */
694
- clientConfig?: {
695
- discord?: {
696
- shouldIgnoreBotMessages?: boolean;
697
- shouldIgnoreDirectMessages?: boolean;
698
- shouldRespondOnlyToMentions?: boolean;
699
- messageSimilarityThreshold?: number;
700
- isPartOfTeam?: boolean;
701
- teamAgentIds?: string[];
702
- teamLeaderId?: string;
703
- teamMemberInterestKeywords?: string[];
704
- allowedChannelIds?: string[];
705
- autoPost?: {
706
- enabled?: boolean;
707
- monitorTime?: number;
708
- inactivityThreshold?: number;
709
- mainChannelId?: string;
710
- announcementChannelIds?: string[];
711
- minTimeBetweenPosts?: number;
712
- };
713
- };
714
- telegram?: {
715
- shouldIgnoreBotMessages?: boolean;
716
- shouldIgnoreDirectMessages?: boolean;
717
- shouldRespondOnlyToMentions?: boolean;
718
- shouldOnlyJoinInAllowedGroups?: boolean;
719
- allowedGroupIds?: string[];
720
- messageSimilarityThreshold?: number;
721
- isPartOfTeam?: boolean;
722
- teamAgentIds?: string[];
723
- teamLeaderId?: string;
724
- teamMemberInterestKeywords?: string[];
725
- autoPost?: {
726
- enabled?: boolean;
727
- monitorTime?: number;
728
- inactivityThreshold?: number;
729
- mainChannelId?: string;
730
- pinnedMessagesGroups?: string[];
731
- minTimeBetweenPosts?: number;
732
- };
733
- };
734
- slack?: {
735
- shouldIgnoreBotMessages?: boolean;
736
- shouldIgnoreDirectMessages?: boolean;
737
- };
738
- gitbook?: {
739
- keywords?: {
740
- projectTerms?: string[];
741
- generalQueries?: string[];
742
- };
743
- documentTriggers?: string[];
744
- };
521
+ /** Optional secrets */
522
+ secrets?: {
523
+ [key: string]: string | boolean | number;
745
524
  };
746
525
  /** Writing style guides */
747
- style: {
748
- all: string[];
749
- chat: string[];
750
- post: string[];
751
- };
752
- /** Optional Twitter profile */
753
- twitterProfile?: {
754
- id: string;
755
- username: string;
756
- screenName: string;
757
- bio: string;
758
- nicknames?: string[];
759
- };
760
- /** Optional Instagram profile */
761
- instagramProfile?: {
762
- id: string;
763
- username: string;
764
- bio: string;
765
- nicknames?: string[];
766
- };
767
- /** Optional SimsAI profile */
768
- simsaiProfile?: {
769
- id: string;
770
- username: string;
771
- screenName: string;
772
- bio: string;
773
- };
774
- /** Optional NFT prompt */
775
- nft?: {
776
- prompt: string;
526
+ style?: {
527
+ all?: string[];
528
+ chat?: string[];
529
+ post?: string[];
777
530
  };
778
- /**Optinal Parent characters to inherit information from */
779
- extends?: string[];
780
- twitterSpaces?: TwitterSpaceDecisionOptions;
781
- };
782
- interface TwitterSpaceDecisionOptions {
783
- maxSpeakers?: number;
784
- topics?: string[];
785
- typicalDurationMinutes?: number;
786
- idleKickTimeoutMs?: number;
787
- minIntervalBetweenSpacesMinutes?: number;
788
- businessHoursOnly?: boolean;
789
- randomChance?: number;
790
- enableIdleMonitor?: boolean;
791
- enableSttTts?: boolean;
792
- enableRecording?: boolean;
793
- voiceId?: string;
794
- sttLanguage?: string;
795
- speakerMaxDurationMs?: number;
531
+ }
532
+ interface Agent extends Character {
533
+ enabled: boolean;
534
+ createdAt: number;
535
+ updatedAt: number;
796
536
  }
797
537
  /**
798
538
  * Interface for database operations
@@ -800,21 +540,40 @@ interface TwitterSpaceDecisionOptions {
800
540
  interface IDatabaseAdapter {
801
541
  /** Database instance */
802
542
  db: any;
803
- /** Optional initialization */
804
- init(): Promise<void>;
805
543
  /** Close database connection */
806
544
  close(): Promise<void>;
807
- /** Get account by ID */
808
- getAccountById(userId: UUID): Promise<Account | null>;
809
- /** Create new account */
810
- createAccount(account: Account): Promise<boolean>;
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>;
811
571
  /** Get memories matching criteria */
812
572
  getMemories(params: {
813
573
  roomId: UUID;
814
574
  count?: number;
815
575
  unique?: boolean;
816
576
  tableName: string;
817
- agentId: UUID;
818
577
  start?: number;
819
578
  end?: number;
820
579
  }): Promise<Memory[]>;
@@ -822,7 +581,6 @@ interface IDatabaseAdapter {
822
581
  getMemoriesByIds(ids: UUID[], tableName?: string): Promise<Memory[]>;
823
582
  getMemoriesByRoomIds(params: {
824
583
  tableName: string;
825
- agentId: UUID;
826
584
  roomIds: UUID[];
827
585
  limit?: number;
828
586
  }): Promise<Memory[]>;
@@ -841,42 +599,29 @@ interface IDatabaseAdapter {
841
599
  body: {
842
600
  [key: string]: unknown;
843
601
  };
844
- userId: UUID;
602
+ entityId: UUID;
845
603
  roomId: UUID;
846
604
  type: string;
847
605
  }): Promise<void>;
848
- getActorDetails(params: {
849
- roomId: UUID;
850
- }): Promise<Actor[]>;
851
- searchMemories(params: {
852
- tableName: string;
853
- agentId: UUID;
854
- roomId: UUID;
855
- embedding: number[];
856
- match_threshold: number;
857
- match_count: number;
858
- unique: boolean;
859
- }): Promise<Memory[]>;
860
606
  updateGoalStatus(params: {
861
607
  goalId: UUID;
862
608
  status: GoalStatus;
863
609
  }): Promise<void>;
864
- searchMemoriesByEmbedding(embedding: number[], params: {
610
+ searchMemories(params: {
611
+ embedding: number[];
865
612
  match_threshold?: number;
866
613
  count?: number;
867
614
  roomId?: UUID;
868
- agentId?: UUID;
869
615
  unique?: boolean;
870
616
  tableName: string;
871
617
  }): Promise<Memory[]>;
872
- createMemory(memory: Memory, tableName: string, unique?: boolean): Promise<void>;
618
+ createMemory(memory: Memory, tableName: string, unique?: boolean): Promise<UUID>;
873
619
  removeMemory(memoryId: UUID, tableName: string): Promise<void>;
874
620
  removeAllMemories(roomId: UUID, tableName: string): Promise<void>;
875
621
  countMemories(roomId: UUID, unique?: boolean, tableName?: string): Promise<number>;
876
622
  getGoals(params: {
877
- agentId: UUID;
878
623
  roomId: UUID;
879
- userId?: UUID | null;
624
+ entityId?: UUID | null;
880
625
  onlyInProgress?: boolean;
881
626
  count?: number;
882
627
  }): Promise<Goal[]>;
@@ -884,60 +629,73 @@ interface IDatabaseAdapter {
884
629
  createGoal(goal: Goal): Promise<void>;
885
630
  removeGoal(goalId: UUID): Promise<void>;
886
631
  removeAllGoals(roomId: UUID): Promise<void>;
887
- getRoom(roomId: UUID): Promise<UUID | null>;
888
- createRoom(roomId?: UUID): Promise<UUID>;
889
- removeRoom(roomId: UUID): Promise<void>;
890
- getRoomsForParticipant(userId: UUID): Promise<UUID[]>;
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[]>;
891
641
  getRoomsForParticipants(userIds: UUID[]): Promise<UUID[]>;
892
- addParticipant(userId: UUID, roomId: UUID): Promise<boolean>;
893
- removeParticipant(userId: UUID, roomId: UUID): Promise<boolean>;
894
- getParticipantsForAccount(userId: UUID): Promise<Participant[]>;
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[]>;
895
646
  getParticipantsForRoom(roomId: UUID): Promise<UUID[]>;
896
- getParticipantUserState(roomId: UUID, userId: UUID): Promise<"FOLLOWED" | "MUTED" | null>;
897
- setParticipantUserState(roomId: UUID, userId: UUID, state: "FOLLOWED" | "MUTED" | null): Promise<void>;
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
+ */
898
654
  createRelationship(params: {
899
- userA: UUID;
900
- userB: UUID;
655
+ sourceEntityId: UUID;
656
+ targetEntityId: UUID;
657
+ tags?: string[];
658
+ metadata?: {
659
+ [key: string]: any;
660
+ };
901
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
+ */
902
673
  getRelationship(params: {
903
- userA: UUID;
904
- userB: UUID;
674
+ sourceEntityId: UUID;
675
+ targetEntityId: UUID;
905
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
+ */
906
682
  getRelationships(params: {
907
- userId: UUID;
683
+ entityId: UUID;
684
+ tags?: string[];
908
685
  }): Promise<Relationship[]>;
909
- getKnowledge(params: {
910
- id?: UUID;
911
- agentId: UUID;
912
- limit?: number;
913
- query?: string;
914
- conversationContext?: string;
915
- }): Promise<RAGKnowledgeItem[]>;
916
- searchKnowledge(params: {
917
- agentId: UUID;
918
- embedding: Float32Array;
919
- match_threshold: number;
920
- match_count: number;
921
- searchText?: string;
922
- }): Promise<RAGKnowledgeItem[]>;
923
- createKnowledge(knowledge: RAGKnowledgeItem): Promise<void>;
924
- removeKnowledge(id: UUID): Promise<void>;
925
- clearKnowledge(agentId: UUID, shared?: boolean): Promise<void>;
926
- }
927
- interface IDatabaseCacheAdapter {
928
- getCache(params: {
929
- agentId: UUID;
930
- key: string;
931
- }): Promise<string | undefined>;
932
- setCache(params: {
933
- agentId: UUID;
934
- key: string;
935
- value: string;
936
- }): Promise<boolean>;
937
- deleteCache(params: {
938
- agentId: UUID;
939
- key: string;
940
- }): Promise<boolean>;
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>;
941
699
  }
942
700
  interface IMemoryManager {
943
701
  runtime: IAgentRuntime;
@@ -951,6 +709,14 @@ interface IMemoryManager {
951
709
  start?: number;
952
710
  end?: number;
953
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[]>;
954
720
  getCachedEmbeddings(content: string): Promise<{
955
721
  embedding: number[];
956
722
  levenshtein_score: number;
@@ -960,120 +726,110 @@ interface IMemoryManager {
960
726
  roomIds: UUID[];
961
727
  limit?: number;
962
728
  }): Promise<Memory[]>;
963
- searchMemoriesByEmbedding(embedding: number[], opts: {
964
- match_threshold?: number;
965
- count?: number;
966
- roomId: UUID;
967
- unique?: boolean;
968
- }): Promise<Memory[]>;
969
- createMemory(memory: Memory, unique?: boolean): Promise<void>;
729
+ createMemory(memory: Memory, unique?: boolean): Promise<UUID>;
970
730
  removeMemory(memoryId: UUID): Promise<void>;
971
731
  removeAllMemories(roomId: UUID): Promise<void>;
972
732
  countMemories(roomId: UUID, unique?: boolean): Promise<number>;
973
733
  }
974
- interface IRAGKnowledgeManager {
975
- runtime: IAgentRuntime;
976
- tableName: string;
977
- getKnowledge(params: {
978
- query?: string;
979
- id?: UUID;
980
- limit?: number;
981
- conversationContext?: string;
982
- agentId?: UUID;
983
- }): Promise<RAGKnowledgeItem[]>;
984
- createKnowledge(item: RAGKnowledgeItem): Promise<void>;
985
- removeKnowledge(id: UUID): Promise<void>;
986
- searchKnowledge(params: {
987
- agentId: UUID;
988
- embedding: Float32Array | number[];
989
- match_threshold?: number;
990
- match_count?: number;
991
- searchText?: string;
992
- }): Promise<RAGKnowledgeItem[]>;
993
- clearKnowledge(shared?: boolean): Promise<void>;
994
- processFile(file: {
995
- path: string;
996
- content: string;
997
- type: "pdf" | "md" | "txt";
998
- isShared: boolean;
999
- }): Promise<void>;
1000
- cleanupDeletedKnowledgeFiles(): Promise<void>;
1001
- generateScopedId(path: string, isShared: boolean): UUID;
1002
- }
1003
734
  type CacheOptions = {
1004
735
  expires?: number;
1005
736
  };
1006
- declare enum CacheStore {
1007
- REDIS = "redis",
1008
- DATABASE = "database",
1009
- FILESYSTEM = "filesystem"
1010
- }
1011
- interface ICacheManager {
1012
- get<T = unknown>(key: string): Promise<T | undefined>;
1013
- set<T>(key: string, value: T, options?: CacheOptions): Promise<void>;
1014
- delete(key: string): Promise<void>;
1015
- }
1016
- declare abstract class Service {
1017
- private static instance;
1018
- static get serviceType(): ServiceType;
1019
- static getInstance<T extends Service>(): T;
1020
- get serviceType(): ServiceType;
1021
- abstract initialize(runtime: IAgentRuntime): Promise<void>;
1022
- }
1023
737
  interface IAgentRuntime {
1024
738
  agentId: UUID;
1025
- serverUrl: string;
1026
739
  databaseAdapter: IDatabaseAdapter;
1027
- token: string | null;
1028
- modelProvider: ModelProviderName;
1029
- imageModelProvider: ModelProviderName;
1030
- imageVisionModelProvider: ModelProviderName;
1031
740
  character: Character;
1032
741
  providers: Provider[];
1033
742
  actions: Action[];
1034
743
  evaluators: Evaluator[];
1035
744
  plugins: Plugin[];
1036
- fetch?: typeof fetch | null;
1037
- messageManager: IMemoryManager;
1038
- descriptionManager: IMemoryManager;
1039
- documentsManager: IMemoryManager;
1040
- knowledgeManager: IMemoryManager;
1041
- ragKnowledgeManager: IRAGKnowledgeManager;
1042
- loreManager: IMemoryManager;
1043
- cacheManager: ICacheManager;
1044
745
  services: Map<ServiceType, Service>;
1045
- clients: ClientInstance[];
746
+ events: Map<string, ((params: any) => void)[]>;
747
+ fetch?: typeof fetch | null;
748
+ routes: Route[];
749
+ registerPlugin(plugin: Plugin): Promise<void>;
1046
750
  initialize(): Promise<void>;
1047
- registerMemoryManager(manager: IMemoryManager): void;
1048
- getMemoryManager(name: string): IMemoryManager | null;
1049
- getService<T extends Service>(service: ServiceType): T | null;
1050
- registerService(service: Service): void;
1051
- getSetting(key: string): string | null;
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;
1052
766
  getConversationLength(): number;
1053
767
  processActions(message: Memory, responses: Memory[], state?: State, callback?: HandlerCallback): Promise<void>;
1054
- evaluate(message: Memory, state?: State, didRespond?: boolean, callback?: HandlerCallback): Promise<string[] | null>;
1055
- ensureParticipantExists(userId: UUID, roomId: UUID): Promise<void>;
1056
- ensureUserExists(userId: UUID, userName: string | null, name: string | null, source: string | null): Promise<void>;
768
+ evaluate(message: Memory, state?: State, didRespond?: boolean, callback?: HandlerCallback, responses?: Memory[]): Promise<Evaluator[] | null>;
769
+ registerProvider(provider: Provider): void;
1057
770
  registerAction(action: Action): void;
1058
- ensureConnection(userId: UUID, roomId: UUID, userName?: string, userScreenName?: string, source?: string): Promise<void>;
1059
- ensureParticipantInRoom(userId: UUID, roomId: UUID): Promise<void>;
1060
- ensureRoomExists(roomId: UUID): Promise<void>;
1061
- composeState(message: Memory, additionalKeys?: {
1062
- [key: string]: unknown;
1063
- }): Promise<State>;
1064
- updateRecentMessageState(state: State): Promise<State>;
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>;
1065
797
  }
1066
- interface IImageDescriptionService extends Service {
1067
- describeImage(imageUrl: string): Promise<{
1068
- title: string;
1069
- description: string;
1070
- }>;
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;
1071
829
  }
1072
- interface ITranscriptionService extends Service {
1073
- transcribeAttachment(audioBuffer: ArrayBuffer): Promise<string | null>;
1074
- transcribeAttachmentLocally(audioBuffer: ArrayBuffer): Promise<string | null>;
1075
- transcribe(audioBuffer: ArrayBuffer): Promise<string | null>;
1076
- transcribeLocally(audioBuffer: ArrayBuffer): Promise<string | null>;
830
+ interface DetokenizeTextParams {
831
+ tokens: number[];
832
+ modelType: ModelType;
1077
833
  }
1078
834
  interface IVideoService extends Service {
1079
835
  isVideoUrl(url: string): boolean;
@@ -1081,29 +837,17 @@ interface IVideoService extends Service {
1081
837
  downloadVideo(videoInfo: Media): Promise<string>;
1082
838
  processVideo(url: string, runtime: IAgentRuntime): Promise<Media>;
1083
839
  }
1084
- interface ITextGenerationService extends Service {
1085
- initializeModel(): Promise<void>;
1086
- queueMessageCompletion(context: string, temperature: number, stop: string[], frequency_penalty: number, presence_penalty: number, max_tokens: number): Promise<any>;
1087
- queueTextCompletion(context: string, temperature: number, stop: string[], frequency_penalty: number, presence_penalty: number, max_tokens: number): Promise<string>;
1088
- getEmbeddingResponse(input: string): Promise<number[] | undefined>;
1089
- }
1090
840
  interface IBrowserService extends Service {
1091
- closeBrowser(): Promise<void>;
1092
841
  getPageContent(url: string, runtime: IAgentRuntime): Promise<{
1093
842
  title: string;
1094
843
  description: string;
1095
844
  bodyContent: string;
1096
845
  }>;
1097
846
  }
1098
- interface ISpeechService extends Service {
1099
- getInstance(): ISpeechService;
1100
- generate(runtime: IAgentRuntime, text: string): Promise<Readable>;
1101
- }
1102
847
  interface IPdfService extends Service {
1103
- getInstance(): IPdfService;
1104
848
  convertPdfToText(pdfBuffer: Buffer): Promise<string>;
1105
849
  }
1106
- interface IAwsS3Service extends Service {
850
+ interface IFileService extends Service {
1107
851
  uploadFile(imagePath: string, subDirectory: string, useSignedUrl: boolean, expiresIn: number): Promise<{
1108
852
  success: boolean;
1109
853
  url?: string;
@@ -1111,129 +855,153 @@ interface IAwsS3Service extends Service {
1111
855
  }>;
1112
856
  generateSignedUrl(fileName: string, expiresIn: number): Promise<string>;
1113
857
  }
1114
- interface UploadIrysResult {
1115
- success: boolean;
1116
- url?: string;
1117
- error?: string;
1118
- data?: any;
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[]>>;
1119
864
  }
1120
- interface DataIrysFetchedFromGQL {
1121
- success: boolean;
1122
- data: any;
1123
- error?: string;
865
+ interface TestCase {
866
+ name: string;
867
+ fn: (runtime: IAgentRuntime) => Promise<void> | void;
1124
868
  }
1125
- interface GraphQLTag {
869
+ interface TestSuite {
1126
870
  name: string;
1127
- values: any[];
871
+ tests: TestCase[];
1128
872
  }
1129
- declare enum IrysMessageType {
1130
- REQUEST = "REQUEST",
1131
- DATA_STORAGE = "DATA_STORAGE",
1132
- REQUEST_RESPONSE = "REQUEST_RESPONSE"
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
+ };
1133
938
  }
1134
- declare enum IrysDataType {
1135
- FILE = "FILE",
1136
- IMAGE = "IMAGE",
1137
- OTHER = "OTHER"
939
+ interface SgxAttestation {
940
+ quote: string;
941
+ timestamp: number;
1138
942
  }
1139
- interface IrysTimestamp {
1140
- from: number;
1141
- to: number;
943
+ declare enum TeeType {
944
+ SGX_GRAMINE = "sgx_gramine",
945
+ TDX_DSTACK = "tdx_dstack"
1142
946
  }
1143
- interface IIrysService extends Service {
1144
- getDataFromAnAgent(agentsWalletPublicKeys: string[], tags: GraphQLTag[], timestamp: IrysTimestamp): Promise<DataIrysFetchedFromGQL>;
1145
- workerUploadDataOnIrys(data: any, dataType: IrysDataType, messageType: IrysMessageType, serviceCategory: string[], protocol: string[], validationThreshold: number[], minimumProviders: number[], testProvider: boolean[], reputation: number[]): Promise<UploadIrysResult>;
1146
- providerUploadDataOnIrys(data: any, dataType: IrysDataType, serviceCategory: string[], protocol: string[]): Promise<UploadIrysResult>;
947
+ interface TeeVendorConfig {
948
+ [key: string]: unknown;
1147
949
  }
1148
- interface ITeeLogService extends Service {
1149
- getInstance(): ITeeLogService;
1150
- log(agentId: string, roomId: string, userId: string, type: string, content: string): Promise<boolean>;
1151
- }
1152
- declare enum ServiceType {
1153
- IMAGE_DESCRIPTION = "image_description",
1154
- TRANSCRIPTION = "transcription",
1155
- VIDEO = "video",
1156
- TEXT_GENERATION = "text_generation",
1157
- BROWSER = "browser",
1158
- SPEECH_GENERATION = "speech_generation",
1159
- PDF = "pdf",
1160
- INTIFACE = "intiface",
1161
- AWS_S3 = "aws_s3",
1162
- BUTTPLUG = "buttplug",
1163
- SLACK = "slack",
1164
- VERIFIABLE_LOGGING = "verifiable_logging",
1165
- IRYS = "irys",
1166
- TEE_LOG = "tee_log",
1167
- GOPLUS_SECURITY = "goplus_security",
1168
- WEB_SEARCH = "web_search",
1169
- EMAIL_AUTOMATION = "email_automation",
1170
- NKN_CLIENT_SERVICE = "nkn_client_service"
1171
- }
1172
- declare enum LoggingLevel {
1173
- DEBUG = "debug",
1174
- VERBOSE = "verbose",
1175
- NONE = "none"
950
+ interface TeePluginConfig {
951
+ vendor?: string;
952
+ vendorConfig?: TeeVendorConfig;
1176
953
  }
1177
- type KnowledgeItem = {
1178
- id: UUID;
1179
- content: Content;
1180
- };
1181
- interface RAGKnowledgeItem {
1182
- id: UUID;
1183
- agentId: UUID;
1184
- content: {
1185
- text: string;
1186
- metadata?: {
1187
- isMain?: boolean;
1188
- isChunk?: boolean;
1189
- originalId?: UUID;
1190
- chunkIndex?: number;
1191
- source?: string;
1192
- type?: string;
1193
- isShared?: boolean;
1194
- [key: string]: unknown;
1195
- };
1196
- };
1197
- embedding?: Float32Array;
1198
- createdAt?: number;
1199
- similarity?: number;
1200
- score?: number;
1201
- }
1202
- interface ActionResponse {
1203
- like: boolean;
1204
- retweet: boolean;
1205
- quote?: boolean;
1206
- reply?: boolean;
1207
- }
1208
- interface ISlackService extends Service {
1209
- client: any;
1210
- }
1211
- declare enum TokenizerType {
1212
- Auto = "auto",
1213
- TikToken = "tiktoken"
1214
- }
1215
- declare enum TranscriptionProvider {
1216
- OpenAI = "openai",
1217
- Deepgram = "deepgram",
1218
- Local = "local"
1219
- }
1220
- declare enum ActionTimelineType {
1221
- ForYou = "foryou",
1222
- Following = "following"
1223
- }
1224
- declare enum KnowledgeScope {
1225
- SHARED = "shared",
1226
- PRIVATE = "private"
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>;
1227
960
  }
1228
- declare enum CacheKeyPrefix {
1229
- KNOWLEDGE = "knowledge"
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[];
1230
977
  }
1231
- interface DirectoryItem {
1232
- directory: string;
1233
- shared?: boolean;
978
+ declare enum Role {
979
+ OWNER = "OWNER",
980
+ ADMIN = "ADMIN",
981
+ NONE = "NONE"
1234
982
  }
1235
- interface ChunkRow {
1236
- id: string;
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
+ };
1237
1005
  }
1238
1006
 
1239
1007
  /**
@@ -1257,143 +1025,15 @@ declare function formatActionNames(actions: Action[]): string;
1257
1025
  */
1258
1026
  declare function formatActions(actions: Action[]): string;
1259
1027
 
1260
- /**
1261
- * Composes a context string by replacing placeholders in a template with corresponding values from the state.
1262
- *
1263
- * This function takes a template string with placeholders in the format `{{placeholder}}` and a state object.
1264
- * It replaces each placeholder with the value from the state object that matches the placeholder's name.
1265
- * If a matching key is not found in the state object for a given placeholder, the placeholder is replaced with an empty string.
1266
- *
1267
- * By default, this function uses a simple string replacement approach. However, when `templatingEngine` is set to `'handlebars'`, it uses Handlebars templating engine instead, compiling the template into a reusable function and evaluating it with the provided state object.
1268
- *
1269
- * @param {Object} params - The parameters for composing the context.
1270
- * @param {State} params.state - The state object containing values to replace the placeholders in the template.
1271
- * @param {TemplateType} params.template - The template string or function containing placeholders to be replaced with state values.
1272
- * @param {"handlebars" | undefined} [params.templatingEngine] - The templating engine to use for compiling and evaluating the template (optional, default: `undefined`).
1273
- * @returns {string} The composed context string with placeholders replaced by corresponding state values.
1274
- *
1275
- * @example
1276
- * // Given a state object and a template
1277
- * const state = { userName: "Alice", userAge: 30 };
1278
- * const template = "Hello, {{userName}}! You are {{userAge}} years old";
1279
- *
1280
- * // Composing the context with simple string replacement will result in:
1281
- * // "Hello, Alice! You are 30 years old."
1282
- * const contextSimple = composeContext({ state, template });
1283
- *
1284
- * // Using composeContext with a template function for dynamic template
1285
- * const template = ({ state }) => {
1286
- * const tone = Math.random() > 0.5 ? "kind" : "rude";
1287
- * return `Hello, {{userName}}! You are {{userAge}} years old. Be ${tone}`;
1288
- * };
1289
- * const contextSimple = composeContext({ state, template });
1290
- */
1291
- declare const composeContext: ({ state, template, templatingEngine, }: {
1292
- state: State;
1293
- template: TemplateType;
1294
- templatingEngine?: "handlebars";
1295
- }) => string;
1296
- /**
1297
- * Adds a header to a body of text.
1298
- *
1299
- * This function takes a header string and a body string and returns a new string with the header prepended to the body.
1300
- * If the body string is empty, the header is returned as is.
1301
- *
1302
- * @param {string} header - The header to add to the body.
1303
- * @param {string} body - The body to which to add the header.
1304
- * @returns {string} The body with the header prepended.
1305
- *
1306
- * @example
1307
- * // Given a header and a body
1308
- * const header = "Header";
1309
- * const body = "Body";
1310
- *
1311
- * // Adding the header to the body will result in:
1312
- * // "Header\nBody"
1313
- * const text = addHeader(header, body);
1314
- */
1315
- declare const addHeader: (header: string, body: string) => string;
1316
- /**
1317
- * Generates a string with random user names populated in a template.
1318
- *
1319
- * This function generates a specified number of random user names and populates placeholders
1320
- * in the provided template with these names. Placeholders in the template should follow the format `{{userX}}`
1321
- * where `X` is the position of the user (e.g., `{{user1}}`, `{{user2}}`).
1322
- *
1323
- * @param {string} params.template - The template string containing placeholders for random user names.
1324
- * @param {number} params.length - The number of random user names to generate.
1325
- * @returns {string} The template string with placeholders replaced by random user names.
1326
- *
1327
- * @example
1328
- * // Given a template and a length
1329
- * const template = "Hello, {{user1}}! Meet {{user2}} and {{user3}}.";
1330
- * const length = 3;
1331
- *
1332
- * // Composing the random user string will result in:
1333
- * // "Hello, John! Meet Alice and Bob."
1334
- * const result = composeRandomUser({ template, length });
1335
- */
1336
- declare const composeRandomUser: (template: string, length: number) => string;
1337
-
1338
- declare class CircuitBreaker {
1339
- private readonly config;
1340
- private state;
1341
- private failureCount;
1342
- private lastFailureTime?;
1343
- private halfOpenSuccesses;
1344
- private readonly failureThreshold;
1345
- private readonly resetTimeout;
1346
- private readonly halfOpenMaxAttempts;
1347
- constructor(config?: {
1348
- failureThreshold?: number;
1349
- resetTimeout?: number;
1350
- halfOpenMaxAttempts?: number;
1351
- });
1352
- execute<T>(operation: () => Promise<T>): Promise<T>;
1353
- private handleFailure;
1354
- private reset;
1355
- getState(): "CLOSED" | "OPEN" | "HALF_OPEN";
1356
- }
1357
-
1358
1028
  /**
1359
1029
  * An abstract class representing a database adapter for managing various entities
1360
- * like accounts, memories, actors, goals, and rooms.
1030
+ * like entities, memories, entities, goals, and rooms.
1361
1031
  */
1362
- declare abstract class DatabaseAdapter<DB = any> implements IDatabaseAdapter {
1032
+ declare abstract class DatabaseAdapter<DB = unknown> implements IDatabaseAdapter {
1363
1033
  /**
1364
1034
  * The database instance.
1365
1035
  */
1366
1036
  db: DB;
1367
- /**
1368
- * Circuit breaker instance used to handle fault tolerance and prevent cascading failures.
1369
- * Implements the Circuit Breaker pattern to temporarily disable operations when a failure threshold is reached.
1370
- *
1371
- * The circuit breaker has three states:
1372
- * - CLOSED: Normal operation, requests pass through
1373
- * - OPEN: Failure threshold exceeded, requests are blocked
1374
- * - HALF_OPEN: Testing if service has recovered
1375
- *
1376
- * @protected
1377
- */
1378
- protected circuitBreaker: CircuitBreaker;
1379
- /**
1380
- * Creates a new DatabaseAdapter instance with optional circuit breaker configuration.
1381
- *
1382
- * @param circuitBreakerConfig - Configuration options for the circuit breaker
1383
- * @param circuitBreakerConfig.failureThreshold - Number of failures before circuit opens (defaults to 5)
1384
- * @param circuitBreakerConfig.resetTimeout - Time in ms before attempting to close circuit (defaults to 60000)
1385
- * @param circuitBreakerConfig.halfOpenMaxAttempts - Number of successful attempts needed to close circuit (defaults to 3)
1386
- */
1387
- constructor(circuitBreakerConfig?: {
1388
- failureThreshold?: number;
1389
- resetTimeout?: number;
1390
- halfOpenMaxAttempts?: number;
1391
- });
1392
- /**
1393
- * Optional initialization method for the database adapter.
1394
- * @returns A Promise that resolves when initialization is complete.
1395
- */
1396
- abstract init(): Promise<void>;
1397
1037
  /**
1398
1038
  * Optional close method for the database adapter.
1399
1039
  * @returns A Promise that resolves when closing is complete.
@@ -1401,30 +1041,70 @@ declare abstract class DatabaseAdapter<DB = any> implements IDatabaseAdapter {
1401
1041
  abstract close(): Promise<void>;
1402
1042
  /**
1403
1043
  * Retrieves an account by its ID.
1404
- * @param userId The UUID of the user account to retrieve.
1405
- * @returns A Promise that resolves to the Account object or null if not found.
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.
1406
1046
  */
1407
- abstract getAccountById(userId: UUID): Promise<Account | null>;
1047
+ abstract getEntityById(entityId: UUID): Promise<Entity | null>;
1048
+ abstract getEntitiesForRoom(roomId: UUID, includeComponents?: boolean): Promise<Entity[]>;
1408
1049
  /**
1409
- * Creates a new account in the database.
1410
- * @param account The account object to create.
1050
+ * Creates a new entity in the database.
1051
+ * @param entity The entity object to create.
1411
1052
  * @returns A Promise that resolves when the account creation is complete.
1412
1053
  */
1413
- abstract createAccount(account: Account): Promise<boolean>;
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>;
1414
1096
  /**
1415
1097
  * Retrieves memories based on the specified parameters.
1416
1098
  * @param params An object containing parameters for the memory retrieval.
1417
1099
  * @returns A Promise that resolves to an array of Memory objects.
1418
1100
  */
1419
1101
  abstract getMemories(params: {
1420
- agentId: UUID;
1421
1102
  roomId: UUID;
1422
1103
  count?: number;
1423
1104
  unique?: boolean;
1424
1105
  tableName: string;
1425
1106
  }): Promise<Memory[]>;
1426
1107
  abstract getMemoriesByRoomIds(params: {
1427
- agentId: UUID;
1428
1108
  roomIds: UUID[];
1429
1109
  tableName: string;
1430
1110
  limit?: number;
@@ -1462,18 +1142,10 @@ declare abstract class DatabaseAdapter<DB = any> implements IDatabaseAdapter {
1462
1142
  body: {
1463
1143
  [key: string]: unknown;
1464
1144
  };
1465
- userId: UUID;
1145
+ entityId: UUID;
1466
1146
  roomId: UUID;
1467
1147
  type: string;
1468
1148
  }): Promise<void>;
1469
- /**
1470
- * Retrieves details of actors in a given room.
1471
- * @param params An object containing the roomId to search for actors.
1472
- * @returns A Promise that resolves to an array of Actor objects.
1473
- */
1474
- abstract getActorDetails(params: {
1475
- roomId: UUID;
1476
- }): Promise<Actor[]>;
1477
1149
  /**
1478
1150
  * Searches for memories based on embeddings and other specified parameters.
1479
1151
  * @param params An object containing parameters for the memory search.
@@ -1481,11 +1153,10 @@ declare abstract class DatabaseAdapter<DB = any> implements IDatabaseAdapter {
1481
1153
  */
1482
1154
  abstract searchMemories(params: {
1483
1155
  tableName: string;
1484
- agentId: UUID;
1485
1156
  roomId: UUID;
1486
1157
  embedding: number[];
1487
1158
  match_threshold: number;
1488
- match_count: number;
1159
+ count: number;
1489
1160
  unique: boolean;
1490
1161
  }): Promise<Memory[]>;
1491
1162
  /**
@@ -1497,20 +1168,6 @@ declare abstract class DatabaseAdapter<DB = any> implements IDatabaseAdapter {
1497
1168
  goalId: UUID;
1498
1169
  status: GoalStatus;
1499
1170
  }): Promise<void>;
1500
- /**
1501
- * Searches for memories by embedding and other specified parameters.
1502
- * @param embedding The embedding vector to search with.
1503
- * @param params Additional parameters for the search.
1504
- * @returns A Promise that resolves to an array of Memory objects.
1505
- */
1506
- abstract searchMemoriesByEmbedding(embedding: number[], params: {
1507
- match_threshold?: number;
1508
- count?: number;
1509
- roomId?: UUID;
1510
- agentId?: UUID;
1511
- unique?: boolean;
1512
- tableName: string;
1513
- }): Promise<Memory[]>;
1514
1171
  /**
1515
1172
  * Creates a new memory in the database.
1516
1173
  * @param memory The memory object to create.
@@ -1518,7 +1175,7 @@ declare abstract class DatabaseAdapter<DB = any> implements IDatabaseAdapter {
1518
1175
  * @param unique Indicates if the memory should be unique.
1519
1176
  * @returns A Promise that resolves when the memory has been created.
1520
1177
  */
1521
- abstract createMemory(memory: Memory, tableName: string, unique?: boolean): Promise<void>;
1178
+ abstract createMemory(memory: Memory, tableName: string, unique?: boolean): Promise<UUID>;
1522
1179
  /**
1523
1180
  * Removes a specific memory from the database.
1524
1181
  * @param memoryId The UUID of the memory to remove.
@@ -1547,9 +1204,8 @@ declare abstract class DatabaseAdapter<DB = any> implements IDatabaseAdapter {
1547
1204
  * @returns A Promise that resolves to an array of Goal objects.
1548
1205
  */
1549
1206
  abstract getGoals(params: {
1550
- agentId: UUID;
1551
1207
  roomId: UUID;
1552
- userId?: UUID | null;
1208
+ entityId?: UUID | null;
1553
1209
  onlyInProgress?: boolean;
1554
1210
  count?: number;
1555
1211
  }): Promise<Goal[]>;
@@ -1577,30 +1233,71 @@ declare abstract class DatabaseAdapter<DB = any> implements IDatabaseAdapter {
1577
1233
  * @returns A Promise that resolves when all goals have been removed.
1578
1234
  */
1579
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>;
1580
1265
  /**
1581
1266
  * Retrieves the room ID for a given room, if it exists.
1582
1267
  * @param roomId The UUID of the room to retrieve.
1583
1268
  * @returns A Promise that resolves to the room ID or null if not found.
1584
1269
  */
1585
- abstract getRoom(roomId: UUID): Promise<UUID | null>;
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[]>;
1586
1277
  /**
1587
1278
  * Creates a new room with an optional specified ID.
1588
1279
  * @param roomId Optional UUID to assign to the new room.
1589
1280
  * @returns A Promise that resolves to the UUID of the created room.
1590
1281
  */
1591
- abstract createRoom(roomId?: UUID): Promise<UUID>;
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>;
1592
1289
  /**
1593
1290
  * Removes a specific room from the database.
1594
1291
  * @param roomId The UUID of the room to remove.
1595
1292
  * @returns A Promise that resolves when the room has been removed.
1596
1293
  */
1597
- abstract removeRoom(roomId: UUID): Promise<void>;
1294
+ abstract deleteRoom(roomId: UUID): Promise<void>;
1598
1295
  /**
1599
1296
  * Retrieves room IDs for which a specific user is a participant.
1600
- * @param userId The UUID of the user.
1297
+ * @param entityId The UUID of the user.
1601
1298
  * @returns A Promise that resolves to an array of room IDs.
1602
1299
  */
1603
- abstract getRoomsForParticipant(userId: UUID): Promise<UUID[]>;
1300
+ abstract getRoomsForParticipant(entityId: UUID): Promise<UUID[]>;
1604
1301
  /**
1605
1302
  * Retrieves room IDs for which specific users are participants.
1606
1303
  * @param userIds An array of UUIDs of the users.
@@ -1609,971 +1306,300 @@ declare abstract class DatabaseAdapter<DB = any> implements IDatabaseAdapter {
1609
1306
  abstract getRoomsForParticipants(userIds: UUID[]): Promise<UUID[]>;
1610
1307
  /**
1611
1308
  * Adds a user as a participant to a specific room.
1612
- * @param userId The UUID of the user to add as a participant.
1309
+ * @param entityId The UUID of the user to add as a participant.
1613
1310
  * @param roomId The UUID of the room to which the user will be added.
1614
1311
  * @returns A Promise that resolves to a boolean indicating success or failure.
1615
1312
  */
1616
- abstract addParticipant(userId: UUID, roomId: UUID): Promise<boolean>;
1313
+ abstract addParticipant(entityId: UUID, roomId: UUID): Promise<boolean>;
1617
1314
  /**
1618
1315
  * Removes a user as a participant from a specific room.
1619
- * @param userId The UUID of the user to remove as a participant.
1316
+ * @param entityId The UUID of the user to remove as a participant.
1620
1317
  * @param roomId The UUID of the room from which the user will be removed.
1621
1318
  * @returns A Promise that resolves to a boolean indicating success or failure.
1622
1319
  */
1623
- abstract removeParticipant(userId: UUID, roomId: UUID): Promise<boolean>;
1624
- /**
1625
- * Retrieves participants associated with a specific account.
1626
- * @param userId The UUID of the account.
1627
- * @returns A Promise that resolves to an array of Participant objects.
1628
- */
1629
- abstract getParticipantsForAccount(userId: UUID): Promise<Participant[]>;
1320
+ abstract removeParticipant(entityId: UUID, roomId: UUID): Promise<boolean>;
1630
1321
  /**
1631
1322
  * Retrieves participants associated with a specific account.
1632
- * @param userId The UUID of the account.
1323
+ * @param entityId The UUID of the account.
1633
1324
  * @returns A Promise that resolves to an array of Participant objects.
1634
1325
  */
1635
- abstract getParticipantsForAccount(userId: UUID): Promise<Participant[]>;
1326
+ abstract getParticipantsForEntity(entityId: UUID): Promise<Participant[]>;
1636
1327
  /**
1637
1328
  * Retrieves participants for a specific room.
1638
1329
  * @param roomId The UUID of the room for which to retrieve participants.
1639
1330
  * @returns A Promise that resolves to an array of UUIDs representing the participants.
1640
1331
  */
1641
1332
  abstract getParticipantsForRoom(roomId: UUID): Promise<UUID[]>;
1642
- abstract getParticipantUserState(roomId: UUID, userId: UUID): Promise<"FOLLOWED" | "MUTED" | null>;
1643
- abstract setParticipantUserState(roomId: UUID, userId: UUID, state: "FOLLOWED" | "MUTED" | null): Promise<void>;
1333
+ abstract getParticipantUserState(roomId: UUID, entityId: UUID): Promise<"FOLLOWED" | "MUTED" | null>;
1334
+ abstract setParticipantUserState(roomId: UUID, entityId: UUID, state: "FOLLOWED" | "MUTED" | null): Promise<void>;
1644
1335
  /**
1645
1336
  * Creates a new relationship between two users.
1646
- * @param params An object containing the UUIDs of the two users (userA and userB).
1337
+ * @param params Object containing the relationship details including entity IDs, agent ID, optional tags and metadata
1647
1338
  * @returns A Promise that resolves to a boolean indicating success or failure of the creation.
1648
1339
  */
1649
1340
  abstract createRelationship(params: {
1650
- userA: UUID;
1651
- userB: UUID;
1341
+ sourceEntityId: UUID;
1342
+ targetEntityId: UUID;
1343
+ tags?: string[];
1344
+ metadata?: Record<string, unknown>;
1652
1345
  }): Promise<boolean>;
1653
1346
  /**
1654
1347
  * Retrieves a relationship between two users if it exists.
1655
- * @param params An object containing the UUIDs of the two users (userA and userB).
1348
+ * @param params Object containing the entity IDs and agent ID
1656
1349
  * @returns A Promise that resolves to the Relationship object or null if not found.
1657
1350
  */
1658
1351
  abstract getRelationship(params: {
1659
- userA: UUID;
1660
- userB: UUID;
1352
+ sourceEntityId: UUID;
1353
+ targetEntityId: UUID;
1661
1354
  }): Promise<Relationship | null>;
1662
1355
  /**
1663
1356
  * Retrieves all relationships for a specific user.
1664
- * @param params An object containing the UUID of the user.
1357
+ * @param params Object containing the user ID, agent ID and optional tags to filter by
1665
1358
  * @returns A Promise that resolves to an array of Relationship objects.
1666
1359
  */
1667
1360
  abstract getRelationships(params: {
1668
- userId: UUID;
1361
+ entityId: UUID;
1362
+ tags?: string[];
1669
1363
  }): Promise<Relationship[]>;
1670
1364
  /**
1671
- * Retrieves knowledge items based on specified parameters.
1672
- * @param params Object containing search parameters
1673
- * @returns Promise resolving to array of knowledge items
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.
1674
1368
  */
1675
- abstract getKnowledge(params: {
1676
- id?: UUID;
1677
- agentId: UUID;
1678
- limit?: number;
1679
- query?: string;
1680
- conversationContext?: string;
1681
- }): Promise<RAGKnowledgeItem[]>;
1682
- abstract searchKnowledge(params: {
1683
- agentId: UUID;
1684
- embedding: Float32Array;
1685
- match_threshold: number;
1686
- match_count: number;
1687
- searchText?: string;
1688
- }): Promise<RAGKnowledgeItem[]>;
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>;
1689
1437
  /**
1690
- * Creates a new knowledge item in the database.
1691
- * @param knowledge The knowledge item to create
1692
- * @returns Promise resolving when creation is complete
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
1693
1441
  */
1694
- abstract createKnowledge(knowledge: RAGKnowledgeItem): Promise<void>;
1442
+ abstract createTask(task: Task): Promise<UUID>;
1695
1443
  /**
1696
- * Removes a knowledge item and its associated chunks from the database.
1697
- * @param id The ID of the knowledge item to remove
1698
- * @returns Promise resolving when removal is complete
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
1699
1447
  */
1700
- abstract removeKnowledge(id: UUID): Promise<void>;
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[]>;
1701
1464
  /**
1702
- * Removes an agents full knowledge database and its associated chunks from the database.
1703
- * @param agentId The Agent ID of the knowledge items to remove
1704
- * @returns Promise resolving when removal is complete
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
1705
1469
  */
1706
- abstract clearKnowledge(agentId: UUID, shared?: boolean): Promise<void>;
1470
+ abstract updateTask(id: UUID, task: Partial<Task>): Promise<void>;
1707
1471
  /**
1708
- * Executes an operation with circuit breaker protection.
1709
- * @param operation A function that returns a Promise to be executed with circuit breaker protection
1710
- * @param context A string describing the context/operation being performed for logging purposes
1711
- * @returns A Promise that resolves to the result of the operation
1712
- * @throws Will throw an error if the circuit breaker is open or if the operation fails
1713
- * @protected
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
1714
1475
  */
1715
- protected withCircuitBreaker<T>(operation: () => Promise<T>, context: string): Promise<T>;
1476
+ abstract deleteTask(id: UUID): Promise<void>;
1716
1477
  }
1717
1478
 
1718
- declare const EmbeddingProvider: {
1719
- readonly OpenAI: "OpenAI";
1720
- readonly Ollama: "Ollama";
1721
- readonly GaiaNet: "GaiaNet";
1722
- readonly Heurist: "Heurist";
1723
- readonly BGE: "BGE";
1724
- };
1725
- type EmbeddingProviderType = (typeof EmbeddingProvider)[keyof typeof EmbeddingProvider];
1726
- type EmbeddingConfig = {
1727
- readonly dimensions: number;
1728
- readonly model: string;
1729
- readonly provider: EmbeddingProviderType;
1730
- };
1731
- declare const getEmbeddingConfig: () => EmbeddingConfig;
1732
- declare function getEmbeddingType(runtime: IAgentRuntime): "local" | "remote";
1733
- declare function getEmbeddingZeroVector(): number[];
1734
- /**
1735
- * Gets embeddings from a remote API endpoint. Falls back to local BGE/384
1736
- *
1737
- * @param {string} input - The text to generate embeddings for
1738
- * @param {EmbeddingOptions} options - Configuration options including:
1739
- * - model: The model name to use
1740
- * - endpoint: Base API endpoint URL
1741
- * - apiKey: Optional API key for authentication
1742
- * - isOllama: Whether this is an Ollama endpoint
1743
- * - dimensions: Desired embedding dimensions
1744
- * @param {IAgentRuntime} runtime - The agent runtime context
1745
- * @returns {Promise<number[]>} Array of embedding values
1746
- * @throws {Error} If the API request fails
1747
- */
1748
- declare function embed(runtime: IAgentRuntime, input: string): Promise<number[]>;
1749
-
1750
- /**
1751
- * Template used for the evaluation generateText.
1752
- */
1753
- declare const evaluationTemplate: string;
1754
- /**
1755
- * Formats the names of evaluators into a comma-separated list, each enclosed in single quotes.
1756
- * @param evaluators - An array of evaluator objects.
1757
- * @returns A string that concatenates the names of all evaluators, each enclosed in single quotes and separated by commas.
1758
- */
1759
- declare function formatEvaluatorNames(evaluators: Evaluator[]): string;
1760
- /**
1761
- * Formats evaluator details into a string, including both the name and description of each evaluator.
1762
- * @param evaluators - An array of evaluator objects.
1763
- * @returns A string that concatenates the name and description of each evaluator, separated by a colon and a newline character.
1764
- */
1765
- declare function formatEvaluators(evaluators: Evaluator[]): string;
1766
- /**
1767
- * Formats evaluator examples into a readable string, replacing placeholders with generated names.
1768
- * @param evaluators - An array of evaluator objects, each containing examples to format.
1769
- * @returns A string that presents each evaluator example in a structured format, including context, messages, and outcomes, with placeholders replaced by generated names.
1770
- */
1771
- declare function formatEvaluatorExamples(evaluators: Evaluator[]): string;
1772
- /**
1773
- * Generates a string summarizing the descriptions of each evaluator example.
1774
- * @param evaluators - An array of evaluator objects, each containing examples.
1775
- * @returns A string that summarizes the descriptions for each evaluator example, formatted with the evaluator name, example number, and description.
1776
- */
1777
- declare function formatEvaluatorExampleDescriptions(evaluators: Evaluator[]): string;
1778
-
1779
- type Tool = CoreTool<any, any>;
1780
- type StepResult = StepResult$1<any>;
1781
- /**
1782
- * Trims the provided text context to a specified token limit using a tokenizer model and type.
1783
- *
1784
- * The function dynamically determines the truncation method based on the tokenizer settings
1785
- * provided by the runtime. If no tokenizer settings are defined, it defaults to using the
1786
- * TikToken truncation method with the "gpt-4o" model.
1787
- *
1788
- * @async
1789
- * @function trimTokens
1790
- * @param {string} context - The text to be tokenized and trimmed.
1791
- * @param {number} maxTokens - The maximum number of tokens allowed after truncation.
1792
- * @param {IAgentRuntime} runtime - The runtime interface providing tokenizer settings.
1793
- *
1794
- * @returns {Promise<string>} A promise that resolves to the trimmed text.
1795
- *
1796
- * @throws {Error} Throws an error if the runtime settings are invalid or missing required fields.
1797
- *
1798
- * @example
1799
- * const trimmedText = await trimTokens("This is an example text", 50, runtime);
1800
- * console.log(trimmedText); // Output will be a truncated version of the input text.
1801
- */
1802
- declare function trimTokens(context: string, maxTokens: number, runtime: IAgentRuntime): Promise<string>;
1479
+ declare function findEntityByName(runtime: IAgentRuntime, message: Memory, state: State): Promise<Entity | null>;
1480
+ declare const createUniqueUuid: (runtime: any, baseUserId: UUID | string) => UUID;
1803
1481
  /**
1804
- * Send a message to the model for a text generateText - receive a string back and parse how you'd like
1805
- * @param opts - The options for the generateText request.
1806
- * @param opts.context The context of the message to be completed.
1807
- * @param opts.stop A list of strings to stop the generateText at.
1808
- * @param opts.model The model to use for generateText.
1809
- * @param opts.frequency_penalty The frequency penalty to apply to the generateText.
1810
- * @param opts.presence_penalty The presence penalty to apply to the generateText.
1811
- * @param opts.temperature The temperature to apply to the generateText.
1812
- * @param opts.max_context_length The maximum length of the context to apply to the generateText.
1813
- * @returns The completed message.
1482
+ * Get details for a list of entities.
1814
1483
  */
1815
- declare function generateText({ runtime, context, modelClass, tools, onStepFinish, maxSteps, stop, customSystemPrompt, }: {
1484
+ declare function getEntityDetails({ runtime, roomId, }: {
1816
1485
  runtime: IAgentRuntime;
1817
- context: string;
1818
- modelClass: ModelClass;
1819
- tools?: Record<string, Tool>;
1820
- onStepFinish?: (event: StepResult) => Promise<void> | void;
1821
- maxSteps?: number;
1822
- stop?: string[];
1823
- customSystemPrompt?: string;
1824
- }): Promise<string>;
1486
+ roomId: UUID;
1487
+ }): Promise<any[]>;
1488
+
1489
+ interface Settings {
1490
+ [key: string]: string | undefined;
1491
+ }
1825
1492
  /**
1826
- * Sends a message to the model to determine if it should respond to the given context.
1827
- * @param opts - The options for the generateText request
1828
- * @param opts.context The context to evaluate for response
1829
- * @param opts.stop A list of strings to stop the generateText at
1830
- * @param opts.model The model to use for generateText
1831
- * @param opts.frequency_penalty The frequency penalty to apply (0.0 to 2.0)
1832
- * @param opts.presence_penalty The presence penalty to apply (0.0 to 2.0)
1833
- * @param opts.temperature The temperature to control randomness (0.0 to 2.0)
1834
- * @param opts.serverUrl The URL of the API server
1835
- * @param opts.max_context_length Maximum allowed context length in tokens
1836
- * @param opts.max_response_length Maximum allowed response length in tokens
1837
- * @returns Promise resolving to "RESPOND", "IGNORE", "STOP" or null
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
1838
1497
  */
1839
- declare function generateShouldRespond({ runtime, context, modelClass, }: {
1840
- runtime: IAgentRuntime;
1841
- context: string;
1842
- modelClass: ModelClass;
1843
- }): Promise<"RESPOND" | "IGNORE" | "STOP" | null>;
1498
+ declare function findNearestEnvFile(startDir?: string): string;
1844
1499
  /**
1845
- * Splits content into chunks of specified size with optional overlapping bleed sections
1846
- * @param content - The text content to split into chunks
1847
- * @param chunkSize - The maximum size of each chunk in tokens
1848
- * @param bleed - Number of characters to overlap between chunks (default: 100)
1849
- * @returns Promise resolving to array of text chunks with bleed sections
1500
+ * Configures environment settings for browser usage
1501
+ * @param {Settings} settings - Object containing environment variables
1850
1502
  */
1851
- declare function splitChunks(content: string, chunkSize?: number, bleed?: number): Promise<string[]>;
1852
- declare function splitText(content: string, chunkSize: number, bleed: number): string[];
1503
+ declare function configureSettings(settings: Settings): void;
1853
1504
  /**
1854
- * Sends a message to the model and parses the response as a boolean value
1855
- * @param opts - The options for the generateText request
1856
- * @param opts.context The context to evaluate for the boolean response
1857
- * @param opts.stop A list of strings to stop the generateText at
1858
- * @param opts.model The model to use for generateText
1859
- * @param opts.frequency_penalty The frequency penalty to apply (0.0 to 2.0)
1860
- * @param opts.presence_penalty The presence penalty to apply (0.0 to 2.0)
1861
- * @param opts.temperature The temperature to control randomness (0.0 to 2.0)
1862
- * @param opts.serverUrl The URL of the API server
1863
- * @param opts.max_context_length Maximum allowed context length in tokens
1864
- * @param opts.max_response_length Maximum allowed response length in tokens
1865
- * @returns Promise resolving to a boolean value parsed from the model's response
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
1866
1509
  */
1867
- declare function generateTrueOrFalse({ runtime, context, modelClass, }: {
1868
- runtime: IAgentRuntime;
1869
- context: string;
1870
- modelClass: ModelClass;
1871
- }): Promise<boolean>;
1510
+ declare function loadEnvConfig(): Settings;
1872
1511
  /**
1873
- * Send a message to the model and parse the response as a string array
1874
- * @param opts - The options for the generateText request
1875
- * @param opts.context The context/prompt to send to the model
1876
- * @param opts.stop Array of strings that will stop the model's generation if encountered
1877
- * @param opts.model The language model to use
1878
- * @param opts.frequency_penalty The frequency penalty to apply (0.0 to 2.0)
1879
- * @param opts.presence_penalty The presence penalty to apply (0.0 to 2.0)
1880
- * @param opts.temperature The temperature to control randomness (0.0 to 2.0)
1881
- * @param opts.serverUrl The URL of the API server
1882
- * @param opts.token The API token for authentication
1883
- * @param opts.max_context_length Maximum allowed context length in tokens
1884
- * @param opts.max_response_length Maximum allowed response length in tokens
1885
- * @returns Promise resolving to an array of strings parsed from the model's response
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
1886
1516
  */
1887
- declare function generateTextArray({ runtime, context, modelClass, }: {
1888
- runtime: IAgentRuntime;
1889
- context: string;
1890
- modelClass: ModelClass;
1891
- }): Promise<string[]>;
1892
- declare function generateObjectDeprecated({ runtime, context, modelClass, }: {
1893
- runtime: IAgentRuntime;
1894
- context: string;
1895
- modelClass: ModelClass;
1896
- }): Promise<any>;
1897
- declare function generateObjectArray({ runtime, context, modelClass, }: {
1898
- runtime: IAgentRuntime;
1899
- context: string;
1900
- modelClass: ModelClass;
1901
- }): Promise<any[]>;
1517
+ declare function getEnvVariable(key: string, defaultValue?: string): string | undefined;
1902
1518
  /**
1903
- * Send a message to the model for generateText.
1904
- * @param opts - The options for the generateText request.
1905
- * @param opts.context The context of the message to be completed.
1906
- * @param opts.stop A list of strings to stop the generateText at.
1907
- * @param opts.model The model to use for generateText.
1908
- * @param opts.frequency_penalty The frequency penalty to apply to the generateText.
1909
- * @param opts.presence_penalty The presence penalty to apply to the generateText.
1910
- * @param opts.temperature The temperature to apply to the generateText.
1911
- * @param opts.max_context_length The maximum length of the context to apply to the generateText.
1912
- * @returns The completed message.
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
1913
1522
  */
1914
- declare function generateMessageResponse({ runtime, context, modelClass, }: {
1915
- runtime: IAgentRuntime;
1916
- context: string;
1917
- modelClass: ModelClass;
1918
- }): Promise<Content>;
1919
- declare const generateImage: (data: {
1920
- prompt: string;
1921
- width: number;
1922
- height: number;
1923
- count?: number;
1924
- negativePrompt?: string;
1925
- numIterations?: number;
1926
- guidanceScale?: number;
1927
- seed?: number;
1928
- modelId?: string;
1929
- jobId?: string;
1930
- stylePreset?: string;
1931
- hideWatermark?: boolean;
1932
- safeMode?: boolean;
1933
- cfgScale?: number;
1934
- }, runtime: IAgentRuntime) => Promise<{
1935
- success: boolean;
1936
- data?: string[];
1937
- error?: any;
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>;
1938
1569
  }>;
1939
- declare const generateCaption: (data: {
1940
- imageUrl: string;
1941
- }, runtime: IAgentRuntime) => Promise<{
1942
- title: string;
1943
- description: string;
1944
- }>;
1945
- /**
1946
- * Configuration options for generating objects with a model.
1947
- */
1948
- interface GenerationOptions {
1949
- runtime: IAgentRuntime;
1950
- context: string;
1951
- modelClass: ModelClass;
1952
- schema?: ZodSchema;
1953
- schemaName?: string;
1954
- schemaDescription?: string;
1955
- stop?: string[];
1956
- mode?: "auto" | "json" | "tool";
1957
- experimental_providerMetadata?: Record<string, unknown>;
1958
- }
1959
- /**
1960
- * Base settings for model generation.
1961
- */
1962
- interface ModelSettings {
1963
- prompt: string;
1964
- temperature: number;
1965
- maxTokens: number;
1966
- frequencyPenalty: number;
1967
- presencePenalty: number;
1968
- stop?: string[];
1969
- experimental_telemetry?: TelemetrySettings;
1970
- }
1971
- /**
1972
- * Generates structured objects from a prompt using specified AI models and configuration options.
1973
- *
1974
- * @param {GenerationOptions} options - Configuration options for generating objects.
1975
- * @returns {Promise<any[]>} - A promise that resolves to an array of generated objects.
1976
- * @throws {Error} - Throws an error if the provider is unsupported or if generation fails.
1977
- */
1978
- declare const generateObject: ({ runtime, context, modelClass, schema, schemaName, schemaDescription, stop, mode, }: GenerationOptions) => Promise<GenerateObjectResult<unknown>>;
1979
- /**
1980
- * Interface for provider-specific generation options.
1981
- */
1982
- interface ProviderOptions {
1983
- runtime: IAgentRuntime;
1984
- provider: ModelProviderName;
1985
- model: any;
1986
- apiKey: string;
1987
- schema?: ZodSchema;
1988
- schemaName?: string;
1989
- schemaDescription?: string;
1990
- mode?: "auto" | "json" | "tool";
1991
- experimental_providerMetadata?: Record<string, unknown>;
1992
- modelOptions: ModelSettings;
1993
- modelClass: ModelClass;
1994
- context: string;
1995
- }
1996
- /**
1997
- * Handles AI generation based on the specified provider.
1998
- *
1999
- * @param {ProviderOptions} options - Configuration options specific to the provider.
2000
- * @returns {Promise<any[]>} - A promise that resolves to an array of generated objects.
2001
- */
2002
- declare function handleProvider(options: ProviderOptions): Promise<GenerateObjectResult<unknown>>;
2003
- declare function generateTweetActions({ runtime, context, modelClass, }: {
2004
- runtime: IAgentRuntime;
2005
- context: string;
2006
- modelClass: ModelClass;
2007
- }): Promise<ActionResponse | null>;
2008
-
2009
- declare const getGoals: ({ runtime, roomId, userId, onlyInProgress, count, }: {
2010
- runtime: IAgentRuntime;
2011
- roomId: UUID;
2012
- userId?: UUID;
2013
- onlyInProgress?: boolean;
2014
- count?: number;
2015
- }) => Promise<Goal[]>;
2016
- declare const formatGoalsAsString: ({ goals }: {
2017
- goals: Goal[];
2018
- }) => string;
2019
- declare const updateGoal: ({ runtime, goal, }: {
2020
- runtime: IAgentRuntime;
2021
- goal: Goal;
2022
- }) => Promise<void>;
2023
- declare const createGoal: ({ runtime, goal, }: {
2024
- runtime: IAgentRuntime;
2025
- goal: Goal;
2026
- }) => Promise<void>;
2027
-
2028
- /**
2029
- * Manage memories in the database.
2030
- */
2031
- declare class MemoryManager implements IMemoryManager {
2032
- /**
2033
- * The AgentRuntime instance associated with this manager.
2034
- */
2035
- runtime: IAgentRuntime;
2036
- /**
2037
- * The name of the database table this manager operates on.
2038
- */
2039
- tableName: string;
2040
- /**
2041
- * Constructs a new MemoryManager instance.
2042
- * @param opts Options for the manager.
2043
- * @param opts.tableName The name of the table this manager will operate on.
2044
- * @param opts.runtime The AgentRuntime instance associated with this manager.
2045
- */
2046
- constructor(opts: {
2047
- tableName: string;
2048
- runtime: IAgentRuntime;
2049
- });
2050
- /**
2051
- * Adds an embedding vector to a memory object. If the memory already has an embedding, it is returned as is.
2052
- * @param memory The memory object to add an embedding to.
2053
- * @returns A Promise resolving to the memory object, potentially updated with an embedding vector.
2054
- */
2055
- /**
2056
- * Adds an embedding vector to a memory object if one doesn't already exist.
2057
- * The embedding is generated from the memory's text content using the runtime's
2058
- * embedding model. If the memory has no text content, an error is thrown.
2059
- *
2060
- * @param memory The memory object to add an embedding to
2061
- * @returns The memory object with an embedding vector added
2062
- * @throws Error if the memory content is empty
2063
- */
2064
- addEmbeddingToMemory(memory: Memory): Promise<Memory>;
2065
- /**
2066
- * Retrieves a list of memories by user IDs, with optional deduplication.
2067
- * @param opts Options including user IDs, count, and uniqueness.
2068
- * @param opts.roomId The room ID to retrieve memories for.
2069
- * @param opts.count The number of memories to retrieve.
2070
- * @param opts.unique Whether to retrieve unique memories only.
2071
- * @returns A Promise resolving to an array of Memory objects.
2072
- */
2073
- getMemories({ roomId, count, unique, start, end, }: {
2074
- roomId: UUID;
2075
- count?: number;
2076
- unique?: boolean;
2077
- start?: number;
2078
- end?: number;
2079
- }): Promise<Memory[]>;
2080
- getCachedEmbeddings(content: string): Promise<{
2081
- embedding: number[];
2082
- levenshtein_score: number;
2083
- }[]>;
2084
- /**
2085
- * Searches for memories similar to a given embedding vector.
2086
- * @param embedding The embedding vector to search with.
2087
- * @param opts Options including match threshold, count, user IDs, and uniqueness.
2088
- * @param opts.match_threshold The similarity threshold for matching memories.
2089
- * @param opts.count The maximum number of memories to retrieve.
2090
- * @param opts.roomId The room ID to retrieve memories for.
2091
- * @param opts.unique Whether to retrieve unique memories only.
2092
- * @returns A Promise resolving to an array of Memory objects that match the embedding.
2093
- */
2094
- searchMemoriesByEmbedding(embedding: number[], opts: {
2095
- match_threshold?: number;
2096
- count?: number;
2097
- roomId: UUID;
2098
- unique?: boolean;
2099
- }): Promise<Memory[]>;
2100
- /**
2101
- * Creates a new memory in the database, with an option to check for similarity before insertion.
2102
- * @param memory The memory object to create.
2103
- * @param unique Whether to check for similarity before insertion.
2104
- * @returns A Promise that resolves when the operation completes.
2105
- */
2106
- createMemory(memory: Memory, unique?: boolean): Promise<void>;
2107
- getMemoriesByRoomIds(params: {
2108
- roomIds: UUID[];
2109
- limit?: number;
2110
- }): Promise<Memory[]>;
2111
- getMemoryById(id: UUID): Promise<Memory | null>;
2112
- /**
2113
- * Removes a memory from the database by its ID.
2114
- * @param memoryId The ID of the memory to remove.
2115
- * @returns A Promise that resolves when the operation completes.
2116
- */
2117
- removeMemory(memoryId: UUID): Promise<void>;
2118
- /**
2119
- * Removes all memories associated with a set of user IDs.
2120
- * @param roomId The room ID to remove memories for.
2121
- * @returns A Promise that resolves when the operation completes.
2122
- */
2123
- removeAllMemories(roomId: UUID): Promise<void>;
2124
- /**
2125
- * Counts the number of memories associated with a set of user IDs, with an option for uniqueness.
2126
- * @param roomId The room ID to count memories for.
2127
- * @param unique Whether to count unique memories only.
2128
- * @returns A Promise resolving to the count of memories.
2129
- */
2130
- countMemories(roomId: UUID, unique?: boolean): Promise<number>;
2131
- }
2132
-
2133
- /**
2134
- * Get details for a list of actors.
2135
- */
2136
- declare function getActorDetails({ runtime, roomId, }: {
2137
- runtime: IAgentRuntime;
2138
- roomId: UUID;
2139
- }): Promise<Actor[]>;
2140
- /**
2141
- * Format actors into a string
2142
- * @param actors - list of actors
2143
- * @returns string
2144
- */
2145
- declare function formatActors({ actors }: {
2146
- actors: Actor[];
2147
- }): string;
2148
- /**
2149
- * Format messages into a string
2150
- * @param messages - list of messages
2151
- * @param actors - list of actors
2152
- * @returns string
2153
- */
2154
- declare const formatMessages: ({ messages, actors, }: {
2155
- messages: Memory[];
2156
- actors: Actor[];
2157
- }) => string;
2158
- declare const formatTimestamp: (messageDate: number) => string;
2159
-
2160
- declare const models: Models;
2161
- declare function getModelSettings(provider: ModelProviderName, type: ModelClass): ModelSettings$1 | undefined;
2162
- declare function getImageModelSettings(provider: ModelProviderName): ImageModelSettings | undefined;
2163
- declare function getEmbeddingModelSettings(provider: ModelProviderName): EmbeddingModelSettings | undefined;
2164
- declare function getEndpoint(provider: ModelProviderName): any;
2165
-
2166
- declare const formatPosts: ({ messages, actors, conversationHeader, }: {
2167
- messages: Memory[];
2168
- actors: Actor[];
2169
- conversationHeader?: boolean;
2170
- }) => string;
2171
-
2172
- /**
2173
- * Formats provider outputs into a string which can be injected into the context.
2174
- * @param runtime The AgentRuntime object.
2175
- * @param message The incoming message object.
2176
- * @param state The current state object.
2177
- * @returns A string that concatenates the outputs of each provider.
2178
- */
2179
- declare function getProviders(runtime: IAgentRuntime, message: Memory, state?: State): Promise<string>;
2180
-
2181
- declare function createRelationship({ runtime, userA, userB, }: {
2182
- runtime: IAgentRuntime;
2183
- userA: UUID;
2184
- userB: UUID;
2185
- }): Promise<boolean>;
2186
- declare function getRelationship({ runtime, userA, userB, }: {
2187
- runtime: IAgentRuntime;
2188
- userA: UUID;
2189
- userB: UUID;
2190
- }): Promise<Relationship>;
2191
- declare function getRelationships({ runtime, userId, }: {
2192
- runtime: IAgentRuntime;
2193
- userId: UUID;
2194
- }): Promise<Relationship[]>;
2195
- declare function formatRelationships({ runtime, userId, }: {
2196
- runtime: IAgentRuntime;
2197
- userId: UUID;
2198
- }): Promise<`${string}-${string}-${string}-${string}-${string}`[]>;
2199
-
2200
- declare class AgentRuntime implements IAgentRuntime {
2201
- #private;
2202
- /**
2203
- * The ID of the agent
2204
- */
2205
- agentId: UUID;
2206
- /**
2207
- * The base URL of the server where the agent's requests are processed.
2208
- */
2209
- serverUrl: string;
2210
- /**
2211
- * The database adapter used for interacting with the database.
2212
- */
2213
- databaseAdapter: IDatabaseAdapter;
2214
- /**
2215
- * Authentication token used for securing requests.
2216
- */
2217
- token: string | null;
2218
- /**
2219
- * Custom actions that the agent can perform.
2220
- */
2221
- actions: Action[];
2222
- /**
2223
- * Evaluators used to assess and guide the agent's responses.
2224
- */
2225
- evaluators: Evaluator[];
2226
- /**
2227
- * Context providers used to provide context for message generation.
2228
- */
2229
- providers: Provider[];
2230
- /**
2231
- * Database adapters used to interact with the database.
2232
- */
2233
- adapters: Adapter[];
2234
- plugins: Plugin[];
2235
- /**
2236
- * The model to use for generateText.
2237
- */
2238
- modelProvider: ModelProviderName;
2239
- /**
2240
- * The model to use for generateImage.
2241
- */
2242
- imageModelProvider: ModelProviderName;
2243
- /**
2244
- * The model to use for describing images.
2245
- */
2246
- imageVisionModelProvider: ModelProviderName;
2247
- /**
2248
- * Fetch function to use
2249
- * Some environments may not have access to the global fetch function and need a custom fetch override.
2250
- */
2251
- fetch: typeof fetch;
2252
- /**
2253
- * The character to use for the agent
2254
- */
2255
- character: Character;
2256
- /**
2257
- * Store messages that are sent and received by the agent.
2258
- */
2259
- messageManager: IMemoryManager;
2260
- /**
2261
- * Store and recall descriptions of users based on conversations.
2262
- */
2263
- descriptionManager: IMemoryManager;
2264
- /**
2265
- * Manage the creation and recall of static information (documents, historical game lore, etc)
2266
- */
2267
- loreManager: IMemoryManager;
2268
- /**
2269
- * Hold large documents that can be referenced
2270
- */
2271
- documentsManager: IMemoryManager;
2272
- /**
2273
- * Searchable document fragments
2274
- */
2275
- knowledgeManager: IMemoryManager;
2276
- ragKnowledgeManager: IRAGKnowledgeManager;
2277
- private readonly knowledgeRoot;
2278
- services: Map<ServiceType, Service>;
2279
- memoryManagers: Map<string, IMemoryManager>;
2280
- cacheManager: ICacheManager;
2281
- clients: ClientInstance[];
2282
- registerMemoryManager(manager: IMemoryManager): void;
2283
- getMemoryManager(tableName: string): IMemoryManager | null;
2284
- getService<T extends Service>(service: ServiceType): T | null;
2285
- registerService(service: Service): Promise<void>;
2286
- /**
2287
- * Creates an instance of AgentRuntime.
2288
- * @param opts - The options for configuring the AgentRuntime.
2289
- * @param opts.conversationLength - The number of messages to hold in the recent message cache.
2290
- * @param opts.token - The JWT token, can be a JWT token if outside worker, or an OpenAI token if inside worker.
2291
- * @param opts.serverUrl - The URL of the worker.
2292
- * @param opts.actions - Optional custom actions.
2293
- * @param opts.evaluators - Optional custom evaluators.
2294
- * @param opts.services - Optional custom services.
2295
- * @param opts.memoryManagers - Optional custom memory managers.
2296
- * @param opts.providers - Optional context providers.
2297
- * @param opts.model - The model to use for generateText.
2298
- * @param opts.embeddingModel - The model to use for embedding.
2299
- * @param opts.agentId - Optional ID of the agent.
2300
- * @param opts.databaseAdapter - The database adapter used for interacting with the database.
2301
- * @param opts.fetch - Custom fetch function to use for making requests.
2302
- */
2303
- constructor(opts: {
2304
- conversationLength?: number;
2305
- agentId?: UUID;
2306
- character?: Character;
2307
- token: string;
2308
- serverUrl?: string;
2309
- actions?: Action[];
2310
- evaluators?: Evaluator[];
2311
- plugins?: Plugin[];
2312
- providers?: Provider[];
2313
- modelProvider: ModelProviderName;
2314
- services?: Service[];
2315
- managers?: IMemoryManager[];
2316
- databaseAdapter?: IDatabaseAdapter;
2317
- fetch?: typeof fetch | unknown;
2318
- speechModelPath?: string;
2319
- cacheManager?: ICacheManager;
2320
- logging?: boolean;
2321
- });
2322
- private initializeDatabase;
2323
- initialize(): Promise<void>;
2324
- stop(): Promise<void>;
2325
- /**
2326
- * Processes character knowledge by creating document memories and fragment memories.
2327
- * This function takes an array of knowledge items, creates a document memory for each item if it doesn't exist,
2328
- * then chunks the content into fragments, embeds each fragment, and creates fragment memories.
2329
- * @param knowledge An array of knowledge items containing id, path, and content.
2330
- */
2331
- private processCharacterKnowledge;
2332
- /**
2333
- * Processes character knowledge by creating document memories and fragment memories.
2334
- * This function takes an array of knowledge items, creates a document knowledge for each item if it doesn't exist,
2335
- * then chunks the content into fragments, embeds each fragment, and creates fragment knowledge.
2336
- * An array of knowledge items or objects containing id, path, and content.
2337
- */
2338
- private processCharacterRAGKnowledge;
2339
- /**
2340
- * Processes directory-based RAG knowledge by recursively loading and processing files.
2341
- * @param dirConfig The directory configuration containing path and shared flag
2342
- */
2343
- private processCharacterRAGDirectory;
2344
- getSetting(key: string): any;
2345
- /**
2346
- * Get the number of messages that are kept in the conversation buffer.
2347
- * @returns The number of recent messages to be kept in memory.
2348
- */
2349
- getConversationLength(): number;
2350
- /**
2351
- * Register an action for the agent to perform.
2352
- * @param action The action to register.
2353
- */
2354
- registerAction(action: Action): void;
2355
- /**
2356
- * Register an evaluator to assess and guide the agent's responses.
2357
- * @param evaluator The evaluator to register.
2358
- */
2359
- registerEvaluator(evaluator: Evaluator): void;
2360
- /**
2361
- * Register a context provider to provide context for message generation.
2362
- * @param provider The context provider to register.
2363
- */
2364
- registerContextProvider(provider: Provider): void;
2365
- /**
2366
- * Register an adapter for the agent to use.
2367
- * @param adapter The adapter to register.
2368
- */
2369
- registerAdapter(adapter: Adapter): void;
2370
- /**
2371
- * Process the actions of a message.
2372
- * @param message The message to process.
2373
- * @param content The content of the message to process actions from.
2374
- */
2375
- processActions(message: Memory, responses: Memory[], state?: State, callback?: HandlerCallback): Promise<void>;
2376
- /**
2377
- * Evaluate the message and state using the registered evaluators.
2378
- * @param message The message to evaluate.
2379
- * @param state The state of the agent.
2380
- * @param didRespond Whether the agent responded to the message.~
2381
- * @param callback The handler callback
2382
- * @returns The results of the evaluation.
2383
- */
2384
- evaluate(message: Memory, state: State, didRespond?: boolean, callback?: HandlerCallback): Promise<string[]>;
2385
- /**
2386
- * Ensure the existence of a participant in the room. If the participant does not exist, they are added to the room.
2387
- * @param userId - The user ID to ensure the existence of.
2388
- * @throws An error if the participant cannot be added.
2389
- */
2390
- ensureParticipantExists(userId: UUID, roomId: UUID): Promise<void>;
2391
- /**
2392
- * Ensure the existence of a user in the database. If the user does not exist, they are added to the database.
2393
- * @param userId - The user ID to ensure the existence of.
2394
- * @param userName - The user name to ensure the existence of.
2395
- * @returns
2396
- */
2397
- ensureUserExists(userId: UUID, userName: string | null, name: string | null, email?: string | null, source?: string | null): Promise<void>;
2398
- ensureParticipantInRoom(userId: UUID, roomId: UUID): Promise<void>;
2399
- ensureConnection(userId: UUID, roomId: UUID, userName?: string, userScreenName?: string, source?: string): Promise<void>;
2400
- /**
2401
- * Ensure the existence of a room between the agent and a user. If no room exists, a new room is created and the user
2402
- * and agent are added as participants. The room ID is returned.
2403
- * @param userId - The user ID to create a room with.
2404
- * @returns The room ID of the room between the agent and the user.
2405
- * @throws An error if the room cannot be created.
2406
- */
2407
- ensureRoomExists(roomId: UUID): Promise<void>;
2408
- /**
2409
- * Compose the state of the agent into an object that can be passed or used for response generation.
2410
- * @param message The message to compose the state from.
2411
- * @returns The state of the agent.
2412
- */
2413
- composeState(message: Memory, additionalKeys?: {
2414
- [key: string]: unknown;
2415
- }): Promise<State>;
2416
- updateRecentMessageState(state: State): Promise<State>;
2417
- }
2418
-
2419
- interface Settings {
2420
- [key: string]: string | undefined;
2421
- }
2422
- /**
2423
- * Recursively searches for a .env file starting from the current directory
2424
- * and moving up through parent directories (Node.js only)
2425
- * @param {string} [startDir=process.cwd()] - Starting directory for the search
2426
- * @returns {string|null} Path to the nearest .env file or null if not found
2427
- */
2428
- declare function findNearestEnvFile(startDir?: string): string;
2429
- /**
2430
- * Configures environment settings for browser usage
2431
- * @param {Settings} settings - Object containing environment variables
2432
- */
2433
- declare function configureSettings(settings: Settings): void;
2434
- /**
2435
- * Loads environment variables from the nearest .env file in Node.js
2436
- * or returns configured settings in browser
2437
- * @returns {Settings} Environment variables object
2438
- * @throws {Error} If no .env file is found in Node.js environment
2439
- */
2440
- declare function loadEnvConfig(): Settings;
2441
- /**
2442
- * Gets a specific environment variable
2443
- * @param {string} key - The environment variable key
2444
- * @param {string} [defaultValue] - Optional default value if key doesn't exist
2445
- * @returns {string|undefined} The environment variable value or default value
2446
- */
2447
- declare function getEnvVariable(key: string, defaultValue?: string): string | undefined;
2448
- /**
2449
- * Checks if a specific environment variable exists
2450
- * @param {string} key - The environment variable key
2451
- * @returns {boolean} True if the environment variable exists
2452
- */
2453
- declare function hasEnvVariable(key: string): boolean;
2454
- declare const settings: Settings;
2455
-
2456
- declare const elizaLogger: pino.Logger<string, boolean>;
2457
-
2458
- declare const messageCompletionFooter = "\nResponse format should be formatted in a valid JSON block like this:\n```json\n{ \"user\": \"{{agentName}}\", \"text\": \"<string>\", \"action\": \"<string>\" }\n```\n\nThe \u201Caction\u201D field should be one of the options in [Available Actions] and the \"text\" field should be the response you want to send.\n";
2459
- declare const shouldRespondFooter = "The available options are [RESPOND], [IGNORE], or [STOP]. Choose the most appropriate option.\nIf {{agentName}} is talking too much, you can choose [IGNORE]\n\nYour response must include one of the options.";
2460
- declare const parseShouldRespondFromText: (text: string) => "RESPOND" | "IGNORE" | "STOP" | null;
2461
- declare const booleanFooter = "Respond with only a YES or a NO.";
2462
- /**
2463
- * Parses a string to determine its boolean equivalent.
2464
- *
2465
- * Recognized affirmative values: "YES", "Y", "TRUE", "T", "1", "ON", "ENABLE".
2466
- * Recognized negative values: "NO", "N", "FALSE", "F", "0", "OFF", "DISABLE".
2467
- *
2468
- * @param {string} text - The input text to parse.
2469
- * @returns {boolean|null} - Returns `true` for affirmative inputs, `false` for negative inputs, and `null` for unrecognized inputs or null/undefined.
2470
- */
2471
- declare const parseBooleanFromText: (text: string) => boolean;
2472
- 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.";
2473
- /**
2474
- * Parses a JSON array from a given text. The function looks for a JSON block wrapped in triple backticks
2475
- * with `json` language identifier, and if not found, it searches for an array pattern within the text.
2476
- * It then attempts to parse the JSON string into a JavaScript object. If parsing is successful and the result
2477
- * is an array, it returns the array; otherwise, it returns null.
2478
- *
2479
- * @param text - The input text from which to extract and parse the JSON array.
2480
- * @returns An array parsed from the JSON string if successful; otherwise, null.
2481
- */
2482
- declare function parseJsonArrayFromText(text: string): any[];
2483
- /**
2484
- * Parses a JSON object from a given text. The function looks for a JSON block wrapped in triple backticks
2485
- * with `json` language identifier, and if not found, it searches for an object pattern within the text.
2486
- * It then attempts to parse the JSON string into a JavaScript object. If parsing is successful and the result
2487
- * is an object (but not an array), it returns the object; otherwise, it tries to parse an array if the result
2488
- * is an array, or returns null if parsing is unsuccessful or the result is neither an object nor an array.
2489
- *
2490
- * @param text - The input text from which to extract and parse the JSON object.
2491
- * @returns An object parsed from the JSON string if successful; otherwise, null or the result of parsing an array.
2492
- */
2493
- declare function parseJSONObjectFromText(text: string): Record<string, any> | null;
2494
- /**
2495
- * Extracts specific attributes (e.g., user, text, action) from a JSON-like string using regex.
2496
- * @param response - The cleaned string response to extract attributes from.
2497
- * @param attributesToExtract - An array of attribute names to extract.
2498
- * @returns An object containing the extracted attributes.
2499
- */
2500
- declare function extractAttributes(response: string, attributesToExtract?: string[]): {
2501
- [key: string]: string | undefined;
2502
- };
2503
- /**
2504
- * Normalizes a JSON-like string by correcting formatting issues:
2505
- * - Removes extra spaces after '{' and before '}'.
2506
- * - Wraps unquoted values in double quotes.
2507
- * - Converts single-quoted values to double-quoted.
2508
- * - Ensures consistency in key-value formatting.
2509
- * - Normalizes mixed adjacent quote pairs.
2510
- *
2511
- * This is useful for cleaning up improperly formatted JSON strings
2512
- * before parsing them into valid JSON.
2513
- *
2514
- * @param str - The JSON-like string to normalize.
2515
- * @returns A properly formatted JSON string.
2516
- */
2517
- declare const normalizeJsonString: (str: string) => string;
2518
- /**
2519
- * Cleans a JSON-like response string by removing unnecessary markers, line breaks, and extra whitespace.
2520
- * This is useful for handling improperly formatted JSON responses from external sources.
2521
- *
2522
- * @param response - The raw JSON-like string response to clean.
2523
- * @returns The cleaned string, ready for parsing or further processing.
2524
- */
2525
- declare function cleanJsonResponse(response: string): string;
2526
- 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.";
2527
- declare const parseActionResponseFromText: (text: string) => {
2528
- actions: ActionResponse;
2529
- };
2530
- /**
2531
- * Truncate text to fit within the character limit, ensuring it ends at a complete sentence.
2532
- */
2533
- declare function truncateToCompleteSentence(text: string, maxLength: number): string;
2534
-
2535
- declare const uuidSchema: z.ZodType<UUID>;
2536
- declare function validateUuid(value: unknown): UUID | null;
2537
- declare function stringToUuid(target: string | number): UUID;
2538
-
2539
- declare const envSchema: z.ZodObject<{
2540
- OPENAI_API_KEY: z.ZodString;
2541
- REDPILL_API_KEY: z.ZodString;
2542
- GROK_API_KEY: z.ZodString;
2543
- GROQ_API_KEY: z.ZodString;
2544
- OPENROUTER_API_KEY: z.ZodString;
2545
- GOOGLE_GENERATIVE_AI_API_KEY: z.ZodString;
2546
- ELEVENLABS_XI_API_KEY: z.ZodString;
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">>;
2547
1578
  }, "strip", z.ZodTypeAny, {
2548
- OPENAI_API_KEY?: string;
2549
- REDPILL_API_KEY?: string;
2550
- GROK_API_KEY?: string;
2551
- GROQ_API_KEY?: string;
2552
- OPENROUTER_API_KEY?: string;
2553
- GOOGLE_GENERATIVE_AI_API_KEY?: string;
2554
- ELEVENLABS_XI_API_KEY?: string;
1579
+ actions?: any[];
1580
+ providers?: any[];
1581
+ description?: string;
1582
+ name?: string;
1583
+ evaluators?: any[];
1584
+ services?: any[];
1585
+ clients?: any[];
2555
1586
  }, {
2556
- OPENAI_API_KEY?: string;
2557
- REDPILL_API_KEY?: string;
2558
- GROK_API_KEY?: string;
2559
- GROQ_API_KEY?: string;
2560
- OPENROUTER_API_KEY?: string;
2561
- GOOGLE_GENERATIVE_AI_API_KEY?: string;
2562
- ELEVENLABS_XI_API_KEY?: string;
1587
+ actions?: any[];
1588
+ providers?: any[];
1589
+ description?: string;
1590
+ name?: string;
1591
+ evaluators?: any[];
1592
+ services?: any[];
1593
+ clients?: any[];
2563
1594
  }>;
2564
- type EnvConfig = z.infer<typeof envSchema>;
2565
- declare function validateEnv(): EnvConfig;
2566
1595
  declare const CharacterSchema: z.ZodObject<{
2567
1596
  id: z.ZodOptional<z.ZodString>;
2568
1597
  name: z.ZodString;
2569
1598
  system: z.ZodOptional<z.ZodString>;
2570
- modelProvider: z.ZodNativeEnum<typeof ModelProviderName>;
2571
- modelEndpointOverride: z.ZodOptional<z.ZodString>;
2572
1599
  templates: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
2573
1600
  bio: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
2574
- lore: z.ZodArray<z.ZodString, "many">;
2575
1601
  messageExamples: z.ZodArray<z.ZodArray<z.ZodObject<{
2576
- user: z.ZodString;
1602
+ name: z.ZodString;
2577
1603
  content: z.ZodIntersection<z.ZodObject<{
2578
1604
  text: z.ZodString;
2579
1605
  action: z.ZodOptional<z.ZodString>;
@@ -2583,38 +1609,38 @@ declare const CharacterSchema: z.ZodObject<{
2583
1609
  attachments: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
2584
1610
  }, "strip", z.ZodTypeAny, {
2585
1611
  text?: string;
2586
- action?: string;
2587
1612
  source?: string;
2588
1613
  url?: string;
2589
1614
  inReplyTo?: string;
2590
1615
  attachments?: any[];
1616
+ action?: string;
2591
1617
  }, {
2592
1618
  text?: string;
2593
- action?: string;
2594
1619
  source?: string;
2595
1620
  url?: string;
2596
1621
  inReplyTo?: string;
2597
1622
  attachments?: any[];
1623
+ action?: string;
2598
1624
  }>, z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2599
1625
  }, "strip", z.ZodTypeAny, {
2600
- user?: string;
1626
+ name?: string;
2601
1627
  content?: {
2602
1628
  text?: string;
2603
- action?: string;
2604
1629
  source?: string;
2605
1630
  url?: string;
2606
1631
  inReplyTo?: string;
2607
1632
  attachments?: any[];
1633
+ action?: string;
2608
1634
  } & Record<string, unknown>;
2609
1635
  }, {
2610
- user?: string;
1636
+ name?: string;
2611
1637
  content?: {
2612
1638
  text?: string;
2613
- action?: string;
2614
1639
  source?: string;
2615
1640
  url?: string;
2616
1641
  inReplyTo?: string;
2617
1642
  attachments?: any[];
1643
+ action?: string;
2618
1644
  } & Record<string, unknown>;
2619
1645
  }>, "many">, "many">;
2620
1646
  postExamples: z.ZodArray<z.ZodString, "many">;
@@ -2650,16 +1676,16 @@ declare const CharacterSchema: z.ZodObject<{
2650
1676
  }, "strip", z.ZodTypeAny, {
2651
1677
  actions?: any[];
2652
1678
  providers?: any[];
2653
- name?: string;
2654
1679
  description?: string;
1680
+ name?: string;
2655
1681
  evaluators?: any[];
2656
1682
  services?: any[];
2657
1683
  clients?: any[];
2658
1684
  }, {
2659
1685
  actions?: any[];
2660
1686
  providers?: any[];
2661
- name?: string;
2662
1687
  description?: string;
1688
+ name?: string;
2663
1689
  evaluators?: any[];
2664
1690
  services?: any[];
2665
1691
  clients?: any[];
@@ -2684,90 +1710,50 @@ declare const CharacterSchema: z.ZodObject<{
2684
1710
  frequency_penalty: z.ZodOptional<z.ZodNumber>;
2685
1711
  presence_penalty: z.ZodOptional<z.ZodNumber>;
2686
1712
  }, "strip", z.ZodTypeAny, {
2687
- temperature?: number;
2688
1713
  maxInputTokens?: number;
2689
1714
  maxOutputTokens?: number;
1715
+ temperature?: number;
2690
1716
  frequency_penalty?: number;
2691
1717
  presence_penalty?: number;
2692
1718
  }, {
2693
- temperature?: number;
2694
1719
  maxInputTokens?: number;
2695
1720
  maxOutputTokens?: number;
1721
+ temperature?: number;
2696
1722
  frequency_penalty?: number;
2697
1723
  presence_penalty?: number;
2698
1724
  }>>;
2699
1725
  embeddingModel: z.ZodOptional<z.ZodString>;
2700
1726
  }, "strip", z.ZodTypeAny, {
2701
- model?: string;
2702
1727
  secrets?: Record<string, string>;
1728
+ model?: string;
2703
1729
  voice?: {
2704
1730
  url?: string;
2705
1731
  model?: string;
2706
1732
  };
2707
1733
  modelConfig?: {
2708
- temperature?: number;
2709
1734
  maxInputTokens?: number;
2710
1735
  maxOutputTokens?: number;
1736
+ temperature?: number;
2711
1737
  frequency_penalty?: number;
2712
1738
  presence_penalty?: number;
2713
1739
  };
2714
1740
  embeddingModel?: string;
2715
1741
  }, {
2716
- model?: string;
2717
1742
  secrets?: Record<string, string>;
1743
+ model?: string;
2718
1744
  voice?: {
2719
1745
  url?: string;
2720
1746
  model?: string;
2721
1747
  };
2722
1748
  modelConfig?: {
2723
- temperature?: number;
2724
1749
  maxInputTokens?: number;
2725
1750
  maxOutputTokens?: number;
1751
+ temperature?: number;
2726
1752
  frequency_penalty?: number;
2727
1753
  presence_penalty?: number;
2728
1754
  };
2729
1755
  embeddingModel?: string;
2730
1756
  }>>;
2731
- clientConfig: z.ZodOptional<z.ZodObject<{
2732
- discord: z.ZodOptional<z.ZodObject<{
2733
- shouldIgnoreBotMessages: z.ZodOptional<z.ZodBoolean>;
2734
- shouldIgnoreDirectMessages: z.ZodOptional<z.ZodBoolean>;
2735
- }, "strip", z.ZodTypeAny, {
2736
- shouldIgnoreBotMessages?: boolean;
2737
- shouldIgnoreDirectMessages?: boolean;
2738
- }, {
2739
- shouldIgnoreBotMessages?: boolean;
2740
- shouldIgnoreDirectMessages?: boolean;
2741
- }>>;
2742
- telegram: z.ZodOptional<z.ZodObject<{
2743
- shouldIgnoreBotMessages: z.ZodOptional<z.ZodBoolean>;
2744
- shouldIgnoreDirectMessages: z.ZodOptional<z.ZodBoolean>;
2745
- }, "strip", z.ZodTypeAny, {
2746
- shouldIgnoreBotMessages?: boolean;
2747
- shouldIgnoreDirectMessages?: boolean;
2748
- }, {
2749
- shouldIgnoreBotMessages?: boolean;
2750
- shouldIgnoreDirectMessages?: boolean;
2751
- }>>;
2752
- }, "strip", z.ZodTypeAny, {
2753
- discord?: {
2754
- shouldIgnoreBotMessages?: boolean;
2755
- shouldIgnoreDirectMessages?: boolean;
2756
- };
2757
- telegram?: {
2758
- shouldIgnoreBotMessages?: boolean;
2759
- shouldIgnoreDirectMessages?: boolean;
2760
- };
2761
- }, {
2762
- discord?: {
2763
- shouldIgnoreBotMessages?: boolean;
2764
- shouldIgnoreDirectMessages?: boolean;
2765
- };
2766
- telegram?: {
2767
- shouldIgnoreBotMessages?: boolean;
2768
- shouldIgnoreDirectMessages?: boolean;
2769
- };
2770
- }>>;
2771
1757
  style: z.ZodObject<{
2772
1758
  all: z.ZodArray<z.ZodString, "many">;
2773
1759
  chat: z.ZodArray<z.ZodString, "many">;
@@ -2781,33 +1767,9 @@ declare const CharacterSchema: z.ZodObject<{
2781
1767
  chat?: string[];
2782
1768
  post?: string[];
2783
1769
  }>;
2784
- twitterProfile: z.ZodOptional<z.ZodObject<{
2785
- username: z.ZodString;
2786
- screenName: z.ZodString;
2787
- bio: z.ZodString;
2788
- nicknames: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2789
- }, "strip", z.ZodTypeAny, {
2790
- bio?: string;
2791
- username?: string;
2792
- screenName?: string;
2793
- nicknames?: string[];
2794
- }, {
2795
- bio?: string;
2796
- username?: string;
2797
- screenName?: string;
2798
- nicknames?: string[];
2799
- }>>;
2800
- nft: z.ZodOptional<z.ZodObject<{
2801
- prompt: z.ZodOptional<z.ZodString>;
2802
- }, "strip", z.ZodTypeAny, {
2803
- prompt?: string;
2804
- }, {
2805
- prompt?: string;
2806
- }>>;
2807
- extends: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2808
1770
  }, "strip", z.ZodTypeAny, {
2809
- bio?: string | string[];
2810
- lore?: string[];
1771
+ id?: string;
1772
+ name?: string;
2811
1773
  knowledge?: (string | {
2812
1774
  shared?: boolean;
2813
1775
  path?: string;
@@ -2816,78 +1778,55 @@ declare const CharacterSchema: z.ZodObject<{
2816
1778
  directory?: string;
2817
1779
  })[];
2818
1780
  settings?: {
2819
- model?: string;
2820
1781
  secrets?: Record<string, string>;
1782
+ model?: string;
2821
1783
  voice?: {
2822
1784
  url?: string;
2823
1785
  model?: string;
2824
1786
  };
2825
1787
  modelConfig?: {
2826
- temperature?: number;
2827
1788
  maxInputTokens?: number;
2828
1789
  maxOutputTokens?: number;
1790
+ temperature?: number;
2829
1791
  frequency_penalty?: number;
2830
1792
  presence_penalty?: number;
2831
1793
  };
2832
1794
  embeddingModel?: string;
2833
1795
  };
2834
- modelProvider?: ModelProviderName;
2835
- name?: string;
2836
- id?: string;
2837
1796
  system?: string;
2838
- plugins?: string[] | {
2839
- actions?: any[];
2840
- providers?: any[];
2841
- name?: string;
2842
- description?: string;
2843
- evaluators?: any[];
2844
- services?: any[];
2845
- clients?: any[];
2846
- }[];
2847
- topics?: string[];
2848
- modelEndpointOverride?: string;
2849
1797
  templates?: Record<string, string>;
1798
+ bio?: string | string[];
2850
1799
  messageExamples?: {
2851
- user?: string;
1800
+ name?: string;
2852
1801
  content?: {
2853
1802
  text?: string;
2854
- action?: string;
2855
1803
  source?: string;
2856
1804
  url?: string;
2857
1805
  inReplyTo?: string;
2858
1806
  attachments?: any[];
1807
+ action?: string;
2859
1808
  } & Record<string, unknown>;
2860
1809
  }[][];
2861
1810
  postExamples?: string[];
1811
+ topics?: string[];
2862
1812
  adjectives?: string[];
2863
- clientConfig?: {
2864
- discord?: {
2865
- shouldIgnoreBotMessages?: boolean;
2866
- shouldIgnoreDirectMessages?: boolean;
2867
- };
2868
- telegram?: {
2869
- shouldIgnoreBotMessages?: boolean;
2870
- shouldIgnoreDirectMessages?: boolean;
2871
- };
2872
- };
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
+ }[];
2873
1822
  style?: {
2874
1823
  all?: string[];
2875
1824
  chat?: string[];
2876
1825
  post?: string[];
2877
1826
  };
2878
- twitterProfile?: {
2879
- bio?: string;
2880
- username?: string;
2881
- screenName?: string;
2882
- nicknames?: string[];
2883
- };
2884
- nft?: {
2885
- prompt?: string;
2886
- };
2887
- extends?: string[];
2888
1827
  }, {
2889
- bio?: string | string[];
2890
- lore?: string[];
1828
+ id?: string;
1829
+ name?: string;
2891
1830
  knowledge?: (string | {
2892
1831
  shared?: boolean;
2893
1832
  path?: string;
@@ -2896,200 +1835,534 @@ declare const CharacterSchema: z.ZodObject<{
2896
1835
  directory?: string;
2897
1836
  })[];
2898
1837
  settings?: {
2899
- model?: string;
2900
1838
  secrets?: Record<string, string>;
1839
+ model?: string;
2901
1840
  voice?: {
2902
1841
  url?: string;
2903
1842
  model?: string;
2904
1843
  };
2905
1844
  modelConfig?: {
2906
- temperature?: number;
2907
1845
  maxInputTokens?: number;
2908
1846
  maxOutputTokens?: number;
1847
+ temperature?: number;
2909
1848
  frequency_penalty?: number;
2910
1849
  presence_penalty?: number;
2911
1850
  };
2912
1851
  embeddingModel?: string;
2913
1852
  };
2914
- modelProvider?: ModelProviderName;
2915
- name?: string;
2916
- id?: string;
2917
1853
  system?: string;
2918
- plugins?: string[] | {
2919
- actions?: any[];
2920
- providers?: any[];
2921
- name?: string;
2922
- description?: string;
2923
- evaluators?: any[];
2924
- services?: any[];
2925
- clients?: any[];
2926
- }[];
2927
- topics?: string[];
2928
- modelEndpointOverride?: string;
2929
1854
  templates?: Record<string, string>;
1855
+ bio?: string | string[];
2930
1856
  messageExamples?: {
2931
- user?: string;
1857
+ name?: string;
2932
1858
  content?: {
2933
1859
  text?: string;
2934
- action?: string;
2935
1860
  source?: string;
2936
1861
  url?: string;
2937
1862
  inReplyTo?: string;
2938
1863
  attachments?: any[];
1864
+ action?: string;
2939
1865
  } & Record<string, unknown>;
2940
1866
  }[][];
2941
1867
  postExamples?: string[];
1868
+ topics?: string[];
2942
1869
  adjectives?: string[];
2943
- clientConfig?: {
2944
- discord?: {
2945
- shouldIgnoreBotMessages?: boolean;
2946
- shouldIgnoreDirectMessages?: boolean;
2947
- };
2948
- telegram?: {
2949
- shouldIgnoreBotMessages?: boolean;
2950
- shouldIgnoreDirectMessages?: boolean;
2951
- };
2952
- };
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
+ }[];
2953
1879
  style?: {
2954
1880
  all?: string[];
2955
1881
  chat?: string[];
2956
1882
  post?: string[];
2957
1883
  };
2958
- twitterProfile?: {
2959
- bio?: string;
2960
- username?: string;
2961
- screenName?: string;
2962
- nicknames?: string[];
2963
- };
2964
- nft?: {
2965
- prompt?: string;
2966
- };
2967
- extends?: string[];
2968
1884
  }>;
2969
1885
  type CharacterConfig = z.infer<typeof CharacterSchema>;
2970
1886
  declare function validateCharacterConfig(json: unknown): CharacterConfig;
2971
1887
 
2972
- interface ICacheAdapter {
2973
- get(key: string): Promise<string | undefined>;
2974
- set(key: string, value: string): Promise<void>;
2975
- delete(key: string): Promise<void>;
2976
- }
2977
- declare class MemoryCacheAdapter implements ICacheAdapter {
2978
- data: Map<string, string>;
2979
- constructor(initalData?: Map<string, string>);
2980
- get(key: string): Promise<string | undefined>;
2981
- set(key: string, value: string): Promise<void>;
2982
- delete(key: string): Promise<void>;
2983
- }
2984
- declare class FsCacheAdapter implements ICacheAdapter {
2985
- private dataDir;
2986
- constructor(dataDir: string);
2987
- get(key: string): Promise<string | undefined>;
2988
- set(key: string, value: string): Promise<void>;
2989
- delete(key: string): Promise<void>;
2990
- }
2991
- declare class DbCacheAdapter implements ICacheAdapter {
2992
- private db;
2993
- private agentId;
2994
- constructor(db: IDatabaseCacheAdapter, agentId: UUID);
2995
- get(key: string): Promise<string | undefined>;
2996
- set(key: string, value: string): Promise<void>;
2997
- delete(key: string): Promise<void>;
2998
- }
2999
- declare class CacheManager<CacheAdapter extends ICacheAdapter = ICacheAdapter> implements ICacheManager {
3000
- adapter: CacheAdapter;
3001
- constructor(adapter: CacheAdapter);
3002
- get<T = unknown>(key: string): Promise<T | undefined>;
3003
- set<T>(key: string, value: T, opts?: CacheOptions): Promise<void>;
3004
- delete(key: string): Promise<void>;
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;
3005
2004
  }
3006
2005
 
3007
- declare function get(runtime: AgentRuntime, message: Memory): Promise<KnowledgeItem[]>;
3008
- declare function set(runtime: AgentRuntime, item: KnowledgeItem, chunkSize?: number, bleed?: number): Promise<void>;
3009
- declare function preprocess(content: string): string;
3010
- declare const _default: {
3011
- get: typeof get;
3012
- set: typeof set;
3013
- preprocess: typeof preprocess;
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;
3014
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>;
3015
2196
 
3016
2197
  /**
3017
- * Manage knowledge in the database.
2198
+ * Represents the runtime environment for an agent, handling message processing,
2199
+ * action registration, and interaction with external services like OpenAI and Supabase.
3018
2200
  */
3019
- declare class RAGKnowledgeManager implements IRAGKnowledgeManager {
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
+ });
3020
2240
  /**
3021
- * The AgentRuntime instance associated with this manager.
2241
+ * Registers a plugin with the runtime and initializes its components
2242
+ * @param plugin The plugin to register
3022
2243
  */
3023
- runtime: IAgentRuntime;
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;
3024
2259
  /**
3025
- * The name of the database table this manager operates on.
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.
3026
2262
  */
3027
- tableName: string;
2263
+ getConversationLength(): number;
2264
+ registerDatabaseAdapter(adapter: IDatabaseAdapter): void;
2265
+ getDatabaseAdapters(): IDatabaseAdapter[];
2266
+ getDatabaseAdapter(): IDatabaseAdapter;
3028
2267
  /**
3029
- * The root directory where RAG knowledge files are located (internal)
2268
+ * Register a provider for the agent to use.
2269
+ * @param provider The provider to register.
3030
2270
  */
3031
- knowledgeRoot: string;
2271
+ registerProvider(provider: Provider): void;
3032
2272
  /**
3033
- * Constructs a new KnowledgeManager instance.
3034
- * @param opts Options for the manager.
3035
- * @param opts.tableName The name of the table this manager will operate on.
3036
- * @param opts.runtime The AgentRuntime instance associated with this manager.
2273
+ * Register an action for the agent to perform.
2274
+ * @param action The action to register.
3037
2275
  */
3038
- constructor(opts: {
3039
- tableName: string;
3040
- runtime: IAgentRuntime;
3041
- knowledgeRoot: string;
3042
- });
3043
- private readonly defaultRAGMatchThreshold;
3044
- private readonly defaultRAGMatchCount;
2276
+ registerAction(action: Action): void;
3045
2277
  /**
3046
- * Common English stop words to filter out from query analysis
2278
+ * Register an evaluator to assess and guide the agent's responses.
2279
+ * @param evaluator The evaluator to register.
3047
2280
  */
3048
- private readonly stopWords;
2281
+ registerEvaluator(evaluator: Evaluator): void;
3049
2282
  /**
3050
- * Filters out stop words and returns meaningful terms
2283
+ * Register a context provider to provide context for message generation.
2284
+ * @param provider The context provider to register.
3051
2285
  */
3052
- private getQueryTerms;
2286
+ registerContextProvider(provider: Provider): void;
3053
2287
  /**
3054
- * Preprocesses text content for better RAG performance.
3055
- * @param content The text content to preprocess.
3056
- * @returns The preprocessed text.
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.
3057
2293
  */
3058
- private preprocess;
3059
- private hasProximityMatch;
3060
- getKnowledge(params: {
3061
- query?: string;
3062
- id?: UUID;
3063
- conversationContext?: string;
3064
- limit?: number;
3065
- agentId?: UUID;
3066
- }): Promise<RAGKnowledgeItem[]>;
3067
- createKnowledge(item: RAGKnowledgeItem): Promise<void>;
3068
- searchKnowledge(params: {
3069
- agentId: UUID;
3070
- embedding: Float32Array | number[];
3071
- match_threshold?: number;
3072
- match_count?: number;
3073
- searchText?: string;
3074
- }): Promise<RAGKnowledgeItem[]>;
3075
- removeKnowledge(id: UUID): Promise<void>;
3076
- clearKnowledge(shared?: boolean): Promise<void>;
3077
- /**
3078
- * Lists all knowledge entries for an agent without semantic search or reranking.
3079
- * Used primarily for administrative tasks like cleanup.
3080
- *
3081
- * @param agentId The agent ID to fetch knowledge entries for
3082
- * @returns Array of RAGKnowledgeItem entries
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.
3083
2302
  */
3084
- listAllKnowledge(agentId: UUID): Promise<RAGKnowledgeItem[]>;
3085
- cleanupDeletedKnowledgeFiles(): Promise<void>;
3086
- generateScopedId(path: string, isShared: boolean): UUID;
3087
- processFile(file: {
3088
- path: string;
3089
- content: string;
3090
- type: "pdf" | "md" | "txt";
3091
- isShared?: boolean;
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;
3092
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;
3093
2349
  }
3094
2350
 
3095
- export { type Account, type Action, type ActionExample, type ActionResponse, ActionTimelineType, type Actor, type Adapter, AgentRuntime, CacheKeyPrefix, CacheManager, type CacheOptions, CacheStore, type Character, type CharacterConfig, CharacterSchema, type ChunkRow, type Client, type ClientInstance, type Content, type ConversationExample, type DataIrysFetchedFromGQL, DatabaseAdapter, DbCacheAdapter, type DirectoryItem, type EmbeddingConfig, type EmbeddingModelSettings, EmbeddingProvider, type EmbeddingProviderType, type EnvConfig, type EvaluationExample, type Evaluator, FsCacheAdapter, type GenerationOptions, type Goal, GoalStatus, type GraphQLTag, type Handler, type HandlerCallback, type IAgentConfig, type IAgentRuntime, type IAwsS3Service, type IBrowserService, type ICacheAdapter, type ICacheManager, type IDatabaseAdapter, type IDatabaseCacheAdapter, type IImageDescriptionService, type IIrysService, type IMemoryManager, type IPdfService, type IRAGKnowledgeManager, type ISlackService, type ISpeechService, type ITeeLogService, type ITextGenerationService, type ITranscriptionService, type IVideoService, type ImageModelSettings, IrysDataType, IrysMessageType, type IrysTimestamp, type KnowledgeItem, KnowledgeScope, LoggingLevel, type Media, type Memory, MemoryCacheAdapter, MemoryManager, type MessageExample, type Model, ModelClass, type ModelConfiguration, ModelProviderName, type ModelSettings$1 as ModelSettings, type Models, type Objective, type Participant, type Plugin, type Provider, type RAGKnowledgeItem, RAGKnowledgeManager, type Relationship, type Room, Service, ServiceType, type State, type TelemetrySettings, type TemplateType, TokenizerType, TranscriptionProvider, type TwitterSpaceDecisionOptions, type UUID, type UploadIrysResult, type Validator, addHeader, booleanFooter, cleanJsonResponse, composeActionExamples, composeContext, composeRandomUser, configureSettings, createGoal, createRelationship, elizaLogger, embed, envSchema, evaluationTemplate, extractAttributes, findNearestEnvFile, formatActionNames, formatActions, formatActors, formatEvaluatorExampleDescriptions, formatEvaluatorExamples, formatEvaluatorNames, formatEvaluators, formatGoalsAsString, formatMessages, formatPosts, formatRelationships, formatTimestamp, generateCaption, generateImage, generateMessageResponse, generateObject, generateObjectArray, generateObjectDeprecated, generateShouldRespond, generateText, generateTextArray, generateTrueOrFalse, generateTweetActions, getActorDetails, getEmbeddingConfig, getEmbeddingModelSettings, getEmbeddingType, getEmbeddingZeroVector, getEndpoint, getEnvVariable, getGoals, getImageModelSettings, getModelSettings, getProviders, getRelationship, getRelationships, handleProvider, hasEnvVariable, _default as knowledge, loadEnvConfig, messageCompletionFooter, models, normalizeJsonString, parseActionResponseFromText, parseBooleanFromText, parseJSONObjectFromText, parseJsonArrayFromText, parseShouldRespondFromText, postActionResponseFooter, settings, shouldRespondFooter, splitChunks, splitText, stringArrayFooter, stringToUuid, trimTokens, truncateToCompleteSentence, updateGoal, uuidSchema, validateCharacterConfig, validateEnv, validateUuid };
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 };