@elizaos/core 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-HRFT5KDK.js +11757 -0
- package/dist/index-Cy9ZgQIe.d.ts +1678 -0
- package/dist/index-DVKkCFlY.d.ts +3118 -0
- package/dist/index.d.ts +1161 -14
- package/dist/index.js +91 -9892
- package/dist/specs/v1/index.d.ts +5 -0
- package/dist/specs/v1/index.js +70 -0
- package/dist/specs/v2/index.d.ts +4 -0
- package/dist/specs/v2/index.js +163 -0
- package/dist/{types.d.ts → types-DzoA9aTJ.d.ts} +176 -195
- package/package.json +15 -3
- package/dist/actions.d.ts +0 -22
- package/dist/database.d.ts +0 -467
- package/dist/entities.d.ts +0 -48
- package/dist/instrumentation/index.d.ts +0 -2
- package/dist/instrumentation/service.d.ts +0 -21
- package/dist/instrumentation/types.d.ts +0 -16
- package/dist/logger.d.ts +0 -5
- package/dist/prompts.d.ts +0 -5
- package/dist/roles.d.ts +0 -29
- package/dist/runtime.d.ts +0 -283
- package/dist/search.d.ts +0 -316
- package/dist/sentry/instrument.d.ts +0 -2
- package/dist/services.d.ts +0 -48
- package/dist/settings.d.ts +0 -91
- package/dist/test_resources/constants.d.ts +0 -9
- package/dist/test_resources/testSetup.d.ts +0 -1
- package/dist/test_resources/types.d.ts +0 -22
- package/dist/utils.d.ts +0 -192
|
@@ -0,0 +1,3118 @@
|
|
|
1
|
+
import { a as Action$1, I as IDatabaseAdapter$1, U as UUID$1, E as Entity$1, b as Component$1, M as Memory$1, L as Log$1, c as MemoryMetadata$1, W as World$1, R as Room$1, d as Participant$1, e as Relationship$1, f as Agent$1, T as Task$1, g as IAgentRuntime$1, h as Role$1, i as ServiceTypeName$1, j as Service$1, k as Route$1, l as Character$1, P as Provider$1, m as Evaluator$1, n as Plugin$1, o as RuntimeSettings$1, S as State$1, H as HandlerCallback$1, p as ModelTypeName$1, q as ModelResultMap$1, r as ModelParamsMap$1, s as TaskWorker$1, t as TargetInfo$1, C as Content$1, u as TemplateType$1, v as ActionEventPayload$1, A as ActionExample$1, w as AgentStatus$1, x as AudioProcessingParams$1, B as BaseMetadata$1, y as BaseModelParams$1, z as CacheKeyPrefix$1, D as ChannelType$1, F as ChunkRow$1, G as ComponentData$1, J as ContentType$1, K as ControlMessage$1, N as CustomMetadata$1, O as DbConnection$1, Q as DeriveKeyAttestationData$1, V as DescriptionMetadata$1, X as DetokenizeTextParams$1, Y as DirectoryItem$1, Z as DocumentMetadata$1, _ as EmbeddingSearchResult$1, $ as EnhancedState$1, a0 as EntityPayload$1, a1 as EvaluationExample$1, a2 as EvaluatorEventPayload$1, a3 as EventDataObject$1, a4 as EventHandler$1, a5 as EventPayload$1, a6 as EventPayloadMap$1, a7 as EventType$1, a8 as FragmentMetadata$1, a9 as GenerateTextParams$1, aa as Handler$1, ab as ImageDescriptionParams$1, ac as ImageGenerationParams$1, ad as InvokePayload$1, ae as IsValidServiceType$1, af as JSONSchema$1, ag as KnowledgeItem$1, ah as KnowledgeScope$1, ai as Media$1, aj as MemoryRetrievalOptions$1, ak as MemoryScope$1, al as MemorySearchOptions$1, am as MemoryType$1, an as MemoryTypeAlias$1, ao as MessageExample$1, ap as MessageMemory$1, aq as MessageMetadata$1, ar as MessagePayload$1, as as MessageReceivedHandlerParams$1, at as MetadataObject$1, au as ModelEventPayload$1, av as ModelHandler$1, aw as ModelType$1, ax as MultiRoomMemoryOptions$1, ay as ObjectGenerationParams$1, az as OnboardingConfig$1, aA as PlatformPrefix$1, aB as PluginEvents$1, aC as Project$1, aD as ProjectAgent$1, aE as ProviderResult$1, aF as RemoteAttestationMessage$1, aG as RemoteAttestationQuote$1, aH as RoomMetadata$1, aI as RunEventPayload$1, aJ as SOCKET_MESSAGE_TYPE$1, aK as SendHandlerFunction$1, aL as ServiceClassMap$1, aM as ServiceConfig$1, aN as ServiceError$1, aO as ServiceInstance$1, aP as ServiceRegistry$1, aQ as ServiceType$1, aR as ServiceTypeRegistry$1, aS as ServiceTypeValue$1, aT as Setting$1, aU as StateArray$1, aV as StateObject$1, aW as StateValue$1, aX as TEEMode$1, aY as TaskMetadata$1, aZ as TeeAgent$1, a_ as TeePluginConfig$1, a$ as TeeType$1, b0 as TeeVendorConfig$1, b1 as TestCase$1, b2 as TestSuite$1, b3 as TextEmbeddingParams$1, b4 as TextGenerationParams$1, b5 as TextToSpeechParams$1, b6 as TokenizeTextParams$1, b7 as TranscriptionParams$1, b8 as TypedEventHandler$1, b9 as TypedService$1, ba as TypedServiceClass$1, bb as UnifiedMemoryOptions$1, bc as UnifiedSearchOptions$1, bd as VECTOR_DIMS$1, be as Validator$1, bf as VideoProcessingParams$1, bg as WorldPayload$1, bh as WorldSettings$1, bi as asUUID$1, bj as createMessageMemory$1, bk as createServiceError$1, bl as getMemoryText$1, bm as getTypedService$1, bn as isCustomMetadata$1, bo as isDescriptionMetadata$1, bp as isDocumentMemory$1, bq as isDocumentMetadata$1, br as isFragmentMemory$1, bs as isFragmentMetadata$1, bt as isMessageMetadata$1 } from './types-DzoA9aTJ.js';
|
|
2
|
+
import { Pool } from 'pg';
|
|
3
|
+
import { PGlite } from '@electric-sql/pglite';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Defines a custom type UUID representing a universally unique identifier
|
|
7
|
+
*/
|
|
8
|
+
type UUID = `${string}-${string}-${string}-${string}-${string}`;
|
|
9
|
+
/**
|
|
10
|
+
* Helper function to safely cast a string to strongly typed UUID
|
|
11
|
+
* @param id The string UUID to validate and cast
|
|
12
|
+
* @returns The same UUID with branded type information
|
|
13
|
+
*/
|
|
14
|
+
declare function asUUID(id: string): UUID;
|
|
15
|
+
/**
|
|
16
|
+
* Represents the content of a memory, message, or other information
|
|
17
|
+
*/
|
|
18
|
+
interface Content {
|
|
19
|
+
/** The agent's internal thought process */
|
|
20
|
+
thought?: string;
|
|
21
|
+
/** The main text content visible to users */
|
|
22
|
+
text?: string;
|
|
23
|
+
/** Optional actions to be performed */
|
|
24
|
+
actions?: string[];
|
|
25
|
+
/** Optional providers to use for context generation */
|
|
26
|
+
providers?: string[];
|
|
27
|
+
/** Optional source/origin of the content */
|
|
28
|
+
source?: string;
|
|
29
|
+
/** URL of the original message/post (e.g. tweet URL, Discord message link) */
|
|
30
|
+
url?: string;
|
|
31
|
+
/** UUID of parent message if this is a reply/thread */
|
|
32
|
+
inReplyTo?: UUID;
|
|
33
|
+
/** Array of media attachments */
|
|
34
|
+
attachments?: Media[];
|
|
35
|
+
/** room type */
|
|
36
|
+
channelType?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Additional dynamic properties
|
|
39
|
+
* Use specific properties above instead of this when possible
|
|
40
|
+
*/
|
|
41
|
+
[key: string]: unknown;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Example content with associated user for demonstration purposes
|
|
45
|
+
*/
|
|
46
|
+
interface ActionExample {
|
|
47
|
+
/** User associated with the example */
|
|
48
|
+
name: string;
|
|
49
|
+
/** Content of the example */
|
|
50
|
+
content: Content;
|
|
51
|
+
}
|
|
52
|
+
type ModelTypeName = (typeof ModelType)[keyof typeof ModelType] | string;
|
|
53
|
+
/**
|
|
54
|
+
* Defines the recognized types of models that the agent runtime can use.
|
|
55
|
+
* These include models for text generation (small, large, reasoning, completion),
|
|
56
|
+
* text embedding, tokenization (encode/decode), image generation and description,
|
|
57
|
+
* audio transcription, text-to-speech, and generic object generation.
|
|
58
|
+
* This constant is used throughout the system, particularly in `AgentRuntime.useModel`,
|
|
59
|
+
* `AgentRuntime.registerModel`, and in `ModelParamsMap` / `ModelResultMap` to ensure
|
|
60
|
+
* type safety and clarity when working with different AI models.
|
|
61
|
+
* String values are used for extensibility with custom model types.
|
|
62
|
+
*/
|
|
63
|
+
declare const ModelType: {
|
|
64
|
+
readonly SMALL: "TEXT_SMALL";
|
|
65
|
+
readonly MEDIUM: "TEXT_LARGE";
|
|
66
|
+
readonly LARGE: "TEXT_LARGE";
|
|
67
|
+
readonly TEXT_SMALL: "TEXT_SMALL";
|
|
68
|
+
readonly TEXT_LARGE: "TEXT_LARGE";
|
|
69
|
+
readonly TEXT_EMBEDDING: "TEXT_EMBEDDING";
|
|
70
|
+
readonly TEXT_TOKENIZER_ENCODE: "TEXT_TOKENIZER_ENCODE";
|
|
71
|
+
readonly TEXT_TOKENIZER_DECODE: "TEXT_TOKENIZER_DECODE";
|
|
72
|
+
readonly TEXT_REASONING_SMALL: "REASONING_SMALL";
|
|
73
|
+
readonly TEXT_REASONING_LARGE: "REASONING_LARGE";
|
|
74
|
+
readonly TEXT_COMPLETION: "TEXT_COMPLETION";
|
|
75
|
+
readonly IMAGE: "IMAGE";
|
|
76
|
+
readonly IMAGE_DESCRIPTION: "IMAGE_DESCRIPTION";
|
|
77
|
+
readonly TRANSCRIPTION: "TRANSCRIPTION";
|
|
78
|
+
readonly TEXT_TO_SPEECH: "TEXT_TO_SPEECH";
|
|
79
|
+
readonly AUDIO: "AUDIO";
|
|
80
|
+
readonly VIDEO: "VIDEO";
|
|
81
|
+
readonly OBJECT_SMALL: "OBJECT_SMALL";
|
|
82
|
+
readonly OBJECT_LARGE: "OBJECT_LARGE";
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Core service type registry that can be extended by plugins via module augmentation.
|
|
86
|
+
* Plugins can extend this interface to add their own service types:
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```typescript
|
|
90
|
+
* declare module '@elizaos/core' {
|
|
91
|
+
* interface ServiceTypeRegistry {
|
|
92
|
+
* MY_CUSTOM_SERVICE: 'my_custom_service';
|
|
93
|
+
* }
|
|
94
|
+
* }
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
interface ServiceTypeRegistry {
|
|
98
|
+
TRANSCRIPTION: 'transcription';
|
|
99
|
+
VIDEO: 'video';
|
|
100
|
+
BROWSER: 'browser';
|
|
101
|
+
PDF: 'pdf';
|
|
102
|
+
REMOTE_FILES: 'aws_s3';
|
|
103
|
+
WEB_SEARCH: 'web_search';
|
|
104
|
+
EMAIL: 'email';
|
|
105
|
+
TEE: 'tee';
|
|
106
|
+
TASK: 'task';
|
|
107
|
+
INSTRUMENTATION: 'instrumentation';
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Type for service names that includes both core services and any plugin-registered services
|
|
111
|
+
*/
|
|
112
|
+
type ServiceTypeName = ServiceTypeRegistry[keyof ServiceTypeRegistry];
|
|
113
|
+
/**
|
|
114
|
+
* Helper type to extract service type values from the registry
|
|
115
|
+
*/
|
|
116
|
+
type ServiceTypeValue<K extends keyof ServiceTypeRegistry> = ServiceTypeRegistry[K];
|
|
117
|
+
/**
|
|
118
|
+
* Helper type to check if a service type exists in the registry
|
|
119
|
+
*/
|
|
120
|
+
type IsValidServiceType<T extends string> = T extends ServiceTypeName ? true : false;
|
|
121
|
+
/**
|
|
122
|
+
* Type-safe service class definition
|
|
123
|
+
*/
|
|
124
|
+
type TypedServiceClass<T extends ServiceTypeName> = {
|
|
125
|
+
new (runtime?: IAgentRuntime): Service;
|
|
126
|
+
serviceType: T;
|
|
127
|
+
start(runtime: IAgentRuntime): Promise<Service>;
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* Map of service type names to their implementation classes
|
|
131
|
+
*/
|
|
132
|
+
interface ServiceClassMap {
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Helper to infer service instance type from service type name
|
|
136
|
+
*/
|
|
137
|
+
type ServiceInstance<T extends ServiceTypeName> = T extends keyof ServiceClassMap ? InstanceType<ServiceClassMap[T]> : Service;
|
|
138
|
+
/**
|
|
139
|
+
* Runtime service registry type
|
|
140
|
+
*/
|
|
141
|
+
type ServiceRegistry<T extends ServiceTypeName = ServiceTypeName> = Map<T, Service>;
|
|
142
|
+
/**
|
|
143
|
+
* Enumerates the recognized types of services that can be registered and used by the agent runtime.
|
|
144
|
+
* Services provide specialized functionalities like audio transcription, video processing,
|
|
145
|
+
* web browsing, PDF handling, file storage (e.g., AWS S3), web search, email integration,
|
|
146
|
+
* secure execution via TEE (Trusted Execution Environment), task management, and instrumentation.
|
|
147
|
+
* This constant is used in `AgentRuntime` for service registration and retrieval (e.g., `getService`).
|
|
148
|
+
* Each service typically implements the `Service` abstract class or a more specific interface like `IVideoService`.
|
|
149
|
+
*/
|
|
150
|
+
declare const ServiceType: {
|
|
151
|
+
readonly TRANSCRIPTION: "transcription";
|
|
152
|
+
readonly VIDEO: "video";
|
|
153
|
+
readonly BROWSER: "browser";
|
|
154
|
+
readonly PDF: "pdf";
|
|
155
|
+
readonly REMOTE_FILES: "aws_s3";
|
|
156
|
+
readonly WEB_SEARCH: "web_search";
|
|
157
|
+
readonly EMAIL: "email";
|
|
158
|
+
readonly TEE: "tee";
|
|
159
|
+
readonly TASK: "task";
|
|
160
|
+
readonly INSTRUMENTATION: "instrumentation";
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* Represents the current state or context of a conversation or agent interaction.
|
|
164
|
+
* This interface is a flexible container for various pieces of information that define the agent's
|
|
165
|
+
* understanding at a point in time. It includes:
|
|
166
|
+
* - `values`: A key-value store for general state variables, often populated by providers.
|
|
167
|
+
* - `data`: Another key-value store, potentially for more structured or internal data.
|
|
168
|
+
* - `text`: A string representation of the current context, often a summary or concatenated history.
|
|
169
|
+
* The `[key: string]: any;` allows for dynamic properties, though `EnhancedState` offers better typing.
|
|
170
|
+
* This state object is passed to handlers for actions, evaluators, and providers.
|
|
171
|
+
*/
|
|
172
|
+
interface State {
|
|
173
|
+
/** Additional dynamic properties */
|
|
174
|
+
[key: string]: any;
|
|
175
|
+
values: {
|
|
176
|
+
[key: string]: any;
|
|
177
|
+
};
|
|
178
|
+
data: {
|
|
179
|
+
[key: string]: any;
|
|
180
|
+
};
|
|
181
|
+
text: string;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Memory type enumeration for built-in memory types
|
|
185
|
+
*/
|
|
186
|
+
type MemoryTypeAlias = string;
|
|
187
|
+
/**
|
|
188
|
+
* Enumerates the built-in types of memories that can be stored and retrieved.
|
|
189
|
+
* - `DOCUMENT`: Represents a whole document or a large piece of text.
|
|
190
|
+
* - `FRAGMENT`: A chunk or segment of a `DOCUMENT`, often created for embedding and search.
|
|
191
|
+
* - `MESSAGE`: A conversational message, typically from a user or the agent.
|
|
192
|
+
* - `DESCRIPTION`: A descriptive piece of information, perhaps about an entity or concept.
|
|
193
|
+
* - `CUSTOM`: For any other type of memory not covered by the built-in types.
|
|
194
|
+
* This enum is used in `MemoryMetadata` to categorize memories and influences how they are processed or queried.
|
|
195
|
+
*/
|
|
196
|
+
declare enum MemoryType {
|
|
197
|
+
DOCUMENT = "document",
|
|
198
|
+
FRAGMENT = "fragment",
|
|
199
|
+
MESSAGE = "message",
|
|
200
|
+
DESCRIPTION = "description",
|
|
201
|
+
CUSTOM = "custom"
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Defines the scope of a memory, indicating its visibility and accessibility.
|
|
205
|
+
* - `shared`: The memory is accessible to multiple entities or across different contexts (e.g., a public fact).
|
|
206
|
+
* - `private`: The memory is specific to a single entity or a private context (e.g., a user's personal preference).
|
|
207
|
+
* - `room`: The memory is scoped to a specific room or channel.
|
|
208
|
+
* This is used in `MemoryMetadata` to control how memories are stored and retrieved based on context.
|
|
209
|
+
*/
|
|
210
|
+
type MemoryScope = 'shared' | 'private' | 'room';
|
|
211
|
+
/**
|
|
212
|
+
* Base interface for all memory metadata types.
|
|
213
|
+
* It includes common properties for all memories, such as:
|
|
214
|
+
* - `type`: The kind of memory (e.g., `MemoryType.MESSAGE`, `MemoryType.DOCUMENT`).
|
|
215
|
+
* - `source`: An optional string indicating the origin of the memory (e.g., 'discord', 'user_input').
|
|
216
|
+
* - `sourceId`: An optional UUID linking to a source entity or object.
|
|
217
|
+
* - `scope`: The visibility scope of the memory (`shared`, `private`, or `room`).
|
|
218
|
+
* - `timestamp`: An optional numerical timestamp (e.g., milliseconds since epoch) of when the memory was created or relevant.
|
|
219
|
+
* - `tags`: Optional array of strings for categorizing or filtering memories.
|
|
220
|
+
* Specific metadata types like `DocumentMetadata` or `MessageMetadata` extend this base.
|
|
221
|
+
*/
|
|
222
|
+
interface BaseMetadata {
|
|
223
|
+
type: MemoryTypeAlias;
|
|
224
|
+
source?: string;
|
|
225
|
+
sourceId?: UUID;
|
|
226
|
+
scope?: MemoryScope;
|
|
227
|
+
timestamp?: number;
|
|
228
|
+
tags?: string[];
|
|
229
|
+
}
|
|
230
|
+
interface DocumentMetadata extends BaseMetadata {
|
|
231
|
+
type: MemoryType.DOCUMENT;
|
|
232
|
+
}
|
|
233
|
+
interface FragmentMetadata extends BaseMetadata {
|
|
234
|
+
type: MemoryType.FRAGMENT;
|
|
235
|
+
documentId: UUID;
|
|
236
|
+
position: number;
|
|
237
|
+
}
|
|
238
|
+
interface MessageMetadata extends BaseMetadata {
|
|
239
|
+
type: MemoryType.MESSAGE;
|
|
240
|
+
}
|
|
241
|
+
interface DescriptionMetadata extends BaseMetadata {
|
|
242
|
+
type: MemoryType.DESCRIPTION;
|
|
243
|
+
}
|
|
244
|
+
interface CustomMetadata extends BaseMetadata {
|
|
245
|
+
[key: string]: unknown;
|
|
246
|
+
}
|
|
247
|
+
type MemoryMetadata = DocumentMetadata | FragmentMetadata | MessageMetadata | DescriptionMetadata | CustomMetadata;
|
|
248
|
+
/**
|
|
249
|
+
* Represents a stored memory/message
|
|
250
|
+
*/
|
|
251
|
+
interface Memory {
|
|
252
|
+
/** Optional unique identifier */
|
|
253
|
+
id?: UUID;
|
|
254
|
+
/** Associated user ID */
|
|
255
|
+
entityId: UUID;
|
|
256
|
+
/** Associated agent ID */
|
|
257
|
+
agentId?: UUID;
|
|
258
|
+
/** Optional creation timestamp in milliseconds since epoch */
|
|
259
|
+
createdAt?: number;
|
|
260
|
+
/** Memory content */
|
|
261
|
+
content: Content;
|
|
262
|
+
/** Optional embedding vector for semantic search */
|
|
263
|
+
embedding?: number[];
|
|
264
|
+
/** Associated room ID */
|
|
265
|
+
roomId: UUID;
|
|
266
|
+
/** Associated world ID (optional) */
|
|
267
|
+
worldId?: UUID;
|
|
268
|
+
/** Whether memory is unique (used to prevent duplicates) */
|
|
269
|
+
unique?: boolean;
|
|
270
|
+
/** Embedding similarity score (set when retrieved via search) */
|
|
271
|
+
similarity?: number;
|
|
272
|
+
/** Metadata for the memory */
|
|
273
|
+
metadata?: MemoryMetadata;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Represents a log entry
|
|
277
|
+
*/
|
|
278
|
+
interface Log {
|
|
279
|
+
/** Optional unique identifier */
|
|
280
|
+
id?: UUID;
|
|
281
|
+
/** Associated entity ID */
|
|
282
|
+
entityId: UUID;
|
|
283
|
+
/** Associated room ID */
|
|
284
|
+
roomId?: UUID;
|
|
285
|
+
/** Log body */
|
|
286
|
+
body: {
|
|
287
|
+
[key: string]: unknown;
|
|
288
|
+
};
|
|
289
|
+
/** Log type */
|
|
290
|
+
type: string;
|
|
291
|
+
/** Log creation timestamp */
|
|
292
|
+
createdAt: Date;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Example message for demonstration
|
|
296
|
+
*/
|
|
297
|
+
interface MessageExample {
|
|
298
|
+
/** Associated user */
|
|
299
|
+
name: string;
|
|
300
|
+
/** Message content */
|
|
301
|
+
content: Content;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Handler function type for processing messages
|
|
305
|
+
*/
|
|
306
|
+
type Handler = (runtime: IAgentRuntime, message: Memory, state?: State, options?: {
|
|
307
|
+
[key: string]: unknown;
|
|
308
|
+
}, callback?: HandlerCallback, responses?: Memory[]) => Promise<unknown>;
|
|
309
|
+
/**
|
|
310
|
+
* Callback function type for handlers
|
|
311
|
+
*/
|
|
312
|
+
type HandlerCallback = (response: Content, files?: any) => Promise<Memory[]>;
|
|
313
|
+
/**
|
|
314
|
+
* Validator function type for actions/evaluators
|
|
315
|
+
*/
|
|
316
|
+
type Validator = (runtime: IAgentRuntime, message: Memory, state?: State) => Promise<boolean>;
|
|
317
|
+
/**
|
|
318
|
+
* Represents an action the agent can perform
|
|
319
|
+
*/
|
|
320
|
+
interface Action {
|
|
321
|
+
/** Similar action descriptions */
|
|
322
|
+
similes?: string[];
|
|
323
|
+
/** Detailed description */
|
|
324
|
+
description: string;
|
|
325
|
+
/** Example usages */
|
|
326
|
+
examples?: ActionExample[][];
|
|
327
|
+
/** Handler function */
|
|
328
|
+
handler: Handler;
|
|
329
|
+
/** Action name */
|
|
330
|
+
name: string;
|
|
331
|
+
/** Validation function */
|
|
332
|
+
validate: Validator;
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Example for evaluating agent behavior
|
|
336
|
+
*/
|
|
337
|
+
interface EvaluationExample {
|
|
338
|
+
/** Evaluation context */
|
|
339
|
+
prompt: string;
|
|
340
|
+
/** Example messages */
|
|
341
|
+
messages: Array<ActionExample>;
|
|
342
|
+
/** Expected outcome */
|
|
343
|
+
outcome: string;
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Evaluator for assessing agent responses
|
|
347
|
+
*/
|
|
348
|
+
interface Evaluator {
|
|
349
|
+
/** Whether to always run */
|
|
350
|
+
alwaysRun?: boolean;
|
|
351
|
+
/** Detailed description */
|
|
352
|
+
description: string;
|
|
353
|
+
/** Similar evaluator descriptions */
|
|
354
|
+
similes?: string[];
|
|
355
|
+
/** Example evaluations */
|
|
356
|
+
examples: EvaluationExample[];
|
|
357
|
+
/** Handler function */
|
|
358
|
+
handler: Handler;
|
|
359
|
+
/** Evaluator name */
|
|
360
|
+
name: string;
|
|
361
|
+
/** Validation function */
|
|
362
|
+
validate: Validator;
|
|
363
|
+
}
|
|
364
|
+
interface ProviderResult {
|
|
365
|
+
values?: {
|
|
366
|
+
[key: string]: any;
|
|
367
|
+
};
|
|
368
|
+
data?: {
|
|
369
|
+
[key: string]: any;
|
|
370
|
+
};
|
|
371
|
+
text?: string;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Provider for external data/services
|
|
375
|
+
*/
|
|
376
|
+
interface Provider {
|
|
377
|
+
/** Provider name */
|
|
378
|
+
name: string;
|
|
379
|
+
/** Description of the provider */
|
|
380
|
+
description?: string;
|
|
381
|
+
/** Whether the provider is dynamic */
|
|
382
|
+
dynamic?: boolean;
|
|
383
|
+
/** Position of the provider in the provider list, positive or negative */
|
|
384
|
+
position?: number;
|
|
385
|
+
/**
|
|
386
|
+
* Whether the provider is private
|
|
387
|
+
*
|
|
388
|
+
* Private providers are not displayed in the regular provider list, they have to be called explicitly
|
|
389
|
+
*/
|
|
390
|
+
private?: boolean;
|
|
391
|
+
/** Data retrieval function */
|
|
392
|
+
get: (runtime: IAgentRuntime, message: Memory, state: State) => Promise<ProviderResult>;
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Represents a relationship between users
|
|
396
|
+
*/
|
|
397
|
+
interface Relationship {
|
|
398
|
+
/** Unique identifier */
|
|
399
|
+
id: UUID;
|
|
400
|
+
/** First user ID */
|
|
401
|
+
sourceEntityId: UUID;
|
|
402
|
+
/** Second user ID */
|
|
403
|
+
targetEntityId: UUID;
|
|
404
|
+
/** Agent ID */
|
|
405
|
+
agentId: UUID;
|
|
406
|
+
/** Tags for filtering/categorizing relationships */
|
|
407
|
+
tags: string[];
|
|
408
|
+
/** Additional metadata about the relationship */
|
|
409
|
+
metadata: {
|
|
410
|
+
[key: string]: any;
|
|
411
|
+
};
|
|
412
|
+
/** Optional creation timestamp */
|
|
413
|
+
createdAt?: string;
|
|
414
|
+
}
|
|
415
|
+
interface Component {
|
|
416
|
+
id: UUID;
|
|
417
|
+
entityId: UUID;
|
|
418
|
+
agentId: UUID;
|
|
419
|
+
roomId: UUID;
|
|
420
|
+
worldId: UUID;
|
|
421
|
+
sourceEntityId: UUID;
|
|
422
|
+
type: string;
|
|
423
|
+
createdAt: number;
|
|
424
|
+
data: {
|
|
425
|
+
[key: string]: any;
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Represents a user account
|
|
430
|
+
*/
|
|
431
|
+
interface Entity {
|
|
432
|
+
/** Unique identifier, optional on creation */
|
|
433
|
+
id?: UUID;
|
|
434
|
+
/** Names of the entity */
|
|
435
|
+
names: string[];
|
|
436
|
+
/** Optional additional metadata */
|
|
437
|
+
metadata?: {
|
|
438
|
+
[key: string]: any;
|
|
439
|
+
};
|
|
440
|
+
/** Agent ID this account is related to, for agents should be themselves */
|
|
441
|
+
agentId: UUID;
|
|
442
|
+
/** Optional array of components */
|
|
443
|
+
components?: Component[];
|
|
444
|
+
}
|
|
445
|
+
type World = {
|
|
446
|
+
id: UUID;
|
|
447
|
+
name?: string;
|
|
448
|
+
agentId: UUID;
|
|
449
|
+
serverId: string;
|
|
450
|
+
metadata?: {
|
|
451
|
+
ownership?: {
|
|
452
|
+
ownerId: string;
|
|
453
|
+
};
|
|
454
|
+
roles?: {
|
|
455
|
+
[entityId: UUID]: Role;
|
|
456
|
+
};
|
|
457
|
+
[key: string]: unknown;
|
|
458
|
+
};
|
|
459
|
+
};
|
|
460
|
+
type RoomMetadata = Record<string, unknown>;
|
|
461
|
+
type Room = {
|
|
462
|
+
id: UUID;
|
|
463
|
+
name?: string;
|
|
464
|
+
agentId?: UUID;
|
|
465
|
+
source: string;
|
|
466
|
+
type: ChannelType;
|
|
467
|
+
channelId?: string;
|
|
468
|
+
serverId?: string;
|
|
469
|
+
worldId?: UUID;
|
|
470
|
+
metadata?: RoomMetadata;
|
|
471
|
+
};
|
|
472
|
+
/**
|
|
473
|
+
* Room participant with account details
|
|
474
|
+
*/
|
|
475
|
+
interface Participant {
|
|
476
|
+
/** Unique identifier */
|
|
477
|
+
id: UUID;
|
|
478
|
+
/** Associated account */
|
|
479
|
+
entity: Entity;
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* Represents a media attachment
|
|
483
|
+
*/
|
|
484
|
+
type Media = {
|
|
485
|
+
/** Unique identifier */
|
|
486
|
+
id: string;
|
|
487
|
+
/** Media URL */
|
|
488
|
+
url: string;
|
|
489
|
+
/** Media title */
|
|
490
|
+
title?: string;
|
|
491
|
+
/** Media source */
|
|
492
|
+
source?: string;
|
|
493
|
+
/** Media description */
|
|
494
|
+
description?: string;
|
|
495
|
+
/** Text content */
|
|
496
|
+
text?: string;
|
|
497
|
+
/** Content type */
|
|
498
|
+
contentType?: ContentType;
|
|
499
|
+
};
|
|
500
|
+
declare enum ContentType {
|
|
501
|
+
IMAGE = "image",
|
|
502
|
+
VIDEO = "video",
|
|
503
|
+
AUDIO = "audio",
|
|
504
|
+
DOCUMENT = "document",
|
|
505
|
+
LINK = "link"
|
|
506
|
+
}
|
|
507
|
+
declare enum ChannelType {
|
|
508
|
+
SELF = "SELF",// Messages to self
|
|
509
|
+
DM = "dm",// Direct messages between two participants
|
|
510
|
+
GROUP = "group",// Group messages with multiple participants
|
|
511
|
+
VOICE_DM = "VOICE_DM",// Voice direct messages
|
|
512
|
+
VOICE_GROUP = "VOICE_GROUP",// Voice channels with multiple participants
|
|
513
|
+
FEED = "FEED",// Social media feed
|
|
514
|
+
THREAD = "THREAD",// Threaded conversation
|
|
515
|
+
WORLD = "WORLD",// World channel
|
|
516
|
+
FORUM = "FORUM",// Forum discussion
|
|
517
|
+
API = "API"
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Client instance
|
|
521
|
+
*/
|
|
522
|
+
declare abstract class Service {
|
|
523
|
+
/** Runtime instance */
|
|
524
|
+
protected runtime: IAgentRuntime;
|
|
525
|
+
constructor(runtime?: IAgentRuntime);
|
|
526
|
+
abstract stop(): Promise<void>;
|
|
527
|
+
/** Service type */
|
|
528
|
+
static serviceType: string;
|
|
529
|
+
/** Service name */
|
|
530
|
+
abstract capabilityDescription: string;
|
|
531
|
+
/** Service configuration */
|
|
532
|
+
config?: {
|
|
533
|
+
[key: string]: any;
|
|
534
|
+
};
|
|
535
|
+
/** Start service connection */
|
|
536
|
+
static start(_runtime: IAgentRuntime): Promise<Service>;
|
|
537
|
+
/** Stop service connection */
|
|
538
|
+
static stop(_runtime: IAgentRuntime): Promise<unknown>;
|
|
539
|
+
}
|
|
540
|
+
type Route = {
|
|
541
|
+
type: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'STATIC';
|
|
542
|
+
path: string;
|
|
543
|
+
filePath?: string;
|
|
544
|
+
public?: boolean;
|
|
545
|
+
name?: string extends {
|
|
546
|
+
public: true;
|
|
547
|
+
} ? string : string | undefined;
|
|
548
|
+
handler?: (req: any, res: any, runtime: IAgentRuntime) => Promise<void>;
|
|
549
|
+
isMultipart?: boolean;
|
|
550
|
+
};
|
|
551
|
+
/**
|
|
552
|
+
* Plugin for extending agent functionality
|
|
553
|
+
*/
|
|
554
|
+
type PluginEvents = {
|
|
555
|
+
[K in keyof EventPayloadMap]?: EventHandler<K>[];
|
|
556
|
+
} & {
|
|
557
|
+
[key: string]: ((params: EventPayload) => Promise<any>)[];
|
|
558
|
+
};
|
|
559
|
+
interface Plugin {
|
|
560
|
+
name: string;
|
|
561
|
+
description: string;
|
|
562
|
+
init?: (config: Record<string, string>, runtime: IAgentRuntime) => Promise<void>;
|
|
563
|
+
config?: {
|
|
564
|
+
[key: string]: any;
|
|
565
|
+
};
|
|
566
|
+
services?: (typeof Service)[];
|
|
567
|
+
componentTypes?: {
|
|
568
|
+
name: string;
|
|
569
|
+
schema: Record<string, unknown>;
|
|
570
|
+
validator?: (data: any) => boolean;
|
|
571
|
+
}[];
|
|
572
|
+
actions?: Action[];
|
|
573
|
+
providers?: Provider[];
|
|
574
|
+
evaluators?: Evaluator[];
|
|
575
|
+
adapter?: IDatabaseAdapter;
|
|
576
|
+
models?: {
|
|
577
|
+
[key: string]: (...args: any[]) => Promise<any>;
|
|
578
|
+
};
|
|
579
|
+
events?: PluginEvents;
|
|
580
|
+
routes?: Route[];
|
|
581
|
+
tests?: TestSuite[];
|
|
582
|
+
dependencies?: string[];
|
|
583
|
+
priority?: number;
|
|
584
|
+
}
|
|
585
|
+
interface ProjectAgent {
|
|
586
|
+
character: Character;
|
|
587
|
+
init?: (runtime: IAgentRuntime) => Promise<void>;
|
|
588
|
+
plugins?: Plugin[];
|
|
589
|
+
tests?: TestSuite | TestSuite[];
|
|
590
|
+
}
|
|
591
|
+
interface Project {
|
|
592
|
+
agents: ProjectAgent[];
|
|
593
|
+
}
|
|
594
|
+
type TemplateType = string | ((options: {
|
|
595
|
+
state: State | {
|
|
596
|
+
[key: string]: string;
|
|
597
|
+
};
|
|
598
|
+
}) => string);
|
|
599
|
+
/**
|
|
600
|
+
* Configuration for an agent's character, defining its personality, knowledge, and capabilities.
|
|
601
|
+
* This is a central piece of an agent's definition, used by the `AgentRuntime` to initialize and operate the agent.
|
|
602
|
+
* It includes:
|
|
603
|
+
* - `id`: Optional unique identifier for the character.
|
|
604
|
+
* - `name`, `username`: Identifying names for the character.
|
|
605
|
+
* - `system`: A system prompt that guides the agent's overall behavior.
|
|
606
|
+
* - `templates`: A map of prompt templates for various situations (e.g., message generation, summarization).
|
|
607
|
+
* - `bio`: A textual biography or description of the character.
|
|
608
|
+
* - `messageExamples`, `postExamples`: Examples of how the character communicates.
|
|
609
|
+
* - `topics`, `adjectives`: Keywords describing the character's knowledge areas and traits.
|
|
610
|
+
* - `knowledge`: Paths to knowledge files or directories to be loaded into the agent's memory.
|
|
611
|
+
* - `plugins`: A list of plugin names to be loaded for this character.
|
|
612
|
+
* - `settings`, `secrets`: Configuration key-value pairs, with secrets being handled more securely.
|
|
613
|
+
* - `style`: Guidelines for the character's writing style in different contexts (chat, post).
|
|
614
|
+
*/
|
|
615
|
+
interface Character {
|
|
616
|
+
/** Optional unique identifier */
|
|
617
|
+
id?: UUID;
|
|
618
|
+
/** Character name */
|
|
619
|
+
name: string;
|
|
620
|
+
/** Optional username */
|
|
621
|
+
username?: string;
|
|
622
|
+
/** Optional system prompt */
|
|
623
|
+
system?: string;
|
|
624
|
+
/** Optional prompt templates */
|
|
625
|
+
templates?: {
|
|
626
|
+
[key: string]: TemplateType;
|
|
627
|
+
};
|
|
628
|
+
/** Character biography */
|
|
629
|
+
bio: string | string[];
|
|
630
|
+
/** Example messages */
|
|
631
|
+
messageExamples?: MessageExample[][];
|
|
632
|
+
/** Example posts */
|
|
633
|
+
postExamples?: string[];
|
|
634
|
+
/** Known topics */
|
|
635
|
+
topics?: string[];
|
|
636
|
+
/** Character traits */
|
|
637
|
+
adjectives?: string[];
|
|
638
|
+
/** Optional knowledge base */
|
|
639
|
+
knowledge?: (string | {
|
|
640
|
+
path: string;
|
|
641
|
+
shared?: boolean;
|
|
642
|
+
} | {
|
|
643
|
+
directory: string;
|
|
644
|
+
shared?: boolean;
|
|
645
|
+
})[];
|
|
646
|
+
/** Available plugins */
|
|
647
|
+
plugins?: string[];
|
|
648
|
+
/** Optional configuration */
|
|
649
|
+
settings?: {
|
|
650
|
+
[key: string]: any | string | boolean | number;
|
|
651
|
+
};
|
|
652
|
+
/** Optional secrets */
|
|
653
|
+
secrets?: {
|
|
654
|
+
[key: string]: string | boolean | number;
|
|
655
|
+
};
|
|
656
|
+
/** Writing style guides */
|
|
657
|
+
style?: {
|
|
658
|
+
all?: string[];
|
|
659
|
+
chat?: string[];
|
|
660
|
+
post?: string[];
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
declare enum AgentStatus {
|
|
664
|
+
ACTIVE = "active",
|
|
665
|
+
INACTIVE = "inactive"
|
|
666
|
+
}
|
|
667
|
+
/**
|
|
668
|
+
* Represents an operational agent, extending the `Character` definition with runtime status and timestamps.
|
|
669
|
+
* While `Character` defines the blueprint, `Agent` represents an instantiated and potentially running version.
|
|
670
|
+
* It includes:
|
|
671
|
+
* - `enabled`: A boolean indicating if the agent is currently active or disabled.
|
|
672
|
+
* - `status`: The current operational status, typically `AgentStatus.ACTIVE` or `AgentStatus.INACTIVE`.
|
|
673
|
+
* - `createdAt`, `updatedAt`: Timestamps for when the agent record was created and last updated in the database.
|
|
674
|
+
* This interface is primarily used by the `IDatabaseAdapter` for agent management.
|
|
675
|
+
*/
|
|
676
|
+
interface Agent extends Character {
|
|
677
|
+
enabled?: boolean;
|
|
678
|
+
status?: AgentStatus;
|
|
679
|
+
createdAt: number;
|
|
680
|
+
updatedAt: number;
|
|
681
|
+
}
|
|
682
|
+
/**
|
|
683
|
+
* Interface for database operations
|
|
684
|
+
*/
|
|
685
|
+
interface IDatabaseAdapter {
|
|
686
|
+
/** Database instance */
|
|
687
|
+
db: any;
|
|
688
|
+
/** Initialize database connection */
|
|
689
|
+
init(): Promise<void>;
|
|
690
|
+
/** Close database connection */
|
|
691
|
+
close(): Promise<void>;
|
|
692
|
+
getConnection(): Promise<PGlite | Pool>;
|
|
693
|
+
getAgent(agentId: UUID): Promise<Agent | null>;
|
|
694
|
+
/** Get all agents */
|
|
695
|
+
getAgents(): Promise<Partial<Agent>[]>;
|
|
696
|
+
createAgent(agent: Partial<Agent>): Promise<boolean>;
|
|
697
|
+
updateAgent(agentId: UUID, agent: Partial<Agent>): Promise<boolean>;
|
|
698
|
+
deleteAgent(agentId: UUID): Promise<boolean>;
|
|
699
|
+
ensureAgentExists(agent: Partial<Agent>): Promise<Agent>;
|
|
700
|
+
ensureEmbeddingDimension(dimension: number): Promise<void>;
|
|
701
|
+
/** Get entity by IDs */
|
|
702
|
+
getEntityByIds(entityIds: UUID[]): Promise<Entity[] | null>;
|
|
703
|
+
/** Get entities for room */
|
|
704
|
+
getEntitiesForRoom(roomId: UUID, includeComponents?: boolean): Promise<Entity[]>;
|
|
705
|
+
/** Create new entities */
|
|
706
|
+
createEntities(entities: Entity[]): Promise<boolean>;
|
|
707
|
+
/** Update entity */
|
|
708
|
+
updateEntity(entity: Entity): Promise<void>;
|
|
709
|
+
/** Get component by ID */
|
|
710
|
+
getComponent(entityId: UUID, type: string, worldId?: UUID, sourceEntityId?: UUID): Promise<Component | null>;
|
|
711
|
+
/** Get all components for an entity */
|
|
712
|
+
getComponents(entityId: UUID, worldId?: UUID, sourceEntityId?: UUID): Promise<Component[]>;
|
|
713
|
+
/** Create component */
|
|
714
|
+
createComponent(component: Component): Promise<boolean>;
|
|
715
|
+
/** Update component */
|
|
716
|
+
updateComponent(component: Component): Promise<void>;
|
|
717
|
+
/** Delete component */
|
|
718
|
+
deleteComponent(componentId: UUID): Promise<void>;
|
|
719
|
+
/** Get memories matching criteria */
|
|
720
|
+
getMemories(params: {
|
|
721
|
+
entityId?: UUID;
|
|
722
|
+
agentId?: UUID;
|
|
723
|
+
count?: number;
|
|
724
|
+
unique?: boolean;
|
|
725
|
+
tableName: string;
|
|
726
|
+
start?: number;
|
|
727
|
+
end?: number;
|
|
728
|
+
roomId?: UUID;
|
|
729
|
+
worldId?: UUID;
|
|
730
|
+
}): Promise<Memory[]>;
|
|
731
|
+
getMemoryById(id: UUID): Promise<Memory | null>;
|
|
732
|
+
getMemoriesByIds(ids: UUID[], tableName?: string): Promise<Memory[]>;
|
|
733
|
+
getMemoriesByRoomIds(params: {
|
|
734
|
+
tableName: string;
|
|
735
|
+
roomIds: UUID[];
|
|
736
|
+
limit?: number;
|
|
737
|
+
}): Promise<Memory[]>;
|
|
738
|
+
getCachedEmbeddings(params: {
|
|
739
|
+
query_table_name: string;
|
|
740
|
+
query_threshold: number;
|
|
741
|
+
query_input: string;
|
|
742
|
+
query_field_name: string;
|
|
743
|
+
query_field_sub_name: string;
|
|
744
|
+
query_match_count: number;
|
|
745
|
+
}): Promise<{
|
|
746
|
+
embedding: number[];
|
|
747
|
+
levenshtein_score: number;
|
|
748
|
+
}[]>;
|
|
749
|
+
log(params: {
|
|
750
|
+
body: {
|
|
751
|
+
[key: string]: unknown;
|
|
752
|
+
};
|
|
753
|
+
entityId: UUID;
|
|
754
|
+
roomId: UUID;
|
|
755
|
+
type: string;
|
|
756
|
+
}): Promise<void>;
|
|
757
|
+
getLogs(params: {
|
|
758
|
+
entityId: UUID;
|
|
759
|
+
roomId?: UUID;
|
|
760
|
+
type?: string;
|
|
761
|
+
count?: number;
|
|
762
|
+
offset?: number;
|
|
763
|
+
}): Promise<Log[]>;
|
|
764
|
+
deleteLog(logId: UUID): Promise<void>;
|
|
765
|
+
searchMemories(params: {
|
|
766
|
+
embedding: number[];
|
|
767
|
+
match_threshold?: number;
|
|
768
|
+
count?: number;
|
|
769
|
+
unique?: boolean;
|
|
770
|
+
tableName: string;
|
|
771
|
+
query?: string;
|
|
772
|
+
roomId?: UUID;
|
|
773
|
+
worldId?: UUID;
|
|
774
|
+
entityId?: UUID;
|
|
775
|
+
}): Promise<Memory[]>;
|
|
776
|
+
createMemory(memory: Memory, tableName: string, unique?: boolean): Promise<UUID>;
|
|
777
|
+
updateMemory(memory: Partial<Memory> & {
|
|
778
|
+
id: UUID;
|
|
779
|
+
metadata?: MemoryMetadata;
|
|
780
|
+
}): Promise<boolean>;
|
|
781
|
+
deleteMemory(memoryId: UUID): Promise<void>;
|
|
782
|
+
deleteAllMemories(roomId: UUID, tableName: string): Promise<void>;
|
|
783
|
+
countMemories(roomId: UUID, unique?: boolean, tableName?: string): Promise<number>;
|
|
784
|
+
createWorld(world: World): Promise<UUID>;
|
|
785
|
+
getWorld(id: UUID): Promise<World | null>;
|
|
786
|
+
removeWorld(id: UUID): Promise<void>;
|
|
787
|
+
getAllWorlds(): Promise<World[]>;
|
|
788
|
+
updateWorld(world: World): Promise<void>;
|
|
789
|
+
getRoomsByIds(roomIds: UUID[]): Promise<Room[] | null>;
|
|
790
|
+
createRooms(rooms: Room[]): Promise<UUID[]>;
|
|
791
|
+
deleteRoom(roomId: UUID): Promise<void>;
|
|
792
|
+
deleteRoomsByWorldId(worldId: UUID): Promise<void>;
|
|
793
|
+
updateRoom(room: Room): Promise<void>;
|
|
794
|
+
getRoomsForParticipant(entityId: UUID): Promise<UUID[]>;
|
|
795
|
+
getRoomsForParticipants(userIds: UUID[]): Promise<UUID[]>;
|
|
796
|
+
getRoomsByWorld(worldId: UUID): Promise<Room[]>;
|
|
797
|
+
removeParticipant(entityId: UUID, roomId: UUID): Promise<boolean>;
|
|
798
|
+
getParticipantsForEntity(entityId: UUID): Promise<Participant[]>;
|
|
799
|
+
getParticipantsForRoom(roomId: UUID): Promise<UUID[]>;
|
|
800
|
+
addParticipantsRoom(entityIds: UUID[], roomId: UUID): Promise<boolean>;
|
|
801
|
+
getParticipantUserState(roomId: UUID, entityId: UUID): Promise<'FOLLOWED' | 'MUTED' | null>;
|
|
802
|
+
setParticipantUserState(roomId: UUID, entityId: UUID, state: 'FOLLOWED' | 'MUTED' | null): Promise<void>;
|
|
803
|
+
/**
|
|
804
|
+
* Creates a new relationship between two entities.
|
|
805
|
+
* @param params Object containing the relationship details
|
|
806
|
+
* @returns Promise resolving to boolean indicating success
|
|
807
|
+
*/
|
|
808
|
+
createRelationship(params: {
|
|
809
|
+
sourceEntityId: UUID;
|
|
810
|
+
targetEntityId: UUID;
|
|
811
|
+
tags?: string[];
|
|
812
|
+
metadata?: {
|
|
813
|
+
[key: string]: any;
|
|
814
|
+
};
|
|
815
|
+
}): Promise<boolean>;
|
|
816
|
+
/**
|
|
817
|
+
* Updates an existing relationship between two entities.
|
|
818
|
+
* @param relationship The relationship object with updated data
|
|
819
|
+
* @returns Promise resolving to void
|
|
820
|
+
*/
|
|
821
|
+
updateRelationship(relationship: Relationship): Promise<void>;
|
|
822
|
+
/**
|
|
823
|
+
* Retrieves a relationship between two entities if it exists.
|
|
824
|
+
* @param params Object containing the entity IDs and agent ID
|
|
825
|
+
* @returns Promise resolving to the Relationship object or null if not found
|
|
826
|
+
*/
|
|
827
|
+
getRelationship(params: {
|
|
828
|
+
sourceEntityId: UUID;
|
|
829
|
+
targetEntityId: UUID;
|
|
830
|
+
}): Promise<Relationship | null>;
|
|
831
|
+
/**
|
|
832
|
+
* Retrieves all relationships for a specific entity.
|
|
833
|
+
* @param params Object containing the user ID, agent ID and optional tags to filter by
|
|
834
|
+
* @returns Promise resolving to an array of Relationship objects
|
|
835
|
+
*/
|
|
836
|
+
getRelationships(params: {
|
|
837
|
+
entityId: UUID;
|
|
838
|
+
tags?: string[];
|
|
839
|
+
}): Promise<Relationship[]>;
|
|
840
|
+
getCache<T>(key: string): Promise<T | undefined>;
|
|
841
|
+
setCache<T>(key: string, value: T): Promise<boolean>;
|
|
842
|
+
deleteCache(key: string): Promise<boolean>;
|
|
843
|
+
createTask(task: Task): Promise<UUID>;
|
|
844
|
+
getTasks(params: {
|
|
845
|
+
roomId?: UUID;
|
|
846
|
+
tags?: string[];
|
|
847
|
+
entityId?: UUID;
|
|
848
|
+
}): Promise<Task[]>;
|
|
849
|
+
getTask(id: UUID): Promise<Task | null>;
|
|
850
|
+
getTasksByName(name: string): Promise<Task[]>;
|
|
851
|
+
updateTask(id: UUID, task: Partial<Task>): Promise<void>;
|
|
852
|
+
deleteTask(id: UUID): Promise<void>;
|
|
853
|
+
getMemoriesByWorldId(params: {
|
|
854
|
+
worldId: UUID;
|
|
855
|
+
count?: number;
|
|
856
|
+
tableName?: string;
|
|
857
|
+
}): Promise<Memory[]>;
|
|
858
|
+
}
|
|
859
|
+
/**
|
|
860
|
+
* Result interface for embedding similarity searches
|
|
861
|
+
*/
|
|
862
|
+
interface EmbeddingSearchResult {
|
|
863
|
+
embedding: number[];
|
|
864
|
+
levenshtein_score: number;
|
|
865
|
+
}
|
|
866
|
+
/**
|
|
867
|
+
* Options for memory retrieval operations
|
|
868
|
+
*/
|
|
869
|
+
interface MemoryRetrievalOptions {
|
|
870
|
+
roomId: UUID;
|
|
871
|
+
count?: number;
|
|
872
|
+
unique?: boolean;
|
|
873
|
+
start?: number;
|
|
874
|
+
end?: number;
|
|
875
|
+
agentId?: UUID;
|
|
876
|
+
}
|
|
877
|
+
/**
|
|
878
|
+
* Options for memory search operations
|
|
879
|
+
*/
|
|
880
|
+
interface MemorySearchOptions {
|
|
881
|
+
embedding: number[];
|
|
882
|
+
match_threshold?: number;
|
|
883
|
+
count?: number;
|
|
884
|
+
roomId: UUID;
|
|
885
|
+
agentId?: UUID;
|
|
886
|
+
unique?: boolean;
|
|
887
|
+
metadata?: Partial<MemoryMetadata>;
|
|
888
|
+
}
|
|
889
|
+
/**
|
|
890
|
+
* Options for multi-room memory retrieval
|
|
891
|
+
*/
|
|
892
|
+
interface MultiRoomMemoryOptions {
|
|
893
|
+
roomIds: UUID[];
|
|
894
|
+
limit?: number;
|
|
895
|
+
agentId?: UUID;
|
|
896
|
+
}
|
|
897
|
+
/**
|
|
898
|
+
* Unified options pattern for memory operations
|
|
899
|
+
* Provides a simpler, more consistent interface
|
|
900
|
+
*/
|
|
901
|
+
interface UnifiedMemoryOptions {
|
|
902
|
+
roomId: UUID;
|
|
903
|
+
limit?: number;
|
|
904
|
+
agentId?: UUID;
|
|
905
|
+
unique?: boolean;
|
|
906
|
+
start?: number;
|
|
907
|
+
end?: number;
|
|
908
|
+
}
|
|
909
|
+
/**
|
|
910
|
+
* Specialized memory search options
|
|
911
|
+
*/
|
|
912
|
+
interface UnifiedSearchOptions extends UnifiedMemoryOptions {
|
|
913
|
+
embedding: number[];
|
|
914
|
+
similarity?: number;
|
|
915
|
+
}
|
|
916
|
+
/**
|
|
917
|
+
* Information describing the target of a message.
|
|
918
|
+
*/
|
|
919
|
+
interface TargetInfo {
|
|
920
|
+
source: string;
|
|
921
|
+
roomId?: UUID;
|
|
922
|
+
channelId?: string;
|
|
923
|
+
serverId?: string;
|
|
924
|
+
entityId?: UUID;
|
|
925
|
+
threadId?: string;
|
|
926
|
+
}
|
|
927
|
+
/**
|
|
928
|
+
* Function signature for handlers responsible for sending messages to specific platforms.
|
|
929
|
+
*/
|
|
930
|
+
type SendHandlerFunction = (runtime: IAgentRuntime, target: TargetInfo, content: Content) => Promise<void>;
|
|
931
|
+
/**
|
|
932
|
+
* Represents the core runtime environment for an agent.
|
|
933
|
+
* Defines methods for database interaction, plugin management, event handling,
|
|
934
|
+
* state composition, model usage, and task management.
|
|
935
|
+
*/
|
|
936
|
+
interface IAgentRuntime extends IDatabaseAdapter {
|
|
937
|
+
agentId: UUID;
|
|
938
|
+
character: Character;
|
|
939
|
+
providers: Provider[];
|
|
940
|
+
actions: Action[];
|
|
941
|
+
evaluators: Evaluator[];
|
|
942
|
+
plugins: Plugin[];
|
|
943
|
+
services: Map<ServiceTypeName, Service>;
|
|
944
|
+
events: Map<string, ((params: any) => Promise<void>)[]>;
|
|
945
|
+
fetch?: typeof fetch | null;
|
|
946
|
+
routes: Route[];
|
|
947
|
+
registerPlugin(plugin: Plugin): Promise<void>;
|
|
948
|
+
initialize(): Promise<void>;
|
|
949
|
+
getConnection(): Promise<PGlite | Pool>;
|
|
950
|
+
getService<T extends Service>(service: ServiceTypeName | string): T | null;
|
|
951
|
+
getAllServices(): Map<ServiceTypeName, Service>;
|
|
952
|
+
registerService(service: typeof Service): Promise<void>;
|
|
953
|
+
registerDatabaseAdapter(adapter: IDatabaseAdapter): void;
|
|
954
|
+
setSetting(key: string, value: string | boolean | null | any, secret?: boolean): void;
|
|
955
|
+
getSetting(key: string): string | boolean | null | any;
|
|
956
|
+
getConversationLength(): number;
|
|
957
|
+
processActions(message: Memory, responses: Memory[], state?: State, callback?: HandlerCallback): Promise<void>;
|
|
958
|
+
evaluate(message: Memory, state?: State, didRespond?: boolean, callback?: HandlerCallback, responses?: Memory[]): Promise<Evaluator[] | null>;
|
|
959
|
+
registerProvider(provider: Provider): void;
|
|
960
|
+
registerAction(action: Action): void;
|
|
961
|
+
registerEvaluator(evaluator: Evaluator): void;
|
|
962
|
+
ensureConnection({ entityId, roomId, metadata, userName, worldName, name, source, channelId, serverId, type, worldId, userId, }: {
|
|
963
|
+
entityId: UUID;
|
|
964
|
+
roomId: UUID;
|
|
965
|
+
userName?: string;
|
|
966
|
+
name?: string;
|
|
967
|
+
worldName?: string;
|
|
968
|
+
source?: string;
|
|
969
|
+
channelId?: string;
|
|
970
|
+
serverId?: string;
|
|
971
|
+
type: ChannelType;
|
|
972
|
+
worldId: UUID;
|
|
973
|
+
userId?: UUID;
|
|
974
|
+
metadata?: Record<string, any>;
|
|
975
|
+
}): Promise<void>;
|
|
976
|
+
ensureParticipantInRoom(entityId: UUID, roomId: UUID): Promise<void>;
|
|
977
|
+
ensureWorldExists(world: World): Promise<void>;
|
|
978
|
+
ensureRoomExists(room: Room): Promise<void>;
|
|
979
|
+
composeState(message: Memory, includeList?: string[], onlyInclude?: boolean, skipCache?: boolean): Promise<State>;
|
|
980
|
+
/**
|
|
981
|
+
* Use a model with strongly typed parameters and return values based on model type
|
|
982
|
+
* @template T - The model type to use
|
|
983
|
+
* @template R - The expected return type, defaults to the type defined in ModelResultMap[T]
|
|
984
|
+
* @param {T} modelType - The type of model to use
|
|
985
|
+
* @param {ModelParamsMap[T] | any} params - The parameters for the model, typed based on model type
|
|
986
|
+
* @returns {Promise<R>} - The model result, typed based on the provided generic type parameter
|
|
987
|
+
*/
|
|
988
|
+
useModel<T extends ModelTypeName, R = ModelResultMap[T]>(modelType: T, params: Omit<ModelParamsMap[T], 'runtime'> | any): Promise<R>;
|
|
989
|
+
registerModel(modelType: ModelTypeName | string, handler: (params: any) => Promise<any>, provider: string, priority?: number): void;
|
|
990
|
+
getModel(modelType: ModelTypeName | string): ((runtime: IAgentRuntime, params: any) => Promise<any>) | undefined;
|
|
991
|
+
registerEvent(event: string, handler: (params: any) => Promise<void>): void;
|
|
992
|
+
getEvent(event: string): ((params: any) => Promise<void>)[] | undefined;
|
|
993
|
+
emitEvent(event: string | string[], params: any): Promise<void>;
|
|
994
|
+
registerTaskWorker(taskHandler: TaskWorker): void;
|
|
995
|
+
getTaskWorker(name: string): TaskWorker | undefined;
|
|
996
|
+
stop(): Promise<void>;
|
|
997
|
+
addEmbeddingToMemory(memory: Memory): Promise<Memory>;
|
|
998
|
+
getEntityById(entityId: UUID): Promise<Entity | null>;
|
|
999
|
+
getRoom(roomId: UUID): Promise<Room | null>;
|
|
1000
|
+
createEntity(entity: Entity): Promise<boolean>;
|
|
1001
|
+
createRoom({ id, name, source, type, channelId, serverId, worldId }: Room): Promise<UUID>;
|
|
1002
|
+
addParticipant(entityId: UUID, roomId: UUID): Promise<boolean>;
|
|
1003
|
+
getRooms(worldId: UUID): Promise<Room[]>;
|
|
1004
|
+
/**
|
|
1005
|
+
* Registers a handler function responsible for sending messages to a specific source/platform.
|
|
1006
|
+
* @param source - The unique identifier string for the source (e.g., 'discord', 'telegram').
|
|
1007
|
+
* @param handler - The SendHandlerFunction to be called for this source.
|
|
1008
|
+
*/
|
|
1009
|
+
registerSendHandler(source: string, handler: SendHandlerFunction): void;
|
|
1010
|
+
/**
|
|
1011
|
+
* Sends a message to a specified target using the appropriate registered handler.
|
|
1012
|
+
* @param target - Information describing the target recipient and platform.
|
|
1013
|
+
* @param content - The message content to send.
|
|
1014
|
+
* @returns Promise resolving when the message sending process is initiated or completed.
|
|
1015
|
+
*/
|
|
1016
|
+
sendMessageToTarget(target: TargetInfo, content: Content): Promise<void>;
|
|
1017
|
+
}
|
|
1018
|
+
/**
|
|
1019
|
+
* Interface representing settings with string key-value pairs.
|
|
1020
|
+
*/
|
|
1021
|
+
interface RuntimeSettings {
|
|
1022
|
+
[key: string]: string | undefined;
|
|
1023
|
+
}
|
|
1024
|
+
/**
|
|
1025
|
+
* Represents a single item of knowledge that can be processed and stored by the agent.
|
|
1026
|
+
* Knowledge items consist of content (text and optional structured data) and metadata.
|
|
1027
|
+
* These items are typically added to the agent's knowledge base via `AgentRuntime.addKnowledge`
|
|
1028
|
+
* and retrieved using `AgentRuntime.getKnowledge`.
|
|
1029
|
+
* The `id` is a unique identifier for the knowledge item, often derived from its source or content.
|
|
1030
|
+
*/
|
|
1031
|
+
type KnowledgeItem = {
|
|
1032
|
+
/** A Universally Unique Identifier for this specific knowledge item. */
|
|
1033
|
+
id: UUID;
|
|
1034
|
+
/** The actual content of the knowledge item, which must include text and can have other fields. */
|
|
1035
|
+
content: Content;
|
|
1036
|
+
/** Optional metadata associated with this knowledge item, conforming to `MemoryMetadata`. */
|
|
1037
|
+
metadata?: MemoryMetadata;
|
|
1038
|
+
};
|
|
1039
|
+
/**
|
|
1040
|
+
* Defines the scope or visibility of knowledge items within the agent's system.
|
|
1041
|
+
* - `SHARED`: Indicates knowledge that is broadly accessible, potentially across different agents or users if the system architecture permits.
|
|
1042
|
+
* - `PRIVATE`: Indicates knowledge that is restricted, typically to the specific agent or user context it belongs to.
|
|
1043
|
+
* This enum is used to manage access and retrieval of knowledge items, often in conjunction with `AgentRuntime.addKnowledge` or `AgentRuntime.getKnowledge` scopes.
|
|
1044
|
+
*/
|
|
1045
|
+
declare enum KnowledgeScope {
|
|
1046
|
+
SHARED = "shared",
|
|
1047
|
+
PRIVATE = "private"
|
|
1048
|
+
}
|
|
1049
|
+
/**
|
|
1050
|
+
* Specifies prefixes for keys used in caching mechanisms, helping to namespace cached data.
|
|
1051
|
+
* For example, `KNOWLEDGE` might be used to prefix keys for cached knowledge embeddings or processed documents.
|
|
1052
|
+
* This helps in organizing the cache and avoiding key collisions.
|
|
1053
|
+
* Used internally by caching strategies, potentially within `IDatabaseAdapter` cache methods or runtime caching layers.
|
|
1054
|
+
*/
|
|
1055
|
+
declare enum CacheKeyPrefix {
|
|
1056
|
+
KNOWLEDGE = "knowledge"
|
|
1057
|
+
}
|
|
1058
|
+
/**
|
|
1059
|
+
* Represents an item within a directory listing, specifically for knowledge loading.
|
|
1060
|
+
* When an agent's `Character.knowledge` configuration includes a directory, this type
|
|
1061
|
+
* is used to specify the path to that directory and whether its contents should be treated as shared.
|
|
1062
|
+
* - `directory`: The path to the directory containing knowledge files.
|
|
1063
|
+
* - `shared`: An optional boolean (defaults to false) indicating if the knowledge from this directory is considered shared or private.
|
|
1064
|
+
*/
|
|
1065
|
+
interface DirectoryItem {
|
|
1066
|
+
/** The path to the directory containing knowledge files. */
|
|
1067
|
+
directory: string;
|
|
1068
|
+
/** If true, knowledge from this directory is considered shared; otherwise, it's private. Defaults to false. */
|
|
1069
|
+
shared?: boolean;
|
|
1070
|
+
}
|
|
1071
|
+
/**
|
|
1072
|
+
* Represents a row structure, typically from a database query related to text chunking or processing.
|
|
1073
|
+
* This interface is quite minimal and seems to be a placeholder or a base for more specific chunk-related types.
|
|
1074
|
+
* The `id` would be the unique identifier for the chunk.
|
|
1075
|
+
* It might be used when splitting large documents into smaller, manageable pieces for embedding or analysis.
|
|
1076
|
+
*/
|
|
1077
|
+
interface ChunkRow {
|
|
1078
|
+
/** The unique identifier for this chunk of text. */
|
|
1079
|
+
id: string;
|
|
1080
|
+
}
|
|
1081
|
+
/**
|
|
1082
|
+
* Parameters for generating text using a language model.
|
|
1083
|
+
* This structure is typically passed to `AgentRuntime.useModel` when the `modelType` is one of
|
|
1084
|
+
* `ModelType.TEXT_SMALL`, `ModelType.TEXT_LARGE`, `ModelType.TEXT_REASONING_SMALL`,
|
|
1085
|
+
* `ModelType.TEXT_REASONING_LARGE`, or `ModelType.TEXT_COMPLETION`.
|
|
1086
|
+
* It includes essential information like the prompt, model type, and various generation controls.
|
|
1087
|
+
*/
|
|
1088
|
+
type GenerateTextParams = {
|
|
1089
|
+
/** The `AgentRuntime` instance, providing access to models and other services. */
|
|
1090
|
+
runtime: IAgentRuntime;
|
|
1091
|
+
/** The input string or prompt that the language model will use to generate text. */
|
|
1092
|
+
prompt: string;
|
|
1093
|
+
/** Specifies the type of text generation model to use (e.g., TEXT_LARGE, REASONING_SMALL). */
|
|
1094
|
+
modelType: ModelTypeName;
|
|
1095
|
+
/** Optional. The maximum number of tokens to generate in the response. */
|
|
1096
|
+
maxTokens?: number;
|
|
1097
|
+
/** Optional. Controls randomness (0.0-1.0). Lower values are more deterministic, higher are more creative. */
|
|
1098
|
+
temperature?: number;
|
|
1099
|
+
/** Optional. Penalizes new tokens based on their existing frequency in the text so far. */
|
|
1100
|
+
frequencyPenalty?: number;
|
|
1101
|
+
/** Optional. Penalizes new tokens based on whether they appear in the text so far. */
|
|
1102
|
+
presencePenalty?: number;
|
|
1103
|
+
/** Optional. A list of sequences at which the model will stop generating further tokens. */
|
|
1104
|
+
stopSequences?: string[];
|
|
1105
|
+
};
|
|
1106
|
+
/**
|
|
1107
|
+
* Parameters for detokenizing text, i.e., converting a sequence of numerical tokens back into a string.
|
|
1108
|
+
* This is the reverse operation of tokenization.
|
|
1109
|
+
* This structure is used with `AgentRuntime.useModel` when the `modelType` is `ModelType.TEXT_TOKENIZER_DECODE`.
|
|
1110
|
+
*/
|
|
1111
|
+
interface DetokenizeTextParams {
|
|
1112
|
+
/** An array of numerical tokens to be converted back into text. */
|
|
1113
|
+
tokens: number[];
|
|
1114
|
+
/** The model type used for detokenization, ensuring consistency with the original tokenization. */
|
|
1115
|
+
modelType: ModelTypeName;
|
|
1116
|
+
}
|
|
1117
|
+
/**
|
|
1118
|
+
* Represents a test case for evaluating agent or plugin functionality.
|
|
1119
|
+
* Each test case has a name and a function that contains the test logic.
|
|
1120
|
+
* The test function receives the `IAgentRuntime` instance, allowing it to interact with the agent's capabilities.
|
|
1121
|
+
* Test cases are typically grouped into `TestSuite`s.
|
|
1122
|
+
*/
|
|
1123
|
+
interface TestCase {
|
|
1124
|
+
/** A descriptive name for the test case, e.g., "should respond to greetings". */
|
|
1125
|
+
name: string;
|
|
1126
|
+
/**
|
|
1127
|
+
* The function that executes the test logic. It can be synchronous or asynchronous.
|
|
1128
|
+
* It receives the `IAgentRuntime` to interact with the agent and its services.
|
|
1129
|
+
* The function should typically contain assertions to verify expected outcomes.
|
|
1130
|
+
*/
|
|
1131
|
+
fn: (runtime: IAgentRuntime) => Promise<void> | void;
|
|
1132
|
+
}
|
|
1133
|
+
/**
|
|
1134
|
+
* Represents a suite of related test cases for an agent or plugin.
|
|
1135
|
+
* This helps in organizing tests and running them collectively.
|
|
1136
|
+
* A `ProjectAgent` can define one or more `TestSuite`s.
|
|
1137
|
+
*/
|
|
1138
|
+
interface TestSuite {
|
|
1139
|
+
/** A descriptive name for the test suite, e.g., "Core Functionality Tests". */
|
|
1140
|
+
name: string;
|
|
1141
|
+
/** An array of `TestCase` objects that belong to this suite. */
|
|
1142
|
+
tests: TestCase[];
|
|
1143
|
+
}
|
|
1144
|
+
/**
|
|
1145
|
+
* Represents an agent's registration details within a Trusted Execution Environment (TEE) context.
|
|
1146
|
+
* This is typically stored in a database table (e.g., `TeeAgent`) to manage agents operating in a TEE.
|
|
1147
|
+
* It allows for multiple registrations of the same `agentId` to support scenarios where an agent might restart,
|
|
1148
|
+
* generating a new keypair and attestation each time.
|
|
1149
|
+
*/
|
|
1150
|
+
interface TeeAgent {
|
|
1151
|
+
/** Primary key for the TEE agent registration record (e.g., a UUID or auto-incrementing ID). */
|
|
1152
|
+
id: string;
|
|
1153
|
+
/** The core identifier of the agent, which can be duplicated across multiple TEE registrations. */
|
|
1154
|
+
agentId: string;
|
|
1155
|
+
/** The human-readable name of the agent. */
|
|
1156
|
+
agentName: string;
|
|
1157
|
+
/** Timestamp (e.g., Unix epoch in milliseconds) when this TEE registration was created. */
|
|
1158
|
+
createdAt: number;
|
|
1159
|
+
/** The public key associated with this specific TEE agent instance/session. */
|
|
1160
|
+
publicKey: string;
|
|
1161
|
+
/** The attestation document proving the authenticity and integrity of the TEE instance. */
|
|
1162
|
+
attestation: string;
|
|
1163
|
+
}
|
|
1164
|
+
/**
|
|
1165
|
+
* Defines the operational modes for a Trusted Execution Environment (TEE).
|
|
1166
|
+
* This enum is used to configure how TEE functionalities are engaged, allowing for
|
|
1167
|
+
* different setups for local development, Docker-based development, and production.
|
|
1168
|
+
*/
|
|
1169
|
+
declare enum TEEMode {
|
|
1170
|
+
/** TEE functionality is completely disabled. */
|
|
1171
|
+
OFF = "OFF",
|
|
1172
|
+
/** For local development, potentially using a TEE simulator. */
|
|
1173
|
+
LOCAL = "LOCAL",// For local development with simulator
|
|
1174
|
+
/** For Docker-based development environments, possibly with a TEE simulator. */
|
|
1175
|
+
DOCKER = "DOCKER",// For docker development with simulator
|
|
1176
|
+
/** For production deployments, using actual TEE hardware without a simulator. */
|
|
1177
|
+
PRODUCTION = "PRODUCTION"
|
|
1178
|
+
}
|
|
1179
|
+
/**
|
|
1180
|
+
* Represents a quote obtained during remote attestation for a Trusted Execution Environment (TEE).
|
|
1181
|
+
* This quote is a piece of evidence provided by the TEE, cryptographically signed, which can be
|
|
1182
|
+
* verified by a relying party to ensure the TEE's integrity and authenticity.
|
|
1183
|
+
*/
|
|
1184
|
+
interface RemoteAttestationQuote {
|
|
1185
|
+
/** The attestation quote data, typically a base64 encoded string or similar format. */
|
|
1186
|
+
quote: string;
|
|
1187
|
+
/** Timestamp (e.g., Unix epoch in milliseconds) when the quote was generated or received. */
|
|
1188
|
+
timestamp: number;
|
|
1189
|
+
}
|
|
1190
|
+
/**
|
|
1191
|
+
* Data structure used in the attestation process for deriving a key within a Trusted Execution Environment (TEE).
|
|
1192
|
+
* This information helps establish a secure channel or verify the identity of the agent instance
|
|
1193
|
+
* requesting key derivation.
|
|
1194
|
+
*/
|
|
1195
|
+
interface DeriveKeyAttestationData {
|
|
1196
|
+
/** The unique identifier of the agent for which the key derivation is being attested. */
|
|
1197
|
+
agentId: string;
|
|
1198
|
+
/** The public key of the agent instance involved in the key derivation process. */
|
|
1199
|
+
publicKey: string;
|
|
1200
|
+
/** Optional subject or context information related to the key derivation. */
|
|
1201
|
+
subject?: string;
|
|
1202
|
+
}
|
|
1203
|
+
/**
|
|
1204
|
+
* Represents a message that has been attested by a Trusted Execution Environment (TEE).
|
|
1205
|
+
* This structure binds a message to an agent's identity and a timestamp, all within the
|
|
1206
|
+
* context of a remote attestation process, ensuring the message originated from a trusted TEE instance.
|
|
1207
|
+
*/
|
|
1208
|
+
interface RemoteAttestationMessage {
|
|
1209
|
+
/** The unique identifier of the agent sending the attested message. */
|
|
1210
|
+
agentId: string;
|
|
1211
|
+
/** Timestamp (e.g., Unix epoch in milliseconds) when the message was attested or sent. */
|
|
1212
|
+
timestamp: number;
|
|
1213
|
+
/** The actual message content, including details about the entity, room, and the content itself. */
|
|
1214
|
+
message: {
|
|
1215
|
+
entityId: string;
|
|
1216
|
+
roomId: string;
|
|
1217
|
+
content: string;
|
|
1218
|
+
};
|
|
1219
|
+
}
|
|
1220
|
+
/**
|
|
1221
|
+
* Enumerates different types or vendors of Trusted Execution Environments (TEEs).
|
|
1222
|
+
* This allows the system to adapt to specific TEE technologies, like Intel TDX on DSTACK.
|
|
1223
|
+
*/
|
|
1224
|
+
declare enum TeeType {
|
|
1225
|
+
/** Represents Intel Trusted Domain Extensions (TDX) running on DSTACK infrastructure. */
|
|
1226
|
+
TDX_DSTACK = "tdx_dstack"
|
|
1227
|
+
}
|
|
1228
|
+
/**
|
|
1229
|
+
* Configuration options specific to a particular Trusted Execution Environment (TEE) vendor.
|
|
1230
|
+
* This allows for vendor-specific settings to be passed to the TEE plugin or service.
|
|
1231
|
+
* The structure is a generic key-value map, as configurations can vary widely between vendors.
|
|
1232
|
+
*/
|
|
1233
|
+
interface TeeVendorConfig {
|
|
1234
|
+
[key: string]: unknown;
|
|
1235
|
+
}
|
|
1236
|
+
/**
|
|
1237
|
+
* Configuration for a TEE (Trusted Execution Environment) plugin.
|
|
1238
|
+
* This allows specifying the TEE vendor and any vendor-specific configurations.
|
|
1239
|
+
* It's used to initialize and configure TEE-related functionalities within the agent system.
|
|
1240
|
+
*/
|
|
1241
|
+
interface TeePluginConfig {
|
|
1242
|
+
/** Optional. The name or identifier of the TEE vendor (e.g., 'tdx_dstack' from `TeeType`). */
|
|
1243
|
+
vendor?: string;
|
|
1244
|
+
/** Optional. Vendor-specific configuration options, conforming to `TeeVendorConfig`. */
|
|
1245
|
+
vendorConfig?: TeeVendorConfig;
|
|
1246
|
+
}
|
|
1247
|
+
/**
|
|
1248
|
+
* Defines the contract for a Task Worker, which is responsible for executing a specific type of task.
|
|
1249
|
+
* Task workers are registered with the `AgentRuntime` and are invoked when a `Task` of their designated `name` needs processing.
|
|
1250
|
+
* This pattern allows for modular and extensible background task processing.
|
|
1251
|
+
*/
|
|
1252
|
+
interface TaskWorker {
|
|
1253
|
+
/** The unique name of the task type this worker handles. This name links `Task` instances to this worker. */
|
|
1254
|
+
name: string;
|
|
1255
|
+
/**
|
|
1256
|
+
* The core execution logic for the task. This function is called by the runtime when a task needs to be processed.
|
|
1257
|
+
* It receives the `AgentRuntime`, task-specific `options`, and the `Task` object itself.
|
|
1258
|
+
*/
|
|
1259
|
+
execute: (runtime: IAgentRuntime, options: {
|
|
1260
|
+
[key: string]: unknown;
|
|
1261
|
+
}, task: Task) => Promise<void>;
|
|
1262
|
+
/**
|
|
1263
|
+
* Optional validation function that can be used to determine if a task is valid or should be executed,
|
|
1264
|
+
* often based on the current message and state. This might be used by an action or evaluator
|
|
1265
|
+
* before creating or queueing a task.
|
|
1266
|
+
*/
|
|
1267
|
+
validate?: (runtime: IAgentRuntime, message: Memory, state: State) => Promise<boolean>;
|
|
1268
|
+
}
|
|
1269
|
+
/**
|
|
1270
|
+
* Defines metadata associated with a `Task`.
|
|
1271
|
+
* This can include scheduling information like `updateInterval` or UI-related details
|
|
1272
|
+
* for presenting task options to a user.
|
|
1273
|
+
* The `[key: string]: unknown;` allows for additional, unspecified metadata fields.
|
|
1274
|
+
*/
|
|
1275
|
+
type TaskMetadata = {
|
|
1276
|
+
/** Optional. If the task is recurring, this specifies the interval in milliseconds between updates or executions. */
|
|
1277
|
+
updateInterval?: number;
|
|
1278
|
+
/** Optional. Describes options or parameters that can be configured for this task, often for UI presentation. */
|
|
1279
|
+
options?: {
|
|
1280
|
+
name: string;
|
|
1281
|
+
description: string;
|
|
1282
|
+
}[];
|
|
1283
|
+
/** Allows for other dynamic metadata properties related to the task. */
|
|
1284
|
+
[key: string]: unknown;
|
|
1285
|
+
};
|
|
1286
|
+
/**
|
|
1287
|
+
* Represents a task to be performed, often in the background or at a later time.
|
|
1288
|
+
* Tasks are managed by the `AgentRuntime` and processed by registered `TaskWorker`s.
|
|
1289
|
+
* They can be associated with a room, world, and tagged for categorization and retrieval.
|
|
1290
|
+
* The `IDatabaseAdapter` handles persistence of task data.
|
|
1291
|
+
*/
|
|
1292
|
+
interface Task {
|
|
1293
|
+
/** Optional. A Universally Unique Identifier for the task. Generated if not provided. */
|
|
1294
|
+
id?: UUID;
|
|
1295
|
+
/** The name of the task, which should correspond to a registered `TaskWorker.name`. */
|
|
1296
|
+
name: string;
|
|
1297
|
+
/** Optional. Timestamp of the last update to this task. */
|
|
1298
|
+
updatedAt?: number;
|
|
1299
|
+
/** Optional. Metadata associated with the task, conforming to `TaskMetadata`. */
|
|
1300
|
+
metadata?: TaskMetadata;
|
|
1301
|
+
/** A human-readable description of what the task does or its purpose. */
|
|
1302
|
+
description: string;
|
|
1303
|
+
/** Optional. The UUID of the room this task is associated with. */
|
|
1304
|
+
roomId?: UUID;
|
|
1305
|
+
/** Optional. The UUID of the world this task is associated with. */
|
|
1306
|
+
worldId?: UUID;
|
|
1307
|
+
entityId?: UUID;
|
|
1308
|
+
tags: string[];
|
|
1309
|
+
}
|
|
1310
|
+
/**
|
|
1311
|
+
* Defines roles within a system, typically for access control or permissions, often within a `World`.
|
|
1312
|
+
* - `OWNER`: Represents the highest level of control, typically the creator or primary administrator.
|
|
1313
|
+
* - `ADMIN`: Represents administrative privileges, usually a subset of owner capabilities.
|
|
1314
|
+
* - `NONE`: Indicates no specific role or default, minimal permissions.
|
|
1315
|
+
* These roles are often used in `World.metadata.roles` to assign roles to entities.
|
|
1316
|
+
*/
|
|
1317
|
+
declare enum Role {
|
|
1318
|
+
OWNER = "OWNER",
|
|
1319
|
+
ADMIN = "ADMIN",
|
|
1320
|
+
NONE = "NONE"
|
|
1321
|
+
}
|
|
1322
|
+
interface Setting {
|
|
1323
|
+
name: string;
|
|
1324
|
+
description: string;
|
|
1325
|
+
usageDescription: string;
|
|
1326
|
+
value: string | boolean | null;
|
|
1327
|
+
required: boolean;
|
|
1328
|
+
public?: boolean;
|
|
1329
|
+
secret?: boolean;
|
|
1330
|
+
validation?: (value: any) => boolean;
|
|
1331
|
+
dependsOn?: string[];
|
|
1332
|
+
onSetAction?: (value: any) => string;
|
|
1333
|
+
visibleIf?: (settings: {
|
|
1334
|
+
[key: string]: Setting;
|
|
1335
|
+
}) => boolean;
|
|
1336
|
+
}
|
|
1337
|
+
interface WorldSettings {
|
|
1338
|
+
[key: string]: Setting;
|
|
1339
|
+
}
|
|
1340
|
+
interface OnboardingConfig {
|
|
1341
|
+
settings: {
|
|
1342
|
+
[key: string]: Omit<Setting, 'value'>;
|
|
1343
|
+
};
|
|
1344
|
+
}
|
|
1345
|
+
/**
|
|
1346
|
+
* Base parameters common to all model types
|
|
1347
|
+
*/
|
|
1348
|
+
interface BaseModelParams {
|
|
1349
|
+
/** The agent runtime for accessing services and utilities */
|
|
1350
|
+
runtime: IAgentRuntime;
|
|
1351
|
+
}
|
|
1352
|
+
/**
|
|
1353
|
+
* Parameters for text generation models
|
|
1354
|
+
*/
|
|
1355
|
+
interface TextGenerationParams extends BaseModelParams {
|
|
1356
|
+
/** The prompt to generate text from */
|
|
1357
|
+
prompt: string;
|
|
1358
|
+
/** Model temperature (0.0 to 1.0, lower is more deterministic) */
|
|
1359
|
+
temperature?: number;
|
|
1360
|
+
/** Maximum number of tokens to generate */
|
|
1361
|
+
maxTokens?: number;
|
|
1362
|
+
/** Sequences that should stop generation when encountered */
|
|
1363
|
+
stopSequences?: string[];
|
|
1364
|
+
/** Frequency penalty to apply */
|
|
1365
|
+
frequencyPenalty?: number;
|
|
1366
|
+
/** Presence penalty to apply */
|
|
1367
|
+
presencePenalty?: number;
|
|
1368
|
+
}
|
|
1369
|
+
/**
|
|
1370
|
+
* Parameters for text embedding models
|
|
1371
|
+
*/
|
|
1372
|
+
interface TextEmbeddingParams extends BaseModelParams {
|
|
1373
|
+
/** The text to create embeddings for */
|
|
1374
|
+
text: string;
|
|
1375
|
+
}
|
|
1376
|
+
/**
|
|
1377
|
+
* Parameters for text tokenization models
|
|
1378
|
+
*/
|
|
1379
|
+
interface TokenizeTextParams extends BaseModelParams {
|
|
1380
|
+
/** The text to tokenize */
|
|
1381
|
+
prompt: string;
|
|
1382
|
+
/** The model type to use for tokenization */
|
|
1383
|
+
modelType: ModelTypeName;
|
|
1384
|
+
}
|
|
1385
|
+
/**
|
|
1386
|
+
* Parameters for image generation models
|
|
1387
|
+
*/
|
|
1388
|
+
interface ImageGenerationParams extends BaseModelParams {
|
|
1389
|
+
/** The prompt describing the image to generate */
|
|
1390
|
+
prompt: string;
|
|
1391
|
+
/** The dimensions of the image to generate */
|
|
1392
|
+
size?: string;
|
|
1393
|
+
/** Number of images to generate */
|
|
1394
|
+
count?: number;
|
|
1395
|
+
}
|
|
1396
|
+
/**
|
|
1397
|
+
* Parameters for image description models
|
|
1398
|
+
*/
|
|
1399
|
+
interface ImageDescriptionParams extends BaseModelParams {
|
|
1400
|
+
/** The URL or path of the image to describe */
|
|
1401
|
+
imageUrl: string;
|
|
1402
|
+
/** Optional prompt to guide the description */
|
|
1403
|
+
prompt?: string;
|
|
1404
|
+
}
|
|
1405
|
+
/**
|
|
1406
|
+
* Parameters for transcription models
|
|
1407
|
+
*/
|
|
1408
|
+
interface TranscriptionParams extends BaseModelParams {
|
|
1409
|
+
/** The URL or path of the audio file to transcribe */
|
|
1410
|
+
audioUrl: string;
|
|
1411
|
+
/** Optional prompt to guide transcription */
|
|
1412
|
+
prompt?: string;
|
|
1413
|
+
}
|
|
1414
|
+
/**
|
|
1415
|
+
* Parameters for text-to-speech models
|
|
1416
|
+
*/
|
|
1417
|
+
interface TextToSpeechParams extends BaseModelParams {
|
|
1418
|
+
/** The text to convert to speech */
|
|
1419
|
+
text: string;
|
|
1420
|
+
/** The voice to use */
|
|
1421
|
+
voice?: string;
|
|
1422
|
+
/** The speaking speed */
|
|
1423
|
+
speed?: number;
|
|
1424
|
+
}
|
|
1425
|
+
/**
|
|
1426
|
+
* Parameters for audio processing models
|
|
1427
|
+
*/
|
|
1428
|
+
interface AudioProcessingParams extends BaseModelParams {
|
|
1429
|
+
/** The URL or path of the audio file to process */
|
|
1430
|
+
audioUrl: string;
|
|
1431
|
+
/** The type of audio processing to perform */
|
|
1432
|
+
processingType: string;
|
|
1433
|
+
}
|
|
1434
|
+
/**
|
|
1435
|
+
* Parameters for video processing models
|
|
1436
|
+
*/
|
|
1437
|
+
interface VideoProcessingParams extends BaseModelParams {
|
|
1438
|
+
/** The URL or path of the video file to process */
|
|
1439
|
+
videoUrl: string;
|
|
1440
|
+
/** The type of video processing to perform */
|
|
1441
|
+
processingType: string;
|
|
1442
|
+
}
|
|
1443
|
+
/**
|
|
1444
|
+
* Optional JSON schema for validating generated objects
|
|
1445
|
+
*/
|
|
1446
|
+
type JSONSchema = {
|
|
1447
|
+
type: string;
|
|
1448
|
+
properties?: Record<string, any>;
|
|
1449
|
+
required?: string[];
|
|
1450
|
+
items?: JSONSchema;
|
|
1451
|
+
[key: string]: any;
|
|
1452
|
+
};
|
|
1453
|
+
/**
|
|
1454
|
+
* Parameters for object generation models
|
|
1455
|
+
* @template T - The expected return type, inferred from schema if provided
|
|
1456
|
+
*/
|
|
1457
|
+
interface ObjectGenerationParams<T = any> extends BaseModelParams {
|
|
1458
|
+
/** The prompt describing the object to generate */
|
|
1459
|
+
prompt: string;
|
|
1460
|
+
/** Optional JSON schema for validation */
|
|
1461
|
+
schema?: JSONSchema;
|
|
1462
|
+
/** Type of object to generate */
|
|
1463
|
+
output?: 'object' | 'array' | 'enum';
|
|
1464
|
+
/** For enum type, the allowed values */
|
|
1465
|
+
enumValues?: string[];
|
|
1466
|
+
/** Model type to use */
|
|
1467
|
+
modelType?: ModelTypeName;
|
|
1468
|
+
/** Model temperature (0.0 to 1.0) */
|
|
1469
|
+
temperature?: number;
|
|
1470
|
+
/** Sequences that should stop generation */
|
|
1471
|
+
stopSequences?: string[];
|
|
1472
|
+
}
|
|
1473
|
+
/**
|
|
1474
|
+
* Map of model types to their parameter types
|
|
1475
|
+
*/
|
|
1476
|
+
interface ModelParamsMap {
|
|
1477
|
+
[ModelType.TEXT_SMALL]: TextGenerationParams;
|
|
1478
|
+
[ModelType.TEXT_LARGE]: TextGenerationParams;
|
|
1479
|
+
[ModelType.TEXT_EMBEDDING]: TextEmbeddingParams | string | null;
|
|
1480
|
+
[ModelType.TEXT_TOKENIZER_ENCODE]: TokenizeTextParams;
|
|
1481
|
+
[ModelType.TEXT_TOKENIZER_DECODE]: DetokenizeTextParams;
|
|
1482
|
+
[ModelType.TEXT_REASONING_SMALL]: TextGenerationParams;
|
|
1483
|
+
[ModelType.TEXT_REASONING_LARGE]: TextGenerationParams;
|
|
1484
|
+
[ModelType.IMAGE]: ImageGenerationParams;
|
|
1485
|
+
[ModelType.IMAGE_DESCRIPTION]: ImageDescriptionParams | string;
|
|
1486
|
+
[ModelType.TRANSCRIPTION]: TranscriptionParams | Buffer | string;
|
|
1487
|
+
[ModelType.TEXT_TO_SPEECH]: TextToSpeechParams | string;
|
|
1488
|
+
[ModelType.AUDIO]: AudioProcessingParams;
|
|
1489
|
+
[ModelType.VIDEO]: VideoProcessingParams;
|
|
1490
|
+
[ModelType.OBJECT_SMALL]: ObjectGenerationParams<any>;
|
|
1491
|
+
[ModelType.OBJECT_LARGE]: ObjectGenerationParams<any>;
|
|
1492
|
+
[key: string]: BaseModelParams | any;
|
|
1493
|
+
}
|
|
1494
|
+
/**
|
|
1495
|
+
* Map of model types to their return value types
|
|
1496
|
+
*/
|
|
1497
|
+
interface ModelResultMap {
|
|
1498
|
+
[ModelType.TEXT_SMALL]: string;
|
|
1499
|
+
[ModelType.TEXT_LARGE]: string;
|
|
1500
|
+
[ModelType.TEXT_EMBEDDING]: number[];
|
|
1501
|
+
[ModelType.TEXT_TOKENIZER_ENCODE]: number[];
|
|
1502
|
+
[ModelType.TEXT_TOKENIZER_DECODE]: string;
|
|
1503
|
+
[ModelType.TEXT_REASONING_SMALL]: string;
|
|
1504
|
+
[ModelType.TEXT_REASONING_LARGE]: string;
|
|
1505
|
+
[ModelType.IMAGE]: {
|
|
1506
|
+
url: string;
|
|
1507
|
+
}[];
|
|
1508
|
+
[ModelType.IMAGE_DESCRIPTION]: {
|
|
1509
|
+
title: string;
|
|
1510
|
+
description: string;
|
|
1511
|
+
};
|
|
1512
|
+
[ModelType.TRANSCRIPTION]: string;
|
|
1513
|
+
[ModelType.TEXT_TO_SPEECH]: any | Buffer;
|
|
1514
|
+
[ModelType.AUDIO]: any;
|
|
1515
|
+
[ModelType.VIDEO]: any;
|
|
1516
|
+
[ModelType.OBJECT_SMALL]: any;
|
|
1517
|
+
[ModelType.OBJECT_LARGE]: any;
|
|
1518
|
+
[key: string]: any;
|
|
1519
|
+
}
|
|
1520
|
+
/**
|
|
1521
|
+
* Standard event types across all platforms
|
|
1522
|
+
*/
|
|
1523
|
+
declare enum EventType {
|
|
1524
|
+
WORLD_JOINED = "WORLD_JOINED",
|
|
1525
|
+
WORLD_CONNECTED = "WORLD_CONNECTED",
|
|
1526
|
+
WORLD_LEFT = "WORLD_LEFT",
|
|
1527
|
+
ENTITY_JOINED = "ENTITY_JOINED",
|
|
1528
|
+
ENTITY_LEFT = "ENTITY_LEFT",
|
|
1529
|
+
ENTITY_UPDATED = "ENTITY_UPDATED",
|
|
1530
|
+
ROOM_JOINED = "ROOM_JOINED",
|
|
1531
|
+
ROOM_LEFT = "ROOM_LEFT",
|
|
1532
|
+
MESSAGE_RECEIVED = "MESSAGE_RECEIVED",
|
|
1533
|
+
MESSAGE_SENT = "MESSAGE_SENT",
|
|
1534
|
+
VOICE_MESSAGE_RECEIVED = "VOICE_MESSAGE_RECEIVED",
|
|
1535
|
+
VOICE_MESSAGE_SENT = "VOICE_MESSAGE_SENT",
|
|
1536
|
+
REACTION_RECEIVED = "REACTION_RECEIVED",
|
|
1537
|
+
POST_GENERATED = "POST_GENERATED",
|
|
1538
|
+
INTERACTION_RECEIVED = "INTERACTION_RECEIVED",
|
|
1539
|
+
RUN_STARTED = "RUN_STARTED",
|
|
1540
|
+
RUN_ENDED = "RUN_ENDED",
|
|
1541
|
+
RUN_TIMEOUT = "RUN_TIMEOUT",
|
|
1542
|
+
ACTION_STARTED = "ACTION_STARTED",
|
|
1543
|
+
ACTION_COMPLETED = "ACTION_COMPLETED",
|
|
1544
|
+
EVALUATOR_STARTED = "EVALUATOR_STARTED",
|
|
1545
|
+
EVALUATOR_COMPLETED = "EVALUATOR_COMPLETED",
|
|
1546
|
+
MODEL_USED = "MODEL_USED"
|
|
1547
|
+
}
|
|
1548
|
+
/**
|
|
1549
|
+
* Platform-specific event type prefix
|
|
1550
|
+
*/
|
|
1551
|
+
declare enum PlatformPrefix {
|
|
1552
|
+
DISCORD = "DISCORD",
|
|
1553
|
+
TELEGRAM = "TELEGRAM",
|
|
1554
|
+
TWITTER = "TWITTER"
|
|
1555
|
+
}
|
|
1556
|
+
/**
|
|
1557
|
+
* Base payload interface for all events
|
|
1558
|
+
*/
|
|
1559
|
+
interface EventPayload {
|
|
1560
|
+
runtime: IAgentRuntime;
|
|
1561
|
+
source: string;
|
|
1562
|
+
onComplete?: () => void;
|
|
1563
|
+
}
|
|
1564
|
+
/**
|
|
1565
|
+
* Payload for world-related events
|
|
1566
|
+
*/
|
|
1567
|
+
interface WorldPayload extends EventPayload {
|
|
1568
|
+
world: World;
|
|
1569
|
+
rooms: Room[];
|
|
1570
|
+
entities: Entity[];
|
|
1571
|
+
}
|
|
1572
|
+
/**
|
|
1573
|
+
* Payload for entity-related events
|
|
1574
|
+
*/
|
|
1575
|
+
interface EntityPayload extends EventPayload {
|
|
1576
|
+
entityId: UUID;
|
|
1577
|
+
worldId?: UUID;
|
|
1578
|
+
roomId?: UUID;
|
|
1579
|
+
metadata?: {
|
|
1580
|
+
orginalId: string;
|
|
1581
|
+
username: string;
|
|
1582
|
+
displayName?: string;
|
|
1583
|
+
[key: string]: any;
|
|
1584
|
+
};
|
|
1585
|
+
}
|
|
1586
|
+
/**
|
|
1587
|
+
* Payload for reaction-related events
|
|
1588
|
+
*/
|
|
1589
|
+
interface MessagePayload extends EventPayload {
|
|
1590
|
+
message: Memory;
|
|
1591
|
+
callback?: HandlerCallback;
|
|
1592
|
+
onComplete?: () => void;
|
|
1593
|
+
}
|
|
1594
|
+
/**
|
|
1595
|
+
* Payload for events that are invoked without a message
|
|
1596
|
+
*/
|
|
1597
|
+
interface InvokePayload extends EventPayload {
|
|
1598
|
+
worldId: UUID;
|
|
1599
|
+
userId: string;
|
|
1600
|
+
roomId: UUID;
|
|
1601
|
+
callback?: HandlerCallback;
|
|
1602
|
+
source: string;
|
|
1603
|
+
}
|
|
1604
|
+
/**
|
|
1605
|
+
* Run event payload type
|
|
1606
|
+
*/
|
|
1607
|
+
interface RunEventPayload extends EventPayload {
|
|
1608
|
+
runId: UUID;
|
|
1609
|
+
messageId: UUID;
|
|
1610
|
+
roomId: UUID;
|
|
1611
|
+
entityId: UUID;
|
|
1612
|
+
startTime: number;
|
|
1613
|
+
status: 'started' | 'completed' | 'timeout';
|
|
1614
|
+
endTime?: number;
|
|
1615
|
+
duration?: number;
|
|
1616
|
+
error?: string;
|
|
1617
|
+
}
|
|
1618
|
+
/**
|
|
1619
|
+
* Action event payload type
|
|
1620
|
+
*/
|
|
1621
|
+
interface ActionEventPayload extends EventPayload {
|
|
1622
|
+
actionId: UUID;
|
|
1623
|
+
actionName: string;
|
|
1624
|
+
startTime?: number;
|
|
1625
|
+
completed?: boolean;
|
|
1626
|
+
error?: Error;
|
|
1627
|
+
}
|
|
1628
|
+
/**
|
|
1629
|
+
* Evaluator event payload type
|
|
1630
|
+
*/
|
|
1631
|
+
interface EvaluatorEventPayload extends EventPayload {
|
|
1632
|
+
evaluatorId: UUID;
|
|
1633
|
+
evaluatorName: string;
|
|
1634
|
+
startTime?: number;
|
|
1635
|
+
completed?: boolean;
|
|
1636
|
+
error?: Error;
|
|
1637
|
+
}
|
|
1638
|
+
/**
|
|
1639
|
+
* Model event payload type
|
|
1640
|
+
*/
|
|
1641
|
+
interface ModelEventPayload extends EventPayload {
|
|
1642
|
+
provider: string;
|
|
1643
|
+
type: ModelTypeName;
|
|
1644
|
+
prompt: string;
|
|
1645
|
+
tokens?: {
|
|
1646
|
+
prompt: number;
|
|
1647
|
+
completion: number;
|
|
1648
|
+
total: number;
|
|
1649
|
+
};
|
|
1650
|
+
}
|
|
1651
|
+
type MessageReceivedHandlerParams = {
|
|
1652
|
+
runtime: IAgentRuntime;
|
|
1653
|
+
message: Memory;
|
|
1654
|
+
callback: HandlerCallback;
|
|
1655
|
+
onComplete?: () => void;
|
|
1656
|
+
};
|
|
1657
|
+
/**
|
|
1658
|
+
* Maps event types to their corresponding payload types
|
|
1659
|
+
*/
|
|
1660
|
+
interface EventPayloadMap {
|
|
1661
|
+
[EventType.WORLD_JOINED]: WorldPayload;
|
|
1662
|
+
[EventType.WORLD_CONNECTED]: WorldPayload;
|
|
1663
|
+
[EventType.WORLD_LEFT]: WorldPayload;
|
|
1664
|
+
[EventType.ENTITY_JOINED]: EntityPayload;
|
|
1665
|
+
[EventType.ENTITY_LEFT]: EntityPayload;
|
|
1666
|
+
[EventType.ENTITY_UPDATED]: EntityPayload;
|
|
1667
|
+
[EventType.MESSAGE_RECEIVED]: MessagePayload;
|
|
1668
|
+
[EventType.MESSAGE_SENT]: MessagePayload;
|
|
1669
|
+
[EventType.REACTION_RECEIVED]: MessagePayload;
|
|
1670
|
+
[EventType.POST_GENERATED]: InvokePayload;
|
|
1671
|
+
[EventType.INTERACTION_RECEIVED]: MessagePayload;
|
|
1672
|
+
[EventType.RUN_STARTED]: RunEventPayload;
|
|
1673
|
+
[EventType.RUN_ENDED]: RunEventPayload;
|
|
1674
|
+
[EventType.RUN_TIMEOUT]: RunEventPayload;
|
|
1675
|
+
[EventType.ACTION_STARTED]: ActionEventPayload;
|
|
1676
|
+
[EventType.ACTION_COMPLETED]: ActionEventPayload;
|
|
1677
|
+
[EventType.EVALUATOR_STARTED]: EvaluatorEventPayload;
|
|
1678
|
+
[EventType.EVALUATOR_COMPLETED]: EvaluatorEventPayload;
|
|
1679
|
+
[EventType.MODEL_USED]: ModelEventPayload;
|
|
1680
|
+
}
|
|
1681
|
+
/**
|
|
1682
|
+
* Event handler function type
|
|
1683
|
+
*/
|
|
1684
|
+
type EventHandler<T extends keyof EventPayloadMap> = (payload: EventPayloadMap[T]) => Promise<void>;
|
|
1685
|
+
/**
|
|
1686
|
+
* Update the Plugin interface with typed events
|
|
1687
|
+
*/
|
|
1688
|
+
declare enum SOCKET_MESSAGE_TYPE {
|
|
1689
|
+
ROOM_JOINING = 1,
|
|
1690
|
+
SEND_MESSAGE = 2,
|
|
1691
|
+
MESSAGE = 3,
|
|
1692
|
+
ACK = 4,
|
|
1693
|
+
THINKING = 5,
|
|
1694
|
+
CONTROL = 6
|
|
1695
|
+
}
|
|
1696
|
+
/**
|
|
1697
|
+
* Specialized memory type for messages with enhanced type checking
|
|
1698
|
+
*/
|
|
1699
|
+
interface MessageMemory extends Memory {
|
|
1700
|
+
metadata: MessageMetadata;
|
|
1701
|
+
content: Content & {
|
|
1702
|
+
text: string;
|
|
1703
|
+
};
|
|
1704
|
+
}
|
|
1705
|
+
/**
|
|
1706
|
+
* Factory function to create a new message memory with proper defaults
|
|
1707
|
+
*/
|
|
1708
|
+
declare function createMessageMemory(params: {
|
|
1709
|
+
id?: UUID;
|
|
1710
|
+
entityId: UUID;
|
|
1711
|
+
agentId?: UUID;
|
|
1712
|
+
roomId: UUID;
|
|
1713
|
+
content: Content & {
|
|
1714
|
+
text: string;
|
|
1715
|
+
};
|
|
1716
|
+
embedding?: number[];
|
|
1717
|
+
}): MessageMemory;
|
|
1718
|
+
/**
|
|
1719
|
+
* Generic service interface that provides better type checking for services
|
|
1720
|
+
* @template ConfigType The configuration type for this service
|
|
1721
|
+
* @template ResultType The result type returned by the service operations
|
|
1722
|
+
*/
|
|
1723
|
+
interface TypedService<ConfigType extends {
|
|
1724
|
+
[key: string]: any;
|
|
1725
|
+
} = {
|
|
1726
|
+
[key: string]: any;
|
|
1727
|
+
}, ResultType = unknown> extends Service {
|
|
1728
|
+
/**
|
|
1729
|
+
* The configuration for this service instance
|
|
1730
|
+
*/
|
|
1731
|
+
config?: ConfigType;
|
|
1732
|
+
/**
|
|
1733
|
+
* Process an input with this service
|
|
1734
|
+
* @param input The input to process
|
|
1735
|
+
* @returns A promise resolving to the result
|
|
1736
|
+
*/
|
|
1737
|
+
process(input: unknown): Promise<ResultType>;
|
|
1738
|
+
}
|
|
1739
|
+
/**
|
|
1740
|
+
* Generic factory function to create a typed service instance
|
|
1741
|
+
* @param runtime The agent runtime
|
|
1742
|
+
* @param serviceType The type of service to get
|
|
1743
|
+
* @returns The service instance or null if not available
|
|
1744
|
+
*/
|
|
1745
|
+
declare function getTypedService<T extends TypedService<any, any>>(runtime: IAgentRuntime, serviceType: ServiceTypeName): T | null;
|
|
1746
|
+
/**
|
|
1747
|
+
* Type guard to check if a memory metadata is a DocumentMetadata
|
|
1748
|
+
* @param metadata The metadata to check
|
|
1749
|
+
* @returns True if the metadata is a DocumentMetadata
|
|
1750
|
+
*/
|
|
1751
|
+
declare function isDocumentMetadata(metadata: MemoryMetadata): metadata is DocumentMetadata;
|
|
1752
|
+
/**
|
|
1753
|
+
* Type guard to check if a memory metadata is a FragmentMetadata
|
|
1754
|
+
* @param metadata The metadata to check
|
|
1755
|
+
* @returns True if the metadata is a FragmentMetadata
|
|
1756
|
+
*/
|
|
1757
|
+
declare function isFragmentMetadata(metadata: MemoryMetadata): metadata is FragmentMetadata;
|
|
1758
|
+
/**
|
|
1759
|
+
* Type guard to check if a memory metadata is a MessageMetadata
|
|
1760
|
+
* @param metadata The metadata to check
|
|
1761
|
+
* @returns True if the metadata is a MessageMetadata
|
|
1762
|
+
*/
|
|
1763
|
+
declare function isMessageMetadata(metadata: MemoryMetadata): metadata is MessageMetadata;
|
|
1764
|
+
/**
|
|
1765
|
+
* Type guard to check if a memory metadata is a DescriptionMetadata
|
|
1766
|
+
* @param metadata The metadata to check
|
|
1767
|
+
* @returns True if the metadata is a DescriptionMetadata
|
|
1768
|
+
*/
|
|
1769
|
+
declare function isDescriptionMetadata(metadata: MemoryMetadata): metadata is DescriptionMetadata;
|
|
1770
|
+
/**
|
|
1771
|
+
* Type guard to check if a memory metadata is a CustomMetadata
|
|
1772
|
+
* @param metadata The metadata to check
|
|
1773
|
+
* @returns True if the metadata is a CustomMetadata
|
|
1774
|
+
*/
|
|
1775
|
+
declare function isCustomMetadata(metadata: MemoryMetadata): metadata is CustomMetadata;
|
|
1776
|
+
/**
|
|
1777
|
+
* Standardized service error type for consistent error handling
|
|
1778
|
+
*/
|
|
1779
|
+
interface ServiceError {
|
|
1780
|
+
code: string;
|
|
1781
|
+
message: string;
|
|
1782
|
+
details?: unknown;
|
|
1783
|
+
cause?: Error;
|
|
1784
|
+
}
|
|
1785
|
+
/**
|
|
1786
|
+
* Memory type guard for document memories
|
|
1787
|
+
*/
|
|
1788
|
+
declare function isDocumentMemory(memory: Memory): memory is Memory & {
|
|
1789
|
+
metadata: DocumentMetadata;
|
|
1790
|
+
};
|
|
1791
|
+
/**
|
|
1792
|
+
* Memory type guard for fragment memories
|
|
1793
|
+
*/
|
|
1794
|
+
declare function isFragmentMemory(memory: Memory): memory is Memory & {
|
|
1795
|
+
metadata: FragmentMetadata;
|
|
1796
|
+
};
|
|
1797
|
+
/**
|
|
1798
|
+
* Safely access the text content of a memory
|
|
1799
|
+
* @param memory The memory to extract text from
|
|
1800
|
+
* @param defaultValue Optional default value if no text is found
|
|
1801
|
+
* @returns The text content or default value
|
|
1802
|
+
*/
|
|
1803
|
+
declare function getMemoryText(memory: Memory, defaultValue?: string): string;
|
|
1804
|
+
/**
|
|
1805
|
+
* Safely create a ServiceError from any caught error
|
|
1806
|
+
*/
|
|
1807
|
+
declare function createServiceError(error: unknown, code?: string): ServiceError;
|
|
1808
|
+
/**
|
|
1809
|
+
* Replace 'any' types with more specific types
|
|
1810
|
+
*/
|
|
1811
|
+
/**
|
|
1812
|
+
* Defines the possible primitive types or structured types for a value within the agent's state.
|
|
1813
|
+
* This type is used to provide more specific typing for properties within `StateObject` and `StateArray`,
|
|
1814
|
+
* moving away from a generic 'any' type for better type safety and clarity in state management.
|
|
1815
|
+
*/
|
|
1816
|
+
type StateValue = string | number | boolean | null | StateObject | StateArray;
|
|
1817
|
+
/**
|
|
1818
|
+
* Represents a generic object structure within the agent's state, where keys are strings
|
|
1819
|
+
* and values can be any `StateValue`. This allows for nested objects within the state.
|
|
1820
|
+
* It's a fundamental part of the `EnhancedState` interface.
|
|
1821
|
+
*/
|
|
1822
|
+
interface StateObject {
|
|
1823
|
+
[key: string]: StateValue;
|
|
1824
|
+
}
|
|
1825
|
+
/**
|
|
1826
|
+
* Represents an array of `StateValue` types within the agent's state.
|
|
1827
|
+
* This allows for lists of mixed or uniform types to be stored in the state,
|
|
1828
|
+
* contributing to the structured definition of `EnhancedState`.
|
|
1829
|
+
*/
|
|
1830
|
+
type StateArray = StateValue[];
|
|
1831
|
+
/**
|
|
1832
|
+
* Enhanced State interface with more specific types for its core properties.
|
|
1833
|
+
* This interface provides a more structured representation of an agent's conversational state,
|
|
1834
|
+
* building upon the base `State` by typing `values` and `data` as `StateObject`.
|
|
1835
|
+
* The `text` property typically holds a textual summary or context derived from the state.
|
|
1836
|
+
* Additional dynamic properties are still allowed via the index signature `[key: string]: StateValue;`.
|
|
1837
|
+
*/
|
|
1838
|
+
interface EnhancedState {
|
|
1839
|
+
/** Holds directly accessible state values, often used for template rendering or quick lookups. */
|
|
1840
|
+
values: StateObject;
|
|
1841
|
+
/** Stores more complex or structured data, potentially namespaced by providers or internal systems. */
|
|
1842
|
+
data: StateObject;
|
|
1843
|
+
/** A textual representation or summary of the current state, often used as context for models. */
|
|
1844
|
+
text: string;
|
|
1845
|
+
/** Allows for additional dynamic properties to be added to the state object. */
|
|
1846
|
+
[key: string]: StateValue;
|
|
1847
|
+
}
|
|
1848
|
+
/**
|
|
1849
|
+
* A generic type for the `data` field within a `Component`.
|
|
1850
|
+
* While `Record<string, unknown>` allows for flexibility, developers are encouraged
|
|
1851
|
+
* to define more specific types for component data where possible to improve type safety
|
|
1852
|
+
* and code maintainability. This type serves as a base for various component implementations.
|
|
1853
|
+
*/
|
|
1854
|
+
type ComponentData = Record<string, unknown>;
|
|
1855
|
+
/**
|
|
1856
|
+
* Represents a generic data object that can be passed as a payload in an event.
|
|
1857
|
+
* This type is often used in `TypedEventHandler` to provide a flexible yet somewhat
|
|
1858
|
+
* structured way to handle event data. Specific event handlers might cast this to a
|
|
1859
|
+
* more concrete type based on the event being processed.
|
|
1860
|
+
*/
|
|
1861
|
+
type EventDataObject = Record<string, unknown>;
|
|
1862
|
+
/**
|
|
1863
|
+
* Defines a more specific type for event handlers, expecting an `EventDataObject`.
|
|
1864
|
+
* This aims to improve upon generic 'any' type handlers, providing a clearer contract
|
|
1865
|
+
* for functions that respond to events emitted within the agent runtime (see `emitEvent` in `AgentRuntime`).
|
|
1866
|
+
* Handlers can be synchronous or asynchronous.
|
|
1867
|
+
*/
|
|
1868
|
+
type TypedEventHandler = (data: EventDataObject) => Promise<void> | void;
|
|
1869
|
+
/**
|
|
1870
|
+
* Represents a generic database connection object.
|
|
1871
|
+
* The actual type of this connection will depend on the specific database adapter implementation
|
|
1872
|
+
* (e.g., a connection pool object for PostgreSQL, a client instance for a NoSQL database).
|
|
1873
|
+
* This `unknown` type serves as a placeholder in the abstract `IDatabaseAdapter`.
|
|
1874
|
+
*/
|
|
1875
|
+
type DbConnection = unknown;
|
|
1876
|
+
/**
|
|
1877
|
+
* A generic type for metadata objects, often used in various parts of the system like
|
|
1878
|
+
* `Relationship` metadata or other extensible data structures.
|
|
1879
|
+
* It allows for arbitrary key-value pairs where values are of `unknown` type,
|
|
1880
|
+
* encouraging consumers to perform type checking or casting.
|
|
1881
|
+
*/
|
|
1882
|
+
type MetadataObject = Record<string, unknown>;
|
|
1883
|
+
/**
|
|
1884
|
+
* Defines the structure for a model handler registration within the `AgentRuntime`.
|
|
1885
|
+
* Each model (e.g., for text generation, embedding) is associated with a handler function,
|
|
1886
|
+
* the name of the provider (plugin or system) that registered it, and an optional priority.
|
|
1887
|
+
* The `priority` (higher is more preferred) helps in selecting which handler to use if multiple
|
|
1888
|
+
* handlers are registered for the same model type. The `registrationOrder` (not in type, but used in runtime)
|
|
1889
|
+
* serves as a tie-breaker. See `AgentRuntime.registerModel` and `AgentRuntime.getModel`.
|
|
1890
|
+
*/
|
|
1891
|
+
interface ModelHandler {
|
|
1892
|
+
/** The function that executes the model, taking runtime and parameters, and returning a Promise. */
|
|
1893
|
+
handler: (runtime: IAgentRuntime, params: Record<string, unknown>) => Promise<unknown>;
|
|
1894
|
+
/** The name of the provider (e.g., plugin name) that registered this model handler. */
|
|
1895
|
+
provider: string;
|
|
1896
|
+
/**
|
|
1897
|
+
* Optional priority for this model handler. Higher numbers indicate higher priority.
|
|
1898
|
+
* This is used by `AgentRuntime.getModel` to select the most appropriate handler
|
|
1899
|
+
* when multiple are available for a given model type. Defaults to 0 if not specified.
|
|
1900
|
+
*/
|
|
1901
|
+
priority?: number;
|
|
1902
|
+
registrationOrder?: number;
|
|
1903
|
+
}
|
|
1904
|
+
/**
|
|
1905
|
+
* A generic type for service configurations.
|
|
1906
|
+
* Services (like `IVideoService`, `IBrowserService`) can have their own specific configuration
|
|
1907
|
+
* structures. This type allows for a flexible way to pass configuration objects,
|
|
1908
|
+
* typically used during service initialization within a plugin or the `AgentRuntime`.
|
|
1909
|
+
*/
|
|
1910
|
+
type ServiceConfig = Record<string, unknown>;
|
|
1911
|
+
declare const VECTOR_DIMS: {
|
|
1912
|
+
readonly SMALL: 384;
|
|
1913
|
+
readonly MEDIUM: 512;
|
|
1914
|
+
readonly LARGE: 768;
|
|
1915
|
+
readonly XL: 1024;
|
|
1916
|
+
readonly XXL: 1536;
|
|
1917
|
+
readonly XXXL: 3072;
|
|
1918
|
+
};
|
|
1919
|
+
/**
|
|
1920
|
+
* Interface for control messages sent from the backend to the frontend
|
|
1921
|
+
* to manage UI state and interaction capabilities
|
|
1922
|
+
*/
|
|
1923
|
+
interface ControlMessage {
|
|
1924
|
+
/** Message type identifier */
|
|
1925
|
+
type: 'control';
|
|
1926
|
+
/** Control message payload */
|
|
1927
|
+
payload: {
|
|
1928
|
+
/** Action to perform */
|
|
1929
|
+
action: 'disable_input' | 'enable_input';
|
|
1930
|
+
/** Optional target element identifier */
|
|
1931
|
+
target?: string;
|
|
1932
|
+
/** Additional optional parameters */
|
|
1933
|
+
[key: string]: unknown;
|
|
1934
|
+
};
|
|
1935
|
+
/** Room ID to ensure signal is directed to the correct chat window */
|
|
1936
|
+
roomId: UUID;
|
|
1937
|
+
}
|
|
1938
|
+
|
|
1939
|
+
/**
|
|
1940
|
+
* Service builder class that provides type-safe service creation
|
|
1941
|
+
* with automatic type inference
|
|
1942
|
+
*/
|
|
1943
|
+
declare class ServiceBuilder$1<TService extends Service = Service> {
|
|
1944
|
+
protected serviceType: ServiceTypeName | string;
|
|
1945
|
+
protected startFn: (runtime: IAgentRuntime) => Promise<TService>;
|
|
1946
|
+
protected stopFn?: () => Promise<void>;
|
|
1947
|
+
protected description: string;
|
|
1948
|
+
constructor(serviceType: ServiceTypeName | string);
|
|
1949
|
+
/**
|
|
1950
|
+
* Set the service description
|
|
1951
|
+
*/
|
|
1952
|
+
withDescription(description: string): this;
|
|
1953
|
+
/**
|
|
1954
|
+
* Set the start function for the service
|
|
1955
|
+
*/
|
|
1956
|
+
withStart(startFn: (runtime: IAgentRuntime) => Promise<TService>): this;
|
|
1957
|
+
/**
|
|
1958
|
+
* Set the stop function for the service
|
|
1959
|
+
*/
|
|
1960
|
+
withStop(stopFn: () => Promise<void>): this;
|
|
1961
|
+
/**
|
|
1962
|
+
* Build the service class with all configured properties
|
|
1963
|
+
*/
|
|
1964
|
+
build(): new (runtime?: IAgentRuntime) => TService;
|
|
1965
|
+
}
|
|
1966
|
+
/**
|
|
1967
|
+
* Create a type-safe service builder
|
|
1968
|
+
* @param serviceType - The service type name
|
|
1969
|
+
* @returns A new ServiceBuilder instance
|
|
1970
|
+
*/
|
|
1971
|
+
declare function createService$1<TService extends Service = Service>(serviceType: ServiceTypeName | string): ServiceBuilder$1<TService>;
|
|
1972
|
+
/**
|
|
1973
|
+
* Type-safe service definition helper
|
|
1974
|
+
*/
|
|
1975
|
+
interface ServiceDefinition$1<T extends Service = Service> {
|
|
1976
|
+
serviceType: ServiceTypeName;
|
|
1977
|
+
description: string;
|
|
1978
|
+
start: (runtime: IAgentRuntime) => Promise<T>;
|
|
1979
|
+
stop?: () => Promise<void>;
|
|
1980
|
+
}
|
|
1981
|
+
/**
|
|
1982
|
+
* Define a service with type safety
|
|
1983
|
+
*/
|
|
1984
|
+
declare function defineService$1<T extends Service = Service>(definition: ServiceDefinition$1<T>): new (runtime?: IAgentRuntime) => T;
|
|
1985
|
+
|
|
1986
|
+
/**
|
|
1987
|
+
* Compose a specified number of random action examples from the given actionsData.
|
|
1988
|
+
*
|
|
1989
|
+
* @param {Action[]} actionsData - The list of actions to generate examples from.
|
|
1990
|
+
* @param {number} count - The number of examples to compose.
|
|
1991
|
+
* @returns {string} The formatted action examples.
|
|
1992
|
+
*/
|
|
1993
|
+
declare const composeActionExamples: (actionsData: Action$1[], count: number) => string;
|
|
1994
|
+
/**
|
|
1995
|
+
* Formats the names of the provided actions into a comma-separated string.
|
|
1996
|
+
* @param actions - An array of `Action` objects from which to extract names.
|
|
1997
|
+
* @returns A comma-separated string of action names.
|
|
1998
|
+
*/
|
|
1999
|
+
declare function formatActionNames(actions: Action$1[]): string;
|
|
2000
|
+
/**
|
|
2001
|
+
* Formats the provided actions into a detailed string listing each action's name and description, separated by commas and newlines.
|
|
2002
|
+
* @param actions - An array of `Action` objects to format.
|
|
2003
|
+
* @returns A detailed string of actions, including names and descriptions.
|
|
2004
|
+
*/
|
|
2005
|
+
declare function formatActions(actions: Action$1[]): string;
|
|
2006
|
+
|
|
2007
|
+
/**
|
|
2008
|
+
* Database adapter class to be extended by individual database adapters.
|
|
2009
|
+
*
|
|
2010
|
+
* @template DB - The type of the database instance.
|
|
2011
|
+
* @abstract
|
|
2012
|
+
* @implements {IDatabaseAdapter}
|
|
2013
|
+
*/
|
|
2014
|
+
declare abstract class DatabaseAdapter<DB = unknown> implements IDatabaseAdapter$1 {
|
|
2015
|
+
/**
|
|
2016
|
+
* The database instance.
|
|
2017
|
+
*/
|
|
2018
|
+
db: DB;
|
|
2019
|
+
/**
|
|
2020
|
+
* Creates a new DatabaseAdapter instance.
|
|
2021
|
+
* @param db The database instance to use.
|
|
2022
|
+
*/
|
|
2023
|
+
constructor(db: DB);
|
|
2024
|
+
/**
|
|
2025
|
+
* Initialize the database adapter.
|
|
2026
|
+
* @returns A Promise that resolves when initialization is complete.
|
|
2027
|
+
*/
|
|
2028
|
+
abstract init(): Promise<void>;
|
|
2029
|
+
/**
|
|
2030
|
+
* Optional close method for the database adapter.
|
|
2031
|
+
* @returns A Promise that resolves when closing is complete.
|
|
2032
|
+
*/
|
|
2033
|
+
abstract close(): Promise<void>;
|
|
2034
|
+
/**
|
|
2035
|
+
* Retrieves a connection to the database.
|
|
2036
|
+
* @returns A Promise that resolves to the database connection.
|
|
2037
|
+
*/
|
|
2038
|
+
abstract getConnection(): Promise<PGlite | Pool>;
|
|
2039
|
+
/**
|
|
2040
|
+
* Retrieves an account by its ID.
|
|
2041
|
+
* @param entityIds The UUIDs of the user account to retrieve.
|
|
2042
|
+
* @returns A Promise that resolves to the Entity object or null if not found.
|
|
2043
|
+
*/
|
|
2044
|
+
abstract getEntityByIds(entityIds: UUID$1[]): Promise<Entity$1[] | null>;
|
|
2045
|
+
abstract getEntitiesForRoom(roomId: UUID$1, includeComponents?: boolean): Promise<Entity$1[]>;
|
|
2046
|
+
/**
|
|
2047
|
+
* Creates a new entities in the database.
|
|
2048
|
+
* @param entities The entity objects to create.
|
|
2049
|
+
* @returns A Promise that resolves when the account creation is complete.
|
|
2050
|
+
*/
|
|
2051
|
+
abstract createEntities(entities: Entity$1[]): Promise<boolean>;
|
|
2052
|
+
/**
|
|
2053
|
+
* Updates an existing entity in the database.
|
|
2054
|
+
* @param entity The entity object with updated properties.
|
|
2055
|
+
* @returns A Promise that resolves when the account update is complete.
|
|
2056
|
+
*/
|
|
2057
|
+
abstract updateEntity(entity: Entity$1): Promise<void>;
|
|
2058
|
+
/**
|
|
2059
|
+
* Retrieves a single component by entity ID and type.
|
|
2060
|
+
* @param entityId The UUID of the entity the component belongs to
|
|
2061
|
+
* @param type The type identifier for the component
|
|
2062
|
+
* @param worldId Optional UUID of the world the component belongs to
|
|
2063
|
+
* @param sourceEntityId Optional UUID of the source entity
|
|
2064
|
+
* @returns Promise resolving to the Component if found, null otherwise
|
|
2065
|
+
*/
|
|
2066
|
+
abstract getComponent(entityId: UUID$1, type: string, worldId?: UUID$1, sourceEntityId?: UUID$1): Promise<Component$1 | null>;
|
|
2067
|
+
/**
|
|
2068
|
+
* Retrieves all components for an entity.
|
|
2069
|
+
* @param entityId The UUID of the entity to get components for
|
|
2070
|
+
* @param worldId Optional UUID of the world to filter components by
|
|
2071
|
+
* @param sourceEntityId Optional UUID of the source entity to filter by
|
|
2072
|
+
* @returns Promise resolving to array of Component objects
|
|
2073
|
+
*/
|
|
2074
|
+
abstract getComponents(entityId: UUID$1, worldId?: UUID$1, sourceEntityId?: UUID$1): Promise<Component$1[]>;
|
|
2075
|
+
/**
|
|
2076
|
+
* Creates a new component in the database.
|
|
2077
|
+
* @param component The component object to create
|
|
2078
|
+
* @returns Promise resolving to true if creation was successful
|
|
2079
|
+
*/
|
|
2080
|
+
abstract createComponent(component: Component$1): Promise<boolean>;
|
|
2081
|
+
/**
|
|
2082
|
+
* Updates an existing component in the database.
|
|
2083
|
+
* @param component The component object with updated properties
|
|
2084
|
+
* @returns Promise that resolves when the update is complete
|
|
2085
|
+
*/
|
|
2086
|
+
abstract updateComponent(component: Component$1): Promise<void>;
|
|
2087
|
+
/**
|
|
2088
|
+
* Deletes a component from the database.
|
|
2089
|
+
* @param componentId The UUID of the component to delete
|
|
2090
|
+
* @returns Promise that resolves when the deletion is complete
|
|
2091
|
+
*/
|
|
2092
|
+
abstract deleteComponent(componentId: UUID$1): Promise<void>;
|
|
2093
|
+
/**
|
|
2094
|
+
* Retrieves memories based on the specified parameters.
|
|
2095
|
+
* @param params An object containing parameters for the memory retrieval.
|
|
2096
|
+
* @returns A Promise that resolves to an array of Memory objects.
|
|
2097
|
+
*/
|
|
2098
|
+
abstract getMemories(params: {
|
|
2099
|
+
entityId?: UUID$1;
|
|
2100
|
+
agentId?: UUID$1;
|
|
2101
|
+
roomId?: UUID$1;
|
|
2102
|
+
count?: number;
|
|
2103
|
+
unique?: boolean;
|
|
2104
|
+
tableName: string;
|
|
2105
|
+
start?: number;
|
|
2106
|
+
end?: number;
|
|
2107
|
+
}): Promise<Memory$1[]>;
|
|
2108
|
+
abstract getMemoriesByRoomIds(params: {
|
|
2109
|
+
roomIds: UUID$1[];
|
|
2110
|
+
tableName: string;
|
|
2111
|
+
limit?: number;
|
|
2112
|
+
}): Promise<Memory$1[]>;
|
|
2113
|
+
abstract getMemoryById(id: UUID$1): Promise<Memory$1 | null>;
|
|
2114
|
+
/**
|
|
2115
|
+
* Retrieves multiple memories by their IDs
|
|
2116
|
+
* @param memoryIds Array of UUIDs of the memories to retrieve
|
|
2117
|
+
* @param tableName Optional table name to filter memories by type
|
|
2118
|
+
* @returns Promise resolving to array of Memory objects
|
|
2119
|
+
*/
|
|
2120
|
+
abstract getMemoriesByIds(memoryIds: UUID$1[], tableName?: string): Promise<Memory$1[]>;
|
|
2121
|
+
/**
|
|
2122
|
+
* Retrieves cached embeddings based on the specified query parameters.
|
|
2123
|
+
* @param params An object containing parameters for the embedding retrieval.
|
|
2124
|
+
* @returns A Promise that resolves to an array of objects containing embeddings and levenshtein scores.
|
|
2125
|
+
*/
|
|
2126
|
+
abstract getCachedEmbeddings({ query_table_name, query_threshold, query_input, query_field_name, query_field_sub_name, query_match_count, }: {
|
|
2127
|
+
query_table_name: string;
|
|
2128
|
+
query_threshold: number;
|
|
2129
|
+
query_input: string;
|
|
2130
|
+
query_field_name: string;
|
|
2131
|
+
query_field_sub_name: string;
|
|
2132
|
+
query_match_count: number;
|
|
2133
|
+
}): Promise<{
|
|
2134
|
+
embedding: number[];
|
|
2135
|
+
levenshtein_score: number;
|
|
2136
|
+
}[]>;
|
|
2137
|
+
/**
|
|
2138
|
+
* Logs an event or action with the specified details.
|
|
2139
|
+
* @param params An object containing parameters for the log entry.
|
|
2140
|
+
* @returns A Promise that resolves when the log entry has been saved.
|
|
2141
|
+
*/
|
|
2142
|
+
abstract log(params: {
|
|
2143
|
+
body: {
|
|
2144
|
+
[key: string]: unknown;
|
|
2145
|
+
};
|
|
2146
|
+
entityId: UUID$1;
|
|
2147
|
+
roomId: UUID$1;
|
|
2148
|
+
type: string;
|
|
2149
|
+
}): Promise<void>;
|
|
2150
|
+
/**
|
|
2151
|
+
* Retrieves logs based on the specified parameters.
|
|
2152
|
+
* @param params An object containing parameters for the log retrieval.
|
|
2153
|
+
* @returns A Promise that resolves to an array of Log objects.
|
|
2154
|
+
*/
|
|
2155
|
+
abstract getLogs(params: {
|
|
2156
|
+
entityId: UUID$1;
|
|
2157
|
+
roomId?: UUID$1;
|
|
2158
|
+
type?: string;
|
|
2159
|
+
count?: number;
|
|
2160
|
+
offset?: number;
|
|
2161
|
+
}): Promise<Log$1[]>;
|
|
2162
|
+
/**
|
|
2163
|
+
* Deletes a log from the database.
|
|
2164
|
+
* @param logId The UUID of the log to delete.
|
|
2165
|
+
* @returns A Promise that resolves when the log has been deleted.
|
|
2166
|
+
*/
|
|
2167
|
+
abstract deleteLog(logId: UUID$1): Promise<void>;
|
|
2168
|
+
/**
|
|
2169
|
+
* Searches for memories based on embeddings and other specified parameters.
|
|
2170
|
+
* @param params An object containing parameters for the memory search.
|
|
2171
|
+
* @returns A Promise that resolves to an array of Memory objects.
|
|
2172
|
+
*/
|
|
2173
|
+
abstract searchMemories(params: {
|
|
2174
|
+
tableName: string;
|
|
2175
|
+
roomId: UUID$1;
|
|
2176
|
+
embedding: number[];
|
|
2177
|
+
match_threshold: number;
|
|
2178
|
+
count: number;
|
|
2179
|
+
unique: boolean;
|
|
2180
|
+
}): Promise<Memory$1[]>;
|
|
2181
|
+
/**
|
|
2182
|
+
* Creates a new memory in the database.
|
|
2183
|
+
* @param memory The memory object to create.
|
|
2184
|
+
* @param tableName The table where the memory should be stored.
|
|
2185
|
+
* @param unique Indicates if the memory should be unique.
|
|
2186
|
+
* @returns A Promise that resolves when the memory has been created.
|
|
2187
|
+
*/
|
|
2188
|
+
abstract createMemory(memory: Memory$1, tableName: string, unique?: boolean): Promise<UUID$1>;
|
|
2189
|
+
/**
|
|
2190
|
+
* Updates an existing memory in the database.
|
|
2191
|
+
* @param memory The memory object with updated content and optional embedding
|
|
2192
|
+
* @returns Promise resolving to boolean indicating success
|
|
2193
|
+
*/
|
|
2194
|
+
abstract updateMemory(memory: Partial<Memory$1> & {
|
|
2195
|
+
id: UUID$1;
|
|
2196
|
+
metadata?: MemoryMetadata$1;
|
|
2197
|
+
}): Promise<boolean>;
|
|
2198
|
+
/**
|
|
2199
|
+
* Removes a specific memory from the database.
|
|
2200
|
+
* @param memoryId The UUID of the memory to remove.
|
|
2201
|
+
* @returns A Promise that resolves when the memory has been removed.
|
|
2202
|
+
*/
|
|
2203
|
+
abstract deleteMemory(memoryId: UUID$1): Promise<void>;
|
|
2204
|
+
/**
|
|
2205
|
+
* Removes all memories associated with a specific room.
|
|
2206
|
+
* @param roomId The UUID of the room whose memories should be removed.
|
|
2207
|
+
* @param tableName The table from which the memories should be removed.
|
|
2208
|
+
* @returns A Promise that resolves when all memories have been removed.
|
|
2209
|
+
*/
|
|
2210
|
+
abstract deleteAllMemories(roomId: UUID$1, tableName: string): Promise<void>;
|
|
2211
|
+
/**
|
|
2212
|
+
* Counts the number of memories in a specific room.
|
|
2213
|
+
* @param roomId The UUID of the room for which to count memories.
|
|
2214
|
+
* @param unique Specifies whether to count only unique memories.
|
|
2215
|
+
* @param tableName Optional table name to count memories from.
|
|
2216
|
+
* @returns A Promise that resolves to the number of memories.
|
|
2217
|
+
*/
|
|
2218
|
+
abstract countMemories(roomId: UUID$1, unique?: boolean, tableName?: string): Promise<number>;
|
|
2219
|
+
/**
|
|
2220
|
+
* Retrieves a world by its ID.
|
|
2221
|
+
* @param id The UUID of the world to retrieve.
|
|
2222
|
+
* @returns A Promise that resolves to the World object or null if not found.
|
|
2223
|
+
*/
|
|
2224
|
+
abstract getWorld(id: UUID$1): Promise<World$1 | null>;
|
|
2225
|
+
/**
|
|
2226
|
+
* Retrieves all worlds for an agent.
|
|
2227
|
+
* @returns A Promise that resolves to an array of World objects.
|
|
2228
|
+
*/
|
|
2229
|
+
abstract getAllWorlds(): Promise<World$1[]>;
|
|
2230
|
+
/**
|
|
2231
|
+
* Creates a new world in the database.
|
|
2232
|
+
* @param world The world object to create.
|
|
2233
|
+
* @returns A Promise that resolves to the UUID of the created world.
|
|
2234
|
+
*/
|
|
2235
|
+
abstract createWorld(world: World$1): Promise<UUID$1>;
|
|
2236
|
+
/**
|
|
2237
|
+
* Updates an existing world in the database.
|
|
2238
|
+
* @param world The world object with updated properties.
|
|
2239
|
+
* @returns A Promise that resolves when the world has been updated.
|
|
2240
|
+
*/
|
|
2241
|
+
abstract updateWorld(world: World$1): Promise<void>;
|
|
2242
|
+
/**
|
|
2243
|
+
* Removes a specific world from the database.
|
|
2244
|
+
* @param id The UUID of the world to remove.
|
|
2245
|
+
* @returns A Promise that resolves when the world has been removed.
|
|
2246
|
+
*/
|
|
2247
|
+
abstract removeWorld(id: UUID$1): Promise<void>;
|
|
2248
|
+
/**
|
|
2249
|
+
* Retrieves the room ID for a given room, if it exists.
|
|
2250
|
+
* @param roomId The UUID of the room to retrieve.
|
|
2251
|
+
* @returns A Promise that resolves to the room ID or null if not found.
|
|
2252
|
+
*/
|
|
2253
|
+
abstract getRoomsByIds(roomIds: UUID$1[]): Promise<Room$1[] | null>;
|
|
2254
|
+
/**
|
|
2255
|
+
* Retrieves all rooms for a given world.
|
|
2256
|
+
* @param worldId The UUID of the world to retrieve rooms for.
|
|
2257
|
+
* @returns A Promise that resolves to an array of Room objects.
|
|
2258
|
+
*/
|
|
2259
|
+
abstract getRoomsByWorld(worldId: UUID$1): Promise<Room$1[]>;
|
|
2260
|
+
/**
|
|
2261
|
+
* Creates a new rooms with an optional specified ID.
|
|
2262
|
+
* @param roomId Optional UUID to assign to the new room.
|
|
2263
|
+
* @returns A Promise that resolves to the UUID of the created rooms.
|
|
2264
|
+
*/
|
|
2265
|
+
abstract createRooms(rooms: Room$1[]): Promise<UUID$1[]>;
|
|
2266
|
+
/**
|
|
2267
|
+
* Updates a specific room in the database.
|
|
2268
|
+
* @param room The room object with updated properties.
|
|
2269
|
+
* @returns A Promise that resolves when the room has been updated.
|
|
2270
|
+
*/
|
|
2271
|
+
abstract updateRoom(room: Room$1): Promise<void>;
|
|
2272
|
+
/**
|
|
2273
|
+
* Removes a specific room from the database.
|
|
2274
|
+
* @param roomId The UUID of the room to remove.
|
|
2275
|
+
* @returns A Promise that resolves when the room has been removed.
|
|
2276
|
+
*/
|
|
2277
|
+
abstract deleteRoom(roomId: UUID$1): Promise<void>;
|
|
2278
|
+
/**
|
|
2279
|
+
* Retrieves room IDs for which a specific user is a participant.
|
|
2280
|
+
* @param entityId The UUID of the user.
|
|
2281
|
+
* @returns A Promise that resolves to an array of room IDs.
|
|
2282
|
+
*/
|
|
2283
|
+
abstract getRoomsForParticipant(entityId: UUID$1): Promise<UUID$1[]>;
|
|
2284
|
+
/**
|
|
2285
|
+
* Retrieves room IDs for which specific users are participants.
|
|
2286
|
+
* @param userIds An array of UUIDs of the users.
|
|
2287
|
+
* @returns A Promise that resolves to an array of room IDs.
|
|
2288
|
+
*/
|
|
2289
|
+
abstract getRoomsForParticipants(userIds: UUID$1[]): Promise<UUID$1[]>;
|
|
2290
|
+
/**
|
|
2291
|
+
* Adds users as a participant to a specific room.
|
|
2292
|
+
* @param entityIds The UUIDs of the users to add as a participant.
|
|
2293
|
+
* @param roomId The UUID of the room to which the user will be added.
|
|
2294
|
+
* @returns A Promise that resolves to a boolean indicating success or failure.
|
|
2295
|
+
*/
|
|
2296
|
+
abstract addParticipantsRoom(entityIds: UUID$1[], roomId: UUID$1): Promise<boolean>;
|
|
2297
|
+
/**
|
|
2298
|
+
* Removes a user as a participant from a specific room.
|
|
2299
|
+
* @param entityId The UUID of the user to remove as a participant.
|
|
2300
|
+
* @param roomId The UUID of the room from which the user will be removed.
|
|
2301
|
+
* @returns A Promise that resolves to a boolean indicating success or failure.
|
|
2302
|
+
*/
|
|
2303
|
+
abstract removeParticipant(entityId: UUID$1, roomId: UUID$1): Promise<boolean>;
|
|
2304
|
+
/**
|
|
2305
|
+
* Retrieves participants associated with a specific account.
|
|
2306
|
+
* @param entityId The UUID of the account.
|
|
2307
|
+
* @returns A Promise that resolves to an array of Participant objects.
|
|
2308
|
+
*/
|
|
2309
|
+
abstract getParticipantsForEntity(entityId: UUID$1): Promise<Participant$1[]>;
|
|
2310
|
+
/**
|
|
2311
|
+
* Retrieves participants for a specific room.
|
|
2312
|
+
* @param roomId The UUID of the room for which to retrieve participants.
|
|
2313
|
+
* @returns A Promise that resolves to an array of UUIDs representing the participants.
|
|
2314
|
+
*/
|
|
2315
|
+
abstract getParticipantsForRoom(roomId: UUID$1): Promise<UUID$1[]>;
|
|
2316
|
+
abstract getParticipantUserState(roomId: UUID$1, entityId: UUID$1): Promise<'FOLLOWED' | 'MUTED' | null>;
|
|
2317
|
+
abstract setParticipantUserState(roomId: UUID$1, entityId: UUID$1, state: 'FOLLOWED' | 'MUTED' | null): Promise<void>;
|
|
2318
|
+
/**
|
|
2319
|
+
* Creates a new relationship between two users.
|
|
2320
|
+
* @param params Object containing the relationship details including entity IDs, agent ID, optional tags and metadata
|
|
2321
|
+
* @returns A Promise that resolves to a boolean indicating success or failure of the creation.
|
|
2322
|
+
*/
|
|
2323
|
+
abstract createRelationship(params: {
|
|
2324
|
+
sourceEntityId: UUID$1;
|
|
2325
|
+
targetEntityId: UUID$1;
|
|
2326
|
+
tags?: string[];
|
|
2327
|
+
metadata?: Record<string, unknown>;
|
|
2328
|
+
}): Promise<boolean>;
|
|
2329
|
+
/**
|
|
2330
|
+
* Retrieves a relationship between two users if it exists.
|
|
2331
|
+
* @param params Object containing the entity IDs and agent ID
|
|
2332
|
+
* @returns A Promise that resolves to the Relationship object or null if not found.
|
|
2333
|
+
*/
|
|
2334
|
+
abstract getRelationship(params: {
|
|
2335
|
+
sourceEntityId: UUID$1;
|
|
2336
|
+
targetEntityId: UUID$1;
|
|
2337
|
+
}): Promise<Relationship$1 | null>;
|
|
2338
|
+
/**
|
|
2339
|
+
* Retrieves all relationships for a specific user.
|
|
2340
|
+
* @param params Object containing the user ID, agent ID and optional tags to filter by
|
|
2341
|
+
* @returns A Promise that resolves to an array of Relationship objects.
|
|
2342
|
+
*/
|
|
2343
|
+
abstract getRelationships(params: {
|
|
2344
|
+
entityId: UUID$1;
|
|
2345
|
+
tags?: string[];
|
|
2346
|
+
}): Promise<Relationship$1[]>;
|
|
2347
|
+
/**
|
|
2348
|
+
* Updates an existing relationship between two users.
|
|
2349
|
+
* @param params Object containing the relationship details to update including entity IDs, agent ID, optional tags and metadata
|
|
2350
|
+
* @returns A Promise that resolves to a boolean indicating success or failure of the update.
|
|
2351
|
+
*/
|
|
2352
|
+
abstract updateRelationship(params: {
|
|
2353
|
+
sourceEntityId: UUID$1;
|
|
2354
|
+
targetEntityId: UUID$1;
|
|
2355
|
+
tags?: string[];
|
|
2356
|
+
metadata?: Record<string, unknown>;
|
|
2357
|
+
}): Promise<void>;
|
|
2358
|
+
/**
|
|
2359
|
+
* Retrieves an agent by its ID.
|
|
2360
|
+
* @param agentId The UUID of the agent to retrieve.
|
|
2361
|
+
* @returns A Promise that resolves to the Agent object or null if not found.
|
|
2362
|
+
*/
|
|
2363
|
+
abstract getAgent(agentId: UUID$1): Promise<Agent$1 | null>;
|
|
2364
|
+
/**
|
|
2365
|
+
* Retrieves all agents from the database.
|
|
2366
|
+
* @returns A Promise that resolves to an array of Agent objects.
|
|
2367
|
+
*/
|
|
2368
|
+
abstract getAgents(): Promise<Agent$1[]>;
|
|
2369
|
+
/**
|
|
2370
|
+
* Creates a new agent in the database.
|
|
2371
|
+
* @param agent The agent object to create.
|
|
2372
|
+
* @returns A Promise that resolves to a boolean indicating success or failure of the creation.
|
|
2373
|
+
*/
|
|
2374
|
+
abstract createAgent(agent: Partial<Agent$1>): Promise<boolean>;
|
|
2375
|
+
/**
|
|
2376
|
+
* Updates an existing agent in the database.
|
|
2377
|
+
* @param agentId The UUID of the agent to update.
|
|
2378
|
+
* @param agent The agent object with updated properties.
|
|
2379
|
+
* @returns A Promise that resolves to a boolean indicating success or failure of the update.
|
|
2380
|
+
*/
|
|
2381
|
+
abstract updateAgent(agentId: UUID$1, agent: Partial<Agent$1>): Promise<boolean>;
|
|
2382
|
+
/**
|
|
2383
|
+
* Deletes an agent from the database.
|
|
2384
|
+
* @param agentId The UUID of the agent to delete.
|
|
2385
|
+
* @returns A Promise that resolves to a boolean indicating success or failure of the deletion.
|
|
2386
|
+
*/
|
|
2387
|
+
abstract deleteAgent(agentId: UUID$1): Promise<boolean>;
|
|
2388
|
+
/**
|
|
2389
|
+
* Ensures an agent exists in the database.
|
|
2390
|
+
* @param agent The agent object to ensure exists.
|
|
2391
|
+
* @returns A Promise that resolves when the agent has been ensured to exist.
|
|
2392
|
+
*/
|
|
2393
|
+
abstract ensureAgentExists(agent: Partial<Agent$1>): Promise<Agent$1>;
|
|
2394
|
+
/**
|
|
2395
|
+
* Ensures an embedding dimension exists in the database.
|
|
2396
|
+
* @param dimension The dimension to ensure exists.
|
|
2397
|
+
* @returns A Promise that resolves when the embedding dimension has been ensured to exist.
|
|
2398
|
+
*/
|
|
2399
|
+
abstract ensureEmbeddingDimension(dimension: number): Promise<void>;
|
|
2400
|
+
/**
|
|
2401
|
+
* Retrieves a cached value by key from the database.
|
|
2402
|
+
* @param key The key to look up in the cache
|
|
2403
|
+
* @returns Promise resolving to the cached string value
|
|
2404
|
+
*/
|
|
2405
|
+
abstract getCache<T>(key: string): Promise<T | undefined>;
|
|
2406
|
+
/**
|
|
2407
|
+
* Sets a value in the cache with the given key.
|
|
2408
|
+
* @param params Object containing the cache key and value
|
|
2409
|
+
* @param key The key to store the value under
|
|
2410
|
+
* @param value The string value to cache
|
|
2411
|
+
* @returns Promise resolving to true if the cache was set successfully
|
|
2412
|
+
*/
|
|
2413
|
+
abstract setCache<T>(key: string, value: T): Promise<boolean>;
|
|
2414
|
+
/**
|
|
2415
|
+
* Deletes a value from the cache by key.
|
|
2416
|
+
* @param key The key to delete from the cache
|
|
2417
|
+
* @returns Promise resolving to true if the value was successfully deleted
|
|
2418
|
+
*/
|
|
2419
|
+
abstract deleteCache(key: string): Promise<boolean>;
|
|
2420
|
+
/**
|
|
2421
|
+
* Creates a new task instance in the database.
|
|
2422
|
+
* @param task The task object to create
|
|
2423
|
+
* @returns Promise resolving to the UUID of the created task
|
|
2424
|
+
*/
|
|
2425
|
+
abstract createTask(task: Task$1): Promise<UUID$1>;
|
|
2426
|
+
/**
|
|
2427
|
+
* Retrieves tasks based on specified parameters.
|
|
2428
|
+
* @param params Object containing optional roomId and tags to filter tasks
|
|
2429
|
+
* @returns Promise resolving to an array of Task objects
|
|
2430
|
+
*/
|
|
2431
|
+
abstract getTasks(params: {
|
|
2432
|
+
roomId?: UUID$1;
|
|
2433
|
+
tags?: string[];
|
|
2434
|
+
}): Promise<Task$1[]>;
|
|
2435
|
+
/**
|
|
2436
|
+
* Retrieves a specific task by its ID.
|
|
2437
|
+
* @param id The UUID of the task to retrieve
|
|
2438
|
+
* @returns Promise resolving to the Task object if found, null otherwise
|
|
2439
|
+
*/
|
|
2440
|
+
abstract getTask(id: UUID$1): Promise<Task$1 | null>;
|
|
2441
|
+
/**
|
|
2442
|
+
* Retrieves a specific task by its name.
|
|
2443
|
+
* @param name The name of the task to retrieve
|
|
2444
|
+
* @returns Promise resolving to the Task object if found, null otherwise
|
|
2445
|
+
*/
|
|
2446
|
+
abstract getTasksByName(name: string): Promise<Task$1[]>;
|
|
2447
|
+
/**
|
|
2448
|
+
* Updates an existing task in the database.
|
|
2449
|
+
* @param id The UUID of the task to update
|
|
2450
|
+
* @param task Partial Task object containing the fields to update
|
|
2451
|
+
* @returns Promise resolving when the update is complete
|
|
2452
|
+
*/
|
|
2453
|
+
abstract updateTask(id: UUID$1, task: Partial<Task$1>): Promise<void>;
|
|
2454
|
+
/**
|
|
2455
|
+
* Deletes a task from the database.
|
|
2456
|
+
* @param id The UUID of the task to delete
|
|
2457
|
+
* @returns Promise resolving when the deletion is complete
|
|
2458
|
+
*/
|
|
2459
|
+
abstract deleteTask(id: UUID$1): Promise<void>;
|
|
2460
|
+
abstract getMemoriesByWorldId(params: {
|
|
2461
|
+
worldId: UUID$1;
|
|
2462
|
+
count?: number;
|
|
2463
|
+
tableName?: string;
|
|
2464
|
+
}): Promise<Memory$1[]>;
|
|
2465
|
+
abstract deleteRoomsByWorldId(worldId: UUID$1): Promise<void>;
|
|
2466
|
+
}
|
|
2467
|
+
|
|
2468
|
+
/**
|
|
2469
|
+
* Finds an entity by name in the given runtime environment.
|
|
2470
|
+
*
|
|
2471
|
+
* @param {IAgentRuntime} runtime - The agent runtime environment.
|
|
2472
|
+
* @param {Memory} message - The memory message containing relevant information.
|
|
2473
|
+
* @param {State} state - The current state of the system.
|
|
2474
|
+
* @returns {Promise<Entity | null>} A promise that resolves to the found entity or null if not found.
|
|
2475
|
+
*/
|
|
2476
|
+
declare function findEntityByName(runtime: IAgentRuntime$1, message: Memory$1, state: State): Promise<Entity$1 | null>;
|
|
2477
|
+
/**
|
|
2478
|
+
* Function to create a unique UUID based on the runtime and base user ID.
|
|
2479
|
+
*
|
|
2480
|
+
* @param {RuntimeContext} runtime - The runtime context object.
|
|
2481
|
+
* @param {UUID|string} baseUserId - The base user ID to use in generating the UUID.
|
|
2482
|
+
* @returns {UUID} - The unique UUID generated based on the runtime and base user ID.
|
|
2483
|
+
*/
|
|
2484
|
+
declare const createUniqueUuid: (runtime: IAgentRuntime$1, baseUserId: UUID | string) => UUID;
|
|
2485
|
+
/**
|
|
2486
|
+
* Retrieves entity details for a specific room from the database.
|
|
2487
|
+
*
|
|
2488
|
+
* @param {Object} params - The input parameters
|
|
2489
|
+
* @param {IAgentRuntime} params.runtime - The Agent Runtime instance
|
|
2490
|
+
* @param {UUID} params.roomId - The ID of the room to retrieve entity details for
|
|
2491
|
+
* @returns {Promise<Array>} - A promise that resolves to an array of unique entity details
|
|
2492
|
+
*/
|
|
2493
|
+
declare function getEntityDetails({ runtime, roomId, }: {
|
|
2494
|
+
runtime: IAgentRuntime$1;
|
|
2495
|
+
roomId: UUID;
|
|
2496
|
+
}): Promise<any[]>;
|
|
2497
|
+
/**
|
|
2498
|
+
* Format the given entities into a string representation.
|
|
2499
|
+
*
|
|
2500
|
+
* @param {Object} options - The options object.
|
|
2501
|
+
* @param {Entity[]} options.entities - The list of entities to format.
|
|
2502
|
+
* @returns {string} A formatted string representing the entities.
|
|
2503
|
+
*/
|
|
2504
|
+
declare function formatEntities({ entities }: {
|
|
2505
|
+
entities: Entity$1[];
|
|
2506
|
+
}): string;
|
|
2507
|
+
|
|
2508
|
+
/**
|
|
2509
|
+
* Type definition for logger methods
|
|
2510
|
+
*/
|
|
2511
|
+
type LogMethod = (...args: any[]) => void;
|
|
2512
|
+
declare const logger: Record<'trace' | 'debug' | 'success' | 'progress' | 'log' | 'info' | 'warn' | 'error' | 'fatal' | 'clear', LogMethod>;
|
|
2513
|
+
declare const elizaLogger: Record<"debug" | "fatal" | "error" | "warn" | "info" | "log" | "progress" | "success" | "trace" | "clear", LogMethod>;
|
|
2514
|
+
|
|
2515
|
+
declare const shouldRespondTemplate: string;
|
|
2516
|
+
declare const messageHandlerTemplate: string;
|
|
2517
|
+
declare const postCreationTemplate: string;
|
|
2518
|
+
declare const booleanFooter: string;
|
|
2519
|
+
declare const imageDescriptionTemplate: string;
|
|
2520
|
+
|
|
2521
|
+
/**
|
|
2522
|
+
* Interface representing the ownership state of servers.
|
|
2523
|
+
* @property {Object.<string, World>} servers - The servers and their corresponding worlds, where the key is the server ID and the value is the World object.
|
|
2524
|
+
*/
|
|
2525
|
+
interface ServerOwnershipState {
|
|
2526
|
+
servers: {
|
|
2527
|
+
[serverId: string]: World$1;
|
|
2528
|
+
};
|
|
2529
|
+
}
|
|
2530
|
+
/**
|
|
2531
|
+
* Retrieve the server role of a specified user entity within a given server.
|
|
2532
|
+
*
|
|
2533
|
+
* @param {IAgentRuntime} runtime - The runtime object containing necessary configurations and services.
|
|
2534
|
+
* @param {string} entityId - The unique identifier of the user entity.
|
|
2535
|
+
* @param {string} serverId - The unique identifier of the server.
|
|
2536
|
+
* @returns {Promise<Role>} The role of the user entity within the server, resolved as a Promise.
|
|
2537
|
+
*/
|
|
2538
|
+
declare function getUserServerRole(runtime: IAgentRuntime$1, entityId: string, serverId: string): Promise<Role$1>;
|
|
2539
|
+
/**
|
|
2540
|
+
* Finds a server where the given user is the owner
|
|
2541
|
+
*/
|
|
2542
|
+
declare function findWorldsForOwner(runtime: IAgentRuntime$1, entityId: string): Promise<World$1[] | null>;
|
|
2543
|
+
|
|
2544
|
+
declare class Semaphore {
|
|
2545
|
+
private _semphonre;
|
|
2546
|
+
constructor(count: number);
|
|
2547
|
+
acquire(): Promise<void>;
|
|
2548
|
+
release(): void;
|
|
2549
|
+
}
|
|
2550
|
+
/**
|
|
2551
|
+
* Represents the runtime environment for an agent.
|
|
2552
|
+
* @class
|
|
2553
|
+
* @implements { IAgentRuntime }
|
|
2554
|
+
* @property { number } #conversationLength - The maximum length of a conversation.
|
|
2555
|
+
* @property { UUID } agentId - The unique identifier for the agent.
|
|
2556
|
+
* @property { Character } character - The character associated with the agent.
|
|
2557
|
+
* @property { IDatabaseAdapter } adapter - The adapter for interacting with the database.
|
|
2558
|
+
* @property {Action[]} actions - The list of actions available to the agent.
|
|
2559
|
+
* @property {Evaluator[]} evaluators - The list of evaluators for decision making.
|
|
2560
|
+
* @property {Provider[]} providers - The list of providers for external services.
|
|
2561
|
+
* @property {Plugin[]} plugins - The list of plugins to extend functionality.
|
|
2562
|
+
*/
|
|
2563
|
+
declare class AgentRuntime implements IAgentRuntime$1 {
|
|
2564
|
+
private _runtime;
|
|
2565
|
+
get services(): Map<ServiceTypeName$1, Service$1>;
|
|
2566
|
+
get events(): Map<string, ((params: any) => Promise<void>)[]>;
|
|
2567
|
+
get routes(): Route$1[];
|
|
2568
|
+
get agentId(): UUID$1;
|
|
2569
|
+
get character(): Character$1;
|
|
2570
|
+
get providers(): Provider$1[];
|
|
2571
|
+
get actions(): Action$1[];
|
|
2572
|
+
get evaluators(): Evaluator$1[];
|
|
2573
|
+
get plugins(): Plugin$1[];
|
|
2574
|
+
get adapter(): IDatabaseAdapter$1;
|
|
2575
|
+
constructor(opts: {
|
|
2576
|
+
conversationLength?: number;
|
|
2577
|
+
agentId?: UUID$1;
|
|
2578
|
+
character?: Character$1;
|
|
2579
|
+
plugins?: Plugin$1[];
|
|
2580
|
+
fetch?: typeof fetch;
|
|
2581
|
+
adapter?: IDatabaseAdapter$1;
|
|
2582
|
+
settings?: RuntimeSettings$1;
|
|
2583
|
+
events?: {
|
|
2584
|
+
[key: string]: ((params: any) => void)[];
|
|
2585
|
+
};
|
|
2586
|
+
});
|
|
2587
|
+
/**
|
|
2588
|
+
* Registers a plugin with the runtime and initializes its components
|
|
2589
|
+
* @param plugin The plugin to register
|
|
2590
|
+
*/
|
|
2591
|
+
registerPlugin(plugin: Plugin$1): Promise<void>;
|
|
2592
|
+
getAllServices(): Map<ServiceTypeName$1, Service$1>;
|
|
2593
|
+
stop(): Promise<any>;
|
|
2594
|
+
initialize(): Promise<any>;
|
|
2595
|
+
getConnection(): Promise<PGlite | Pool>;
|
|
2596
|
+
setSetting(key: string, value: string | boolean | null | any, secret?: boolean): any;
|
|
2597
|
+
getSetting(key: string): string | boolean | null | any;
|
|
2598
|
+
/**
|
|
2599
|
+
* Get the number of messages that are kept in the conversation buffer.
|
|
2600
|
+
* @returns The number of recent messages to be kept in memory.
|
|
2601
|
+
*/
|
|
2602
|
+
getConversationLength(): any;
|
|
2603
|
+
registerDatabaseAdapter(adapter: IDatabaseAdapter$1): any;
|
|
2604
|
+
/**
|
|
2605
|
+
* Register a provider for the agent to use.
|
|
2606
|
+
* @param provider The provider to register.
|
|
2607
|
+
*/
|
|
2608
|
+
registerProvider(provider: Provider$1): any;
|
|
2609
|
+
/**
|
|
2610
|
+
* Register an action for the agent to perform.
|
|
2611
|
+
* @param action The action to register.
|
|
2612
|
+
*/
|
|
2613
|
+
registerAction(action: Action$1): any;
|
|
2614
|
+
/**
|
|
2615
|
+
* Register an evaluator to assess and guide the agent's responses.
|
|
2616
|
+
* @param evaluator The evaluator to register.
|
|
2617
|
+
*/
|
|
2618
|
+
registerEvaluator(evaluator: Evaluator$1): any;
|
|
2619
|
+
/**
|
|
2620
|
+
* Process the actions of a message.
|
|
2621
|
+
* @param message The message to process.
|
|
2622
|
+
* @param responses The array of response memories to process actions from.
|
|
2623
|
+
* @param state Optional state object for the action processing.
|
|
2624
|
+
* @param callback Optional callback handler for action results.
|
|
2625
|
+
*/
|
|
2626
|
+
processActions(message: Memory$1, responses: Memory$1[], state?: State$1, callback?: HandlerCallback$1): Promise<void>;
|
|
2627
|
+
/**
|
|
2628
|
+
* Evaluate the message and state using the registered evaluators.
|
|
2629
|
+
* @param message The message to evaluate.
|
|
2630
|
+
* @param state The state of the agent.
|
|
2631
|
+
* @param didRespond Whether the agent responded to the message.~
|
|
2632
|
+
* @param callback The handler callback
|
|
2633
|
+
* @returns The results of the evaluation.
|
|
2634
|
+
*/
|
|
2635
|
+
evaluate(message: Memory$1, state: State$1, didRespond?: boolean, callback?: HandlerCallback$1, responses?: Memory$1[]): Promise<any>;
|
|
2636
|
+
ensureConnection({ entityId, roomId, userName, name, source, type, channelId, serverId, worldId, userId, }: {
|
|
2637
|
+
entityId: UUID$1;
|
|
2638
|
+
roomId: UUID$1;
|
|
2639
|
+
userName?: string;
|
|
2640
|
+
name?: string;
|
|
2641
|
+
source?: string;
|
|
2642
|
+
type?: ChannelType;
|
|
2643
|
+
channelId?: string;
|
|
2644
|
+
serverId?: string;
|
|
2645
|
+
worldId?: UUID$1;
|
|
2646
|
+
userId?: UUID$1;
|
|
2647
|
+
}): Promise<any>;
|
|
2648
|
+
/**
|
|
2649
|
+
* Ensures a participant is added to a room, checking that the entity exists first
|
|
2650
|
+
*/
|
|
2651
|
+
ensureParticipantInRoom(entityId: UUID$1, roomId: UUID$1): Promise<any>;
|
|
2652
|
+
removeParticipant(entityId: UUID$1, roomId: UUID$1): Promise<boolean>;
|
|
2653
|
+
getParticipantsForEntity(entityId: UUID$1): Promise<Participant$1[]>;
|
|
2654
|
+
getParticipantsForRoom(roomId: UUID$1): Promise<UUID$1[]>;
|
|
2655
|
+
addParticipant(entityId: UUID$1, roomId: UUID$1): Promise<boolean>;
|
|
2656
|
+
addParticipantsRoom(entityIds: UUID$1[], roomId: UUID$1): Promise<boolean>;
|
|
2657
|
+
/**
|
|
2658
|
+
* Ensure the existence of a world.
|
|
2659
|
+
*/
|
|
2660
|
+
ensureWorldExists({ id, name, serverId, metadata, agentId }: World$1): Promise<any>;
|
|
2661
|
+
/**
|
|
2662
|
+
* Ensure the existence of a room between the agent and a user. If no room exists, a new room is created and the user
|
|
2663
|
+
* and agent are added as participants. The room ID is returned.
|
|
2664
|
+
* @param entityId - The user ID to create a room with.
|
|
2665
|
+
* @returns The room ID of the room between the agent and the user.
|
|
2666
|
+
* @throws An error if the room cannot be created.
|
|
2667
|
+
*/
|
|
2668
|
+
ensureRoomExists({ id, name, source, type, channelId, serverId, worldId, metadata }: Room$1): Promise<any>;
|
|
2669
|
+
/**
|
|
2670
|
+
* Composes the agent's state by gathering data from enabled providers.
|
|
2671
|
+
* @param message - The message to use as context for state composition
|
|
2672
|
+
* @param includeList - Optional list of provider names to include, filtering out all others
|
|
2673
|
+
* @param onlyInclude - Whether to only include the specified providers
|
|
2674
|
+
* @param skipCache - Whether to skip the cache
|
|
2675
|
+
* @returns A State object containing provider data, values, and text
|
|
2676
|
+
*/
|
|
2677
|
+
composeState(message: Memory$1, includeList?: string[] | null, onlyInclude?: boolean, skipCache?: boolean): Promise<State$1>;
|
|
2678
|
+
getService<T extends Service$1>(service: ServiceTypeName$1): T | null;
|
|
2679
|
+
registerService(service: typeof Service$1): Promise<void>;
|
|
2680
|
+
registerModel(modelType: ModelTypeName$1, handler: (runtime: IAgentRuntime$1, params: any) => Promise<any>, provider?: string): any;
|
|
2681
|
+
getModel(modelType: ModelTypeName$1): ((runtime: IAgentRuntime$1, params: any) => Promise<any>) | undefined;
|
|
2682
|
+
/**
|
|
2683
|
+
* Use a model with strongly typed parameters and return values based on model type
|
|
2684
|
+
* @template T - The model type to use
|
|
2685
|
+
* @template R - The expected return type, defaults to the type defined in ModelResultMap[T]
|
|
2686
|
+
* @param {T} modelType - The type of model to use
|
|
2687
|
+
* @param {ModelParamsMap[T] | any} params - The parameters for the model, typed based on model type
|
|
2688
|
+
* @returns {Promise<R>} - The model result, typed based on the provided generic type parameter
|
|
2689
|
+
*/
|
|
2690
|
+
useModel<T extends ModelTypeName$1, R = ModelResultMap$1[T]>(modelType: T, params: Omit<ModelParamsMap$1[T], 'runtime'> | any): Promise<R>;
|
|
2691
|
+
registerEvent(event: string, handler: (params: any) => Promise<void>): any;
|
|
2692
|
+
getEvent(event: string): ((params: any) => Promise<void>)[] | undefined;
|
|
2693
|
+
emitEvent(event: string | string[], params: any): Promise<any>;
|
|
2694
|
+
ensureEmbeddingDimension(): Promise<any>;
|
|
2695
|
+
registerTaskWorker(taskHandler: TaskWorker$1): void;
|
|
2696
|
+
/**
|
|
2697
|
+
* Get a task worker by name
|
|
2698
|
+
*/
|
|
2699
|
+
getTaskWorker(name: string): TaskWorker$1 | undefined;
|
|
2700
|
+
get db(): any;
|
|
2701
|
+
init(): Promise<void>;
|
|
2702
|
+
close(): Promise<void>;
|
|
2703
|
+
getAgent(agentId: UUID$1): Promise<Agent$1 | null>;
|
|
2704
|
+
getAgents(): Promise<Agent$1[]>;
|
|
2705
|
+
createAgent(agent: Partial<Agent$1>): Promise<boolean>;
|
|
2706
|
+
updateAgent(agentId: UUID$1, agent: Partial<Agent$1>): Promise<boolean>;
|
|
2707
|
+
deleteAgent(agentId: UUID$1): Promise<boolean>;
|
|
2708
|
+
ensureAgentExists(agent: Partial<Agent$1>): Promise<Agent$1>;
|
|
2709
|
+
getEntityById(entityId: UUID$1): Promise<Entity$1 | null>;
|
|
2710
|
+
getEntityByIds(entityIds: UUID$1[]): Promise<Entity$1[] | null>;
|
|
2711
|
+
getEntitiesForRoom(roomId: UUID$1, includeComponents?: boolean): Promise<Entity$1[]>;
|
|
2712
|
+
createEntity(entity: Entity$1): Promise<boolean>;
|
|
2713
|
+
createEntities(entities: Entity$1[]): Promise<boolean>;
|
|
2714
|
+
updateEntity(entity: Entity$1): Promise<void>;
|
|
2715
|
+
getComponent(entityId: UUID$1, type: string, worldId?: UUID$1, sourceEntityId?: UUID$1): Promise<Component$1 | null>;
|
|
2716
|
+
getComponents(entityId: UUID$1, worldId?: UUID$1, sourceEntityId?: UUID$1): Promise<Component$1[]>;
|
|
2717
|
+
createComponent(component: Component$1): Promise<boolean>;
|
|
2718
|
+
updateComponent(component: Component$1): Promise<void>;
|
|
2719
|
+
deleteComponent(componentId: UUID$1): Promise<void>;
|
|
2720
|
+
addEmbeddingToMemory(memory: Memory$1): Promise<Memory$1>;
|
|
2721
|
+
getMemories(params: {
|
|
2722
|
+
entityId?: UUID$1;
|
|
2723
|
+
agentId?: UUID$1;
|
|
2724
|
+
roomId?: UUID$1;
|
|
2725
|
+
count?: number;
|
|
2726
|
+
unique?: boolean;
|
|
2727
|
+
tableName: string;
|
|
2728
|
+
start?: number;
|
|
2729
|
+
end?: number;
|
|
2730
|
+
}): Promise<Memory$1[]>;
|
|
2731
|
+
getMemoryById(id: UUID$1): Promise<Memory$1 | null>;
|
|
2732
|
+
getMemoriesByIds(ids: UUID$1[], tableName?: string): Promise<Memory$1[]>;
|
|
2733
|
+
getMemoriesByRoomIds(params: {
|
|
2734
|
+
tableName: string;
|
|
2735
|
+
roomIds: UUID$1[];
|
|
2736
|
+
limit?: number;
|
|
2737
|
+
}): Promise<Memory$1[]>;
|
|
2738
|
+
getCachedEmbeddings(params: {
|
|
2739
|
+
query_table_name: string;
|
|
2740
|
+
query_threshold: number;
|
|
2741
|
+
query_input: string;
|
|
2742
|
+
query_field_name: string;
|
|
2743
|
+
query_field_sub_name: string;
|
|
2744
|
+
query_match_count: number;
|
|
2745
|
+
}): Promise<{
|
|
2746
|
+
embedding: number[];
|
|
2747
|
+
levenshtein_score: number;
|
|
2748
|
+
}[]>;
|
|
2749
|
+
log(params: {
|
|
2750
|
+
body: {
|
|
2751
|
+
[key: string]: unknown;
|
|
2752
|
+
};
|
|
2753
|
+
entityId: UUID$1;
|
|
2754
|
+
roomId: UUID$1;
|
|
2755
|
+
type: string;
|
|
2756
|
+
}): Promise<void>;
|
|
2757
|
+
searchMemories(params: {
|
|
2758
|
+
embedding: number[];
|
|
2759
|
+
match_threshold?: number;
|
|
2760
|
+
count?: number;
|
|
2761
|
+
roomId?: UUID$1;
|
|
2762
|
+
unique?: boolean;
|
|
2763
|
+
tableName: string;
|
|
2764
|
+
}): Promise<Memory$1[]>;
|
|
2765
|
+
createMemory(memory: Memory$1, tableName: string, unique?: boolean): Promise<UUID$1>;
|
|
2766
|
+
updateMemory(memory: Partial<Memory$1> & {
|
|
2767
|
+
id: UUID$1;
|
|
2768
|
+
metadata?: MemoryMetadata$1;
|
|
2769
|
+
}): Promise<boolean>;
|
|
2770
|
+
deleteMemory(memoryId: UUID$1): Promise<void>;
|
|
2771
|
+
deleteAllMemories(roomId: UUID$1, tableName: string): Promise<void>;
|
|
2772
|
+
countMemories(roomId: UUID$1, unique?: boolean, tableName?: string): Promise<number>;
|
|
2773
|
+
getLogs(params: {
|
|
2774
|
+
entityId: UUID$1;
|
|
2775
|
+
roomId?: UUID$1;
|
|
2776
|
+
type?: string;
|
|
2777
|
+
count?: number;
|
|
2778
|
+
offset?: number;
|
|
2779
|
+
}): Promise<Log$1[]>;
|
|
2780
|
+
deleteLog(logId: UUID$1): Promise<void>;
|
|
2781
|
+
createWorld(world: World$1): Promise<UUID$1>;
|
|
2782
|
+
getWorld(id: UUID$1): Promise<World$1 | null>;
|
|
2783
|
+
removeWorld(worldId: UUID$1): Promise<void>;
|
|
2784
|
+
getAllWorlds(): Promise<World$1[]>;
|
|
2785
|
+
updateWorld(world: World$1): Promise<void>;
|
|
2786
|
+
getRoom(roomId: UUID$1): Promise<Room$1 | null>;
|
|
2787
|
+
getRoomsByIds(roomIds: UUID$1[]): Promise<Room$1[] | null>;
|
|
2788
|
+
createRoom({ id, name, source, type, channelId, serverId, worldId }: Room$1): Promise<UUID$1>;
|
|
2789
|
+
createRooms(rooms: Room$1[]): Promise<UUID$1[]>;
|
|
2790
|
+
deleteRoom(roomId: UUID$1): Promise<void>;
|
|
2791
|
+
deleteRoomsByWorldId(worldId: UUID$1): Promise<void>;
|
|
2792
|
+
updateRoom(room: Room$1): Promise<void>;
|
|
2793
|
+
getRoomsForParticipant(entityId: UUID$1): Promise<UUID$1[]>;
|
|
2794
|
+
getRoomsForParticipants(userIds: UUID$1[]): Promise<UUID$1[]>;
|
|
2795
|
+
getRooms(worldId: UUID$1): Promise<Room$1[]>;
|
|
2796
|
+
getRoomsByWorld(worldId: UUID$1): Promise<Room$1[]>;
|
|
2797
|
+
getParticipantUserState(roomId: UUID$1, entityId: UUID$1): Promise<'FOLLOWED' | 'MUTED' | null>;
|
|
2798
|
+
setParticipantUserState(roomId: UUID$1, entityId: UUID$1, state: 'FOLLOWED' | 'MUTED' | null): Promise<void>;
|
|
2799
|
+
createRelationship(params: {
|
|
2800
|
+
sourceEntityId: UUID$1;
|
|
2801
|
+
targetEntityId: UUID$1;
|
|
2802
|
+
tags?: string[];
|
|
2803
|
+
metadata?: {
|
|
2804
|
+
[key: string]: any;
|
|
2805
|
+
};
|
|
2806
|
+
}): Promise<boolean>;
|
|
2807
|
+
updateRelationship(relationship: Relationship$1): Promise<void>;
|
|
2808
|
+
getRelationship(params: {
|
|
2809
|
+
sourceEntityId: UUID$1;
|
|
2810
|
+
targetEntityId: UUID$1;
|
|
2811
|
+
}): Promise<Relationship$1 | null>;
|
|
2812
|
+
getRelationships(params: {
|
|
2813
|
+
entityId: UUID$1;
|
|
2814
|
+
tags?: string[];
|
|
2815
|
+
}): Promise<Relationship$1[]>;
|
|
2816
|
+
getCache<T>(key: string): Promise<T | undefined>;
|
|
2817
|
+
setCache<T>(key: string, value: T): Promise<boolean>;
|
|
2818
|
+
deleteCache(key: string): Promise<boolean>;
|
|
2819
|
+
createTask(task: Task$1): Promise<UUID$1>;
|
|
2820
|
+
getTasks(params: {
|
|
2821
|
+
roomId?: UUID$1;
|
|
2822
|
+
tags?: string[];
|
|
2823
|
+
}): Promise<Task$1[]>;
|
|
2824
|
+
getTask(id: UUID$1): Promise<Task$1 | null>;
|
|
2825
|
+
getTasksByName(name: string): Promise<Task$1[]>;
|
|
2826
|
+
updateTask(id: UUID$1, task: Partial<Task$1>): Promise<void>;
|
|
2827
|
+
deleteTask(id: UUID$1): Promise<void>;
|
|
2828
|
+
on(event: string, callback: (data: any) => void): void;
|
|
2829
|
+
off(event: string, callback: (data: any) => void): void;
|
|
2830
|
+
emit(event: string, data: any): void;
|
|
2831
|
+
sendControlMessage(params: {
|
|
2832
|
+
roomId: UUID$1;
|
|
2833
|
+
action: 'enable_input' | 'disable_input';
|
|
2834
|
+
target?: string;
|
|
2835
|
+
}): Promise<void>;
|
|
2836
|
+
registerSendHandler(source: string, handler: any): void;
|
|
2837
|
+
sendMessageToTarget(target: TargetInfo$1, content: Content$1): Promise<void>;
|
|
2838
|
+
getMemoriesByWorldId(params: {
|
|
2839
|
+
worldId: UUID$1;
|
|
2840
|
+
count?: number;
|
|
2841
|
+
tableName?: string;
|
|
2842
|
+
}): Promise<Memory$1[]>;
|
|
2843
|
+
}
|
|
2844
|
+
|
|
2845
|
+
/**
|
|
2846
|
+
* Creates a Setting object from a configSetting object by omitting the 'value' property.
|
|
2847
|
+
*
|
|
2848
|
+
* @param {Omit<Setting, 'value'>} configSetting - The configSetting object to create the Setting from.
|
|
2849
|
+
* @returns {Setting} A new Setting object created from the provided configSetting object.
|
|
2850
|
+
*/
|
|
2851
|
+
declare function createSettingFromConfig(configSetting: Omit<Setting, 'value'>): Setting;
|
|
2852
|
+
/**
|
|
2853
|
+
* Retrieves the salt based on env variable SECRET_SALT
|
|
2854
|
+
*
|
|
2855
|
+
* @returns {string} The salt for the agent.
|
|
2856
|
+
*/
|
|
2857
|
+
declare function getSalt(): string;
|
|
2858
|
+
/**
|
|
2859
|
+
* Common encryption function for string values
|
|
2860
|
+
* @param {string} value - The string value to encrypt
|
|
2861
|
+
* @param {string} salt - The salt to use for encryption
|
|
2862
|
+
* @returns {string} - The encrypted value in 'iv:encrypted' format
|
|
2863
|
+
*/
|
|
2864
|
+
declare function encryptStringValue(value: string, salt: string): string;
|
|
2865
|
+
/**
|
|
2866
|
+
* Common decryption function for string values
|
|
2867
|
+
* @param {string} value - The encrypted value in 'iv:encrypted' format
|
|
2868
|
+
* @param {string} salt - The salt to use for decryption
|
|
2869
|
+
* @returns {string} - The decrypted string value
|
|
2870
|
+
*/
|
|
2871
|
+
declare function decryptStringValue(value: string, salt: string): string;
|
|
2872
|
+
/**
|
|
2873
|
+
* Applies salt to the value of a setting
|
|
2874
|
+
* Only applies to secret settings with string values
|
|
2875
|
+
*/
|
|
2876
|
+
declare function saltSettingValue(setting: Setting, salt: string): Setting;
|
|
2877
|
+
/**
|
|
2878
|
+
* Removes salt from the value of a setting
|
|
2879
|
+
* Only applies to secret settings with string values
|
|
2880
|
+
*/
|
|
2881
|
+
declare function unsaltSettingValue(setting: Setting, salt: string): Setting;
|
|
2882
|
+
/**
|
|
2883
|
+
* Applies salt to all settings in a WorldSettings object
|
|
2884
|
+
*/
|
|
2885
|
+
declare function saltWorldSettings(worldSettings: WorldSettings, salt: string): WorldSettings;
|
|
2886
|
+
/**
|
|
2887
|
+
* Removes salt from all settings in a WorldSettings object
|
|
2888
|
+
*/
|
|
2889
|
+
declare function unsaltWorldSettings(worldSettings: WorldSettings, salt: string): WorldSettings;
|
|
2890
|
+
/**
|
|
2891
|
+
* Updates settings state in world metadata
|
|
2892
|
+
*/
|
|
2893
|
+
declare function updateWorldSettings(runtime: IAgentRuntime, serverId: string, worldSettings: WorldSettings): Promise<boolean>;
|
|
2894
|
+
/**
|
|
2895
|
+
* Gets settings state from world metadata
|
|
2896
|
+
*/
|
|
2897
|
+
declare function getWorldSettings(runtime: IAgentRuntime, serverId: string): Promise<WorldSettings | null>;
|
|
2898
|
+
/**
|
|
2899
|
+
* Initializes settings configuration for a server
|
|
2900
|
+
*/
|
|
2901
|
+
declare function initializeOnboarding(runtime: IAgentRuntime, world: World, config: OnboardingConfig): Promise<WorldSettings | null>;
|
|
2902
|
+
/**
|
|
2903
|
+
* Encrypts sensitive data in a Character object
|
|
2904
|
+
* @param {Character} character - The character object to encrypt secrets for
|
|
2905
|
+
* @param {IAgentRuntime} runtime - The runtime information needed for salt generation
|
|
2906
|
+
* @returns {Character} - A copy of the character with encrypted secrets
|
|
2907
|
+
*/
|
|
2908
|
+
declare function encryptedCharacter(character: Character): Character;
|
|
2909
|
+
/**
|
|
2910
|
+
* Decrypts sensitive data in a Character object
|
|
2911
|
+
* @param {Character} character - The character object with encrypted secrets
|
|
2912
|
+
* @param {IAgentRuntime} runtime - The runtime information needed for salt generation
|
|
2913
|
+
* @returns {Character} - A copy of the character with decrypted secrets
|
|
2914
|
+
*/
|
|
2915
|
+
declare function decryptedCharacter(character: Character, runtime: IAgentRuntime): Character;
|
|
2916
|
+
/**
|
|
2917
|
+
* Helper function to encrypt all string values in an object
|
|
2918
|
+
* @param {Record<string, any>} obj - Object with values to encrypt
|
|
2919
|
+
* @param {string} salt - The salt to use for encryption
|
|
2920
|
+
* @returns {Record<string, any>} - Object with encrypted values
|
|
2921
|
+
*/
|
|
2922
|
+
declare function encryptObjectValues(obj: Record<string, any>, salt: string): Record<string, any>;
|
|
2923
|
+
/**
|
|
2924
|
+
* Helper function to decrypt all string values in an object
|
|
2925
|
+
* @param {Record<string, any>} obj - Object with encrypted values
|
|
2926
|
+
* @param {string} salt - The salt to use for decryption
|
|
2927
|
+
* @returns {Record<string, any>} - Object with decrypted values
|
|
2928
|
+
*/
|
|
2929
|
+
declare function decryptObjectValues(obj: Record<string, any>, salt: string): Record<string, any>;
|
|
2930
|
+
|
|
2931
|
+
/**
|
|
2932
|
+
* Convert all double-brace bindings in a Handlebars template
|
|
2933
|
+
* to triple-brace bindings, so the output is NOT HTML-escaped.
|
|
2934
|
+
*
|
|
2935
|
+
* - Ignores block/partial/comment tags that start with # / ! >.
|
|
2936
|
+
* - Ignores the else keyword.
|
|
2937
|
+
* - Ignores bindings that are already triple-braced.
|
|
2938
|
+
*
|
|
2939
|
+
* @param tpl Handlebars template source
|
|
2940
|
+
* @return Transformed template
|
|
2941
|
+
*/
|
|
2942
|
+
/**
|
|
2943
|
+
* Function to compose a prompt using a provided template and state.
|
|
2944
|
+
* It compiles the template (upgrading double braces to triple braces for non-HTML escaping)
|
|
2945
|
+
* and then populates it with values from the state. Additionally, it processes the
|
|
2946
|
+
* resulting string with `composeRandomUser` to replace placeholders like `{{nameX}}`.
|
|
2947
|
+
*
|
|
2948
|
+
* @param {Object} options - Object containing state and template information.
|
|
2949
|
+
* @param {State} options.state - The state object containing values to fill the template.
|
|
2950
|
+
* @param {TemplateType} options.template - The template string or function to be used for composing the prompt.
|
|
2951
|
+
* @returns {string} The composed prompt output, with state values and random user names populated.
|
|
2952
|
+
*/
|
|
2953
|
+
declare const composePrompt: ({ state, template, }: {
|
|
2954
|
+
state: {
|
|
2955
|
+
[key: string]: string;
|
|
2956
|
+
};
|
|
2957
|
+
template: TemplateType$1;
|
|
2958
|
+
}) => string;
|
|
2959
|
+
/**
|
|
2960
|
+
* Function to compose a prompt using a provided template and state.
|
|
2961
|
+
*
|
|
2962
|
+
* @param {Object} options - Object containing state and template information.
|
|
2963
|
+
* @param {State} options.state - The state object containing values to fill the template.
|
|
2964
|
+
* @param {TemplateType} options.template - The template to be used for composing the prompt.
|
|
2965
|
+
* @returns {string} The composed prompt output.
|
|
2966
|
+
*/
|
|
2967
|
+
declare const composePromptFromState: ({ state, template, }: {
|
|
2968
|
+
state: State$1;
|
|
2969
|
+
template: TemplateType$1;
|
|
2970
|
+
}) => string;
|
|
2971
|
+
/**
|
|
2972
|
+
* Adds a header to a body of text.
|
|
2973
|
+
*
|
|
2974
|
+
* This function takes a header string and a body string and returns a new string with the header prepended to the body.
|
|
2975
|
+
* If the body string is empty, the header is returned as is.
|
|
2976
|
+
*
|
|
2977
|
+
* @param {string} header - The header to add to the body.
|
|
2978
|
+
* @param {string} body - The body to which to add the header.
|
|
2979
|
+
* @returns {string} The body with the header prepended.
|
|
2980
|
+
*
|
|
2981
|
+
* @example
|
|
2982
|
+
* // Given a header and a body
|
|
2983
|
+
* const header = "Header";
|
|
2984
|
+
* const body = "Body";
|
|
2985
|
+
*
|
|
2986
|
+
* // Adding the header to the body will result in:
|
|
2987
|
+
* // "Header\nBody"
|
|
2988
|
+
* const text = addHeader(header, body);
|
|
2989
|
+
*/
|
|
2990
|
+
declare const addHeader: (header: string, body: string) => string;
|
|
2991
|
+
declare const formatPosts: ({ messages, entities, conversationHeader, }: {
|
|
2992
|
+
messages: Memory$1[];
|
|
2993
|
+
entities: Entity$1[];
|
|
2994
|
+
conversationHeader?: boolean;
|
|
2995
|
+
}) => string;
|
|
2996
|
+
/**
|
|
2997
|
+
* Format messages into a string
|
|
2998
|
+
* @param {Object} params - The formatting parameters
|
|
2999
|
+
* @param {Memory[]} params.messages - List of messages to format
|
|
3000
|
+
* @param {Entity[]} params.entities - List of entities for name resolution
|
|
3001
|
+
* @returns {string} Formatted message string with timestamps and user information
|
|
3002
|
+
*/
|
|
3003
|
+
declare const formatMessages: ({ messages, entities, }: {
|
|
3004
|
+
messages: Memory$1[];
|
|
3005
|
+
entities: Entity$1[];
|
|
3006
|
+
}) => string;
|
|
3007
|
+
declare const formatTimestamp: (messageDate: number) => string;
|
|
3008
|
+
/**
|
|
3009
|
+
* Validates a UUID value.
|
|
3010
|
+
*
|
|
3011
|
+
* @param {unknown} value - The value to validate.
|
|
3012
|
+
* @returns {UUID | null} Returns the validated UUID value or null if validation fails.
|
|
3013
|
+
*/
|
|
3014
|
+
declare function validateUuid(value: unknown): UUID$1 | null;
|
|
3015
|
+
/**
|
|
3016
|
+
* Converts a string or number to a UUID.
|
|
3017
|
+
*
|
|
3018
|
+
* @param {string | number} target - The string or number to convert to a UUID.
|
|
3019
|
+
* @returns {UUID} The UUID generated from the input target.
|
|
3020
|
+
* @throws {TypeError} Throws an error if the input target is not a string.
|
|
3021
|
+
*/
|
|
3022
|
+
declare function stringToUuid(target: string | number): UUID$1;
|
|
3023
|
+
declare function truncateToCompleteSentence(text: string, maxLength: number): string;
|
|
3024
|
+
declare function parseKeyValueXml(text: string): Record<string, any> | null;
|
|
3025
|
+
declare function parseJSONObjectFromText(text: string): Record<string, any> | null;
|
|
3026
|
+
declare function parseBooleanFromText(text: string): boolean | null;
|
|
3027
|
+
declare function safeReplacer(): (key: string, value: any) => any;
|
|
3028
|
+
declare function trimTokens(text: string, maxTokens: number, runtime: IAgentRuntime): Promise<string>;
|
|
3029
|
+
|
|
3030
|
+
/**
|
|
3031
|
+
* Service builder class that provides type-safe service creation
|
|
3032
|
+
* with automatic type inference
|
|
3033
|
+
*/
|
|
3034
|
+
declare class ServiceBuilder<TService extends Service$1 = Service$1> extends ServiceBuilder$1 {
|
|
3035
|
+
constructor(serviceType: ServiceTypeName$1 | string);
|
|
3036
|
+
}
|
|
3037
|
+
/**
|
|
3038
|
+
* Create a type-safe service builder
|
|
3039
|
+
* @param serviceType - The service type name
|
|
3040
|
+
* @returns A new ServiceBuilder instance
|
|
3041
|
+
*/
|
|
3042
|
+
declare function createService<TService extends Service = Service>(serviceType: ServiceTypeName$1 | string): ServiceBuilder$1<TService>;
|
|
3043
|
+
/**
|
|
3044
|
+
* Type-safe service definition helper
|
|
3045
|
+
*/
|
|
3046
|
+
interface ServiceDefinition<T extends Service$1 = Service$1> {
|
|
3047
|
+
serviceType: ServiceTypeName$1;
|
|
3048
|
+
description: string;
|
|
3049
|
+
start: (runtime: IAgentRuntime$1) => Promise<T>;
|
|
3050
|
+
stop?: () => Promise<void>;
|
|
3051
|
+
}
|
|
3052
|
+
/**
|
|
3053
|
+
* Define a service with type safety
|
|
3054
|
+
*/
|
|
3055
|
+
declare function defineService<T extends Service = Service>(definition: ServiceDefinition$1<T>): new (runtime?: IAgentRuntime) => T;
|
|
3056
|
+
|
|
3057
|
+
type v2_AgentRuntime = AgentRuntime;
|
|
3058
|
+
declare const v2_AgentRuntime: typeof AgentRuntime;
|
|
3059
|
+
type v2_DatabaseAdapter<DB = unknown> = DatabaseAdapter<DB>;
|
|
3060
|
+
declare const v2_DatabaseAdapter: typeof DatabaseAdapter;
|
|
3061
|
+
type v2_Semaphore = Semaphore;
|
|
3062
|
+
declare const v2_Semaphore: typeof Semaphore;
|
|
3063
|
+
type v2_ServerOwnershipState = ServerOwnershipState;
|
|
3064
|
+
type v2_ServiceBuilder<TService extends Service$1 = Service$1> = ServiceBuilder<TService>;
|
|
3065
|
+
declare const v2_ServiceBuilder: typeof ServiceBuilder;
|
|
3066
|
+
type v2_ServiceDefinition<T extends Service$1 = Service$1> = ServiceDefinition<T>;
|
|
3067
|
+
declare const v2_addHeader: typeof addHeader;
|
|
3068
|
+
declare const v2_booleanFooter: typeof booleanFooter;
|
|
3069
|
+
declare const v2_composeActionExamples: typeof composeActionExamples;
|
|
3070
|
+
declare const v2_composePrompt: typeof composePrompt;
|
|
3071
|
+
declare const v2_composePromptFromState: typeof composePromptFromState;
|
|
3072
|
+
declare const v2_createService: typeof createService;
|
|
3073
|
+
declare const v2_createSettingFromConfig: typeof createSettingFromConfig;
|
|
3074
|
+
declare const v2_createUniqueUuid: typeof createUniqueUuid;
|
|
3075
|
+
declare const v2_decryptObjectValues: typeof decryptObjectValues;
|
|
3076
|
+
declare const v2_decryptStringValue: typeof decryptStringValue;
|
|
3077
|
+
declare const v2_decryptedCharacter: typeof decryptedCharacter;
|
|
3078
|
+
declare const v2_defineService: typeof defineService;
|
|
3079
|
+
declare const v2_elizaLogger: typeof elizaLogger;
|
|
3080
|
+
declare const v2_encryptObjectValues: typeof encryptObjectValues;
|
|
3081
|
+
declare const v2_encryptStringValue: typeof encryptStringValue;
|
|
3082
|
+
declare const v2_encryptedCharacter: typeof encryptedCharacter;
|
|
3083
|
+
declare const v2_findEntityByName: typeof findEntityByName;
|
|
3084
|
+
declare const v2_findWorldsForOwner: typeof findWorldsForOwner;
|
|
3085
|
+
declare const v2_formatActionNames: typeof formatActionNames;
|
|
3086
|
+
declare const v2_formatActions: typeof formatActions;
|
|
3087
|
+
declare const v2_formatEntities: typeof formatEntities;
|
|
3088
|
+
declare const v2_formatMessages: typeof formatMessages;
|
|
3089
|
+
declare const v2_formatPosts: typeof formatPosts;
|
|
3090
|
+
declare const v2_formatTimestamp: typeof formatTimestamp;
|
|
3091
|
+
declare const v2_getEntityDetails: typeof getEntityDetails;
|
|
3092
|
+
declare const v2_getSalt: typeof getSalt;
|
|
3093
|
+
declare const v2_getUserServerRole: typeof getUserServerRole;
|
|
3094
|
+
declare const v2_getWorldSettings: typeof getWorldSettings;
|
|
3095
|
+
declare const v2_imageDescriptionTemplate: typeof imageDescriptionTemplate;
|
|
3096
|
+
declare const v2_initializeOnboarding: typeof initializeOnboarding;
|
|
3097
|
+
declare const v2_logger: typeof logger;
|
|
3098
|
+
declare const v2_messageHandlerTemplate: typeof messageHandlerTemplate;
|
|
3099
|
+
declare const v2_parseBooleanFromText: typeof parseBooleanFromText;
|
|
3100
|
+
declare const v2_parseJSONObjectFromText: typeof parseJSONObjectFromText;
|
|
3101
|
+
declare const v2_parseKeyValueXml: typeof parseKeyValueXml;
|
|
3102
|
+
declare const v2_postCreationTemplate: typeof postCreationTemplate;
|
|
3103
|
+
declare const v2_safeReplacer: typeof safeReplacer;
|
|
3104
|
+
declare const v2_saltSettingValue: typeof saltSettingValue;
|
|
3105
|
+
declare const v2_saltWorldSettings: typeof saltWorldSettings;
|
|
3106
|
+
declare const v2_shouldRespondTemplate: typeof shouldRespondTemplate;
|
|
3107
|
+
declare const v2_stringToUuid: typeof stringToUuid;
|
|
3108
|
+
declare const v2_trimTokens: typeof trimTokens;
|
|
3109
|
+
declare const v2_truncateToCompleteSentence: typeof truncateToCompleteSentence;
|
|
3110
|
+
declare const v2_unsaltSettingValue: typeof unsaltSettingValue;
|
|
3111
|
+
declare const v2_unsaltWorldSettings: typeof unsaltWorldSettings;
|
|
3112
|
+
declare const v2_updateWorldSettings: typeof updateWorldSettings;
|
|
3113
|
+
declare const v2_validateUuid: typeof validateUuid;
|
|
3114
|
+
declare namespace v2 {
|
|
3115
|
+
export { Action$1 as Action, ActionEventPayload$1 as ActionEventPayload, ActionExample$1 as ActionExample, Agent$1 as Agent, v2_AgentRuntime as AgentRuntime, AgentStatus$1 as AgentStatus, AudioProcessingParams$1 as AudioProcessingParams, BaseMetadata$1 as BaseMetadata, BaseModelParams$1 as BaseModelParams, CacheKeyPrefix$1 as CacheKeyPrefix, ChannelType$1 as ChannelType, Character$1 as Character, ChunkRow$1 as ChunkRow, Component$1 as Component, ComponentData$1 as ComponentData, Content$1 as Content, ContentType$1 as ContentType, ControlMessage$1 as ControlMessage, CustomMetadata$1 as CustomMetadata, v2_DatabaseAdapter as DatabaseAdapter, DbConnection$1 as DbConnection, DeriveKeyAttestationData$1 as DeriveKeyAttestationData, DescriptionMetadata$1 as DescriptionMetadata, DetokenizeTextParams$1 as DetokenizeTextParams, DirectoryItem$1 as DirectoryItem, DocumentMetadata$1 as DocumentMetadata, EmbeddingSearchResult$1 as EmbeddingSearchResult, EnhancedState$1 as EnhancedState, Entity$1 as Entity, EntityPayload$1 as EntityPayload, EvaluationExample$1 as EvaluationExample, Evaluator$1 as Evaluator, EvaluatorEventPayload$1 as EvaluatorEventPayload, EventDataObject$1 as EventDataObject, EventHandler$1 as EventHandler, EventPayload$1 as EventPayload, EventPayloadMap$1 as EventPayloadMap, EventType$1 as EventType, FragmentMetadata$1 as FragmentMetadata, GenerateTextParams$1 as GenerateTextParams, Handler$1 as Handler, HandlerCallback$1 as HandlerCallback, IAgentRuntime$1 as IAgentRuntime, IDatabaseAdapter$1 as IDatabaseAdapter, ImageDescriptionParams$1 as ImageDescriptionParams, ImageGenerationParams$1 as ImageGenerationParams, InvokePayload$1 as InvokePayload, IsValidServiceType$1 as IsValidServiceType, JSONSchema$1 as JSONSchema, KnowledgeItem$1 as KnowledgeItem, KnowledgeScope$1 as KnowledgeScope, Log$1 as Log, Media$1 as Media, Memory$1 as Memory, MemoryMetadata$1 as MemoryMetadata, MemoryRetrievalOptions$1 as MemoryRetrievalOptions, MemoryScope$1 as MemoryScope, MemorySearchOptions$1 as MemorySearchOptions, MemoryType$1 as MemoryType, MemoryTypeAlias$1 as MemoryTypeAlias, MessageExample$1 as MessageExample, MessageMemory$1 as MessageMemory, MessageMetadata$1 as MessageMetadata, MessagePayload$1 as MessagePayload, MessageReceivedHandlerParams$1 as MessageReceivedHandlerParams, MetadataObject$1 as MetadataObject, ModelEventPayload$1 as ModelEventPayload, ModelHandler$1 as ModelHandler, ModelParamsMap$1 as ModelParamsMap, ModelResultMap$1 as ModelResultMap, ModelType$1 as ModelType, ModelTypeName$1 as ModelTypeName, MultiRoomMemoryOptions$1 as MultiRoomMemoryOptions, ObjectGenerationParams$1 as ObjectGenerationParams, OnboardingConfig$1 as OnboardingConfig, Participant$1 as Participant, PlatformPrefix$1 as PlatformPrefix, Plugin$1 as Plugin, PluginEvents$1 as PluginEvents, Project$1 as Project, ProjectAgent$1 as ProjectAgent, Provider$1 as Provider, ProviderResult$1 as ProviderResult, Relationship$1 as Relationship, RemoteAttestationMessage$1 as RemoteAttestationMessage, RemoteAttestationQuote$1 as RemoteAttestationQuote, Role$1 as Role, Room$1 as Room, RoomMetadata$1 as RoomMetadata, Route$1 as Route, RunEventPayload$1 as RunEventPayload, RuntimeSettings$1 as RuntimeSettings, SOCKET_MESSAGE_TYPE$1 as SOCKET_MESSAGE_TYPE, v2_Semaphore as Semaphore, SendHandlerFunction$1 as SendHandlerFunction, type v2_ServerOwnershipState as ServerOwnershipState, Service$1 as Service, v2_ServiceBuilder as ServiceBuilder, ServiceClassMap$1 as ServiceClassMap, ServiceConfig$1 as ServiceConfig, type v2_ServiceDefinition as ServiceDefinition, ServiceError$1 as ServiceError, ServiceInstance$1 as ServiceInstance, ServiceRegistry$1 as ServiceRegistry, ServiceType$1 as ServiceType, ServiceTypeName$1 as ServiceTypeName, ServiceTypeRegistry$1 as ServiceTypeRegistry, ServiceTypeValue$1 as ServiceTypeValue, Setting$1 as Setting, State$1 as State, StateArray$1 as StateArray, StateObject$1 as StateObject, StateValue$1 as StateValue, TEEMode$1 as TEEMode, TargetInfo$1 as TargetInfo, Task$1 as Task, TaskMetadata$1 as TaskMetadata, TaskWorker$1 as TaskWorker, TeeAgent$1 as TeeAgent, TeePluginConfig$1 as TeePluginConfig, TeeType$1 as TeeType, TeeVendorConfig$1 as TeeVendorConfig, TemplateType$1 as TemplateType, TestCase$1 as TestCase, TestSuite$1 as TestSuite, TextEmbeddingParams$1 as TextEmbeddingParams, TextGenerationParams$1 as TextGenerationParams, TextToSpeechParams$1 as TextToSpeechParams, TokenizeTextParams$1 as TokenizeTextParams, TranscriptionParams$1 as TranscriptionParams, TypedEventHandler$1 as TypedEventHandler, TypedService$1 as TypedService, TypedServiceClass$1 as TypedServiceClass, UUID$1 as UUID, UnifiedMemoryOptions$1 as UnifiedMemoryOptions, UnifiedSearchOptions$1 as UnifiedSearchOptions, VECTOR_DIMS$1 as VECTOR_DIMS, Validator$1 as Validator, VideoProcessingParams$1 as VideoProcessingParams, World$1 as World, WorldPayload$1 as WorldPayload, WorldSettings$1 as WorldSettings, v2_addHeader as addHeader, asUUID$1 as asUUID, v2_booleanFooter as booleanFooter, v2_composeActionExamples as composeActionExamples, v2_composePrompt as composePrompt, v2_composePromptFromState as composePromptFromState, createMessageMemory$1 as createMessageMemory, v2_createService as createService, createServiceError$1 as createServiceError, v2_createSettingFromConfig as createSettingFromConfig, v2_createUniqueUuid as createUniqueUuid, v2_decryptObjectValues as decryptObjectValues, decryptStringValue as decryptSecret, v2_decryptStringValue as decryptStringValue, v2_decryptedCharacter as decryptedCharacter, v2_defineService as defineService, v2_elizaLogger as elizaLogger, v2_encryptObjectValues as encryptObjectValues, v2_encryptStringValue as encryptStringValue, v2_encryptedCharacter as encryptedCharacter, v2_findEntityByName as findEntityByName, v2_findWorldsForOwner as findWorldsForOwner, v2_formatActionNames as formatActionNames, v2_formatActions as formatActions, v2_formatEntities as formatEntities, v2_formatMessages as formatMessages, v2_formatPosts as formatPosts, v2_formatTimestamp as formatTimestamp, v2_getEntityDetails as getEntityDetails, getMemoryText$1 as getMemoryText, v2_getSalt as getSalt, getTypedService$1 as getTypedService, v2_getUserServerRole as getUserServerRole, v2_getWorldSettings as getWorldSettings, v2_imageDescriptionTemplate as imageDescriptionTemplate, v2_initializeOnboarding as initializeOnboarding, isCustomMetadata$1 as isCustomMetadata, isDescriptionMetadata$1 as isDescriptionMetadata, isDocumentMemory$1 as isDocumentMemory, isDocumentMetadata$1 as isDocumentMetadata, isFragmentMemory$1 as isFragmentMemory, isFragmentMetadata$1 as isFragmentMetadata, isMessageMetadata$1 as isMessageMetadata, v2_logger as logger, v2_messageHandlerTemplate as messageHandlerTemplate, v2_parseBooleanFromText as parseBooleanFromText, v2_parseJSONObjectFromText as parseJSONObjectFromText, v2_parseKeyValueXml as parseKeyValueXml, v2_postCreationTemplate as postCreationTemplate, v2_safeReplacer as safeReplacer, v2_saltSettingValue as saltSettingValue, v2_saltWorldSettings as saltWorldSettings, v2_shouldRespondTemplate as shouldRespondTemplate, v2_stringToUuid as stringToUuid, v2_trimTokens as trimTokens, v2_truncateToCompleteSentence as truncateToCompleteSentence, v2_unsaltSettingValue as unsaltSettingValue, v2_unsaltWorldSettings as unsaltWorldSettings, v2_updateWorldSettings as updateWorldSettings, v2_validateUuid as validateUuid };
|
|
3116
|
+
}
|
|
3117
|
+
|
|
3118
|
+
export { type MemoryScope as $, type Action as A, asUUID as B, type Component as C, type ActionExample as D, type Entity as E, ModelType as F, type ServiceTypeRegistry as G, type HandlerCallback as H, type IDatabaseAdapter as I, type ServiceTypeValue as J, type IsValidServiceType as K, type Log as L, type Memory as M, type TypedServiceClass as N, type OnboardingConfig as O, type Participant as P, type ServiceClassMap as Q, type Room as R, type State as S, type Task as T, type UUID as U, type ServiceInstance as V, type World as W, type ServiceRegistry as X, ServiceType as Y, type MemoryTypeAlias as Z, MemoryType as _, type MemoryMetadata as a, type EvaluatorEventPayload as a$, type BaseMetadata as a0, type DocumentMetadata as a1, type FragmentMetadata as a2, type MessageMetadata as a3, type DescriptionMetadata as a4, type CustomMetadata as a5, type MessageExample as a6, type Handler as a7, type Validator as a8, type EvaluationExample as a9, type DeriveKeyAttestationData as aA, type RemoteAttestationMessage as aB, TeeType as aC, type TeeVendorConfig as aD, type TeePluginConfig as aE, type TaskMetadata as aF, type BaseModelParams as aG, type TextGenerationParams as aH, type TextEmbeddingParams as aI, type TokenizeTextParams as aJ, type ImageGenerationParams as aK, type ImageDescriptionParams as aL, type TranscriptionParams as aM, type TextToSpeechParams as aN, type AudioProcessingParams as aO, type VideoProcessingParams as aP, type JSONSchema as aQ, type ObjectGenerationParams as aR, EventType as aS, PlatformPrefix as aT, type EventPayload as aU, type WorldPayload as aV, type EntityPayload as aW, type MessagePayload as aX, type InvokePayload as aY, type RunEventPayload as aZ, type ActionEventPayload as a_, type ProviderResult as aa, type RoomMetadata as ab, type Media as ac, ContentType as ad, type PluginEvents as ae, type ProjectAgent as af, type Project as ag, AgentStatus as ah, type EmbeddingSearchResult as ai, type MemoryRetrievalOptions as aj, type MemorySearchOptions as ak, type MultiRoomMemoryOptions as al, type UnifiedMemoryOptions as am, type UnifiedSearchOptions as an, type KnowledgeItem as ao, KnowledgeScope as ap, CacheKeyPrefix as aq, type DirectoryItem as ar, type ChunkRow as as, type GenerateTextParams as at, type DetokenizeTextParams as au, type TestCase as av, type TestSuite as aw, type TeeAgent as ax, TEEMode as ay, type RemoteAttestationQuote as az, type Relationship as b, updateWorldSettings as b$, type ModelEventPayload as b0, type MessageReceivedHandlerParams as b1, type EventPayloadMap as b2, type EventHandler as b3, SOCKET_MESSAGE_TYPE as b4, type MessageMemory as b5, createMessageMemory as b6, type TypedService as b7, getTypedService as b8, isDocumentMetadata as b9, formatActionNames as bA, formatActions as bB, DatabaseAdapter as bC, findEntityByName as bD, createUniqueUuid as bE, getEntityDetails as bF, formatEntities as bG, logger as bH, elizaLogger as bI, shouldRespondTemplate as bJ, messageHandlerTemplate as bK, postCreationTemplate as bL, booleanFooter as bM, imageDescriptionTemplate as bN, type ServerOwnershipState as bO, getUserServerRole as bP, findWorldsForOwner as bQ, Semaphore as bR, AgentRuntime as bS, decryptStringValue as bT, createSettingFromConfig as bU, getSalt as bV, encryptStringValue as bW, saltSettingValue as bX, unsaltSettingValue as bY, saltWorldSettings as bZ, unsaltWorldSettings as b_, isFragmentMetadata as ba, isMessageMetadata as bb, isDescriptionMetadata as bc, isCustomMetadata as bd, type ServiceError as be, isDocumentMemory as bf, isFragmentMemory as bg, getMemoryText as bh, createServiceError as bi, type StateValue as bj, type StateObject as bk, type StateArray as bl, type EnhancedState as bm, type ComponentData as bn, type EventDataObject as bo, type TypedEventHandler as bp, type DbConnection as bq, type MetadataObject as br, type ServiceConfig as bs, VECTOR_DIMS as bt, type ControlMessage as bu, ServiceBuilder$1 as bv, createService$1 as bw, type ServiceDefinition$1 as bx, defineService$1 as by, composeActionExamples as bz, type Agent as c, getWorldSettings as c0, initializeOnboarding as c1, encryptedCharacter as c2, decryptedCharacter as c3, encryptObjectValues as c4, decryptObjectValues as c5, composePrompt as c6, composePromptFromState as c7, addHeader as c8, formatPosts as c9, formatMessages as ca, formatTimestamp as cb, validateUuid as cc, stringToUuid as cd, truncateToCompleteSentence as ce, parseKeyValueXml as cf, parseJSONObjectFromText as cg, parseBooleanFromText as ch, safeReplacer as ci, trimTokens as cj, ServiceBuilder as ck, createService as cl, type ServiceDefinition as cm, defineService as cn, type IAgentRuntime as d, Role as e, Service as f, type Character as g, type Evaluator as h, type Provider as i, type Plugin as j, type ServiceTypeName as k, type ModelHandler as l, type Route as m, type RuntimeSettings as n, ChannelType 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 Content as v, type Setting as w, type WorldSettings as x, type TemplateType as y, v2 as z };
|