@elizaos/core 1.3.1 → 1.4.2
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/README.md +1 -1
- package/dist/index.d.ts +1975 -21
- package/dist/index.js +4899 -116
- package/package.json +2 -15
- package/dist/chunk-2HSL25IJ.js +0 -40
- package/dist/chunk-JX2SRFHQ.js +0 -59
- package/dist/chunk-P3YTG22Y.js +0 -6353
- package/dist/chunk-R5U7XKVJ.js +0 -16
- package/dist/chunk-U2ADTLZY.js +0 -50
- package/dist/chunk-WO7Z3GE6.js +0 -158
- package/dist/chunk-YIBXLDIR.js +0 -42
- package/dist/index-BHW44X0A.d.ts +0 -112
- package/dist/index-DQlJZj2X.d.ts +0 -3066
- package/dist/specs/v1/actionExample.d.ts +0 -41
- package/dist/specs/v1/actionExample.js +0 -13
- package/dist/specs/v1/index.d.ts +0 -11
- package/dist/specs/v1/index.js +0 -81
- package/dist/specs/v1/messages.d.ts +0 -32
- package/dist/specs/v1/messages.js +0 -18
- package/dist/specs/v1/posts.d.ts +0 -10
- package/dist/specs/v1/posts.js +0 -12
- package/dist/specs/v1/provider.d.ts +0 -21
- package/dist/specs/v1/provider.js +0 -10
- package/dist/specs/v1/runtime.d.ts +0 -146
- package/dist/specs/v1/runtime.js +0 -12
- package/dist/specs/v1/state.d.ts +0 -21
- package/dist/specs/v1/state.js +0 -9
- package/dist/specs/v1/templates.d.ts +0 -42
- package/dist/specs/v1/templates.js +0 -11
- package/dist/specs/v1/types.d.ts +0 -1261
- package/dist/specs/v1/types.js +0 -33
- package/dist/specs/v1/uuid.d.ts +0 -27
- package/dist/specs/v1/uuid.js +0 -14
- package/dist/specs/v2/index.d.ts +0 -2
- package/dist/specs/v2/index.js +0 -169
- package/dist/types-DIUaglro.d.ts +0 -1964
package/dist/types-DIUaglro.d.ts
DELETED
|
@@ -1,1964 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Defines a custom type UUID representing a universally unique identifier
|
|
3
|
-
*/
|
|
4
|
-
type UUID = `${string}-${string}-${string}-${string}-${string}`;
|
|
5
|
-
/**
|
|
6
|
-
* Helper function to safely cast a string to strongly typed UUID
|
|
7
|
-
* @param id The string UUID to validate and cast
|
|
8
|
-
* @returns The same UUID with branded type information
|
|
9
|
-
*/
|
|
10
|
-
declare function asUUID(id: string): UUID;
|
|
11
|
-
/**
|
|
12
|
-
* Represents the content of a memory, message, or other information
|
|
13
|
-
*/
|
|
14
|
-
interface Content {
|
|
15
|
-
/** The agent's internal thought process */
|
|
16
|
-
thought?: string;
|
|
17
|
-
/** The main text content visible to users */
|
|
18
|
-
text?: string;
|
|
19
|
-
/** Optional actions to be performed */
|
|
20
|
-
actions?: string[];
|
|
21
|
-
/** Optional providers to use for context generation */
|
|
22
|
-
providers?: string[];
|
|
23
|
-
/** Optional source/origin of the content */
|
|
24
|
-
source?: string;
|
|
25
|
-
/** URL of the original message/post (e.g. tweet URL, Discord message link) */
|
|
26
|
-
url?: string;
|
|
27
|
-
/** UUID of parent message if this is a reply/thread */
|
|
28
|
-
inReplyTo?: UUID;
|
|
29
|
-
/** Array of media attachments */
|
|
30
|
-
attachments?: Media[];
|
|
31
|
-
/**
|
|
32
|
-
* Additional dynamic properties
|
|
33
|
-
* Use specific properties above instead of this when possible
|
|
34
|
-
*/
|
|
35
|
-
[key: string]: unknown;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Example content with associated user for demonstration purposes
|
|
39
|
-
*/
|
|
40
|
-
interface ActionExample {
|
|
41
|
-
/** User associated with the example */
|
|
42
|
-
name: string;
|
|
43
|
-
/** Content of the example */
|
|
44
|
-
content: Content;
|
|
45
|
-
}
|
|
46
|
-
type ModelTypeName = (typeof ModelType)[keyof typeof ModelType] | string;
|
|
47
|
-
/**
|
|
48
|
-
* Defines the recognized types of models that the agent runtime can use.
|
|
49
|
-
* These include models for text generation (small, large, reasoning, completion),
|
|
50
|
-
* text embedding, tokenization (encode/decode), image generation and description,
|
|
51
|
-
* audio transcription, text-to-speech, and generic object generation.
|
|
52
|
-
* This constant is used throughout the system, particularly in `AgentRuntime.useModel`,
|
|
53
|
-
* `AgentRuntime.registerModel`, and in `ModelParamsMap` / `ModelResultMap` to ensure
|
|
54
|
-
* type safety and clarity when working with different AI models.
|
|
55
|
-
* String values are used for extensibility with custom model types.
|
|
56
|
-
*/
|
|
57
|
-
declare const ModelType: {
|
|
58
|
-
readonly SMALL: "TEXT_SMALL";
|
|
59
|
-
readonly MEDIUM: "TEXT_LARGE";
|
|
60
|
-
readonly LARGE: "TEXT_LARGE";
|
|
61
|
-
readonly TEXT_SMALL: "TEXT_SMALL";
|
|
62
|
-
readonly TEXT_LARGE: "TEXT_LARGE";
|
|
63
|
-
readonly TEXT_EMBEDDING: "TEXT_EMBEDDING";
|
|
64
|
-
readonly TEXT_TOKENIZER_ENCODE: "TEXT_TOKENIZER_ENCODE";
|
|
65
|
-
readonly TEXT_TOKENIZER_DECODE: "TEXT_TOKENIZER_DECODE";
|
|
66
|
-
readonly TEXT_REASONING_SMALL: "REASONING_SMALL";
|
|
67
|
-
readonly TEXT_REASONING_LARGE: "REASONING_LARGE";
|
|
68
|
-
readonly TEXT_COMPLETION: "TEXT_COMPLETION";
|
|
69
|
-
readonly IMAGE: "IMAGE";
|
|
70
|
-
readonly IMAGE_DESCRIPTION: "IMAGE_DESCRIPTION";
|
|
71
|
-
readonly TRANSCRIPTION: "TRANSCRIPTION";
|
|
72
|
-
readonly TEXT_TO_SPEECH: "TEXT_TO_SPEECH";
|
|
73
|
-
readonly AUDIO: "AUDIO";
|
|
74
|
-
readonly VIDEO: "VIDEO";
|
|
75
|
-
readonly OBJECT_SMALL: "OBJECT_SMALL";
|
|
76
|
-
readonly OBJECT_LARGE: "OBJECT_LARGE";
|
|
77
|
-
};
|
|
78
|
-
/**
|
|
79
|
-
* Core service type registry that can be extended by plugins via module augmentation.
|
|
80
|
-
* Plugins can extend this interface to add their own service types:
|
|
81
|
-
*
|
|
82
|
-
* @example
|
|
83
|
-
* ```typescript
|
|
84
|
-
* declare module '@elizaos/core' {
|
|
85
|
-
* interface ServiceTypeRegistry {
|
|
86
|
-
* MY_CUSTOM_SERVICE: 'my_custom_service';
|
|
87
|
-
* }
|
|
88
|
-
* }
|
|
89
|
-
* ```
|
|
90
|
-
*/
|
|
91
|
-
interface ServiceTypeRegistry {
|
|
92
|
-
TRANSCRIPTION: 'transcription';
|
|
93
|
-
VIDEO: 'video';
|
|
94
|
-
BROWSER: 'browser';
|
|
95
|
-
PDF: 'pdf';
|
|
96
|
-
REMOTE_FILES: 'aws_s3';
|
|
97
|
-
WEB_SEARCH: 'web_search';
|
|
98
|
-
EMAIL: 'email';
|
|
99
|
-
TEE: 'tee';
|
|
100
|
-
TASK: 'task';
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Type for service names that includes both core services and any plugin-registered services
|
|
104
|
-
*/
|
|
105
|
-
type ServiceTypeName = ServiceTypeRegistry[keyof ServiceTypeRegistry];
|
|
106
|
-
/**
|
|
107
|
-
* Helper type to extract service type values from the registry
|
|
108
|
-
*/
|
|
109
|
-
type ServiceTypeValue<K extends keyof ServiceTypeRegistry> = ServiceTypeRegistry[K];
|
|
110
|
-
/**
|
|
111
|
-
* Helper type to check if a service type exists in the registry
|
|
112
|
-
*/
|
|
113
|
-
type IsValidServiceType<T extends string> = T extends ServiceTypeName ? true : false;
|
|
114
|
-
/**
|
|
115
|
-
* Type-safe service class definition
|
|
116
|
-
*/
|
|
117
|
-
type TypedServiceClass<T extends ServiceTypeName> = {
|
|
118
|
-
new (runtime?: IAgentRuntime): Service;
|
|
119
|
-
serviceType: T;
|
|
120
|
-
start(runtime: IAgentRuntime): Promise<Service>;
|
|
121
|
-
};
|
|
122
|
-
/**
|
|
123
|
-
* Map of service type names to their implementation classes
|
|
124
|
-
*/
|
|
125
|
-
interface ServiceClassMap {
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Helper to infer service instance type from service type name
|
|
129
|
-
*/
|
|
130
|
-
type ServiceInstance<T extends ServiceTypeName> = T extends keyof ServiceClassMap ? InstanceType<ServiceClassMap[T]> : Service;
|
|
131
|
-
/**
|
|
132
|
-
* Runtime service registry type
|
|
133
|
-
*/
|
|
134
|
-
type ServiceRegistry<T extends ServiceTypeName = ServiceTypeName> = Map<T, Service>;
|
|
135
|
-
/**
|
|
136
|
-
* Enumerates the recognized types of services that can be registered and used by the agent runtime.
|
|
137
|
-
* Services provide specialized functionalities like audio transcription, video processing,
|
|
138
|
-
* web browsing, PDF handling, file storage (e.g., AWS S3), web search, email integration,
|
|
139
|
-
* secure execution via TEE (Trusted Execution Environment), and task management.
|
|
140
|
-
* This constant is used in `AgentRuntime` for service registration and retrieval (e.g., `getService`).
|
|
141
|
-
* Each service typically implements the `Service` abstract class or a more specific interface like `IVideoService`.
|
|
142
|
-
*/
|
|
143
|
-
declare const ServiceType: {
|
|
144
|
-
readonly TRANSCRIPTION: "transcription";
|
|
145
|
-
readonly VIDEO: "video";
|
|
146
|
-
readonly BROWSER: "browser";
|
|
147
|
-
readonly PDF: "pdf";
|
|
148
|
-
readonly REMOTE_FILES: "aws_s3";
|
|
149
|
-
readonly WEB_SEARCH: "web_search";
|
|
150
|
-
readonly EMAIL: "email";
|
|
151
|
-
readonly TEE: "tee";
|
|
152
|
-
readonly TASK: "task";
|
|
153
|
-
};
|
|
154
|
-
/**
|
|
155
|
-
* Represents the current state or context of a conversation or agent interaction.
|
|
156
|
-
* This interface is a flexible container for various pieces of information that define the agent's
|
|
157
|
-
* understanding at a point in time. It includes:
|
|
158
|
-
* - `values`: A key-value store for general state variables, often populated by providers.
|
|
159
|
-
* - `data`: Another key-value store, potentially for more structured or internal data.
|
|
160
|
-
* - `text`: A string representation of the current context, often a summary or concatenated history.
|
|
161
|
-
* The `[key: string]: any;` allows for dynamic properties, though `EnhancedState` offers better typing.
|
|
162
|
-
* This state object is passed to handlers for actions, evaluators, and providers.
|
|
163
|
-
*/
|
|
164
|
-
interface State {
|
|
165
|
-
/** Additional dynamic properties */
|
|
166
|
-
[key: string]: any;
|
|
167
|
-
values: {
|
|
168
|
-
[key: string]: any;
|
|
169
|
-
};
|
|
170
|
-
data: {
|
|
171
|
-
[key: string]: any;
|
|
172
|
-
};
|
|
173
|
-
text: string;
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Memory type enumeration for built-in memory types
|
|
177
|
-
*/
|
|
178
|
-
type MemoryTypeAlias = string;
|
|
179
|
-
/**
|
|
180
|
-
* Enumerates the built-in types of memories that can be stored and retrieved.
|
|
181
|
-
* - `DOCUMENT`: Represents a whole document or a large piece of text.
|
|
182
|
-
* - `FRAGMENT`: A chunk or segment of a `DOCUMENT`, often created for embedding and search.
|
|
183
|
-
* - `MESSAGE`: A conversational message, typically from a user or the agent.
|
|
184
|
-
* - `DESCRIPTION`: A descriptive piece of information, perhaps about an entity or concept.
|
|
185
|
-
* - `CUSTOM`: For any other type of memory not covered by the built-in types.
|
|
186
|
-
* This enum is used in `MemoryMetadata` to categorize memories and influences how they are processed or queried.
|
|
187
|
-
*/
|
|
188
|
-
declare enum MemoryType {
|
|
189
|
-
DOCUMENT = "document",
|
|
190
|
-
FRAGMENT = "fragment",
|
|
191
|
-
MESSAGE = "message",
|
|
192
|
-
DESCRIPTION = "description",
|
|
193
|
-
CUSTOM = "custom"
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* Defines the scope of a memory, indicating its visibility and accessibility.
|
|
197
|
-
* - `shared`: The memory is accessible to multiple entities or across different contexts (e.g., a public fact).
|
|
198
|
-
* - `private`: The memory is specific to a single entity or a private context (e.g., a user's personal preference).
|
|
199
|
-
* - `room`: The memory is scoped to a specific room or channel.
|
|
200
|
-
* This is used in `MemoryMetadata` to control how memories are stored and retrieved based on context.
|
|
201
|
-
*/
|
|
202
|
-
type MemoryScope = 'shared' | 'private' | 'room';
|
|
203
|
-
/**
|
|
204
|
-
* Base interface for all memory metadata types.
|
|
205
|
-
* It includes common properties for all memories, such as:
|
|
206
|
-
* - `type`: The kind of memory (e.g., `MemoryType.MESSAGE`, `MemoryType.DOCUMENT`).
|
|
207
|
-
* - `source`: An optional string indicating the origin of the memory (e.g., 'discord', 'user_input').
|
|
208
|
-
* - `sourceId`: An optional UUID linking to a source entity or object.
|
|
209
|
-
* - `scope`: The visibility scope of the memory (`shared`, `private`, or `room`).
|
|
210
|
-
* - `timestamp`: An optional numerical timestamp (e.g., milliseconds since epoch) of when the memory was created or relevant.
|
|
211
|
-
* - `tags`: Optional array of strings for categorizing or filtering memories.
|
|
212
|
-
* Specific metadata types like `DocumentMetadata` or `MessageMetadata` extend this base.
|
|
213
|
-
*/
|
|
214
|
-
interface BaseMetadata {
|
|
215
|
-
type: MemoryTypeAlias;
|
|
216
|
-
source?: string;
|
|
217
|
-
sourceId?: UUID;
|
|
218
|
-
scope?: MemoryScope;
|
|
219
|
-
timestamp?: number;
|
|
220
|
-
tags?: string[];
|
|
221
|
-
}
|
|
222
|
-
interface DocumentMetadata extends BaseMetadata {
|
|
223
|
-
type: MemoryType.DOCUMENT;
|
|
224
|
-
}
|
|
225
|
-
interface FragmentMetadata extends BaseMetadata {
|
|
226
|
-
type: MemoryType.FRAGMENT;
|
|
227
|
-
documentId: UUID;
|
|
228
|
-
position: number;
|
|
229
|
-
}
|
|
230
|
-
interface MessageMetadata extends BaseMetadata {
|
|
231
|
-
type: MemoryType.MESSAGE;
|
|
232
|
-
}
|
|
233
|
-
interface DescriptionMetadata extends BaseMetadata {
|
|
234
|
-
type: MemoryType.DESCRIPTION;
|
|
235
|
-
}
|
|
236
|
-
interface CustomMetadata extends BaseMetadata {
|
|
237
|
-
[key: string]: unknown;
|
|
238
|
-
}
|
|
239
|
-
type MemoryMetadata = DocumentMetadata | FragmentMetadata | MessageMetadata | DescriptionMetadata | CustomMetadata;
|
|
240
|
-
/**
|
|
241
|
-
* Represents a stored memory/message
|
|
242
|
-
*/
|
|
243
|
-
interface Memory {
|
|
244
|
-
/** Optional unique identifier */
|
|
245
|
-
id?: UUID;
|
|
246
|
-
/** Associated user ID */
|
|
247
|
-
entityId: UUID;
|
|
248
|
-
/** Associated agent ID */
|
|
249
|
-
agentId?: UUID;
|
|
250
|
-
/** Optional creation timestamp in milliseconds since epoch */
|
|
251
|
-
createdAt?: number;
|
|
252
|
-
/** Memory content */
|
|
253
|
-
content: Content;
|
|
254
|
-
/** Optional embedding vector for semantic search */
|
|
255
|
-
embedding?: number[];
|
|
256
|
-
/** Associated room ID */
|
|
257
|
-
roomId: UUID;
|
|
258
|
-
/** Associated world ID (optional) */
|
|
259
|
-
worldId?: UUID;
|
|
260
|
-
/** Whether memory is unique (used to prevent duplicates) */
|
|
261
|
-
unique?: boolean;
|
|
262
|
-
/** Embedding similarity score (set when retrieved via search) */
|
|
263
|
-
similarity?: number;
|
|
264
|
-
/** Metadata for the memory */
|
|
265
|
-
metadata?: MemoryMetadata;
|
|
266
|
-
}
|
|
267
|
-
/**
|
|
268
|
-
* Represents a log entry
|
|
269
|
-
*/
|
|
270
|
-
interface Log {
|
|
271
|
-
/** Optional unique identifier */
|
|
272
|
-
id?: UUID;
|
|
273
|
-
/** Associated entity ID */
|
|
274
|
-
entityId: UUID;
|
|
275
|
-
/** Associated room ID */
|
|
276
|
-
roomId?: UUID;
|
|
277
|
-
/** Log body */
|
|
278
|
-
body: {
|
|
279
|
-
[key: string]: unknown;
|
|
280
|
-
};
|
|
281
|
-
/** Log type */
|
|
282
|
-
type: string;
|
|
283
|
-
/** Log creation timestamp */
|
|
284
|
-
createdAt: Date;
|
|
285
|
-
}
|
|
286
|
-
/**
|
|
287
|
-
* Example message for demonstration
|
|
288
|
-
*/
|
|
289
|
-
interface MessageExample {
|
|
290
|
-
/** Associated user */
|
|
291
|
-
name: string;
|
|
292
|
-
/** Message content */
|
|
293
|
-
content: Content;
|
|
294
|
-
}
|
|
295
|
-
/**
|
|
296
|
-
* Handler function type for processing messages
|
|
297
|
-
*/
|
|
298
|
-
type Handler = (runtime: IAgentRuntime, message: Memory, state?: State, options?: {
|
|
299
|
-
[key: string]: unknown;
|
|
300
|
-
}, callback?: HandlerCallback, responses?: Memory[]) => Promise<unknown>;
|
|
301
|
-
/**
|
|
302
|
-
* Callback function type for handlers
|
|
303
|
-
*/
|
|
304
|
-
type HandlerCallback = (response: Content, files?: any) => Promise<Memory[]>;
|
|
305
|
-
/**
|
|
306
|
-
* Validator function type for actions/evaluators
|
|
307
|
-
*/
|
|
308
|
-
type Validator = (runtime: IAgentRuntime, message: Memory, state?: State) => Promise<boolean>;
|
|
309
|
-
/**
|
|
310
|
-
* Represents an action the agent can perform
|
|
311
|
-
*/
|
|
312
|
-
interface Action {
|
|
313
|
-
/** Similar action descriptions */
|
|
314
|
-
similes?: string[];
|
|
315
|
-
/** Detailed description */
|
|
316
|
-
description: string;
|
|
317
|
-
/** Example usages */
|
|
318
|
-
examples?: ActionExample[][];
|
|
319
|
-
/** Handler function */
|
|
320
|
-
handler: Handler;
|
|
321
|
-
/** Action name */
|
|
322
|
-
name: string;
|
|
323
|
-
/** Validation function */
|
|
324
|
-
validate: Validator;
|
|
325
|
-
}
|
|
326
|
-
/**
|
|
327
|
-
* Example for evaluating agent behavior
|
|
328
|
-
*/
|
|
329
|
-
interface EvaluationExample {
|
|
330
|
-
/** Evaluation context */
|
|
331
|
-
prompt: string;
|
|
332
|
-
/** Example messages */
|
|
333
|
-
messages: Array<ActionExample>;
|
|
334
|
-
/** Expected outcome */
|
|
335
|
-
outcome: string;
|
|
336
|
-
}
|
|
337
|
-
/**
|
|
338
|
-
* Evaluator for assessing agent responses
|
|
339
|
-
*/
|
|
340
|
-
interface Evaluator {
|
|
341
|
-
/** Whether to always run */
|
|
342
|
-
alwaysRun?: boolean;
|
|
343
|
-
/** Detailed description */
|
|
344
|
-
description: string;
|
|
345
|
-
/** Similar evaluator descriptions */
|
|
346
|
-
similes?: string[];
|
|
347
|
-
/** Example evaluations */
|
|
348
|
-
examples: EvaluationExample[];
|
|
349
|
-
/** Handler function */
|
|
350
|
-
handler: Handler;
|
|
351
|
-
/** Evaluator name */
|
|
352
|
-
name: string;
|
|
353
|
-
/** Validation function */
|
|
354
|
-
validate: Validator;
|
|
355
|
-
}
|
|
356
|
-
interface ProviderResult {
|
|
357
|
-
values?: {
|
|
358
|
-
[key: string]: any;
|
|
359
|
-
};
|
|
360
|
-
data?: {
|
|
361
|
-
[key: string]: any;
|
|
362
|
-
};
|
|
363
|
-
text?: string;
|
|
364
|
-
}
|
|
365
|
-
/**
|
|
366
|
-
* Provider for external data/services
|
|
367
|
-
*/
|
|
368
|
-
interface Provider {
|
|
369
|
-
/** Provider name */
|
|
370
|
-
name: string;
|
|
371
|
-
/** Description of the provider */
|
|
372
|
-
description?: string;
|
|
373
|
-
/** Whether the provider is dynamic */
|
|
374
|
-
dynamic?: boolean;
|
|
375
|
-
/** Position of the provider in the provider list, positive or negative */
|
|
376
|
-
position?: number;
|
|
377
|
-
/**
|
|
378
|
-
* Whether the provider is private
|
|
379
|
-
*
|
|
380
|
-
* Private providers are not displayed in the regular provider list, they have to be called explicitly
|
|
381
|
-
*/
|
|
382
|
-
private?: boolean;
|
|
383
|
-
/** Data retrieval function */
|
|
384
|
-
get: (runtime: IAgentRuntime, message: Memory, state: State) => Promise<ProviderResult>;
|
|
385
|
-
}
|
|
386
|
-
/**
|
|
387
|
-
* Represents a relationship between users
|
|
388
|
-
*/
|
|
389
|
-
interface Relationship {
|
|
390
|
-
/** Unique identifier */
|
|
391
|
-
id: UUID;
|
|
392
|
-
/** First user ID */
|
|
393
|
-
sourceEntityId: UUID;
|
|
394
|
-
/** Second user ID */
|
|
395
|
-
targetEntityId: UUID;
|
|
396
|
-
/** Agent ID */
|
|
397
|
-
agentId: UUID;
|
|
398
|
-
/** Tags for filtering/categorizing relationships */
|
|
399
|
-
tags: string[];
|
|
400
|
-
/** Additional metadata about the relationship */
|
|
401
|
-
metadata: {
|
|
402
|
-
[key: string]: any;
|
|
403
|
-
};
|
|
404
|
-
/** Optional creation timestamp */
|
|
405
|
-
createdAt?: string;
|
|
406
|
-
}
|
|
407
|
-
interface Component {
|
|
408
|
-
id: UUID;
|
|
409
|
-
entityId: UUID;
|
|
410
|
-
agentId: UUID;
|
|
411
|
-
roomId: UUID;
|
|
412
|
-
worldId: UUID;
|
|
413
|
-
sourceEntityId: UUID;
|
|
414
|
-
type: string;
|
|
415
|
-
createdAt: number;
|
|
416
|
-
data: {
|
|
417
|
-
[key: string]: any;
|
|
418
|
-
};
|
|
419
|
-
}
|
|
420
|
-
/**
|
|
421
|
-
* Represents a user account
|
|
422
|
-
*/
|
|
423
|
-
interface Entity {
|
|
424
|
-
/** Unique identifier, optional on creation */
|
|
425
|
-
id?: UUID;
|
|
426
|
-
/** Names of the entity */
|
|
427
|
-
names: string[];
|
|
428
|
-
/** Optional additional metadata */
|
|
429
|
-
metadata?: {
|
|
430
|
-
[key: string]: any;
|
|
431
|
-
};
|
|
432
|
-
/** Agent ID this account is related to, for agents should be themselves */
|
|
433
|
-
agentId: UUID;
|
|
434
|
-
/** Optional array of components */
|
|
435
|
-
components?: Component[];
|
|
436
|
-
}
|
|
437
|
-
type World = {
|
|
438
|
-
id: UUID;
|
|
439
|
-
name?: string;
|
|
440
|
-
agentId: UUID;
|
|
441
|
-
serverId: string;
|
|
442
|
-
metadata?: {
|
|
443
|
-
ownership?: {
|
|
444
|
-
ownerId: string;
|
|
445
|
-
};
|
|
446
|
-
roles?: {
|
|
447
|
-
[entityId: UUID]: Role;
|
|
448
|
-
};
|
|
449
|
-
[key: string]: unknown;
|
|
450
|
-
};
|
|
451
|
-
};
|
|
452
|
-
type RoomMetadata = {
|
|
453
|
-
[key: string]: unknown;
|
|
454
|
-
};
|
|
455
|
-
type Room = {
|
|
456
|
-
id: UUID;
|
|
457
|
-
name?: string;
|
|
458
|
-
agentId?: UUID;
|
|
459
|
-
source: string;
|
|
460
|
-
type: ChannelType;
|
|
461
|
-
channelId?: string;
|
|
462
|
-
serverId?: string;
|
|
463
|
-
worldId?: UUID;
|
|
464
|
-
metadata?: RoomMetadata;
|
|
465
|
-
};
|
|
466
|
-
/**
|
|
467
|
-
* Room participant with account details
|
|
468
|
-
*/
|
|
469
|
-
interface Participant {
|
|
470
|
-
/** Unique identifier */
|
|
471
|
-
id: UUID;
|
|
472
|
-
/** Associated account */
|
|
473
|
-
entity: Entity;
|
|
474
|
-
}
|
|
475
|
-
/**
|
|
476
|
-
* Represents a media attachment
|
|
477
|
-
*/
|
|
478
|
-
type Media = {
|
|
479
|
-
/** Unique identifier */
|
|
480
|
-
id: string;
|
|
481
|
-
/** Media URL */
|
|
482
|
-
url: string;
|
|
483
|
-
/** Media title */
|
|
484
|
-
title?: string;
|
|
485
|
-
/** Media source */
|
|
486
|
-
source?: string;
|
|
487
|
-
/** Media description */
|
|
488
|
-
description?: string;
|
|
489
|
-
/** Text content */
|
|
490
|
-
text?: string;
|
|
491
|
-
/** Content type */
|
|
492
|
-
contentType?: ContentType;
|
|
493
|
-
};
|
|
494
|
-
declare enum ContentType {
|
|
495
|
-
IMAGE = "image",
|
|
496
|
-
VIDEO = "video",
|
|
497
|
-
AUDIO = "audio",
|
|
498
|
-
DOCUMENT = "document",
|
|
499
|
-
LINK = "link"
|
|
500
|
-
}
|
|
501
|
-
declare enum ChannelType {
|
|
502
|
-
SELF = "SELF",// Messages to self
|
|
503
|
-
DM = "DM",// Direct messages between two participants
|
|
504
|
-
GROUP = "GROUP",// Group messages with multiple participants
|
|
505
|
-
VOICE_DM = "VOICE_DM",// Voice direct messages
|
|
506
|
-
VOICE_GROUP = "VOICE_GROUP",// Voice channels with multiple participants
|
|
507
|
-
FEED = "FEED",// Social media feed
|
|
508
|
-
THREAD = "THREAD",// Threaded conversation
|
|
509
|
-
WORLD = "WORLD",// World channel
|
|
510
|
-
FORUM = "FORUM",// Forum discussion
|
|
511
|
-
API = "API"
|
|
512
|
-
}
|
|
513
|
-
type Route = {
|
|
514
|
-
type: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'STATIC';
|
|
515
|
-
path: string;
|
|
516
|
-
filePath?: string;
|
|
517
|
-
public?: boolean;
|
|
518
|
-
name?: string extends {
|
|
519
|
-
public: true;
|
|
520
|
-
} ? string : string | undefined;
|
|
521
|
-
handler?: (req: any, res: any, runtime: IAgentRuntime) => Promise<void>;
|
|
522
|
-
isMultipart?: boolean;
|
|
523
|
-
};
|
|
524
|
-
/**
|
|
525
|
-
* Plugin for extending agent functionality
|
|
526
|
-
*/
|
|
527
|
-
type PluginEvents = {
|
|
528
|
-
[K in keyof EventPayloadMap]?: EventHandler<K>[];
|
|
529
|
-
} & {
|
|
530
|
-
[key: string]: ((params: EventPayload) => Promise<any>)[];
|
|
531
|
-
};
|
|
532
|
-
interface Plugin {
|
|
533
|
-
name: string;
|
|
534
|
-
description: string;
|
|
535
|
-
init?: (config: Record<string, string>, runtime: IAgentRuntime) => Promise<void>;
|
|
536
|
-
config?: {
|
|
537
|
-
[key: string]: any;
|
|
538
|
-
};
|
|
539
|
-
services?: (typeof Service)[];
|
|
540
|
-
componentTypes?: {
|
|
541
|
-
name: string;
|
|
542
|
-
schema: Record<string, unknown>;
|
|
543
|
-
validator?: (data: any) => boolean;
|
|
544
|
-
}[];
|
|
545
|
-
actions?: Action[];
|
|
546
|
-
providers?: Provider[];
|
|
547
|
-
evaluators?: Evaluator[];
|
|
548
|
-
adapter?: IDatabaseAdapter;
|
|
549
|
-
models?: {
|
|
550
|
-
[key: string]: (...args: any[]) => Promise<any>;
|
|
551
|
-
};
|
|
552
|
-
events?: PluginEvents;
|
|
553
|
-
routes?: Route[];
|
|
554
|
-
tests?: TestSuite[];
|
|
555
|
-
dependencies?: string[];
|
|
556
|
-
priority?: number;
|
|
557
|
-
}
|
|
558
|
-
interface ProjectAgent {
|
|
559
|
-
character: Character;
|
|
560
|
-
init?: (runtime: IAgentRuntime) => Promise<void>;
|
|
561
|
-
plugins?: Plugin[];
|
|
562
|
-
tests?: TestSuite | TestSuite[];
|
|
563
|
-
}
|
|
564
|
-
interface Project {
|
|
565
|
-
agents: ProjectAgent[];
|
|
566
|
-
}
|
|
567
|
-
type TemplateType = string | ((options: {
|
|
568
|
-
state: State | {
|
|
569
|
-
[key: string]: string;
|
|
570
|
-
};
|
|
571
|
-
}) => string);
|
|
572
|
-
/**
|
|
573
|
-
* Configuration for an agent's character, defining its personality, knowledge, and capabilities.
|
|
574
|
-
* This is a central piece of an agent's definition, used by the `AgentRuntime` to initialize and operate the agent.
|
|
575
|
-
* It includes:
|
|
576
|
-
* - `id`: Optional unique identifier for the character.
|
|
577
|
-
* - `name`, `username`: Identifying names for the character.
|
|
578
|
-
* - `system`: A system prompt that guides the agent's overall behavior.
|
|
579
|
-
* - `templates`: A map of prompt templates for various situations (e.g., message generation, summarization).
|
|
580
|
-
* - `bio`: A textual biography or description of the character.
|
|
581
|
-
* - `messageExamples`, `postExamples`: Examples of how the character communicates.
|
|
582
|
-
* - `topics`, `adjectives`: Keywords describing the character's knowledge areas and traits.
|
|
583
|
-
* - `knowledge`: Paths to knowledge files or directories to be loaded into the agent's memory.
|
|
584
|
-
* - `plugins`: A list of plugin names to be loaded for this character.
|
|
585
|
-
* - `settings`, `secrets`: Configuration key-value pairs, with secrets being handled more securely.
|
|
586
|
-
* - `style`: Guidelines for the character's writing style in different contexts (chat, post).
|
|
587
|
-
*/
|
|
588
|
-
interface Character {
|
|
589
|
-
/** Optional unique identifier */
|
|
590
|
-
id?: UUID;
|
|
591
|
-
/** Character name */
|
|
592
|
-
name: string;
|
|
593
|
-
/** Optional username */
|
|
594
|
-
username?: string;
|
|
595
|
-
/** Optional system prompt */
|
|
596
|
-
system?: string;
|
|
597
|
-
/** Optional prompt templates */
|
|
598
|
-
templates?: {
|
|
599
|
-
[key: string]: TemplateType;
|
|
600
|
-
};
|
|
601
|
-
/** Character biography */
|
|
602
|
-
bio: string | string[];
|
|
603
|
-
/** Example messages */
|
|
604
|
-
messageExamples?: MessageExample[][];
|
|
605
|
-
/** Example posts */
|
|
606
|
-
postExamples?: string[];
|
|
607
|
-
/** Known topics */
|
|
608
|
-
topics?: string[];
|
|
609
|
-
/** Character traits */
|
|
610
|
-
adjectives?: string[];
|
|
611
|
-
/** Optional knowledge base */
|
|
612
|
-
knowledge?: (string | {
|
|
613
|
-
path: string;
|
|
614
|
-
shared?: boolean;
|
|
615
|
-
} | {
|
|
616
|
-
directory: string;
|
|
617
|
-
shared?: boolean;
|
|
618
|
-
})[];
|
|
619
|
-
/** Available plugins */
|
|
620
|
-
plugins?: string[];
|
|
621
|
-
/** Optional configuration */
|
|
622
|
-
settings?: {
|
|
623
|
-
[key: string]: any | string | boolean | number;
|
|
624
|
-
};
|
|
625
|
-
/** Optional secrets */
|
|
626
|
-
secrets?: {
|
|
627
|
-
[key: string]: string | boolean | number;
|
|
628
|
-
};
|
|
629
|
-
/** Writing style guides */
|
|
630
|
-
style?: {
|
|
631
|
-
all?: string[];
|
|
632
|
-
chat?: string[];
|
|
633
|
-
post?: string[];
|
|
634
|
-
};
|
|
635
|
-
}
|
|
636
|
-
declare enum AgentStatus {
|
|
637
|
-
ACTIVE = "active",
|
|
638
|
-
INACTIVE = "inactive"
|
|
639
|
-
}
|
|
640
|
-
/**
|
|
641
|
-
* Represents an operational agent, extending the `Character` definition with runtime status and timestamps.
|
|
642
|
-
* While `Character` defines the blueprint, `Agent` represents an instantiated and potentially running version.
|
|
643
|
-
* It includes:
|
|
644
|
-
* - `enabled`: A boolean indicating if the agent is currently active or disabled.
|
|
645
|
-
* - `status`: The current operational status, typically `AgentStatus.ACTIVE` or `AgentStatus.INACTIVE`.
|
|
646
|
-
* - `createdAt`, `updatedAt`: Timestamps for when the agent record was created and last updated in the database.
|
|
647
|
-
* This interface is primarily used by the `IDatabaseAdapter` for agent management.
|
|
648
|
-
*/
|
|
649
|
-
interface Agent extends Character {
|
|
650
|
-
enabled?: boolean;
|
|
651
|
-
status?: AgentStatus;
|
|
652
|
-
createdAt: number;
|
|
653
|
-
updatedAt: number;
|
|
654
|
-
}
|
|
655
|
-
/**
|
|
656
|
-
* Interface for database operations
|
|
657
|
-
*/
|
|
658
|
-
interface IDatabaseAdapter {
|
|
659
|
-
/** Database instance */
|
|
660
|
-
db: any;
|
|
661
|
-
/** Initialize database connection */
|
|
662
|
-
init(): Promise<void>;
|
|
663
|
-
/** Close database connection */
|
|
664
|
-
close(): Promise<void>;
|
|
665
|
-
getConnection(): Promise<any>;
|
|
666
|
-
getAgent(agentId: UUID): Promise<Agent | null>;
|
|
667
|
-
/** Get all agents */
|
|
668
|
-
getAgents(): Promise<Partial<Agent>[]>;
|
|
669
|
-
createAgent(agent: Partial<Agent>): Promise<boolean>;
|
|
670
|
-
updateAgent(agentId: UUID, agent: Partial<Agent>): Promise<boolean>;
|
|
671
|
-
deleteAgent(agentId: UUID): Promise<boolean>;
|
|
672
|
-
ensureEmbeddingDimension(dimension: number): Promise<void>;
|
|
673
|
-
/** Get entity by IDs */
|
|
674
|
-
getEntitiesByIds(entityIds: UUID[]): Promise<Entity[] | null>;
|
|
675
|
-
/** Get entities for room */
|
|
676
|
-
getEntitiesForRoom(roomId: UUID, includeComponents?: boolean): Promise<Entity[]>;
|
|
677
|
-
/** Create new entities */
|
|
678
|
-
createEntities(entities: Entity[]): Promise<boolean>;
|
|
679
|
-
/** Update entity */
|
|
680
|
-
updateEntity(entity: Entity): Promise<void>;
|
|
681
|
-
/** Get component by ID */
|
|
682
|
-
getComponent(entityId: UUID, type: string, worldId?: UUID, sourceEntityId?: UUID): Promise<Component | null>;
|
|
683
|
-
/** Get all components for an entity */
|
|
684
|
-
getComponents(entityId: UUID, worldId?: UUID, sourceEntityId?: UUID): Promise<Component[]>;
|
|
685
|
-
/** Create component */
|
|
686
|
-
createComponent(component: Component): Promise<boolean>;
|
|
687
|
-
/** Update component */
|
|
688
|
-
updateComponent(component: Component): Promise<void>;
|
|
689
|
-
/** Delete component */
|
|
690
|
-
deleteComponent(componentId: UUID): Promise<void>;
|
|
691
|
-
/** Get memories matching criteria */
|
|
692
|
-
getMemories(params: {
|
|
693
|
-
entityId?: UUID;
|
|
694
|
-
agentId?: UUID;
|
|
695
|
-
count?: number;
|
|
696
|
-
unique?: boolean;
|
|
697
|
-
tableName: string;
|
|
698
|
-
start?: number;
|
|
699
|
-
end?: number;
|
|
700
|
-
roomId?: UUID;
|
|
701
|
-
worldId?: UUID;
|
|
702
|
-
}): Promise<Memory[]>;
|
|
703
|
-
getMemoryById(id: UUID): Promise<Memory | null>;
|
|
704
|
-
getMemoriesByIds(ids: UUID[], tableName?: string): Promise<Memory[]>;
|
|
705
|
-
getMemoriesByRoomIds(params: {
|
|
706
|
-
tableName: string;
|
|
707
|
-
roomIds: UUID[];
|
|
708
|
-
limit?: number;
|
|
709
|
-
}): Promise<Memory[]>;
|
|
710
|
-
getCachedEmbeddings(params: {
|
|
711
|
-
query_table_name: string;
|
|
712
|
-
query_threshold: number;
|
|
713
|
-
query_input: string;
|
|
714
|
-
query_field_name: string;
|
|
715
|
-
query_field_sub_name: string;
|
|
716
|
-
query_match_count: number;
|
|
717
|
-
}): Promise<{
|
|
718
|
-
embedding: number[];
|
|
719
|
-
levenshtein_score: number;
|
|
720
|
-
}[]>;
|
|
721
|
-
log(params: {
|
|
722
|
-
body: {
|
|
723
|
-
[key: string]: unknown;
|
|
724
|
-
};
|
|
725
|
-
entityId: UUID;
|
|
726
|
-
roomId: UUID;
|
|
727
|
-
type: string;
|
|
728
|
-
}): Promise<void>;
|
|
729
|
-
getLogs(params: {
|
|
730
|
-
entityId: UUID;
|
|
731
|
-
roomId?: UUID;
|
|
732
|
-
type?: string;
|
|
733
|
-
count?: number;
|
|
734
|
-
offset?: number;
|
|
735
|
-
}): Promise<Log[]>;
|
|
736
|
-
deleteLog(logId: UUID): Promise<void>;
|
|
737
|
-
searchMemories(params: {
|
|
738
|
-
embedding: number[];
|
|
739
|
-
match_threshold?: number;
|
|
740
|
-
count?: number;
|
|
741
|
-
unique?: boolean;
|
|
742
|
-
tableName: string;
|
|
743
|
-
query?: string;
|
|
744
|
-
roomId?: UUID;
|
|
745
|
-
worldId?: UUID;
|
|
746
|
-
entityId?: UUID;
|
|
747
|
-
}): Promise<Memory[]>;
|
|
748
|
-
createMemory(memory: Memory, tableName: string, unique?: boolean): Promise<UUID>;
|
|
749
|
-
updateMemory(memory: Partial<Memory> & {
|
|
750
|
-
id: UUID;
|
|
751
|
-
metadata?: MemoryMetadata;
|
|
752
|
-
}): Promise<boolean>;
|
|
753
|
-
deleteMemory(memoryId: UUID): Promise<void>;
|
|
754
|
-
deleteManyMemories(memoryIds: UUID[]): Promise<void>;
|
|
755
|
-
deleteAllMemories(roomId: UUID, tableName: string): Promise<void>;
|
|
756
|
-
countMemories(roomId: UUID, unique?: boolean, tableName?: string): Promise<number>;
|
|
757
|
-
createWorld(world: World): Promise<UUID>;
|
|
758
|
-
getWorld(id: UUID): Promise<World | null>;
|
|
759
|
-
removeWorld(id: UUID): Promise<void>;
|
|
760
|
-
getAllWorlds(): Promise<World[]>;
|
|
761
|
-
updateWorld(world: World): Promise<void>;
|
|
762
|
-
getRoomsByIds(roomIds: UUID[]): Promise<Room[] | null>;
|
|
763
|
-
createRooms(rooms: Room[]): Promise<UUID[]>;
|
|
764
|
-
deleteRoom(roomId: UUID): Promise<void>;
|
|
765
|
-
deleteRoomsByWorldId(worldId: UUID): Promise<void>;
|
|
766
|
-
updateRoom(room: Room): Promise<void>;
|
|
767
|
-
getRoomsForParticipant(entityId: UUID): Promise<UUID[]>;
|
|
768
|
-
getRoomsForParticipants(userIds: UUID[]): Promise<UUID[]>;
|
|
769
|
-
getRoomsByWorld(worldId: UUID): Promise<Room[]>;
|
|
770
|
-
removeParticipant(entityId: UUID, roomId: UUID): Promise<boolean>;
|
|
771
|
-
getParticipantsForEntity(entityId: UUID): Promise<Participant[]>;
|
|
772
|
-
getParticipantsForRoom(roomId: UUID): Promise<UUID[]>;
|
|
773
|
-
addParticipantsRoom(entityIds: UUID[], roomId: UUID): Promise<boolean>;
|
|
774
|
-
getParticipantUserState(roomId: UUID, entityId: UUID): Promise<'FOLLOWED' | 'MUTED' | null>;
|
|
775
|
-
setParticipantUserState(roomId: UUID, entityId: UUID, state: 'FOLLOWED' | 'MUTED' | null): Promise<void>;
|
|
776
|
-
/**
|
|
777
|
-
* Creates a new relationship between two entities.
|
|
778
|
-
* @param params Object containing the relationship details
|
|
779
|
-
* @returns Promise resolving to boolean indicating success
|
|
780
|
-
*/
|
|
781
|
-
createRelationship(params: {
|
|
782
|
-
sourceEntityId: UUID;
|
|
783
|
-
targetEntityId: UUID;
|
|
784
|
-
tags?: string[];
|
|
785
|
-
metadata?: {
|
|
786
|
-
[key: string]: any;
|
|
787
|
-
};
|
|
788
|
-
}): Promise<boolean>;
|
|
789
|
-
/**
|
|
790
|
-
* Updates an existing relationship between two entities.
|
|
791
|
-
* @param relationship The relationship object with updated data
|
|
792
|
-
* @returns Promise resolving to void
|
|
793
|
-
*/
|
|
794
|
-
updateRelationship(relationship: Relationship): Promise<void>;
|
|
795
|
-
/**
|
|
796
|
-
* Retrieves a relationship between two entities if it exists.
|
|
797
|
-
* @param params Object containing the entity IDs and agent ID
|
|
798
|
-
* @returns Promise resolving to the Relationship object or null if not found
|
|
799
|
-
*/
|
|
800
|
-
getRelationship(params: {
|
|
801
|
-
sourceEntityId: UUID;
|
|
802
|
-
targetEntityId: UUID;
|
|
803
|
-
}): Promise<Relationship | null>;
|
|
804
|
-
/**
|
|
805
|
-
* Retrieves all relationships for a specific entity.
|
|
806
|
-
* @param params Object containing the user ID, agent ID and optional tags to filter by
|
|
807
|
-
* @returns Promise resolving to an array of Relationship objects
|
|
808
|
-
*/
|
|
809
|
-
getRelationships(params: {
|
|
810
|
-
entityId: UUID;
|
|
811
|
-
tags?: string[];
|
|
812
|
-
}): Promise<Relationship[]>;
|
|
813
|
-
ensureEmbeddingDimension(dimension: number): Promise<void>;
|
|
814
|
-
getCache<T>(key: string): Promise<T | undefined>;
|
|
815
|
-
setCache<T>(key: string, value: T): Promise<boolean>;
|
|
816
|
-
deleteCache(key: string): Promise<boolean>;
|
|
817
|
-
createTask(task: Task): Promise<UUID>;
|
|
818
|
-
getTasks(params: {
|
|
819
|
-
roomId?: UUID;
|
|
820
|
-
tags?: string[];
|
|
821
|
-
entityId?: UUID;
|
|
822
|
-
}): Promise<Task[]>;
|
|
823
|
-
getTask(id: UUID): Promise<Task | null>;
|
|
824
|
-
getTasksByName(name: string): Promise<Task[]>;
|
|
825
|
-
updateTask(id: UUID, task: Partial<Task>): Promise<void>;
|
|
826
|
-
deleteTask(id: UUID): Promise<void>;
|
|
827
|
-
getMemoriesByWorldId(params: {
|
|
828
|
-
worldId: UUID;
|
|
829
|
-
count?: number;
|
|
830
|
-
tableName?: string;
|
|
831
|
-
}): Promise<Memory[]>;
|
|
832
|
-
}
|
|
833
|
-
/**
|
|
834
|
-
* Result interface for embedding similarity searches
|
|
835
|
-
*/
|
|
836
|
-
interface EmbeddingSearchResult {
|
|
837
|
-
embedding: number[];
|
|
838
|
-
levenshtein_score: number;
|
|
839
|
-
}
|
|
840
|
-
/**
|
|
841
|
-
* Options for memory retrieval operations
|
|
842
|
-
*/
|
|
843
|
-
interface MemoryRetrievalOptions {
|
|
844
|
-
roomId: UUID;
|
|
845
|
-
count?: number;
|
|
846
|
-
unique?: boolean;
|
|
847
|
-
start?: number;
|
|
848
|
-
end?: number;
|
|
849
|
-
agentId?: UUID;
|
|
850
|
-
}
|
|
851
|
-
/**
|
|
852
|
-
* Options for memory search operations
|
|
853
|
-
*/
|
|
854
|
-
interface MemorySearchOptions {
|
|
855
|
-
embedding: number[];
|
|
856
|
-
match_threshold?: number;
|
|
857
|
-
count?: number;
|
|
858
|
-
roomId: UUID;
|
|
859
|
-
agentId?: UUID;
|
|
860
|
-
unique?: boolean;
|
|
861
|
-
metadata?: Partial<MemoryMetadata>;
|
|
862
|
-
}
|
|
863
|
-
/**
|
|
864
|
-
* Options for multi-room memory retrieval
|
|
865
|
-
*/
|
|
866
|
-
interface MultiRoomMemoryOptions {
|
|
867
|
-
roomIds: UUID[];
|
|
868
|
-
limit?: number;
|
|
869
|
-
agentId?: UUID;
|
|
870
|
-
}
|
|
871
|
-
/**
|
|
872
|
-
* Unified options pattern for memory operations
|
|
873
|
-
* Provides a simpler, more consistent interface
|
|
874
|
-
*/
|
|
875
|
-
interface UnifiedMemoryOptions {
|
|
876
|
-
roomId: UUID;
|
|
877
|
-
limit?: number;
|
|
878
|
-
agentId?: UUID;
|
|
879
|
-
unique?: boolean;
|
|
880
|
-
start?: number;
|
|
881
|
-
end?: number;
|
|
882
|
-
}
|
|
883
|
-
/**
|
|
884
|
-
* Specialized memory search options
|
|
885
|
-
*/
|
|
886
|
-
interface UnifiedSearchOptions extends UnifiedMemoryOptions {
|
|
887
|
-
embedding: number[];
|
|
888
|
-
similarity?: number;
|
|
889
|
-
}
|
|
890
|
-
/**
|
|
891
|
-
* Information describing the target of a message.
|
|
892
|
-
*/
|
|
893
|
-
interface TargetInfo {
|
|
894
|
-
source: string;
|
|
895
|
-
roomId?: UUID;
|
|
896
|
-
channelId?: string;
|
|
897
|
-
serverId?: string;
|
|
898
|
-
entityId?: UUID;
|
|
899
|
-
threadId?: string;
|
|
900
|
-
}
|
|
901
|
-
/**
|
|
902
|
-
* Function signature for handlers responsible for sending messages to specific platforms.
|
|
903
|
-
*/
|
|
904
|
-
type SendHandlerFunction = (runtime: IAgentRuntime, target: TargetInfo, content: Content) => Promise<void>;
|
|
905
|
-
/**
|
|
906
|
-
* Represents the core runtime environment for an agent.
|
|
907
|
-
* Defines methods for database interaction, plugin management, event handling,
|
|
908
|
-
* state composition, model usage, and task management.
|
|
909
|
-
*/
|
|
910
|
-
interface IAgentRuntime extends IDatabaseAdapter {
|
|
911
|
-
agentId: UUID;
|
|
912
|
-
character: Character;
|
|
913
|
-
providers: Provider[];
|
|
914
|
-
actions: Action[];
|
|
915
|
-
evaluators: Evaluator[];
|
|
916
|
-
plugins: Plugin[];
|
|
917
|
-
services: Map<ServiceTypeName, Service>;
|
|
918
|
-
events: Map<string, ((params: any) => Promise<void>)[]>;
|
|
919
|
-
fetch?: typeof fetch | null;
|
|
920
|
-
routes: Route[];
|
|
921
|
-
registerPlugin(plugin: Plugin): Promise<void>;
|
|
922
|
-
initialize(): Promise<void>;
|
|
923
|
-
getConnection(): Promise<any>;
|
|
924
|
-
getService<T extends Service>(service: ServiceTypeName | string): T | null;
|
|
925
|
-
getAllServices(): Map<ServiceTypeName, Service>;
|
|
926
|
-
registerService(service: typeof Service): Promise<void>;
|
|
927
|
-
registerDatabaseAdapter(adapter: IDatabaseAdapter): void;
|
|
928
|
-
setSetting(key: string, value: string | boolean | null | any, secret?: boolean): void;
|
|
929
|
-
getSetting(key: string): string | boolean | null | any;
|
|
930
|
-
getConversationLength(): number;
|
|
931
|
-
processActions(message: Memory, responses: Memory[], state?: State, callback?: HandlerCallback): Promise<void>;
|
|
932
|
-
evaluate(message: Memory, state?: State, didRespond?: boolean, callback?: HandlerCallback, responses?: Memory[]): Promise<Evaluator[] | null>;
|
|
933
|
-
registerProvider(provider: Provider): void;
|
|
934
|
-
registerAction(action: Action): void;
|
|
935
|
-
registerEvaluator(evaluator: Evaluator): void;
|
|
936
|
-
ensureConnection({ entityId, roomId, metadata, userName, worldName, name, source, channelId, serverId, type, worldId, userId, }: {
|
|
937
|
-
entityId: UUID;
|
|
938
|
-
roomId: UUID;
|
|
939
|
-
userName?: string;
|
|
940
|
-
name?: string;
|
|
941
|
-
worldName?: string;
|
|
942
|
-
source?: string;
|
|
943
|
-
channelId?: string;
|
|
944
|
-
serverId?: string;
|
|
945
|
-
type: ChannelType;
|
|
946
|
-
worldId: UUID;
|
|
947
|
-
userId?: UUID;
|
|
948
|
-
metadata?: Record<string, any>;
|
|
949
|
-
}): Promise<void>;
|
|
950
|
-
ensureParticipantInRoom(entityId: UUID, roomId: UUID): Promise<void>;
|
|
951
|
-
ensureWorldExists(world: World): Promise<void>;
|
|
952
|
-
ensureRoomExists(room: Room): Promise<void>;
|
|
953
|
-
composeState(message: Memory, includeList?: string[], onlyInclude?: boolean, skipCache?: boolean): Promise<State>;
|
|
954
|
-
/**
|
|
955
|
-
* Use a model with strongly typed parameters and return values based on model type
|
|
956
|
-
* @template T - The model type to use
|
|
957
|
-
* @template R - The expected return type, defaults to the type defined in ModelResultMap[T]
|
|
958
|
-
* @param {T} modelType - The type of model to use
|
|
959
|
-
* @param {ModelParamsMap[T] | any} params - The parameters for the model, typed based on model type
|
|
960
|
-
* @returns {Promise<R>} - The model result, typed based on the provided generic type parameter
|
|
961
|
-
*/
|
|
962
|
-
useModel<T extends ModelTypeName, R = ModelResultMap[T]>(modelType: T, params: Omit<ModelParamsMap[T], 'runtime'> | any): Promise<R>;
|
|
963
|
-
registerModel(modelType: ModelTypeName | string, handler: (params: any) => Promise<any>, provider: string, priority?: number): void;
|
|
964
|
-
getModel(modelType: ModelTypeName | string): ((runtime: IAgentRuntime, params: any) => Promise<any>) | undefined;
|
|
965
|
-
registerEvent(event: string, handler: (params: any) => Promise<void>): void;
|
|
966
|
-
getEvent(event: string): ((params: any) => Promise<void>)[] | undefined;
|
|
967
|
-
emitEvent(event: string | string[], params: any): Promise<void>;
|
|
968
|
-
registerTaskWorker(taskHandler: TaskWorker): void;
|
|
969
|
-
getTaskWorker(name: string): TaskWorker | undefined;
|
|
970
|
-
stop(): Promise<void>;
|
|
971
|
-
addEmbeddingToMemory(memory: Memory): Promise<Memory>;
|
|
972
|
-
getAllMemories(): Promise<Memory[]>;
|
|
973
|
-
clearAllAgentMemories(): Promise<void>;
|
|
974
|
-
createRunId(): UUID;
|
|
975
|
-
startRun(): UUID;
|
|
976
|
-
endRun(): void;
|
|
977
|
-
getCurrentRunId(): UUID;
|
|
978
|
-
getEntityById(entityId: UUID): Promise<Entity | null>;
|
|
979
|
-
getRoom(roomId: UUID): Promise<Room | null>;
|
|
980
|
-
createEntity(entity: Entity): Promise<boolean>;
|
|
981
|
-
createRoom({ id, name, source, type, channelId, serverId, worldId }: Room): Promise<UUID>;
|
|
982
|
-
addParticipant(entityId: UUID, roomId: UUID): Promise<boolean>;
|
|
983
|
-
getRooms(worldId: UUID): Promise<Room[]>;
|
|
984
|
-
/**
|
|
985
|
-
* Registers a handler function responsible for sending messages to a specific source/platform.
|
|
986
|
-
* @param source - The unique identifier string for the source (e.g., 'discord', 'telegram').
|
|
987
|
-
* @param handler - The SendHandlerFunction to be called for this source.
|
|
988
|
-
*/
|
|
989
|
-
registerSendHandler(source: string, handler: SendHandlerFunction): void;
|
|
990
|
-
/**
|
|
991
|
-
* Sends a message to a specified target using the appropriate registered handler.
|
|
992
|
-
* @param target - Information describing the target recipient and platform.
|
|
993
|
-
* @param content - The message content to send.
|
|
994
|
-
* @returns Promise resolving when the message sending process is initiated or completed.
|
|
995
|
-
*/
|
|
996
|
-
sendMessageToTarget(target: TargetInfo, content: Content): Promise<void>;
|
|
997
|
-
}
|
|
998
|
-
/**
|
|
999
|
-
* Interface for settings object with key-value pairs.
|
|
1000
|
-
*/
|
|
1001
|
-
/**
|
|
1002
|
-
* Interface representing settings with string key-value pairs.
|
|
1003
|
-
*/
|
|
1004
|
-
interface RuntimeSettings {
|
|
1005
|
-
[key: string]: string | undefined;
|
|
1006
|
-
}
|
|
1007
|
-
/**
|
|
1008
|
-
* Represents a single item of knowledge that can be processed and stored by the agent.
|
|
1009
|
-
* Knowledge items consist of content (text and optional structured data) and metadata.
|
|
1010
|
-
* These items are typically added to the agent's knowledge base via `AgentRuntime.addKnowledge`
|
|
1011
|
-
* and retrieved using `AgentRuntime.getKnowledge`.
|
|
1012
|
-
* The `id` is a unique identifier for the knowledge item, often derived from its source or content.
|
|
1013
|
-
*/
|
|
1014
|
-
type KnowledgeItem = {
|
|
1015
|
-
/** A Universally Unique Identifier for this specific knowledge item. */
|
|
1016
|
-
id: UUID;
|
|
1017
|
-
/** The actual content of the knowledge item, which must include text and can have other fields. */
|
|
1018
|
-
content: Content;
|
|
1019
|
-
/** Optional metadata associated with this knowledge item, conforming to `MemoryMetadata`. */
|
|
1020
|
-
metadata?: MemoryMetadata;
|
|
1021
|
-
};
|
|
1022
|
-
/**
|
|
1023
|
-
* Defines the scope or visibility of knowledge items within the agent's system.
|
|
1024
|
-
* - `SHARED`: Indicates knowledge that is broadly accessible, potentially across different agents or users if the system architecture permits.
|
|
1025
|
-
* - `PRIVATE`: Indicates knowledge that is restricted, typically to the specific agent or user context it belongs to.
|
|
1026
|
-
* This enum is used to manage access and retrieval of knowledge items, often in conjunction with `AgentRuntime.addKnowledge` or `AgentRuntime.getKnowledge` scopes.
|
|
1027
|
-
*/
|
|
1028
|
-
declare enum KnowledgeScope {
|
|
1029
|
-
SHARED = "shared",
|
|
1030
|
-
PRIVATE = "private"
|
|
1031
|
-
}
|
|
1032
|
-
/**
|
|
1033
|
-
* Specifies prefixes for keys used in caching mechanisms, helping to namespace cached data.
|
|
1034
|
-
* For example, `KNOWLEDGE` might be used to prefix keys for cached knowledge embeddings or processed documents.
|
|
1035
|
-
* This helps in organizing the cache and avoiding key collisions.
|
|
1036
|
-
* Used internally by caching strategies, potentially within `IDatabaseAdapter` cache methods or runtime caching layers.
|
|
1037
|
-
*/
|
|
1038
|
-
declare enum CacheKeyPrefix {
|
|
1039
|
-
KNOWLEDGE = "knowledge"
|
|
1040
|
-
}
|
|
1041
|
-
/**
|
|
1042
|
-
* Represents an item within a directory listing, specifically for knowledge loading.
|
|
1043
|
-
* When an agent's `Character.knowledge` configuration includes a directory, this type
|
|
1044
|
-
* is used to specify the path to that directory and whether its contents should be treated as shared.
|
|
1045
|
-
* - `directory`: The path to the directory containing knowledge files.
|
|
1046
|
-
* - `shared`: An optional boolean (defaults to false) indicating if the knowledge from this directory is considered shared or private.
|
|
1047
|
-
*/
|
|
1048
|
-
interface DirectoryItem {
|
|
1049
|
-
/** The path to the directory containing knowledge files. */
|
|
1050
|
-
directory: string;
|
|
1051
|
-
/** If true, knowledge from this directory is considered shared; otherwise, it's private. Defaults to false. */
|
|
1052
|
-
shared?: boolean;
|
|
1053
|
-
}
|
|
1054
|
-
/**
|
|
1055
|
-
* Represents a row structure, typically from a database query related to text chunking or processing.
|
|
1056
|
-
* This interface is quite minimal and seems to be a placeholder or a base for more specific chunk-related types.
|
|
1057
|
-
* The `id` would be the unique identifier for the chunk.
|
|
1058
|
-
* It might be used when splitting large documents into smaller, manageable pieces for embedding or analysis.
|
|
1059
|
-
*/
|
|
1060
|
-
interface ChunkRow {
|
|
1061
|
-
/** The unique identifier for this chunk of text. */
|
|
1062
|
-
id: string;
|
|
1063
|
-
}
|
|
1064
|
-
/**
|
|
1065
|
-
* Parameters for generating text using a language model.
|
|
1066
|
-
* This structure is typically passed to `AgentRuntime.useModel` when the `modelType` is one of
|
|
1067
|
-
* `ModelType.TEXT_SMALL`, `ModelType.TEXT_LARGE`, `ModelType.TEXT_REASONING_SMALL`,
|
|
1068
|
-
* `ModelType.TEXT_REASONING_LARGE`, or `ModelType.TEXT_COMPLETION`.
|
|
1069
|
-
* It includes essential information like the prompt, model type, and various generation controls.
|
|
1070
|
-
*/
|
|
1071
|
-
type GenerateTextParams = {
|
|
1072
|
-
/** The `AgentRuntime` instance, providing access to models and other services. */
|
|
1073
|
-
runtime: IAgentRuntime;
|
|
1074
|
-
/** The input string or prompt that the language model will use to generate text. */
|
|
1075
|
-
prompt: string;
|
|
1076
|
-
/** Specifies the type of text generation model to use (e.g., TEXT_LARGE, REASONING_SMALL). */
|
|
1077
|
-
modelType: ModelTypeName;
|
|
1078
|
-
/** Optional. The maximum number of tokens to generate in the response. */
|
|
1079
|
-
maxTokens?: number;
|
|
1080
|
-
/** Optional. Controls randomness (0.0-1.0). Lower values are more deterministic, higher are more creative. */
|
|
1081
|
-
temperature?: number;
|
|
1082
|
-
/** Optional. Penalizes new tokens based on their existing frequency in the text so far. */
|
|
1083
|
-
frequencyPenalty?: number;
|
|
1084
|
-
/** Optional. Penalizes new tokens based on whether they appear in the text so far. */
|
|
1085
|
-
presencePenalty?: number;
|
|
1086
|
-
/** Optional. A list of sequences at which the model will stop generating further tokens. */
|
|
1087
|
-
stopSequences?: string[];
|
|
1088
|
-
};
|
|
1089
|
-
/**
|
|
1090
|
-
* Parameters for tokenizing text, i.e., converting a string into a sequence of numerical tokens.
|
|
1091
|
-
* This is a common preprocessing step for many language models.
|
|
1092
|
-
* This structure is used with `AgentRuntime.useModel` when the `modelType` is `ModelType.TEXT_TOKENIZER_ENCODE`.
|
|
1093
|
-
*/
|
|
1094
|
-
interface TokenizeTextParams {
|
|
1095
|
-
/** The input string to be tokenized. */
|
|
1096
|
-
prompt: string;
|
|
1097
|
-
/** The model type to use for tokenization, which determines the tokenizer algorithm and vocabulary. */
|
|
1098
|
-
modelType: ModelTypeName;
|
|
1099
|
-
}
|
|
1100
|
-
/**
|
|
1101
|
-
* Parameters for detokenizing text, i.e., converting a sequence of numerical tokens back into a string.
|
|
1102
|
-
* This is the reverse operation of tokenization.
|
|
1103
|
-
* This structure is used with `AgentRuntime.useModel` when the `modelType` is `ModelType.TEXT_TOKENIZER_DECODE`.
|
|
1104
|
-
*/
|
|
1105
|
-
interface DetokenizeTextParams {
|
|
1106
|
-
/** An array of numerical tokens to be converted back into text. */
|
|
1107
|
-
tokens: number[];
|
|
1108
|
-
/** The model type used for detokenization, ensuring consistency with the original tokenization. */
|
|
1109
|
-
modelType: ModelTypeName;
|
|
1110
|
-
}
|
|
1111
|
-
/**
|
|
1112
|
-
* Represents a test case for evaluating agent or plugin functionality.
|
|
1113
|
-
* Each test case has a name and a function that contains the test logic.
|
|
1114
|
-
* The test function receives the `IAgentRuntime` instance, allowing it to interact with the agent's capabilities.
|
|
1115
|
-
* Test cases are typically grouped into `TestSuite`s.
|
|
1116
|
-
*/
|
|
1117
|
-
interface TestCase {
|
|
1118
|
-
/** A descriptive name for the test case, e.g., "should respond to greetings". */
|
|
1119
|
-
name: string;
|
|
1120
|
-
/**
|
|
1121
|
-
* The function that executes the test logic. It can be synchronous or asynchronous.
|
|
1122
|
-
* It receives the `IAgentRuntime` to interact with the agent and its services.
|
|
1123
|
-
* The function should typically contain assertions to verify expected outcomes.
|
|
1124
|
-
*/
|
|
1125
|
-
fn: (runtime: IAgentRuntime) => Promise<void> | void;
|
|
1126
|
-
}
|
|
1127
|
-
/**
|
|
1128
|
-
* Represents a suite of related test cases for an agent or plugin.
|
|
1129
|
-
* This helps in organizing tests and running them collectively.
|
|
1130
|
-
* A `ProjectAgent` can define one or more `TestSuite`s.
|
|
1131
|
-
*/
|
|
1132
|
-
interface TestSuite {
|
|
1133
|
-
/** A descriptive name for the test suite, e.g., "Core Functionality Tests". */
|
|
1134
|
-
name: string;
|
|
1135
|
-
/** An array of `TestCase` objects that belong to this suite. */
|
|
1136
|
-
tests: TestCase[];
|
|
1137
|
-
}
|
|
1138
|
-
/**
|
|
1139
|
-
* Represents an agent's registration details within a Trusted Execution Environment (TEE) context.
|
|
1140
|
-
* This is typically stored in a database table (e.g., `TeeAgent`) to manage agents operating in a TEE.
|
|
1141
|
-
* It allows for multiple registrations of the same `agentId` to support scenarios where an agent might restart,
|
|
1142
|
-
* generating a new keypair and attestation each time.
|
|
1143
|
-
*/
|
|
1144
|
-
interface TeeAgent {
|
|
1145
|
-
/** Primary key for the TEE agent registration record (e.g., a UUID or auto-incrementing ID). */
|
|
1146
|
-
id: string;
|
|
1147
|
-
/** The core identifier of the agent, which can be duplicated across multiple TEE registrations. */
|
|
1148
|
-
agentId: string;
|
|
1149
|
-
/** The human-readable name of the agent. */
|
|
1150
|
-
agentName: string;
|
|
1151
|
-
/** Timestamp (e.g., Unix epoch in milliseconds) when this TEE registration was created. */
|
|
1152
|
-
createdAt: number;
|
|
1153
|
-
/** The public key associated with this specific TEE agent instance/session. */
|
|
1154
|
-
publicKey: string;
|
|
1155
|
-
/** The attestation document proving the authenticity and integrity of the TEE instance. */
|
|
1156
|
-
attestation: string;
|
|
1157
|
-
}
|
|
1158
|
-
/**
|
|
1159
|
-
* Defines the operational modes for a Trusted Execution Environment (TEE).
|
|
1160
|
-
* This enum is used to configure how TEE functionalities are engaged, allowing for
|
|
1161
|
-
* different setups for local development, Docker-based development, and production.
|
|
1162
|
-
*/
|
|
1163
|
-
declare enum TEEMode {
|
|
1164
|
-
/** TEE functionality is completely disabled. */
|
|
1165
|
-
OFF = "OFF",
|
|
1166
|
-
/** For local development, potentially using a TEE simulator. */
|
|
1167
|
-
LOCAL = "LOCAL",// For local development with simulator
|
|
1168
|
-
/** For Docker-based development environments, possibly with a TEE simulator. */
|
|
1169
|
-
DOCKER = "DOCKER",// For docker development with simulator
|
|
1170
|
-
/** For production deployments, using actual TEE hardware without a simulator. */
|
|
1171
|
-
PRODUCTION = "PRODUCTION"
|
|
1172
|
-
}
|
|
1173
|
-
/**
|
|
1174
|
-
* Represents a quote obtained during remote attestation for a Trusted Execution Environment (TEE).
|
|
1175
|
-
* This quote is a piece of evidence provided by the TEE, cryptographically signed, which can be
|
|
1176
|
-
* verified by a relying party to ensure the TEE's integrity and authenticity.
|
|
1177
|
-
*/
|
|
1178
|
-
interface RemoteAttestationQuote {
|
|
1179
|
-
/** The attestation quote data, typically a base64 encoded string or similar format. */
|
|
1180
|
-
quote: string;
|
|
1181
|
-
/** Timestamp (e.g., Unix epoch in milliseconds) when the quote was generated or received. */
|
|
1182
|
-
timestamp: number;
|
|
1183
|
-
}
|
|
1184
|
-
/**
|
|
1185
|
-
* Data structure used in the attestation process for deriving a key within a Trusted Execution Environment (TEE).
|
|
1186
|
-
* This information helps establish a secure channel or verify the identity of the agent instance
|
|
1187
|
-
* requesting key derivation.
|
|
1188
|
-
*/
|
|
1189
|
-
interface DeriveKeyAttestationData {
|
|
1190
|
-
/** The unique identifier of the agent for which the key derivation is being attested. */
|
|
1191
|
-
agentId: string;
|
|
1192
|
-
/** The public key of the agent instance involved in the key derivation process. */
|
|
1193
|
-
publicKey: string;
|
|
1194
|
-
/** Optional subject or context information related to the key derivation. */
|
|
1195
|
-
subject?: string;
|
|
1196
|
-
}
|
|
1197
|
-
/**
|
|
1198
|
-
* Represents a message that has been attested by a Trusted Execution Environment (TEE).
|
|
1199
|
-
* This structure binds a message to an agent's identity and a timestamp, all within the
|
|
1200
|
-
* context of a remote attestation process, ensuring the message originated from a trusted TEE instance.
|
|
1201
|
-
*/
|
|
1202
|
-
interface RemoteAttestationMessage {
|
|
1203
|
-
/** The unique identifier of the agent sending the attested message. */
|
|
1204
|
-
agentId: string;
|
|
1205
|
-
/** Timestamp (e.g., Unix epoch in milliseconds) when the message was attested or sent. */
|
|
1206
|
-
timestamp: number;
|
|
1207
|
-
/** The actual message content, including details about the entity, room, and the content itself. */
|
|
1208
|
-
message: {
|
|
1209
|
-
entityId: string;
|
|
1210
|
-
roomId: string;
|
|
1211
|
-
content: string;
|
|
1212
|
-
};
|
|
1213
|
-
}
|
|
1214
|
-
/**
|
|
1215
|
-
* Enumerates different types or vendors of Trusted Execution Environments (TEEs).
|
|
1216
|
-
* This allows the system to adapt to specific TEE technologies, like Intel TDX on DSTACK.
|
|
1217
|
-
*/
|
|
1218
|
-
declare enum TeeType {
|
|
1219
|
-
/** Represents Intel Trusted Domain Extensions (TDX) running on DSTACK infrastructure. */
|
|
1220
|
-
TDX_DSTACK = "tdx_dstack"
|
|
1221
|
-
}
|
|
1222
|
-
/**
|
|
1223
|
-
* Configuration options specific to a particular Trusted Execution Environment (TEE) vendor.
|
|
1224
|
-
* This allows for vendor-specific settings to be passed to the TEE plugin or service.
|
|
1225
|
-
* The structure is a generic key-value map, as configurations can vary widely between vendors.
|
|
1226
|
-
*/
|
|
1227
|
-
interface TeeVendorConfig {
|
|
1228
|
-
[key: string]: unknown;
|
|
1229
|
-
}
|
|
1230
|
-
/**
|
|
1231
|
-
* Configuration for a TEE (Trusted Execution Environment) plugin.
|
|
1232
|
-
* This allows specifying the TEE vendor and any vendor-specific configurations.
|
|
1233
|
-
* It's used to initialize and configure TEE-related functionalities within the agent system.
|
|
1234
|
-
*/
|
|
1235
|
-
interface TeePluginConfig {
|
|
1236
|
-
/** Optional. The name or identifier of the TEE vendor (e.g., 'tdx_dstack' from `TeeType`). */
|
|
1237
|
-
vendor?: string;
|
|
1238
|
-
/** Optional. Vendor-specific configuration options, conforming to `TeeVendorConfig`. */
|
|
1239
|
-
vendorConfig?: TeeVendorConfig;
|
|
1240
|
-
}
|
|
1241
|
-
/**
|
|
1242
|
-
* Defines the contract for a Task Worker, which is responsible for executing a specific type of task.
|
|
1243
|
-
* Task workers are registered with the `AgentRuntime` and are invoked when a `Task` of their designated `name` needs processing.
|
|
1244
|
-
* This pattern allows for modular and extensible background task processing.
|
|
1245
|
-
*/
|
|
1246
|
-
interface TaskWorker {
|
|
1247
|
-
/** The unique name of the task type this worker handles. This name links `Task` instances to this worker. */
|
|
1248
|
-
name: string;
|
|
1249
|
-
/**
|
|
1250
|
-
* The core execution logic for the task. This function is called by the runtime when a task needs to be processed.
|
|
1251
|
-
* It receives the `AgentRuntime`, task-specific `options`, and the `Task` object itself.
|
|
1252
|
-
*/
|
|
1253
|
-
execute: (runtime: IAgentRuntime, options: {
|
|
1254
|
-
[key: string]: unknown;
|
|
1255
|
-
}, task: Task) => Promise<void>;
|
|
1256
|
-
/**
|
|
1257
|
-
* Optional validation function that can be used to determine if a task is valid or should be executed,
|
|
1258
|
-
* often based on the current message and state. This might be used by an action or evaluator
|
|
1259
|
-
* before creating or queueing a task.
|
|
1260
|
-
*/
|
|
1261
|
-
validate?: (runtime: IAgentRuntime, message: Memory, state: State) => Promise<boolean>;
|
|
1262
|
-
}
|
|
1263
|
-
/**
|
|
1264
|
-
* Defines metadata associated with a `Task`.
|
|
1265
|
-
* This can include scheduling information like `updateInterval` or UI-related details
|
|
1266
|
-
* for presenting task options to a user.
|
|
1267
|
-
* The `[key: string]: unknown;` allows for additional, unspecified metadata fields.
|
|
1268
|
-
*/
|
|
1269
|
-
type TaskMetadata = {
|
|
1270
|
-
/** Optional. If the task is recurring, this specifies the interval in milliseconds between updates or executions. */
|
|
1271
|
-
updateInterval?: number;
|
|
1272
|
-
/** Optional. Describes options or parameters that can be configured for this task, often for UI presentation. */
|
|
1273
|
-
options?: {
|
|
1274
|
-
name: string;
|
|
1275
|
-
description: string;
|
|
1276
|
-
}[];
|
|
1277
|
-
/** Allows for other dynamic metadata properties related to the task. */
|
|
1278
|
-
[key: string]: unknown;
|
|
1279
|
-
};
|
|
1280
|
-
/**
|
|
1281
|
-
* Represents a task to be performed, often in the background or at a later time.
|
|
1282
|
-
* Tasks are managed by the `AgentRuntime` and processed by registered `TaskWorker`s.
|
|
1283
|
-
* They can be associated with a room, world, and tagged for categorization and retrieval.
|
|
1284
|
-
* The `IDatabaseAdapter` handles persistence of task data.
|
|
1285
|
-
*/
|
|
1286
|
-
interface Task {
|
|
1287
|
-
/** Optional. A Universally Unique Identifier for the task. Generated if not provided. */
|
|
1288
|
-
id?: UUID;
|
|
1289
|
-
/** The name of the task, which should correspond to a registered `TaskWorker.name`. */
|
|
1290
|
-
name: string;
|
|
1291
|
-
/** Optional. Timestamp of the last update to this task. */
|
|
1292
|
-
updatedAt?: number;
|
|
1293
|
-
/** Optional. Metadata associated with the task, conforming to `TaskMetadata`. */
|
|
1294
|
-
metadata?: TaskMetadata;
|
|
1295
|
-
/** A human-readable description of what the task does or its purpose. */
|
|
1296
|
-
description: string;
|
|
1297
|
-
/** Optional. The UUID of the room this task is associated with. */
|
|
1298
|
-
roomId?: UUID;
|
|
1299
|
-
/** Optional. The UUID of the world this task is associated with. */
|
|
1300
|
-
worldId?: UUID;
|
|
1301
|
-
entityId?: UUID;
|
|
1302
|
-
tags: string[];
|
|
1303
|
-
}
|
|
1304
|
-
/**
|
|
1305
|
-
* Defines roles within a system, typically for access control or permissions, often within a `World`.
|
|
1306
|
-
* - `OWNER`: Represents the highest level of control, typically the creator or primary administrator.
|
|
1307
|
-
* - `ADMIN`: Represents administrative privileges, usually a subset of owner capabilities.
|
|
1308
|
-
* - `NONE`: Indicates no specific role or default, minimal permissions.
|
|
1309
|
-
* These roles are often used in `World.metadata.roles` to assign roles to entities.
|
|
1310
|
-
*/
|
|
1311
|
-
declare enum Role {
|
|
1312
|
-
OWNER = "OWNER",
|
|
1313
|
-
ADMIN = "ADMIN",
|
|
1314
|
-
NONE = "NONE"
|
|
1315
|
-
}
|
|
1316
|
-
interface Setting {
|
|
1317
|
-
name: string;
|
|
1318
|
-
description: string;
|
|
1319
|
-
usageDescription: string;
|
|
1320
|
-
value: string | boolean | null;
|
|
1321
|
-
required: boolean;
|
|
1322
|
-
public?: boolean;
|
|
1323
|
-
secret?: boolean;
|
|
1324
|
-
validation?: (value: any) => boolean;
|
|
1325
|
-
dependsOn?: string[];
|
|
1326
|
-
onSetAction?: (value: any) => string;
|
|
1327
|
-
visibleIf?: (settings: {
|
|
1328
|
-
[key: string]: Setting;
|
|
1329
|
-
}) => boolean;
|
|
1330
|
-
}
|
|
1331
|
-
interface WorldSettings {
|
|
1332
|
-
[key: string]: Setting;
|
|
1333
|
-
}
|
|
1334
|
-
interface OnboardingConfig {
|
|
1335
|
-
settings: {
|
|
1336
|
-
[key: string]: Omit<Setting, 'value'>;
|
|
1337
|
-
};
|
|
1338
|
-
}
|
|
1339
|
-
/**
|
|
1340
|
-
* Base parameters common to all model types
|
|
1341
|
-
*/
|
|
1342
|
-
interface BaseModelParams {
|
|
1343
|
-
/** The agent runtime for accessing services and utilities */
|
|
1344
|
-
runtime: IAgentRuntime;
|
|
1345
|
-
}
|
|
1346
|
-
/**
|
|
1347
|
-
* Parameters for text generation models
|
|
1348
|
-
*/
|
|
1349
|
-
interface TextGenerationParams extends BaseModelParams {
|
|
1350
|
-
/** The prompt to generate text from */
|
|
1351
|
-
prompt: string;
|
|
1352
|
-
/** Model temperature (0.0 to 1.0, lower is more deterministic) */
|
|
1353
|
-
temperature?: number;
|
|
1354
|
-
/** Maximum number of tokens to generate */
|
|
1355
|
-
maxTokens?: number;
|
|
1356
|
-
/** Sequences that should stop generation when encountered */
|
|
1357
|
-
stopSequences?: string[];
|
|
1358
|
-
/** Frequency penalty to apply */
|
|
1359
|
-
frequencyPenalty?: number;
|
|
1360
|
-
/** Presence penalty to apply */
|
|
1361
|
-
presencePenalty?: number;
|
|
1362
|
-
}
|
|
1363
|
-
/**
|
|
1364
|
-
* Parameters for text embedding models
|
|
1365
|
-
*/
|
|
1366
|
-
interface TextEmbeddingParams extends BaseModelParams {
|
|
1367
|
-
/** The text to create embeddings for */
|
|
1368
|
-
text: string;
|
|
1369
|
-
}
|
|
1370
|
-
/**
|
|
1371
|
-
* Parameters for image generation models
|
|
1372
|
-
*/
|
|
1373
|
-
interface ImageGenerationParams extends BaseModelParams {
|
|
1374
|
-
/** The prompt describing the image to generate */
|
|
1375
|
-
prompt: string;
|
|
1376
|
-
/** The dimensions of the image to generate */
|
|
1377
|
-
size?: string;
|
|
1378
|
-
/** Number of images to generate */
|
|
1379
|
-
count?: number;
|
|
1380
|
-
}
|
|
1381
|
-
/**
|
|
1382
|
-
* Parameters for image description models
|
|
1383
|
-
*/
|
|
1384
|
-
interface ImageDescriptionParams extends BaseModelParams {
|
|
1385
|
-
/** The URL or path of the image to describe */
|
|
1386
|
-
imageUrl: string;
|
|
1387
|
-
/** Optional prompt to guide the description */
|
|
1388
|
-
prompt?: string;
|
|
1389
|
-
}
|
|
1390
|
-
/**
|
|
1391
|
-
* Parameters for transcription models
|
|
1392
|
-
*/
|
|
1393
|
-
interface TranscriptionParams extends BaseModelParams {
|
|
1394
|
-
/** The URL or path of the audio file to transcribe */
|
|
1395
|
-
audioUrl: string;
|
|
1396
|
-
/** Optional prompt to guide transcription */
|
|
1397
|
-
prompt?: string;
|
|
1398
|
-
}
|
|
1399
|
-
/**
|
|
1400
|
-
* Parameters for text-to-speech models
|
|
1401
|
-
*/
|
|
1402
|
-
interface TextToSpeechParams extends BaseModelParams {
|
|
1403
|
-
/** The text to convert to speech */
|
|
1404
|
-
text: string;
|
|
1405
|
-
/** The voice to use */
|
|
1406
|
-
voice?: string;
|
|
1407
|
-
/** The speaking speed */
|
|
1408
|
-
speed?: number;
|
|
1409
|
-
}
|
|
1410
|
-
/**
|
|
1411
|
-
* Parameters for audio processing models
|
|
1412
|
-
*/
|
|
1413
|
-
interface AudioProcessingParams extends BaseModelParams {
|
|
1414
|
-
/** The URL or path of the audio file to process */
|
|
1415
|
-
audioUrl: string;
|
|
1416
|
-
/** The type of audio processing to perform */
|
|
1417
|
-
processingType: string;
|
|
1418
|
-
}
|
|
1419
|
-
/**
|
|
1420
|
-
* Parameters for video processing models
|
|
1421
|
-
*/
|
|
1422
|
-
interface VideoProcessingParams extends BaseModelParams {
|
|
1423
|
-
/** The URL or path of the video file to process */
|
|
1424
|
-
videoUrl: string;
|
|
1425
|
-
/** The type of video processing to perform */
|
|
1426
|
-
processingType: string;
|
|
1427
|
-
}
|
|
1428
|
-
/**
|
|
1429
|
-
* Optional JSON schema for validating generated objects
|
|
1430
|
-
*/
|
|
1431
|
-
type JSONSchema = {
|
|
1432
|
-
type: string;
|
|
1433
|
-
properties?: Record<string, any>;
|
|
1434
|
-
required?: string[];
|
|
1435
|
-
items?: JSONSchema;
|
|
1436
|
-
[key: string]: any;
|
|
1437
|
-
};
|
|
1438
|
-
/**
|
|
1439
|
-
* Parameters for object generation models
|
|
1440
|
-
* @template T - The expected return type, inferred from schema if provided
|
|
1441
|
-
*/
|
|
1442
|
-
interface ObjectGenerationParams<T = any> extends BaseModelParams {
|
|
1443
|
-
/** The prompt describing the object to generate */
|
|
1444
|
-
prompt: string;
|
|
1445
|
-
/** Optional JSON schema for validation */
|
|
1446
|
-
schema?: JSONSchema;
|
|
1447
|
-
/** Type of object to generate */
|
|
1448
|
-
output?: 'object' | 'array' | 'enum';
|
|
1449
|
-
/** For enum type, the allowed values */
|
|
1450
|
-
enumValues?: string[];
|
|
1451
|
-
/** Model type to use */
|
|
1452
|
-
modelType?: ModelTypeName;
|
|
1453
|
-
/** Model temperature (0.0 to 1.0) */
|
|
1454
|
-
temperature?: number;
|
|
1455
|
-
/** Sequences that should stop generation */
|
|
1456
|
-
stopSequences?: string[];
|
|
1457
|
-
}
|
|
1458
|
-
/**
|
|
1459
|
-
* Map of model types to their parameter types
|
|
1460
|
-
*/
|
|
1461
|
-
interface ModelParamsMap {
|
|
1462
|
-
[ModelType.TEXT_SMALL]: TextGenerationParams;
|
|
1463
|
-
[ModelType.TEXT_LARGE]: TextGenerationParams;
|
|
1464
|
-
[ModelType.TEXT_EMBEDDING]: TextEmbeddingParams | string | null;
|
|
1465
|
-
[ModelType.TEXT_TOKENIZER_ENCODE]: TokenizeTextParams;
|
|
1466
|
-
[ModelType.TEXT_TOKENIZER_DECODE]: DetokenizeTextParams;
|
|
1467
|
-
[ModelType.TEXT_REASONING_SMALL]: TextGenerationParams;
|
|
1468
|
-
[ModelType.TEXT_REASONING_LARGE]: TextGenerationParams;
|
|
1469
|
-
[ModelType.IMAGE]: ImageGenerationParams;
|
|
1470
|
-
[ModelType.IMAGE_DESCRIPTION]: ImageDescriptionParams | string;
|
|
1471
|
-
[ModelType.TRANSCRIPTION]: TranscriptionParams | Buffer | string;
|
|
1472
|
-
[ModelType.TEXT_TO_SPEECH]: TextToSpeechParams | string;
|
|
1473
|
-
[ModelType.AUDIO]: AudioProcessingParams;
|
|
1474
|
-
[ModelType.VIDEO]: VideoProcessingParams;
|
|
1475
|
-
[ModelType.OBJECT_SMALL]: ObjectGenerationParams<any>;
|
|
1476
|
-
[ModelType.OBJECT_LARGE]: ObjectGenerationParams<any>;
|
|
1477
|
-
[key: string]: BaseModelParams | any;
|
|
1478
|
-
}
|
|
1479
|
-
/**
|
|
1480
|
-
* Map of model types to their return value types
|
|
1481
|
-
*/
|
|
1482
|
-
interface ModelResultMap {
|
|
1483
|
-
[ModelType.TEXT_SMALL]: string;
|
|
1484
|
-
[ModelType.TEXT_LARGE]: string;
|
|
1485
|
-
[ModelType.TEXT_EMBEDDING]: number[];
|
|
1486
|
-
[ModelType.TEXT_TOKENIZER_ENCODE]: number[];
|
|
1487
|
-
[ModelType.TEXT_TOKENIZER_DECODE]: string;
|
|
1488
|
-
[ModelType.TEXT_REASONING_SMALL]: string;
|
|
1489
|
-
[ModelType.TEXT_REASONING_LARGE]: string;
|
|
1490
|
-
[ModelType.IMAGE]: {
|
|
1491
|
-
url: string;
|
|
1492
|
-
}[];
|
|
1493
|
-
[ModelType.IMAGE_DESCRIPTION]: {
|
|
1494
|
-
title: string;
|
|
1495
|
-
description: string;
|
|
1496
|
-
};
|
|
1497
|
-
[ModelType.TRANSCRIPTION]: string;
|
|
1498
|
-
[ModelType.TEXT_TO_SPEECH]: any | Buffer;
|
|
1499
|
-
[ModelType.AUDIO]: any;
|
|
1500
|
-
[ModelType.VIDEO]: any;
|
|
1501
|
-
[ModelType.OBJECT_SMALL]: any;
|
|
1502
|
-
[ModelType.OBJECT_LARGE]: any;
|
|
1503
|
-
[key: string]: any;
|
|
1504
|
-
}
|
|
1505
|
-
/**
|
|
1506
|
-
* Standard event types across all platforms
|
|
1507
|
-
*/
|
|
1508
|
-
declare enum EventType {
|
|
1509
|
-
WORLD_JOINED = "WORLD_JOINED",
|
|
1510
|
-
WORLD_CONNECTED = "WORLD_CONNECTED",
|
|
1511
|
-
WORLD_LEFT = "WORLD_LEFT",
|
|
1512
|
-
ENTITY_JOINED = "ENTITY_JOINED",
|
|
1513
|
-
ENTITY_LEFT = "ENTITY_LEFT",
|
|
1514
|
-
ENTITY_UPDATED = "ENTITY_UPDATED",
|
|
1515
|
-
ROOM_JOINED = "ROOM_JOINED",
|
|
1516
|
-
ROOM_LEFT = "ROOM_LEFT",
|
|
1517
|
-
MESSAGE_RECEIVED = "MESSAGE_RECEIVED",
|
|
1518
|
-
MESSAGE_SENT = "MESSAGE_SENT",
|
|
1519
|
-
MESSAGE_DELETED = "MESSAGE_DELETED",
|
|
1520
|
-
CHANNEL_CLEARED = "CHANNEL_CLEARED",
|
|
1521
|
-
VOICE_MESSAGE_RECEIVED = "VOICE_MESSAGE_RECEIVED",
|
|
1522
|
-
VOICE_MESSAGE_SENT = "VOICE_MESSAGE_SENT",
|
|
1523
|
-
REACTION_RECEIVED = "REACTION_RECEIVED",
|
|
1524
|
-
POST_GENERATED = "POST_GENERATED",
|
|
1525
|
-
INTERACTION_RECEIVED = "INTERACTION_RECEIVED",
|
|
1526
|
-
RUN_STARTED = "RUN_STARTED",
|
|
1527
|
-
RUN_ENDED = "RUN_ENDED",
|
|
1528
|
-
RUN_TIMEOUT = "RUN_TIMEOUT",
|
|
1529
|
-
ACTION_STARTED = "ACTION_STARTED",
|
|
1530
|
-
ACTION_COMPLETED = "ACTION_COMPLETED",
|
|
1531
|
-
EVALUATOR_STARTED = "EVALUATOR_STARTED",
|
|
1532
|
-
EVALUATOR_COMPLETED = "EVALUATOR_COMPLETED",
|
|
1533
|
-
MODEL_USED = "MODEL_USED"
|
|
1534
|
-
}
|
|
1535
|
-
/**
|
|
1536
|
-
* Platform-specific event type prefix
|
|
1537
|
-
*/
|
|
1538
|
-
declare enum PlatformPrefix {
|
|
1539
|
-
DISCORD = "DISCORD",
|
|
1540
|
-
TELEGRAM = "TELEGRAM",
|
|
1541
|
-
TWITTER = "TWITTER"
|
|
1542
|
-
}
|
|
1543
|
-
/**
|
|
1544
|
-
* Base payload interface for all events
|
|
1545
|
-
*/
|
|
1546
|
-
interface EventPayload {
|
|
1547
|
-
runtime: IAgentRuntime;
|
|
1548
|
-
source: string;
|
|
1549
|
-
onComplete?: () => void;
|
|
1550
|
-
}
|
|
1551
|
-
/**
|
|
1552
|
-
* Payload for world-related events
|
|
1553
|
-
*/
|
|
1554
|
-
interface WorldPayload extends EventPayload {
|
|
1555
|
-
world: World;
|
|
1556
|
-
rooms: Room[];
|
|
1557
|
-
entities: Entity[];
|
|
1558
|
-
}
|
|
1559
|
-
/**
|
|
1560
|
-
* Payload for entity-related events
|
|
1561
|
-
*/
|
|
1562
|
-
interface EntityPayload extends EventPayload {
|
|
1563
|
-
entityId: UUID;
|
|
1564
|
-
worldId?: UUID;
|
|
1565
|
-
roomId?: UUID;
|
|
1566
|
-
metadata?: {
|
|
1567
|
-
orginalId: string;
|
|
1568
|
-
username: string;
|
|
1569
|
-
displayName?: string;
|
|
1570
|
-
[key: string]: any;
|
|
1571
|
-
};
|
|
1572
|
-
}
|
|
1573
|
-
/**
|
|
1574
|
-
* Payload for reaction-related events
|
|
1575
|
-
*/
|
|
1576
|
-
interface MessagePayload extends EventPayload {
|
|
1577
|
-
message: Memory;
|
|
1578
|
-
callback?: HandlerCallback;
|
|
1579
|
-
onComplete?: () => void;
|
|
1580
|
-
}
|
|
1581
|
-
/**
|
|
1582
|
-
* Payload for channel cleared events
|
|
1583
|
-
*/
|
|
1584
|
-
interface ChannelClearedPayload extends EventPayload {
|
|
1585
|
-
roomId: UUID;
|
|
1586
|
-
channelId: string;
|
|
1587
|
-
memoryCount: number;
|
|
1588
|
-
}
|
|
1589
|
-
/**
|
|
1590
|
-
* Payload for events that are invoked without a message
|
|
1591
|
-
*/
|
|
1592
|
-
interface InvokePayload extends EventPayload {
|
|
1593
|
-
worldId: UUID;
|
|
1594
|
-
userId: string;
|
|
1595
|
-
roomId: UUID;
|
|
1596
|
-
callback?: HandlerCallback;
|
|
1597
|
-
source: string;
|
|
1598
|
-
}
|
|
1599
|
-
/**
|
|
1600
|
-
* Run event payload type
|
|
1601
|
-
*/
|
|
1602
|
-
interface RunEventPayload extends EventPayload {
|
|
1603
|
-
runId: UUID;
|
|
1604
|
-
messageId: UUID;
|
|
1605
|
-
roomId: UUID;
|
|
1606
|
-
entityId: UUID;
|
|
1607
|
-
startTime: number;
|
|
1608
|
-
status: 'started' | 'completed' | 'timeout';
|
|
1609
|
-
endTime?: number;
|
|
1610
|
-
duration?: number;
|
|
1611
|
-
error?: string;
|
|
1612
|
-
}
|
|
1613
|
-
/**
|
|
1614
|
-
* Action event payload type
|
|
1615
|
-
*/
|
|
1616
|
-
interface ActionEventPayload extends EventPayload {
|
|
1617
|
-
actionId: UUID;
|
|
1618
|
-
actionName: string;
|
|
1619
|
-
startTime?: number;
|
|
1620
|
-
completed?: boolean;
|
|
1621
|
-
error?: Error;
|
|
1622
|
-
}
|
|
1623
|
-
/**
|
|
1624
|
-
* Evaluator event payload type
|
|
1625
|
-
*/
|
|
1626
|
-
interface EvaluatorEventPayload extends EventPayload {
|
|
1627
|
-
evaluatorId: UUID;
|
|
1628
|
-
evaluatorName: string;
|
|
1629
|
-
startTime?: number;
|
|
1630
|
-
completed?: boolean;
|
|
1631
|
-
error?: Error;
|
|
1632
|
-
}
|
|
1633
|
-
/**
|
|
1634
|
-
* Model event payload type
|
|
1635
|
-
*/
|
|
1636
|
-
interface ModelEventPayload extends EventPayload {
|
|
1637
|
-
provider: string;
|
|
1638
|
-
type: ModelTypeName;
|
|
1639
|
-
prompt: string;
|
|
1640
|
-
tokens?: {
|
|
1641
|
-
prompt: number;
|
|
1642
|
-
completion: number;
|
|
1643
|
-
total: number;
|
|
1644
|
-
};
|
|
1645
|
-
}
|
|
1646
|
-
/**
|
|
1647
|
-
* Represents the parameters for a message received handler.
|
|
1648
|
-
* @typedef {Object} MessageReceivedHandlerParams
|
|
1649
|
-
* @property {IAgentRuntime} runtime - The agent runtime associated with the message.
|
|
1650
|
-
* @property {Memory} message - The message received.
|
|
1651
|
-
* @property {HandlerCallback} callback - The callback function to be executed after handling the message.
|
|
1652
|
-
*/
|
|
1653
|
-
type MessageReceivedHandlerParams = {
|
|
1654
|
-
runtime: IAgentRuntime;
|
|
1655
|
-
message: Memory;
|
|
1656
|
-
callback: HandlerCallback;
|
|
1657
|
-
onComplete?: () => void;
|
|
1658
|
-
};
|
|
1659
|
-
/**
|
|
1660
|
-
* Maps event types to their corresponding payload types
|
|
1661
|
-
*/
|
|
1662
|
-
interface EventPayloadMap {
|
|
1663
|
-
[EventType.WORLD_JOINED]: WorldPayload;
|
|
1664
|
-
[EventType.WORLD_CONNECTED]: WorldPayload;
|
|
1665
|
-
[EventType.WORLD_LEFT]: WorldPayload;
|
|
1666
|
-
[EventType.ENTITY_JOINED]: EntityPayload;
|
|
1667
|
-
[EventType.ENTITY_LEFT]: EntityPayload;
|
|
1668
|
-
[EventType.ENTITY_UPDATED]: EntityPayload;
|
|
1669
|
-
[EventType.MESSAGE_RECEIVED]: MessagePayload;
|
|
1670
|
-
[EventType.MESSAGE_SENT]: MessagePayload;
|
|
1671
|
-
[EventType.MESSAGE_DELETED]: MessagePayload;
|
|
1672
|
-
[EventType.REACTION_RECEIVED]: MessagePayload;
|
|
1673
|
-
[EventType.POST_GENERATED]: InvokePayload;
|
|
1674
|
-
[EventType.INTERACTION_RECEIVED]: MessagePayload;
|
|
1675
|
-
[EventType.RUN_STARTED]: RunEventPayload;
|
|
1676
|
-
[EventType.RUN_ENDED]: RunEventPayload;
|
|
1677
|
-
[EventType.RUN_TIMEOUT]: RunEventPayload;
|
|
1678
|
-
[EventType.ACTION_STARTED]: ActionEventPayload;
|
|
1679
|
-
[EventType.ACTION_COMPLETED]: ActionEventPayload;
|
|
1680
|
-
[EventType.EVALUATOR_STARTED]: EvaluatorEventPayload;
|
|
1681
|
-
[EventType.EVALUATOR_COMPLETED]: EvaluatorEventPayload;
|
|
1682
|
-
[EventType.MODEL_USED]: ModelEventPayload;
|
|
1683
|
-
[EventType.CHANNEL_CLEARED]: ChannelClearedPayload;
|
|
1684
|
-
}
|
|
1685
|
-
/**
|
|
1686
|
-
* Event handler function type
|
|
1687
|
-
*/
|
|
1688
|
-
type EventHandler<T extends keyof EventPayloadMap> = (payload: EventPayloadMap[T]) => Promise<void>;
|
|
1689
|
-
/**
|
|
1690
|
-
* Update the Plugin interface with typed events
|
|
1691
|
-
*/
|
|
1692
|
-
declare enum SOCKET_MESSAGE_TYPE {
|
|
1693
|
-
ROOM_JOINING = 1,
|
|
1694
|
-
SEND_MESSAGE = 2,
|
|
1695
|
-
MESSAGE = 3,
|
|
1696
|
-
ACK = 4,
|
|
1697
|
-
THINKING = 5,
|
|
1698
|
-
CONTROL = 6
|
|
1699
|
-
}
|
|
1700
|
-
/**
|
|
1701
|
-
* Specialized memory type for messages with enhanced type checking
|
|
1702
|
-
*/
|
|
1703
|
-
interface MessageMemory extends Memory {
|
|
1704
|
-
metadata: MessageMetadata;
|
|
1705
|
-
content: Content & {
|
|
1706
|
-
text: string;
|
|
1707
|
-
};
|
|
1708
|
-
}
|
|
1709
|
-
/**
|
|
1710
|
-
* Factory function to create a new message memory with proper defaults
|
|
1711
|
-
*/
|
|
1712
|
-
declare function createMessageMemory(params: {
|
|
1713
|
-
id?: UUID;
|
|
1714
|
-
entityId: UUID;
|
|
1715
|
-
agentId?: UUID;
|
|
1716
|
-
roomId: UUID;
|
|
1717
|
-
content: Content & {
|
|
1718
|
-
text: string;
|
|
1719
|
-
};
|
|
1720
|
-
embedding?: number[];
|
|
1721
|
-
}): MessageMemory;
|
|
1722
|
-
/**
|
|
1723
|
-
* Generic service interface that provides better type checking for services
|
|
1724
|
-
* @template ConfigType The configuration type for this service
|
|
1725
|
-
* @template ResultType The result type returned by the service operations
|
|
1726
|
-
*/
|
|
1727
|
-
interface TypedService<ConfigType extends {
|
|
1728
|
-
[key: string]: any;
|
|
1729
|
-
} = {
|
|
1730
|
-
[key: string]: any;
|
|
1731
|
-
}, ResultType = unknown> extends Service {
|
|
1732
|
-
/**
|
|
1733
|
-
* The configuration for this service instance
|
|
1734
|
-
*/
|
|
1735
|
-
config?: ConfigType;
|
|
1736
|
-
/**
|
|
1737
|
-
* Process an input with this service
|
|
1738
|
-
* @param input The input to process
|
|
1739
|
-
* @returns A promise resolving to the result
|
|
1740
|
-
*/
|
|
1741
|
-
process(input: unknown): Promise<ResultType>;
|
|
1742
|
-
}
|
|
1743
|
-
/**
|
|
1744
|
-
* Generic factory function to create a typed service instance
|
|
1745
|
-
* @param runtime The agent runtime
|
|
1746
|
-
* @param serviceType The type of service to get
|
|
1747
|
-
* @returns The service instance or null if not available
|
|
1748
|
-
*/
|
|
1749
|
-
declare function getTypedService<T extends TypedService<any, any>>(runtime: IAgentRuntime, serviceType: ServiceTypeName): T | null;
|
|
1750
|
-
/**
|
|
1751
|
-
* Type guard to check if a memory metadata is a DocumentMetadata
|
|
1752
|
-
* @param metadata The metadata to check
|
|
1753
|
-
* @returns True if the metadata is a DocumentMetadata
|
|
1754
|
-
*/
|
|
1755
|
-
declare function isDocumentMetadata(metadata: MemoryMetadata): metadata is DocumentMetadata;
|
|
1756
|
-
/**
|
|
1757
|
-
* Type guard to check if a memory metadata is a FragmentMetadata
|
|
1758
|
-
* @param metadata The metadata to check
|
|
1759
|
-
* @returns True if the metadata is a FragmentMetadata
|
|
1760
|
-
*/
|
|
1761
|
-
declare function isFragmentMetadata(metadata: MemoryMetadata): metadata is FragmentMetadata;
|
|
1762
|
-
/**
|
|
1763
|
-
* Type guard to check if a memory metadata is a MessageMetadata
|
|
1764
|
-
* @param metadata The metadata to check
|
|
1765
|
-
* @returns True if the metadata is a MessageMetadata
|
|
1766
|
-
*/
|
|
1767
|
-
declare function isMessageMetadata(metadata: MemoryMetadata): metadata is MessageMetadata;
|
|
1768
|
-
/**
|
|
1769
|
-
* Type guard to check if a memory metadata is a DescriptionMetadata
|
|
1770
|
-
* @param metadata The metadata to check
|
|
1771
|
-
* @returns True if the metadata is a DescriptionMetadata
|
|
1772
|
-
*/
|
|
1773
|
-
declare function isDescriptionMetadata(metadata: MemoryMetadata): metadata is DescriptionMetadata;
|
|
1774
|
-
/**
|
|
1775
|
-
* Type guard to check if a memory metadata is a CustomMetadata
|
|
1776
|
-
* @param metadata The metadata to check
|
|
1777
|
-
* @returns True if the metadata is a CustomMetadata
|
|
1778
|
-
*/
|
|
1779
|
-
declare function isCustomMetadata(metadata: MemoryMetadata): metadata is CustomMetadata;
|
|
1780
|
-
/**
|
|
1781
|
-
* Standardized service error type for consistent error handling
|
|
1782
|
-
*/
|
|
1783
|
-
interface ServiceError {
|
|
1784
|
-
code: string;
|
|
1785
|
-
message: string;
|
|
1786
|
-
details?: unknown;
|
|
1787
|
-
cause?: Error;
|
|
1788
|
-
}
|
|
1789
|
-
/**
|
|
1790
|
-
* Memory type guard for document memories
|
|
1791
|
-
*/
|
|
1792
|
-
declare function isDocumentMemory(memory: Memory): memory is Memory & {
|
|
1793
|
-
metadata: DocumentMetadata;
|
|
1794
|
-
};
|
|
1795
|
-
/**
|
|
1796
|
-
* Memory type guard for fragment memories
|
|
1797
|
-
*/
|
|
1798
|
-
declare function isFragmentMemory(memory: Memory): memory is Memory & {
|
|
1799
|
-
metadata: FragmentMetadata;
|
|
1800
|
-
};
|
|
1801
|
-
/**
|
|
1802
|
-
* Safely access the text content of a memory
|
|
1803
|
-
* @param memory The memory to extract text from
|
|
1804
|
-
* @param defaultValue Optional default value if no text is found
|
|
1805
|
-
* @returns The text content or default value
|
|
1806
|
-
*/
|
|
1807
|
-
declare function getMemoryText(memory: Memory, defaultValue?: string): string;
|
|
1808
|
-
/**
|
|
1809
|
-
* Safely create a ServiceError from any caught error
|
|
1810
|
-
*/
|
|
1811
|
-
declare function createServiceError(error: unknown, code?: string): ServiceError;
|
|
1812
|
-
/**
|
|
1813
|
-
* Replace 'any' types with more specific types
|
|
1814
|
-
*/
|
|
1815
|
-
/**
|
|
1816
|
-
* Defines the possible primitive types or structured types for a value within the agent's state.
|
|
1817
|
-
* This type is used to provide more specific typing for properties within `StateObject` and `StateArray`,
|
|
1818
|
-
* moving away from a generic 'any' type for better type safety and clarity in state management.
|
|
1819
|
-
*/
|
|
1820
|
-
type StateValue = string | number | boolean | null | StateObject | StateArray;
|
|
1821
|
-
/**
|
|
1822
|
-
* Represents a generic object structure within the agent's state, where keys are strings
|
|
1823
|
-
* and values can be any `StateValue`. This allows for nested objects within the state.
|
|
1824
|
-
* It's a fundamental part of the `EnhancedState` interface.
|
|
1825
|
-
*/
|
|
1826
|
-
interface StateObject {
|
|
1827
|
-
[key: string]: StateValue;
|
|
1828
|
-
}
|
|
1829
|
-
/**
|
|
1830
|
-
* Represents an array of `StateValue` types within the agent's state.
|
|
1831
|
-
* This allows for lists of mixed or uniform types to be stored in the state,
|
|
1832
|
-
* contributing to the structured definition of `EnhancedState`.
|
|
1833
|
-
*/
|
|
1834
|
-
type StateArray = StateValue[];
|
|
1835
|
-
/**
|
|
1836
|
-
* Enhanced State interface with more specific types for its core properties.
|
|
1837
|
-
* This interface provides a more structured representation of an agent's conversational state,
|
|
1838
|
-
* building upon the base `State` by typing `values` and `data` as `StateObject`.
|
|
1839
|
-
* The `text` property typically holds a textual summary or context derived from the state.
|
|
1840
|
-
* Additional dynamic properties are still allowed via the index signature `[key: string]: StateValue;`.
|
|
1841
|
-
*/
|
|
1842
|
-
interface EnhancedState {
|
|
1843
|
-
/** Holds directly accessible state values, often used for template rendering or quick lookups. */
|
|
1844
|
-
values: StateObject;
|
|
1845
|
-
/** Stores more complex or structured data, potentially namespaced by providers or internal systems. */
|
|
1846
|
-
data: StateObject;
|
|
1847
|
-
/** A textual representation or summary of the current state, often used as context for models. */
|
|
1848
|
-
text: string;
|
|
1849
|
-
/** Allows for additional dynamic properties to be added to the state object. */
|
|
1850
|
-
[key: string]: StateValue;
|
|
1851
|
-
}
|
|
1852
|
-
/**
|
|
1853
|
-
* A generic type for the `data` field within a `Component`.
|
|
1854
|
-
* While `Record<string, unknown>` allows for flexibility, developers are encouraged
|
|
1855
|
-
* to define more specific types for component data where possible to improve type safety
|
|
1856
|
-
* and code maintainability. This type serves as a base for various component implementations.
|
|
1857
|
-
*/
|
|
1858
|
-
type ComponentData = Record<string, unknown>;
|
|
1859
|
-
/**
|
|
1860
|
-
* Represents a generic data object that can be passed as a payload in an event.
|
|
1861
|
-
* This type is often used in `TypedEventHandler` to provide a flexible yet somewhat
|
|
1862
|
-
* structured way to handle event data. Specific event handlers might cast this to a
|
|
1863
|
-
* more concrete type based on the event being processed.
|
|
1864
|
-
*/
|
|
1865
|
-
type EventDataObject = Record<string, unknown>;
|
|
1866
|
-
/**
|
|
1867
|
-
* Defines a more specific type for event handlers, expecting an `EventDataObject`.
|
|
1868
|
-
* This aims to improve upon generic 'any' type handlers, providing a clearer contract
|
|
1869
|
-
* for functions that respond to events emitted within the agent runtime (see `emitEvent` in `AgentRuntime`).
|
|
1870
|
-
* Handlers can be synchronous or asynchronous.
|
|
1871
|
-
*/
|
|
1872
|
-
type TypedEventHandler = (data: EventDataObject) => Promise<void> | void;
|
|
1873
|
-
/**
|
|
1874
|
-
* Represents a generic database connection object.
|
|
1875
|
-
* The actual type of this connection will depend on the specific database adapter implementation
|
|
1876
|
-
* (e.g., a connection pool object for PostgreSQL, a client instance for a NoSQL database).
|
|
1877
|
-
* This `unknown` type serves as a placeholder in the abstract `IDatabaseAdapter`.
|
|
1878
|
-
*/
|
|
1879
|
-
type DbConnection = unknown;
|
|
1880
|
-
/**
|
|
1881
|
-
* A generic type for metadata objects, often used in various parts of the system like
|
|
1882
|
-
* `Relationship` metadata or other extensible data structures.
|
|
1883
|
-
* It allows for arbitrary key-value pairs where values are of `unknown` type,
|
|
1884
|
-
* encouraging consumers to perform type checking or casting.
|
|
1885
|
-
*/
|
|
1886
|
-
type MetadataObject = Record<string, unknown>;
|
|
1887
|
-
/**
|
|
1888
|
-
* Defines the structure for a model handler registration within the `AgentRuntime`.
|
|
1889
|
-
* Each model (e.g., for text generation, embedding) is associated with a handler function,
|
|
1890
|
-
* the name of the provider (plugin or system) that registered it, and an optional priority.
|
|
1891
|
-
* The `priority` (higher is more preferred) helps in selecting which handler to use if multiple
|
|
1892
|
-
* handlers are registered for the same model type. The `registrationOrder` (not in type, but used in runtime)
|
|
1893
|
-
* serves as a tie-breaker. See `AgentRuntime.registerModel` and `AgentRuntime.getModel`.
|
|
1894
|
-
*/
|
|
1895
|
-
interface ModelHandler {
|
|
1896
|
-
/** The function that executes the model, taking runtime and parameters, and returning a Promise. */
|
|
1897
|
-
handler: (runtime: IAgentRuntime, params: Record<string, unknown>) => Promise<unknown>;
|
|
1898
|
-
/** The name of the provider (e.g., plugin name) that registered this model handler. */
|
|
1899
|
-
provider: string;
|
|
1900
|
-
/**
|
|
1901
|
-
* Optional priority for this model handler. Higher numbers indicate higher priority.
|
|
1902
|
-
* This is used by `AgentRuntime.getModel` to select the most appropriate handler
|
|
1903
|
-
* when multiple are available for a given model type. Defaults to 0 if not specified.
|
|
1904
|
-
*/
|
|
1905
|
-
priority?: number;
|
|
1906
|
-
registrationOrder?: number;
|
|
1907
|
-
}
|
|
1908
|
-
/**
|
|
1909
|
-
* A generic type for service configurations.
|
|
1910
|
-
* Services (like `IVideoService`, `IBrowserService`) can have their own specific configuration
|
|
1911
|
-
* structures. This type allows for a flexible way to pass configuration objects,
|
|
1912
|
-
* typically used during service initialization within a plugin or the `AgentRuntime`.
|
|
1913
|
-
*/
|
|
1914
|
-
type ServiceConfig = Record<string, unknown>;
|
|
1915
|
-
declare const VECTOR_DIMS: {
|
|
1916
|
-
readonly SMALL: 384;
|
|
1917
|
-
readonly MEDIUM: 512;
|
|
1918
|
-
readonly LARGE: 768;
|
|
1919
|
-
readonly XL: 1024;
|
|
1920
|
-
readonly XXL: 1536;
|
|
1921
|
-
readonly XXXL: 3072;
|
|
1922
|
-
};
|
|
1923
|
-
/**
|
|
1924
|
-
* Interface for control messages sent from the backend to the frontend
|
|
1925
|
-
* to manage UI state and interaction capabilities
|
|
1926
|
-
*/
|
|
1927
|
-
interface ControlMessage {
|
|
1928
|
-
/** Message type identifier */
|
|
1929
|
-
type: 'control';
|
|
1930
|
-
/** Control message payload */
|
|
1931
|
-
payload: {
|
|
1932
|
-
/** Action to perform */
|
|
1933
|
-
action: 'disable_input' | 'enable_input';
|
|
1934
|
-
/** Optional target element identifier */
|
|
1935
|
-
target?: string;
|
|
1936
|
-
/** Additional optional parameters */
|
|
1937
|
-
[key: string]: unknown;
|
|
1938
|
-
};
|
|
1939
|
-
/** Room ID to ensure signal is directed to the correct chat window */
|
|
1940
|
-
roomId: UUID;
|
|
1941
|
-
}
|
|
1942
|
-
/**
|
|
1943
|
-
* Client instance
|
|
1944
|
-
*/
|
|
1945
|
-
declare abstract class Service {
|
|
1946
|
-
/** Runtime instance */
|
|
1947
|
-
protected runtime: IAgentRuntime;
|
|
1948
|
-
constructor(runtime?: IAgentRuntime);
|
|
1949
|
-
abstract stop(): Promise<void>;
|
|
1950
|
-
/** Service type */
|
|
1951
|
-
static serviceType: string;
|
|
1952
|
-
/** Service name */
|
|
1953
|
-
abstract capabilityDescription: string;
|
|
1954
|
-
/** Service configuration */
|
|
1955
|
-
config?: {
|
|
1956
|
-
[key: string]: any;
|
|
1957
|
-
};
|
|
1958
|
-
/** Start service connection */
|
|
1959
|
-
static start(_runtime: IAgentRuntime): Promise<Service>;
|
|
1960
|
-
/** Stop service connection */
|
|
1961
|
-
static stop(_runtime: IAgentRuntime): Promise<unknown>;
|
|
1962
|
-
}
|
|
1963
|
-
|
|
1964
|
-
export { type DocumentMetadata as $, type ActionExample as A, type BaseMetadata as B, type Content as C, CacheKeyPrefix as D, type Entity as E, type ChannelClearedPayload as F, ChannelType as G, type HandlerCallback as H, type IDatabaseAdapter as I, type ChunkRow as J, type ComponentData as K, type Log as L, type Memory as M, ContentType as N, type ControlMessage as O, type Provider as P, type CustomMetadata as Q, type Room as R, type State as S, type Task as T, type UUID as U, type DbConnection as V, type World as W, type DeriveKeyAttestationData as X, type DescriptionMetadata as Y, type DetokenizeTextParams as Z, type DirectoryItem as _, type Action as a, type TeePluginConfig as a$, type EmbeddingSearchResult as a0, type EnhancedState as a1, type EntityPayload as a2, type EvaluationExample as a3, type EvaluatorEventPayload as a4, type EventDataObject as a5, type EventHandler as a6, type EventPayload as a7, type EventPayloadMap as a8, EventType as a9, type ObjectGenerationParams as aA, type OnboardingConfig as aB, PlatformPrefix as aC, type PluginEvents as aD, type Project as aE, type ProjectAgent as aF, type ProviderResult as aG, type RemoteAttestationMessage as aH, type RemoteAttestationQuote as aI, type RoomMetadata as aJ, type RunEventPayload as aK, SOCKET_MESSAGE_TYPE as aL, type ServiceClassMap as aM, type ServiceConfig as aN, type ServiceError as aO, type ServiceInstance as aP, type ServiceRegistry as aQ, ServiceType as aR, type ServiceTypeRegistry as aS, type ServiceTypeValue as aT, type Setting as aU, type StateArray as aV, type StateObject as aW, type StateValue as aX, TEEMode as aY, type TaskMetadata as aZ, type TeeAgent as a_, type FragmentMetadata as aa, type GenerateTextParams as ab, type Handler as ac, type ImageDescriptionParams as ad, type ImageGenerationParams as ae, type InvokePayload as af, type IsValidServiceType as ag, type JSONSchema as ah, type KnowledgeItem as ai, KnowledgeScope as aj, type Media as ak, type MemoryRetrievalOptions as al, type MemoryScope as am, type MemorySearchOptions as an, MemoryType as ao, type MemoryTypeAlias as ap, type MessageExample as aq, type MessageMemory as ar, type MessageMetadata as as, type MessagePayload as at, type MessageReceivedHandlerParams as au, type MetadataObject as av, type ModelEventPayload as aw, type ModelHandler as ax, ModelType as ay, type MultiRoomMemoryOptions as az, type Component as b, TeeType as b0, type TeeVendorConfig as b1, type TestCase as b2, type TestSuite as b3, type TextEmbeddingParams as b4, type TextGenerationParams as b5, type TextToSpeechParams as b6, type TokenizeTextParams as b7, type TranscriptionParams as b8, type TypedEventHandler as b9, type TypedService as ba, type TypedServiceClass as bb, type UnifiedMemoryOptions as bc, type UnifiedSearchOptions as bd, VECTOR_DIMS as be, type Validator as bf, type VideoProcessingParams as bg, type WorldPayload as bh, type WorldSettings as bi, asUUID as bj, createMessageMemory as bk, createServiceError as bl, getMemoryText as bm, getTypedService as bn, isCustomMetadata as bo, isDescriptionMetadata as bp, isDocumentMemory as bq, isDocumentMetadata as br, isFragmentMemory as bs, isFragmentMetadata as bt, isMessageMetadata as bu, type MemoryMetadata as c, type Participant as d, type Relationship as e, type Agent as f, type IAgentRuntime as g, Role as h, type ServiceTypeName as i, Service as j, type Route as k, type Character as l, type Evaluator as m, type Plugin as n, type RuntimeSettings as o, type ModelTypeName as p, type ModelResultMap as q, type ModelParamsMap as r, type TaskWorker as s, type SendHandlerFunction as t, type TargetInfo as u, type TemplateType as v, type ActionEventPayload as w, AgentStatus as x, type AudioProcessingParams as y, type BaseModelParams as z };
|