@elizaos/core 1.0.0-alpha.57 → 1.0.0-alpha.59
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/bootstrap.d.ts +12 -1
- package/dist/database.d.ts +21 -4
- package/dist/index.d.ts +0 -1
- package/dist/index.js +543 -591
- package/dist/logger.d.ts +2 -1
- package/dist/prompts.d.ts +1 -0
- package/dist/runtime.d.ts +31 -16
- package/dist/services/task.d.ts +3 -3
- package/dist/types.d.ts +337 -116
- package/package.json +2 -2
- package/dist/index.js.map +0 -1
- package/dist/memory.d.ts +0 -114
package/dist/types.d.ts
CHANGED
|
@@ -1,24 +1,28 @@
|
|
|
1
1
|
import type { Readable } from "node:stream";
|
|
2
|
-
/**
|
|
3
|
-
* Represents a UUID string in the format "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
|
4
|
-
*/
|
|
5
2
|
/**
|
|
6
3
|
* Type definition for a Universally Unique Identifier (UUID) using a specific format.
|
|
7
4
|
* @typedef {`${string}-${string}-${string}-${string}-${string}`} UUID
|
|
8
5
|
*/
|
|
9
6
|
export type UUID = `${string}-${string}-${string}-${string}-${string}`;
|
|
10
7
|
/**
|
|
11
|
-
*
|
|
8
|
+
* Helper function to safely cast a string to strongly typed UUID
|
|
9
|
+
* @param id The string UUID to validate and cast
|
|
10
|
+
* @returns The same UUID with branded type information
|
|
11
|
+
*/
|
|
12
|
+
export declare function asUUID(id: string): UUID;
|
|
13
|
+
/**
|
|
14
|
+
* Represents the content of a memory, message, or other information
|
|
12
15
|
*/
|
|
13
16
|
export interface Content {
|
|
17
|
+
/** The agent's internal thought process */
|
|
14
18
|
thought?: string;
|
|
15
19
|
/** The agent's plan for the next message */
|
|
16
20
|
plan?: string;
|
|
17
|
-
/** The main text content */
|
|
21
|
+
/** The main text content visible to users */
|
|
18
22
|
text?: string;
|
|
19
|
-
/** Optional
|
|
23
|
+
/** Optional actions to be performed */
|
|
20
24
|
actions?: string[];
|
|
21
|
-
/** Optional providers
|
|
25
|
+
/** Optional providers to use for context generation */
|
|
22
26
|
providers?: string[];
|
|
23
27
|
/** Optional source/origin of the content */
|
|
24
28
|
source?: string;
|
|
@@ -28,7 +32,10 @@ export interface Content {
|
|
|
28
32
|
inReplyTo?: UUID;
|
|
29
33
|
/** Array of media attachments */
|
|
30
34
|
attachments?: Media[];
|
|
31
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* Additional dynamic properties
|
|
37
|
+
* Use specific properties above instead of this when possible
|
|
38
|
+
*/
|
|
32
39
|
[key: string]: unknown;
|
|
33
40
|
}
|
|
34
41
|
/**
|
|
@@ -40,20 +47,11 @@ export interface ActionExample {
|
|
|
40
47
|
/** Content of the example */
|
|
41
48
|
content: Content;
|
|
42
49
|
}
|
|
43
|
-
|
|
44
|
-
* Example conversation content with user ID
|
|
45
|
-
*/
|
|
46
|
-
export interface ConversationExample {
|
|
47
|
-
/** UUID of user in conversation */
|
|
48
|
-
entityId: UUID;
|
|
49
|
-
/** Content of the conversation */
|
|
50
|
-
content: Content;
|
|
51
|
-
}
|
|
52
|
-
export type ModelType = (typeof ModelTypes)[keyof typeof ModelTypes] | string;
|
|
50
|
+
export type ModelTypeName = (typeof ModelType)[keyof typeof ModelType] | string;
|
|
53
51
|
/**
|
|
54
52
|
* Model size/type classification
|
|
55
53
|
*/
|
|
56
|
-
export declare const
|
|
54
|
+
export declare const ModelType: {
|
|
57
55
|
readonly SMALL: "TEXT_SMALL";
|
|
58
56
|
readonly MEDIUM: "TEXT_LARGE";
|
|
59
57
|
readonly LARGE: "TEXT_LARGE";
|
|
@@ -74,8 +72,8 @@ export declare const ModelTypes: {
|
|
|
74
72
|
readonly OBJECT_SMALL: "OBJECT_SMALL";
|
|
75
73
|
readonly OBJECT_LARGE: "OBJECT_LARGE";
|
|
76
74
|
};
|
|
77
|
-
export type
|
|
78
|
-
export declare const
|
|
75
|
+
export type ServiceTypeName = (typeof ServiceType)[keyof typeof ServiceType];
|
|
76
|
+
export declare const ServiceType: {
|
|
79
77
|
readonly TRANSCRIPTION: "transcription";
|
|
80
78
|
readonly VIDEO: "video";
|
|
81
79
|
readonly BROWSER: "browser";
|
|
@@ -100,6 +98,9 @@ export interface State {
|
|
|
100
98
|
};
|
|
101
99
|
text: string;
|
|
102
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Memory type enumeration for built-in memory types
|
|
103
|
+
*/
|
|
103
104
|
export type MemoryTypeAlias = string;
|
|
104
105
|
export declare enum MemoryType {
|
|
105
106
|
DOCUMENT = "document",
|
|
@@ -108,11 +109,15 @@ export declare enum MemoryType {
|
|
|
108
109
|
DESCRIPTION = "description",
|
|
109
110
|
CUSTOM = "custom"
|
|
110
111
|
}
|
|
112
|
+
export type MemoryScope = "shared" | "private" | "room";
|
|
113
|
+
/**
|
|
114
|
+
* Base interface for all memory metadata types
|
|
115
|
+
*/
|
|
111
116
|
export interface BaseMetadata {
|
|
112
117
|
type: MemoryTypeAlias;
|
|
113
118
|
source?: string;
|
|
114
119
|
sourceId?: UUID;
|
|
115
|
-
scope?:
|
|
120
|
+
scope?: MemoryScope;
|
|
116
121
|
timestamp?: number;
|
|
117
122
|
tags?: string[];
|
|
118
123
|
}
|
|
@@ -131,10 +136,9 @@ export interface DescriptionMetadata extends BaseMetadata {
|
|
|
131
136
|
type: MemoryType.DESCRIPTION;
|
|
132
137
|
}
|
|
133
138
|
export interface CustomMetadata extends BaseMetadata {
|
|
134
|
-
type: MemoryTypeAlias;
|
|
135
139
|
[key: string]: unknown;
|
|
136
140
|
}
|
|
137
|
-
export type MemoryMetadata = DocumentMetadata | FragmentMetadata | MessageMetadata | DescriptionMetadata | CustomMetadata
|
|
141
|
+
export type MemoryMetadata = DocumentMetadata | FragmentMetadata | MessageMetadata | DescriptionMetadata | CustomMetadata;
|
|
138
142
|
/**
|
|
139
143
|
* Represents a stored memory/message
|
|
140
144
|
*/
|
|
@@ -145,21 +149,40 @@ export interface Memory {
|
|
|
145
149
|
entityId: UUID;
|
|
146
150
|
/** Associated agent ID */
|
|
147
151
|
agentId?: UUID;
|
|
148
|
-
/** Optional creation timestamp */
|
|
152
|
+
/** Optional creation timestamp in milliseconds since epoch */
|
|
149
153
|
createdAt?: number;
|
|
150
154
|
/** Memory content */
|
|
151
155
|
content: Content;
|
|
152
|
-
/** Optional embedding vector */
|
|
156
|
+
/** Optional embedding vector for semantic search */
|
|
153
157
|
embedding?: number[];
|
|
154
158
|
/** Associated room ID */
|
|
155
159
|
roomId: UUID;
|
|
156
|
-
/** Whether memory is unique */
|
|
160
|
+
/** Whether memory is unique (used to prevent duplicates) */
|
|
157
161
|
unique?: boolean;
|
|
158
|
-
/** Embedding similarity score */
|
|
162
|
+
/** Embedding similarity score (set when retrieved via search) */
|
|
159
163
|
similarity?: number;
|
|
160
|
-
/** Metadata for the
|
|
164
|
+
/** Metadata for the memory */
|
|
161
165
|
metadata?: MemoryMetadata;
|
|
162
166
|
}
|
|
167
|
+
/**
|
|
168
|
+
* Represents a log entry
|
|
169
|
+
*/
|
|
170
|
+
export interface Log {
|
|
171
|
+
/** Optional unique identifier */
|
|
172
|
+
id?: UUID;
|
|
173
|
+
/** Associated entity ID */
|
|
174
|
+
entityId: UUID;
|
|
175
|
+
/** Associated room ID */
|
|
176
|
+
roomId?: UUID;
|
|
177
|
+
/** Log body */
|
|
178
|
+
body: {
|
|
179
|
+
[key: string]: unknown;
|
|
180
|
+
};
|
|
181
|
+
/** Log type */
|
|
182
|
+
type: string;
|
|
183
|
+
/** Log creation timestamp */
|
|
184
|
+
createdAt: Date;
|
|
185
|
+
}
|
|
163
186
|
/**
|
|
164
187
|
* Example message for demonstration
|
|
165
188
|
*/
|
|
@@ -413,7 +436,6 @@ export interface Plugin {
|
|
|
413
436
|
config?: {
|
|
414
437
|
[key: string]: any;
|
|
415
438
|
};
|
|
416
|
-
memoryManagers?: IMemoryManager[];
|
|
417
439
|
services?: (typeof Service)[];
|
|
418
440
|
componentTypes?: {
|
|
419
441
|
name: string;
|
|
@@ -444,13 +466,6 @@ export interface ProjectAgent {
|
|
|
444
466
|
export interface Project {
|
|
445
467
|
agents: ProjectAgent[];
|
|
446
468
|
}
|
|
447
|
-
export interface ModelConfiguration {
|
|
448
|
-
temperature?: number;
|
|
449
|
-
maxOutputTokens?: number;
|
|
450
|
-
frequency_penalty?: number;
|
|
451
|
-
presence_penalty?: number;
|
|
452
|
-
maxInputTokens?: number;
|
|
453
|
-
}
|
|
454
469
|
export type TemplateType = string | ((options: {
|
|
455
470
|
state: State | {
|
|
456
471
|
[key: string]: string;
|
|
@@ -504,7 +519,13 @@ export interface Character {
|
|
|
504
519
|
post?: string[];
|
|
505
520
|
};
|
|
506
521
|
}
|
|
522
|
+
export declare enum AgentStatus {
|
|
523
|
+
ACTIVE = "active",
|
|
524
|
+
INACTIVE = "inactive"
|
|
525
|
+
}
|
|
507
526
|
export interface Agent extends Character {
|
|
527
|
+
enabled?: boolean;
|
|
528
|
+
status?: AgentStatus;
|
|
508
529
|
createdAt: number;
|
|
509
530
|
updatedAt: number;
|
|
510
531
|
}
|
|
@@ -579,6 +600,14 @@ export interface IDatabaseAdapter {
|
|
|
579
600
|
roomId: UUID;
|
|
580
601
|
type: string;
|
|
581
602
|
}): Promise<void>;
|
|
603
|
+
getLogs(params: {
|
|
604
|
+
entityId: UUID;
|
|
605
|
+
roomId?: UUID;
|
|
606
|
+
type?: string;
|
|
607
|
+
count?: number;
|
|
608
|
+
offset?: number;
|
|
609
|
+
}): Promise<Log[]>;
|
|
610
|
+
deleteLog(logId: UUID): Promise<void>;
|
|
582
611
|
searchMemories(params: {
|
|
583
612
|
embedding: number[];
|
|
584
613
|
match_threshold?: number;
|
|
@@ -588,8 +617,8 @@ export interface IDatabaseAdapter {
|
|
|
588
617
|
tableName: string;
|
|
589
618
|
}): Promise<Memory[]>;
|
|
590
619
|
createMemory(memory: Memory, tableName: string, unique?: boolean): Promise<UUID>;
|
|
591
|
-
|
|
592
|
-
|
|
620
|
+
deleteMemory(memoryId: UUID): Promise<void>;
|
|
621
|
+
deleteAllMemories(roomId: UUID, tableName: string): Promise<void>;
|
|
593
622
|
countMemories(roomId: UUID, unique?: boolean, tableName?: string): Promise<number>;
|
|
594
623
|
createWorld(world: World): Promise<UUID>;
|
|
595
624
|
getWorld(id: UUID): Promise<World | null>;
|
|
@@ -659,51 +688,74 @@ export interface IDatabaseAdapter {
|
|
|
659
688
|
updateTask(id: UUID, task: Partial<Task>): Promise<void>;
|
|
660
689
|
deleteTask(id: UUID): Promise<void>;
|
|
661
690
|
}
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
691
|
+
/**
|
|
692
|
+
* Result interface for embedding similarity searches
|
|
693
|
+
*/
|
|
694
|
+
export interface EmbeddingSearchResult {
|
|
695
|
+
embedding: number[];
|
|
696
|
+
levenshtein_score: number;
|
|
697
|
+
}
|
|
698
|
+
/**
|
|
699
|
+
* Options for memory retrieval operations
|
|
700
|
+
*/
|
|
701
|
+
export interface MemoryRetrievalOptions {
|
|
702
|
+
roomId: UUID;
|
|
703
|
+
count?: number;
|
|
704
|
+
unique?: boolean;
|
|
705
|
+
start?: number;
|
|
706
|
+
end?: number;
|
|
707
|
+
agentId?: UUID;
|
|
708
|
+
}
|
|
709
|
+
/**
|
|
710
|
+
* Options for memory search operations
|
|
711
|
+
*/
|
|
712
|
+
export interface MemorySearchOptions {
|
|
713
|
+
embedding: number[];
|
|
714
|
+
match_threshold?: number;
|
|
715
|
+
count?: number;
|
|
716
|
+
roomId: UUID;
|
|
717
|
+
agentId?: UUID;
|
|
718
|
+
unique?: boolean;
|
|
719
|
+
metadata?: Partial<MemoryMetadata>;
|
|
720
|
+
}
|
|
721
|
+
/**
|
|
722
|
+
* Options for multi-room memory retrieval
|
|
723
|
+
*/
|
|
724
|
+
export interface MultiRoomMemoryOptions {
|
|
725
|
+
roomIds: UUID[];
|
|
726
|
+
limit?: number;
|
|
727
|
+
agentId?: UUID;
|
|
728
|
+
}
|
|
729
|
+
/**
|
|
730
|
+
* Unified options pattern for memory operations
|
|
731
|
+
* Provides a simpler, more consistent interface
|
|
732
|
+
*/
|
|
733
|
+
export interface UnifiedMemoryOptions {
|
|
734
|
+
roomId: UUID;
|
|
735
|
+
limit?: number;
|
|
736
|
+
agentId?: UUID;
|
|
737
|
+
unique?: boolean;
|
|
738
|
+
start?: number;
|
|
739
|
+
end?: number;
|
|
740
|
+
}
|
|
741
|
+
/**
|
|
742
|
+
* Specialized memory search options
|
|
743
|
+
*/
|
|
744
|
+
export interface UnifiedSearchOptions extends UnifiedMemoryOptions {
|
|
745
|
+
embedding: number[];
|
|
746
|
+
similarity?: number;
|
|
694
747
|
}
|
|
695
748
|
export type CacheOptions = {
|
|
696
749
|
expires?: number;
|
|
697
750
|
};
|
|
698
751
|
export interface IAgentRuntime extends IDatabaseAdapter {
|
|
699
752
|
agentId: UUID;
|
|
700
|
-
databaseAdapter: IDatabaseAdapter;
|
|
701
753
|
character: Character;
|
|
702
754
|
providers: Provider[];
|
|
703
755
|
actions: Action[];
|
|
704
756
|
evaluators: Evaluator[];
|
|
705
757
|
plugins: Plugin[];
|
|
706
|
-
services: Map<
|
|
758
|
+
services: Map<ServiceTypeName, Service>;
|
|
707
759
|
events: Map<string, ((params: any) => Promise<void>)[]>;
|
|
708
760
|
fetch?: typeof fetch | null;
|
|
709
761
|
routes: Route[];
|
|
@@ -715,9 +767,8 @@ export interface IAgentRuntime extends IDatabaseAdapter {
|
|
|
715
767
|
overlap: number;
|
|
716
768
|
modelContextSize: number;
|
|
717
769
|
}): Promise<void>;
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
getAllServices(): Map<ServiceType, Service>;
|
|
770
|
+
getService<T extends Service>(service: ServiceTypeName | string): T | null;
|
|
771
|
+
getAllServices(): Map<ServiceTypeName, Service>;
|
|
721
772
|
registerService(service: typeof Service): void;
|
|
722
773
|
registerDatabaseAdapter(adapter: IDatabaseAdapter): void;
|
|
723
774
|
setSetting(key: string, value: string | boolean | null | any, secret: boolean): void;
|
|
@@ -751,15 +802,16 @@ export interface IAgentRuntime extends IDatabaseAdapter {
|
|
|
751
802
|
* @param {ModelParamsMap[T] | any} params - The parameters for the model, typed based on model type
|
|
752
803
|
* @returns {Promise<R>} - The model result, typed based on the provided generic type parameter
|
|
753
804
|
*/
|
|
754
|
-
useModel<T extends
|
|
755
|
-
registerModel(modelType:
|
|
756
|
-
getModel(modelType:
|
|
805
|
+
useModel<T extends ModelTypeName, R = ModelResultMap[T]>(modelType: T, params: Omit<ModelParamsMap[T], "runtime"> | any): Promise<R>;
|
|
806
|
+
registerModel(modelType: ModelTypeName | string, handler: (params: any) => Promise<any>): void;
|
|
807
|
+
getModel(modelType: ModelTypeName | string): ((runtime: IAgentRuntime, params: any) => Promise<any>) | undefined;
|
|
757
808
|
registerEvent(event: string, handler: (params: any) => Promise<void>): void;
|
|
758
809
|
getEvent(event: string): ((params: any) => Promise<void>)[] | undefined;
|
|
759
810
|
emitEvent(event: string | string[], params: any): Promise<void>;
|
|
760
811
|
registerTaskWorker(taskHandler: TaskWorker): void;
|
|
761
812
|
getTaskWorker(name: string): TaskWorker | undefined;
|
|
762
813
|
stop(): Promise<void>;
|
|
814
|
+
addEmbeddingToMemory(memory: Memory): Promise<Memory>;
|
|
763
815
|
}
|
|
764
816
|
export type KnowledgeItem = {
|
|
765
817
|
id: UUID;
|
|
@@ -782,7 +834,7 @@ export interface ChunkRow {
|
|
|
782
834
|
export type GenerateTextParams = {
|
|
783
835
|
runtime: IAgentRuntime;
|
|
784
836
|
prompt: string;
|
|
785
|
-
modelType:
|
|
837
|
+
modelType: ModelTypeName;
|
|
786
838
|
maxTokens?: number;
|
|
787
839
|
temperature?: number;
|
|
788
840
|
frequencyPenalty?: number;
|
|
@@ -791,11 +843,11 @@ export type GenerateTextParams = {
|
|
|
791
843
|
};
|
|
792
844
|
export interface TokenizeTextParams {
|
|
793
845
|
prompt: string;
|
|
794
|
-
modelType:
|
|
846
|
+
modelType: ModelTypeName;
|
|
795
847
|
}
|
|
796
848
|
export interface DetokenizeTextParams {
|
|
797
849
|
tokens: number[];
|
|
798
|
-
modelType:
|
|
850
|
+
modelType: ModelTypeName;
|
|
799
851
|
}
|
|
800
852
|
export interface IVideoService extends Service {
|
|
801
853
|
isVideoUrl(url: string): boolean;
|
|
@@ -1007,7 +1059,7 @@ export interface TokenizeTextParams extends BaseModelParams {
|
|
|
1007
1059
|
/** The text to tokenize */
|
|
1008
1060
|
prompt: string;
|
|
1009
1061
|
/** The model type to use for tokenization */
|
|
1010
|
-
modelType:
|
|
1062
|
+
modelType: ModelTypeName;
|
|
1011
1063
|
}
|
|
1012
1064
|
/**
|
|
1013
1065
|
* Parameters for text detokenization models
|
|
@@ -1016,7 +1068,7 @@ export interface DetokenizeTextParams extends BaseModelParams {
|
|
|
1016
1068
|
/** The tokens to convert back to text */
|
|
1017
1069
|
tokens: number[];
|
|
1018
1070
|
/** The model type to use for detokenization */
|
|
1019
|
-
modelType:
|
|
1071
|
+
modelType: ModelTypeName;
|
|
1020
1072
|
}
|
|
1021
1073
|
/**
|
|
1022
1074
|
* Parameters for image generation models
|
|
@@ -1100,7 +1152,7 @@ export interface ObjectGenerationParams<T = any> extends BaseModelParams {
|
|
|
1100
1152
|
/** For enum type, the allowed values */
|
|
1101
1153
|
enumValues?: string[];
|
|
1102
1154
|
/** Model type to use */
|
|
1103
|
-
modelType?:
|
|
1155
|
+
modelType?: ModelTypeName;
|
|
1104
1156
|
/** Model temperature (0.0 to 1.0) */
|
|
1105
1157
|
temperature?: number;
|
|
1106
1158
|
/** Sequences that should stop generation */
|
|
@@ -1110,47 +1162,47 @@ export interface ObjectGenerationParams<T = any> extends BaseModelParams {
|
|
|
1110
1162
|
* Map of model types to their parameter types
|
|
1111
1163
|
*/
|
|
1112
1164
|
export interface ModelParamsMap {
|
|
1113
|
-
[
|
|
1114
|
-
[
|
|
1115
|
-
[
|
|
1116
|
-
[
|
|
1117
|
-
[
|
|
1118
|
-
[
|
|
1119
|
-
[
|
|
1120
|
-
[
|
|
1121
|
-
[
|
|
1122
|
-
[
|
|
1123
|
-
[
|
|
1124
|
-
[
|
|
1125
|
-
[
|
|
1126
|
-
[
|
|
1127
|
-
[
|
|
1165
|
+
[ModelType.TEXT_SMALL]: TextGenerationParams;
|
|
1166
|
+
[ModelType.TEXT_LARGE]: TextGenerationParams;
|
|
1167
|
+
[ModelType.TEXT_EMBEDDING]: TextEmbeddingParams | string | null;
|
|
1168
|
+
[ModelType.TEXT_TOKENIZER_ENCODE]: TokenizeTextParams;
|
|
1169
|
+
[ModelType.TEXT_TOKENIZER_DECODE]: DetokenizeTextParams;
|
|
1170
|
+
[ModelType.TEXT_REASONING_SMALL]: TextGenerationParams;
|
|
1171
|
+
[ModelType.TEXT_REASONING_LARGE]: TextGenerationParams;
|
|
1172
|
+
[ModelType.IMAGE]: ImageGenerationParams;
|
|
1173
|
+
[ModelType.IMAGE_DESCRIPTION]: ImageDescriptionParams | string;
|
|
1174
|
+
[ModelType.TRANSCRIPTION]: TranscriptionParams | Buffer | string;
|
|
1175
|
+
[ModelType.TEXT_TO_SPEECH]: TextToSpeechParams | string;
|
|
1176
|
+
[ModelType.AUDIO]: AudioProcessingParams;
|
|
1177
|
+
[ModelType.VIDEO]: VideoProcessingParams;
|
|
1178
|
+
[ModelType.OBJECT_SMALL]: ObjectGenerationParams<any>;
|
|
1179
|
+
[ModelType.OBJECT_LARGE]: ObjectGenerationParams<any>;
|
|
1128
1180
|
[key: string]: BaseModelParams | any;
|
|
1129
1181
|
}
|
|
1130
1182
|
/**
|
|
1131
1183
|
* Map of model types to their return value types
|
|
1132
1184
|
*/
|
|
1133
1185
|
export interface ModelResultMap {
|
|
1134
|
-
[
|
|
1135
|
-
[
|
|
1136
|
-
[
|
|
1137
|
-
[
|
|
1138
|
-
[
|
|
1139
|
-
[
|
|
1140
|
-
[
|
|
1141
|
-
[
|
|
1186
|
+
[ModelType.TEXT_SMALL]: string;
|
|
1187
|
+
[ModelType.TEXT_LARGE]: string;
|
|
1188
|
+
[ModelType.TEXT_EMBEDDING]: number[];
|
|
1189
|
+
[ModelType.TEXT_TOKENIZER_ENCODE]: number[];
|
|
1190
|
+
[ModelType.TEXT_TOKENIZER_DECODE]: string;
|
|
1191
|
+
[ModelType.TEXT_REASONING_SMALL]: string;
|
|
1192
|
+
[ModelType.TEXT_REASONING_LARGE]: string;
|
|
1193
|
+
[ModelType.IMAGE]: {
|
|
1142
1194
|
url: string;
|
|
1143
1195
|
}[];
|
|
1144
|
-
[
|
|
1196
|
+
[ModelType.IMAGE_DESCRIPTION]: {
|
|
1145
1197
|
title: string;
|
|
1146
1198
|
description: string;
|
|
1147
1199
|
};
|
|
1148
|
-
[
|
|
1149
|
-
[
|
|
1150
|
-
[
|
|
1151
|
-
[
|
|
1152
|
-
[
|
|
1153
|
-
[
|
|
1200
|
+
[ModelType.TRANSCRIPTION]: string;
|
|
1201
|
+
[ModelType.TEXT_TO_SPEECH]: Readable | Buffer;
|
|
1202
|
+
[ModelType.AUDIO]: any;
|
|
1203
|
+
[ModelType.VIDEO]: any;
|
|
1204
|
+
[ModelType.OBJECT_SMALL]: any;
|
|
1205
|
+
[ModelType.OBJECT_LARGE]: any;
|
|
1154
1206
|
[key: string]: any;
|
|
1155
1207
|
}
|
|
1156
1208
|
/**
|
|
@@ -1224,6 +1276,15 @@ export interface MessagePayload extends EventPayload {
|
|
|
1224
1276
|
message: Memory;
|
|
1225
1277
|
callback?: HandlerCallback;
|
|
1226
1278
|
}
|
|
1279
|
+
/**
|
|
1280
|
+
* Payload for events that are invoked without a message
|
|
1281
|
+
*/
|
|
1282
|
+
export interface InvokePayload extends EventPayload {
|
|
1283
|
+
worldId: UUID;
|
|
1284
|
+
userId: string;
|
|
1285
|
+
roomId: UUID;
|
|
1286
|
+
callback?: HandlerCallback;
|
|
1287
|
+
}
|
|
1227
1288
|
/**
|
|
1228
1289
|
* Run event payload type
|
|
1229
1290
|
*/
|
|
@@ -1258,6 +1319,18 @@ export interface EvaluatorEventPayload extends EventPayload {
|
|
|
1258
1319
|
completed?: boolean;
|
|
1259
1320
|
error?: Error;
|
|
1260
1321
|
}
|
|
1322
|
+
/**
|
|
1323
|
+
* Represents the parameters for a message received handler.
|
|
1324
|
+
* @typedef {Object} MessageReceivedHandlerParams
|
|
1325
|
+
* @property {IAgentRuntime} runtime - The agent runtime associated with the message.
|
|
1326
|
+
* @property {Memory} message - The message received.
|
|
1327
|
+
* @property {HandlerCallback} callback - The callback function to be executed after handling the message.
|
|
1328
|
+
*/
|
|
1329
|
+
export type MessageReceivedHandlerParams = {
|
|
1330
|
+
runtime: IAgentRuntime;
|
|
1331
|
+
message: Memory;
|
|
1332
|
+
callback: HandlerCallback;
|
|
1333
|
+
};
|
|
1261
1334
|
/**
|
|
1262
1335
|
* Maps event types to their corresponding payload types
|
|
1263
1336
|
*/
|
|
@@ -1271,7 +1344,7 @@ export interface EventPayloadMap {
|
|
|
1271
1344
|
[EventTypes.MESSAGE_RECEIVED]: MessagePayload;
|
|
1272
1345
|
[EventTypes.MESSAGE_SENT]: MessagePayload;
|
|
1273
1346
|
[EventTypes.REACTION_RECEIVED]: MessagePayload;
|
|
1274
|
-
[EventTypes.POST_GENERATED]:
|
|
1347
|
+
[EventTypes.POST_GENERATED]: InvokePayload;
|
|
1275
1348
|
[EventTypes.INTERACTION_RECEIVED]: MessagePayload;
|
|
1276
1349
|
[EventTypes.RUN_STARTED]: RunEventPayload;
|
|
1277
1350
|
[EventTypes.RUN_ENDED]: RunEventPayload;
|
|
@@ -1292,3 +1365,151 @@ export declare enum SOCKET_MESSAGE_TYPE {
|
|
|
1292
1365
|
ROOM_JOINING = 1,
|
|
1293
1366
|
SEND_MESSAGE = 2
|
|
1294
1367
|
}
|
|
1368
|
+
/**
|
|
1369
|
+
* Specialized memory type for messages with enhanced type checking
|
|
1370
|
+
*/
|
|
1371
|
+
export interface MessageMemory extends Memory {
|
|
1372
|
+
metadata: MessageMetadata;
|
|
1373
|
+
content: Content & {
|
|
1374
|
+
text: string;
|
|
1375
|
+
};
|
|
1376
|
+
}
|
|
1377
|
+
/**
|
|
1378
|
+
* Factory function to create a new message memory with proper defaults
|
|
1379
|
+
*/
|
|
1380
|
+
export declare function createMessageMemory(params: {
|
|
1381
|
+
id?: UUID;
|
|
1382
|
+
entityId: UUID;
|
|
1383
|
+
agentId?: UUID;
|
|
1384
|
+
roomId: UUID;
|
|
1385
|
+
content: Content & {
|
|
1386
|
+
text: string;
|
|
1387
|
+
};
|
|
1388
|
+
embedding?: number[];
|
|
1389
|
+
}): MessageMemory;
|
|
1390
|
+
/**
|
|
1391
|
+
* Generic service interface that provides better type checking for services
|
|
1392
|
+
* @template ConfigType The configuration type for this service
|
|
1393
|
+
* @template ResultType The result type returned by the service operations
|
|
1394
|
+
*/
|
|
1395
|
+
export interface TypedService<ConfigType = unknown, ResultType = unknown> extends Service {
|
|
1396
|
+
/**
|
|
1397
|
+
* The configuration for this service instance
|
|
1398
|
+
*/
|
|
1399
|
+
config: ConfigType;
|
|
1400
|
+
/**
|
|
1401
|
+
* Process an input with this service
|
|
1402
|
+
* @param input The input to process
|
|
1403
|
+
* @returns A promise resolving to the result
|
|
1404
|
+
*/
|
|
1405
|
+
process(input: unknown): Promise<ResultType>;
|
|
1406
|
+
}
|
|
1407
|
+
/**
|
|
1408
|
+
* Generic factory function to create a typed service instance
|
|
1409
|
+
* @param runtime The agent runtime
|
|
1410
|
+
* @param serviceType The type of service to get
|
|
1411
|
+
* @returns The service instance or null if not available
|
|
1412
|
+
*/
|
|
1413
|
+
export declare function getTypedService<T extends TypedService<any, any>>(runtime: IAgentRuntime, serviceType: ServiceTypeName): T | null;
|
|
1414
|
+
/**
|
|
1415
|
+
* Type guard to check if a memory metadata is a DocumentMetadata
|
|
1416
|
+
* @param metadata The metadata to check
|
|
1417
|
+
* @returns True if the metadata is a DocumentMetadata
|
|
1418
|
+
*/
|
|
1419
|
+
export declare function isDocumentMetadata(metadata: MemoryMetadata): metadata is DocumentMetadata;
|
|
1420
|
+
/**
|
|
1421
|
+
* Type guard to check if a memory metadata is a FragmentMetadata
|
|
1422
|
+
* @param metadata The metadata to check
|
|
1423
|
+
* @returns True if the metadata is a FragmentMetadata
|
|
1424
|
+
*/
|
|
1425
|
+
export declare function isFragmentMetadata(metadata: MemoryMetadata): metadata is FragmentMetadata;
|
|
1426
|
+
/**
|
|
1427
|
+
* Type guard to check if a memory metadata is a MessageMetadata
|
|
1428
|
+
* @param metadata The metadata to check
|
|
1429
|
+
* @returns True if the metadata is a MessageMetadata
|
|
1430
|
+
*/
|
|
1431
|
+
export declare function isMessageMetadata(metadata: MemoryMetadata): metadata is MessageMetadata;
|
|
1432
|
+
/**
|
|
1433
|
+
* Type guard to check if a memory metadata is a DescriptionMetadata
|
|
1434
|
+
* @param metadata The metadata to check
|
|
1435
|
+
* @returns True if the metadata is a DescriptionMetadata
|
|
1436
|
+
*/
|
|
1437
|
+
export declare function isDescriptionMetadata(metadata: MemoryMetadata): metadata is DescriptionMetadata;
|
|
1438
|
+
/**
|
|
1439
|
+
* Type guard to check if a memory metadata is a CustomMetadata
|
|
1440
|
+
* @param metadata The metadata to check
|
|
1441
|
+
* @returns True if the metadata is a CustomMetadata
|
|
1442
|
+
*/
|
|
1443
|
+
export declare function isCustomMetadata(metadata: MemoryMetadata): metadata is CustomMetadata;
|
|
1444
|
+
/**
|
|
1445
|
+
* Standardized service error type for consistent error handling
|
|
1446
|
+
*/
|
|
1447
|
+
export interface ServiceError {
|
|
1448
|
+
code: string;
|
|
1449
|
+
message: string;
|
|
1450
|
+
details?: unknown;
|
|
1451
|
+
cause?: Error;
|
|
1452
|
+
}
|
|
1453
|
+
/**
|
|
1454
|
+
* Type-safe helper for accessing the video service
|
|
1455
|
+
*/
|
|
1456
|
+
export declare function getVideoService(runtime: IAgentRuntime): IVideoService | null;
|
|
1457
|
+
/**
|
|
1458
|
+
* Type-safe helper for accessing the browser service
|
|
1459
|
+
*/
|
|
1460
|
+
export declare function getBrowserService(runtime: IAgentRuntime): IBrowserService | null;
|
|
1461
|
+
/**
|
|
1462
|
+
* Type-safe helper for accessing the PDF service
|
|
1463
|
+
*/
|
|
1464
|
+
export declare function getPdfService(runtime: IAgentRuntime): IPdfService | null;
|
|
1465
|
+
/**
|
|
1466
|
+
* Type-safe helper for accessing the file service
|
|
1467
|
+
*/
|
|
1468
|
+
export declare function getFileService(runtime: IAgentRuntime): IFileService | null;
|
|
1469
|
+
/**
|
|
1470
|
+
* Memory type guard for document memories
|
|
1471
|
+
*/
|
|
1472
|
+
export declare function isDocumentMemory(memory: Memory): memory is Memory & {
|
|
1473
|
+
metadata: DocumentMetadata;
|
|
1474
|
+
};
|
|
1475
|
+
/**
|
|
1476
|
+
* Memory type guard for fragment memories
|
|
1477
|
+
*/
|
|
1478
|
+
export declare function isFragmentMemory(memory: Memory): memory is Memory & {
|
|
1479
|
+
metadata: FragmentMetadata;
|
|
1480
|
+
};
|
|
1481
|
+
/**
|
|
1482
|
+
* Safely access the text content of a memory
|
|
1483
|
+
* @param memory The memory to extract text from
|
|
1484
|
+
* @param defaultValue Optional default value if no text is found
|
|
1485
|
+
* @returns The text content or default value
|
|
1486
|
+
*/
|
|
1487
|
+
export declare function getMemoryText(memory: Memory, defaultValue?: string): string;
|
|
1488
|
+
/**
|
|
1489
|
+
* Safely create a ServiceError from any caught error
|
|
1490
|
+
*/
|
|
1491
|
+
export declare function createServiceError(error: unknown, code?: string): ServiceError;
|
|
1492
|
+
/**
|
|
1493
|
+
* Replace 'any' types with more specific types
|
|
1494
|
+
*/
|
|
1495
|
+
export type StateValue = string | number | boolean | null | StateObject | StateArray;
|
|
1496
|
+
export interface StateObject {
|
|
1497
|
+
[key: string]: StateValue;
|
|
1498
|
+
}
|
|
1499
|
+
export type StateArray = StateValue[];
|
|
1500
|
+
/**
|
|
1501
|
+
* Enhanced State interface with more specific types
|
|
1502
|
+
*/
|
|
1503
|
+
export interface EnhancedState {
|
|
1504
|
+
values: StateObject;
|
|
1505
|
+
data: StateObject;
|
|
1506
|
+
text: string;
|
|
1507
|
+
[key: string]: StateValue;
|
|
1508
|
+
}
|
|
1509
|
+
export type ComponentData = Record<string, unknown>;
|
|
1510
|
+
export type EventDataObject = Record<string, unknown>;
|
|
1511
|
+
export type TypedEventHandler = (data: EventDataObject) => Promise<void> | void;
|
|
1512
|
+
export type DbConnection = unknown;
|
|
1513
|
+
export type MetadataObject = Record<string, unknown>;
|
|
1514
|
+
export type ModelHandler = (runtime: IAgentRuntime, params: Record<string, unknown>) => Promise<unknown>;
|
|
1515
|
+
export type ServiceConfig = Record<string, unknown>;
|