@elizaos/core 1.5.1 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.browser.js +120 -120
- package/dist/browser/index.browser.js.map +5 -21
- package/dist/browser/index.d.ts +3 -1
- package/dist/index.d.ts +2 -3
- package/dist/index.js +1 -5
- package/dist/node/index.d.ts +3 -1
- package/package.json +10 -4
- package/src/__tests__/action-chaining-simple.test.ts +203 -0
- package/src/__tests__/actions.test.ts +218 -0
- package/src/__tests__/buffer.test.ts +337 -0
- package/src/__tests__/character-validation.test.ts +309 -0
- package/src/__tests__/database.test.ts +750 -0
- package/src/__tests__/entities.test.ts +727 -0
- package/src/__tests__/env.test.ts +23 -0
- package/src/__tests__/environment.test.ts +285 -0
- package/src/__tests__/logger-browser-node.test.ts +716 -0
- package/src/__tests__/logger.test.ts +403 -0
- package/src/__tests__/messages.test.ts +196 -0
- package/src/__tests__/mockCharacter.ts +544 -0
- package/src/__tests__/parsing.test.ts +58 -0
- package/src/__tests__/prompts.test.ts +159 -0
- package/src/__tests__/roles.test.ts +331 -0
- package/src/__tests__/runtime-embedding.test.ts +343 -0
- package/src/__tests__/runtime.test.ts +978 -0
- package/src/__tests__/search.test.ts +15 -0
- package/src/__tests__/services-by-type.test.ts +204 -0
- package/src/__tests__/services.test.ts +136 -0
- package/src/__tests__/settings.test.ts +810 -0
- package/src/__tests__/utils.test.ts +1105 -0
- package/src/__tests__/uuid.test.ts +94 -0
- package/src/actions.ts +122 -0
- package/src/database.ts +579 -0
- package/src/entities.ts +406 -0
- package/src/index.browser.ts +48 -0
- package/src/index.node.ts +39 -0
- package/src/index.ts +50 -0
- package/src/logger.ts +527 -0
- package/src/prompts.ts +243 -0
- package/src/roles.ts +85 -0
- package/src/runtime.ts +2514 -0
- package/src/schemas/character.ts +149 -0
- package/src/search.ts +1543 -0
- package/src/sentry/instrument.browser.ts +65 -0
- package/src/sentry/instrument.node.ts +57 -0
- package/src/sentry/instrument.ts +82 -0
- package/src/services.ts +105 -0
- package/src/settings.ts +409 -0
- package/src/test_resources/constants.ts +12 -0
- package/src/test_resources/testSetup.ts +21 -0
- package/src/test_resources/types.ts +22 -0
- package/src/types/agent.ts +112 -0
- package/src/types/browser.ts +145 -0
- package/src/types/components.ts +184 -0
- package/src/types/database.ts +348 -0
- package/src/types/email.ts +162 -0
- package/src/types/environment.ts +129 -0
- package/src/types/events.ts +249 -0
- package/src/types/index.ts +29 -0
- package/src/types/knowledge.ts +65 -0
- package/src/types/lp.ts +124 -0
- package/src/types/memory.ts +228 -0
- package/src/types/message.ts +233 -0
- package/src/types/messaging.ts +57 -0
- package/src/types/model.ts +359 -0
- package/src/types/pdf.ts +77 -0
- package/src/types/plugin.ts +78 -0
- package/src/types/post.ts +271 -0
- package/src/types/primitives.ts +97 -0
- package/src/types/runtime.ts +190 -0
- package/src/types/service.ts +198 -0
- package/src/types/settings.ts +30 -0
- package/src/types/state.ts +60 -0
- package/src/types/task.ts +72 -0
- package/src/types/tee.ts +107 -0
- package/src/types/testing.ts +30 -0
- package/src/types/token.ts +96 -0
- package/src/types/transcription.ts +133 -0
- package/src/types/video.ts +108 -0
- package/src/types/wallet.ts +56 -0
- package/src/types/web-search.ts +146 -0
- package/src/utils/__tests__/buffer.test.ts +80 -0
- package/src/utils/__tests__/environment.test.ts +58 -0
- package/src/utils/__tests__/stringToUuid.test.ts +88 -0
- package/src/utils/buffer.ts +312 -0
- package/src/utils/environment.ts +316 -0
- package/src/utils/server-health.ts +117 -0
- package/src/utils.ts +1076 -0
- package/dist/tsconfig.build.tsbuildinfo +0 -1
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { Service, ServiceType } from './service';
|
|
2
|
+
|
|
3
|
+
export interface EmailAddress {
|
|
4
|
+
email: string;
|
|
5
|
+
name?: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface EmailAttachment {
|
|
9
|
+
filename: string;
|
|
10
|
+
content: Buffer | string;
|
|
11
|
+
contentType?: string;
|
|
12
|
+
contentDisposition?: 'attachment' | 'inline';
|
|
13
|
+
cid?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface EmailMessage {
|
|
17
|
+
from: EmailAddress;
|
|
18
|
+
to: EmailAddress[];
|
|
19
|
+
cc?: EmailAddress[];
|
|
20
|
+
bcc?: EmailAddress[];
|
|
21
|
+
subject: string;
|
|
22
|
+
text?: string;
|
|
23
|
+
html?: string;
|
|
24
|
+
attachments?: EmailAttachment[];
|
|
25
|
+
replyTo?: EmailAddress;
|
|
26
|
+
date?: Date;
|
|
27
|
+
messageId?: string;
|
|
28
|
+
references?: string[];
|
|
29
|
+
inReplyTo?: string;
|
|
30
|
+
priority?: 'high' | 'normal' | 'low';
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface EmailSendOptions {
|
|
34
|
+
retry?: number;
|
|
35
|
+
timeout?: number;
|
|
36
|
+
trackOpens?: boolean;
|
|
37
|
+
trackClicks?: boolean;
|
|
38
|
+
tags?: string[];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface EmailSearchOptions {
|
|
42
|
+
query?: string;
|
|
43
|
+
from?: string;
|
|
44
|
+
to?: string;
|
|
45
|
+
subject?: string;
|
|
46
|
+
folder?: string;
|
|
47
|
+
since?: Date;
|
|
48
|
+
before?: Date;
|
|
49
|
+
limit?: number;
|
|
50
|
+
offset?: number;
|
|
51
|
+
unread?: boolean;
|
|
52
|
+
flagged?: boolean;
|
|
53
|
+
hasAttachments?: boolean;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface EmailFolder {
|
|
57
|
+
name: string;
|
|
58
|
+
path: string;
|
|
59
|
+
type: 'inbox' | 'sent' | 'drafts' | 'trash' | 'spam' | 'custom';
|
|
60
|
+
messageCount?: number;
|
|
61
|
+
unreadCount?: number;
|
|
62
|
+
children?: EmailFolder[];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface EmailAccount {
|
|
66
|
+
email: string;
|
|
67
|
+
name?: string;
|
|
68
|
+
provider?: string;
|
|
69
|
+
folders?: EmailFolder[];
|
|
70
|
+
quotaUsed?: number;
|
|
71
|
+
quotaLimit?: number;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Interface for email services
|
|
76
|
+
*/
|
|
77
|
+
export abstract class IEmailService extends Service {
|
|
78
|
+
static override readonly serviceType = ServiceType.EMAIL;
|
|
79
|
+
|
|
80
|
+
public readonly capabilityDescription = 'Email sending, receiving, and management capabilities';
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Send an email
|
|
84
|
+
* @param message - Email message to send
|
|
85
|
+
* @param options - Send options
|
|
86
|
+
* @returns Promise resolving to message ID
|
|
87
|
+
*/
|
|
88
|
+
abstract sendEmail(message: EmailMessage, options?: EmailSendOptions): Promise<string>;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Get emails from a folder
|
|
92
|
+
* @param options - Search options
|
|
93
|
+
* @returns Promise resolving to array of emails
|
|
94
|
+
*/
|
|
95
|
+
abstract getEmails(options?: EmailSearchOptions): Promise<EmailMessage[]>;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Get a specific email by ID
|
|
99
|
+
* @param messageId - Message ID
|
|
100
|
+
* @returns Promise resolving to email message
|
|
101
|
+
*/
|
|
102
|
+
abstract getEmail(messageId: string): Promise<EmailMessage>;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Delete an email
|
|
106
|
+
* @param messageId - Message ID
|
|
107
|
+
* @returns Promise resolving when deletion completes
|
|
108
|
+
*/
|
|
109
|
+
abstract deleteEmail(messageId: string): Promise<void>;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Mark an email as read/unread
|
|
113
|
+
* @param messageId - Message ID
|
|
114
|
+
* @param read - True to mark as read, false for unread
|
|
115
|
+
* @returns Promise resolving when operation completes
|
|
116
|
+
*/
|
|
117
|
+
abstract markEmailAsRead(messageId: string, read: boolean): Promise<void>;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Flag/unflag an email
|
|
121
|
+
* @param messageId - Message ID
|
|
122
|
+
* @param flagged - True to flag, false to unflag
|
|
123
|
+
* @returns Promise resolving when operation completes
|
|
124
|
+
*/
|
|
125
|
+
abstract flagEmail(messageId: string, flagged: boolean): Promise<void>;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Move email to a different folder
|
|
129
|
+
* @param messageId - Message ID
|
|
130
|
+
* @param folderPath - Destination folder path
|
|
131
|
+
* @returns Promise resolving when move completes
|
|
132
|
+
*/
|
|
133
|
+
abstract moveEmail(messageId: string, folderPath: string): Promise<void>;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Get available folders
|
|
137
|
+
* @returns Promise resolving to array of folders
|
|
138
|
+
*/
|
|
139
|
+
abstract getFolders(): Promise<EmailFolder[]>;
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Create a new folder
|
|
143
|
+
* @param folderName - Name of the folder
|
|
144
|
+
* @param parentPath - Optional parent folder path
|
|
145
|
+
* @returns Promise resolving when folder is created
|
|
146
|
+
*/
|
|
147
|
+
abstract createFolder(folderName: string, parentPath?: string): Promise<void>;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Get account information
|
|
151
|
+
* @returns Promise resolving to account details
|
|
152
|
+
*/
|
|
153
|
+
abstract getAccountInfo(): Promise<EmailAccount>;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Search emails
|
|
157
|
+
* @param query - Search query
|
|
158
|
+
* @param options - Search options
|
|
159
|
+
* @returns Promise resolving to search results
|
|
160
|
+
*/
|
|
161
|
+
abstract searchEmails(query: string, options?: EmailSearchOptions): Promise<EmailMessage[]>;
|
|
162
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import type { Metadata, UUID } from './primitives';
|
|
2
|
+
|
|
3
|
+
export interface Component {
|
|
4
|
+
id: UUID;
|
|
5
|
+
entityId: UUID;
|
|
6
|
+
agentId: UUID;
|
|
7
|
+
roomId: UUID;
|
|
8
|
+
worldId: UUID;
|
|
9
|
+
sourceEntityId: UUID;
|
|
10
|
+
type: string;
|
|
11
|
+
createdAt: number;
|
|
12
|
+
data: Metadata;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Represents a user account
|
|
17
|
+
*/
|
|
18
|
+
export interface Entity {
|
|
19
|
+
/** Unique identifier, optional on creation */
|
|
20
|
+
id?: UUID;
|
|
21
|
+
|
|
22
|
+
/** Names of the entity */
|
|
23
|
+
names: string[];
|
|
24
|
+
|
|
25
|
+
/** Additional metadata */
|
|
26
|
+
metadata: Metadata;
|
|
27
|
+
|
|
28
|
+
/** Agent ID this account is related to, for agents should be themselves */
|
|
29
|
+
agentId: UUID;
|
|
30
|
+
|
|
31
|
+
/** Optional array of components */
|
|
32
|
+
components?: Component[];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Defines roles within a system, typically for access control or permissions, often within a `World`.
|
|
37
|
+
* - `OWNER`: Represents the highest level of control, typically the creator or primary administrator.
|
|
38
|
+
* - `ADMIN`: Represents administrative privileges, usually a subset of owner capabilities.
|
|
39
|
+
* - `NONE`: Indicates no specific role or default, minimal permissions.
|
|
40
|
+
* These roles are often used in `World.metadata.roles` to assign roles to entities.
|
|
41
|
+
*/
|
|
42
|
+
export enum Role {
|
|
43
|
+
OWNER = 'OWNER',
|
|
44
|
+
ADMIN = 'ADMIN',
|
|
45
|
+
NONE = 'NONE',
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export type World = {
|
|
49
|
+
id: UUID;
|
|
50
|
+
name?: string;
|
|
51
|
+
agentId: UUID;
|
|
52
|
+
serverId: string;
|
|
53
|
+
metadata?: {
|
|
54
|
+
ownership?: {
|
|
55
|
+
ownerId: string;
|
|
56
|
+
};
|
|
57
|
+
roles?: {
|
|
58
|
+
[entityId: UUID]: Role;
|
|
59
|
+
};
|
|
60
|
+
[key: string]: unknown;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export enum ChannelType {
|
|
65
|
+
SELF = 'SELF', // Messages to self
|
|
66
|
+
DM = 'DM', // Direct messages between two participants
|
|
67
|
+
GROUP = 'GROUP', // Group messages with multiple participants
|
|
68
|
+
VOICE_DM = 'VOICE_DM', // Voice direct messages
|
|
69
|
+
VOICE_GROUP = 'VOICE_GROUP', // Voice channels with multiple participants
|
|
70
|
+
FEED = 'FEED', // Social media feed
|
|
71
|
+
THREAD = 'THREAD', // Threaded conversation
|
|
72
|
+
WORLD = 'WORLD', // World channel
|
|
73
|
+
FORUM = 'FORUM', // Forum discussion
|
|
74
|
+
// Legacy types - kept for backward compatibility but should be replaced
|
|
75
|
+
API = 'API', // @deprecated - Use DM or GROUP instead
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export type Room = {
|
|
79
|
+
id: UUID;
|
|
80
|
+
name?: string;
|
|
81
|
+
agentId?: UUID;
|
|
82
|
+
source: string;
|
|
83
|
+
type: ChannelType;
|
|
84
|
+
channelId?: string;
|
|
85
|
+
serverId?: string;
|
|
86
|
+
worldId?: UUID;
|
|
87
|
+
metadata?: Metadata;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export type RoomMetadata = {
|
|
91
|
+
[key: string]: unknown;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Room participant with account details
|
|
96
|
+
*/
|
|
97
|
+
export interface Participant {
|
|
98
|
+
/** Unique identifier */
|
|
99
|
+
id: UUID;
|
|
100
|
+
|
|
101
|
+
/** Associated account */
|
|
102
|
+
entity: Entity;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Represents a relationship between users
|
|
107
|
+
*/
|
|
108
|
+
export interface Relationship {
|
|
109
|
+
/** Unique identifier */
|
|
110
|
+
id: UUID;
|
|
111
|
+
|
|
112
|
+
/** First user ID */
|
|
113
|
+
sourceEntityId: UUID;
|
|
114
|
+
|
|
115
|
+
/** Second user ID */
|
|
116
|
+
targetEntityId: UUID;
|
|
117
|
+
|
|
118
|
+
/** Agent ID */
|
|
119
|
+
agentId: UUID;
|
|
120
|
+
|
|
121
|
+
/** Tags for filtering/categorizing relationships */
|
|
122
|
+
tags: string[];
|
|
123
|
+
|
|
124
|
+
/** Additional metadata about the relationship */
|
|
125
|
+
metadata: Metadata;
|
|
126
|
+
|
|
127
|
+
/** Optional creation timestamp */
|
|
128
|
+
createdAt?: string;
|
|
129
|
+
}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import type { HandlerCallback } from './components';
|
|
2
|
+
import type { Entity, Room, World } from './environment';
|
|
3
|
+
import type { Memory } from './memory';
|
|
4
|
+
import type { ModelTypeName } from './model';
|
|
5
|
+
import type { Metadata, UUID } from './primitives';
|
|
6
|
+
import type { IAgentRuntime } from './runtime';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Standard event types across all platforms
|
|
10
|
+
*/
|
|
11
|
+
export enum EventType {
|
|
12
|
+
// World events
|
|
13
|
+
WORLD_JOINED = 'WORLD_JOINED',
|
|
14
|
+
WORLD_CONNECTED = 'WORLD_CONNECTED',
|
|
15
|
+
WORLD_LEFT = 'WORLD_LEFT',
|
|
16
|
+
|
|
17
|
+
// Entity events
|
|
18
|
+
ENTITY_JOINED = 'ENTITY_JOINED',
|
|
19
|
+
ENTITY_LEFT = 'ENTITY_LEFT',
|
|
20
|
+
ENTITY_UPDATED = 'ENTITY_UPDATED',
|
|
21
|
+
|
|
22
|
+
// Room events
|
|
23
|
+
ROOM_JOINED = 'ROOM_JOINED',
|
|
24
|
+
ROOM_LEFT = 'ROOM_LEFT',
|
|
25
|
+
|
|
26
|
+
// Message events
|
|
27
|
+
MESSAGE_RECEIVED = 'MESSAGE_RECEIVED',
|
|
28
|
+
MESSAGE_SENT = 'MESSAGE_SENT',
|
|
29
|
+
MESSAGE_DELETED = 'MESSAGE_DELETED',
|
|
30
|
+
|
|
31
|
+
// Channel events
|
|
32
|
+
CHANNEL_CLEARED = 'CHANNEL_CLEARED',
|
|
33
|
+
|
|
34
|
+
// Voice events
|
|
35
|
+
VOICE_MESSAGE_RECEIVED = 'VOICE_MESSAGE_RECEIVED',
|
|
36
|
+
VOICE_MESSAGE_SENT = 'VOICE_MESSAGE_SENT',
|
|
37
|
+
|
|
38
|
+
// Interaction events
|
|
39
|
+
REACTION_RECEIVED = 'REACTION_RECEIVED',
|
|
40
|
+
POST_GENERATED = 'POST_GENERATED',
|
|
41
|
+
INTERACTION_RECEIVED = 'INTERACTION_RECEIVED',
|
|
42
|
+
|
|
43
|
+
// Run events
|
|
44
|
+
RUN_STARTED = 'RUN_STARTED',
|
|
45
|
+
RUN_ENDED = 'RUN_ENDED',
|
|
46
|
+
RUN_TIMEOUT = 'RUN_TIMEOUT',
|
|
47
|
+
|
|
48
|
+
// Action events
|
|
49
|
+
ACTION_STARTED = 'ACTION_STARTED',
|
|
50
|
+
ACTION_COMPLETED = 'ACTION_COMPLETED',
|
|
51
|
+
|
|
52
|
+
// Evaluator events
|
|
53
|
+
EVALUATOR_STARTED = 'EVALUATOR_STARTED',
|
|
54
|
+
EVALUATOR_COMPLETED = 'EVALUATOR_COMPLETED',
|
|
55
|
+
|
|
56
|
+
// Model events
|
|
57
|
+
MODEL_USED = 'MODEL_USED',
|
|
58
|
+
|
|
59
|
+
// Embedding events
|
|
60
|
+
EMBEDDING_GENERATION_REQUESTED = 'EMBEDDING_GENERATION_REQUESTED',
|
|
61
|
+
EMBEDDING_GENERATION_COMPLETED = 'EMBEDDING_GENERATION_COMPLETED',
|
|
62
|
+
EMBEDDING_GENERATION_FAILED = 'EMBEDDING_GENERATION_FAILED',
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Platform-specific event type prefix
|
|
67
|
+
*/
|
|
68
|
+
export enum PlatformPrefix {
|
|
69
|
+
DISCORD = 'DISCORD',
|
|
70
|
+
TELEGRAM = 'TELEGRAM',
|
|
71
|
+
TWITTER = 'TWITTER',
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Base payload interface for all events
|
|
76
|
+
*/
|
|
77
|
+
export interface EventPayload {
|
|
78
|
+
runtime: IAgentRuntime;
|
|
79
|
+
source: string;
|
|
80
|
+
onComplete?: () => void;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Payload for world-related events
|
|
85
|
+
*/
|
|
86
|
+
export interface WorldPayload extends EventPayload {
|
|
87
|
+
world: World;
|
|
88
|
+
rooms: Room[];
|
|
89
|
+
entities: Entity[];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Payload for entity-related events
|
|
94
|
+
*/
|
|
95
|
+
export interface EntityPayload extends EventPayload {
|
|
96
|
+
entityId: UUID;
|
|
97
|
+
worldId?: UUID;
|
|
98
|
+
roomId?: UUID;
|
|
99
|
+
metadata?: {
|
|
100
|
+
orginalId: string;
|
|
101
|
+
username: string;
|
|
102
|
+
displayName?: string;
|
|
103
|
+
[key: string]: any;
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Payload for reaction-related events
|
|
109
|
+
*/
|
|
110
|
+
export interface MessagePayload extends EventPayload {
|
|
111
|
+
message: Memory;
|
|
112
|
+
callback?: HandlerCallback;
|
|
113
|
+
onComplete?: () => void;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Payload for channel cleared events
|
|
118
|
+
*/
|
|
119
|
+
export interface ChannelClearedPayload extends EventPayload {
|
|
120
|
+
roomId: UUID;
|
|
121
|
+
channelId: string;
|
|
122
|
+
memoryCount: number;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Payload for events that are invoked without a message
|
|
127
|
+
*/
|
|
128
|
+
export interface InvokePayload extends EventPayload {
|
|
129
|
+
worldId: UUID;
|
|
130
|
+
userId: string;
|
|
131
|
+
roomId: UUID;
|
|
132
|
+
callback?: HandlerCallback;
|
|
133
|
+
source: string;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Run event payload type
|
|
138
|
+
*/
|
|
139
|
+
export interface RunEventPayload extends EventPayload {
|
|
140
|
+
runId: UUID;
|
|
141
|
+
messageId: UUID;
|
|
142
|
+
roomId: UUID;
|
|
143
|
+
entityId: UUID;
|
|
144
|
+
startTime: number;
|
|
145
|
+
status: 'started' | 'completed' | 'timeout';
|
|
146
|
+
endTime?: number;
|
|
147
|
+
duration?: number;
|
|
148
|
+
error?: string;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Action event payload type
|
|
153
|
+
*/
|
|
154
|
+
export interface ActionEventPayload extends EventPayload {
|
|
155
|
+
actionId: UUID;
|
|
156
|
+
actionName: string;
|
|
157
|
+
startTime?: number;
|
|
158
|
+
completed?: boolean;
|
|
159
|
+
error?: Error;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Evaluator event payload type
|
|
164
|
+
*/
|
|
165
|
+
export interface EvaluatorEventPayload extends EventPayload {
|
|
166
|
+
evaluatorId: UUID;
|
|
167
|
+
evaluatorName: string;
|
|
168
|
+
startTime?: number;
|
|
169
|
+
completed?: boolean;
|
|
170
|
+
error?: Error;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Model event payload type
|
|
175
|
+
*/
|
|
176
|
+
export interface ModelEventPayload extends EventPayload {
|
|
177
|
+
provider: string;
|
|
178
|
+
type: ModelTypeName;
|
|
179
|
+
prompt: string;
|
|
180
|
+
tokens?: {
|
|
181
|
+
prompt: number;
|
|
182
|
+
completion: number;
|
|
183
|
+
total: number;
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Payload for embedding generation events
|
|
189
|
+
*/
|
|
190
|
+
export interface EmbeddingGenerationPayload extends EventPayload {
|
|
191
|
+
memory: Memory;
|
|
192
|
+
priority?: 'high' | 'normal' | 'low';
|
|
193
|
+
retryCount?: number;
|
|
194
|
+
maxRetries?: number;
|
|
195
|
+
embedding?: number[];
|
|
196
|
+
error?: any;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export type MessageReceivedHandlerParams = {
|
|
200
|
+
runtime: IAgentRuntime;
|
|
201
|
+
message: Memory;
|
|
202
|
+
callback: HandlerCallback;
|
|
203
|
+
onComplete?: () => void;
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Maps event types to their corresponding payload types
|
|
208
|
+
*/
|
|
209
|
+
export interface EventPayloadMap {
|
|
210
|
+
[EventType.WORLD_JOINED]: WorldPayload;
|
|
211
|
+
[EventType.WORLD_CONNECTED]: WorldPayload;
|
|
212
|
+
[EventType.WORLD_LEFT]: WorldPayload;
|
|
213
|
+
[EventType.ENTITY_JOINED]: EntityPayload;
|
|
214
|
+
[EventType.ENTITY_LEFT]: EntityPayload;
|
|
215
|
+
[EventType.ENTITY_UPDATED]: EntityPayload;
|
|
216
|
+
[EventType.MESSAGE_RECEIVED]: MessagePayload;
|
|
217
|
+
[EventType.MESSAGE_SENT]: MessagePayload;
|
|
218
|
+
[EventType.MESSAGE_DELETED]: MessagePayload;
|
|
219
|
+
[EventType.CHANNEL_CLEARED]: ChannelClearedPayload;
|
|
220
|
+
[EventType.REACTION_RECEIVED]: MessagePayload;
|
|
221
|
+
[EventType.POST_GENERATED]: InvokePayload;
|
|
222
|
+
[EventType.INTERACTION_RECEIVED]: MessagePayload;
|
|
223
|
+
[EventType.RUN_STARTED]: RunEventPayload;
|
|
224
|
+
[EventType.RUN_ENDED]: RunEventPayload;
|
|
225
|
+
[EventType.RUN_TIMEOUT]: RunEventPayload;
|
|
226
|
+
[EventType.ACTION_STARTED]: ActionEventPayload;
|
|
227
|
+
[EventType.ACTION_COMPLETED]: ActionEventPayload;
|
|
228
|
+
[EventType.EVALUATOR_STARTED]: EvaluatorEventPayload;
|
|
229
|
+
[EventType.EVALUATOR_COMPLETED]: EvaluatorEventPayload;
|
|
230
|
+
[EventType.MODEL_USED]: ModelEventPayload;
|
|
231
|
+
[EventType.EMBEDDING_GENERATION_REQUESTED]: EmbeddingGenerationPayload;
|
|
232
|
+
[EventType.EMBEDDING_GENERATION_COMPLETED]: EmbeddingGenerationPayload;
|
|
233
|
+
[EventType.EMBEDDING_GENERATION_FAILED]: EmbeddingGenerationPayload;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Event handler function type
|
|
238
|
+
*/
|
|
239
|
+
export type EventHandler<T extends keyof EventPayloadMap> = (
|
|
240
|
+
payload: EventPayloadMap[T]
|
|
241
|
+
) => Promise<void>;
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Defines a more specific type for event handlers, expecting an `Metadata`.
|
|
245
|
+
* This aims to improve upon generic 'any' type handlers, providing a clearer contract
|
|
246
|
+
* for functions that respond to events emitted within the agent runtime (see `emitEvent` in `AgentRuntime`).
|
|
247
|
+
* Handlers can be synchronous or asynchronous.
|
|
248
|
+
*/
|
|
249
|
+
export type TypedEventHandler = (data: Metadata) => Promise<void> | void;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export * from './primitives';
|
|
2
|
+
export * from './state';
|
|
3
|
+
export * from './memory';
|
|
4
|
+
export * from './knowledge';
|
|
5
|
+
export * from './environment';
|
|
6
|
+
export * from './agent';
|
|
7
|
+
export * from './components';
|
|
8
|
+
export * from './plugin';
|
|
9
|
+
export * from './service';
|
|
10
|
+
export * from './model';
|
|
11
|
+
export * from './database';
|
|
12
|
+
export * from './events';
|
|
13
|
+
export * from './task';
|
|
14
|
+
export * from './tee';
|
|
15
|
+
export * from './runtime';
|
|
16
|
+
export * from './token';
|
|
17
|
+
export * from './messaging';
|
|
18
|
+
export * from './testing';
|
|
19
|
+
export * from './settings';
|
|
20
|
+
export * from './wallet';
|
|
21
|
+
export * from './lp';
|
|
22
|
+
export * from './pdf';
|
|
23
|
+
export * from './video';
|
|
24
|
+
export * from './browser';
|
|
25
|
+
export * from './transcription';
|
|
26
|
+
export * from './web-search';
|
|
27
|
+
export * from './email';
|
|
28
|
+
export * from './message';
|
|
29
|
+
export * from './post';
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { MemoryMetadata } from './memory';
|
|
2
|
+
import type { Content, UUID } from './primitives';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Represents a single item of knowledge that can be processed and stored by the agent.
|
|
6
|
+
* Knowledge items consist of content (text and optional structured data) and metadata.
|
|
7
|
+
* These items are typically added to the agent's knowledge base via `AgentRuntime.addKnowledge`
|
|
8
|
+
* and retrieved using `AgentRuntime.getKnowledge`.
|
|
9
|
+
* The `id` is a unique identifier for the knowledge item, often derived from its source or content.
|
|
10
|
+
*/
|
|
11
|
+
export type KnowledgeItem = {
|
|
12
|
+
/** A Universally Unique Identifier for this specific knowledge item. */
|
|
13
|
+
id: UUID;
|
|
14
|
+
/** The actual content of the knowledge item, which must include text and can have other fields. */
|
|
15
|
+
content: Content;
|
|
16
|
+
/** Optional metadata associated with this knowledge item, conforming to `MemoryMetadata`. */
|
|
17
|
+
metadata?: MemoryMetadata;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Defines the scope or visibility of knowledge items within the agent's system.
|
|
22
|
+
* - `SHARED`: Indicates knowledge that is broadly accessible, potentially across different agents or users if the system architecture permits.
|
|
23
|
+
* - `PRIVATE`: Indicates knowledge that is restricted, typically to the specific agent or user context it belongs to.
|
|
24
|
+
* This enum is used to manage access and retrieval of knowledge items, often in conjunction with `AgentRuntime.addKnowledge` or `AgentRuntime.getKnowledge` scopes.
|
|
25
|
+
*/
|
|
26
|
+
export enum KnowledgeScope {
|
|
27
|
+
SHARED = 'shared',
|
|
28
|
+
PRIVATE = 'private',
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Specifies prefixes for keys used in caching mechanisms, helping to namespace cached data.
|
|
33
|
+
* For example, `KNOWLEDGE` might be used to prefix keys for cached knowledge embeddings or processed documents.
|
|
34
|
+
* This helps in organizing the cache and avoiding key collisions.
|
|
35
|
+
* Used internally by caching strategies, potentially within `IDatabaseAdapter` cache methods or runtime caching layers.
|
|
36
|
+
*/
|
|
37
|
+
export enum CacheKeyPrefix {
|
|
38
|
+
KNOWLEDGE = 'knowledge',
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Represents an item within a directory listing, specifically for knowledge loading.
|
|
43
|
+
* When an agent's `Character.knowledge` configuration includes a directory, this type
|
|
44
|
+
* is used to specify the path to that directory and whether its contents should be treated as shared.
|
|
45
|
+
* - `directory`: The path to the directory containing knowledge files.
|
|
46
|
+
* - `shared`: An optional boolean (defaults to false) indicating if the knowledge from this directory is considered shared or private.
|
|
47
|
+
*/
|
|
48
|
+
export interface DirectoryItem {
|
|
49
|
+
/** The path to the directory containing knowledge files. */
|
|
50
|
+
directory: string;
|
|
51
|
+
/** If true, knowledge from this directory is considered shared; otherwise, it's private. Defaults to false. */
|
|
52
|
+
shared?: boolean;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Represents a row structure, typically from a database query related to text chunking or processing.
|
|
57
|
+
* This interface is quite minimal and seems to be a placeholder or a base for more specific chunk-related types.
|
|
58
|
+
* The `id` would be the unique identifier for the chunk.
|
|
59
|
+
* It might be used when splitting large documents into smaller, manageable pieces for embedding or analysis.
|
|
60
|
+
*/
|
|
61
|
+
export interface ChunkRow {
|
|
62
|
+
/** The unique identifier for this chunk of text. */
|
|
63
|
+
id: string;
|
|
64
|
+
// Add other properties if needed
|
|
65
|
+
}
|