@elizaos/core 0.1.7-alpha.1
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 +2480 -0
- package/dist/index.js +4654 -0
- package/dist/index.js.map +1 -0
- package/package.json +79 -0
- package/tsup.config.ts +22 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,2480 @@
|
|
|
1
|
+
import { Readable } from 'stream';
|
|
2
|
+
import { GenerateObjectResult } from 'ai';
|
|
3
|
+
import { TiktokenModel } from 'js-tiktoken';
|
|
4
|
+
import { ZodSchema, z } from 'zod';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Represents a UUID string in the format "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
|
8
|
+
*/
|
|
9
|
+
type UUID = `${string}-${string}-${string}-${string}-${string}`;
|
|
10
|
+
/**
|
|
11
|
+
* Represents the content of a message or communication
|
|
12
|
+
*/
|
|
13
|
+
interface Content {
|
|
14
|
+
/** The main text content */
|
|
15
|
+
text: string;
|
|
16
|
+
/** Optional action associated with the message */
|
|
17
|
+
action?: string;
|
|
18
|
+
/** Optional source/origin of the content */
|
|
19
|
+
source?: string;
|
|
20
|
+
/** URL of the original message/post (e.g. tweet URL, Discord message link) */
|
|
21
|
+
url?: string;
|
|
22
|
+
/** UUID of parent message if this is a reply/thread */
|
|
23
|
+
inReplyTo?: UUID;
|
|
24
|
+
/** Array of media attachments */
|
|
25
|
+
attachments?: Media[];
|
|
26
|
+
/** Additional dynamic properties */
|
|
27
|
+
[key: string]: unknown;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Example content with associated user for demonstration purposes
|
|
31
|
+
*/
|
|
32
|
+
interface ActionExample {
|
|
33
|
+
/** User associated with the example */
|
|
34
|
+
user: string;
|
|
35
|
+
/** Content of the example */
|
|
36
|
+
content: Content;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Example conversation content with user ID
|
|
40
|
+
*/
|
|
41
|
+
interface ConversationExample {
|
|
42
|
+
/** UUID of user in conversation */
|
|
43
|
+
userId: UUID;
|
|
44
|
+
/** Content of the conversation */
|
|
45
|
+
content: Content;
|
|
46
|
+
}
|
|
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
|
+
/**
|
|
68
|
+
* Represents a single objective within a goal
|
|
69
|
+
*/
|
|
70
|
+
interface Objective {
|
|
71
|
+
/** Optional unique identifier */
|
|
72
|
+
id?: string;
|
|
73
|
+
/** Description of what needs to be achieved */
|
|
74
|
+
description: string;
|
|
75
|
+
/** Whether objective is completed */
|
|
76
|
+
completed: boolean;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Status enum for goals
|
|
80
|
+
*/
|
|
81
|
+
declare enum GoalStatus {
|
|
82
|
+
DONE = "DONE",
|
|
83
|
+
FAILED = "FAILED",
|
|
84
|
+
IN_PROGRESS = "IN_PROGRESS"
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Represents a high-level goal composed of objectives
|
|
88
|
+
*/
|
|
89
|
+
interface Goal {
|
|
90
|
+
/** Optional unique identifier */
|
|
91
|
+
id?: UUID;
|
|
92
|
+
/** Room ID where goal exists */
|
|
93
|
+
roomId: UUID;
|
|
94
|
+
/** User ID of goal owner */
|
|
95
|
+
userId: UUID;
|
|
96
|
+
/** Name/title of the goal */
|
|
97
|
+
name: string;
|
|
98
|
+
/** Current status */
|
|
99
|
+
status: GoalStatus;
|
|
100
|
+
/** Component objectives */
|
|
101
|
+
objectives: Objective[];
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Model size/type classification
|
|
105
|
+
*/
|
|
106
|
+
declare enum ModelClass {
|
|
107
|
+
SMALL = "small",
|
|
108
|
+
MEDIUM = "medium",
|
|
109
|
+
LARGE = "large",
|
|
110
|
+
EMBEDDING = "embedding",
|
|
111
|
+
IMAGE = "image"
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Configuration for an AI model
|
|
115
|
+
*/
|
|
116
|
+
type Model = {
|
|
117
|
+
/** Optional API endpoint */
|
|
118
|
+
endpoint?: string;
|
|
119
|
+
/** Model settings */
|
|
120
|
+
settings: {
|
|
121
|
+
/** Maximum input tokens */
|
|
122
|
+
maxInputTokens: number;
|
|
123
|
+
/** Maximum output tokens */
|
|
124
|
+
maxOutputTokens: number;
|
|
125
|
+
/** Optional frequency penalty */
|
|
126
|
+
frequency_penalty?: number;
|
|
127
|
+
/** Optional presence penalty */
|
|
128
|
+
presence_penalty?: number;
|
|
129
|
+
/** Optional repetition penalty */
|
|
130
|
+
repetition_penalty?: number;
|
|
131
|
+
/** Stop sequences */
|
|
132
|
+
stop: string[];
|
|
133
|
+
/** Temperature setting */
|
|
134
|
+
temperature: number;
|
|
135
|
+
};
|
|
136
|
+
/** Optional image generation settings */
|
|
137
|
+
imageSettings?: {
|
|
138
|
+
steps?: number;
|
|
139
|
+
};
|
|
140
|
+
/** Model names by size class */
|
|
141
|
+
model: {
|
|
142
|
+
[ModelClass.SMALL]: string;
|
|
143
|
+
[ModelClass.MEDIUM]: string;
|
|
144
|
+
[ModelClass.LARGE]: string;
|
|
145
|
+
[ModelClass.EMBEDDING]?: string;
|
|
146
|
+
[ModelClass.IMAGE]?: string;
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
/**
|
|
150
|
+
* Model configurations by provider
|
|
151
|
+
*/
|
|
152
|
+
type Models = {
|
|
153
|
+
[ModelProviderName.OPENAI]: Model;
|
|
154
|
+
[ModelProviderName.ETERNALAI]: Model;
|
|
155
|
+
[ModelProviderName.ANTHROPIC]: Model;
|
|
156
|
+
[ModelProviderName.GROK]: Model;
|
|
157
|
+
[ModelProviderName.GROQ]: Model;
|
|
158
|
+
[ModelProviderName.LLAMACLOUD]: Model;
|
|
159
|
+
[ModelProviderName.TOGETHER]: Model;
|
|
160
|
+
[ModelProviderName.LLAMALOCAL]: Model;
|
|
161
|
+
[ModelProviderName.GOOGLE]: Model;
|
|
162
|
+
[ModelProviderName.CLAUDE_VERTEX]: Model;
|
|
163
|
+
[ModelProviderName.REDPILL]: Model;
|
|
164
|
+
[ModelProviderName.OPENROUTER]: Model;
|
|
165
|
+
[ModelProviderName.OLLAMA]: Model;
|
|
166
|
+
[ModelProviderName.HEURIST]: Model;
|
|
167
|
+
[ModelProviderName.GALADRIEL]: Model;
|
|
168
|
+
[ModelProviderName.FAL]: Model;
|
|
169
|
+
[ModelProviderName.GAIANET]: Model;
|
|
170
|
+
[ModelProviderName.ALI_BAILIAN]: Model;
|
|
171
|
+
[ModelProviderName.VOLENGINE]: Model;
|
|
172
|
+
[ModelProviderName.NANOGPT]: Model;
|
|
173
|
+
[ModelProviderName.HYPERBOLIC]: Model;
|
|
174
|
+
[ModelProviderName.VENICE]: Model;
|
|
175
|
+
[ModelProviderName.AKASH_CHAT_API]: Model;
|
|
176
|
+
};
|
|
177
|
+
/**
|
|
178
|
+
* Available model providers
|
|
179
|
+
*/
|
|
180
|
+
declare enum ModelProviderName {
|
|
181
|
+
OPENAI = "openai",
|
|
182
|
+
ETERNALAI = "eternalai",
|
|
183
|
+
ANTHROPIC = "anthropic",
|
|
184
|
+
GROK = "grok",
|
|
185
|
+
GROQ = "groq",
|
|
186
|
+
LLAMACLOUD = "llama_cloud",
|
|
187
|
+
TOGETHER = "together",
|
|
188
|
+
LLAMALOCAL = "llama_local",
|
|
189
|
+
GOOGLE = "google",
|
|
190
|
+
CLAUDE_VERTEX = "claude_vertex",
|
|
191
|
+
REDPILL = "redpill",
|
|
192
|
+
OPENROUTER = "openrouter",
|
|
193
|
+
OLLAMA = "ollama",
|
|
194
|
+
HEURIST = "heurist",
|
|
195
|
+
GALADRIEL = "galadriel",
|
|
196
|
+
FAL = "falai",
|
|
197
|
+
GAIANET = "gaianet",
|
|
198
|
+
ALI_BAILIAN = "ali_bailian",
|
|
199
|
+
VOLENGINE = "volengine",
|
|
200
|
+
NANOGPT = "nanogpt",
|
|
201
|
+
HYPERBOLIC = "hyperbolic",
|
|
202
|
+
VENICE = "venice",
|
|
203
|
+
AKASH_CHAT_API = "akash_chat_api"
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Represents the current state/context of a conversation
|
|
207
|
+
*/
|
|
208
|
+
interface State {
|
|
209
|
+
/** ID of user who sent current message */
|
|
210
|
+
userId?: UUID;
|
|
211
|
+
/** ID of agent in conversation */
|
|
212
|
+
agentId?: UUID;
|
|
213
|
+
/** Agent's biography */
|
|
214
|
+
bio: string;
|
|
215
|
+
/** Agent's background lore */
|
|
216
|
+
lore: string;
|
|
217
|
+
/** Message handling directions */
|
|
218
|
+
messageDirections: string;
|
|
219
|
+
/** Post handling directions */
|
|
220
|
+
postDirections: string;
|
|
221
|
+
/** Current room/conversation ID */
|
|
222
|
+
roomId: UUID;
|
|
223
|
+
/** Optional agent name */
|
|
224
|
+
agentName?: string;
|
|
225
|
+
/** Optional message sender name */
|
|
226
|
+
senderName?: string;
|
|
227
|
+
/** String representation of conversation actors */
|
|
228
|
+
actors: string;
|
|
229
|
+
/** Optional array of actor objects */
|
|
230
|
+
actorsData?: Actor[];
|
|
231
|
+
/** Optional string representation of goals */
|
|
232
|
+
goals?: string;
|
|
233
|
+
/** Optional array of goal objects */
|
|
234
|
+
goalsData?: Goal[];
|
|
235
|
+
/** Recent message history as string */
|
|
236
|
+
recentMessages: string;
|
|
237
|
+
/** Recent message objects */
|
|
238
|
+
recentMessagesData: Memory[];
|
|
239
|
+
/** Optional valid action names */
|
|
240
|
+
actionNames?: string;
|
|
241
|
+
/** Optional action descriptions */
|
|
242
|
+
actions?: string;
|
|
243
|
+
/** Optional action objects */
|
|
244
|
+
actionsData?: Action[];
|
|
245
|
+
/** Optional action examples */
|
|
246
|
+
actionExamples?: string;
|
|
247
|
+
/** Optional provider descriptions */
|
|
248
|
+
providers?: string;
|
|
249
|
+
/** Optional response content */
|
|
250
|
+
responseData?: Content;
|
|
251
|
+
/** Optional recent interaction objects */
|
|
252
|
+
recentInteractionsData?: Memory[];
|
|
253
|
+
/** Optional recent interactions string */
|
|
254
|
+
recentInteractions?: string;
|
|
255
|
+
/** Optional formatted conversation */
|
|
256
|
+
formattedConversation?: string;
|
|
257
|
+
/** Optional formatted knowledge */
|
|
258
|
+
knowledge?: string;
|
|
259
|
+
/** Optional knowledge data */
|
|
260
|
+
knowledgeData?: KnowledgeItem[];
|
|
261
|
+
/** Additional dynamic properties */
|
|
262
|
+
[key: string]: unknown;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Represents a stored memory/message
|
|
266
|
+
*/
|
|
267
|
+
interface Memory {
|
|
268
|
+
/** Optional unique identifier */
|
|
269
|
+
id?: UUID;
|
|
270
|
+
/** Associated user ID */
|
|
271
|
+
userId: UUID;
|
|
272
|
+
/** Associated agent ID */
|
|
273
|
+
agentId: UUID;
|
|
274
|
+
/** Optional creation timestamp */
|
|
275
|
+
createdAt?: number;
|
|
276
|
+
/** Memory content */
|
|
277
|
+
content: Content;
|
|
278
|
+
/** Optional embedding vector */
|
|
279
|
+
embedding?: number[];
|
|
280
|
+
/** Associated room ID */
|
|
281
|
+
roomId: UUID;
|
|
282
|
+
/** Whether memory is unique */
|
|
283
|
+
unique?: boolean;
|
|
284
|
+
/** Embedding similarity score */
|
|
285
|
+
similarity?: number;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Example message for demonstration
|
|
289
|
+
*/
|
|
290
|
+
interface MessageExample {
|
|
291
|
+
/** Associated user */
|
|
292
|
+
user: string;
|
|
293
|
+
/** Message content */
|
|
294
|
+
content: Content;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Handler function type for processing messages
|
|
298
|
+
*/
|
|
299
|
+
type Handler = (runtime: IAgentRuntime, message: Memory, state?: State, options?: {
|
|
300
|
+
[key: string]: unknown;
|
|
301
|
+
}, callback?: HandlerCallback) => Promise<unknown>;
|
|
302
|
+
/**
|
|
303
|
+
* Callback function type for handlers
|
|
304
|
+
*/
|
|
305
|
+
type HandlerCallback = (response: Content, files?: any) => Promise<Memory[]>;
|
|
306
|
+
/**
|
|
307
|
+
* Validator function type for actions/evaluators
|
|
308
|
+
*/
|
|
309
|
+
type Validator = (runtime: IAgentRuntime, message: Memory, state?: State) => Promise<boolean>;
|
|
310
|
+
/**
|
|
311
|
+
* Represents an action the agent can perform
|
|
312
|
+
*/
|
|
313
|
+
interface Action {
|
|
314
|
+
/** Similar action descriptions */
|
|
315
|
+
similes: string[];
|
|
316
|
+
/** Detailed description */
|
|
317
|
+
description: string;
|
|
318
|
+
/** Example usages */
|
|
319
|
+
examples: ActionExample[][];
|
|
320
|
+
/** Handler function */
|
|
321
|
+
handler: Handler;
|
|
322
|
+
/** Action name */
|
|
323
|
+
name: string;
|
|
324
|
+
/** Validation function */
|
|
325
|
+
validate: Validator;
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Example for evaluating agent behavior
|
|
329
|
+
*/
|
|
330
|
+
interface EvaluationExample {
|
|
331
|
+
/** Evaluation context */
|
|
332
|
+
context: string;
|
|
333
|
+
/** Example messages */
|
|
334
|
+
messages: Array<ActionExample>;
|
|
335
|
+
/** Expected outcome */
|
|
336
|
+
outcome: string;
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Evaluator for assessing agent responses
|
|
340
|
+
*/
|
|
341
|
+
interface Evaluator {
|
|
342
|
+
/** Whether to always run */
|
|
343
|
+
alwaysRun?: boolean;
|
|
344
|
+
/** Detailed description */
|
|
345
|
+
description: string;
|
|
346
|
+
/** Similar evaluator descriptions */
|
|
347
|
+
similes: string[];
|
|
348
|
+
/** Example evaluations */
|
|
349
|
+
examples: EvaluationExample[];
|
|
350
|
+
/** Handler function */
|
|
351
|
+
handler: Handler;
|
|
352
|
+
/** Evaluator name */
|
|
353
|
+
name: string;
|
|
354
|
+
/** Validation function */
|
|
355
|
+
validate: Validator;
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Provider for external data/services
|
|
359
|
+
*/
|
|
360
|
+
interface Provider {
|
|
361
|
+
/** Data retrieval function */
|
|
362
|
+
get: (runtime: IAgentRuntime, message: Memory, state?: State) => Promise<any>;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Represents a relationship between users
|
|
366
|
+
*/
|
|
367
|
+
interface Relationship {
|
|
368
|
+
/** Unique identifier */
|
|
369
|
+
id: UUID;
|
|
370
|
+
/** First user ID */
|
|
371
|
+
userA: UUID;
|
|
372
|
+
/** Second user ID */
|
|
373
|
+
userB: UUID;
|
|
374
|
+
/** Primary user ID */
|
|
375
|
+
userId: UUID;
|
|
376
|
+
/** Associated room ID */
|
|
377
|
+
roomId: UUID;
|
|
378
|
+
/** Relationship status */
|
|
379
|
+
status: string;
|
|
380
|
+
/** Optional creation timestamp */
|
|
381
|
+
createdAt?: string;
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Represents a user account
|
|
385
|
+
*/
|
|
386
|
+
interface Account {
|
|
387
|
+
/** Unique identifier */
|
|
388
|
+
id: UUID;
|
|
389
|
+
/** Display name */
|
|
390
|
+
name: string;
|
|
391
|
+
/** Username */
|
|
392
|
+
username: string;
|
|
393
|
+
/** Optional additional details */
|
|
394
|
+
details?: {
|
|
395
|
+
[key: string]: any;
|
|
396
|
+
};
|
|
397
|
+
/** Optional email */
|
|
398
|
+
email?: string;
|
|
399
|
+
/** Optional avatar URL */
|
|
400
|
+
avatarUrl?: string;
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Room participant with account details
|
|
404
|
+
*/
|
|
405
|
+
interface Participant {
|
|
406
|
+
/** Unique identifier */
|
|
407
|
+
id: UUID;
|
|
408
|
+
/** Associated account */
|
|
409
|
+
account: Account;
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Represents a conversation room
|
|
413
|
+
*/
|
|
414
|
+
interface Room {
|
|
415
|
+
/** Unique identifier */
|
|
416
|
+
id: UUID;
|
|
417
|
+
/** Room participants */
|
|
418
|
+
participants: Participant[];
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Represents a media attachment
|
|
422
|
+
*/
|
|
423
|
+
type Media = {
|
|
424
|
+
/** Unique identifier */
|
|
425
|
+
id: string;
|
|
426
|
+
/** Media URL */
|
|
427
|
+
url: string;
|
|
428
|
+
/** Media title */
|
|
429
|
+
title: string;
|
|
430
|
+
/** Media source */
|
|
431
|
+
source: string;
|
|
432
|
+
/** Media description */
|
|
433
|
+
description: string;
|
|
434
|
+
/** Text content */
|
|
435
|
+
text: string;
|
|
436
|
+
/** Content type */
|
|
437
|
+
contentType?: string;
|
|
438
|
+
};
|
|
439
|
+
/**
|
|
440
|
+
* Client interface for platform connections
|
|
441
|
+
*/
|
|
442
|
+
type Client = {
|
|
443
|
+
/** Start client connection */
|
|
444
|
+
start: (runtime: IAgentRuntime) => Promise<unknown>;
|
|
445
|
+
/** Stop client connection */
|
|
446
|
+
stop: (runtime: IAgentRuntime) => Promise<unknown>;
|
|
447
|
+
};
|
|
448
|
+
/**
|
|
449
|
+
* Plugin for extending agent functionality
|
|
450
|
+
*/
|
|
451
|
+
type Plugin = {
|
|
452
|
+
/** Plugin name */
|
|
453
|
+
name: string;
|
|
454
|
+
/** Plugin description */
|
|
455
|
+
description: string;
|
|
456
|
+
/** Optional actions */
|
|
457
|
+
actions?: Action[];
|
|
458
|
+
/** Optional providers */
|
|
459
|
+
providers?: Provider[];
|
|
460
|
+
/** Optional evaluators */
|
|
461
|
+
evaluators?: Evaluator[];
|
|
462
|
+
/** Optional services */
|
|
463
|
+
services?: Service[];
|
|
464
|
+
/** Optional clients */
|
|
465
|
+
clients?: Client[];
|
|
466
|
+
};
|
|
467
|
+
/**
|
|
468
|
+
* Available client platforms
|
|
469
|
+
*/
|
|
470
|
+
declare enum Clients {
|
|
471
|
+
DISCORD = "discord",
|
|
472
|
+
DIRECT = "direct",
|
|
473
|
+
TWITTER = "twitter",
|
|
474
|
+
TELEGRAM = "telegram",
|
|
475
|
+
FARCASTER = "farcaster",
|
|
476
|
+
LENS = "lens",
|
|
477
|
+
AUTO = "auto",
|
|
478
|
+
SLACK = "slack"
|
|
479
|
+
}
|
|
480
|
+
interface IAgentConfig {
|
|
481
|
+
[key: string]: string;
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Configuration for an agent character
|
|
485
|
+
*/
|
|
486
|
+
type Character = {
|
|
487
|
+
/** Optional unique identifier */
|
|
488
|
+
id?: UUID;
|
|
489
|
+
/** Character name */
|
|
490
|
+
name: string;
|
|
491
|
+
/** Optional username */
|
|
492
|
+
username?: string;
|
|
493
|
+
/** Optional system prompt */
|
|
494
|
+
system?: string;
|
|
495
|
+
/** Model provider to use */
|
|
496
|
+
modelProvider: ModelProviderName;
|
|
497
|
+
/** Image model provider to use, if different from modelProvider */
|
|
498
|
+
imageModelProvider?: ModelProviderName;
|
|
499
|
+
/** Optional model endpoint override */
|
|
500
|
+
modelEndpointOverride?: string;
|
|
501
|
+
/** Optional prompt templates */
|
|
502
|
+
templates?: {
|
|
503
|
+
goalsTemplate?: string;
|
|
504
|
+
factsTemplate?: string;
|
|
505
|
+
messageHandlerTemplate?: string;
|
|
506
|
+
shouldRespondTemplate?: string;
|
|
507
|
+
continueMessageHandlerTemplate?: string;
|
|
508
|
+
evaluationTemplate?: string;
|
|
509
|
+
twitterSearchTemplate?: string;
|
|
510
|
+
twitterActionTemplate?: string;
|
|
511
|
+
twitterPostTemplate?: string;
|
|
512
|
+
twitterMessageHandlerTemplate?: string;
|
|
513
|
+
twitterShouldRespondTemplate?: string;
|
|
514
|
+
farcasterPostTemplate?: string;
|
|
515
|
+
lensPostTemplate?: string;
|
|
516
|
+
farcasterMessageHandlerTemplate?: string;
|
|
517
|
+
lensMessageHandlerTemplate?: string;
|
|
518
|
+
farcasterShouldRespondTemplate?: string;
|
|
519
|
+
lensShouldRespondTemplate?: string;
|
|
520
|
+
telegramMessageHandlerTemplate?: string;
|
|
521
|
+
telegramShouldRespondTemplate?: string;
|
|
522
|
+
discordVoiceHandlerTemplate?: string;
|
|
523
|
+
discordShouldRespondTemplate?: string;
|
|
524
|
+
discordMessageHandlerTemplate?: string;
|
|
525
|
+
slackMessageHandlerTemplate?: string;
|
|
526
|
+
slackShouldRespondTemplate?: string;
|
|
527
|
+
};
|
|
528
|
+
/** Character biography */
|
|
529
|
+
bio: string | string[];
|
|
530
|
+
/** Character background lore */
|
|
531
|
+
lore: string[];
|
|
532
|
+
/** Example messages */
|
|
533
|
+
messageExamples: MessageExample[][];
|
|
534
|
+
/** Example posts */
|
|
535
|
+
postExamples: string[];
|
|
536
|
+
/** Known topics */
|
|
537
|
+
topics: string[];
|
|
538
|
+
/** Character traits */
|
|
539
|
+
adjectives: string[];
|
|
540
|
+
/** Optional knowledge base */
|
|
541
|
+
knowledge?: string[];
|
|
542
|
+
/** Supported client platforms */
|
|
543
|
+
clients: Clients[];
|
|
544
|
+
/** Available plugins */
|
|
545
|
+
plugins: Plugin[];
|
|
546
|
+
/** Optional configuration */
|
|
547
|
+
settings?: {
|
|
548
|
+
secrets?: {
|
|
549
|
+
[key: string]: string;
|
|
550
|
+
};
|
|
551
|
+
intiface?: boolean;
|
|
552
|
+
voice?: {
|
|
553
|
+
model?: string;
|
|
554
|
+
url?: string;
|
|
555
|
+
elevenlabs?: {
|
|
556
|
+
voiceId: string;
|
|
557
|
+
model?: string;
|
|
558
|
+
stability?: string;
|
|
559
|
+
similarityBoost?: string;
|
|
560
|
+
style?: string;
|
|
561
|
+
useSpeakerBoost?: string;
|
|
562
|
+
};
|
|
563
|
+
};
|
|
564
|
+
model?: string;
|
|
565
|
+
embeddingModel?: string;
|
|
566
|
+
chains?: {
|
|
567
|
+
evm?: any[];
|
|
568
|
+
solana?: any[];
|
|
569
|
+
[key: string]: any[];
|
|
570
|
+
};
|
|
571
|
+
};
|
|
572
|
+
/** Optional client-specific config */
|
|
573
|
+
clientConfig?: {
|
|
574
|
+
discord?: {
|
|
575
|
+
shouldIgnoreBotMessages?: boolean;
|
|
576
|
+
shouldIgnoreDirectMessages?: boolean;
|
|
577
|
+
shouldRespondOnlyToMentions?: boolean;
|
|
578
|
+
messageSimilarityThreshold?: number;
|
|
579
|
+
isPartOfTeam?: boolean;
|
|
580
|
+
teamAgentIds?: string[];
|
|
581
|
+
teamLeaderId?: string;
|
|
582
|
+
teamMemberInterestKeywords?: string[];
|
|
583
|
+
};
|
|
584
|
+
telegram?: {
|
|
585
|
+
shouldIgnoreBotMessages?: boolean;
|
|
586
|
+
shouldIgnoreDirectMessages?: boolean;
|
|
587
|
+
shouldRespondOnlyToMentions?: boolean;
|
|
588
|
+
shouldOnlyJoinInAllowedGroups?: boolean;
|
|
589
|
+
allowedGroupIds?: string[];
|
|
590
|
+
messageSimilarityThreshold?: number;
|
|
591
|
+
isPartOfTeam?: boolean;
|
|
592
|
+
teamAgentIds?: string[];
|
|
593
|
+
teamLeaderId?: string;
|
|
594
|
+
teamMemberInterestKeywords?: string[];
|
|
595
|
+
};
|
|
596
|
+
slack?: {
|
|
597
|
+
shouldIgnoreBotMessages?: boolean;
|
|
598
|
+
shouldIgnoreDirectMessages?: boolean;
|
|
599
|
+
};
|
|
600
|
+
};
|
|
601
|
+
/** Writing style guides */
|
|
602
|
+
style: {
|
|
603
|
+
all: string[];
|
|
604
|
+
chat: string[];
|
|
605
|
+
post: string[];
|
|
606
|
+
};
|
|
607
|
+
/** Optional Twitter profile */
|
|
608
|
+
twitterProfile?: {
|
|
609
|
+
id: string;
|
|
610
|
+
username: string;
|
|
611
|
+
screenName: string;
|
|
612
|
+
bio: string;
|
|
613
|
+
nicknames?: string[];
|
|
614
|
+
};
|
|
615
|
+
/** Optional NFT prompt */
|
|
616
|
+
nft?: {
|
|
617
|
+
prompt: string;
|
|
618
|
+
};
|
|
619
|
+
};
|
|
620
|
+
/**
|
|
621
|
+
* Interface for database operations
|
|
622
|
+
*/
|
|
623
|
+
interface IDatabaseAdapter {
|
|
624
|
+
/** Database instance */
|
|
625
|
+
db: any;
|
|
626
|
+
/** Optional initialization */
|
|
627
|
+
init(): Promise<void>;
|
|
628
|
+
/** Close database connection */
|
|
629
|
+
close(): Promise<void>;
|
|
630
|
+
/** Get account by ID */
|
|
631
|
+
getAccountById(userId: UUID): Promise<Account | null>;
|
|
632
|
+
/** Create new account */
|
|
633
|
+
createAccount(account: Account): Promise<boolean>;
|
|
634
|
+
/** Get memories matching criteria */
|
|
635
|
+
getMemories(params: {
|
|
636
|
+
roomId: UUID;
|
|
637
|
+
count?: number;
|
|
638
|
+
unique?: boolean;
|
|
639
|
+
tableName: string;
|
|
640
|
+
agentId: UUID;
|
|
641
|
+
start?: number;
|
|
642
|
+
end?: number;
|
|
643
|
+
}): Promise<Memory[]>;
|
|
644
|
+
getMemoryById(id: UUID): Promise<Memory | null>;
|
|
645
|
+
getMemoriesByRoomIds(params: {
|
|
646
|
+
tableName: string;
|
|
647
|
+
agentId: UUID;
|
|
648
|
+
roomIds: UUID[];
|
|
649
|
+
}): Promise<Memory[]>;
|
|
650
|
+
getCachedEmbeddings(params: {
|
|
651
|
+
query_table_name: string;
|
|
652
|
+
query_threshold: number;
|
|
653
|
+
query_input: string;
|
|
654
|
+
query_field_name: string;
|
|
655
|
+
query_field_sub_name: string;
|
|
656
|
+
query_match_count: number;
|
|
657
|
+
}): Promise<{
|
|
658
|
+
embedding: number[];
|
|
659
|
+
levenshtein_score: number;
|
|
660
|
+
}[]>;
|
|
661
|
+
log(params: {
|
|
662
|
+
body: {
|
|
663
|
+
[key: string]: unknown;
|
|
664
|
+
};
|
|
665
|
+
userId: UUID;
|
|
666
|
+
roomId: UUID;
|
|
667
|
+
type: string;
|
|
668
|
+
}): Promise<void>;
|
|
669
|
+
getActorDetails(params: {
|
|
670
|
+
roomId: UUID;
|
|
671
|
+
}): Promise<Actor[]>;
|
|
672
|
+
searchMemories(params: {
|
|
673
|
+
tableName: string;
|
|
674
|
+
agentId: UUID;
|
|
675
|
+
roomId: UUID;
|
|
676
|
+
embedding: number[];
|
|
677
|
+
match_threshold: number;
|
|
678
|
+
match_count: number;
|
|
679
|
+
unique: boolean;
|
|
680
|
+
}): Promise<Memory[]>;
|
|
681
|
+
updateGoalStatus(params: {
|
|
682
|
+
goalId: UUID;
|
|
683
|
+
status: GoalStatus;
|
|
684
|
+
}): Promise<void>;
|
|
685
|
+
searchMemoriesByEmbedding(embedding: number[], params: {
|
|
686
|
+
match_threshold?: number;
|
|
687
|
+
count?: number;
|
|
688
|
+
roomId?: UUID;
|
|
689
|
+
agentId?: UUID;
|
|
690
|
+
unique?: boolean;
|
|
691
|
+
tableName: string;
|
|
692
|
+
}): Promise<Memory[]>;
|
|
693
|
+
createMemory(memory: Memory, tableName: string, unique?: boolean): Promise<void>;
|
|
694
|
+
removeMemory(memoryId: UUID, tableName: string): Promise<void>;
|
|
695
|
+
removeAllMemories(roomId: UUID, tableName: string): Promise<void>;
|
|
696
|
+
countMemories(roomId: UUID, unique?: boolean, tableName?: string): Promise<number>;
|
|
697
|
+
getGoals(params: {
|
|
698
|
+
agentId: UUID;
|
|
699
|
+
roomId: UUID;
|
|
700
|
+
userId?: UUID | null;
|
|
701
|
+
onlyInProgress?: boolean;
|
|
702
|
+
count?: number;
|
|
703
|
+
}): Promise<Goal[]>;
|
|
704
|
+
updateGoal(goal: Goal): Promise<void>;
|
|
705
|
+
createGoal(goal: Goal): Promise<void>;
|
|
706
|
+
removeGoal(goalId: UUID): Promise<void>;
|
|
707
|
+
removeAllGoals(roomId: UUID): Promise<void>;
|
|
708
|
+
getRoom(roomId: UUID): Promise<UUID | null>;
|
|
709
|
+
createRoom(roomId?: UUID): Promise<UUID>;
|
|
710
|
+
removeRoom(roomId: UUID): Promise<void>;
|
|
711
|
+
getRoomsForParticipant(userId: UUID): Promise<UUID[]>;
|
|
712
|
+
getRoomsForParticipants(userIds: UUID[]): Promise<UUID[]>;
|
|
713
|
+
addParticipant(userId: UUID, roomId: UUID): Promise<boolean>;
|
|
714
|
+
removeParticipant(userId: UUID, roomId: UUID): Promise<boolean>;
|
|
715
|
+
getParticipantsForAccount(userId: UUID): Promise<Participant[]>;
|
|
716
|
+
getParticipantsForRoom(roomId: UUID): Promise<UUID[]>;
|
|
717
|
+
getParticipantUserState(roomId: UUID, userId: UUID): Promise<"FOLLOWED" | "MUTED" | null>;
|
|
718
|
+
setParticipantUserState(roomId: UUID, userId: UUID, state: "FOLLOWED" | "MUTED" | null): Promise<void>;
|
|
719
|
+
createRelationship(params: {
|
|
720
|
+
userA: UUID;
|
|
721
|
+
userB: UUID;
|
|
722
|
+
}): Promise<boolean>;
|
|
723
|
+
getRelationship(params: {
|
|
724
|
+
userA: UUID;
|
|
725
|
+
userB: UUID;
|
|
726
|
+
}): Promise<Relationship | null>;
|
|
727
|
+
getRelationships(params: {
|
|
728
|
+
userId: UUID;
|
|
729
|
+
}): Promise<Relationship[]>;
|
|
730
|
+
}
|
|
731
|
+
interface IDatabaseCacheAdapter {
|
|
732
|
+
getCache(params: {
|
|
733
|
+
agentId: UUID;
|
|
734
|
+
key: string;
|
|
735
|
+
}): Promise<string | undefined>;
|
|
736
|
+
setCache(params: {
|
|
737
|
+
agentId: UUID;
|
|
738
|
+
key: string;
|
|
739
|
+
value: string;
|
|
740
|
+
}): Promise<boolean>;
|
|
741
|
+
deleteCache(params: {
|
|
742
|
+
agentId: UUID;
|
|
743
|
+
key: string;
|
|
744
|
+
}): Promise<boolean>;
|
|
745
|
+
}
|
|
746
|
+
interface IMemoryManager {
|
|
747
|
+
runtime: IAgentRuntime;
|
|
748
|
+
tableName: string;
|
|
749
|
+
constructor: Function;
|
|
750
|
+
addEmbeddingToMemory(memory: Memory): Promise<Memory>;
|
|
751
|
+
getMemories(opts: {
|
|
752
|
+
roomId: UUID;
|
|
753
|
+
count?: number;
|
|
754
|
+
unique?: boolean;
|
|
755
|
+
start?: number;
|
|
756
|
+
end?: number;
|
|
757
|
+
}): Promise<Memory[]>;
|
|
758
|
+
getCachedEmbeddings(content: string): Promise<{
|
|
759
|
+
embedding: number[];
|
|
760
|
+
levenshtein_score: number;
|
|
761
|
+
}[]>;
|
|
762
|
+
getMemoryById(id: UUID): Promise<Memory | null>;
|
|
763
|
+
getMemoriesByRoomIds(params: {
|
|
764
|
+
roomIds: UUID[];
|
|
765
|
+
}): Promise<Memory[]>;
|
|
766
|
+
searchMemoriesByEmbedding(embedding: number[], opts: {
|
|
767
|
+
match_threshold?: number;
|
|
768
|
+
count?: number;
|
|
769
|
+
roomId: UUID;
|
|
770
|
+
unique?: boolean;
|
|
771
|
+
}): Promise<Memory[]>;
|
|
772
|
+
createMemory(memory: Memory, unique?: boolean): Promise<void>;
|
|
773
|
+
removeMemory(memoryId: UUID): Promise<void>;
|
|
774
|
+
removeAllMemories(roomId: UUID): Promise<void>;
|
|
775
|
+
countMemories(roomId: UUID, unique?: boolean): Promise<number>;
|
|
776
|
+
}
|
|
777
|
+
type CacheOptions = {
|
|
778
|
+
expires?: number;
|
|
779
|
+
};
|
|
780
|
+
declare enum CacheStore {
|
|
781
|
+
REDIS = "redis",
|
|
782
|
+
DATABASE = "database",
|
|
783
|
+
FILESYSTEM = "filesystem"
|
|
784
|
+
}
|
|
785
|
+
interface ICacheManager {
|
|
786
|
+
get<T = unknown>(key: string): Promise<T | undefined>;
|
|
787
|
+
set<T>(key: string, value: T, options?: CacheOptions): Promise<void>;
|
|
788
|
+
delete(key: string): Promise<void>;
|
|
789
|
+
}
|
|
790
|
+
declare abstract class Service {
|
|
791
|
+
private static instance;
|
|
792
|
+
static get serviceType(): ServiceType;
|
|
793
|
+
static getInstance<T extends Service>(): T;
|
|
794
|
+
get serviceType(): ServiceType;
|
|
795
|
+
abstract initialize(runtime: IAgentRuntime): Promise<void>;
|
|
796
|
+
}
|
|
797
|
+
interface IAgentRuntime {
|
|
798
|
+
agentId: UUID;
|
|
799
|
+
serverUrl: string;
|
|
800
|
+
databaseAdapter: IDatabaseAdapter;
|
|
801
|
+
token: string | null;
|
|
802
|
+
modelProvider: ModelProviderName;
|
|
803
|
+
imageModelProvider: ModelProviderName;
|
|
804
|
+
character: Character;
|
|
805
|
+
providers: Provider[];
|
|
806
|
+
actions: Action[];
|
|
807
|
+
evaluators: Evaluator[];
|
|
808
|
+
plugins: Plugin[];
|
|
809
|
+
fetch?: typeof fetch | null;
|
|
810
|
+
messageManager: IMemoryManager;
|
|
811
|
+
descriptionManager: IMemoryManager;
|
|
812
|
+
documentsManager: IMemoryManager;
|
|
813
|
+
knowledgeManager: IMemoryManager;
|
|
814
|
+
loreManager: IMemoryManager;
|
|
815
|
+
cacheManager: ICacheManager;
|
|
816
|
+
services: Map<ServiceType, Service>;
|
|
817
|
+
clients: Record<string, any>;
|
|
818
|
+
initialize(): Promise<void>;
|
|
819
|
+
registerMemoryManager(manager: IMemoryManager): void;
|
|
820
|
+
getMemoryManager(name: string): IMemoryManager | null;
|
|
821
|
+
getService<T extends Service>(service: ServiceType): T | null;
|
|
822
|
+
registerService(service: Service): void;
|
|
823
|
+
getSetting(key: string): string | null;
|
|
824
|
+
getConversationLength(): number;
|
|
825
|
+
processActions(message: Memory, responses: Memory[], state?: State, callback?: HandlerCallback): Promise<void>;
|
|
826
|
+
evaluate(message: Memory, state?: State, didRespond?: boolean, callback?: HandlerCallback): Promise<string[]>;
|
|
827
|
+
ensureParticipantExists(userId: UUID, roomId: UUID): Promise<void>;
|
|
828
|
+
ensureUserExists(userId: UUID, userName: string | null, name: string | null, source: string | null): Promise<void>;
|
|
829
|
+
registerAction(action: Action): void;
|
|
830
|
+
ensureConnection(userId: UUID, roomId: UUID, userName?: string, userScreenName?: string, source?: string): Promise<void>;
|
|
831
|
+
ensureParticipantInRoom(userId: UUID, roomId: UUID): Promise<void>;
|
|
832
|
+
ensureRoomExists(roomId: UUID): Promise<void>;
|
|
833
|
+
composeState(message: Memory, additionalKeys?: {
|
|
834
|
+
[key: string]: unknown;
|
|
835
|
+
}): Promise<State>;
|
|
836
|
+
updateRecentMessageState(state: State): Promise<State>;
|
|
837
|
+
}
|
|
838
|
+
interface IImageDescriptionService extends Service {
|
|
839
|
+
describeImage(imageUrl: string): Promise<{
|
|
840
|
+
title: string;
|
|
841
|
+
description: string;
|
|
842
|
+
}>;
|
|
843
|
+
}
|
|
844
|
+
interface ITranscriptionService extends Service {
|
|
845
|
+
transcribeAttachment(audioBuffer: ArrayBuffer): Promise<string | null>;
|
|
846
|
+
transcribeAttachmentLocally(audioBuffer: ArrayBuffer): Promise<string | null>;
|
|
847
|
+
transcribe(audioBuffer: ArrayBuffer): Promise<string | null>;
|
|
848
|
+
transcribeLocally(audioBuffer: ArrayBuffer): Promise<string | null>;
|
|
849
|
+
}
|
|
850
|
+
interface IVideoService extends Service {
|
|
851
|
+
isVideoUrl(url: string): boolean;
|
|
852
|
+
fetchVideoInfo(url: string): Promise<Media>;
|
|
853
|
+
downloadVideo(videoInfo: Media): Promise<string>;
|
|
854
|
+
processVideo(url: string, runtime: IAgentRuntime): Promise<Media>;
|
|
855
|
+
}
|
|
856
|
+
interface ITextGenerationService extends Service {
|
|
857
|
+
initializeModel(): Promise<void>;
|
|
858
|
+
queueMessageCompletion(context: string, temperature: number, stop: string[], frequency_penalty: number, presence_penalty: number, max_tokens: number): Promise<any>;
|
|
859
|
+
queueTextCompletion(context: string, temperature: number, stop: string[], frequency_penalty: number, presence_penalty: number, max_tokens: number): Promise<string>;
|
|
860
|
+
getEmbeddingResponse(input: string): Promise<number[] | undefined>;
|
|
861
|
+
}
|
|
862
|
+
interface IBrowserService extends Service {
|
|
863
|
+
closeBrowser(): Promise<void>;
|
|
864
|
+
getPageContent(url: string, runtime: IAgentRuntime): Promise<{
|
|
865
|
+
title: string;
|
|
866
|
+
description: string;
|
|
867
|
+
bodyContent: string;
|
|
868
|
+
}>;
|
|
869
|
+
}
|
|
870
|
+
interface ISpeechService extends Service {
|
|
871
|
+
getInstance(): ISpeechService;
|
|
872
|
+
generate(runtime: IAgentRuntime, text: string): Promise<Readable>;
|
|
873
|
+
}
|
|
874
|
+
interface IPdfService extends Service {
|
|
875
|
+
getInstance(): IPdfService;
|
|
876
|
+
convertPdfToText(pdfBuffer: Buffer): Promise<string>;
|
|
877
|
+
}
|
|
878
|
+
interface IAwsS3Service extends Service {
|
|
879
|
+
uploadFile(imagePath: string, subDirectory: string, useSignedUrl: boolean, expiresIn: number): Promise<{
|
|
880
|
+
success: boolean;
|
|
881
|
+
url?: string;
|
|
882
|
+
error?: string;
|
|
883
|
+
}>;
|
|
884
|
+
generateSignedUrl(fileName: string, expiresIn: number): Promise<string>;
|
|
885
|
+
}
|
|
886
|
+
type SearchResult = {
|
|
887
|
+
title: string;
|
|
888
|
+
url: string;
|
|
889
|
+
content: string;
|
|
890
|
+
score: number;
|
|
891
|
+
raw_content: string | null;
|
|
892
|
+
};
|
|
893
|
+
type SearchResponse = {
|
|
894
|
+
query: string;
|
|
895
|
+
follow_up_questions: string[] | null;
|
|
896
|
+
answer: string | null;
|
|
897
|
+
images: string[];
|
|
898
|
+
results: SearchResult[];
|
|
899
|
+
response_time: number;
|
|
900
|
+
};
|
|
901
|
+
declare enum ServiceType {
|
|
902
|
+
IMAGE_DESCRIPTION = "image_description",
|
|
903
|
+
TRANSCRIPTION = "transcription",
|
|
904
|
+
VIDEO = "video",
|
|
905
|
+
TEXT_GENERATION = "text_generation",
|
|
906
|
+
BROWSER = "browser",
|
|
907
|
+
SPEECH_GENERATION = "speech_generation",
|
|
908
|
+
PDF = "pdf",
|
|
909
|
+
INTIFACE = "intiface",
|
|
910
|
+
AWS_S3 = "aws_s3",
|
|
911
|
+
BUTTPLUG = "buttplug",
|
|
912
|
+
SLACK = "slack"
|
|
913
|
+
}
|
|
914
|
+
declare enum LoggingLevel {
|
|
915
|
+
DEBUG = "debug",
|
|
916
|
+
VERBOSE = "verbose",
|
|
917
|
+
NONE = "none"
|
|
918
|
+
}
|
|
919
|
+
type KnowledgeItem = {
|
|
920
|
+
id: UUID;
|
|
921
|
+
content: Content;
|
|
922
|
+
};
|
|
923
|
+
interface ActionResponse {
|
|
924
|
+
like: boolean;
|
|
925
|
+
retweet: boolean;
|
|
926
|
+
quote?: boolean;
|
|
927
|
+
reply?: boolean;
|
|
928
|
+
}
|
|
929
|
+
interface ISlackService extends Service {
|
|
930
|
+
client: any;
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
/**
|
|
934
|
+
* Composes a set of example conversations based on provided actions and a specified count.
|
|
935
|
+
* It randomly selects examples from the provided actions and formats them with generated names.
|
|
936
|
+
* @param actionsData - An array of `Action` objects from which to draw examples.
|
|
937
|
+
* @param count - The number of examples to generate.
|
|
938
|
+
* @returns A string containing formatted examples of conversations.
|
|
939
|
+
*/
|
|
940
|
+
declare const composeActionExamples: (actionsData: Action[], count: number) => string;
|
|
941
|
+
/**
|
|
942
|
+
* Formats the names of the provided actions into a comma-separated string.
|
|
943
|
+
* @param actions - An array of `Action` objects from which to extract names.
|
|
944
|
+
* @returns A comma-separated string of action names.
|
|
945
|
+
*/
|
|
946
|
+
declare function formatActionNames(actions: Action[]): string;
|
|
947
|
+
/**
|
|
948
|
+
* Formats the provided actions into a detailed string listing each action's name and description, separated by commas and newlines.
|
|
949
|
+
* @param actions - An array of `Action` objects to format.
|
|
950
|
+
* @returns A detailed string of actions, including names and descriptions.
|
|
951
|
+
*/
|
|
952
|
+
declare function formatActions(actions: Action[]): string;
|
|
953
|
+
|
|
954
|
+
/**
|
|
955
|
+
* Composes a context string by replacing placeholders in a template with corresponding values from the state.
|
|
956
|
+
*
|
|
957
|
+
* This function takes a template string with placeholders in the format `{{placeholder}}` and a state object.
|
|
958
|
+
* It replaces each placeholder with the value from the state object that matches the placeholder's name.
|
|
959
|
+
* If a matching key is not found in the state object for a given placeholder, the placeholder is replaced with an empty string.
|
|
960
|
+
*
|
|
961
|
+
* 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.
|
|
962
|
+
*
|
|
963
|
+
* @param {Object} params - The parameters for composing the context.
|
|
964
|
+
* @param {State} params.state - The state object containing values to replace the placeholders in the template.
|
|
965
|
+
* @param {string} params.template - The template string containing placeholders to be replaced with state values.
|
|
966
|
+
* @param {"handlebars" | undefined} [params.templatingEngine] - The templating engine to use for compiling and evaluating the template (optional, default: `undefined`).
|
|
967
|
+
* @returns {string} The composed context string with placeholders replaced by corresponding state values.
|
|
968
|
+
*
|
|
969
|
+
* @example
|
|
970
|
+
* // Given a state object and a template
|
|
971
|
+
* const state = { userName: "Alice", userAge: 30 };
|
|
972
|
+
* const template = "Hello, {{userName}}! You are {{userAge}} years old";
|
|
973
|
+
*
|
|
974
|
+
* // Composing the context with simple string replacement will result in:
|
|
975
|
+
* // "Hello, Alice! You are 30 years old."
|
|
976
|
+
* const contextSimple = composeContext({ state, template });
|
|
977
|
+
*/
|
|
978
|
+
declare const composeContext: ({ state, template, templatingEngine, }: {
|
|
979
|
+
state: State;
|
|
980
|
+
template: string;
|
|
981
|
+
templatingEngine?: "handlebars";
|
|
982
|
+
}) => string;
|
|
983
|
+
/**
|
|
984
|
+
* Adds a header to a body of text.
|
|
985
|
+
*
|
|
986
|
+
* This function takes a header string and a body string and returns a new string with the header prepended to the body.
|
|
987
|
+
* If the body string is empty, the header is returned as is.
|
|
988
|
+
*
|
|
989
|
+
* @param {string} header - The header to add to the body.
|
|
990
|
+
* @param {string} body - The body to which to add the header.
|
|
991
|
+
* @returns {string} The body with the header prepended.
|
|
992
|
+
*
|
|
993
|
+
* @example
|
|
994
|
+
* // Given a header and a body
|
|
995
|
+
* const header = "Header";
|
|
996
|
+
* const body = "Body";
|
|
997
|
+
*
|
|
998
|
+
* // Adding the header to the body will result in:
|
|
999
|
+
* // "Header\nBody"
|
|
1000
|
+
* const text = addHeader(header, body);
|
|
1001
|
+
*/
|
|
1002
|
+
declare const addHeader: (header: string, body: string) => string;
|
|
1003
|
+
|
|
1004
|
+
declare class CircuitBreaker {
|
|
1005
|
+
private readonly config;
|
|
1006
|
+
private state;
|
|
1007
|
+
private failureCount;
|
|
1008
|
+
private lastFailureTime?;
|
|
1009
|
+
private halfOpenSuccesses;
|
|
1010
|
+
private readonly failureThreshold;
|
|
1011
|
+
private readonly resetTimeout;
|
|
1012
|
+
private readonly halfOpenMaxAttempts;
|
|
1013
|
+
constructor(config?: {
|
|
1014
|
+
failureThreshold?: number;
|
|
1015
|
+
resetTimeout?: number;
|
|
1016
|
+
halfOpenMaxAttempts?: number;
|
|
1017
|
+
});
|
|
1018
|
+
execute<T>(operation: () => Promise<T>): Promise<T>;
|
|
1019
|
+
private handleFailure;
|
|
1020
|
+
private reset;
|
|
1021
|
+
getState(): "CLOSED" | "OPEN" | "HALF_OPEN";
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
/**
|
|
1025
|
+
* An abstract class representing a database adapter for managing various entities
|
|
1026
|
+
* like accounts, memories, actors, goals, and rooms.
|
|
1027
|
+
*/
|
|
1028
|
+
declare abstract class DatabaseAdapter<DB = any> implements IDatabaseAdapter {
|
|
1029
|
+
/**
|
|
1030
|
+
* The database instance.
|
|
1031
|
+
*/
|
|
1032
|
+
db: DB;
|
|
1033
|
+
/**
|
|
1034
|
+
* Circuit breaker instance used to handle fault tolerance and prevent cascading failures.
|
|
1035
|
+
* Implements the Circuit Breaker pattern to temporarily disable operations when a failure threshold is reached.
|
|
1036
|
+
*
|
|
1037
|
+
* The circuit breaker has three states:
|
|
1038
|
+
* - CLOSED: Normal operation, requests pass through
|
|
1039
|
+
* - OPEN: Failure threshold exceeded, requests are blocked
|
|
1040
|
+
* - HALF_OPEN: Testing if service has recovered
|
|
1041
|
+
*
|
|
1042
|
+
* @protected
|
|
1043
|
+
*/
|
|
1044
|
+
protected circuitBreaker: CircuitBreaker;
|
|
1045
|
+
/**
|
|
1046
|
+
* Creates a new DatabaseAdapter instance with optional circuit breaker configuration.
|
|
1047
|
+
*
|
|
1048
|
+
* @param circuitBreakerConfig - Configuration options for the circuit breaker
|
|
1049
|
+
* @param circuitBreakerConfig.failureThreshold - Number of failures before circuit opens (defaults to 5)
|
|
1050
|
+
* @param circuitBreakerConfig.resetTimeout - Time in ms before attempting to close circuit (defaults to 60000)
|
|
1051
|
+
* @param circuitBreakerConfig.halfOpenMaxAttempts - Number of successful attempts needed to close circuit (defaults to 3)
|
|
1052
|
+
*/
|
|
1053
|
+
constructor(circuitBreakerConfig?: {
|
|
1054
|
+
failureThreshold?: number;
|
|
1055
|
+
resetTimeout?: number;
|
|
1056
|
+
halfOpenMaxAttempts?: number;
|
|
1057
|
+
});
|
|
1058
|
+
/**
|
|
1059
|
+
* Optional initialization method for the database adapter.
|
|
1060
|
+
* @returns A Promise that resolves when initialization is complete.
|
|
1061
|
+
*/
|
|
1062
|
+
abstract init(): Promise<void>;
|
|
1063
|
+
/**
|
|
1064
|
+
* Optional close method for the database adapter.
|
|
1065
|
+
* @returns A Promise that resolves when closing is complete.
|
|
1066
|
+
*/
|
|
1067
|
+
abstract close(): Promise<void>;
|
|
1068
|
+
/**
|
|
1069
|
+
* Retrieves an account by its ID.
|
|
1070
|
+
* @param userId The UUID of the user account to retrieve.
|
|
1071
|
+
* @returns A Promise that resolves to the Account object or null if not found.
|
|
1072
|
+
*/
|
|
1073
|
+
abstract getAccountById(userId: UUID): Promise<Account | null>;
|
|
1074
|
+
/**
|
|
1075
|
+
* Creates a new account in the database.
|
|
1076
|
+
* @param account The account object to create.
|
|
1077
|
+
* @returns A Promise that resolves when the account creation is complete.
|
|
1078
|
+
*/
|
|
1079
|
+
abstract createAccount(account: Account): Promise<boolean>;
|
|
1080
|
+
/**
|
|
1081
|
+
* Retrieves memories based on the specified parameters.
|
|
1082
|
+
* @param params An object containing parameters for the memory retrieval.
|
|
1083
|
+
* @returns A Promise that resolves to an array of Memory objects.
|
|
1084
|
+
*/
|
|
1085
|
+
abstract getMemories(params: {
|
|
1086
|
+
agentId: UUID;
|
|
1087
|
+
roomId: UUID;
|
|
1088
|
+
count?: number;
|
|
1089
|
+
unique?: boolean;
|
|
1090
|
+
tableName: string;
|
|
1091
|
+
}): Promise<Memory[]>;
|
|
1092
|
+
abstract getMemoriesByRoomIds(params: {
|
|
1093
|
+
agentId: UUID;
|
|
1094
|
+
roomIds: UUID[];
|
|
1095
|
+
tableName: string;
|
|
1096
|
+
}): Promise<Memory[]>;
|
|
1097
|
+
abstract getMemoryById(id: UUID): Promise<Memory | null>;
|
|
1098
|
+
/**
|
|
1099
|
+
* Retrieves cached embeddings based on the specified query parameters.
|
|
1100
|
+
* @param params An object containing parameters for the embedding retrieval.
|
|
1101
|
+
* @returns A Promise that resolves to an array of objects containing embeddings and levenshtein scores.
|
|
1102
|
+
*/
|
|
1103
|
+
abstract getCachedEmbeddings({ query_table_name, query_threshold, query_input, query_field_name, query_field_sub_name, query_match_count, }: {
|
|
1104
|
+
query_table_name: string;
|
|
1105
|
+
query_threshold: number;
|
|
1106
|
+
query_input: string;
|
|
1107
|
+
query_field_name: string;
|
|
1108
|
+
query_field_sub_name: string;
|
|
1109
|
+
query_match_count: number;
|
|
1110
|
+
}): Promise<{
|
|
1111
|
+
embedding: number[];
|
|
1112
|
+
levenshtein_score: number;
|
|
1113
|
+
}[]>;
|
|
1114
|
+
/**
|
|
1115
|
+
* Logs an event or action with the specified details.
|
|
1116
|
+
* @param params An object containing parameters for the log entry.
|
|
1117
|
+
* @returns A Promise that resolves when the log entry has been saved.
|
|
1118
|
+
*/
|
|
1119
|
+
abstract log(params: {
|
|
1120
|
+
body: {
|
|
1121
|
+
[key: string]: unknown;
|
|
1122
|
+
};
|
|
1123
|
+
userId: UUID;
|
|
1124
|
+
roomId: UUID;
|
|
1125
|
+
type: string;
|
|
1126
|
+
}): Promise<void>;
|
|
1127
|
+
/**
|
|
1128
|
+
* Retrieves details of actors in a given room.
|
|
1129
|
+
* @param params An object containing the roomId to search for actors.
|
|
1130
|
+
* @returns A Promise that resolves to an array of Actor objects.
|
|
1131
|
+
*/
|
|
1132
|
+
abstract getActorDetails(params: {
|
|
1133
|
+
roomId: UUID;
|
|
1134
|
+
}): Promise<Actor[]>;
|
|
1135
|
+
/**
|
|
1136
|
+
* Searches for memories based on embeddings and other specified parameters.
|
|
1137
|
+
* @param params An object containing parameters for the memory search.
|
|
1138
|
+
* @returns A Promise that resolves to an array of Memory objects.
|
|
1139
|
+
*/
|
|
1140
|
+
abstract searchMemories(params: {
|
|
1141
|
+
tableName: string;
|
|
1142
|
+
agentId: UUID;
|
|
1143
|
+
roomId: UUID;
|
|
1144
|
+
embedding: number[];
|
|
1145
|
+
match_threshold: number;
|
|
1146
|
+
match_count: number;
|
|
1147
|
+
unique: boolean;
|
|
1148
|
+
}): Promise<Memory[]>;
|
|
1149
|
+
/**
|
|
1150
|
+
* Updates the status of a specific goal.
|
|
1151
|
+
* @param params An object containing the goalId and the new status.
|
|
1152
|
+
* @returns A Promise that resolves when the goal status has been updated.
|
|
1153
|
+
*/
|
|
1154
|
+
abstract updateGoalStatus(params: {
|
|
1155
|
+
goalId: UUID;
|
|
1156
|
+
status: GoalStatus;
|
|
1157
|
+
}): Promise<void>;
|
|
1158
|
+
/**
|
|
1159
|
+
* Searches for memories by embedding and other specified parameters.
|
|
1160
|
+
* @param embedding The embedding vector to search with.
|
|
1161
|
+
* @param params Additional parameters for the search.
|
|
1162
|
+
* @returns A Promise that resolves to an array of Memory objects.
|
|
1163
|
+
*/
|
|
1164
|
+
abstract searchMemoriesByEmbedding(embedding: number[], params: {
|
|
1165
|
+
match_threshold?: number;
|
|
1166
|
+
count?: number;
|
|
1167
|
+
roomId?: UUID;
|
|
1168
|
+
agentId?: UUID;
|
|
1169
|
+
unique?: boolean;
|
|
1170
|
+
tableName: string;
|
|
1171
|
+
}): Promise<Memory[]>;
|
|
1172
|
+
/**
|
|
1173
|
+
* Creates a new memory in the database.
|
|
1174
|
+
* @param memory The memory object to create.
|
|
1175
|
+
* @param tableName The table where the memory should be stored.
|
|
1176
|
+
* @param unique Indicates if the memory should be unique.
|
|
1177
|
+
* @returns A Promise that resolves when the memory has been created.
|
|
1178
|
+
*/
|
|
1179
|
+
abstract createMemory(memory: Memory, tableName: string, unique?: boolean): Promise<void>;
|
|
1180
|
+
/**
|
|
1181
|
+
* Removes a specific memory from the database.
|
|
1182
|
+
* @param memoryId The UUID of the memory to remove.
|
|
1183
|
+
* @param tableName The table from which the memory should be removed.
|
|
1184
|
+
* @returns A Promise that resolves when the memory has been removed.
|
|
1185
|
+
*/
|
|
1186
|
+
abstract removeMemory(memoryId: UUID, tableName: string): Promise<void>;
|
|
1187
|
+
/**
|
|
1188
|
+
* Removes all memories associated with a specific room.
|
|
1189
|
+
* @param roomId The UUID of the room whose memories should be removed.
|
|
1190
|
+
* @param tableName The table from which the memories should be removed.
|
|
1191
|
+
* @returns A Promise that resolves when all memories have been removed.
|
|
1192
|
+
*/
|
|
1193
|
+
abstract removeAllMemories(roomId: UUID, tableName: string): Promise<void>;
|
|
1194
|
+
/**
|
|
1195
|
+
* Counts the number of memories in a specific room.
|
|
1196
|
+
* @param roomId The UUID of the room for which to count memories.
|
|
1197
|
+
* @param unique Specifies whether to count only unique memories.
|
|
1198
|
+
* @param tableName Optional table name to count memories from.
|
|
1199
|
+
* @returns A Promise that resolves to the number of memories.
|
|
1200
|
+
*/
|
|
1201
|
+
abstract countMemories(roomId: UUID, unique?: boolean, tableName?: string): Promise<number>;
|
|
1202
|
+
/**
|
|
1203
|
+
* Retrieves goals based on specified parameters.
|
|
1204
|
+
* @param params An object containing parameters for goal retrieval.
|
|
1205
|
+
* @returns A Promise that resolves to an array of Goal objects.
|
|
1206
|
+
*/
|
|
1207
|
+
abstract getGoals(params: {
|
|
1208
|
+
agentId: UUID;
|
|
1209
|
+
roomId: UUID;
|
|
1210
|
+
userId?: UUID | null;
|
|
1211
|
+
onlyInProgress?: boolean;
|
|
1212
|
+
count?: number;
|
|
1213
|
+
}): Promise<Goal[]>;
|
|
1214
|
+
/**
|
|
1215
|
+
* Updates a specific goal in the database.
|
|
1216
|
+
* @param goal The goal object with updated properties.
|
|
1217
|
+
* @returns A Promise that resolves when the goal has been updated.
|
|
1218
|
+
*/
|
|
1219
|
+
abstract updateGoal(goal: Goal): Promise<void>;
|
|
1220
|
+
/**
|
|
1221
|
+
* Creates a new goal in the database.
|
|
1222
|
+
* @param goal The goal object to create.
|
|
1223
|
+
* @returns A Promise that resolves when the goal has been created.
|
|
1224
|
+
*/
|
|
1225
|
+
abstract createGoal(goal: Goal): Promise<void>;
|
|
1226
|
+
/**
|
|
1227
|
+
* Removes a specific goal from the database.
|
|
1228
|
+
* @param goalId The UUID of the goal to remove.
|
|
1229
|
+
* @returns A Promise that resolves when the goal has been removed.
|
|
1230
|
+
*/
|
|
1231
|
+
abstract removeGoal(goalId: UUID): Promise<void>;
|
|
1232
|
+
/**
|
|
1233
|
+
* Removes all goals associated with a specific room.
|
|
1234
|
+
* @param roomId The UUID of the room whose goals should be removed.
|
|
1235
|
+
* @returns A Promise that resolves when all goals have been removed.
|
|
1236
|
+
*/
|
|
1237
|
+
abstract removeAllGoals(roomId: UUID): Promise<void>;
|
|
1238
|
+
/**
|
|
1239
|
+
* Retrieves the room ID for a given room, if it exists.
|
|
1240
|
+
* @param roomId The UUID of the room to retrieve.
|
|
1241
|
+
* @returns A Promise that resolves to the room ID or null if not found.
|
|
1242
|
+
*/
|
|
1243
|
+
abstract getRoom(roomId: UUID): Promise<UUID | null>;
|
|
1244
|
+
/**
|
|
1245
|
+
* Creates a new room with an optional specified ID.
|
|
1246
|
+
* @param roomId Optional UUID to assign to the new room.
|
|
1247
|
+
* @returns A Promise that resolves to the UUID of the created room.
|
|
1248
|
+
*/
|
|
1249
|
+
abstract createRoom(roomId?: UUID): Promise<UUID>;
|
|
1250
|
+
/**
|
|
1251
|
+
* Removes a specific room from the database.
|
|
1252
|
+
* @param roomId The UUID of the room to remove.
|
|
1253
|
+
* @returns A Promise that resolves when the room has been removed.
|
|
1254
|
+
*/
|
|
1255
|
+
abstract removeRoom(roomId: UUID): Promise<void>;
|
|
1256
|
+
/**
|
|
1257
|
+
* Retrieves room IDs for which a specific user is a participant.
|
|
1258
|
+
* @param userId The UUID of the user.
|
|
1259
|
+
* @returns A Promise that resolves to an array of room IDs.
|
|
1260
|
+
*/
|
|
1261
|
+
abstract getRoomsForParticipant(userId: UUID): Promise<UUID[]>;
|
|
1262
|
+
/**
|
|
1263
|
+
* Retrieves room IDs for which specific users are participants.
|
|
1264
|
+
* @param userIds An array of UUIDs of the users.
|
|
1265
|
+
* @returns A Promise that resolves to an array of room IDs.
|
|
1266
|
+
*/
|
|
1267
|
+
abstract getRoomsForParticipants(userIds: UUID[]): Promise<UUID[]>;
|
|
1268
|
+
/**
|
|
1269
|
+
* Adds a user as a participant to a specific room.
|
|
1270
|
+
* @param userId The UUID of the user to add as a participant.
|
|
1271
|
+
* @param roomId The UUID of the room to which the user will be added.
|
|
1272
|
+
* @returns A Promise that resolves to a boolean indicating success or failure.
|
|
1273
|
+
*/
|
|
1274
|
+
abstract addParticipant(userId: UUID, roomId: UUID): Promise<boolean>;
|
|
1275
|
+
/**
|
|
1276
|
+
* Removes a user as a participant from a specific room.
|
|
1277
|
+
* @param userId The UUID of the user to remove as a participant.
|
|
1278
|
+
* @param roomId The UUID of the room from which the user will be removed.
|
|
1279
|
+
* @returns A Promise that resolves to a boolean indicating success or failure.
|
|
1280
|
+
*/
|
|
1281
|
+
abstract removeParticipant(userId: UUID, roomId: UUID): Promise<boolean>;
|
|
1282
|
+
/**
|
|
1283
|
+
* Retrieves participants associated with a specific account.
|
|
1284
|
+
* @param userId The UUID of the account.
|
|
1285
|
+
* @returns A Promise that resolves to an array of Participant objects.
|
|
1286
|
+
*/
|
|
1287
|
+
abstract getParticipantsForAccount(userId: UUID): Promise<Participant[]>;
|
|
1288
|
+
/**
|
|
1289
|
+
* Retrieves participants associated with a specific account.
|
|
1290
|
+
* @param userId The UUID of the account.
|
|
1291
|
+
* @returns A Promise that resolves to an array of Participant objects.
|
|
1292
|
+
*/
|
|
1293
|
+
abstract getParticipantsForAccount(userId: UUID): Promise<Participant[]>;
|
|
1294
|
+
/**
|
|
1295
|
+
* Retrieves participants for a specific room.
|
|
1296
|
+
* @param roomId The UUID of the room for which to retrieve participants.
|
|
1297
|
+
* @returns A Promise that resolves to an array of UUIDs representing the participants.
|
|
1298
|
+
*/
|
|
1299
|
+
abstract getParticipantsForRoom(roomId: UUID): Promise<UUID[]>;
|
|
1300
|
+
abstract getParticipantUserState(roomId: UUID, userId: UUID): Promise<"FOLLOWED" | "MUTED" | null>;
|
|
1301
|
+
abstract setParticipantUserState(roomId: UUID, userId: UUID, state: "FOLLOWED" | "MUTED" | null): Promise<void>;
|
|
1302
|
+
/**
|
|
1303
|
+
* Creates a new relationship between two users.
|
|
1304
|
+
* @param params An object containing the UUIDs of the two users (userA and userB).
|
|
1305
|
+
* @returns A Promise that resolves to a boolean indicating success or failure of the creation.
|
|
1306
|
+
*/
|
|
1307
|
+
abstract createRelationship(params: {
|
|
1308
|
+
userA: UUID;
|
|
1309
|
+
userB: UUID;
|
|
1310
|
+
}): Promise<boolean>;
|
|
1311
|
+
/**
|
|
1312
|
+
* Retrieves a relationship between two users if it exists.
|
|
1313
|
+
* @param params An object containing the UUIDs of the two users (userA and userB).
|
|
1314
|
+
* @returns A Promise that resolves to the Relationship object or null if not found.
|
|
1315
|
+
*/
|
|
1316
|
+
abstract getRelationship(params: {
|
|
1317
|
+
userA: UUID;
|
|
1318
|
+
userB: UUID;
|
|
1319
|
+
}): Promise<Relationship | null>;
|
|
1320
|
+
/**
|
|
1321
|
+
* Retrieves all relationships for a specific user.
|
|
1322
|
+
* @param params An object containing the UUID of the user.
|
|
1323
|
+
* @returns A Promise that resolves to an array of Relationship objects.
|
|
1324
|
+
*/
|
|
1325
|
+
abstract getRelationships(params: {
|
|
1326
|
+
userId: UUID;
|
|
1327
|
+
}): Promise<Relationship[]>;
|
|
1328
|
+
/**
|
|
1329
|
+
* Executes an operation with circuit breaker protection.
|
|
1330
|
+
* @param operation A function that returns a Promise to be executed with circuit breaker protection
|
|
1331
|
+
* @param context A string describing the context/operation being performed for logging purposes
|
|
1332
|
+
* @returns A Promise that resolves to the result of the operation
|
|
1333
|
+
* @throws Will throw an error if the circuit breaker is open or if the operation fails
|
|
1334
|
+
* @protected
|
|
1335
|
+
*/
|
|
1336
|
+
protected withCircuitBreaker<T>(operation: () => Promise<T>, context: string): Promise<T>;
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
declare const defaultCharacter: Character;
|
|
1340
|
+
|
|
1341
|
+
declare const getEmbeddingConfig: () => {
|
|
1342
|
+
dimensions: number;
|
|
1343
|
+
model: string;
|
|
1344
|
+
provider: string;
|
|
1345
|
+
};
|
|
1346
|
+
declare function getEmbeddingType(runtime: IAgentRuntime): "local" | "remote";
|
|
1347
|
+
declare function getEmbeddingZeroVector(): number[];
|
|
1348
|
+
/**
|
|
1349
|
+
* Gets embeddings from a remote API endpoint. Falls back to local BGE/384
|
|
1350
|
+
*
|
|
1351
|
+
* @param {string} input - The text to generate embeddings for
|
|
1352
|
+
* @param {EmbeddingOptions} options - Configuration options including:
|
|
1353
|
+
* - model: The model name to use
|
|
1354
|
+
* - endpoint: Base API endpoint URL
|
|
1355
|
+
* - apiKey: Optional API key for authentication
|
|
1356
|
+
* - isOllama: Whether this is an Ollama endpoint
|
|
1357
|
+
* - dimensions: Desired embedding dimensions
|
|
1358
|
+
* @param {IAgentRuntime} runtime - The agent runtime context
|
|
1359
|
+
* @returns {Promise<number[]>} Array of embedding values
|
|
1360
|
+
* @throws {Error} If the API request fails
|
|
1361
|
+
*/
|
|
1362
|
+
declare function embed(runtime: IAgentRuntime, input: string): Promise<number[]>;
|
|
1363
|
+
|
|
1364
|
+
/**
|
|
1365
|
+
* Template used for the evaluation generateText.
|
|
1366
|
+
*/
|
|
1367
|
+
declare const evaluationTemplate: string;
|
|
1368
|
+
/**
|
|
1369
|
+
* Formats the names of evaluators into a comma-separated list, each enclosed in single quotes.
|
|
1370
|
+
* @param evaluators - An array of evaluator objects.
|
|
1371
|
+
* @returns A string that concatenates the names of all evaluators, each enclosed in single quotes and separated by commas.
|
|
1372
|
+
*/
|
|
1373
|
+
declare function formatEvaluatorNames(evaluators: Evaluator[]): string;
|
|
1374
|
+
/**
|
|
1375
|
+
* Formats evaluator details into a string, including both the name and description of each evaluator.
|
|
1376
|
+
* @param evaluators - An array of evaluator objects.
|
|
1377
|
+
* @returns A string that concatenates the name and description of each evaluator, separated by a colon and a newline character.
|
|
1378
|
+
*/
|
|
1379
|
+
declare function formatEvaluators(evaluators: Evaluator[]): string;
|
|
1380
|
+
/**
|
|
1381
|
+
* Formats evaluator examples into a readable string, replacing placeholders with generated names.
|
|
1382
|
+
* @param evaluators - An array of evaluator objects, each containing examples to format.
|
|
1383
|
+
* @returns A string that presents each evaluator example in a structured format, including context, messages, and outcomes, with placeholders replaced by generated names.
|
|
1384
|
+
*/
|
|
1385
|
+
declare function formatEvaluatorExamples(evaluators: Evaluator[]): string;
|
|
1386
|
+
/**
|
|
1387
|
+
* Generates a string summarizing the descriptions of each evaluator example.
|
|
1388
|
+
* @param evaluators - An array of evaluator objects, each containing examples.
|
|
1389
|
+
* @returns A string that summarizes the descriptions for each evaluator example, formatted with the evaluator name, example number, and description.
|
|
1390
|
+
*/
|
|
1391
|
+
declare function formatEvaluatorExampleDescriptions(evaluators: Evaluator[]): string;
|
|
1392
|
+
|
|
1393
|
+
/**
|
|
1394
|
+
* Send a message to the model for a text generateText - receive a string back and parse how you'd like
|
|
1395
|
+
* @param opts - The options for the generateText request.
|
|
1396
|
+
* @param opts.context The context of the message to be completed.
|
|
1397
|
+
* @param opts.stop A list of strings to stop the generateText at.
|
|
1398
|
+
* @param opts.model The model to use for generateText.
|
|
1399
|
+
* @param opts.frequency_penalty The frequency penalty to apply to the generateText.
|
|
1400
|
+
* @param opts.presence_penalty The presence penalty to apply to the generateText.
|
|
1401
|
+
* @param opts.temperature The temperature to apply to the generateText.
|
|
1402
|
+
* @param opts.max_context_length The maximum length of the context to apply to the generateText.
|
|
1403
|
+
* @returns The completed message.
|
|
1404
|
+
*/
|
|
1405
|
+
declare function generateText({ runtime, context, modelClass, stop, }: {
|
|
1406
|
+
runtime: IAgentRuntime;
|
|
1407
|
+
context: string;
|
|
1408
|
+
modelClass: string;
|
|
1409
|
+
stop?: string[];
|
|
1410
|
+
}): Promise<string>;
|
|
1411
|
+
/**
|
|
1412
|
+
* Truncate the context to the maximum length allowed by the model.
|
|
1413
|
+
* @param context The text to truncate
|
|
1414
|
+
* @param maxTokens Maximum number of tokens to keep
|
|
1415
|
+
* @param model The tokenizer model to use
|
|
1416
|
+
* @returns The truncated text
|
|
1417
|
+
*/
|
|
1418
|
+
declare function trimTokens(context: string, maxTokens: number, model: TiktokenModel): string;
|
|
1419
|
+
/**
|
|
1420
|
+
* Sends a message to the model to determine if it should respond to the given context.
|
|
1421
|
+
* @param opts - The options for the generateText request
|
|
1422
|
+
* @param opts.context The context to evaluate for response
|
|
1423
|
+
* @param opts.stop A list of strings to stop the generateText at
|
|
1424
|
+
* @param opts.model The model to use for generateText
|
|
1425
|
+
* @param opts.frequency_penalty The frequency penalty to apply (0.0 to 2.0)
|
|
1426
|
+
* @param opts.presence_penalty The presence penalty to apply (0.0 to 2.0)
|
|
1427
|
+
* @param opts.temperature The temperature to control randomness (0.0 to 2.0)
|
|
1428
|
+
* @param opts.serverUrl The URL of the API server
|
|
1429
|
+
* @param opts.max_context_length Maximum allowed context length in tokens
|
|
1430
|
+
* @param opts.max_response_length Maximum allowed response length in tokens
|
|
1431
|
+
* @returns Promise resolving to "RESPOND", "IGNORE", "STOP" or null
|
|
1432
|
+
*/
|
|
1433
|
+
declare function generateShouldRespond({ runtime, context, modelClass, }: {
|
|
1434
|
+
runtime: IAgentRuntime;
|
|
1435
|
+
context: string;
|
|
1436
|
+
modelClass: string;
|
|
1437
|
+
}): Promise<"RESPOND" | "IGNORE" | "STOP" | null>;
|
|
1438
|
+
/**
|
|
1439
|
+
* Splits content into chunks of specified size with optional overlapping bleed sections
|
|
1440
|
+
* @param content - The text content to split into chunks
|
|
1441
|
+
* @param chunkSize - The maximum size of each chunk in tokens
|
|
1442
|
+
* @param bleed - Number of characters to overlap between chunks (default: 100)
|
|
1443
|
+
* @returns Promise resolving to array of text chunks with bleed sections
|
|
1444
|
+
*/
|
|
1445
|
+
declare function splitChunks(content: string, chunkSize?: number, bleed?: number): Promise<string[]>;
|
|
1446
|
+
/**
|
|
1447
|
+
* Sends a message to the model and parses the response as a boolean value
|
|
1448
|
+
* @param opts - The options for the generateText request
|
|
1449
|
+
* @param opts.context The context to evaluate for the boolean response
|
|
1450
|
+
* @param opts.stop A list of strings to stop the generateText at
|
|
1451
|
+
* @param opts.model The model to use for generateText
|
|
1452
|
+
* @param opts.frequency_penalty The frequency penalty to apply (0.0 to 2.0)
|
|
1453
|
+
* @param opts.presence_penalty The presence penalty to apply (0.0 to 2.0)
|
|
1454
|
+
* @param opts.temperature The temperature to control randomness (0.0 to 2.0)
|
|
1455
|
+
* @param opts.serverUrl The URL of the API server
|
|
1456
|
+
* @param opts.token The API token for authentication
|
|
1457
|
+
* @param opts.max_context_length Maximum allowed context length in tokens
|
|
1458
|
+
* @param opts.max_response_length Maximum allowed response length in tokens
|
|
1459
|
+
* @returns Promise resolving to a boolean value parsed from the model's response
|
|
1460
|
+
*/
|
|
1461
|
+
declare function generateTrueOrFalse({ runtime, context, modelClass, }: {
|
|
1462
|
+
runtime: IAgentRuntime;
|
|
1463
|
+
context: string;
|
|
1464
|
+
modelClass: string;
|
|
1465
|
+
}): Promise<boolean>;
|
|
1466
|
+
/**
|
|
1467
|
+
* Send a message to the model and parse the response as a string array
|
|
1468
|
+
* @param opts - The options for the generateText request
|
|
1469
|
+
* @param opts.context The context/prompt to send to the model
|
|
1470
|
+
* @param opts.stop Array of strings that will stop the model's generation if encountered
|
|
1471
|
+
* @param opts.model The language model to use
|
|
1472
|
+
* @param opts.frequency_penalty The frequency penalty to apply (0.0 to 2.0)
|
|
1473
|
+
* @param opts.presence_penalty The presence penalty to apply (0.0 to 2.0)
|
|
1474
|
+
* @param opts.temperature The temperature to control randomness (0.0 to 2.0)
|
|
1475
|
+
* @param opts.serverUrl The URL of the API server
|
|
1476
|
+
* @param opts.token The API token for authentication
|
|
1477
|
+
* @param opts.max_context_length Maximum allowed context length in tokens
|
|
1478
|
+
* @param opts.max_response_length Maximum allowed response length in tokens
|
|
1479
|
+
* @returns Promise resolving to an array of strings parsed from the model's response
|
|
1480
|
+
*/
|
|
1481
|
+
declare function generateTextArray({ runtime, context, modelClass, }: {
|
|
1482
|
+
runtime: IAgentRuntime;
|
|
1483
|
+
context: string;
|
|
1484
|
+
modelClass: string;
|
|
1485
|
+
}): Promise<string[]>;
|
|
1486
|
+
declare function generateObjectDeprecated({ runtime, context, modelClass, }: {
|
|
1487
|
+
runtime: IAgentRuntime;
|
|
1488
|
+
context: string;
|
|
1489
|
+
modelClass: string;
|
|
1490
|
+
}): Promise<any>;
|
|
1491
|
+
declare function generateObjectArray({ runtime, context, modelClass, }: {
|
|
1492
|
+
runtime: IAgentRuntime;
|
|
1493
|
+
context: string;
|
|
1494
|
+
modelClass: string;
|
|
1495
|
+
}): Promise<any[]>;
|
|
1496
|
+
/**
|
|
1497
|
+
* Send a message to the model for generateText.
|
|
1498
|
+
* @param opts - The options for the generateText request.
|
|
1499
|
+
* @param opts.context The context of the message to be completed.
|
|
1500
|
+
* @param opts.stop A list of strings to stop the generateText at.
|
|
1501
|
+
* @param opts.model The model to use for generateText.
|
|
1502
|
+
* @param opts.frequency_penalty The frequency penalty to apply to the generateText.
|
|
1503
|
+
* @param opts.presence_penalty The presence penalty to apply to the generateText.
|
|
1504
|
+
* @param opts.temperature The temperature to apply to the generateText.
|
|
1505
|
+
* @param opts.max_context_length The maximum length of the context to apply to the generateText.
|
|
1506
|
+
* @returns The completed message.
|
|
1507
|
+
*/
|
|
1508
|
+
declare function generateMessageResponse({ runtime, context, modelClass, }: {
|
|
1509
|
+
runtime: IAgentRuntime;
|
|
1510
|
+
context: string;
|
|
1511
|
+
modelClass: string;
|
|
1512
|
+
}): Promise<Content>;
|
|
1513
|
+
declare const generateImage: (data: {
|
|
1514
|
+
prompt: string;
|
|
1515
|
+
width: number;
|
|
1516
|
+
height: number;
|
|
1517
|
+
count?: number;
|
|
1518
|
+
negativePrompt?: string;
|
|
1519
|
+
numIterations?: number;
|
|
1520
|
+
guidanceScale?: number;
|
|
1521
|
+
seed?: number;
|
|
1522
|
+
modelId?: string;
|
|
1523
|
+
jobId?: string;
|
|
1524
|
+
}, runtime: IAgentRuntime) => Promise<{
|
|
1525
|
+
success: boolean;
|
|
1526
|
+
data?: string[];
|
|
1527
|
+
error?: any;
|
|
1528
|
+
}>;
|
|
1529
|
+
declare const generateCaption: (data: {
|
|
1530
|
+
imageUrl: string;
|
|
1531
|
+
}, runtime: IAgentRuntime) => Promise<{
|
|
1532
|
+
title: string;
|
|
1533
|
+
description: string;
|
|
1534
|
+
}>;
|
|
1535
|
+
declare const generateWebSearch: (query: string, runtime: IAgentRuntime) => Promise<SearchResponse>;
|
|
1536
|
+
/**
|
|
1537
|
+
* Configuration options for generating objects with a model.
|
|
1538
|
+
*/
|
|
1539
|
+
interface GenerationOptions {
|
|
1540
|
+
runtime: IAgentRuntime;
|
|
1541
|
+
context: string;
|
|
1542
|
+
modelClass: ModelClass;
|
|
1543
|
+
schema?: ZodSchema;
|
|
1544
|
+
schemaName?: string;
|
|
1545
|
+
schemaDescription?: string;
|
|
1546
|
+
stop?: string[];
|
|
1547
|
+
mode?: "auto" | "json" | "tool";
|
|
1548
|
+
experimental_providerMetadata?: Record<string, unknown>;
|
|
1549
|
+
}
|
|
1550
|
+
/**
|
|
1551
|
+
* Base settings for model generation.
|
|
1552
|
+
*/
|
|
1553
|
+
interface ModelSettings {
|
|
1554
|
+
prompt: string;
|
|
1555
|
+
temperature: number;
|
|
1556
|
+
maxTokens: number;
|
|
1557
|
+
frequencyPenalty: number;
|
|
1558
|
+
presencePenalty: number;
|
|
1559
|
+
stop?: string[];
|
|
1560
|
+
}
|
|
1561
|
+
/**
|
|
1562
|
+
* Generates structured objects from a prompt using specified AI models and configuration options.
|
|
1563
|
+
*
|
|
1564
|
+
* @param {GenerationOptions} options - Configuration options for generating objects.
|
|
1565
|
+
* @returns {Promise<any[]>} - A promise that resolves to an array of generated objects.
|
|
1566
|
+
* @throws {Error} - Throws an error if the provider is unsupported or if generation fails.
|
|
1567
|
+
*/
|
|
1568
|
+
declare const generateObject: ({ runtime, context, modelClass, schema, schemaName, schemaDescription, stop, mode, }: GenerationOptions) => Promise<GenerateObjectResult<unknown>>;
|
|
1569
|
+
/**
|
|
1570
|
+
* Interface for provider-specific generation options.
|
|
1571
|
+
*/
|
|
1572
|
+
interface ProviderOptions {
|
|
1573
|
+
runtime: IAgentRuntime;
|
|
1574
|
+
provider: ModelProviderName;
|
|
1575
|
+
model: any;
|
|
1576
|
+
apiKey: string;
|
|
1577
|
+
schema?: ZodSchema;
|
|
1578
|
+
schemaName?: string;
|
|
1579
|
+
schemaDescription?: string;
|
|
1580
|
+
mode?: "auto" | "json" | "tool";
|
|
1581
|
+
experimental_providerMetadata?: Record<string, unknown>;
|
|
1582
|
+
modelOptions: ModelSettings;
|
|
1583
|
+
modelClass: string;
|
|
1584
|
+
context: string;
|
|
1585
|
+
}
|
|
1586
|
+
/**
|
|
1587
|
+
* Handles AI generation based on the specified provider.
|
|
1588
|
+
*
|
|
1589
|
+
* @param {ProviderOptions} options - Configuration options specific to the provider.
|
|
1590
|
+
* @returns {Promise<any[]>} - A promise that resolves to an array of generated objects.
|
|
1591
|
+
*/
|
|
1592
|
+
declare function handleProvider(options: ProviderOptions): Promise<GenerateObjectResult<unknown>>;
|
|
1593
|
+
declare function generateTweetActions({ runtime, context, modelClass, }: {
|
|
1594
|
+
runtime: IAgentRuntime;
|
|
1595
|
+
context: string;
|
|
1596
|
+
modelClass: string;
|
|
1597
|
+
}): Promise<ActionResponse | null>;
|
|
1598
|
+
|
|
1599
|
+
declare const getGoals: ({ runtime, roomId, userId, onlyInProgress, count, }: {
|
|
1600
|
+
runtime: IAgentRuntime;
|
|
1601
|
+
roomId: UUID;
|
|
1602
|
+
userId?: UUID;
|
|
1603
|
+
onlyInProgress?: boolean;
|
|
1604
|
+
count?: number;
|
|
1605
|
+
}) => Promise<Goal[]>;
|
|
1606
|
+
declare const formatGoalsAsString: ({ goals }: {
|
|
1607
|
+
goals: Goal[];
|
|
1608
|
+
}) => string;
|
|
1609
|
+
declare const updateGoal: ({ runtime, goal, }: {
|
|
1610
|
+
runtime: IAgentRuntime;
|
|
1611
|
+
goal: Goal;
|
|
1612
|
+
}) => Promise<void>;
|
|
1613
|
+
declare const createGoal: ({ runtime, goal, }: {
|
|
1614
|
+
runtime: IAgentRuntime;
|
|
1615
|
+
goal: Goal;
|
|
1616
|
+
}) => Promise<void>;
|
|
1617
|
+
|
|
1618
|
+
/**
|
|
1619
|
+
* Manage memories in the database.
|
|
1620
|
+
*/
|
|
1621
|
+
declare class MemoryManager implements IMemoryManager {
|
|
1622
|
+
/**
|
|
1623
|
+
* The AgentRuntime instance associated with this manager.
|
|
1624
|
+
*/
|
|
1625
|
+
runtime: IAgentRuntime;
|
|
1626
|
+
/**
|
|
1627
|
+
* The name of the database table this manager operates on.
|
|
1628
|
+
*/
|
|
1629
|
+
tableName: string;
|
|
1630
|
+
/**
|
|
1631
|
+
* Constructs a new MemoryManager instance.
|
|
1632
|
+
* @param opts Options for the manager.
|
|
1633
|
+
* @param opts.tableName The name of the table this manager will operate on.
|
|
1634
|
+
* @param opts.runtime The AgentRuntime instance associated with this manager.
|
|
1635
|
+
*/
|
|
1636
|
+
constructor(opts: {
|
|
1637
|
+
tableName: string;
|
|
1638
|
+
runtime: IAgentRuntime;
|
|
1639
|
+
});
|
|
1640
|
+
/**
|
|
1641
|
+
* Adds an embedding vector to a memory object. If the memory already has an embedding, it is returned as is.
|
|
1642
|
+
* @param memory The memory object to add an embedding to.
|
|
1643
|
+
* @returns A Promise resolving to the memory object, potentially updated with an embedding vector.
|
|
1644
|
+
*/
|
|
1645
|
+
/**
|
|
1646
|
+
* Adds an embedding vector to a memory object if one doesn't already exist.
|
|
1647
|
+
* The embedding is generated from the memory's text content using the runtime's
|
|
1648
|
+
* embedding model. If the memory has no text content, an error is thrown.
|
|
1649
|
+
*
|
|
1650
|
+
* @param memory The memory object to add an embedding to
|
|
1651
|
+
* @returns The memory object with an embedding vector added
|
|
1652
|
+
* @throws Error if the memory content is empty
|
|
1653
|
+
*/
|
|
1654
|
+
addEmbeddingToMemory(memory: Memory): Promise<Memory>;
|
|
1655
|
+
/**
|
|
1656
|
+
* Retrieves a list of memories by user IDs, with optional deduplication.
|
|
1657
|
+
* @param opts Options including user IDs, count, and uniqueness.
|
|
1658
|
+
* @param opts.roomId The room ID to retrieve memories for.
|
|
1659
|
+
* @param opts.count The number of memories to retrieve.
|
|
1660
|
+
* @param opts.unique Whether to retrieve unique memories only.
|
|
1661
|
+
* @returns A Promise resolving to an array of Memory objects.
|
|
1662
|
+
*/
|
|
1663
|
+
getMemories({ roomId, count, unique, start, end, }: {
|
|
1664
|
+
roomId: UUID;
|
|
1665
|
+
count?: number;
|
|
1666
|
+
unique?: boolean;
|
|
1667
|
+
start?: number;
|
|
1668
|
+
end?: number;
|
|
1669
|
+
}): Promise<Memory[]>;
|
|
1670
|
+
getCachedEmbeddings(content: string): Promise<{
|
|
1671
|
+
embedding: number[];
|
|
1672
|
+
levenshtein_score: number;
|
|
1673
|
+
}[]>;
|
|
1674
|
+
/**
|
|
1675
|
+
* Searches for memories similar to a given embedding vector.
|
|
1676
|
+
* @param embedding The embedding vector to search with.
|
|
1677
|
+
* @param opts Options including match threshold, count, user IDs, and uniqueness.
|
|
1678
|
+
* @param opts.match_threshold The similarity threshold for matching memories.
|
|
1679
|
+
* @param opts.count The maximum number of memories to retrieve.
|
|
1680
|
+
* @param opts.roomId The room ID to retrieve memories for.
|
|
1681
|
+
* @param opts.unique Whether to retrieve unique memories only.
|
|
1682
|
+
* @returns A Promise resolving to an array of Memory objects that match the embedding.
|
|
1683
|
+
*/
|
|
1684
|
+
searchMemoriesByEmbedding(embedding: number[], opts: {
|
|
1685
|
+
match_threshold?: number;
|
|
1686
|
+
count?: number;
|
|
1687
|
+
roomId: UUID;
|
|
1688
|
+
unique?: boolean;
|
|
1689
|
+
}): Promise<Memory[]>;
|
|
1690
|
+
/**
|
|
1691
|
+
* Creates a new memory in the database, with an option to check for similarity before insertion.
|
|
1692
|
+
* @param memory The memory object to create.
|
|
1693
|
+
* @param unique Whether to check for similarity before insertion.
|
|
1694
|
+
* @returns A Promise that resolves when the operation completes.
|
|
1695
|
+
*/
|
|
1696
|
+
createMemory(memory: Memory, unique?: boolean): Promise<void>;
|
|
1697
|
+
getMemoriesByRoomIds(params: {
|
|
1698
|
+
roomIds: UUID[];
|
|
1699
|
+
}): Promise<Memory[]>;
|
|
1700
|
+
getMemoryById(id: UUID): Promise<Memory | null>;
|
|
1701
|
+
/**
|
|
1702
|
+
* Removes a memory from the database by its ID.
|
|
1703
|
+
* @param memoryId The ID of the memory to remove.
|
|
1704
|
+
* @returns A Promise that resolves when the operation completes.
|
|
1705
|
+
*/
|
|
1706
|
+
removeMemory(memoryId: UUID): Promise<void>;
|
|
1707
|
+
/**
|
|
1708
|
+
* Removes all memories associated with a set of user IDs.
|
|
1709
|
+
* @param roomId The room ID to remove memories for.
|
|
1710
|
+
* @returns A Promise that resolves when the operation completes.
|
|
1711
|
+
*/
|
|
1712
|
+
removeAllMemories(roomId: UUID): Promise<void>;
|
|
1713
|
+
/**
|
|
1714
|
+
* Counts the number of memories associated with a set of user IDs, with an option for uniqueness.
|
|
1715
|
+
* @param roomId The room ID to count memories for.
|
|
1716
|
+
* @param unique Whether to count unique memories only.
|
|
1717
|
+
* @returns A Promise resolving to the count of memories.
|
|
1718
|
+
*/
|
|
1719
|
+
countMemories(roomId: UUID, unique?: boolean): Promise<number>;
|
|
1720
|
+
}
|
|
1721
|
+
|
|
1722
|
+
/**
|
|
1723
|
+
* Get details for a list of actors.
|
|
1724
|
+
*/
|
|
1725
|
+
declare function getActorDetails({ runtime, roomId, }: {
|
|
1726
|
+
runtime: IAgentRuntime;
|
|
1727
|
+
roomId: UUID;
|
|
1728
|
+
}): Promise<Actor[]>;
|
|
1729
|
+
/**
|
|
1730
|
+
* Format actors into a string
|
|
1731
|
+
* @param actors - list of actors
|
|
1732
|
+
* @returns string
|
|
1733
|
+
*/
|
|
1734
|
+
declare function formatActors({ actors }: {
|
|
1735
|
+
actors: Actor[];
|
|
1736
|
+
}): string;
|
|
1737
|
+
/**
|
|
1738
|
+
* Format messages into a string
|
|
1739
|
+
* @param messages - list of messages
|
|
1740
|
+
* @param actors - list of actors
|
|
1741
|
+
* @returns string
|
|
1742
|
+
*/
|
|
1743
|
+
declare const formatMessages: ({ messages, actors, }: {
|
|
1744
|
+
messages: Memory[];
|
|
1745
|
+
actors: Actor[];
|
|
1746
|
+
}) => string;
|
|
1747
|
+
declare const formatTimestamp: (messageDate: number) => string;
|
|
1748
|
+
|
|
1749
|
+
declare const models: Models;
|
|
1750
|
+
declare function getModel(provider: ModelProviderName, type: ModelClass): string;
|
|
1751
|
+
declare function getEndpoint(provider: ModelProviderName): string;
|
|
1752
|
+
|
|
1753
|
+
declare const formatPosts: ({ messages, actors, conversationHeader, }: {
|
|
1754
|
+
messages: Memory[];
|
|
1755
|
+
actors: Actor[];
|
|
1756
|
+
conversationHeader?: boolean;
|
|
1757
|
+
}) => string;
|
|
1758
|
+
|
|
1759
|
+
/**
|
|
1760
|
+
* Formats provider outputs into a string which can be injected into the context.
|
|
1761
|
+
* @param runtime The AgentRuntime object.
|
|
1762
|
+
* @param message The incoming message object.
|
|
1763
|
+
* @param state The current state object.
|
|
1764
|
+
* @returns A string that concatenates the outputs of each provider.
|
|
1765
|
+
*/
|
|
1766
|
+
declare function getProviders(runtime: IAgentRuntime, message: Memory, state?: State): Promise<string>;
|
|
1767
|
+
|
|
1768
|
+
declare function createRelationship({ runtime, userA, userB, }: {
|
|
1769
|
+
runtime: IAgentRuntime;
|
|
1770
|
+
userA: UUID;
|
|
1771
|
+
userB: UUID;
|
|
1772
|
+
}): Promise<boolean>;
|
|
1773
|
+
declare function getRelationship({ runtime, userA, userB, }: {
|
|
1774
|
+
runtime: IAgentRuntime;
|
|
1775
|
+
userA: UUID;
|
|
1776
|
+
userB: UUID;
|
|
1777
|
+
}): Promise<Relationship>;
|
|
1778
|
+
declare function getRelationships({ runtime, userId, }: {
|
|
1779
|
+
runtime: IAgentRuntime;
|
|
1780
|
+
userId: UUID;
|
|
1781
|
+
}): Promise<Relationship[]>;
|
|
1782
|
+
declare function formatRelationships({ runtime, userId, }: {
|
|
1783
|
+
runtime: IAgentRuntime;
|
|
1784
|
+
userId: UUID;
|
|
1785
|
+
}): Promise<`${string}-${string}-${string}-${string}-${string}`[]>;
|
|
1786
|
+
|
|
1787
|
+
/**
|
|
1788
|
+
* Represents the runtime environment for an agent, handling message processing,
|
|
1789
|
+
* action registration, and interaction with external services like OpenAI and Supabase.
|
|
1790
|
+
*/
|
|
1791
|
+
declare class AgentRuntime implements IAgentRuntime {
|
|
1792
|
+
#private;
|
|
1793
|
+
/**
|
|
1794
|
+
* The ID of the agent
|
|
1795
|
+
*/
|
|
1796
|
+
agentId: UUID;
|
|
1797
|
+
/**
|
|
1798
|
+
* The base URL of the server where the agent's requests are processed.
|
|
1799
|
+
*/
|
|
1800
|
+
serverUrl: string;
|
|
1801
|
+
/**
|
|
1802
|
+
* The database adapter used for interacting with the database.
|
|
1803
|
+
*/
|
|
1804
|
+
databaseAdapter: IDatabaseAdapter;
|
|
1805
|
+
/**
|
|
1806
|
+
* Authentication token used for securing requests.
|
|
1807
|
+
*/
|
|
1808
|
+
token: string | null;
|
|
1809
|
+
/**
|
|
1810
|
+
* Custom actions that the agent can perform.
|
|
1811
|
+
*/
|
|
1812
|
+
actions: Action[];
|
|
1813
|
+
/**
|
|
1814
|
+
* Evaluators used to assess and guide the agent's responses.
|
|
1815
|
+
*/
|
|
1816
|
+
evaluators: Evaluator[];
|
|
1817
|
+
/**
|
|
1818
|
+
* Context providers used to provide context for message generation.
|
|
1819
|
+
*/
|
|
1820
|
+
providers: Provider[];
|
|
1821
|
+
plugins: Plugin[];
|
|
1822
|
+
/**
|
|
1823
|
+
* The model to use for generateText.
|
|
1824
|
+
*/
|
|
1825
|
+
modelProvider: ModelProviderName;
|
|
1826
|
+
/**
|
|
1827
|
+
* The model to use for generateImage.
|
|
1828
|
+
*/
|
|
1829
|
+
imageModelProvider: ModelProviderName;
|
|
1830
|
+
/**
|
|
1831
|
+
* Fetch function to use
|
|
1832
|
+
* Some environments may not have access to the global fetch function and need a custom fetch override.
|
|
1833
|
+
*/
|
|
1834
|
+
fetch: typeof fetch;
|
|
1835
|
+
/**
|
|
1836
|
+
* The character to use for the agent
|
|
1837
|
+
*/
|
|
1838
|
+
character: Character;
|
|
1839
|
+
/**
|
|
1840
|
+
* Store messages that are sent and received by the agent.
|
|
1841
|
+
*/
|
|
1842
|
+
messageManager: IMemoryManager;
|
|
1843
|
+
/**
|
|
1844
|
+
* Store and recall descriptions of users based on conversations.
|
|
1845
|
+
*/
|
|
1846
|
+
descriptionManager: IMemoryManager;
|
|
1847
|
+
/**
|
|
1848
|
+
* Manage the creation and recall of static information (documents, historical game lore, etc)
|
|
1849
|
+
*/
|
|
1850
|
+
loreManager: IMemoryManager;
|
|
1851
|
+
/**
|
|
1852
|
+
* Hold large documents that can be referenced
|
|
1853
|
+
*/
|
|
1854
|
+
documentsManager: IMemoryManager;
|
|
1855
|
+
/**
|
|
1856
|
+
* Searchable document fragments
|
|
1857
|
+
*/
|
|
1858
|
+
knowledgeManager: IMemoryManager;
|
|
1859
|
+
services: Map<ServiceType, Service>;
|
|
1860
|
+
memoryManagers: Map<string, IMemoryManager>;
|
|
1861
|
+
cacheManager: ICacheManager;
|
|
1862
|
+
clients: Record<string, any>;
|
|
1863
|
+
registerMemoryManager(manager: IMemoryManager): void;
|
|
1864
|
+
getMemoryManager(tableName: string): IMemoryManager | null;
|
|
1865
|
+
getService<T extends Service>(service: ServiceType): T | null;
|
|
1866
|
+
registerService(service: Service): Promise<void>;
|
|
1867
|
+
/**
|
|
1868
|
+
* Creates an instance of AgentRuntime.
|
|
1869
|
+
* @param opts - The options for configuring the AgentRuntime.
|
|
1870
|
+
* @param opts.conversationLength - The number of messages to hold in the recent message cache.
|
|
1871
|
+
* @param opts.token - The JWT token, can be a JWT token if outside worker, or an OpenAI token if inside worker.
|
|
1872
|
+
* @param opts.serverUrl - The URL of the worker.
|
|
1873
|
+
* @param opts.actions - Optional custom actions.
|
|
1874
|
+
* @param opts.evaluators - Optional custom evaluators.
|
|
1875
|
+
* @param opts.services - Optional custom services.
|
|
1876
|
+
* @param opts.memoryManagers - Optional custom memory managers.
|
|
1877
|
+
* @param opts.providers - Optional context providers.
|
|
1878
|
+
* @param opts.model - The model to use for generateText.
|
|
1879
|
+
* @param opts.embeddingModel - The model to use for embedding.
|
|
1880
|
+
* @param opts.agentId - Optional ID of the agent.
|
|
1881
|
+
* @param opts.databaseAdapter - The database adapter used for interacting with the database.
|
|
1882
|
+
* @param opts.fetch - Custom fetch function to use for making requests.
|
|
1883
|
+
*/
|
|
1884
|
+
constructor(opts: {
|
|
1885
|
+
conversationLength?: number;
|
|
1886
|
+
agentId?: UUID;
|
|
1887
|
+
character?: Character;
|
|
1888
|
+
token: string;
|
|
1889
|
+
serverUrl?: string;
|
|
1890
|
+
actions?: Action[];
|
|
1891
|
+
evaluators?: Evaluator[];
|
|
1892
|
+
plugins?: Plugin[];
|
|
1893
|
+
providers?: Provider[];
|
|
1894
|
+
modelProvider: ModelProviderName;
|
|
1895
|
+
services?: Service[];
|
|
1896
|
+
managers?: IMemoryManager[];
|
|
1897
|
+
databaseAdapter: IDatabaseAdapter;
|
|
1898
|
+
fetch?: typeof fetch | unknown;
|
|
1899
|
+
speechModelPath?: string;
|
|
1900
|
+
cacheManager: ICacheManager;
|
|
1901
|
+
logging?: boolean;
|
|
1902
|
+
});
|
|
1903
|
+
initialize(): Promise<void>;
|
|
1904
|
+
stop(): Promise<void>;
|
|
1905
|
+
/**
|
|
1906
|
+
* Processes character knowledge by creating document memories and fragment memories.
|
|
1907
|
+
* This function takes an array of knowledge items, creates a document memory for each item if it doesn't exist,
|
|
1908
|
+
* then chunks the content into fragments, embeds each fragment, and creates fragment memories.
|
|
1909
|
+
* @param knowledge An array of knowledge items containing id, path, and content.
|
|
1910
|
+
*/
|
|
1911
|
+
private processCharacterKnowledge;
|
|
1912
|
+
getSetting(key: string): any;
|
|
1913
|
+
/**
|
|
1914
|
+
* Get the number of messages that are kept in the conversation buffer.
|
|
1915
|
+
* @returns The number of recent messages to be kept in memory.
|
|
1916
|
+
*/
|
|
1917
|
+
getConversationLength(): number;
|
|
1918
|
+
/**
|
|
1919
|
+
* Register an action for the agent to perform.
|
|
1920
|
+
* @param action The action to register.
|
|
1921
|
+
*/
|
|
1922
|
+
registerAction(action: Action): void;
|
|
1923
|
+
/**
|
|
1924
|
+
* Register an evaluator to assess and guide the agent's responses.
|
|
1925
|
+
* @param evaluator The evaluator to register.
|
|
1926
|
+
*/
|
|
1927
|
+
registerEvaluator(evaluator: Evaluator): void;
|
|
1928
|
+
/**
|
|
1929
|
+
* Register a context provider to provide context for message generation.
|
|
1930
|
+
* @param provider The context provider to register.
|
|
1931
|
+
*/
|
|
1932
|
+
registerContextProvider(provider: Provider): void;
|
|
1933
|
+
/**
|
|
1934
|
+
* Process the actions of a message.
|
|
1935
|
+
* @param message The message to process.
|
|
1936
|
+
* @param content The content of the message to process actions from.
|
|
1937
|
+
*/
|
|
1938
|
+
processActions(message: Memory, responses: Memory[], state?: State, callback?: HandlerCallback): Promise<void>;
|
|
1939
|
+
/**
|
|
1940
|
+
* Evaluate the message and state using the registered evaluators.
|
|
1941
|
+
* @param message The message to evaluate.
|
|
1942
|
+
* @param state The state of the agent.
|
|
1943
|
+
* @param didRespond Whether the agent responded to the message.~
|
|
1944
|
+
* @param callback The handler callback
|
|
1945
|
+
* @returns The results of the evaluation.
|
|
1946
|
+
*/
|
|
1947
|
+
evaluate(message: Memory, state?: State, didRespond?: boolean, callback?: HandlerCallback): Promise<string[]>;
|
|
1948
|
+
/**
|
|
1949
|
+
* Ensure the existence of a participant in the room. If the participant does not exist, they are added to the room.
|
|
1950
|
+
* @param userId - The user ID to ensure the existence of.
|
|
1951
|
+
* @throws An error if the participant cannot be added.
|
|
1952
|
+
*/
|
|
1953
|
+
ensureParticipantExists(userId: UUID, roomId: UUID): Promise<void>;
|
|
1954
|
+
/**
|
|
1955
|
+
* Ensure the existence of a user in the database. If the user does not exist, they are added to the database.
|
|
1956
|
+
* @param userId - The user ID to ensure the existence of.
|
|
1957
|
+
* @param userName - The user name to ensure the existence of.
|
|
1958
|
+
* @returns
|
|
1959
|
+
*/
|
|
1960
|
+
ensureUserExists(userId: UUID, userName: string | null, name: string | null, email?: string | null, source?: string | null): Promise<void>;
|
|
1961
|
+
ensureParticipantInRoom(userId: UUID, roomId: UUID): Promise<void>;
|
|
1962
|
+
ensureConnection(userId: UUID, roomId: UUID, userName?: string, userScreenName?: string, source?: string): Promise<void>;
|
|
1963
|
+
/**
|
|
1964
|
+
* Ensure the existence of a room between the agent and a user. If no room exists, a new room is created and the user
|
|
1965
|
+
* and agent are added as participants. The room ID is returned.
|
|
1966
|
+
* @param userId - The user ID to create a room with.
|
|
1967
|
+
* @returns The room ID of the room between the agent and the user.
|
|
1968
|
+
* @throws An error if the room cannot be created.
|
|
1969
|
+
*/
|
|
1970
|
+
ensureRoomExists(roomId: UUID): Promise<void>;
|
|
1971
|
+
/**
|
|
1972
|
+
* Compose the state of the agent into an object that can be passed or used for response generation.
|
|
1973
|
+
* @param message The message to compose the state from.
|
|
1974
|
+
* @returns The state of the agent.
|
|
1975
|
+
*/
|
|
1976
|
+
composeState(message: Memory, additionalKeys?: {
|
|
1977
|
+
[key: string]: unknown;
|
|
1978
|
+
}): Promise<State>;
|
|
1979
|
+
updateRecentMessageState(state: State): Promise<State>;
|
|
1980
|
+
}
|
|
1981
|
+
|
|
1982
|
+
interface Settings {
|
|
1983
|
+
[key: string]: string | undefined;
|
|
1984
|
+
}
|
|
1985
|
+
/**
|
|
1986
|
+
* Recursively searches for a .env file starting from the current directory
|
|
1987
|
+
* and moving up through parent directories (Node.js only)
|
|
1988
|
+
* @param {string} [startDir=process.cwd()] - Starting directory for the search
|
|
1989
|
+
* @returns {string|null} Path to the nearest .env file or null if not found
|
|
1990
|
+
*/
|
|
1991
|
+
declare function findNearestEnvFile(startDir?: string): string;
|
|
1992
|
+
/**
|
|
1993
|
+
* Configures environment settings for browser usage
|
|
1994
|
+
* @param {Settings} settings - Object containing environment variables
|
|
1995
|
+
*/
|
|
1996
|
+
declare function configureSettings(settings: Settings): void;
|
|
1997
|
+
/**
|
|
1998
|
+
* Loads environment variables from the nearest .env file in Node.js
|
|
1999
|
+
* or returns configured settings in browser
|
|
2000
|
+
* @returns {Settings} Environment variables object
|
|
2001
|
+
* @throws {Error} If no .env file is found in Node.js environment
|
|
2002
|
+
*/
|
|
2003
|
+
declare function loadEnvConfig(): Settings;
|
|
2004
|
+
/**
|
|
2005
|
+
* Gets a specific environment variable
|
|
2006
|
+
* @param {string} key - The environment variable key
|
|
2007
|
+
* @param {string} [defaultValue] - Optional default value if key doesn't exist
|
|
2008
|
+
* @returns {string|undefined} The environment variable value or default value
|
|
2009
|
+
*/
|
|
2010
|
+
declare function getEnvVariable(key: string, defaultValue?: string): string | undefined;
|
|
2011
|
+
/**
|
|
2012
|
+
* Checks if a specific environment variable exists
|
|
2013
|
+
* @param {string} key - The environment variable key
|
|
2014
|
+
* @returns {boolean} True if the environment variable exists
|
|
2015
|
+
*/
|
|
2016
|
+
declare function hasEnvVariable(key: string): boolean;
|
|
2017
|
+
declare const settings: Settings;
|
|
2018
|
+
|
|
2019
|
+
declare class ElizaLogger {
|
|
2020
|
+
#private;
|
|
2021
|
+
constructor();
|
|
2022
|
+
private isNode;
|
|
2023
|
+
verbose: boolean;
|
|
2024
|
+
closeByNewLine: boolean;
|
|
2025
|
+
useIcons: boolean;
|
|
2026
|
+
logsTitle: string;
|
|
2027
|
+
warningsTitle: string;
|
|
2028
|
+
errorsTitle: string;
|
|
2029
|
+
informationsTitle: string;
|
|
2030
|
+
successesTitle: string;
|
|
2031
|
+
debugsTitle: string;
|
|
2032
|
+
assertsTitle: string;
|
|
2033
|
+
clear(): void;
|
|
2034
|
+
print(foregroundColor?: string, backgroundColor?: string, ...strings: any[]): void;
|
|
2035
|
+
log(...strings: any[]): void;
|
|
2036
|
+
warn(...strings: any[]): void;
|
|
2037
|
+
error(...strings: any[]): void;
|
|
2038
|
+
info(...strings: any[]): void;
|
|
2039
|
+
debug(...strings: any[]): void;
|
|
2040
|
+
success(...strings: any[]): void;
|
|
2041
|
+
assert(...strings: any[]): void;
|
|
2042
|
+
progress(message: string): void;
|
|
2043
|
+
}
|
|
2044
|
+
declare const elizaLogger: ElizaLogger;
|
|
2045
|
+
|
|
2046
|
+
declare const messageCompletionFooter = "\nResponse format should be formatted in a JSON block like this:\n```json\n{ \"user\": \"{{agentName}}\", \"text\": \"string\", \"action\": \"string\" }\n```";
|
|
2047
|
+
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.";
|
|
2048
|
+
declare const parseShouldRespondFromText: (text: string) => "RESPOND" | "IGNORE" | "STOP" | null;
|
|
2049
|
+
declare const booleanFooter = "Respond with a YES or a NO.";
|
|
2050
|
+
declare const parseBooleanFromText: (text: string) => boolean;
|
|
2051
|
+
declare const stringArrayFooter = "Respond with a JSON array containing the values in a JSON block formatted for markdown with this structure:\n```json\n[\n 'value',\n 'value'\n]\n```\n\nYour response must include the JSON block.";
|
|
2052
|
+
/**
|
|
2053
|
+
* Parses a JSON array from a given text. The function looks for a JSON block wrapped in triple backticks
|
|
2054
|
+
* with `json` language identifier, and if not found, it searches for an array pattern within the text.
|
|
2055
|
+
* It then attempts to parse the JSON string into a JavaScript object. If parsing is successful and the result
|
|
2056
|
+
* is an array, it returns the array; otherwise, it returns null.
|
|
2057
|
+
*
|
|
2058
|
+
* @param text - The input text from which to extract and parse the JSON array.
|
|
2059
|
+
* @returns An array parsed from the JSON string if successful; otherwise, null.
|
|
2060
|
+
*/
|
|
2061
|
+
declare function parseJsonArrayFromText(text: string): any[];
|
|
2062
|
+
/**
|
|
2063
|
+
* Parses a JSON object from a given text. The function looks for a JSON block wrapped in triple backticks
|
|
2064
|
+
* with `json` language identifier, and if not found, it searches for an object pattern within the text.
|
|
2065
|
+
* It then attempts to parse the JSON string into a JavaScript object. If parsing is successful and the result
|
|
2066
|
+
* is an object (but not an array), it returns the object; otherwise, it tries to parse an array if the result
|
|
2067
|
+
* is an array, or returns null if parsing is unsuccessful or the result is neither an object nor an array.
|
|
2068
|
+
*
|
|
2069
|
+
* @param text - The input text from which to extract and parse the JSON object.
|
|
2070
|
+
* @returns An object parsed from the JSON string if successful; otherwise, null or the result of parsing an array.
|
|
2071
|
+
*/
|
|
2072
|
+
declare function parseJSONObjectFromText(text: string): Record<string, any> | null;
|
|
2073
|
+
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.";
|
|
2074
|
+
declare const parseActionResponseFromText: (text: string) => {
|
|
2075
|
+
actions: ActionResponse;
|
|
2076
|
+
};
|
|
2077
|
+
|
|
2078
|
+
declare function stringToUuid(target: string | number): UUID;
|
|
2079
|
+
|
|
2080
|
+
declare const envSchema: z.ZodObject<{
|
|
2081
|
+
OPENAI_API_KEY: z.ZodString;
|
|
2082
|
+
REDPILL_API_KEY: z.ZodString;
|
|
2083
|
+
GROK_API_KEY: z.ZodString;
|
|
2084
|
+
GROQ_API_KEY: z.ZodString;
|
|
2085
|
+
OPENROUTER_API_KEY: z.ZodString;
|
|
2086
|
+
GOOGLE_GENERATIVE_AI_API_KEY: z.ZodString;
|
|
2087
|
+
ELEVENLABS_XI_API_KEY: z.ZodString;
|
|
2088
|
+
}, "strip", z.ZodTypeAny, {
|
|
2089
|
+
OPENAI_API_KEY?: string;
|
|
2090
|
+
REDPILL_API_KEY?: string;
|
|
2091
|
+
GROK_API_KEY?: string;
|
|
2092
|
+
GROQ_API_KEY?: string;
|
|
2093
|
+
OPENROUTER_API_KEY?: string;
|
|
2094
|
+
GOOGLE_GENERATIVE_AI_API_KEY?: string;
|
|
2095
|
+
ELEVENLABS_XI_API_KEY?: string;
|
|
2096
|
+
}, {
|
|
2097
|
+
OPENAI_API_KEY?: string;
|
|
2098
|
+
REDPILL_API_KEY?: string;
|
|
2099
|
+
GROK_API_KEY?: string;
|
|
2100
|
+
GROQ_API_KEY?: string;
|
|
2101
|
+
OPENROUTER_API_KEY?: string;
|
|
2102
|
+
GOOGLE_GENERATIVE_AI_API_KEY?: string;
|
|
2103
|
+
ELEVENLABS_XI_API_KEY?: string;
|
|
2104
|
+
}>;
|
|
2105
|
+
type EnvConfig = z.infer<typeof envSchema>;
|
|
2106
|
+
declare function validateEnv(): EnvConfig;
|
|
2107
|
+
declare const CharacterSchema: z.ZodObject<{
|
|
2108
|
+
id: z.ZodOptional<z.ZodString>;
|
|
2109
|
+
name: z.ZodString;
|
|
2110
|
+
system: z.ZodOptional<z.ZodString>;
|
|
2111
|
+
modelProvider: z.ZodNativeEnum<typeof ModelProviderName>;
|
|
2112
|
+
modelEndpointOverride: z.ZodOptional<z.ZodString>;
|
|
2113
|
+
templates: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
2114
|
+
bio: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
|
|
2115
|
+
lore: z.ZodArray<z.ZodString, "many">;
|
|
2116
|
+
messageExamples: z.ZodArray<z.ZodArray<z.ZodObject<{
|
|
2117
|
+
user: z.ZodString;
|
|
2118
|
+
content: z.ZodIntersection<z.ZodObject<{
|
|
2119
|
+
text: z.ZodString;
|
|
2120
|
+
action: z.ZodOptional<z.ZodString>;
|
|
2121
|
+
source: z.ZodOptional<z.ZodString>;
|
|
2122
|
+
url: z.ZodOptional<z.ZodString>;
|
|
2123
|
+
inReplyTo: z.ZodOptional<z.ZodString>;
|
|
2124
|
+
attachments: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
|
|
2125
|
+
}, "strip", z.ZodTypeAny, {
|
|
2126
|
+
text?: string;
|
|
2127
|
+
action?: string;
|
|
2128
|
+
source?: string;
|
|
2129
|
+
url?: string;
|
|
2130
|
+
inReplyTo?: string;
|
|
2131
|
+
attachments?: any[];
|
|
2132
|
+
}, {
|
|
2133
|
+
text?: string;
|
|
2134
|
+
action?: string;
|
|
2135
|
+
source?: string;
|
|
2136
|
+
url?: string;
|
|
2137
|
+
inReplyTo?: string;
|
|
2138
|
+
attachments?: any[];
|
|
2139
|
+
}>, z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
2140
|
+
}, "strip", z.ZodTypeAny, {
|
|
2141
|
+
content?: {
|
|
2142
|
+
text?: string;
|
|
2143
|
+
action?: string;
|
|
2144
|
+
source?: string;
|
|
2145
|
+
url?: string;
|
|
2146
|
+
inReplyTo?: string;
|
|
2147
|
+
attachments?: any[];
|
|
2148
|
+
} & Record<string, unknown>;
|
|
2149
|
+
user?: string;
|
|
2150
|
+
}, {
|
|
2151
|
+
content?: {
|
|
2152
|
+
text?: string;
|
|
2153
|
+
action?: string;
|
|
2154
|
+
source?: string;
|
|
2155
|
+
url?: string;
|
|
2156
|
+
inReplyTo?: string;
|
|
2157
|
+
attachments?: any[];
|
|
2158
|
+
} & Record<string, unknown>;
|
|
2159
|
+
user?: string;
|
|
2160
|
+
}>, "many">, "many">;
|
|
2161
|
+
postExamples: z.ZodArray<z.ZodString, "many">;
|
|
2162
|
+
topics: z.ZodArray<z.ZodString, "many">;
|
|
2163
|
+
adjectives: z.ZodArray<z.ZodString, "many">;
|
|
2164
|
+
knowledge: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
2165
|
+
clients: z.ZodArray<z.ZodNativeEnum<typeof Clients>, "many">;
|
|
2166
|
+
plugins: z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodArray<z.ZodObject<{
|
|
2167
|
+
name: z.ZodString;
|
|
2168
|
+
description: z.ZodString;
|
|
2169
|
+
actions: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
|
|
2170
|
+
providers: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
|
|
2171
|
+
evaluators: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
|
|
2172
|
+
services: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
|
|
2173
|
+
clients: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
|
|
2174
|
+
}, "strip", z.ZodTypeAny, {
|
|
2175
|
+
actions?: any[];
|
|
2176
|
+
providers?: any[];
|
|
2177
|
+
description?: string;
|
|
2178
|
+
name?: string;
|
|
2179
|
+
evaluators?: any[];
|
|
2180
|
+
services?: any[];
|
|
2181
|
+
clients?: any[];
|
|
2182
|
+
}, {
|
|
2183
|
+
actions?: any[];
|
|
2184
|
+
providers?: any[];
|
|
2185
|
+
description?: string;
|
|
2186
|
+
name?: string;
|
|
2187
|
+
evaluators?: any[];
|
|
2188
|
+
services?: any[];
|
|
2189
|
+
clients?: any[];
|
|
2190
|
+
}>, "many">]>;
|
|
2191
|
+
settings: z.ZodOptional<z.ZodObject<{
|
|
2192
|
+
secrets: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
2193
|
+
voice: z.ZodOptional<z.ZodObject<{
|
|
2194
|
+
model: z.ZodOptional<z.ZodString>;
|
|
2195
|
+
url: z.ZodOptional<z.ZodString>;
|
|
2196
|
+
}, "strip", z.ZodTypeAny, {
|
|
2197
|
+
url?: string;
|
|
2198
|
+
model?: string;
|
|
2199
|
+
}, {
|
|
2200
|
+
url?: string;
|
|
2201
|
+
model?: string;
|
|
2202
|
+
}>>;
|
|
2203
|
+
model: z.ZodOptional<z.ZodString>;
|
|
2204
|
+
embeddingModel: z.ZodOptional<z.ZodString>;
|
|
2205
|
+
}, "strip", z.ZodTypeAny, {
|
|
2206
|
+
model?: string;
|
|
2207
|
+
secrets?: Record<string, string>;
|
|
2208
|
+
voice?: {
|
|
2209
|
+
url?: string;
|
|
2210
|
+
model?: string;
|
|
2211
|
+
};
|
|
2212
|
+
embeddingModel?: string;
|
|
2213
|
+
}, {
|
|
2214
|
+
model?: string;
|
|
2215
|
+
secrets?: Record<string, string>;
|
|
2216
|
+
voice?: {
|
|
2217
|
+
url?: string;
|
|
2218
|
+
model?: string;
|
|
2219
|
+
};
|
|
2220
|
+
embeddingModel?: string;
|
|
2221
|
+
}>>;
|
|
2222
|
+
clientConfig: z.ZodOptional<z.ZodObject<{
|
|
2223
|
+
discord: z.ZodOptional<z.ZodObject<{
|
|
2224
|
+
shouldIgnoreBotMessages: z.ZodOptional<z.ZodBoolean>;
|
|
2225
|
+
shouldIgnoreDirectMessages: z.ZodOptional<z.ZodBoolean>;
|
|
2226
|
+
}, "strip", z.ZodTypeAny, {
|
|
2227
|
+
shouldIgnoreBotMessages?: boolean;
|
|
2228
|
+
shouldIgnoreDirectMessages?: boolean;
|
|
2229
|
+
}, {
|
|
2230
|
+
shouldIgnoreBotMessages?: boolean;
|
|
2231
|
+
shouldIgnoreDirectMessages?: boolean;
|
|
2232
|
+
}>>;
|
|
2233
|
+
telegram: z.ZodOptional<z.ZodObject<{
|
|
2234
|
+
shouldIgnoreBotMessages: z.ZodOptional<z.ZodBoolean>;
|
|
2235
|
+
shouldIgnoreDirectMessages: z.ZodOptional<z.ZodBoolean>;
|
|
2236
|
+
}, "strip", z.ZodTypeAny, {
|
|
2237
|
+
shouldIgnoreBotMessages?: boolean;
|
|
2238
|
+
shouldIgnoreDirectMessages?: boolean;
|
|
2239
|
+
}, {
|
|
2240
|
+
shouldIgnoreBotMessages?: boolean;
|
|
2241
|
+
shouldIgnoreDirectMessages?: boolean;
|
|
2242
|
+
}>>;
|
|
2243
|
+
}, "strip", z.ZodTypeAny, {
|
|
2244
|
+
discord?: {
|
|
2245
|
+
shouldIgnoreBotMessages?: boolean;
|
|
2246
|
+
shouldIgnoreDirectMessages?: boolean;
|
|
2247
|
+
};
|
|
2248
|
+
telegram?: {
|
|
2249
|
+
shouldIgnoreBotMessages?: boolean;
|
|
2250
|
+
shouldIgnoreDirectMessages?: boolean;
|
|
2251
|
+
};
|
|
2252
|
+
}, {
|
|
2253
|
+
discord?: {
|
|
2254
|
+
shouldIgnoreBotMessages?: boolean;
|
|
2255
|
+
shouldIgnoreDirectMessages?: boolean;
|
|
2256
|
+
};
|
|
2257
|
+
telegram?: {
|
|
2258
|
+
shouldIgnoreBotMessages?: boolean;
|
|
2259
|
+
shouldIgnoreDirectMessages?: boolean;
|
|
2260
|
+
};
|
|
2261
|
+
}>>;
|
|
2262
|
+
style: z.ZodObject<{
|
|
2263
|
+
all: z.ZodArray<z.ZodString, "many">;
|
|
2264
|
+
chat: z.ZodArray<z.ZodString, "many">;
|
|
2265
|
+
post: z.ZodArray<z.ZodString, "many">;
|
|
2266
|
+
}, "strip", z.ZodTypeAny, {
|
|
2267
|
+
all?: string[];
|
|
2268
|
+
chat?: string[];
|
|
2269
|
+
post?: string[];
|
|
2270
|
+
}, {
|
|
2271
|
+
all?: string[];
|
|
2272
|
+
chat?: string[];
|
|
2273
|
+
post?: string[];
|
|
2274
|
+
}>;
|
|
2275
|
+
twitterProfile: z.ZodOptional<z.ZodObject<{
|
|
2276
|
+
username: z.ZodString;
|
|
2277
|
+
screenName: z.ZodString;
|
|
2278
|
+
bio: z.ZodString;
|
|
2279
|
+
nicknames: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
2280
|
+
}, "strip", z.ZodTypeAny, {
|
|
2281
|
+
bio?: string;
|
|
2282
|
+
username?: string;
|
|
2283
|
+
screenName?: string;
|
|
2284
|
+
nicknames?: string[];
|
|
2285
|
+
}, {
|
|
2286
|
+
bio?: string;
|
|
2287
|
+
username?: string;
|
|
2288
|
+
screenName?: string;
|
|
2289
|
+
nicknames?: string[];
|
|
2290
|
+
}>>;
|
|
2291
|
+
nft: z.ZodOptional<z.ZodObject<{
|
|
2292
|
+
prompt: z.ZodOptional<z.ZodString>;
|
|
2293
|
+
}, "strip", z.ZodTypeAny, {
|
|
2294
|
+
prompt?: string;
|
|
2295
|
+
}, {
|
|
2296
|
+
prompt?: string;
|
|
2297
|
+
}>>;
|
|
2298
|
+
}, "strip", z.ZodTypeAny, {
|
|
2299
|
+
bio?: string | string[];
|
|
2300
|
+
lore?: string[];
|
|
2301
|
+
knowledge?: string[];
|
|
2302
|
+
system?: string;
|
|
2303
|
+
id?: string;
|
|
2304
|
+
name?: string;
|
|
2305
|
+
topics?: string[];
|
|
2306
|
+
clients?: Clients[];
|
|
2307
|
+
modelProvider?: ModelProviderName;
|
|
2308
|
+
modelEndpointOverride?: string;
|
|
2309
|
+
templates?: Record<string, string>;
|
|
2310
|
+
messageExamples?: {
|
|
2311
|
+
content?: {
|
|
2312
|
+
text?: string;
|
|
2313
|
+
action?: string;
|
|
2314
|
+
source?: string;
|
|
2315
|
+
url?: string;
|
|
2316
|
+
inReplyTo?: string;
|
|
2317
|
+
attachments?: any[];
|
|
2318
|
+
} & Record<string, unknown>;
|
|
2319
|
+
user?: string;
|
|
2320
|
+
}[][];
|
|
2321
|
+
postExamples?: string[];
|
|
2322
|
+
adjectives?: string[];
|
|
2323
|
+
plugins?: string[] | {
|
|
2324
|
+
actions?: any[];
|
|
2325
|
+
providers?: any[];
|
|
2326
|
+
description?: string;
|
|
2327
|
+
name?: string;
|
|
2328
|
+
evaluators?: any[];
|
|
2329
|
+
services?: any[];
|
|
2330
|
+
clients?: any[];
|
|
2331
|
+
}[];
|
|
2332
|
+
settings?: {
|
|
2333
|
+
model?: string;
|
|
2334
|
+
secrets?: Record<string, string>;
|
|
2335
|
+
voice?: {
|
|
2336
|
+
url?: string;
|
|
2337
|
+
model?: string;
|
|
2338
|
+
};
|
|
2339
|
+
embeddingModel?: string;
|
|
2340
|
+
};
|
|
2341
|
+
clientConfig?: {
|
|
2342
|
+
discord?: {
|
|
2343
|
+
shouldIgnoreBotMessages?: boolean;
|
|
2344
|
+
shouldIgnoreDirectMessages?: boolean;
|
|
2345
|
+
};
|
|
2346
|
+
telegram?: {
|
|
2347
|
+
shouldIgnoreBotMessages?: boolean;
|
|
2348
|
+
shouldIgnoreDirectMessages?: boolean;
|
|
2349
|
+
};
|
|
2350
|
+
};
|
|
2351
|
+
style?: {
|
|
2352
|
+
all?: string[];
|
|
2353
|
+
chat?: string[];
|
|
2354
|
+
post?: string[];
|
|
2355
|
+
};
|
|
2356
|
+
twitterProfile?: {
|
|
2357
|
+
bio?: string;
|
|
2358
|
+
username?: string;
|
|
2359
|
+
screenName?: string;
|
|
2360
|
+
nicknames?: string[];
|
|
2361
|
+
};
|
|
2362
|
+
nft?: {
|
|
2363
|
+
prompt?: string;
|
|
2364
|
+
};
|
|
2365
|
+
}, {
|
|
2366
|
+
bio?: string | string[];
|
|
2367
|
+
lore?: string[];
|
|
2368
|
+
knowledge?: string[];
|
|
2369
|
+
system?: string;
|
|
2370
|
+
id?: string;
|
|
2371
|
+
name?: string;
|
|
2372
|
+
topics?: string[];
|
|
2373
|
+
clients?: Clients[];
|
|
2374
|
+
modelProvider?: ModelProviderName;
|
|
2375
|
+
modelEndpointOverride?: string;
|
|
2376
|
+
templates?: Record<string, string>;
|
|
2377
|
+
messageExamples?: {
|
|
2378
|
+
content?: {
|
|
2379
|
+
text?: string;
|
|
2380
|
+
action?: string;
|
|
2381
|
+
source?: string;
|
|
2382
|
+
url?: string;
|
|
2383
|
+
inReplyTo?: string;
|
|
2384
|
+
attachments?: any[];
|
|
2385
|
+
} & Record<string, unknown>;
|
|
2386
|
+
user?: string;
|
|
2387
|
+
}[][];
|
|
2388
|
+
postExamples?: string[];
|
|
2389
|
+
adjectives?: string[];
|
|
2390
|
+
plugins?: string[] | {
|
|
2391
|
+
actions?: any[];
|
|
2392
|
+
providers?: any[];
|
|
2393
|
+
description?: string;
|
|
2394
|
+
name?: string;
|
|
2395
|
+
evaluators?: any[];
|
|
2396
|
+
services?: any[];
|
|
2397
|
+
clients?: any[];
|
|
2398
|
+
}[];
|
|
2399
|
+
settings?: {
|
|
2400
|
+
model?: string;
|
|
2401
|
+
secrets?: Record<string, string>;
|
|
2402
|
+
voice?: {
|
|
2403
|
+
url?: string;
|
|
2404
|
+
model?: string;
|
|
2405
|
+
};
|
|
2406
|
+
embeddingModel?: string;
|
|
2407
|
+
};
|
|
2408
|
+
clientConfig?: {
|
|
2409
|
+
discord?: {
|
|
2410
|
+
shouldIgnoreBotMessages?: boolean;
|
|
2411
|
+
shouldIgnoreDirectMessages?: boolean;
|
|
2412
|
+
};
|
|
2413
|
+
telegram?: {
|
|
2414
|
+
shouldIgnoreBotMessages?: boolean;
|
|
2415
|
+
shouldIgnoreDirectMessages?: boolean;
|
|
2416
|
+
};
|
|
2417
|
+
};
|
|
2418
|
+
style?: {
|
|
2419
|
+
all?: string[];
|
|
2420
|
+
chat?: string[];
|
|
2421
|
+
post?: string[];
|
|
2422
|
+
};
|
|
2423
|
+
twitterProfile?: {
|
|
2424
|
+
bio?: string;
|
|
2425
|
+
username?: string;
|
|
2426
|
+
screenName?: string;
|
|
2427
|
+
nicknames?: string[];
|
|
2428
|
+
};
|
|
2429
|
+
nft?: {
|
|
2430
|
+
prompt?: string;
|
|
2431
|
+
};
|
|
2432
|
+
}>;
|
|
2433
|
+
type CharacterConfig = z.infer<typeof CharacterSchema>;
|
|
2434
|
+
declare function validateCharacterConfig(json: unknown): CharacterConfig;
|
|
2435
|
+
|
|
2436
|
+
interface ICacheAdapter {
|
|
2437
|
+
get(key: string): Promise<string | undefined>;
|
|
2438
|
+
set(key: string, value: string): Promise<void>;
|
|
2439
|
+
delete(key: string): Promise<void>;
|
|
2440
|
+
}
|
|
2441
|
+
declare class MemoryCacheAdapter implements ICacheAdapter {
|
|
2442
|
+
data: Map<string, string>;
|
|
2443
|
+
constructor(initalData?: Map<string, string>);
|
|
2444
|
+
get(key: string): Promise<string | undefined>;
|
|
2445
|
+
set(key: string, value: string): Promise<void>;
|
|
2446
|
+
delete(key: string): Promise<void>;
|
|
2447
|
+
}
|
|
2448
|
+
declare class FsCacheAdapter implements ICacheAdapter {
|
|
2449
|
+
private dataDir;
|
|
2450
|
+
constructor(dataDir: string);
|
|
2451
|
+
get(key: string): Promise<string | undefined>;
|
|
2452
|
+
set(key: string, value: string): Promise<void>;
|
|
2453
|
+
delete(key: string): Promise<void>;
|
|
2454
|
+
}
|
|
2455
|
+
declare class DbCacheAdapter implements ICacheAdapter {
|
|
2456
|
+
private db;
|
|
2457
|
+
private agentId;
|
|
2458
|
+
constructor(db: IDatabaseCacheAdapter, agentId: UUID);
|
|
2459
|
+
get(key: string): Promise<string | undefined>;
|
|
2460
|
+
set(key: string, value: string): Promise<void>;
|
|
2461
|
+
delete(key: string): Promise<void>;
|
|
2462
|
+
}
|
|
2463
|
+
declare class CacheManager<CacheAdapter extends ICacheAdapter = ICacheAdapter> implements ICacheManager {
|
|
2464
|
+
adapter: CacheAdapter;
|
|
2465
|
+
constructor(adapter: CacheAdapter);
|
|
2466
|
+
get<T = unknown>(key: string): Promise<T | undefined>;
|
|
2467
|
+
set<T>(key: string, value: T, opts?: CacheOptions): Promise<void>;
|
|
2468
|
+
delete(key: string): Promise<void>;
|
|
2469
|
+
}
|
|
2470
|
+
|
|
2471
|
+
declare function get(runtime: AgentRuntime, message: Memory): Promise<KnowledgeItem[]>;
|
|
2472
|
+
declare function set(runtime: AgentRuntime, item: KnowledgeItem, chunkSize?: number, bleed?: number): Promise<void>;
|
|
2473
|
+
declare function preprocess(content: string): string;
|
|
2474
|
+
declare const _default: {
|
|
2475
|
+
get: typeof get;
|
|
2476
|
+
set: typeof set;
|
|
2477
|
+
preprocess: typeof preprocess;
|
|
2478
|
+
};
|
|
2479
|
+
|
|
2480
|
+
export { type Account, type Action, type ActionExample, type ActionResponse, type Actor, AgentRuntime, CacheManager, type CacheOptions, CacheStore, type Character, type CharacterConfig, CharacterSchema, type Client, Clients, type Content, type ConversationExample, DatabaseAdapter, DbCacheAdapter, type EnvConfig, type EvaluationExample, type Evaluator, FsCacheAdapter, type GenerationOptions, type Goal, GoalStatus, type Handler, type HandlerCallback, type IAgentConfig, type IAgentRuntime, type IAwsS3Service, type IBrowserService, type ICacheAdapter, type ICacheManager, type IDatabaseAdapter, type IDatabaseCacheAdapter, type IImageDescriptionService, type IMemoryManager, type IPdfService, type ISlackService, type ISpeechService, type ITextGenerationService, type ITranscriptionService, type IVideoService, type KnowledgeItem, LoggingLevel, type Media, type Memory, MemoryCacheAdapter, MemoryManager, type MessageExample, type Model, ModelClass, ModelProviderName, type Models, type Objective, type Participant, type Plugin, type Provider, type Relationship, type Room, type SearchResponse, type SearchResult, Service, ServiceType, type State, type UUID, type Validator, addHeader, booleanFooter, composeActionExamples, composeContext, configureSettings, createGoal, createRelationship, defaultCharacter, elizaLogger, embed, envSchema, evaluationTemplate, findNearestEnvFile, formatActionNames, formatActions, formatActors, formatEvaluatorExampleDescriptions, formatEvaluatorExamples, formatEvaluatorNames, formatEvaluators, formatGoalsAsString, formatMessages, formatPosts, formatRelationships, formatTimestamp, generateCaption, generateImage, generateMessageResponse, generateObject, generateObjectArray, generateObjectDeprecated, generateShouldRespond, generateText, generateTextArray, generateTrueOrFalse, generateTweetActions, generateWebSearch, getActorDetails, getEmbeddingConfig, getEmbeddingType, getEmbeddingZeroVector, getEndpoint, getEnvVariable, getGoals, getModel, getProviders, getRelationship, getRelationships, handleProvider, hasEnvVariable, _default as knowledge, loadEnvConfig, messageCompletionFooter, models, parseActionResponseFromText, parseBooleanFromText, parseJSONObjectFromText, parseJsonArrayFromText, parseShouldRespondFromText, postActionResponseFooter, settings, shouldRespondFooter, splitChunks, stringArrayFooter, stringToUuid, trimTokens, updateGoal, validateCharacterConfig, validateEnv };
|