@elizaos/core 1.6.4-alpha.5 → 1.6.4-alpha.7
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 +55 -55
- package/dist/browser/index.browser.js.map +4 -4
- package/dist/elizaos.d.ts +119 -16
- package/dist/elizaos.d.ts.map +1 -1
- package/dist/node/index.node.js +67 -19
- package/dist/node/index.node.js.map +4 -4
- package/dist/types/messaging.d.ts +42 -0
- package/dist/types/messaging.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/elizaos.d.ts
CHANGED
|
@@ -1,4 +1,51 @@
|
|
|
1
|
-
import type { Character, IAgentRuntime, UUID, Memory, State, Plugin, RuntimeSettings } from './types';
|
|
1
|
+
import type { Character, IAgentRuntime, UUID, Memory, State, Plugin, RuntimeSettings, Content } from './types';
|
|
2
|
+
import type { MessageProcessingResult } from './services/message-service';
|
|
3
|
+
/**
|
|
4
|
+
* Options for sending a message to an agent
|
|
5
|
+
*/
|
|
6
|
+
export interface SendMessageOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Called when the agent generates a response (ASYNC MODE)
|
|
9
|
+
* If provided, method returns immediately (fire & forget)
|
|
10
|
+
* If not provided, method waits for response (SYNC MODE)
|
|
11
|
+
*/
|
|
12
|
+
onResponse?: (content: Content) => Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Called if an error occurs during processing
|
|
15
|
+
*/
|
|
16
|
+
onError?: (error: Error) => Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Called when processing is complete
|
|
19
|
+
*/
|
|
20
|
+
onComplete?: () => Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Maximum number of retries for failed messages
|
|
23
|
+
*/
|
|
24
|
+
maxRetries?: number;
|
|
25
|
+
/**
|
|
26
|
+
* Timeout duration in milliseconds
|
|
27
|
+
*/
|
|
28
|
+
timeoutDuration?: number;
|
|
29
|
+
/**
|
|
30
|
+
* Enable multi-step message processing
|
|
31
|
+
*/
|
|
32
|
+
useMultiStep?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Maximum multi-step iterations
|
|
35
|
+
*/
|
|
36
|
+
maxMultiStepIterations?: number;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Result of sending a message to an agent
|
|
40
|
+
*/
|
|
41
|
+
export interface SendMessageResult {
|
|
42
|
+
/** ID of the user message */
|
|
43
|
+
messageId: UUID;
|
|
44
|
+
/** The user message that was created */
|
|
45
|
+
userMessage: Memory;
|
|
46
|
+
/** Processing result (only in SYNC mode) */
|
|
47
|
+
result?: MessageProcessingResult;
|
|
48
|
+
}
|
|
2
49
|
/**
|
|
3
50
|
* Batch operation for sending messages
|
|
4
51
|
*/
|
|
@@ -113,29 +160,85 @@ export declare class ElizaOS extends EventTarget {
|
|
|
113
160
|
*/
|
|
114
161
|
getAgentByCharacterId(characterId: UUID): IAgentRuntime | undefined;
|
|
115
162
|
/**
|
|
116
|
-
* Send a message to a specific agent
|
|
117
|
-
*
|
|
163
|
+
* Send a message to a specific agent
|
|
164
|
+
*
|
|
165
|
+
* @param agentId - The agent ID to send the message to
|
|
166
|
+
* @param message - Partial Memory object (missing fields auto-filled)
|
|
167
|
+
* @param options - Optional callbacks and processing options
|
|
168
|
+
* @returns Promise with message ID and result
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* // SYNC mode (HTTP API)
|
|
172
|
+
* const result = await elizaOS.sendMessage(agentId, {
|
|
173
|
+
* entityId: user.id,
|
|
174
|
+
* roomId: room.id,
|
|
175
|
+
* content: { text: "Hello", source: 'web' }
|
|
176
|
+
* });
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* // ASYNC mode (WebSocket, MessageBus)
|
|
180
|
+
* await elizaOS.sendMessage(agentId, {
|
|
181
|
+
* entityId: user.id,
|
|
182
|
+
* roomId: room.id,
|
|
183
|
+
* content: { text: "Hello", source: 'websocket' }
|
|
184
|
+
* }, {
|
|
185
|
+
* onResponse: async (response) => {
|
|
186
|
+
* await socket.emit('message', response.text);
|
|
187
|
+
* }
|
|
188
|
+
* });
|
|
118
189
|
*/
|
|
119
|
-
sendMessage(agentId: UUID, message: Memory
|
|
120
|
-
|
|
121
|
-
roomId
|
|
122
|
-
|
|
123
|
-
|
|
190
|
+
sendMessage(agentId: UUID, message: Partial<Memory> & {
|
|
191
|
+
entityId: UUID;
|
|
192
|
+
roomId: UUID;
|
|
193
|
+
content: Content;
|
|
194
|
+
worldId?: UUID;
|
|
195
|
+
}, options?: SendMessageOptions): Promise<SendMessageResult>;
|
|
124
196
|
/**
|
|
125
|
-
* Send messages to multiple agents
|
|
126
|
-
*
|
|
197
|
+
* Send messages to multiple agents in parallel
|
|
198
|
+
*
|
|
199
|
+
* Useful for batch operations where you need to send messages to multiple agents at once.
|
|
200
|
+
* All messages are sent in parallel for maximum performance.
|
|
201
|
+
*
|
|
202
|
+
* @param messages - Array of messages to send, each with agentId and message data
|
|
203
|
+
* @returns Promise with array of results, one per message
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* const results = await elizaOS.sendMessages([
|
|
207
|
+
* {
|
|
208
|
+
* agentId: agent1Id,
|
|
209
|
+
* message: {
|
|
210
|
+
* entityId: user.id,
|
|
211
|
+
* roomId: room.id,
|
|
212
|
+
* content: { text: "Hello Agent 1", source: "web" }
|
|
213
|
+
* }
|
|
214
|
+
* },
|
|
215
|
+
* {
|
|
216
|
+
* agentId: agent2Id,
|
|
217
|
+
* message: {
|
|
218
|
+
* entityId: user.id,
|
|
219
|
+
* roomId: room.id,
|
|
220
|
+
* content: { text: "Hello Agent 2", source: "web" }
|
|
221
|
+
* },
|
|
222
|
+
* options: {
|
|
223
|
+
* onResponse: async (response) => {
|
|
224
|
+
* console.log("Agent 2 responded:", response.text);
|
|
225
|
+
* }
|
|
226
|
+
* }
|
|
227
|
+
* }
|
|
228
|
+
* ]);
|
|
127
229
|
*/
|
|
128
230
|
sendMessages(messages: Array<{
|
|
129
231
|
agentId: UUID;
|
|
130
|
-
message: Memory
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
232
|
+
message: Partial<Memory> & {
|
|
233
|
+
entityId: UUID;
|
|
234
|
+
roomId: UUID;
|
|
235
|
+
content: Content;
|
|
236
|
+
worldId?: UUID;
|
|
135
237
|
};
|
|
238
|
+
options?: SendMessageOptions;
|
|
136
239
|
}>): Promise<Array<{
|
|
137
240
|
agentId: UUID;
|
|
138
|
-
|
|
241
|
+
result: SendMessageResult;
|
|
139
242
|
error?: Error;
|
|
140
243
|
}>>;
|
|
141
244
|
/**
|
package/dist/elizaos.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"elizaos.d.ts","sourceRoot":"","sources":["../src/elizaos.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,SAAS,EACT,aAAa,EACb,IAAI,EACJ,MAAM,EACN,KAAK,EACL,MAAM,EACN,eAAe,
|
|
1
|
+
{"version":3,"file":"elizaos.d.ts","sourceRoot":"","sources":["../src/elizaos.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,SAAS,EACT,aAAa,EACb,IAAI,EACJ,MAAM,EACN,KAAK,EACL,MAAM,EACN,eAAe,EACf,OAAO,EACR,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAEV,uBAAuB,EACxB,MAAM,4BAA4B,CAAC;AAEpC;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjD;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1C;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjC;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CA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;;OAEG;IACG,WAAW,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IAuBpE;;OAEG;IACH,kBAAkB,IAAI,eAAe;IAqBrC;;OAEG;IACH,kBAAkB,IAAI,IAAI;CAQ3B"}
|
package/dist/node/index.node.js
CHANGED
|
@@ -47280,31 +47280,79 @@ class ElizaOS extends EventTarget {
|
|
|
47280
47280
|
if (!runtime) {
|
|
47281
47281
|
throw new Error(`Agent ${agentId} not found`);
|
|
47282
47282
|
}
|
|
47283
|
-
|
|
47284
|
-
|
|
47285
|
-
|
|
47286
|
-
|
|
47287
|
-
|
|
47288
|
-
|
|
47289
|
-
|
|
47290
|
-
|
|
47291
|
-
|
|
47292
|
-
|
|
47293
|
-
|
|
47294
|
-
|
|
47295
|
-
|
|
47296
|
-
|
|
47297
|
-
|
|
47283
|
+
if (!runtime.messageService) {
|
|
47284
|
+
throw new Error("messageService is not initialized on runtime");
|
|
47285
|
+
}
|
|
47286
|
+
const messageId = message.id || v4_default();
|
|
47287
|
+
const userMessage = {
|
|
47288
|
+
...message,
|
|
47289
|
+
id: messageId,
|
|
47290
|
+
agentId: message.agentId || runtime.agentId,
|
|
47291
|
+
createdAt: message.createdAt || Date.now(),
|
|
47292
|
+
entityId: message.entityId,
|
|
47293
|
+
roomId: message.roomId,
|
|
47294
|
+
content: message.content
|
|
47295
|
+
};
|
|
47296
|
+
await runtime.ensureConnection({
|
|
47297
|
+
entityId: userMessage.entityId,
|
|
47298
|
+
roomId: userMessage.roomId,
|
|
47299
|
+
worldId: message.worldId || userMessage.roomId,
|
|
47300
|
+
source: userMessage.content.source || "unknown",
|
|
47301
|
+
channelId: userMessage.roomId
|
|
47302
|
+
});
|
|
47303
|
+
const processingOptions = {
|
|
47304
|
+
maxRetries: options?.maxRetries,
|
|
47305
|
+
timeoutDuration: options?.timeoutDuration,
|
|
47306
|
+
useMultiStep: options?.useMultiStep,
|
|
47307
|
+
maxMultiStepIterations: options?.maxMultiStepIterations
|
|
47308
|
+
};
|
|
47309
|
+
const isAsyncMode = !!options?.onResponse;
|
|
47310
|
+
if (isAsyncMode) {
|
|
47311
|
+
const callback = async (content) => {
|
|
47312
|
+
try {
|
|
47313
|
+
if (options.onResponse) {
|
|
47314
|
+
await options.onResponse(content);
|
|
47315
|
+
}
|
|
47316
|
+
} catch (error) {
|
|
47317
|
+
if (options.onError) {
|
|
47318
|
+
await options.onError(error instanceof Error ? error : new Error(String(error)));
|
|
47319
|
+
}
|
|
47320
|
+
}
|
|
47321
|
+
return [];
|
|
47322
|
+
};
|
|
47323
|
+
runtime.messageService.handleMessage(runtime, userMessage, callback, processingOptions).then(() => {
|
|
47324
|
+
if (options.onComplete)
|
|
47325
|
+
options.onComplete();
|
|
47326
|
+
}).catch((error) => {
|
|
47327
|
+
if (options.onError)
|
|
47328
|
+
options.onError(error);
|
|
47329
|
+
});
|
|
47330
|
+
this.dispatchEvent(new CustomEvent("message:sent", {
|
|
47331
|
+
detail: { agentId, messageId, mode: "async" }
|
|
47332
|
+
}));
|
|
47333
|
+
return { messageId, userMessage };
|
|
47334
|
+
} else {
|
|
47335
|
+
const result = await runtime.messageService.handleMessage(runtime, userMessage, undefined, processingOptions);
|
|
47336
|
+
if (options?.onComplete)
|
|
47337
|
+
await options.onComplete();
|
|
47338
|
+
this.dispatchEvent(new CustomEvent("message:sent", {
|
|
47339
|
+
detail: { agentId, messageId, mode: "sync", result }
|
|
47340
|
+
}));
|
|
47341
|
+
return { messageId, userMessage, result };
|
|
47342
|
+
}
|
|
47298
47343
|
}
|
|
47299
47344
|
async sendMessages(messages) {
|
|
47300
47345
|
const results = await Promise.all(messages.map(async ({ agentId, message, options }) => {
|
|
47301
47346
|
try {
|
|
47302
|
-
const
|
|
47303
|
-
return { agentId,
|
|
47347
|
+
const result = await this.sendMessage(agentId, message, options);
|
|
47348
|
+
return { agentId, result };
|
|
47304
47349
|
} catch (error) {
|
|
47305
47350
|
return {
|
|
47306
47351
|
agentId,
|
|
47307
|
-
|
|
47352
|
+
result: {
|
|
47353
|
+
messageId: message.id || "",
|
|
47354
|
+
userMessage: message
|
|
47355
|
+
},
|
|
47308
47356
|
error: error instanceof Error ? error : new Error(String(error))
|
|
47309
47357
|
};
|
|
47310
47358
|
}
|
|
@@ -47754,5 +47802,5 @@ export {
|
|
|
47754
47802
|
AgentRuntime
|
|
47755
47803
|
};
|
|
47756
47804
|
|
|
47757
|
-
//# debugId=
|
|
47805
|
+
//# debugId=53C943B8F90F554964756E2164756E21
|
|
47758
47806
|
//# sourceMappingURL=index.node.js.map
|