@elizaos/core 1.6.4-alpha.2 → 1.6.4-alpha.21

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/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 - THE ONLY WAY to send messages
117
- * All message sending (WebSocket, API, CLI, Tests, MessageBus) must use this method
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 | string, options?: {
120
- userId?: UUID;
121
- roomId?: UUID;
122
- metadata?: Record<string, any>;
123
- }): Promise<Memory[]>;
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 (batch operation)
126
- * All batch message sending must use this method
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 | string;
131
- options?: {
132
- userId?: UUID;
133
- roomId?: UUID;
134
- metadata?: Record<string, any>;
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
- responses: Memory[];
241
+ result: SendMessageResult;
139
242
  error?: Error;
140
243
  }>>;
141
244
  /**
@@ -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,EAChB,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,IAAI,CAAC;IACd,SAAS,EAAE,SAAS,GAAG,QAAQ,GAAG,UAAU,CAAC;IAC7C,OAAO,EAAE,GAAG,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,IAAI,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,EAAE,EAAE,IAAI,GAAG,aAAa,GAAG,SAAS,CAAC;IAC9C,SAAS,IAAI,aAAa,EAAE,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,IAAI,GAAG,KAAK,GAAG,SAAS,CAAC;CAC5C;AAED;;GAEG;AACH,MA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;IACH,kBAAkB,IAAI,IAAI;CAQ3B"}
@@ -25990,7 +25990,7 @@ var getDefaultProjectName = () => {
25990
25990
  };
25991
25991
 
25992
25992
  // ../../node_modules/langsmith/dist/index.js
25993
- var __version__ = "0.3.74";
25993
+ var __version__ = "0.3.75";
25994
25994
 
25995
25995
  // ../../node_modules/langsmith/dist/utils/env.js
25996
25996
  var globalEnv;
@@ -32234,7 +32234,7 @@ class AIMessageChunk extends BaseMessageChunk {
32234
32234
  invalid_tool_calls: [],
32235
32235
  tool_call_chunks: []
32236
32236
  };
32237
- } else if (fields.tool_call_chunks === undefined) {
32237
+ } else if (fields.tool_call_chunks === undefined || fields.tool_call_chunks.length === 0) {
32238
32238
  initParams = {
32239
32239
  ...fields,
32240
32240
  tool_calls: fields.tool_calls ?? [],
@@ -32243,7 +32243,8 @@ class AIMessageChunk extends BaseMessageChunk {
32243
32243
  usage_metadata: fields.usage_metadata !== undefined ? fields.usage_metadata : undefined
32244
32244
  };
32245
32245
  } else {
32246
- const groupedToolCallChunks = fields.tool_call_chunks.reduce((acc, chunk) => {
32246
+ const toolCallChunks = fields.tool_call_chunks ?? [];
32247
+ const groupedToolCallChunks = toolCallChunks.reduce((acc, chunk) => {
32247
32248
  const matchedChunkIndex = acc.findIndex(([match]) => {
32248
32249
  if ("id" in chunk && chunk.id && "index" in chunk && chunk.index !== undefined) {
32249
32250
  return chunk.id === match.id && chunk.index === match.index;
@@ -44765,7 +44766,7 @@ class AgentRuntime {
44765
44766
  }
44766
44767
  }
44767
44768
  }
44768
- async initialize() {
44769
+ async initialize(options) {
44769
44770
  try {
44770
44771
  const pluginRegistrationPromises = [];
44771
44772
  const pluginsToLoad = this.characterPlugins;
@@ -44784,9 +44785,14 @@ class AgentRuntime {
44784
44785
  await this.adapter.init();
44785
44786
  }
44786
44787
  this.messageService = new DefaultMessageService;
44787
- this.logger.info("Running plugin migrations...");
44788
- await this.runPluginMigrations();
44789
- this.logger.info("Plugin migrations completed.");
44788
+ const skipMigrations = options?.skipMigrations ?? false;
44789
+ if (skipMigrations) {
44790
+ this.logger.info("Skipping plugin migrations (skipMigrations=true)");
44791
+ } else {
44792
+ this.logger.info("Running plugin migrations...");
44793
+ await this.runPluginMigrations();
44794
+ this.logger.info("Plugin migrations completed.");
44795
+ }
44790
44796
  const existingAgent = await this.ensureAgentExists({
44791
44797
  ...this.character,
44792
44798
  id: this.agentId
@@ -44795,6 +44801,24 @@ class AgentRuntime {
44795
44801
  const errorMsg = `Agent ${this.agentId} does not exist in database after ensureAgentExists call`;
44796
44802
  throw new Error(errorMsg);
44797
44803
  }
44804
+ if (existingAgent.settings) {
44805
+ this.character.settings = {
44806
+ ...existingAgent.settings,
44807
+ ...this.character.settings
44808
+ };
44809
+ const dbSecrets = existingAgent.settings.secrets && typeof existingAgent.settings.secrets === "object" ? existingAgent.settings.secrets : {};
44810
+ const settingsSecrets = this.character.settings.secrets && typeof this.character.settings.secrets === "object" ? this.character.settings.secrets : {};
44811
+ const characterSecrets = this.character.secrets && typeof this.character.secrets === "object" ? this.character.secrets : {};
44812
+ const mergedSecrets = {
44813
+ ...dbSecrets,
44814
+ ...characterSecrets,
44815
+ ...settingsSecrets
44816
+ };
44817
+ if (Object.keys(mergedSecrets).length > 0) {
44818
+ this.character.secrets = mergedSecrets;
44819
+ this.character.settings.secrets = mergedSecrets;
44820
+ }
44821
+ }
44798
44822
  let agentEntity = await this.getEntityById(this.agentId);
44799
44823
  if (!agentEntity) {
44800
44824
  const created = await this.createEntity({
@@ -46135,8 +46159,21 @@ ${input}`;
46135
46159
  }
46136
46160
  const existingAgent = await this.adapter.getAgent(agent.id);
46137
46161
  if (existingAgent) {
46162
+ const mergedSettings = {
46163
+ ...existingAgent.settings,
46164
+ ...agent.settings
46165
+ };
46166
+ const mergedSecrets = typeof existingAgent.settings?.secrets === "object" || typeof agent.settings?.secrets === "object" ? {
46167
+ ...typeof existingAgent.settings?.secrets === "object" ? existingAgent.settings.secrets : {},
46168
+ ...typeof agent.settings?.secrets === "object" ? agent.settings.secrets : {}
46169
+ } : undefined;
46170
+ if (mergedSecrets) {
46171
+ mergedSettings.secrets = mergedSecrets;
46172
+ }
46138
46173
  const updatedAgent = {
46174
+ ...existingAgent,
46139
46175
  ...agent,
46176
+ settings: mergedSettings,
46140
46177
  id: agent.id,
46141
46178
  updatedAt: Date.now()
46142
46179
  };
@@ -46145,7 +46182,7 @@ ${input}`;
46145
46182
  if (!refreshedAgent) {
46146
46183
  throw new Error(`Failed to retrieve agent after update: ${agent.id}`);
46147
46184
  }
46148
- this.logger.debug(`Updated existing agent ${agent.id} on restart`);
46185
+ this.logger.debug(`Updated existing agent ${agent.id} on restart (merged ${Object.keys(existingAgent.settings || {}).length} DB settings with ${Object.keys(agent.settings || {}).length} character settings)`);
46149
46186
  return refreshedAgent;
46150
46187
  }
46151
46188
  const newAgent = {
@@ -46535,19 +46572,25 @@ async function loadSecretsNodeImpl(character) {
46535
46572
  const fs = await import("node:fs");
46536
46573
  const dotenv = await import("dotenv");
46537
46574
  const { findEnvFile: findEnvFile2 } = await Promise.resolve().then(() => (init_environment(), exports_environment));
46538
- if (hasCharacterSecrets(character)) {
46539
- return false;
46540
- }
46541
46575
  const envPath = findEnvFile2();
46542
46576
  if (!envPath)
46543
46577
  return false;
46544
46578
  try {
46545
46579
  const buf = fs.readFileSync(envPath);
46546
- const envSecrets = dotenv.parse(buf);
46580
+ const envVars = dotenv.parse(buf);
46547
46581
  if (!character.settings) {
46548
46582
  character.settings = {};
46549
46583
  }
46550
- character.settings.secrets = envSecrets;
46584
+ const existingSettings = { ...character.settings };
46585
+ const existingSecrets = character.settings.secrets && typeof character.settings.secrets === "object" ? { ...character.settings.secrets } : {};
46586
+ character.settings = {
46587
+ ...envVars,
46588
+ ...existingSettings
46589
+ };
46590
+ character.settings.secrets = {
46591
+ ...envVars,
46592
+ ...existingSecrets
46593
+ };
46551
46594
  return true;
46552
46595
  } catch {
46553
46596
  return false;
@@ -47147,9 +47190,7 @@ class ElizaOS extends EventTarget {
47147
47190
  async addAgents(agents, options) {
47148
47191
  const promises = agents.map(async (agent) => {
47149
47192
  const character = agent.character;
47150
- if (!hasCharacterSecrets(character)) {
47151
- await setDefaultSecretsFromEnv(character);
47152
- }
47193
+ await setDefaultSecretsFromEnv(character);
47153
47194
  const resolvedPlugins = agent.plugins ? await resolvePlugins(agent.plugins, options?.isTestMode || false) : [];
47154
47195
  const runtime = new AgentRuntime({
47155
47196
  character,
@@ -47280,31 +47321,79 @@ class ElizaOS extends EventTarget {
47280
47321
  if (!runtime) {
47281
47322
  throw new Error(`Agent ${agentId} not found`);
47282
47323
  }
47283
- const memory = typeof message === "string" ? {
47284
- id: v4_default(),
47285
- entityId: options?.userId || "system",
47286
- agentId,
47287
- roomId: options?.roomId || agentId,
47288
- content: { text: message },
47289
- createdAt: Date.now(),
47290
- metadata: options?.metadata
47291
- } : message;
47292
- const responses = [];
47293
- await runtime.processActions(memory, responses);
47294
- this.dispatchEvent(new CustomEvent("message:sent", {
47295
- detail: { agentId, message: memory, responses }
47296
- }));
47297
- return responses;
47324
+ if (!runtime.messageService) {
47325
+ throw new Error("messageService is not initialized on runtime");
47326
+ }
47327
+ const messageId = message.id || v4_default();
47328
+ const userMessage = {
47329
+ ...message,
47330
+ id: messageId,
47331
+ agentId: message.agentId || runtime.agentId,
47332
+ createdAt: message.createdAt || Date.now(),
47333
+ entityId: message.entityId,
47334
+ roomId: message.roomId,
47335
+ content: message.content
47336
+ };
47337
+ await runtime.ensureConnection({
47338
+ entityId: userMessage.entityId,
47339
+ roomId: userMessage.roomId,
47340
+ worldId: message.worldId || userMessage.roomId,
47341
+ source: userMessage.content.source || "unknown",
47342
+ channelId: userMessage.roomId
47343
+ });
47344
+ const processingOptions = {
47345
+ maxRetries: options?.maxRetries,
47346
+ timeoutDuration: options?.timeoutDuration,
47347
+ useMultiStep: options?.useMultiStep,
47348
+ maxMultiStepIterations: options?.maxMultiStepIterations
47349
+ };
47350
+ const isAsyncMode = !!options?.onResponse;
47351
+ if (isAsyncMode) {
47352
+ const callback = async (content) => {
47353
+ try {
47354
+ if (options.onResponse) {
47355
+ await options.onResponse(content);
47356
+ }
47357
+ } catch (error) {
47358
+ if (options.onError) {
47359
+ await options.onError(error instanceof Error ? error : new Error(String(error)));
47360
+ }
47361
+ }
47362
+ return [];
47363
+ };
47364
+ runtime.messageService.handleMessage(runtime, userMessage, callback, processingOptions).then(() => {
47365
+ if (options.onComplete)
47366
+ options.onComplete();
47367
+ }).catch((error) => {
47368
+ if (options.onError)
47369
+ options.onError(error);
47370
+ });
47371
+ this.dispatchEvent(new CustomEvent("message:sent", {
47372
+ detail: { agentId, messageId, mode: "async" }
47373
+ }));
47374
+ return { messageId, userMessage };
47375
+ } else {
47376
+ const result = await runtime.messageService.handleMessage(runtime, userMessage, undefined, processingOptions);
47377
+ if (options?.onComplete)
47378
+ await options.onComplete();
47379
+ this.dispatchEvent(new CustomEvent("message:sent", {
47380
+ detail: { agentId, messageId, mode: "sync", result }
47381
+ }));
47382
+ return { messageId, userMessage, result };
47383
+ }
47298
47384
  }
47299
47385
  async sendMessages(messages) {
47300
47386
  const results = await Promise.all(messages.map(async ({ agentId, message, options }) => {
47301
47387
  try {
47302
- const responses = await this.sendMessage(agentId, message, options);
47303
- return { agentId, responses };
47388
+ const result = await this.sendMessage(agentId, message, options);
47389
+ return { agentId, result };
47304
47390
  } catch (error) {
47305
47391
  return {
47306
47392
  agentId,
47307
- responses: [],
47393
+ result: {
47394
+ messageId: message.id || "",
47395
+ userMessage: message
47396
+ },
47308
47397
  error: error instanceof Error ? error : new Error(String(error))
47309
47398
  };
47310
47399
  }
@@ -47754,5 +47843,5 @@ export {
47754
47843
  AgentRuntime
47755
47844
  };
47756
47845
 
47757
- //# debugId=9B89E2D616BB564964756E2164756E21
47846
+ //# debugId=7C69A32469711FD264756E2164756E21
47758
47847
  //# sourceMappingURL=index.node.js.map