@elizaos/core 1.5.4 → 1.5.5

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.
Files changed (90) hide show
  1. package/README.md +0 -15
  2. package/dist/index.d.ts +4886 -3
  3. package/dist/index.js +5287 -4
  4. package/package.json +21 -39
  5. package/dist/browser/index.browser.js +0 -1109
  6. package/dist/browser/index.browser.js.map +0 -707
  7. package/dist/browser/index.d.ts +0 -3
  8. package/dist/node/index.d.ts +0 -3
  9. package/dist/node/index.node.js +0 -74530
  10. package/dist/node/index.node.js.map +0 -1027
  11. package/src/__tests__/action-chaining-simple.test.ts +0 -203
  12. package/src/__tests__/actions.test.ts +0 -218
  13. package/src/__tests__/buffer.test.ts +0 -337
  14. package/src/__tests__/character-validation.test.ts +0 -309
  15. package/src/__tests__/database.test.ts +0 -750
  16. package/src/__tests__/entities.test.ts +0 -727
  17. package/src/__tests__/env.test.ts +0 -23
  18. package/src/__tests__/environment.test.ts +0 -285
  19. package/src/__tests__/logger-browser-node.test.ts +0 -716
  20. package/src/__tests__/logger.test.ts +0 -403
  21. package/src/__tests__/messages.test.ts +0 -196
  22. package/src/__tests__/mockCharacter.ts +0 -544
  23. package/src/__tests__/parsing.test.ts +0 -58
  24. package/src/__tests__/prompts.test.ts +0 -159
  25. package/src/__tests__/roles.test.ts +0 -331
  26. package/src/__tests__/runtime-embedding.test.ts +0 -343
  27. package/src/__tests__/runtime.test.ts +0 -978
  28. package/src/__tests__/search.test.ts +0 -15
  29. package/src/__tests__/services-by-type.test.ts +0 -204
  30. package/src/__tests__/services.test.ts +0 -136
  31. package/src/__tests__/settings.test.ts +0 -810
  32. package/src/__tests__/utils.test.ts +0 -1105
  33. package/src/__tests__/uuid.test.ts +0 -94
  34. package/src/actions.ts +0 -122
  35. package/src/database.ts +0 -579
  36. package/src/entities.ts +0 -406
  37. package/src/index.browser.ts +0 -48
  38. package/src/index.node.ts +0 -39
  39. package/src/index.ts +0 -50
  40. package/src/logger.ts +0 -527
  41. package/src/prompts.ts +0 -243
  42. package/src/roles.ts +0 -85
  43. package/src/runtime.ts +0 -2514
  44. package/src/schemas/character.ts +0 -149
  45. package/src/search.ts +0 -1543
  46. package/src/sentry/instrument.browser.ts +0 -65
  47. package/src/sentry/instrument.node.ts +0 -57
  48. package/src/sentry/instrument.ts +0 -82
  49. package/src/services.ts +0 -105
  50. package/src/settings.ts +0 -409
  51. package/src/test_resources/constants.ts +0 -12
  52. package/src/test_resources/testSetup.ts +0 -21
  53. package/src/test_resources/types.ts +0 -22
  54. package/src/types/agent.ts +0 -112
  55. package/src/types/browser.ts +0 -145
  56. package/src/types/components.ts +0 -184
  57. package/src/types/database.ts +0 -348
  58. package/src/types/email.ts +0 -162
  59. package/src/types/environment.ts +0 -129
  60. package/src/types/events.ts +0 -249
  61. package/src/types/index.ts +0 -29
  62. package/src/types/knowledge.ts +0 -65
  63. package/src/types/lp.ts +0 -124
  64. package/src/types/memory.ts +0 -228
  65. package/src/types/message.ts +0 -233
  66. package/src/types/messaging.ts +0 -57
  67. package/src/types/model.ts +0 -359
  68. package/src/types/pdf.ts +0 -77
  69. package/src/types/plugin.ts +0 -78
  70. package/src/types/post.ts +0 -271
  71. package/src/types/primitives.ts +0 -97
  72. package/src/types/runtime.ts +0 -190
  73. package/src/types/service.ts +0 -198
  74. package/src/types/settings.ts +0 -30
  75. package/src/types/state.ts +0 -60
  76. package/src/types/task.ts +0 -72
  77. package/src/types/tee.ts +0 -107
  78. package/src/types/testing.ts +0 -30
  79. package/src/types/token.ts +0 -96
  80. package/src/types/transcription.ts +0 -133
  81. package/src/types/video.ts +0 -108
  82. package/src/types/wallet.ts +0 -56
  83. package/src/types/web-search.ts +0 -146
  84. package/src/utils/__tests__/buffer.test.ts +0 -80
  85. package/src/utils/__tests__/environment.test.ts +0 -58
  86. package/src/utils/__tests__/stringToUuid.test.ts +0 -88
  87. package/src/utils/buffer.ts +0 -312
  88. package/src/utils/environment.ts +0 -316
  89. package/src/utils/server-health.ts +0 -117
  90. package/src/utils.ts +0 -1076
package/src/types/post.ts DELETED
@@ -1,271 +0,0 @@
1
- import { Service, ServiceType } from './service';
2
- import type { UUID } from './primitives';
3
-
4
- export interface PostMedia {
5
- id: UUID;
6
- url: string;
7
- type: 'image' | 'video' | 'audio' | 'document';
8
- mimeType: string;
9
- size: number;
10
- width?: number;
11
- height?: number;
12
- duration?: number;
13
- thumbnail?: string;
14
- description?: string;
15
- altText?: string;
16
- }
17
-
18
- export interface PostLocation {
19
- name: string;
20
- address?: string;
21
- coordinates?: {
22
- latitude: number;
23
- longitude: number;
24
- };
25
- placeId?: string;
26
- }
27
-
28
- export interface PostAuthor {
29
- id: UUID;
30
- username: string;
31
- displayName: string;
32
- avatar?: string;
33
- verified?: boolean;
34
- followerCount?: number;
35
- followingCount?: number;
36
- bio?: string;
37
- website?: string;
38
- }
39
-
40
- export interface PostEngagement {
41
- likes: number;
42
- shares: number;
43
- comments: number;
44
- views?: number;
45
- hasLiked: boolean;
46
- hasShared: boolean;
47
- hasCommented: boolean;
48
- hasSaved: boolean;
49
- }
50
-
51
- export interface PostContent {
52
- text?: string;
53
- html?: string;
54
- media?: PostMedia[];
55
- location?: PostLocation;
56
- tags?: string[];
57
- mentions?: UUID[];
58
- links?: Array<{
59
- url: string;
60
- title?: string;
61
- description?: string;
62
- image?: string;
63
- }>;
64
- poll?: {
65
- question: string;
66
- options: Array<{
67
- text: string;
68
- votes: number;
69
- }>;
70
- expiresAt?: Date;
71
- multipleChoice?: boolean;
72
- };
73
- }
74
-
75
- export interface PostInfo {
76
- id: UUID;
77
- author: PostAuthor;
78
- content: PostContent;
79
- platform: string;
80
- platformId: string;
81
- url: string;
82
- createdAt: Date;
83
- editedAt?: Date;
84
- scheduledAt?: Date;
85
- engagement: PostEngagement;
86
- visibility: 'public' | 'private' | 'followers' | 'friends' | 'unlisted';
87
- replyTo?: UUID;
88
- thread?: {
89
- id: UUID;
90
- position: number;
91
- total: number;
92
- };
93
- crossPosted?: Array<{
94
- platform: string;
95
- platformId: string;
96
- url: string;
97
- }>;
98
- }
99
-
100
- export interface PostCreateOptions {
101
- platforms?: string[];
102
- scheduledAt?: Date;
103
- visibility?: PostInfo['visibility'];
104
- replyTo?: UUID;
105
- thread?: boolean;
106
- location?: PostLocation;
107
- tags?: string[];
108
- mentions?: UUID[];
109
- enableComments?: boolean;
110
- enableSharing?: boolean;
111
- contentWarning?: string;
112
- sensitive?: boolean;
113
- }
114
-
115
- export interface PostSearchOptions {
116
- query?: string;
117
- author?: UUID;
118
- platform?: string;
119
- tags?: string[];
120
- mentions?: UUID[];
121
- since?: Date;
122
- before?: Date;
123
- limit?: number;
124
- offset?: number;
125
- hasMedia?: boolean;
126
- hasLocation?: boolean;
127
- visibility?: PostInfo['visibility'];
128
- sortBy?: 'date' | 'engagement' | 'relevance';
129
- }
130
-
131
- export interface PostAnalytics {
132
- postId: UUID;
133
- platform: string;
134
- impressions: number;
135
- reach: number;
136
- engagement: PostEngagement;
137
- clicks: number;
138
- shares: number;
139
- saves: number;
140
- demographics?: {
141
- age?: Record<string, number>;
142
- gender?: Record<string, number>;
143
- location?: Record<string, number>;
144
- };
145
- topPerformingHours?: Array<{
146
- hour: number;
147
- engagement: number;
148
- }>;
149
- }
150
-
151
- /**
152
- * Interface for social media posting services
153
- */
154
- export abstract class IPostService extends Service {
155
- static override readonly serviceType = ServiceType.POST;
156
-
157
- public readonly capabilityDescription =
158
- 'Social media posting and content management capabilities';
159
-
160
- /**
161
- * Create and publish a new post
162
- * @param content - Post content
163
- * @param options - Publishing options
164
- * @returns Promise resolving to post ID
165
- */
166
- abstract createPost(content: PostContent, options?: PostCreateOptions): Promise<UUID>;
167
-
168
- /**
169
- * Get posts from timeline or specific user
170
- * @param options - Search options
171
- * @returns Promise resolving to array of posts
172
- */
173
- abstract getPosts(options?: PostSearchOptions): Promise<PostInfo[]>;
174
-
175
- /**
176
- * Get a specific post by ID
177
- * @param postId - Post ID
178
- * @returns Promise resolving to post info
179
- */
180
- abstract getPost(postId: UUID): Promise<PostInfo>;
181
-
182
- /**
183
- * Edit an existing post
184
- * @param postId - Post ID
185
- * @param content - New post content
186
- * @returns Promise resolving when edit completes
187
- */
188
- abstract editPost(postId: UUID, content: PostContent): Promise<void>;
189
-
190
- /**
191
- * Delete a post
192
- * @param postId - Post ID
193
- * @returns Promise resolving when deletion completes
194
- */
195
- abstract deletePost(postId: UUID): Promise<void>;
196
-
197
- /**
198
- * Like/unlike a post
199
- * @param postId - Post ID
200
- * @param like - True to like, false to unlike
201
- * @returns Promise resolving when operation completes
202
- */
203
- abstract likePost(postId: UUID, like: boolean): Promise<void>;
204
-
205
- /**
206
- * Share/repost a post
207
- * @param postId - Post ID
208
- * @param comment - Optional comment when sharing
209
- * @returns Promise resolving to share ID
210
- */
211
- abstract sharePost(postId: UUID, comment?: string): Promise<UUID>;
212
-
213
- /**
214
- * Save/unsave a post
215
- * @param postId - Post ID
216
- * @param save - True to save, false to unsave
217
- * @returns Promise resolving when operation completes
218
- */
219
- abstract savePost(postId: UUID, save: boolean): Promise<void>;
220
-
221
- /**
222
- * Comment on a post
223
- * @param postId - Post ID
224
- * @param content - Comment content
225
- * @returns Promise resolving to comment ID
226
- */
227
- abstract commentOnPost(postId: UUID, content: PostContent): Promise<UUID>;
228
-
229
- /**
230
- * Get comments for a post
231
- * @param postId - Post ID
232
- * @param options - Search options
233
- * @returns Promise resolving to array of comments
234
- */
235
- abstract getComments(postId: UUID, options?: PostSearchOptions): Promise<PostInfo[]>;
236
-
237
- /**
238
- * Schedule a post for later publishing
239
- * @param content - Post content
240
- * @param scheduledAt - When to publish
241
- * @param options - Publishing options
242
- * @returns Promise resolving to scheduled post ID
243
- */
244
- abstract schedulePost(
245
- content: PostContent,
246
- scheduledAt: Date,
247
- options?: PostCreateOptions
248
- ): Promise<UUID>;
249
-
250
- /**
251
- * Get analytics for a post
252
- * @param postId - Post ID
253
- * @returns Promise resolving to post analytics
254
- */
255
- abstract getPostAnalytics(postId: UUID): Promise<PostAnalytics>;
256
-
257
- /**
258
- * Get trending posts
259
- * @param options - Search options
260
- * @returns Promise resolving to trending posts
261
- */
262
- abstract getTrendingPosts(options?: PostSearchOptions): Promise<PostInfo[]>;
263
-
264
- /**
265
- * Search posts across platforms
266
- * @param query - Search query
267
- * @param options - Search options
268
- * @returns Promise resolving to search results
269
- */
270
- abstract searchPosts(query: string, options?: PostSearchOptions): Promise<PostInfo[]>;
271
- }
@@ -1,97 +0,0 @@
1
- /**
2
- * Defines a custom type UUID representing a universally unique identifier
3
- */
4
- export type UUID = `${string}-${string}-${string}-${string}-${string}`;
5
-
6
- /**
7
- * Helper function to safely cast a string to strongly typed UUID
8
- * @param id The string UUID to validate and cast
9
- * @returns The same UUID with branded type information
10
- */
11
- export function asUUID(id: string): UUID {
12
- if (!id || !/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(id)) {
13
- throw new Error(`Invalid UUID format: ${id}`);
14
- }
15
- return id as UUID;
16
- }
17
-
18
- /**
19
- * Represents the content of a memory, message, or other information
20
- */
21
- export interface Content {
22
- /** The agent's internal thought process */
23
- thought?: string;
24
-
25
- /** The main text content visible to users */
26
- text?: string;
27
-
28
- /** Optional actions to be performed */
29
- actions?: string[];
30
-
31
- /** Optional providers to use for context generation */
32
- providers?: string[];
33
-
34
- /** Optional source/origin of the content */
35
- source?: string;
36
-
37
- /** Optional target/destination for responses */
38
- target?: string;
39
-
40
- /** URL of the original message/post (e.g. tweet URL, Discord message link) */
41
- url?: string;
42
-
43
- /** UUID of parent message if this is a reply/thread */
44
- inReplyTo?: UUID;
45
-
46
- /** Array of media attachments */
47
- attachments?: Media[];
48
-
49
- /** room type */
50
- channelType?: string;
51
-
52
- /**
53
- * Additional dynamic properties
54
- * Use specific properties above instead of this when possible
55
- */
56
- [key: string]: unknown;
57
- }
58
-
59
- /**
60
- * Represents a media attachment
61
- */
62
- export type Media = {
63
- /** Unique identifier */
64
- id: string;
65
-
66
- /** Media URL */
67
- url: string;
68
-
69
- /** Media title */
70
- title?: string;
71
-
72
- /** Media source */
73
- source?: string;
74
-
75
- /** Media description */
76
- description?: string;
77
-
78
- /** Text content */
79
- text?: string;
80
-
81
- /** Content type */
82
- contentType?: ContentType;
83
- };
84
-
85
- export enum ContentType {
86
- IMAGE = 'image',
87
- VIDEO = 'video',
88
- AUDIO = 'audio',
89
- DOCUMENT = 'document',
90
- LINK = 'link',
91
- }
92
-
93
- /**
94
- * A generic type for metadata objects, allowing for arbitrary key-value pairs.
95
- * This encourages consumers to perform type checking or casting.
96
- */
97
- export type Metadata = Record<string, unknown>;
@@ -1,190 +0,0 @@
1
- import type { Character } from './agent';
2
- import type { Action, Evaluator, Provider } from './components';
3
- import { HandlerCallback } from './components';
4
- import type { IDatabaseAdapter } from './database';
5
- import type { Entity, Room, World } from './environment';
6
- import { Memory, MemoryMetadata } from './memory';
7
- import type { SendHandlerFunction, TargetInfo } from './messaging';
8
- import type { ModelParamsMap, ModelResultMap, ModelTypeName } from './model';
9
- import type { Plugin, Route } from './plugin';
10
- import type { Content, UUID } from './primitives';
11
- import type { Service, ServiceTypeName } from './service';
12
- import type { State } from './state';
13
- import type { TaskWorker } from './task';
14
-
15
- /**
16
- * Represents the core runtime environment for an agent.
17
- * Defines methods for database interaction, plugin management, event handling,
18
- * state composition, model usage, and task management.
19
- */
20
-
21
- export interface IAgentRuntime extends IDatabaseAdapter {
22
- // Properties
23
- agentId: UUID;
24
- character: Character;
25
- providers: Provider[];
26
- actions: Action[];
27
- evaluators: Evaluator[];
28
- plugins: Plugin[];
29
- services: Map<ServiceTypeName, Service[]>;
30
- events: Map<string, ((params: any) => Promise<void>)[]>;
31
- fetch?: typeof fetch | null;
32
- routes: Route[];
33
- logger: any;
34
-
35
- // Methods
36
- registerPlugin(plugin: Plugin): Promise<void>;
37
-
38
- initialize(): Promise<void>;
39
-
40
- getConnection(): Promise<any>;
41
-
42
- getService<T extends Service>(service: ServiceTypeName | string): T | null;
43
-
44
- getServicesByType<T extends Service>(service: ServiceTypeName | string): T[];
45
-
46
- getAllServices(): Map<ServiceTypeName, Service[]>;
47
-
48
- registerService(service: typeof Service): Promise<void>;
49
-
50
- getServiceLoadPromise(serviceType: ServiceTypeName): Promise<Service>;
51
-
52
- getRegisteredServiceTypes(): ServiceTypeName[];
53
-
54
- hasService(serviceType: ServiceTypeName | string): boolean;
55
-
56
- // Keep these methods for backward compatibility
57
- registerDatabaseAdapter(adapter: IDatabaseAdapter): void;
58
-
59
- setSetting(key: string, value: string | boolean | null | any, secret?: boolean): void;
60
-
61
- getSetting(key: string): string | boolean | null | any;
62
-
63
- getConversationLength(): number;
64
-
65
- processActions(
66
- message: Memory,
67
- responses: Memory[],
68
- state?: State,
69
- callback?: HandlerCallback
70
- ): Promise<void>;
71
-
72
- evaluate(
73
- message: Memory,
74
- state?: State,
75
- didRespond?: boolean,
76
- callback?: HandlerCallback,
77
- responses?: Memory[]
78
- ): Promise<Evaluator[] | null>;
79
-
80
- registerProvider(provider: Provider): void;
81
-
82
- registerAction(action: Action): void;
83
-
84
- registerEvaluator(evaluator: Evaluator): void;
85
-
86
- ensureConnections(entities: Entity[], rooms: Room[], source: string, world: World): Promise<void>;
87
- ensureConnection({
88
- entityId,
89
- roomId,
90
- metadata,
91
- userName,
92
- worldName,
93
- name,
94
- source,
95
- channelId,
96
- serverId,
97
- type,
98
- worldId,
99
- userId,
100
- }: {
101
- entityId: UUID;
102
- roomId: UUID;
103
- userName?: string;
104
- name?: string;
105
- worldName?: string;
106
- source?: string;
107
- channelId?: string;
108
- serverId?: string;
109
- type: any;
110
- worldId: UUID;
111
- userId?: UUID;
112
- metadata?: Record<string, any>;
113
- }): Promise<void>;
114
-
115
- ensureParticipantInRoom(entityId: UUID, roomId: UUID): Promise<void>;
116
-
117
- ensureWorldExists(world: World): Promise<void>;
118
-
119
- ensureRoomExists(room: Room): Promise<void>;
120
-
121
- composeState(
122
- message: Memory,
123
- includeList?: string[],
124
- onlyInclude?: boolean,
125
- skipCache?: boolean
126
- ): Promise<State>;
127
-
128
- useModel<T extends ModelTypeName, R = ModelResultMap[T]>(
129
- modelType: T,
130
- params: Omit<ModelParamsMap[T], 'runtime'> | any
131
- ): Promise<R>;
132
-
133
- registerModel(
134
- modelType: ModelTypeName | string,
135
- handler: (params: any) => Promise<any>,
136
- provider: string,
137
- priority?: number
138
- ): void;
139
-
140
- getModel(
141
- modelType: ModelTypeName | string
142
- ): ((runtime: IAgentRuntime, params: any) => Promise<any>) | undefined;
143
-
144
- registerEvent(event: string, handler: (params: any) => Promise<void>): void;
145
-
146
- getEvent(event: string): ((params: any) => Promise<void>)[] | undefined;
147
-
148
- emitEvent(event: string | string[], params: any): Promise<void>;
149
- // In-memory task definition methods
150
- registerTaskWorker(taskHandler: TaskWorker): void;
151
- getTaskWorker(name: string): TaskWorker | undefined;
152
-
153
- stop(): Promise<void>;
154
-
155
- addEmbeddingToMemory(memory: Memory): Promise<Memory>;
156
-
157
- /**
158
- * Queue a memory for async embedding generation.
159
- * This method is non-blocking and returns immediately.
160
- * The embedding will be generated asynchronously via event handlers.
161
- * @param memory The memory to generate embeddings for
162
- * @param priority Priority level for the embedding generation
163
- */
164
- queueEmbeddingGeneration(memory: Memory, priority?: 'high' | 'normal' | 'low'): Promise<void>;
165
-
166
- getAllMemories(): Promise<Memory[]>;
167
-
168
- clearAllAgentMemories(): Promise<void>;
169
-
170
- updateMemory(memory: Partial<Memory> & { id: UUID; metadata?: MemoryMetadata }): Promise<boolean>;
171
-
172
- // Run tracking methods
173
- createRunId(): UUID;
174
- startRun(): UUID;
175
- endRun(): void;
176
- getCurrentRunId(): UUID;
177
-
178
- // easy/compat wrappers
179
-
180
- getEntityById(entityId: UUID): Promise<Entity | null>;
181
- getRoom(roomId: UUID): Promise<Room | null>;
182
- createEntity(entity: Entity): Promise<boolean>;
183
- createRoom({ id, name, source, type, channelId, serverId, worldId }: Room): Promise<UUID>;
184
- addParticipant(entityId: UUID, roomId: UUID): Promise<boolean>;
185
- getRooms(worldId: UUID): Promise<Room[]>;
186
-
187
- registerSendHandler(source: string, handler: SendHandlerFunction): void;
188
-
189
- sendMessageToTarget(target: TargetInfo, content: Content): Promise<void>;
190
- }