@elizaos/plugin-bootstrap 1.2.0 → 1.2.1

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/index.js CHANGED
@@ -3768,7 +3768,7 @@ import {
3768
3768
  createUniqueUuid as createUniqueUuid3,
3769
3769
  EventType,
3770
3770
  imageDescriptionTemplate,
3771
- logger as logger18,
3771
+ logger as logger20,
3772
3772
  messageHandlerTemplate,
3773
3773
  ModelType as ModelType14,
3774
3774
  parseKeyValueXml,
@@ -4036,11 +4036,33 @@ var choiceAction = {
4036
4036
  tags: ["AWAITING_CHOICE"]
4037
4037
  });
4038
4038
  if (!pendingTasks?.length) {
4039
- throw new Error("No pending tasks with options found");
4039
+ return {
4040
+ text: "No pending tasks with options found",
4041
+ values: {
4042
+ success: false,
4043
+ error: "NO_PENDING_TASKS"
4044
+ },
4045
+ data: {
4046
+ actionName: "CHOOSE_OPTION",
4047
+ error: "No pending tasks with options found"
4048
+ },
4049
+ success: false
4050
+ };
4040
4051
  }
4041
4052
  const tasksWithOptions = pendingTasks.filter((task) => task.metadata?.options);
4042
4053
  if (!tasksWithOptions.length) {
4043
- throw new Error("No tasks currently have options to select from.");
4054
+ return {
4055
+ text: "No tasks currently have options to select from",
4056
+ values: {
4057
+ success: false,
4058
+ error: "NO_OPTIONS_AVAILABLE"
4059
+ },
4060
+ data: {
4061
+ actionName: "CHOOSE_OPTION",
4062
+ error: "No tasks currently have options to select from"
4063
+ },
4064
+ success: false
4065
+ };
4044
4066
  }
4045
4067
  const formattedTasks = tasksWithOptions.map((task) => {
4046
4068
  const shortId = task.id?.substring(0, 8);
@@ -4081,7 +4103,20 @@ ${task.options?.map((opt) => `- ${opt.name}: ${opt.description}`).join("\n")}`;
4081
4103
  actions: ["SELECT_OPTION_ERROR"],
4082
4104
  source: message.content.source
4083
4105
  });
4084
- return;
4106
+ return {
4107
+ text: `Could not find task with ID: ${taskId}`,
4108
+ values: {
4109
+ success: false,
4110
+ error: "TASK_NOT_FOUND",
4111
+ taskId
4112
+ },
4113
+ data: {
4114
+ actionName: "CHOOSE_OPTION",
4115
+ error: "Task not found",
4116
+ taskId
4117
+ },
4118
+ success: false
4119
+ };
4085
4120
  }
4086
4121
  const selectedTask = tasksWithOptions.find((task) => task.id === taskInfo.fullId);
4087
4122
  if (!selectedTask) {
@@ -4090,7 +4125,18 @@ ${task.options?.map((opt) => `- ${opt.name}: ${opt.description}`).join("\n")}`;
4090
4125
  actions: ["SELECT_OPTION_ERROR"],
4091
4126
  source: message.content.source
4092
4127
  });
4093
- return;
4128
+ return {
4129
+ text: "Error locating the selected task",
4130
+ values: {
4131
+ success: false,
4132
+ error: "TASK_LOOKUP_ERROR"
4133
+ },
4134
+ data: {
4135
+ actionName: "CHOOSE_OPTION",
4136
+ error: "Failed to locate task"
4137
+ },
4138
+ success: false
4139
+ };
4094
4140
  }
4095
4141
  if (selectedOption === "ABORT") {
4096
4142
  if (!selectedTask?.id) {
@@ -4099,7 +4145,18 @@ ${task.options?.map((opt) => `- ${opt.name}: ${opt.description}`).join("\n")}`;
4099
4145
  actions: ["SELECT_OPTION_ERROR"],
4100
4146
  source: message.content.source
4101
4147
  });
4102
- return;
4148
+ return {
4149
+ text: "Error aborting task",
4150
+ values: {
4151
+ success: false,
4152
+ error: "ABORT_ERROR"
4153
+ },
4154
+ data: {
4155
+ actionName: "CHOOSE_OPTION",
4156
+ error: "Could not abort task"
4157
+ },
4158
+ success: false
4159
+ };
4103
4160
  }
4104
4161
  await runtime.deleteTask(selectedTask.id);
4105
4162
  await callback?.({
@@ -4107,7 +4164,22 @@ ${task.options?.map((opt) => `- ${opt.name}: ${opt.description}`).join("\n")}`;
4107
4164
  actions: ["CHOOSE_OPTION_CANCELLED"],
4108
4165
  source: message.content.source
4109
4166
  });
4110
- return;
4167
+ return {
4168
+ text: `Task "${selectedTask.name}" has been cancelled`,
4169
+ values: {
4170
+ success: true,
4171
+ taskAborted: true,
4172
+ taskId: selectedTask.id,
4173
+ taskName: selectedTask.name
4174
+ },
4175
+ data: {
4176
+ actionName: "CHOOSE_OPTION",
4177
+ selectedOption: "ABORT",
4178
+ taskId: selectedTask.id,
4179
+ taskName: selectedTask.name
4180
+ },
4181
+ success: true
4182
+ };
4111
4183
  }
4112
4184
  try {
4113
4185
  const taskWorker = runtime.getTaskWorker(selectedTask.name);
@@ -4117,7 +4189,23 @@ ${task.options?.map((opt) => `- ${opt.name}: ${opt.description}`).join("\n")}`;
4117
4189
  actions: ["CHOOSE_OPTION"],
4118
4190
  source: message.content.source
4119
4191
  });
4120
- return;
4192
+ return {
4193
+ text: `Selected option: ${selectedOption} for task: ${selectedTask.name}`,
4194
+ values: {
4195
+ success: true,
4196
+ selectedOption,
4197
+ taskId: selectedTask.id,
4198
+ taskName: selectedTask.name,
4199
+ taskExecuted: true
4200
+ },
4201
+ data: {
4202
+ actionName: "CHOOSE_OPTION",
4203
+ selectedOption,
4204
+ taskId: selectedTask.id,
4205
+ taskName: selectedTask.name
4206
+ },
4207
+ success: true
4208
+ };
4121
4209
  } catch (error) {
4122
4210
  logger.error("Error executing task with option:", error);
4123
4211
  await callback?.({
@@ -4125,7 +4213,21 @@ ${task.options?.map((opt) => `- ${opt.name}: ${opt.description}`).join("\n")}`;
4125
4213
  actions: ["SELECT_OPTION_ERROR"],
4126
4214
  source: message.content.source
4127
4215
  });
4128
- return;
4216
+ return {
4217
+ text: "Error processing selection",
4218
+ values: {
4219
+ success: false,
4220
+ error: "EXECUTION_ERROR"
4221
+ },
4222
+ data: {
4223
+ actionName: "CHOOSE_OPTION",
4224
+ error: error instanceof Error ? error.message : String(error),
4225
+ taskId: selectedTask.id,
4226
+ selectedOption
4227
+ },
4228
+ success: false,
4229
+ error: error instanceof Error ? error : new Error(String(error))
4230
+ };
4129
4231
  }
4130
4232
  }
4131
4233
  let optionsText = "Please select a valid option from one of these tasks:\n\n";
@@ -4145,6 +4247,20 @@ ${task.options?.map((opt) => `- ${opt.name}: ${opt.description}`).join("\n")}`;
4145
4247
  actions: ["SELECT_OPTION_INVALID"],
4146
4248
  source: message.content.source
4147
4249
  });
4250
+ return {
4251
+ text: "No valid option selected",
4252
+ values: {
4253
+ success: false,
4254
+ error: "NO_SELECTION",
4255
+ availableTasks: tasksWithOptions.length
4256
+ },
4257
+ data: {
4258
+ actionName: "CHOOSE_OPTION",
4259
+ error: "No valid selection made",
4260
+ availableTasks: formattedTasks
4261
+ },
4262
+ success: false
4263
+ };
4148
4264
  },
4149
4265
  examples: [
4150
4266
  [
@@ -4215,7 +4331,19 @@ var followRoomAction = {
4215
4331
  handler: async (runtime, message, state, _options, _callback, _responses) => {
4216
4332
  if (!state) {
4217
4333
  logger2.error("State is required for followRoomAction");
4218
- throw new Error("State is required for followRoomAction");
4334
+ return {
4335
+ text: "State is required for follow room action",
4336
+ values: {
4337
+ success: false,
4338
+ error: "STATE_REQUIRED"
4339
+ },
4340
+ data: {
4341
+ actionName: "FOLLOW_ROOM",
4342
+ error: "State is required"
4343
+ },
4344
+ success: false,
4345
+ error: new Error("State is required for followRoomAction")
4346
+ };
4219
4347
  }
4220
4348
  async function _shouldFollow(state2) {
4221
4349
  const shouldFollowPrompt = composePromptFromState2({
@@ -4270,22 +4398,77 @@ var followRoomAction = {
4270
4398
  logger2.warn(`Unclear boolean response: ${response}, defaulting to false`);
4271
4399
  return false;
4272
4400
  }
4273
- if (await _shouldFollow(state)) {
4274
- await runtime.setParticipantUserState(message.roomId, runtime.agentId, "FOLLOWED");
4275
- }
4401
+ const shouldFollow = await _shouldFollow(state);
4276
4402
  const room = state.data.room ?? await runtime.getRoom(message.roomId);
4277
- await runtime.createMemory(
4278
- {
4279
- entityId: message.entityId,
4280
- agentId: message.agentId,
4281
- roomId: message.roomId,
4282
- content: {
4283
- thought: `I followed the room ${room.name}`,
4284
- actions: ["FOLLOW_ROOM_START"]
4285
- }
4286
- },
4287
- "messages"
4288
- );
4403
+ if (shouldFollow) {
4404
+ try {
4405
+ await runtime.setParticipantUserState(message.roomId, runtime.agentId, "FOLLOWED");
4406
+ await runtime.createMemory(
4407
+ {
4408
+ entityId: message.entityId,
4409
+ agentId: message.agentId,
4410
+ roomId: message.roomId,
4411
+ content: {
4412
+ thought: `I followed the room ${room.name}`,
4413
+ actions: ["FOLLOW_ROOM_START"]
4414
+ }
4415
+ },
4416
+ "messages"
4417
+ );
4418
+ return {
4419
+ text: `Now following room: ${room.name}`,
4420
+ values: {
4421
+ success: true,
4422
+ roomFollowed: true,
4423
+ roomId: message.roomId,
4424
+ roomName: room.name,
4425
+ newState: "FOLLOWED"
4426
+ },
4427
+ data: {
4428
+ actionName: "FOLLOW_ROOM",
4429
+ roomId: message.roomId,
4430
+ roomName: room.name,
4431
+ followed: true
4432
+ },
4433
+ success: true
4434
+ };
4435
+ } catch (error) {
4436
+ logger2.error("Error following room:", error);
4437
+ return {
4438
+ text: "Failed to follow room",
4439
+ values: {
4440
+ success: false,
4441
+ error: "FOLLOW_FAILED"
4442
+ },
4443
+ data: {
4444
+ actionName: "FOLLOW_ROOM",
4445
+ error: error instanceof Error ? error.message : String(error),
4446
+ roomId: message.roomId
4447
+ },
4448
+ success: false,
4449
+ error: error instanceof Error ? error : new Error(String(error))
4450
+ };
4451
+ }
4452
+ } else {
4453
+ return {
4454
+ text: `Decided not to follow room: ${room.name}`,
4455
+ values: {
4456
+ success: true,
4457
+ roomFollowed: false,
4458
+ roomId: message.roomId,
4459
+ roomName: room.name,
4460
+ reason: "NOT_APPROPRIATE"
4461
+ },
4462
+ data: {
4463
+ actionName: "FOLLOW_ROOM",
4464
+ roomId: message.roomId,
4465
+ roomName: room.name,
4466
+ followed: false,
4467
+ reason: "Decision criteria not met"
4468
+ },
4469
+ success: true
4470
+ };
4471
+ }
4289
4472
  },
4290
4473
  examples: [
4291
4474
  [
@@ -4574,7 +4757,6 @@ var ignoreAction = {
4574
4757
  if (callback && responses?.[0]?.content) {
4575
4758
  await callback(responses[0].content);
4576
4759
  }
4577
- return true;
4578
4760
  },
4579
4761
  examples: [
4580
4762
  [
@@ -4815,7 +4997,19 @@ var muteRoomAction = {
4815
4997
  handler: async (runtime, message, state, _options, _callback, _responses) => {
4816
4998
  if (!state) {
4817
4999
  logger3.error("State is required for muting a room");
4818
- throw new Error("State is required for muting a room");
5000
+ return {
5001
+ text: "State is required for mute room action",
5002
+ values: {
5003
+ success: false,
5004
+ error: "STATE_REQUIRED"
5005
+ },
5006
+ data: {
5007
+ actionName: "MUTE_ROOM",
5008
+ error: "State is required"
5009
+ },
5010
+ success: false,
5011
+ error: new Error("State is required for muting a room")
5012
+ };
4819
5013
  }
4820
5014
  async function _shouldMute(state2) {
4821
5015
  const shouldMutePrompt = composePromptFromState3({
@@ -4869,22 +5063,77 @@ var muteRoomAction = {
4869
5063
  logger3.warn(`Unclear boolean response: ${response}, defaulting to false`);
4870
5064
  return false;
4871
5065
  }
4872
- if (await _shouldMute(state)) {
4873
- await runtime.setParticipantUserState(message.roomId, runtime.agentId, "MUTED");
4874
- }
5066
+ const shouldMute = await _shouldMute(state);
4875
5067
  const room = state.data.room ?? await runtime.getRoom(message.roomId);
4876
- await runtime.createMemory(
4877
- {
4878
- entityId: message.entityId,
4879
- agentId: message.agentId,
4880
- roomId: message.roomId,
4881
- content: {
4882
- thought: `I muted the room ${room.name}`,
4883
- actions: ["MUTE_ROOM_START"]
4884
- }
4885
- },
4886
- "messages"
4887
- );
5068
+ if (shouldMute) {
5069
+ try {
5070
+ await runtime.setParticipantUserState(message.roomId, runtime.agentId, "MUTED");
5071
+ await runtime.createMemory(
5072
+ {
5073
+ entityId: message.entityId,
5074
+ agentId: message.agentId,
5075
+ roomId: message.roomId,
5076
+ content: {
5077
+ thought: `I muted the room ${room.name}`,
5078
+ actions: ["MUTE_ROOM_START"]
5079
+ }
5080
+ },
5081
+ "messages"
5082
+ );
5083
+ return {
5084
+ text: `Room muted: ${room.name}`,
5085
+ values: {
5086
+ success: true,
5087
+ roomMuted: true,
5088
+ roomId: message.roomId,
5089
+ roomName: room.name,
5090
+ newState: "MUTED"
5091
+ },
5092
+ data: {
5093
+ actionName: "MUTE_ROOM",
5094
+ roomId: message.roomId,
5095
+ roomName: room.name,
5096
+ muted: true
5097
+ },
5098
+ success: true
5099
+ };
5100
+ } catch (error) {
5101
+ logger3.error("Error muting room:", error);
5102
+ return {
5103
+ text: "Failed to mute room",
5104
+ values: {
5105
+ success: false,
5106
+ error: "MUTE_FAILED"
5107
+ },
5108
+ data: {
5109
+ actionName: "MUTE_ROOM",
5110
+ error: error instanceof Error ? error.message : String(error),
5111
+ roomId: message.roomId
5112
+ },
5113
+ success: false,
5114
+ error: error instanceof Error ? error : new Error(String(error))
5115
+ };
5116
+ }
5117
+ } else {
5118
+ return {
5119
+ text: `Decided not to mute room: ${room.name}`,
5120
+ values: {
5121
+ success: true,
5122
+ roomMuted: false,
5123
+ roomId: message.roomId,
5124
+ roomName: room.name,
5125
+ reason: "NOT_APPROPRIATE"
5126
+ },
5127
+ data: {
5128
+ actionName: "MUTE_ROOM",
5129
+ roomId: message.roomId,
5130
+ roomName: room.name,
5131
+ muted: false,
5132
+ reason: "Decision criteria not met"
5133
+ },
5134
+ success: true
5135
+ };
5136
+ }
4888
5137
  },
4889
5138
  examples: [
4890
5139
  [
@@ -5006,7 +5255,18 @@ var noneAction = {
5006
5255
  },
5007
5256
  description: "Respond but perform no additional action. This is the default if the agent is speaking and not doing anything additional.",
5008
5257
  handler: async (_runtime, _message) => {
5009
- return true;
5258
+ return {
5259
+ text: "No additional action taken",
5260
+ values: {
5261
+ success: true,
5262
+ actionType: "NONE"
5263
+ },
5264
+ data: {
5265
+ actionName: "NONE",
5266
+ description: "Response without additional action"
5267
+ },
5268
+ success: true
5269
+ };
5010
5270
  },
5011
5271
  examples: [
5012
5272
  [
@@ -5131,14 +5391,23 @@ var noneAction = {
5131
5391
  // src/actions/reply.ts
5132
5392
  import {
5133
5393
  composePromptFromState as composePromptFromState4,
5134
- ModelType as ModelType5
5394
+ ModelType as ModelType5,
5395
+ logger as logger4
5135
5396
  } from "@elizaos/core";
5136
5397
  var replyTemplate = `# Task: Generate dialog for the character {{agentName}}.
5398
+
5137
5399
  {{providers}}
5400
+
5138
5401
  # Instructions: Write the next message for {{agentName}}.
5139
5402
  "thought" should be a short description of what the agent is thinking about and planning.
5140
5403
  "message" should be the next message for {{agentName}} which they will send to the conversation.
5141
5404
 
5405
+ IMPORTANT CODE BLOCK FORMATTING RULES:
5406
+ - If {{agentName}} includes code examples, snippets, or multi-line code in the response, ALWAYS wrap the code with \`\`\` fenced code blocks (specify the language if known, e.g., \`\`\`python).
5407
+ - ONLY use fenced code blocks for actual code. Do NOT wrap non-code text, instructions, or single words in fenced code blocks.
5408
+ - If including inline code (short single words or function names), use single backticks (\`) as appropriate.
5409
+ - This ensures the user sees clearly formatted and copyable code when relevant.
5410
+
5142
5411
  Response format should be formatted in a valid JSON block like this:
5143
5412
  \`\`\`json
5144
5413
  {
@@ -5156,22 +5425,65 @@ var replyAction = {
5156
5425
  return true;
5157
5426
  },
5158
5427
  handler: async (runtime, message, state, _options, callback, responses) => {
5428
+ const context = _options?.context;
5429
+ const previousResults = context?.previousResults || [];
5430
+ if (previousResults.length > 0) {
5431
+ logger4.debug(`[REPLY] Found ${previousResults.length} previous action results`);
5432
+ }
5159
5433
  const allProviders = responses?.flatMap((res) => res.content?.providers ?? []) ?? [];
5160
- state = await runtime.composeState(message, [...allProviders ?? [], "RECENT_MESSAGES"]);
5434
+ state = await runtime.composeState(message, [
5435
+ ...allProviders ?? [],
5436
+ "RECENT_MESSAGES",
5437
+ "ACTION_STATE"
5438
+ ]);
5161
5439
  const prompt = composePromptFromState4({
5162
5440
  state,
5163
5441
  template: replyTemplate
5164
5442
  });
5165
- const response = await runtime.useModel(ModelType5.OBJECT_LARGE, {
5166
- prompt
5167
- });
5168
- const responseContent = {
5169
- thought: response.thought,
5170
- text: response.message || "",
5171
- actions: ["REPLY"]
5172
- };
5173
- await callback(responseContent);
5174
- return true;
5443
+ try {
5444
+ const response = await runtime.useModel(ModelType5.OBJECT_LARGE, {
5445
+ prompt
5446
+ });
5447
+ const responseContent = {
5448
+ thought: response.thought,
5449
+ text: response.message || "",
5450
+ actions: ["REPLY"]
5451
+ };
5452
+ await callback(responseContent);
5453
+ return {
5454
+ text: `Generated reply: ${responseContent.text}`,
5455
+ values: {
5456
+ success: true,
5457
+ responded: true,
5458
+ lastReply: responseContent.text,
5459
+ lastReplyTime: Date.now(),
5460
+ thoughtProcess: response.thought
5461
+ },
5462
+ data: {
5463
+ actionName: "REPLY",
5464
+ response: responseContent,
5465
+ thought: response.thought,
5466
+ messageGenerated: true
5467
+ },
5468
+ success: true
5469
+ };
5470
+ } catch (error) {
5471
+ logger4.error(`[REPLY] Error generating response: ${error}`);
5472
+ return {
5473
+ text: "Error generating reply",
5474
+ values: {
5475
+ success: false,
5476
+ responded: false,
5477
+ error: true
5478
+ },
5479
+ data: {
5480
+ actionName: "REPLY",
5481
+ error: error instanceof Error ? error.message : String(error)
5482
+ },
5483
+ success: false,
5484
+ error: error instanceof Error ? error : new Error(String(error))
5485
+ };
5486
+ }
5175
5487
  },
5176
5488
  examples: [
5177
5489
  [
@@ -5242,7 +5554,7 @@ var import_dedent = __toESM(require_dedent(), 1);
5242
5554
  import {
5243
5555
  ChannelType,
5244
5556
  composePrompt as composePrompt2,
5245
- logger as logger4,
5557
+ logger as logger5,
5246
5558
  ModelType as ModelType6,
5247
5559
  Role
5248
5560
  } from "@elizaos/core";
@@ -5276,8 +5588,20 @@ var updateRoleAction = {
5276
5588
  },
5277
5589
  handler: async (runtime, message, state, _options, callback) => {
5278
5590
  if (!state) {
5279
- logger4.error("State is required for role assignment");
5280
- throw new Error("State is required for role assignment");
5591
+ logger5.error("State is required for role assignment");
5592
+ return {
5593
+ text: "State is required for role assignment",
5594
+ values: {
5595
+ success: false,
5596
+ error: "STATE_REQUIRED"
5597
+ },
5598
+ data: {
5599
+ actionName: "UPDATE_ROLE",
5600
+ error: "State is required"
5601
+ },
5602
+ success: false,
5603
+ error: new Error("State is required for role assignment")
5604
+ };
5281
5605
  }
5282
5606
  const { roomId } = message;
5283
5607
  const serverId = message.content.serverId;
@@ -5287,11 +5611,22 @@ var updateRoleAction = {
5287
5611
  world = await runtime.getWorld(worldId);
5288
5612
  }
5289
5613
  if (!world) {
5290
- logger4.error("World not found");
5614
+ logger5.error("World not found");
5291
5615
  await callback?.({
5292
5616
  text: "I couldn't find the world. This action only works in a world."
5293
5617
  });
5294
- return;
5618
+ return {
5619
+ text: "World not found",
5620
+ values: {
5621
+ success: false,
5622
+ error: "WORLD_NOT_FOUND"
5623
+ },
5624
+ data: {
5625
+ actionName: "UPDATE_ROLE",
5626
+ error: "World not found"
5627
+ },
5628
+ success: false
5629
+ };
5295
5630
  }
5296
5631
  if (!world.metadata?.roles) {
5297
5632
  world.metadata = world.metadata || {};
@@ -5363,13 +5698,31 @@ var updateRoleAction = {
5363
5698
  actions: ["UPDATE_ROLE"],
5364
5699
  source: "discord"
5365
5700
  });
5366
- return;
5701
+ return {
5702
+ text: "No valid role assignments found",
5703
+ values: {
5704
+ success: false,
5705
+ error: "NO_ASSIGNMENTS"
5706
+ },
5707
+ data: {
5708
+ actionName: "UPDATE_ROLE",
5709
+ error: "No valid role assignments found in the request"
5710
+ },
5711
+ success: false
5712
+ };
5367
5713
  }
5368
5714
  let worldUpdated = false;
5715
+ const successfulUpdates = [];
5716
+ const failedUpdates = [];
5369
5717
  for (const assignment of result) {
5370
5718
  let targetEntity = entities.find((e2) => e2.id === assignment.entityId);
5371
5719
  if (!targetEntity) {
5372
- logger4.error("Could not find an ID ot assign to");
5720
+ logger5.error("Could not find an ID to assign to");
5721
+ failedUpdates.push({
5722
+ entityId: assignment.entityId,
5723
+ reason: "Entity not found"
5724
+ });
5725
+ continue;
5373
5726
  }
5374
5727
  const currentRole = world.metadata.roles[assignment.entityId];
5375
5728
  if (!canModifyRole(requesterRole, currentRole, assignment.newRole)) {
@@ -5378,10 +5731,19 @@ var updateRoleAction = {
5378
5731
  actions: ["UPDATE_ROLE"],
5379
5732
  source: "discord"
5380
5733
  });
5734
+ failedUpdates.push({
5735
+ entityId: assignment.entityId,
5736
+ reason: "Insufficient permissions"
5737
+ });
5381
5738
  continue;
5382
5739
  }
5383
5740
  world.metadata.roles[assignment.entityId] = assignment.newRole;
5384
5741
  worldUpdated = true;
5742
+ successfulUpdates.push({
5743
+ entityId: assignment.entityId,
5744
+ entityName: targetEntity?.names[0] || "Unknown",
5745
+ newRole: assignment.newRole
5746
+ });
5385
5747
  await callback?.({
5386
5748
  text: `Updated ${targetEntity?.names[0]}'s role to ${assignment.newRole}.`,
5387
5749
  actions: ["UPDATE_ROLE"],
@@ -5389,9 +5751,45 @@ var updateRoleAction = {
5389
5751
  });
5390
5752
  }
5391
5753
  if (worldUpdated) {
5392
- await runtime.updateWorld(world);
5393
- logger4.info(`Updated roles in world metadata for server ${serverId}`);
5754
+ try {
5755
+ await runtime.updateWorld(world);
5756
+ logger5.info(`Updated roles in world metadata for server ${serverId}`);
5757
+ } catch (error) {
5758
+ logger5.error("Failed to save world updates:", error);
5759
+ return {
5760
+ text: "Failed to save role updates",
5761
+ values: {
5762
+ success: false,
5763
+ error: "SAVE_FAILED"
5764
+ },
5765
+ data: {
5766
+ actionName: "UPDATE_ROLE",
5767
+ error: error instanceof Error ? error.message : String(error),
5768
+ attemptedUpdates: successfulUpdates
5769
+ },
5770
+ success: false,
5771
+ error: error instanceof Error ? error : new Error(String(error))
5772
+ };
5773
+ }
5394
5774
  }
5775
+ return {
5776
+ text: `Role updates completed: ${successfulUpdates.length} successful, ${failedUpdates.length} failed`,
5777
+ values: {
5778
+ success: true,
5779
+ successfulUpdates: successfulUpdates.length,
5780
+ failedUpdates: failedUpdates.length,
5781
+ updates: successfulUpdates,
5782
+ failures: failedUpdates
5783
+ },
5784
+ data: {
5785
+ actionName: "UPDATE_ROLE",
5786
+ successfulUpdates,
5787
+ failedUpdates,
5788
+ worldId: world.id,
5789
+ serverId
5790
+ },
5791
+ success: true
5792
+ };
5395
5793
  },
5396
5794
  examples: [
5397
5795
  [
@@ -5449,7 +5847,7 @@ var updateRoleAction = {
5449
5847
  import {
5450
5848
  composePromptFromState as composePromptFromState5,
5451
5849
  findEntityByName,
5452
- logger as logger5,
5850
+ logger as logger6,
5453
5851
  ModelType as ModelType7,
5454
5852
  parseJSONObjectFromText as parseJSONObjectFromText2
5455
5853
  } from "@elizaos/core";
@@ -5513,16 +5911,52 @@ var sendMessageAction = {
5513
5911
  handler: async (runtime, message, state, _options, callback, responses) => {
5514
5912
  try {
5515
5913
  if (!state) {
5516
- logger5.error("State is required for sendMessage action");
5517
- throw new Error("State is required for sendMessage action");
5914
+ logger6.error("State is required for sendMessage action");
5915
+ return {
5916
+ text: "State is required for sendMessage action",
5917
+ values: {
5918
+ success: false,
5919
+ error: "STATE_REQUIRED"
5920
+ },
5921
+ data: {
5922
+ actionName: "SEND_MESSAGE",
5923
+ error: "State is required"
5924
+ },
5925
+ success: false,
5926
+ error: new Error("State is required for sendMessage action")
5927
+ };
5518
5928
  }
5519
5929
  if (!callback) {
5520
- logger5.error("Callback is required for sendMessage action");
5521
- throw new Error("Callback is required for sendMessage action");
5930
+ logger6.error("Callback is required for sendMessage action");
5931
+ return {
5932
+ text: "Callback is required for sendMessage action",
5933
+ values: {
5934
+ success: false,
5935
+ error: "CALLBACK_REQUIRED"
5936
+ },
5937
+ data: {
5938
+ actionName: "SEND_MESSAGE",
5939
+ error: "Callback is required"
5940
+ },
5941
+ success: false,
5942
+ error: new Error("Callback is required for sendMessage action")
5943
+ };
5522
5944
  }
5523
5945
  if (!responses) {
5524
- logger5.error("Responses are required for sendMessage action");
5525
- throw new Error("Responses are required for sendMessage action");
5946
+ logger6.error("Responses are required for sendMessage action");
5947
+ return {
5948
+ text: "Responses are required for sendMessage action",
5949
+ values: {
5950
+ success: false,
5951
+ error: "RESPONSES_REQUIRED"
5952
+ },
5953
+ data: {
5954
+ actionName: "SEND_MESSAGE",
5955
+ error: "Responses are required"
5956
+ },
5957
+ success: false,
5958
+ error: new Error("Responses are required for sendMessage action")
5959
+ };
5526
5960
  }
5527
5961
  for (const response of responses) {
5528
5962
  await callback(response.content);
@@ -5545,7 +5979,18 @@ var sendMessageAction = {
5545
5979
  actions: ["SEND_MESSAGE_ERROR"],
5546
5980
  source: message.content.source
5547
5981
  });
5548
- return;
5982
+ return {
5983
+ text: "Could not determine message target",
5984
+ values: {
5985
+ success: false,
5986
+ error: "TARGET_UNCLEAR"
5987
+ },
5988
+ data: {
5989
+ actionName: "SEND_MESSAGE",
5990
+ error: "Could not parse target information from message"
5991
+ },
5992
+ success: false
5993
+ };
5549
5994
  }
5550
5995
  const source = targetData.source.toLowerCase();
5551
5996
  if (targetData.targetType === "user") {
@@ -5556,7 +6001,21 @@ var sendMessageAction = {
5556
6001
  actions: ["SEND_MESSAGE_ERROR"],
5557
6002
  source: message.content.source
5558
6003
  });
5559
- return;
6004
+ return {
6005
+ text: "Target user not found",
6006
+ values: {
6007
+ success: false,
6008
+ error: "USER_NOT_FOUND",
6009
+ targetType: "user"
6010
+ },
6011
+ data: {
6012
+ actionName: "SEND_MESSAGE",
6013
+ error: "Could not find target user",
6014
+ targetType: "user",
6015
+ source
6016
+ },
6017
+ success: false
6018
+ };
5560
6019
  }
5561
6020
  const userComponent = await runtime.getComponent(
5562
6021
  targetEntity.id,
@@ -5570,7 +6029,23 @@ var sendMessageAction = {
5570
6029
  actions: ["SEND_MESSAGE_ERROR"],
5571
6030
  source: message.content.source
5572
6031
  });
5573
- return;
6032
+ return {
6033
+ text: `No ${source} information found for user`,
6034
+ values: {
6035
+ success: false,
6036
+ error: "COMPONENT_NOT_FOUND",
6037
+ targetType: "user",
6038
+ source
6039
+ },
6040
+ data: {
6041
+ actionName: "SEND_MESSAGE",
6042
+ error: `No ${source} component found for target user`,
6043
+ targetType: "user",
6044
+ targetEntityId: targetEntity.id,
6045
+ source
6046
+ },
6047
+ success: false
6048
+ };
5574
6049
  }
5575
6050
  const sendDirectMessage = runtime.getService(source)?.sendDirectMessage;
5576
6051
  if (!sendDirectMessage) {
@@ -5579,7 +6054,22 @@ var sendMessageAction = {
5579
6054
  actions: ["SEND_MESSAGE_ERROR"],
5580
6055
  source: message.content.source
5581
6056
  });
5582
- return;
6057
+ return {
6058
+ text: "Message service not available",
6059
+ values: {
6060
+ success: false,
6061
+ error: "SERVICE_NOT_FOUND",
6062
+ targetType: "user",
6063
+ source
6064
+ },
6065
+ data: {
6066
+ actionName: "SEND_MESSAGE",
6067
+ error: `No sendDirectMessage service found for ${source}`,
6068
+ targetType: "user",
6069
+ source
6070
+ },
6071
+ success: false
6072
+ };
5583
6073
  }
5584
6074
  try {
5585
6075
  await sendDirectMessage(runtime, targetEntity.id, source, message.content.text, worldId);
@@ -5588,13 +6078,51 @@ var sendMessageAction = {
5588
6078
  actions: ["SEND_MESSAGE"],
5589
6079
  source: message.content.source
5590
6080
  });
6081
+ return {
6082
+ text: `Message sent to ${targetEntity.names[0]}`,
6083
+ values: {
6084
+ success: true,
6085
+ targetType: "user",
6086
+ targetId: targetEntity.id,
6087
+ targetName: targetEntity.names[0],
6088
+ source,
6089
+ messageSent: true
6090
+ },
6091
+ data: {
6092
+ actionName: "SEND_MESSAGE",
6093
+ targetType: "user",
6094
+ targetId: targetEntity.id,
6095
+ targetName: targetEntity.names[0],
6096
+ source,
6097
+ messageContent: message.content.text
6098
+ },
6099
+ success: true
6100
+ };
5591
6101
  } catch (error) {
5592
- logger5.error(`Failed to send direct message: ${error.message}`);
6102
+ logger6.error(`Failed to send direct message: ${error.message}`);
5593
6103
  await callback({
5594
6104
  text: "I encountered an error trying to send the message. Please try again.",
5595
6105
  actions: ["SEND_MESSAGE_ERROR"],
5596
6106
  source: message.content.source
5597
6107
  });
6108
+ return {
6109
+ text: "Failed to send direct message",
6110
+ values: {
6111
+ success: false,
6112
+ error: "SEND_FAILED",
6113
+ targetType: "user",
6114
+ source
6115
+ },
6116
+ data: {
6117
+ actionName: "SEND_MESSAGE",
6118
+ error: error.message,
6119
+ targetType: "user",
6120
+ targetId: targetEntity.id,
6121
+ source
6122
+ },
6123
+ success: false,
6124
+ error: error instanceof Error ? error : new Error(String(error))
6125
+ };
5598
6126
  }
5599
6127
  } else if (targetData.targetType === "room") {
5600
6128
  const rooms = await runtime.getRooms(worldId);
@@ -5607,7 +6135,23 @@ var sendMessageAction = {
5607
6135
  actions: ["SEND_MESSAGE_ERROR"],
5608
6136
  source: message.content.source
5609
6137
  });
5610
- return;
6138
+ return {
6139
+ text: "Target room not found",
6140
+ values: {
6141
+ success: false,
6142
+ error: "ROOM_NOT_FOUND",
6143
+ targetType: "room",
6144
+ roomName: targetData.identifiers.roomName
6145
+ },
6146
+ data: {
6147
+ actionName: "SEND_MESSAGE",
6148
+ error: "Could not find target room",
6149
+ targetType: "room",
6150
+ roomName: targetData.identifiers.roomName,
6151
+ source
6152
+ },
6153
+ success: false
6154
+ };
5611
6155
  }
5612
6156
  const sendRoomMessage = runtime.getService(source)?.sendRoomMessage;
5613
6157
  if (!sendRoomMessage) {
@@ -5616,7 +6160,22 @@ var sendMessageAction = {
5616
6160
  actions: ["SEND_MESSAGE_ERROR"],
5617
6161
  source: message.content.source
5618
6162
  });
5619
- return;
6163
+ return {
6164
+ text: "Room message service not available",
6165
+ values: {
6166
+ success: false,
6167
+ error: "SERVICE_NOT_FOUND",
6168
+ targetType: "room",
6169
+ source
6170
+ },
6171
+ data: {
6172
+ actionName: "SEND_MESSAGE",
6173
+ error: `No sendRoomMessage service found for ${source}`,
6174
+ targetType: "room",
6175
+ source
6176
+ },
6177
+ success: false
6178
+ };
5620
6179
  }
5621
6180
  try {
5622
6181
  await sendRoomMessage(runtime, targetRoom.id, source, message.content.text, worldId);
@@ -5625,22 +6184,86 @@ var sendMessageAction = {
5625
6184
  actions: ["SEND_MESSAGE"],
5626
6185
  source: message.content.source
5627
6186
  });
6187
+ return {
6188
+ text: `Message sent to ${targetRoom.name}`,
6189
+ values: {
6190
+ success: true,
6191
+ targetType: "room",
6192
+ targetId: targetRoom.id,
6193
+ targetName: targetRoom.name,
6194
+ source,
6195
+ messageSent: true
6196
+ },
6197
+ data: {
6198
+ actionName: "SEND_MESSAGE",
6199
+ targetType: "room",
6200
+ targetId: targetRoom.id,
6201
+ targetName: targetRoom.name,
6202
+ source,
6203
+ messageContent: message.content.text
6204
+ },
6205
+ success: true
6206
+ };
5628
6207
  } catch (error) {
5629
- logger5.error(`Failed to send room message: ${error.message}`);
6208
+ logger6.error(`Failed to send room message: ${error.message}`);
5630
6209
  await callback({
5631
6210
  text: "I encountered an error trying to send the message to the room. Please try again.",
5632
6211
  actions: ["SEND_MESSAGE_ERROR"],
5633
6212
  source: message.content.source
5634
6213
  });
6214
+ return {
6215
+ text: "Failed to send room message",
6216
+ values: {
6217
+ success: false,
6218
+ error: "SEND_FAILED",
6219
+ targetType: "room",
6220
+ source
6221
+ },
6222
+ data: {
6223
+ actionName: "SEND_MESSAGE",
6224
+ error: error.message,
6225
+ targetType: "room",
6226
+ targetId: targetRoom.id,
6227
+ targetName: targetRoom.name,
6228
+ source
6229
+ },
6230
+ success: false,
6231
+ error: error instanceof Error ? error : new Error(String(error))
6232
+ };
5635
6233
  }
5636
6234
  }
6235
+ return {
6236
+ text: "Unknown target type",
6237
+ values: {
6238
+ success: false,
6239
+ error: "UNKNOWN_TARGET_TYPE"
6240
+ },
6241
+ data: {
6242
+ actionName: "SEND_MESSAGE",
6243
+ error: "Unknown target type: " + targetData.targetType
6244
+ },
6245
+ success: false
6246
+ };
5637
6247
  } catch (error) {
5638
- logger5.error(`Error in sendMessage handler: ${error}`);
6248
+ logger6.error(`Error in sendMessage handler: ${error}`);
5639
6249
  await callback?.({
5640
6250
  text: "There was an error processing your message request.",
5641
6251
  actions: ["SEND_MESSAGE_ERROR"],
5642
6252
  source: message.content.source
5643
6253
  });
6254
+ return {
6255
+ text: "Error processing message request",
6256
+ values: {
6257
+ success: false,
6258
+ error: "HANDLER_ERROR"
6259
+ },
6260
+ data: {
6261
+ actionName: "SEND_MESSAGE",
6262
+ error: error instanceof Error ? error.message : String(error)
6263
+ },
6264
+ success: false,
6265
+ error: error instanceof Error ? error : new Error(String(error))
6266
+ };
5644
6267
  }
5645
6268
  },
5646
6269
  examples: [
@@ -5700,7 +6323,7 @@ import {
5700
6323
  composePromptFromState as composePromptFromState6,
5701
6324
  createUniqueUuid,
5702
6325
  findWorldsForOwner,
5703
- logger as logger6,
6326
+ logger as logger7,
5704
6327
  ModelType as ModelType8,
5705
6328
  parseJSONObjectFromText as parseJSONObjectFromText3
5706
6329
  } from "@elizaos/core";
@@ -5805,7 +6428,7 @@ async function getWorldSettings(runtime, serverId) {
5805
6428
  }
5806
6429
  return world.metadata.settings;
5807
6430
  } catch (error) {
5808
- logger6.error(`Error getting settings state: ${error}`);
6431
+ logger7.error(`Error getting settings state: ${error}`);
5809
6432
  return null;
5810
6433
  }
5811
6434
  }
@@ -5814,7 +6437,7 @@ async function updateWorldSettings(runtime, serverId, worldSettings) {
5814
6437
  const worldId = createUniqueUuid(runtime, serverId);
5815
6438
  const world = await runtime.getWorld(worldId);
5816
6439
  if (!world) {
5817
- logger6.error(`No world found for server ${serverId}`);
6440
+ logger7.error(`No world found for server ${serverId}`);
5818
6441
  return false;
5819
6442
  }
5820
6443
  if (!world.metadata) {
@@ -5824,7 +6447,7 @@ async function updateWorldSettings(runtime, serverId, worldSettings) {
5824
6447
  await runtime.updateWorld(world);
5825
6448
  return true;
5826
6449
  } catch (error) {
5827
- logger6.error(`Error updating settings state: ${error}`);
6450
+ logger7.error(`Error updating settings state: ${error}`);
5828
6451
  return false;
5829
6452
  }
5830
6453
  }
@@ -5842,12 +6465,13 @@ function categorizeSettings(worldSettings) {
5842
6465
  const optionalUnconfigured = [];
5843
6466
  for (const [key, setting] of Object.entries(worldSettings)) {
5844
6467
  if (key.startsWith("_")) continue;
5845
- if (setting.value !== null) {
5846
- configured.push([key, setting]);
5847
- } else if (setting.required) {
5848
- requiredUnconfigured.push([key, setting]);
6468
+ const typedSetting = setting;
6469
+ if (typedSetting.value !== null) {
6470
+ configured.push([key, typedSetting]);
6471
+ } else if (typedSetting.required) {
6472
+ requiredUnconfigured.push([key, typedSetting]);
5849
6473
  } else {
5850
- optionalUnconfigured.push([key, setting]);
6474
+ optionalUnconfigured.push([key, typedSetting]);
5851
6475
  }
5852
6476
  }
5853
6477
  return { configured, requiredUnconfigured, optionalUnconfigured };
@@ -5964,7 +6588,7 @@ async function processSettingUpdates(runtime, serverId, worldSettings, updates)
5964
6588
  }
5965
6589
  return { updatedAny, messages };
5966
6590
  } catch (error) {
5967
- logger6.error("Error processing setting updates:", error);
6591
+ logger7.error("Error processing setting updates:", error);
5968
6592
  return {
5969
6593
  updatedAny: false,
5970
6594
  messages: ["Error occurred while updating settings"]
@@ -5988,21 +6612,48 @@ async function handleOnboardingComplete(runtime, worldSettings, _state, callback
5988
6612
  actions: ["ONBOARDING_COMPLETE"],
5989
6613
  source: "discord"
5990
6614
  });
6615
+ return {
6616
+ text: "Onboarding completed successfully",
6617
+ values: {
6618
+ success: true,
6619
+ onboardingComplete: true,
6620
+ allRequiredConfigured: true
6621
+ },
6622
+ data: {
6623
+ actionName: "UPDATE_SETTINGS",
6624
+ action: "ONBOARDING_COMPLETE",
6625
+ settingsStatus: formatSettingsList(worldSettings)
6626
+ },
6627
+ success: true
6628
+ };
5991
6629
  } catch (error) {
5992
- logger6.error(`Error handling settings completion: ${error}`);
6630
+ logger7.error(`Error handling settings completion: ${error}`);
5993
6631
  await callback({
5994
6632
  text: "Great! All required settings have been configured. Your server is now fully set up and ready to use.",
5995
6633
  actions: ["ONBOARDING_COMPLETE"],
5996
6634
  source: "discord"
5997
6635
  });
6636
+ return {
6637
+ text: "Onboarding completed with fallback message",
6638
+ values: {
6639
+ success: true,
6640
+ onboardingComplete: true,
6641
+ fallbackUsed: true
6642
+ },
6643
+ data: {
6644
+ actionName: "UPDATE_SETTINGS",
6645
+ action: "ONBOARDING_COMPLETE",
6646
+ error: error instanceof Error ? error.message : String(error)
6647
+ },
6648
+ success: true
6649
+ };
5998
6650
  }
5999
6651
  }
6000
6652
  async function generateSuccessResponse(runtime, worldSettings, state, messages, callback) {
6001
6653
  try {
6002
6654
  const { requiredUnconfigured } = categorizeSettings(worldSettings);
6003
6655
  if (requiredUnconfigured.length === 0) {
6004
- await handleOnboardingComplete(runtime, worldSettings, state, callback);
6005
- return;
6656
+ return await handleOnboardingComplete(runtime, worldSettings, state, callback);
6006
6657
  }
6007
6658
  const requiredUnconfiguredString = requiredUnconfigured.map(([key, setting]) => `${key}: ${setting.name}`).join("\n");
6008
6659
  const prompt = composePrompt3({
@@ -6022,21 +6673,49 @@ async function generateSuccessResponse(runtime, worldSettings, state, messages,
6022
6673
  actions: ["SETTING_UPDATED"],
6023
6674
  source: "discord"
6024
6675
  });
6676
+ return {
6677
+ text: "Settings updated successfully",
6678
+ values: {
6679
+ success: true,
6680
+ settingsUpdated: true,
6681
+ remainingRequired: requiredUnconfigured.length
6682
+ },
6683
+ data: {
6684
+ actionName: "UPDATE_SETTINGS",
6685
+ action: "SETTING_UPDATED",
6686
+ updatedMessages: messages,
6687
+ remainingRequired: requiredUnconfigured.length
6688
+ },
6689
+ success: true
6690
+ };
6025
6691
  } catch (error) {
6026
- logger6.error(`Error generating success response: ${error}`);
6692
+ logger7.error(`Error generating success response: ${error}`);
6027
6693
  await callback({
6028
6694
  text: "Settings updated successfully. Please continue with the remaining configuration.",
6029
6695
  actions: ["SETTING_UPDATED"],
6030
6696
  source: "discord"
6031
6697
  });
6698
+ return {
6699
+ text: "Settings updated with fallback message",
6700
+ values: {
6701
+ success: true,
6702
+ settingsUpdated: true,
6703
+ fallbackUsed: true
6704
+ },
6705
+ data: {
6706
+ actionName: "UPDATE_SETTINGS",
6707
+ action: "SETTING_UPDATED",
6708
+ error: error instanceof Error ? error.message : String(error)
6709
+ },
6710
+ success: true
6711
+ };
6032
6712
  }
6033
6713
  }
6034
6714
  async function generateFailureResponse(runtime, worldSettings, state, callback) {
6035
6715
  try {
6036
6716
  const { requiredUnconfigured } = categorizeSettings(worldSettings);
6037
6717
  if (requiredUnconfigured.length === 0) {
6038
- await handleOnboardingComplete(runtime, worldSettings, state, callback);
6039
- return;
6718
+ return await handleOnboardingComplete(runtime, worldSettings, state, callback);
6040
6719
  }
6041
6720
  const requiredUnconfiguredString = requiredUnconfigured.map(([key, setting]) => `${key}: ${setting.name}`).join("\n");
6042
6721
  const prompt = composePrompt3({
@@ -6055,13 +6734,41 @@ async function generateFailureResponse(runtime, worldSettings, state, callback)
6055
6734
  actions: ["SETTING_UPDATE_FAILED"],
6056
6735
  source: "discord"
6057
6736
  });
6737
+ return {
6738
+ text: "No settings were updated",
6739
+ values: {
6740
+ success: false,
6741
+ settingsUpdated: false,
6742
+ remainingRequired: requiredUnconfigured.length
6743
+ },
6744
+ data: {
6745
+ actionName: "UPDATE_SETTINGS",
6746
+ action: "SETTING_UPDATE_FAILED",
6747
+ remainingRequired: requiredUnconfigured.length
6748
+ },
6749
+ success: false
6750
+ };
6058
6751
  } catch (error) {
6059
- logger6.error(`Error generating failure response: ${error}`);
6752
+ logger7.error(`Error generating failure response: ${error}`);
6060
6753
  await callback({
6061
6754
  text: "I couldn't understand your settings update. Please try again with a clearer format.",
6062
6755
  actions: ["SETTING_UPDATE_FAILED"],
6063
6756
  source: "discord"
6064
6757
  });
6758
+ return {
6759
+ text: "Failed to parse settings with fallback message",
6760
+ values: {
6761
+ success: false,
6762
+ settingsUpdated: false,
6763
+ fallbackUsed: true
6764
+ },
6765
+ data: {
6766
+ actionName: "UPDATE_SETTINGS",
6767
+ action: "SETTING_UPDATE_FAILED",
6768
+ error: error instanceof Error ? error.message : String(error)
6769
+ },
6770
+ success: false
6771
+ };
6065
6772
  }
6066
6773
  }
6067
6774
  async function generateErrorResponse(runtime, state, callback) {
@@ -6079,13 +6786,40 @@ async function generateErrorResponse(runtime, state, callback) {
6079
6786
  actions: ["SETTING_UPDATE_ERROR"],
6080
6787
  source: "discord"
6081
6788
  });
6789
+ return {
6790
+ text: "Error processing settings",
6791
+ values: {
6792
+ success: false,
6793
+ error: "PROCESSING_ERROR"
6794
+ },
6795
+ data: {
6796
+ actionName: "UPDATE_SETTINGS",
6797
+ action: "SETTING_UPDATE_ERROR"
6798
+ },
6799
+ success: false
6800
+ };
6082
6801
  } catch (error) {
6083
- logger6.error(`Error generating error response: ${error}`);
6802
+ logger7.error(`Error generating error response: ${error}`);
6084
6803
  await callback({
6085
6804
  text: "I'm sorry, but I encountered an error while processing your request. Please try again or contact support if the issue persists.",
6086
6805
  actions: ["SETTING_UPDATE_ERROR"],
6087
6806
  source: "discord"
6088
6807
  });
6808
+ return {
6809
+ text: "Error with fallback message",
6810
+ values: {
6811
+ success: false,
6812
+ error: "PROCESSING_ERROR",
6813
+ fallbackUsed: true
6814
+ },
6815
+ data: {
6816
+ actionName: "UPDATE_SETTINGS",
6817
+ action: "SETTING_UPDATE_ERROR",
6818
+ error: error instanceof Error ? error.message : String(error)
6819
+ },
6820
+ success: false,
6821
+ error: error instanceof Error ? error : new Error(String(error))
6822
+ };
6089
6823
  }
6090
6824
  }
6091
6825
  var updateSettingsAction = {
@@ -6095,10 +6829,10 @@ var updateSettingsAction = {
6095
6829
  validate: async (runtime, message, _state) => {
6096
6830
  try {
6097
6831
  if (message.content.channelType !== ChannelType2.DM) {
6098
- logger6.debug(`Skipping settings in non-DM channel (type: ${message.content.channelType})`);
6832
+ logger7.debug(`Skipping settings in non-DM channel (type: ${message.content.channelType})`);
6099
6833
  return false;
6100
6834
  }
6101
- logger6.debug(`Looking for server where user ${message.entityId} is owner`);
6835
+ logger7.debug(`Looking for server where user ${message.entityId} is owner`);
6102
6836
  const worlds = await findWorldsForOwner(runtime, message.entityId);
6103
6837
  if (!worlds) {
6104
6838
  return false;
@@ -6106,53 +6840,130 @@ var updateSettingsAction = {
6106
6840
  const world = worlds.find((world2) => world2.metadata?.settings);
6107
6841
  const worldSettings = world?.metadata?.settings;
6108
6842
  if (!worldSettings) {
6109
- logger6.error(`No settings state found for server ${world?.serverId}`);
6843
+ logger7.error(`No settings state found for server ${world?.serverId}`);
6110
6844
  return false;
6111
6845
  }
6112
- logger6.debug(`Found valid settings state for server ${world.serverId}`);
6846
+ logger7.debug(`Found valid settings state for server ${world.serverId}`);
6113
6847
  return true;
6114
6848
  } catch (error) {
6115
- logger6.error(`Error validating settings action: ${error}`);
6849
+ logger7.error(`Error validating settings action: ${error}`);
6116
6850
  return false;
6117
6851
  }
6118
6852
  },
6119
6853
  handler: async (runtime, message, state, _options, callback) => {
6120
6854
  try {
6121
6855
  if (!state) {
6122
- logger6.error("State is required for settings handler");
6123
- throw new Error("State is required for settings handler");
6856
+ logger7.error("State is required for settings handler");
6857
+ if (callback) {
6858
+ await generateErrorResponse(runtime, state, callback);
6859
+ }
6860
+ return {
6861
+ text: "State is required for settings handler",
6862
+ values: {
6863
+ success: false,
6864
+ error: "STATE_REQUIRED"
6865
+ },
6866
+ data: {
6867
+ actionName: "UPDATE_SETTINGS",
6868
+ error: "State is required"
6869
+ },
6870
+ success: false,
6871
+ error: new Error("State is required for settings handler")
6872
+ };
6124
6873
  }
6125
6874
  if (!message) {
6126
- logger6.error("Message is required for settings handler");
6127
- throw new Error("Message is required for settings handler");
6875
+ logger7.error("Message is required for settings handler");
6876
+ await generateErrorResponse(runtime, state, callback);
6877
+ return {
6878
+ text: "Message is required for settings handler",
6879
+ values: {
6880
+ success: false,
6881
+ error: "MESSAGE_REQUIRED"
6882
+ },
6883
+ data: {
6884
+ actionName: "UPDATE_SETTINGS",
6885
+ error: "Message is required"
6886
+ },
6887
+ success: false,
6888
+ error: new Error("Message is required for settings handler")
6889
+ };
6128
6890
  }
6129
6891
  if (!callback) {
6130
- logger6.error("Callback is required for settings handler");
6131
- throw new Error("Callback is required for settings handler");
6892
+ logger7.error("Callback is required for settings handler");
6893
+ return {
6894
+ text: "Callback is required for settings handler",
6895
+ values: {
6896
+ success: false,
6897
+ error: "CALLBACK_REQUIRED"
6898
+ },
6899
+ data: {
6900
+ actionName: "UPDATE_SETTINGS",
6901
+ error: "Callback is required"
6902
+ },
6903
+ success: false,
6904
+ error: new Error("Callback is required for settings handler")
6905
+ };
6132
6906
  }
6133
- logger6.info(`Handler looking for server for user ${message.entityId}`);
6907
+ logger7.info(`Handler looking for server for user ${message.entityId}`);
6134
6908
  const worlds = await findWorldsForOwner(runtime, message.entityId);
6135
6909
  const serverOwnership = worlds?.find((world) => world.metadata?.settings);
6136
6910
  if (!serverOwnership) {
6137
- logger6.error(`No server found for user ${message.entityId} in handler`);
6911
+ logger7.error(`No server found for user ${message.entityId} in handler`);
6138
6912
  await generateErrorResponse(runtime, state, callback);
6139
- return;
6913
+ return {
6914
+ text: "No server found for user",
6915
+ values: {
6916
+ success: false,
6917
+ error: "NO_SERVER_FOUND"
6918
+ },
6919
+ data: {
6920
+ actionName: "UPDATE_SETTINGS",
6921
+ error: "No server found where user is owner",
6922
+ entityId: message.entityId
6923
+ },
6924
+ success: false
6925
+ };
6140
6926
  }
6141
6927
  const serverId = serverOwnership?.serverId;
6142
- logger6.info(`Using server ID: ${serverId}`);
6928
+ logger7.info(`Using server ID: ${serverId}`);
6143
6929
  if (!serverId) {
6144
- logger6.error(`No server ID found for user ${message.entityId} in handler`);
6145
- return;
6930
+ logger7.error(`No server ID found for user ${message.entityId} in handler`);
6931
+ await generateErrorResponse(runtime, state, callback);
6932
+ return {
6933
+ text: "No server ID found",
6934
+ values: {
6935
+ success: false,
6936
+ error: "NO_SERVER_ID"
6937
+ },
6938
+ data: {
6939
+ actionName: "UPDATE_SETTINGS",
6940
+ error: "No server ID found",
6941
+ entityId: message.entityId
6942
+ },
6943
+ success: false
6944
+ };
6146
6945
  }
6147
6946
  const worldSettings = await getWorldSettings(runtime, serverId);
6148
6947
  if (!worldSettings) {
6149
- logger6.error(`No settings state found for server ${serverId} in handler`);
6948
+ logger7.error(`No settings state found for server ${serverId} in handler`);
6150
6949
  await generateErrorResponse(runtime, state, callback);
6151
- return;
6950
+ return {
6951
+ text: "No settings state found",
6952
+ values: {
6953
+ success: false,
6954
+ error: "NO_SETTINGS_STATE"
6955
+ },
6956
+ data: {
6957
+ actionName: "UPDATE_SETTINGS",
6958
+ error: "No settings state found for server",
6959
+ serverId
6960
+ },
6961
+ success: false
6962
+ };
6152
6963
  }
6153
- logger6.info(`Extracting settings from message: ${message.content.text}`);
6964
+ logger7.info(`Extracting settings from message: ${message.content.text}`);
6154
6965
  const extractedSettings = await extractSettingValues(runtime, message, state, worldSettings);
6155
- logger6.info(`Extracted ${extractedSettings.length} settings`);
6966
+ logger7.info(`Extracted ${extractedSettings.length} settings`);
6156
6967
  const updateResults = await processSettingUpdates(
6157
6968
  runtime,
6158
6969
  serverId,
@@ -6160,12 +6971,24 @@ var updateSettingsAction = {
6160
6971
  extractedSettings
6161
6972
  );
6162
6973
  if (updateResults.updatedAny) {
6163
- logger6.info(`Successfully updated settings: ${updateResults.messages.join(", ")}`);
6974
+ logger7.info(`Successfully updated settings: ${updateResults.messages.join(", ")}`);
6164
6975
  const updatedWorldSettings = await getWorldSettings(runtime, serverId);
6165
6976
  if (!updatedWorldSettings) {
6166
- logger6.error("Failed to retrieve updated settings state");
6977
+ logger7.error("Failed to retrieve updated settings state");
6167
6978
  await generateErrorResponse(runtime, state, callback);
6168
- return;
6979
+ return {
6980
+ text: "Failed to retrieve updated settings state",
6981
+ values: {
6982
+ success: false,
6983
+ error: "RETRIEVE_FAILED"
6984
+ },
6985
+ data: {
6986
+ actionName: "UPDATE_SETTINGS",
6987
+ error: "Failed to retrieve updated settings state",
6988
+ serverId
6989
+ },
6990
+ success: false
6991
+ };
6169
6992
  }
6170
6993
  await generateSuccessResponse(
6171
6994
  runtime,
@@ -6174,15 +6997,67 @@ var updateSettingsAction = {
6174
6997
  updateResults.messages,
6175
6998
  callback
6176
6999
  );
7000
+ const { requiredUnconfigured } = categorizeSettings(updatedWorldSettings);
7001
+ const allConfigured = requiredUnconfigured.length === 0;
7002
+ return {
7003
+ text: `Settings updated successfully`,
7004
+ values: {
7005
+ success: true,
7006
+ settingsUpdated: extractedSettings.length,
7007
+ updatedSettings: extractedSettings.map((s) => s.key),
7008
+ remainingRequired: requiredUnconfigured.length,
7009
+ allConfigured,
7010
+ serverId
7011
+ },
7012
+ data: {
7013
+ actionName: "UPDATE_SETTINGS",
7014
+ updatedSettings: extractedSettings,
7015
+ messages: updateResults.messages,
7016
+ remainingRequired: requiredUnconfigured.map(([key, _]) => key),
7017
+ allConfigured,
7018
+ serverId
7019
+ },
7020
+ success: true
7021
+ };
6177
7022
  } else {
6178
- logger6.info("No settings were updated");
7023
+ logger7.info("No settings were updated");
6179
7024
  await generateFailureResponse(runtime, worldSettings, state, callback);
7025
+ const { requiredUnconfigured } = categorizeSettings(worldSettings);
7026
+ return {
7027
+ text: "No settings were updated",
7028
+ values: {
7029
+ success: false,
7030
+ error: "NO_UPDATES",
7031
+ remainingRequired: requiredUnconfigured.length,
7032
+ serverId
7033
+ },
7034
+ data: {
7035
+ actionName: "UPDATE_SETTINGS",
7036
+ error: "No valid settings found in message",
7037
+ remainingRequired: requiredUnconfigured.map(([key, _]) => key),
7038
+ serverId
7039
+ },
7040
+ success: false
7041
+ };
6180
7042
  }
6181
7043
  } catch (error) {
6182
- logger6.error(`Error in settings handler: ${error}`);
7044
+ logger7.error(`Error in settings handler: ${error}`);
6183
7045
  if (state && callback) {
6184
7046
  await generateErrorResponse(runtime, state, callback);
6185
7047
  }
7048
+ return {
7049
+ text: "Error in settings handler",
7050
+ values: {
7051
+ success: false,
7052
+ error: "HANDLER_ERROR"
7053
+ },
7054
+ data: {
7055
+ actionName: "UPDATE_SETTINGS",
7056
+ error: error instanceof Error ? error.message : String(error)
7057
+ },
7058
+ success: false,
7059
+ error: error instanceof Error ? error : new Error(String(error))
7060
+ };
6186
7061
  }
6187
7062
  },
6188
7063
  examples: [
@@ -6401,21 +7276,70 @@ var unfollowRoomAction = {
6401
7276
  return parsedResponse;
6402
7277
  }
6403
7278
  if (state && await _shouldUnfollow(state)) {
6404
- await runtime.setParticipantUserState(message.roomId, runtime.agentId, null);
6405
- const room = state.data.room ?? await runtime.getRoom(message.roomId);
6406
- await runtime.createMemory(
6407
- {
6408
- entityId: message.entityId,
6409
- agentId: message.agentId,
6410
- roomId: message.roomId,
6411
- content: {
6412
- thought: `I unfollowed the room ${room.name}`,
6413
- actions: ["UNFOLLOW_ROOM_START"]
6414
- }
6415
- },
6416
- "messages"
6417
- );
7279
+ try {
7280
+ await runtime.setParticipantUserState(message.roomId, runtime.agentId, null);
7281
+ const room = state.data.room ?? await runtime.getRoom(message.roomId);
7282
+ await runtime.createMemory(
7283
+ {
7284
+ entityId: message.entityId,
7285
+ agentId: message.agentId,
7286
+ roomId: message.roomId,
7287
+ content: {
7288
+ thought: `I unfollowed the room ${room.name}`,
7289
+ actions: ["UNFOLLOW_ROOM_START"]
7290
+ }
7291
+ },
7292
+ "messages"
7293
+ );
7294
+ return {
7295
+ text: `Stopped following room: ${room.name}`,
7296
+ values: {
7297
+ success: true,
7298
+ roomUnfollowed: true,
7299
+ roomId: message.roomId,
7300
+ roomName: room.name,
7301
+ newState: null
7302
+ },
7303
+ data: {
7304
+ actionName: "UNFOLLOW_ROOM",
7305
+ roomId: message.roomId,
7306
+ roomName: room.name,
7307
+ unfollowed: true
7308
+ },
7309
+ success: true
7310
+ };
7311
+ } catch (error) {
7312
+ return {
7313
+ text: "Failed to unfollow room",
7314
+ values: {
7315
+ success: false,
7316
+ error: "UNFOLLOW_FAILED"
7317
+ },
7318
+ data: {
7319
+ actionName: "UNFOLLOW_ROOM",
7320
+ error: error instanceof Error ? error.message : String(error),
7321
+ roomId: message.roomId
7322
+ },
7323
+ success: false,
7324
+ error: error instanceof Error ? error : new Error(String(error))
7325
+ };
7326
+ }
6418
7327
  } else {
7328
+ if (!state) {
7329
+ return {
7330
+ text: "State is required for unfollow room action",
7331
+ values: {
7332
+ success: false,
7333
+ error: "STATE_REQUIRED"
7334
+ },
7335
+ data: {
7336
+ actionName: "UNFOLLOW_ROOM",
7337
+ error: "State is required"
7338
+ },
7339
+ success: false,
7340
+ error: new Error("State is required for unfollow room action")
7341
+ };
7342
+ }
6419
7343
  await runtime.createMemory(
6420
7344
  {
6421
7345
  entityId: message.entityId,
@@ -6432,6 +7356,22 @@ var unfollowRoomAction = {
6432
7356
  },
6433
7357
  "messages"
6434
7358
  );
7359
+ return {
7360
+ text: "Did not unfollow room - criteria not met",
7361
+ values: {
7362
+ success: true,
7363
+ roomUnfollowed: false,
7364
+ roomId: message.roomId,
7365
+ reason: "CRITERIA_NOT_MET"
7366
+ },
7367
+ data: {
7368
+ actionName: "UNFOLLOW_ROOM",
7369
+ roomId: message.roomId,
7370
+ unfollowed: false,
7371
+ reason: "Decision criteria not met"
7372
+ },
7373
+ success: true
7374
+ };
6435
7375
  }
6436
7376
  },
6437
7377
  examples: [
@@ -6685,7 +7625,7 @@ var unfollowRoomAction = {
6685
7625
  import {
6686
7626
  booleanFooter as booleanFooter4,
6687
7627
  composePromptFromState as composePromptFromState8,
6688
- logger as logger7,
7628
+ logger as logger8,
6689
7629
  ModelType as ModelType10
6690
7630
  } from "@elizaos/core";
6691
7631
  var shouldUnmuteTemplate = `# Task: Decide if {{agentName}} should unmute this previously muted room and start considering it for responses again.
@@ -6760,29 +7700,110 @@ var unmuteRoomAction = {
6760
7700
  );
6761
7701
  return false;
6762
7702
  }
6763
- logger7.warn(`Unclear boolean response: ${response}, defaulting to false`);
7703
+ logger8.warn(`Unclear boolean response: ${response}, defaulting to false`);
6764
7704
  return false;
6765
7705
  }
6766
- if (state && await _shouldUnmute(state)) {
6767
- await runtime.setParticipantUserState(message.roomId, runtime.agentId, null);
6768
- }
6769
- const room = await runtime.getRoom(message.roomId);
6770
- if (!room) {
6771
- logger7.warn(`Room not found: ${message.roomId}`);
6772
- return false;
7706
+ if (!state) {
7707
+ return {
7708
+ text: "State is required for unmute room action",
7709
+ values: {
7710
+ success: false,
7711
+ error: "STATE_REQUIRED"
7712
+ },
7713
+ data: {
7714
+ actionName: "UNMUTE_ROOM",
7715
+ error: "State is required"
7716
+ },
7717
+ success: false,
7718
+ error: new Error("State is required for unmute room action")
7719
+ };
6773
7720
  }
6774
- await runtime.createMemory(
6775
- {
6776
- entityId: message.entityId,
6777
- agentId: message.agentId,
6778
- roomId: message.roomId,
6779
- content: {
6780
- thought: `I unmuted the room ${room.name}`,
6781
- actions: ["UNMUTE_ROOM_START"]
7721
+ const shouldUnmute = await _shouldUnmute(state);
7722
+ if (shouldUnmute) {
7723
+ try {
7724
+ await runtime.setParticipantUserState(message.roomId, runtime.agentId, null);
7725
+ const room = await runtime.getRoom(message.roomId);
7726
+ if (!room) {
7727
+ logger8.warn(`Room not found: ${message.roomId}`);
7728
+ return {
7729
+ text: `Room not found: ${message.roomId}`,
7730
+ values: {
7731
+ success: false,
7732
+ error: "ROOM_NOT_FOUND",
7733
+ roomId: message.roomId
7734
+ },
7735
+ data: {
7736
+ actionName: "UNMUTE_ROOM",
7737
+ error: "Room not found",
7738
+ roomId: message.roomId
7739
+ },
7740
+ success: false
7741
+ };
6782
7742
  }
6783
- },
6784
- "messages"
6785
- );
7743
+ await runtime.createMemory(
7744
+ {
7745
+ entityId: message.entityId,
7746
+ agentId: message.agentId,
7747
+ roomId: message.roomId,
7748
+ content: {
7749
+ thought: `I unmuted the room ${room.name}`,
7750
+ actions: ["UNMUTE_ROOM_START"]
7751
+ }
7752
+ },
7753
+ "messages"
7754
+ );
7755
+ return {
7756
+ text: `Room unmuted: ${room.name}`,
7757
+ values: {
7758
+ success: true,
7759
+ roomUnmuted: true,
7760
+ roomId: message.roomId,
7761
+ roomName: room.name,
7762
+ newState: null
7763
+ },
7764
+ data: {
7765
+ actionName: "UNMUTE_ROOM",
7766
+ roomId: message.roomId,
7767
+ roomName: room.name,
7768
+ unmuted: true
7769
+ },
7770
+ success: true
7771
+ };
7772
+ } catch (error) {
7773
+ logger8.error("Error unmuting room:", error);
7774
+ return {
7775
+ text: "Failed to unmute room",
7776
+ values: {
7777
+ success: false,
7778
+ error: "UNMUTE_FAILED"
7779
+ },
7780
+ data: {
7781
+ actionName: "UNMUTE_ROOM",
7782
+ error: error instanceof Error ? error.message : String(error),
7783
+ roomId: message.roomId
7784
+ },
7785
+ success: false,
7786
+ error: error instanceof Error ? error : new Error(String(error))
7787
+ };
7788
+ }
7789
+ } else {
7790
+ return {
7791
+ text: "Decided not to unmute room",
7792
+ values: {
7793
+ success: true,
7794
+ roomUnmuted: false,
7795
+ roomId: message.roomId,
7796
+ reason: "CRITERIA_NOT_MET"
7797
+ },
7798
+ data: {
7799
+ actionName: "UNMUTE_ROOM",
7800
+ roomId: message.roomId,
7801
+ unmuted: false,
7802
+ reason: "Decision criteria not met"
7803
+ },
7804
+ success: true
7805
+ };
7806
+ }
6786
7807
  },
6787
7808
  examples: [
6788
7809
  [
@@ -6879,7 +7900,7 @@ var unmuteRoomAction = {
6879
7900
  import {
6880
7901
  composePromptFromState as composePromptFromState9,
6881
7902
  findEntityByName as findEntityByName2,
6882
- logger as logger8,
7903
+ logger as logger9,
6883
7904
  ModelType as ModelType11
6884
7905
  } from "@elizaos/core";
6885
7906
  var componentTemplate = `# Task: Extract Source and Update Component Data
@@ -6947,20 +7968,68 @@ var updateEntityAction = {
6947
7968
  handler: async (runtime, message, state, _options, callback, responses) => {
6948
7969
  try {
6949
7970
  if (!state) {
6950
- logger8.error("State is required for the updateEntity action");
6951
- throw new Error("State is required for the updateEntity action");
7971
+ logger9.error("State is required for the updateEntity action");
7972
+ return {
7973
+ text: "State is required for updateEntity action",
7974
+ values: {
7975
+ success: false,
7976
+ error: "STATE_REQUIRED"
7977
+ },
7978
+ data: {
7979
+ actionName: "UPDATE_CONTACT",
7980
+ error: "State is required"
7981
+ },
7982
+ success: false,
7983
+ error: new Error("State is required for the updateEntity action")
7984
+ };
6952
7985
  }
6953
7986
  if (!callback) {
6954
- logger8.error("State is required for the updateEntity action");
6955
- throw new Error("Callback is required for the updateEntity action");
7987
+ logger9.error("Callback is required for the updateEntity action");
7988
+ return {
7989
+ text: "Callback is required for updateEntity action",
7990
+ values: {
7991
+ success: false,
7992
+ error: "CALLBACK_REQUIRED"
7993
+ },
7994
+ data: {
7995
+ actionName: "UPDATE_CONTACT",
7996
+ error: "Callback is required"
7997
+ },
7998
+ success: false,
7999
+ error: new Error("Callback is required for the updateEntity action")
8000
+ };
6956
8001
  }
6957
8002
  if (!responses) {
6958
- logger8.error("Responses are required for the updateEntity action");
6959
- throw new Error("Responses are required for the updateEntity action");
8003
+ logger9.error("Responses are required for the updateEntity action");
8004
+ return {
8005
+ text: "Responses are required for updateEntity action",
8006
+ values: {
8007
+ success: false,
8008
+ error: "RESPONSES_REQUIRED"
8009
+ },
8010
+ data: {
8011
+ actionName: "UPDATE_CONTACT",
8012
+ error: "Responses are required"
8013
+ },
8014
+ success: false,
8015
+ error: new Error("Responses are required for the updateEntity action")
8016
+ };
6960
8017
  }
6961
8018
  if (!message) {
6962
- logger8.error("Message is required for the updateEntity action");
6963
- throw new Error("Message is required for the updateEntity action");
8019
+ logger9.error("Message is required for the updateEntity action");
8020
+ return {
8021
+ text: "Message is required for updateEntity action",
8022
+ values: {
8023
+ success: false,
8024
+ error: "MESSAGE_REQUIRED"
8025
+ },
8026
+ data: {
8027
+ actionName: "UPDATE_CONTACT",
8028
+ error: "Message is required"
8029
+ },
8030
+ success: false,
8031
+ error: new Error("Message is required for the updateEntity action")
8032
+ };
6964
8033
  }
6965
8034
  for (const response of responses) {
6966
8035
  await callback(response.content);
@@ -6976,7 +8045,18 @@ var updateEntityAction = {
6976
8045
  actions: ["UPDATE_ENTITY_ERROR"],
6977
8046
  source: message.content.source
6978
8047
  });
6979
- return;
8048
+ return {
8049
+ text: "Entity not found",
8050
+ values: {
8051
+ success: false,
8052
+ error: "ENTITY_NOT_FOUND"
8053
+ },
8054
+ data: {
8055
+ actionName: "UPDATE_CONTACT",
8056
+ error: "Could not find entity to update"
8057
+ },
8058
+ success: false
8059
+ };
6980
8060
  }
6981
8061
  let existingComponent = null;
6982
8062
  const prompt = composePromptFromState9({
@@ -6998,13 +8078,25 @@ var updateEntityAction = {
6998
8078
  throw new Error("Invalid response format - missing source or data");
6999
8079
  }
7000
8080
  } catch (error) {
7001
- logger8.error(`Failed to parse component data: ${error.message}`);
8081
+ logger9.error(`Failed to parse component data: ${error.message}`);
7002
8082
  await callback({
7003
8083
  text: "I couldn't properly understand the component information. Please try again with more specific information.",
7004
8084
  actions: ["UPDATE_ENTITY_ERROR"],
7005
8085
  source: message.content.source
7006
8086
  });
7007
- return;
8087
+ return {
8088
+ text: "Failed to parse component data",
8089
+ values: {
8090
+ success: false,
8091
+ error: "PARSE_ERROR"
8092
+ },
8093
+ data: {
8094
+ actionName: "UPDATE_CONTACT",
8095
+ error: error.message
8096
+ },
8097
+ success: false,
8098
+ error
8099
+ };
7008
8100
  }
7009
8101
  const componentType = parsedResult.source.toLowerCase();
7010
8102
  const componentData = parsedResult.data;
@@ -7031,9 +8123,30 @@ var updateEntityAction = {
7031
8123
  actions: ["UPDATE_ENTITY"],
7032
8124
  source: message.content.source
7033
8125
  });
8126
+ return {
8127
+ text: `Updated ${componentType} information`,
8128
+ values: {
8129
+ success: true,
8130
+ entityId: entity.id,
8131
+ entityName: entity.names[0],
8132
+ componentType,
8133
+ componentUpdated: true,
8134
+ isNewComponent: false
8135
+ },
8136
+ data: {
8137
+ actionName: "UPDATE_CONTACT",
8138
+ entityId: entity.id,
8139
+ entityName: entity.names[0],
8140
+ componentType,
8141
+ componentData,
8142
+ existingComponentId: existingComponent.id
8143
+ },
8144
+ success: true
8145
+ };
7034
8146
  } else {
8147
+ const newComponentId = v4_default();
7035
8148
  await runtime.createComponent({
7036
- id: v4_default(),
8149
+ id: newComponentId,
7037
8150
  entityId: entity.id,
7038
8151
  worldId,
7039
8152
  type: componentType,
@@ -7048,14 +8161,47 @@ var updateEntityAction = {
7048
8161
  actions: ["UPDATE_ENTITY"],
7049
8162
  source: message.content.source
7050
8163
  });
8164
+ return {
8165
+ text: `Added new ${componentType} information`,
8166
+ values: {
8167
+ success: true,
8168
+ entityId: entity.id,
8169
+ entityName: entity.names[0],
8170
+ componentType,
8171
+ componentCreated: true,
8172
+ isNewComponent: true
8173
+ },
8174
+ data: {
8175
+ actionName: "UPDATE_CONTACT",
8176
+ entityId: entity.id,
8177
+ entityName: entity.names[0],
8178
+ componentType,
8179
+ componentData,
8180
+ newComponentId
8181
+ },
8182
+ success: true
8183
+ };
7051
8184
  }
7052
8185
  } catch (error) {
7053
- logger8.error(`Error in updateEntity handler: ${error}`);
8186
+ logger9.error(`Error in updateEntity handler: ${error}`);
7054
8187
  await callback?.({
7055
8188
  text: "There was an error processing the entity information.",
7056
8189
  actions: ["UPDATE_ENTITY_ERROR"],
7057
8190
  source: message.content.source
7058
8191
  });
8192
+ return {
8193
+ text: "Error processing entity information",
8194
+ values: {
8195
+ success: false,
8196
+ error: "HANDLER_ERROR"
8197
+ },
8198
+ data: {
8199
+ actionName: "UPDATE_CONTACT",
8200
+ error: error instanceof Error ? error.message : String(error)
8201
+ },
8202
+ success: false,
8203
+ error: error instanceof Error ? error : new Error(String(error))
8204
+ };
7059
8205
  }
7060
8206
  },
7061
8207
  examples: [
@@ -7109,7 +8255,7 @@ var updateEntityAction = {
7109
8255
 
7110
8256
  // src/evaluators/reflection.ts
7111
8257
  import { z } from "zod";
7112
- import { getEntityDetails, logger as logger9 } from "@elizaos/core";
8258
+ import { getEntityDetails, logger as logger10 } from "@elizaos/core";
7113
8259
  import { composePrompt as composePrompt4 } from "@elizaos/core";
7114
8260
  import {
7115
8261
  ModelType as ModelType12
@@ -7210,7 +8356,7 @@ function resolveEntity(entityId, entities) {
7210
8356
  async function handler(runtime, message, state) {
7211
8357
  const { agentId, roomId } = message;
7212
8358
  if (!agentId || !roomId) {
7213
- logger9.warn("Missing agentId or roomId in message", message);
8359
+ logger10.warn("Missing agentId or roomId in message", message);
7214
8360
  return;
7215
8361
  }
7216
8362
  const [existingRelationships, entities, knownFacts] = await Promise.all([
@@ -7242,15 +8388,15 @@ async function handler(runtime, message, state) {
7242
8388
  // Remove schema validation to avoid zod issues
7243
8389
  });
7244
8390
  if (!reflection) {
7245
- logger9.warn("Getting reflection failed - empty response", prompt);
8391
+ logger10.warn("Getting reflection failed - empty response", prompt);
7246
8392
  return;
7247
8393
  }
7248
8394
  if (!reflection.facts || !Array.isArray(reflection.facts)) {
7249
- logger9.warn("Getting reflection failed - invalid facts structure", reflection);
8395
+ logger10.warn("Getting reflection failed - invalid facts structure", reflection);
7250
8396
  return;
7251
8397
  }
7252
8398
  if (!reflection.relationships || !Array.isArray(reflection.relationships)) {
7253
- logger9.warn("Getting reflection failed - invalid relationships structure", reflection);
8399
+ logger10.warn("Getting reflection failed - invalid relationships structure", reflection);
7254
8400
  return;
7255
8401
  }
7256
8402
  const newFacts = reflection.facts.filter(
@@ -7313,7 +8459,7 @@ async function handler(runtime, message, state) {
7313
8459
  );
7314
8460
  return reflection;
7315
8461
  } catch (error) {
7316
- logger9.error("Error in reflection handler:", error);
8462
+ logger10.error("Error in reflection handler:", error);
7317
8463
  return;
7318
8464
  }
7319
8465
  }
@@ -7530,24 +8676,17 @@ var actionsProvider = {
7530
8676
  const resolvedActions = await Promise.all(actionPromises);
7531
8677
  const actionsData = resolvedActions.filter(Boolean);
7532
8678
  const actionNames = `Possible response actions: ${formatActionNames(actionsData)}`;
7533
- const actionsWithDescriptions = actionsData.length > 0 ? addHeader(
7534
- "# Available Actions",
7535
- actionsData.map(
7536
- (action) => `- **${action.name}**: ${action.description || "No description available"}`
7537
- ).join("\n")
7538
- ) : "";
7539
- const actions = actionsData.length > 0 ? addHeader("# Available Actions", formatActions(actionsData)) : "";
8679
+ const actionsWithDescriptions = actionsData.length > 0 ? addHeader("# Available Actions", formatActions(actionsData)) : "";
7540
8680
  const actionExamples = actionsData.length > 0 ? addHeader("# Action Examples", composeActionExamples(actionsData, 10)) : "";
7541
8681
  const data = {
7542
8682
  actionsData
7543
8683
  };
7544
8684
  const values = {
7545
- actions,
7546
8685
  actionNames,
7547
8686
  actionExamples,
7548
8687
  actionsWithDescriptions
7549
8688
  };
7550
- const text = [actionNames, actionsWithDescriptions, actionExamples, actions].filter(Boolean).join("\n\n");
8689
+ const text = [actionNames, actionsWithDescriptions, actionExamples].filter(Boolean).join("\n\n");
7551
8690
  return {
7552
8691
  data,
7553
8692
  values,
@@ -7556,8 +8695,156 @@ var actionsProvider = {
7556
8695
  }
7557
8696
  };
7558
8697
 
8698
+ // src/providers/actionState.ts
8699
+ import {
8700
+ addHeader as addHeader2,
8701
+ logger as logger11
8702
+ } from "@elizaos/core";
8703
+ var actionStateProvider = {
8704
+ name: "ACTION_STATE",
8705
+ description: "Previous action results, working memory, and action plan from the current execution run",
8706
+ position: 150,
8707
+ get: async (runtime, message, state) => {
8708
+ const actionResults = state.data?.actionResults || [];
8709
+ const actionPlan = state.data?.actionPlan || null;
8710
+ const workingMemory = state.data?.workingMemory || {};
8711
+ let planText = "";
8712
+ if (actionPlan && actionPlan.totalSteps > 1) {
8713
+ const completedSteps = actionPlan.steps.filter((s) => s.status === "completed").length;
8714
+ const failedSteps = actionPlan.steps.filter((s) => s.status === "failed").length;
8715
+ planText = addHeader2(
8716
+ "# Action Execution Plan",
8717
+ [
8718
+ `**Plan:** ${actionPlan.thought}`,
8719
+ `**Progress:** Step ${actionPlan.currentStep} of ${actionPlan.totalSteps}`,
8720
+ `**Status:** ${completedSteps} completed, ${failedSteps} failed`,
8721
+ "",
8722
+ "## Steps:",
8723
+ ...actionPlan.steps.map((step, index) => {
8724
+ const icon = step.status === "completed" ? "\u2713" : step.status === "failed" ? "\u2717" : index < actionPlan.currentStep - 1 ? "\u25CB" : index === actionPlan.currentStep - 1 ? "\u2192" : "\u25CB";
8725
+ const status = step.status === "pending" && index === actionPlan.currentStep - 1 ? "in progress" : step.status;
8726
+ let stepText = `${icon} **Step ${index + 1}:** ${step.action} (${status})`;
8727
+ if (step.error) {
8728
+ stepText += `
8729
+ Error: ${step.error}`;
8730
+ }
8731
+ if (step.result?.text) {
8732
+ stepText += `
8733
+ Result: ${step.result.text}`;
8734
+ }
8735
+ return stepText;
8736
+ }),
8737
+ ""
8738
+ ].join("\n")
8739
+ );
8740
+ }
8741
+ let resultsText = "";
8742
+ if (actionResults.length > 0) {
8743
+ const formattedResults = actionResults.map((result, index) => {
8744
+ const actionName = result.data?.actionName || "Unknown Action";
8745
+ const success = result.success;
8746
+ const status = success ? "Success" : "Failed";
8747
+ let resultText = `**${index + 1}. ${actionName}** - ${status}`;
8748
+ if (result.text) {
8749
+ resultText += `
8750
+ Output: ${result.text}`;
8751
+ }
8752
+ if (result.error) {
8753
+ resultText += `
8754
+ Error: ${result.error}`;
8755
+ }
8756
+ if (result.values && Object.keys(result.values).length > 0) {
8757
+ const values = Object.entries(result.values).map(([key, value]) => ` - ${key}: ${JSON.stringify(value)}`).join("\n");
8758
+ resultText += `
8759
+ Values:
8760
+ ${values}`;
8761
+ }
8762
+ return resultText;
8763
+ }).join("\n\n");
8764
+ resultsText = addHeader2("# Previous Action Results", formattedResults);
8765
+ }
8766
+ let memoryText = "";
8767
+ if (Object.keys(workingMemory).length > 0) {
8768
+ const memoryEntries = Object.entries(workingMemory).sort((a2, b) => (b[1].timestamp || 0) - (a2[1].timestamp || 0)).slice(0, 10).map(([key, value]) => {
8769
+ if (value.actionName && value.result) {
8770
+ return `**${value.actionName}**: ${value.result.text || JSON.stringify(value.result.data)}`;
8771
+ }
8772
+ return `**${key}**: ${JSON.stringify(value)}`;
8773
+ }).join("\n");
8774
+ memoryText = addHeader2("# Working Memory", memoryEntries);
8775
+ }
8776
+ let recentActionMemories = [];
8777
+ try {
8778
+ const recentMessages = await runtime.getMemories({
8779
+ tableName: "messages",
8780
+ roomId: message.roomId,
8781
+ count: 20,
8782
+ unique: false
8783
+ });
8784
+ recentActionMemories = recentMessages.filter(
8785
+ (msg) => msg.content?.type === "action_result" && msg.metadata?.type === "action_result"
8786
+ );
8787
+ } catch (error) {
8788
+ logger11?.error("Failed to retrieve action memories:", error);
8789
+ }
8790
+ let actionMemoriesText = "";
8791
+ if (recentActionMemories.length > 0) {
8792
+ const groupedByRun = /* @__PURE__ */ new Map();
8793
+ for (const mem of recentActionMemories) {
8794
+ const runId = String(mem.content?.runId || "unknown");
8795
+ if (!groupedByRun.has(runId)) {
8796
+ groupedByRun.set(runId, []);
8797
+ }
8798
+ const memories = groupedByRun.get(runId);
8799
+ if (memories) {
8800
+ memories.push(mem);
8801
+ }
8802
+ }
8803
+ const formattedMemories = Array.from(groupedByRun.entries()).map(([runId, memories]) => {
8804
+ const sortedMemories = memories.sort(
8805
+ (a2, b) => (a2.createdAt || 0) - (b.createdAt || 0)
8806
+ );
8807
+ const runText = sortedMemories.map((mem) => {
8808
+ const actionName = mem.content?.actionName || "Unknown";
8809
+ const status = mem.content?.actionStatus || "unknown";
8810
+ const planStep = mem.content?.planStep || "";
8811
+ const text = mem.content?.text || "";
8812
+ let memText = ` - ${actionName} (${status})`;
8813
+ if (planStep) memText += ` [${planStep}]`;
8814
+ if (text && text !== `Executed action: ${actionName}`) {
8815
+ memText += `: ${text}`;
8816
+ }
8817
+ return memText;
8818
+ }).join("\n");
8819
+ const thought = sortedMemories[0]?.content?.planThought || "";
8820
+ return `**Run ${runId.slice(0, 8)}**${thought ? ` - ${thought}` : ""}
8821
+ ${runText}`;
8822
+ }).join("\n\n");
8823
+ actionMemoriesText = addHeader2("# Recent Action History", formattedMemories);
8824
+ }
8825
+ const allText = [planText, resultsText, memoryText, actionMemoriesText].filter(Boolean).join("\n\n");
8826
+ return {
8827
+ data: {
8828
+ actionResults,
8829
+ actionPlan,
8830
+ workingMemory,
8831
+ recentActionMemories
8832
+ },
8833
+ values: {
8834
+ hasActionResults: actionResults.length > 0,
8835
+ hasActionPlan: !!actionPlan,
8836
+ currentActionStep: actionPlan?.currentStep || 0,
8837
+ totalActionSteps: actionPlan?.totalSteps || 0,
8838
+ completedActions: actionResults.filter((r) => r.success).length,
8839
+ failedActions: actionResults.filter((r) => !r.success).length
8840
+ },
8841
+ text: allText || "No action state available"
8842
+ };
8843
+ }
8844
+ };
8845
+
7559
8846
  // src/providers/anxiety.ts
7560
- import { addHeader as addHeader2, ChannelType as ChannelType3 } from "@elizaos/core";
8847
+ import { addHeader as addHeader3, ChannelType as ChannelType3 } from "@elizaos/core";
7561
8848
  var anxietyProvider = {
7562
8849
  name: "ANXIETY",
7563
8850
  description: "Social directions for the AI to follow based on the channel type",
@@ -7625,7 +8912,7 @@ var anxietyProvider = {
7625
8912
  const randomAnxietyExamples = anxietyExamples.sort(() => Math.random() - 0.5).slice(0, 3);
7626
8913
  const anxietyText = randomAnxietyExamples.join("\n");
7627
8914
  const anxietyHeader = "# You are roleplaying as a character, but as an AI model, you are too verbose and eager.";
7628
- const anxiety = addHeader2(anxietyHeader, anxietyText);
8915
+ const anxiety = addHeader3(anxietyHeader, anxietyText);
7629
8916
  return {
7630
8917
  data: {
7631
8918
  anxiety: randomAnxietyExamples
@@ -7639,7 +8926,7 @@ var anxietyProvider = {
7639
8926
  };
7640
8927
 
7641
8928
  // src/providers/attachments.ts
7642
- import { addHeader as addHeader3 } from "@elizaos/core";
8929
+ import { addHeader as addHeader4 } from "@elizaos/core";
7643
8930
  var attachmentsProvider = {
7644
8931
  name: "ATTACHMENTS",
7645
8932
  description: "List of attachments sent during the current conversation, including names, descriptions, and summaries",
@@ -7691,7 +8978,7 @@ var attachmentsProvider = {
7691
8978
  Text: ${attachment.text}
7692
8979
  `
7693
8980
  ).join("\n");
7694
- const text = formattedAttachments && formattedAttachments.length > 0 ? addHeader3("# Attachments", formattedAttachments) : "";
8981
+ const text = formattedAttachments && formattedAttachments.length > 0 ? addHeader4("# Attachments", formattedAttachments) : "";
7695
8982
  const values = {
7696
8983
  attachments: text
7697
8984
  };
@@ -7707,7 +8994,7 @@ var attachmentsProvider = {
7707
8994
  };
7708
8995
 
7709
8996
  // src/providers/capabilities.ts
7710
- import { logger as logger10 } from "@elizaos/core";
8997
+ import { logger as logger12 } from "@elizaos/core";
7711
8998
  var capabilitiesProvider = {
7712
8999
  name: "CAPABILITIES",
7713
9000
  get: async (runtime, _message) => {
@@ -7741,7 +9028,7 @@ var capabilitiesProvider = {
7741
9028
  ${formattedCapabilities}`
7742
9029
  };
7743
9030
  } catch (error) {
7744
- logger10.error("Error in capabilities provider:", error);
9031
+ logger12.error("Error in capabilities provider:", error);
7745
9032
  return {
7746
9033
  text: "Error retrieving capabilities from services."
7747
9034
  };
@@ -7750,7 +9037,7 @@ ${formattedCapabilities}`
7750
9037
  };
7751
9038
 
7752
9039
  // src/providers/character.ts
7753
- import { addHeader as addHeader4, ChannelType as ChannelType4 } from "@elizaos/core";
9040
+ import { addHeader as addHeader5, ChannelType as ChannelType4 } from "@elizaos/core";
7754
9041
  var characterProvider = {
7755
9042
  name: "CHARACTER",
7756
9043
  description: "Character information",
@@ -7758,7 +9045,7 @@ var characterProvider = {
7758
9045
  const character = runtime.character;
7759
9046
  const agentName = character.name;
7760
9047
  const bioText = Array.isArray(character.bio) ? character.bio.sort(() => 0.5 - Math.random()).slice(0, 10).join(" ") : character.bio || "";
7761
- const bio = addHeader4(`# About ${character.name}`, bioText);
9048
+ const bio = addHeader5(`# About ${character.name}`, bioText);
7762
9049
  const system = character.system ?? "";
7763
9050
  const topicString = character.topics && character.topics.length > 0 ? character.topics[Math.floor(Math.random() * character.topics.length)] : null;
7764
9051
  const topic = topicString || "";
@@ -7777,7 +9064,7 @@ var characterProvider = {
7777
9064
  const messageString = `${post}`;
7778
9065
  return messageString;
7779
9066
  }).slice(0, 50).join("\n");
7780
- const characterPostExamples = formattedCharacterPostExamples && formattedCharacterPostExamples.replaceAll("\n", "").length > 0 ? addHeader4(`# Example Posts for ${character.name}`, formattedCharacterPostExamples) : "";
9067
+ const characterPostExamples = formattedCharacterPostExamples && formattedCharacterPostExamples.replaceAll("\n", "").length > 0 ? addHeader5(`# Example Posts for ${character.name}`, formattedCharacterPostExamples) : "";
7781
9068
  const formattedCharacterMessageExamples = !character.messageExamples ? "" : character.messageExamples.sort(() => 0.5 - Math.random()).slice(0, 5).map((example) => {
7782
9069
  const exampleNames = Array.from(
7783
9070
  { length: 5 },
@@ -7792,13 +9079,13 @@ var characterProvider = {
7792
9079
  return messageString;
7793
9080
  }).join("\n");
7794
9081
  }).join("\n\n");
7795
- const characterMessageExamples = formattedCharacterMessageExamples && formattedCharacterMessageExamples.replaceAll("\n", "").length > 0 ? addHeader4(
9082
+ const characterMessageExamples = formattedCharacterMessageExamples && formattedCharacterMessageExamples.replaceAll("\n", "").length > 0 ? addHeader5(
7796
9083
  `# Example Conversations for ${character.name}`,
7797
9084
  formattedCharacterMessageExamples
7798
9085
  ) : "";
7799
9086
  const room = state.data.room ?? await runtime.getRoom(message.roomId);
7800
9087
  const isPostFormat = room?.type === ChannelType4.FEED || room?.type === ChannelType4.THREAD;
7801
- const postDirections = character?.style?.all?.length && character?.style?.all?.length > 0 || character?.style?.post?.length && character?.style?.post?.length > 0 ? addHeader4(
9088
+ const postDirections = character?.style?.all?.length && character?.style?.all?.length > 0 || character?.style?.post?.length && character?.style?.post?.length > 0 ? addHeader5(
7802
9089
  `# Post Directions for ${character.name}`,
7803
9090
  (() => {
7804
9091
  const all = character?.style?.all || [];
@@ -7806,7 +9093,7 @@ var characterProvider = {
7806
9093
  return [...all, ...post].join("\n");
7807
9094
  })()
7808
9095
  ) : "";
7809
- const messageDirections = character?.style?.all?.length && character?.style?.all?.length > 0 || character?.style?.chat?.length && character?.style?.chat?.length > 0 ? addHeader4(
9096
+ const messageDirections = character?.style?.all?.length && character?.style?.all?.length > 0 || character?.style?.chat?.length && character?.style?.chat?.length > 0 ? addHeader5(
7810
9097
  `# Message Directions for ${character.name}`,
7811
9098
  (() => {
7812
9099
  const all = character?.style?.all || [];
@@ -7852,7 +9139,7 @@ var characterProvider = {
7852
9139
  };
7853
9140
 
7854
9141
  // src/providers/choice.ts
7855
- import { logger as logger11 } from "@elizaos/core";
9142
+ import { logger as logger13 } from "@elizaos/core";
7856
9143
  var choiceProvider = {
7857
9144
  name: "CHOICE",
7858
9145
  get: async (runtime, message, _state) => {
@@ -7920,7 +9207,7 @@ var choiceProvider = {
7920
9207
  text: output
7921
9208
  };
7922
9209
  } catch (error) {
7923
- logger11.error("Error in options provider:", error);
9210
+ logger13.error("Error in options provider:", error);
7924
9211
  return {
7925
9212
  data: {
7926
9213
  tasks: []
@@ -7935,7 +9222,7 @@ var choiceProvider = {
7935
9222
  };
7936
9223
 
7937
9224
  // src/providers/entities.ts
7938
- import { addHeader as addHeader5, formatEntities, getEntityDetails as getEntityDetails2 } from "@elizaos/core";
9225
+ import { addHeader as addHeader6, formatEntities, getEntityDetails as getEntityDetails2 } from "@elizaos/core";
7939
9226
  var entitiesProvider = {
7940
9227
  name: "ENTITIES",
7941
9228
  description: "People in the current conversation",
@@ -7945,7 +9232,7 @@ var entitiesProvider = {
7945
9232
  const entitiesData = await getEntityDetails2({ runtime, roomId });
7946
9233
  const formattedEntities = formatEntities({ entities: entitiesData ?? [] });
7947
9234
  const senderName = entitiesData?.find((entity) => entity.id === entityId)?.names[0];
7948
- const entities = formattedEntities && formattedEntities.length > 0 ? addHeader5("# People in the Room", formattedEntities) : "";
9235
+ const entities = formattedEntities && formattedEntities.length > 0 ? addHeader6("# People in the Room", formattedEntities) : "";
7949
9236
  const data = {
7950
9237
  entitiesData,
7951
9238
  senderName
@@ -7962,7 +9249,7 @@ var entitiesProvider = {
7962
9249
  };
7963
9250
 
7964
9251
  // src/providers/evaluators.ts
7965
- import { addHeader as addHeader6 } from "@elizaos/core";
9252
+ import { addHeader as addHeader7 } from "@elizaos/core";
7966
9253
 
7967
9254
  // ../../node_modules/unique-names-generator/dist/index.m.js
7968
9255
  var a = (a2) => {
@@ -8063,9 +9350,9 @@ var evaluatorsProvider = {
8063
9350
  });
8064
9351
  const resolvedEvaluators = await Promise.all(evaluatorPromises);
8065
9352
  const evaluatorsData = resolvedEvaluators.filter(Boolean);
8066
- const evaluators = evaluatorsData.length > 0 ? addHeader6("# Available Evaluators", formatEvaluators(evaluatorsData)) : "";
9353
+ const evaluators = evaluatorsData.length > 0 ? addHeader7("# Available Evaluators", formatEvaluators(evaluatorsData)) : "";
8067
9354
  const evaluatorNames = evaluatorsData.length > 0 ? formatEvaluatorNames(evaluatorsData) : "";
8068
- const evaluatorExamples = evaluatorsData.length > 0 ? addHeader6("# Evaluator Examples", formatEvaluatorExamples(evaluatorsData)) : "";
9355
+ const evaluatorExamples = evaluatorsData.length > 0 ? addHeader7("# Evaluator Examples", formatEvaluatorExamples(evaluatorsData)) : "";
8069
9356
  const values = {
8070
9357
  evaluatorsData,
8071
9358
  evaluators,
@@ -8082,7 +9369,7 @@ var evaluatorsProvider = {
8082
9369
 
8083
9370
  // src/providers/facts.ts
8084
9371
  import { ModelType as ModelType13 } from "@elizaos/core";
8085
- import { logger as logger12 } from "@elizaos/core";
9372
+ import { logger as logger14 } from "@elizaos/core";
8086
9373
  function formatFacts2(facts) {
8087
9374
  return facts.reverse().map((fact) => fact.content.text).join("\n");
8088
9375
  }
@@ -8146,7 +9433,7 @@ var factsProvider = {
8146
9433
  text
8147
9434
  };
8148
9435
  } catch (error) {
8149
- logger12.error("Error in factsProvider:", error);
9436
+ logger14.error("Error in factsProvider:", error);
8150
9437
  return {
8151
9438
  values: {
8152
9439
  facts: ""
@@ -8161,7 +9448,7 @@ var factsProvider = {
8161
9448
  };
8162
9449
 
8163
9450
  // src/providers/providers.ts
8164
- import { addHeader as addHeader7 } from "@elizaos/core";
9451
+ import { addHeader as addHeader8 } from "@elizaos/core";
8165
9452
  var providersProvider = {
8166
9453
  name: "PROVIDERS",
8167
9454
  description: "List of all data providers the agent can use to get additional information",
@@ -8173,11 +9460,11 @@ var providersProvider = {
8173
9460
  const headerText = "# Providers\n\nThese providers are available for the agent to select and use:";
8174
9461
  if (providerDescriptions.length === 0) {
8175
9462
  return {
8176
- text: addHeader7(headerText, "No dynamic providers are currently available.")
9463
+ text: addHeader8(headerText, "No dynamic providers are currently available.")
8177
9464
  };
8178
9465
  }
8179
9466
  const providersText = providerDescriptions.join("\n");
8180
- const text = addHeader7(headerText, providersText);
9467
+ const text = addHeader8(headerText, providersText);
8181
9468
  const data = {
8182
9469
  dynamicProviders: dynamicProviders.map((provider) => ({
8183
9470
  name: provider.name,
@@ -8193,12 +9480,12 @@ var providersProvider = {
8193
9480
 
8194
9481
  // src/providers/recentMessages.ts
8195
9482
  import {
8196
- addHeader as addHeader8,
9483
+ addHeader as addHeader9,
8197
9484
  ChannelType as ChannelType5,
8198
9485
  formatMessages,
8199
9486
  formatPosts,
8200
9487
  getEntityDetails as getEntityDetails3,
8201
- logger as logger13
9488
+ logger as logger15
8202
9489
  } from "@elizaos/core";
8203
9490
  var getRecentInteractions = async (runtime, sourceEntityId, targetEntityId, excludeRoomId) => {
8204
9491
  const rooms = await runtime.getRoomsForParticipants([sourceEntityId, targetEntityId]);
@@ -8228,32 +9515,78 @@ var recentMessagesProvider = {
8228
9515
  }),
8229
9516
  message.entityId !== runtime.agentId ? getRecentInteractions(runtime, message.entityId, runtime.agentId, roomId) : Promise.resolve([])
8230
9517
  ]);
9518
+ const actionResultMessages = recentMessagesData.filter(
9519
+ (msg) => msg.content?.type === "action_result" && msg.metadata?.type === "action_result"
9520
+ );
9521
+ const dialogueMessages = recentMessagesData.filter(
9522
+ (msg) => !(msg.content?.type === "action_result" && msg.metadata?.type === "action_result")
9523
+ );
8231
9524
  const isPostFormat = room?.type ? room.type === ChannelType5.FEED || room.type === ChannelType5.THREAD : false;
8232
9525
  const [formattedRecentMessages, formattedRecentPosts] = await Promise.all([
8233
9526
  formatMessages({
8234
- messages: recentMessagesData,
9527
+ messages: dialogueMessages,
8235
9528
  entities: entitiesData
8236
9529
  }),
8237
9530
  formatPosts({
8238
- messages: recentMessagesData,
9531
+ messages: dialogueMessages,
8239
9532
  entities: entitiesData,
8240
9533
  conversationHeader: false
8241
9534
  })
8242
9535
  ]);
8243
- const recentPosts = formattedRecentPosts && formattedRecentPosts.length > 0 ? addHeader8("# Posts in Thread", formattedRecentPosts) : "";
8244
- const recentMessages = formattedRecentMessages && formattedRecentMessages.length > 0 ? addHeader8("# Conversation Messages", formattedRecentMessages) : "";
8245
- if (!recentPosts && !recentMessages && recentMessagesData.length === 0 && !message.content.text) {
9536
+ let actionResultsText = "";
9537
+ if (actionResultMessages.length > 0) {
9538
+ const groupedByRun = /* @__PURE__ */ new Map();
9539
+ for (const mem of actionResultMessages) {
9540
+ const runId = String(mem.content?.runId || "unknown");
9541
+ if (!groupedByRun.has(runId)) {
9542
+ groupedByRun.set(runId, []);
9543
+ }
9544
+ const memories = groupedByRun.get(runId);
9545
+ if (memories) {
9546
+ memories.push(mem);
9547
+ }
9548
+ }
9549
+ const formattedActionResults = Array.from(groupedByRun.entries()).slice(-3).map(([runId, memories]) => {
9550
+ const sortedMemories = memories.sort(
9551
+ (a2, b) => (a2.createdAt || 0) - (b.createdAt || 0)
9552
+ );
9553
+ const thought = sortedMemories[0]?.content?.planThought || "";
9554
+ const runText = sortedMemories.map((mem) => {
9555
+ const actionName = mem.content?.actionName || "Unknown";
9556
+ const status = mem.content?.actionStatus || "unknown";
9557
+ const planStep = mem.content?.planStep || "";
9558
+ const text2 = mem.content?.text || "";
9559
+ const error = mem.content?.error || "";
9560
+ let memText = ` - ${actionName} (${status})`;
9561
+ if (planStep) memText += ` [${planStep}]`;
9562
+ if (error) {
9563
+ memText += `: Error - ${error}`;
9564
+ } else if (text2 && text2 !== `Executed action: ${actionName}`) {
9565
+ memText += `: ${text2}`;
9566
+ }
9567
+ return memText;
9568
+ }).join("\n");
9569
+ return `**Action Run ${runId.slice(0, 8)}**${thought ? ` - "${thought}"` : ""}
9570
+ ${runText}`;
9571
+ }).join("\n\n");
9572
+ actionResultsText = formattedActionResults ? addHeader9("# Recent Action Executions", formattedActionResults) : "";
9573
+ }
9574
+ const recentPosts = formattedRecentPosts && formattedRecentPosts.length > 0 ? addHeader9("# Posts in Thread", formattedRecentPosts) : "";
9575
+ const recentMessages = formattedRecentMessages && formattedRecentMessages.length > 0 ? addHeader9("# Conversation Messages", formattedRecentMessages) : "";
9576
+ if (!recentPosts && !recentMessages && dialogueMessages.length === 0 && !message.content.text) {
8246
9577
  return {
8247
9578
  data: {
8248
- recentMessages: [],
8249
- recentInteractions: []
9579
+ recentMessages: dialogueMessages,
9580
+ recentInteractions: [],
9581
+ actionResults: actionResultMessages
8250
9582
  },
8251
9583
  values: {
8252
9584
  recentPosts: "",
8253
9585
  recentMessages: "",
8254
9586
  recentMessageInteractions: "",
8255
9587
  recentPostInteractions: "",
8256
- recentInteractions: ""
9588
+ recentInteractions: "",
9589
+ recentActionResults: actionResultsText
8257
9590
  },
8258
9591
  text: "No recent messages available"
8259
9592
  };
@@ -8262,8 +9595,8 @@ var recentMessagesProvider = {
8262
9595
  const senderName = entitiesData.find((entity) => entity.id === message.entityId)?.names[0] || metaData?.entityName || "Unknown User";
8263
9596
  const receivedMessageContent = message.content.text;
8264
9597
  const hasReceivedMessage = !!receivedMessageContent?.trim();
8265
- const receivedMessageHeader = hasReceivedMessage ? addHeader8("# Received Message", `${senderName}: ${receivedMessageContent}`) : "";
8266
- const focusHeader = hasReceivedMessage ? addHeader8(
9598
+ const receivedMessageHeader = hasReceivedMessage ? addHeader9("# Received Message", `${senderName}: ${receivedMessageContent}`) : "";
9599
+ const focusHeader = hasReceivedMessage ? addHeader9(
8267
9600
  "# Focus your response",
8268
9601
  `You are replying to the above message from **${senderName}**. Keep your answer relevant to that message. Do not repeat earlier replies unless the sender asks again.`
8269
9602
  ) : "";
@@ -8327,18 +9660,22 @@ var recentMessagesProvider = {
8327
9660
  getRecentPostInteractions(recentInteractionsData, entitiesData)
8328
9661
  ]);
8329
9662
  const data = {
8330
- recentMessages: recentMessagesData,
8331
- recentInteractions: recentInteractionsData
9663
+ recentMessages: dialogueMessages,
9664
+ recentInteractions: recentInteractionsData,
9665
+ actionResults: actionResultMessages
8332
9666
  };
8333
9667
  const values = {
8334
9668
  recentPosts,
8335
9669
  recentMessages,
8336
9670
  recentMessageInteractions,
8337
9671
  recentPostInteractions,
8338
- recentInteractions: isPostFormat ? recentPostInteractions : recentMessageInteractions
9672
+ recentInteractions: isPostFormat ? recentPostInteractions : recentMessageInteractions,
9673
+ recentActionResults: actionResultsText
8339
9674
  };
8340
9675
  const text = [
8341
9676
  isPostFormat ? recentPosts : recentMessages,
9677
+ actionResultsText,
9678
+ // Include action results in the text output
8342
9679
  // Only add received message and focus headers if there are messages or a current message to process
8343
9680
  recentMessages || recentPosts || message.content.text ? receivedMessageHeader : "",
8344
9681
  recentMessages || recentPosts || message.content.text ? focusHeader : ""
@@ -8349,18 +9686,20 @@ var recentMessagesProvider = {
8349
9686
  text
8350
9687
  };
8351
9688
  } catch (error) {
8352
- logger13.error("Error in recentMessagesProvider:", error);
9689
+ logger15.error("Error in recentMessagesProvider:", error);
8353
9690
  return {
8354
9691
  data: {
8355
9692
  recentMessages: [],
8356
- recentInteractions: []
9693
+ recentInteractions: [],
9694
+ actionResults: []
8357
9695
  },
8358
9696
  values: {
8359
9697
  recentPosts: "",
8360
9698
  recentMessages: "",
8361
9699
  recentMessageInteractions: "",
8362
9700
  recentPostInteractions: "",
8363
- recentInteractions: ""
9701
+ recentInteractions: "",
9702
+ recentActionResults: ""
8364
9703
  },
8365
9704
  text: "Error retrieving recent messages."
8366
9705
  // Or 'No recent messages available' as the test expects
@@ -8456,7 +9795,7 @@ ${formattedRelationships}`
8456
9795
  import {
8457
9796
  ChannelType as ChannelType6,
8458
9797
  createUniqueUuid as createUniqueUuid2,
8459
- logger as logger14
9798
+ logger as logger16
8460
9799
  } from "@elizaos/core";
8461
9800
  var roleProvider = {
8462
9801
  name: "ROLES",
@@ -8481,11 +9820,11 @@ var roleProvider = {
8481
9820
  if (!serverId) {
8482
9821
  throw new Error("No server ID found");
8483
9822
  }
8484
- logger14.info(`Using server ID: ${serverId}`);
9823
+ logger16.info(`Using server ID: ${serverId}`);
8485
9824
  const worldId = createUniqueUuid2(runtime, serverId);
8486
9825
  const world = await runtime.getWorld(worldId);
8487
9826
  if (!world || !world.metadata?.ownership?.ownerId) {
8488
- logger14.info(
9827
+ logger16.info(
8489
9828
  `No ownership data found for server ${serverId}, initializing empty role hierarchy`
8490
9829
  );
8491
9830
  return {
@@ -8500,7 +9839,7 @@ var roleProvider = {
8500
9839
  }
8501
9840
  const roles = world.metadata.roles || {};
8502
9841
  if (Object.keys(roles).length === 0) {
8503
- logger14.info(`No roles found for server ${serverId}`);
9842
+ logger16.info(`No roles found for server ${serverId}`);
8504
9843
  return {
8505
9844
  data: {
8506
9845
  roles: []
@@ -8511,7 +9850,7 @@ var roleProvider = {
8511
9850
  text: "No role information available for this server."
8512
9851
  };
8513
9852
  }
8514
- logger14.info(`Found ${Object.keys(roles).length} roles`);
9853
+ logger16.info(`Found ${Object.keys(roles).length} roles`);
8515
9854
  const owners = [];
8516
9855
  const admins = [];
8517
9856
  const members = [];
@@ -8525,7 +9864,7 @@ var roleProvider = {
8525
9864
  continue;
8526
9865
  }
8527
9866
  if (!name || !username || !names) {
8528
- logger14.warn(`User ${entityId} has no name or username, skipping`);
9867
+ logger16.warn(`User ${entityId} has no name or username, skipping`);
8529
9868
  continue;
8530
9869
  }
8531
9870
  switch (userRole) {
@@ -8592,7 +9931,7 @@ import {
8592
9931
  ChannelType as ChannelType7,
8593
9932
  findWorldsForOwner as findWorldsForOwner2,
8594
9933
  getWorldSettings as getWorldSettings2,
8595
- logger as logger15
9934
+ logger as logger17
8596
9935
  } from "@elizaos/core";
8597
9936
  var formatSettingValue = (setting, isOnboarding) => {
8598
9937
  if (setting.value === null) return "Not set";
@@ -8663,7 +10002,7 @@ ${requiredUnconfigured > 0 ? `IMPORTANT!: ${requiredUnconfigured} required setti
8663
10002
  **Value:** ${s?.value}
8664
10003
  **Description:** ${s?.description}`).join("\n\n")}`;
8665
10004
  } catch (error) {
8666
- logger15.error(`Error generating status message: ${error}`);
10005
+ logger17.error(`Error generating status message: ${error}`);
8667
10006
  return "Error generating configuration status.";
8668
10007
  }
8669
10008
  }
@@ -8676,11 +10015,11 @@ var settingsProvider = {
8676
10015
  runtime.getRoom(message.roomId),
8677
10016
  findWorldsForOwner2(runtime, message.entityId)
8678
10017
  ]).catch((error) => {
8679
- logger15.error(`Error fetching initial data: ${error}`);
10018
+ logger17.error(`Error fetching initial data: ${error}`);
8680
10019
  throw new Error("Failed to retrieve room or user world information");
8681
10020
  });
8682
10021
  if (!room) {
8683
- logger15.error("No room found for settings provider");
10022
+ logger17.error("No room found for settings provider");
8684
10023
  return {
8685
10024
  data: {
8686
10025
  settings: []
@@ -8692,7 +10031,7 @@ var settingsProvider = {
8692
10031
  };
8693
10032
  }
8694
10033
  if (!room.worldId) {
8695
- logger15.debug("No world found for settings provider -- settings provider will be skipped");
10034
+ logger17.debug("No world found for settings provider -- settings provider will be skipped");
8696
10035
  return {
8697
10036
  data: {
8698
10037
  settings: []
@@ -8717,39 +10056,39 @@ var settingsProvider = {
8717
10056
  }
8718
10057
  world.metadata.settings = {};
8719
10058
  await runtime.updateWorld(world);
8720
- logger15.info(`Initialized settings for user's world ${world.id}`);
10059
+ logger17.info(`Initialized settings for user's world ${world.id}`);
8721
10060
  }
8722
10061
  if (!world) {
8723
- logger15.error("No world found for user during onboarding");
10062
+ logger17.error("No world found for user during onboarding");
8724
10063
  throw new Error("No server ownership found for onboarding");
8725
10064
  }
8726
10065
  serverId = world.serverId;
8727
10066
  try {
8728
10067
  worldSettings = await getWorldSettings2(runtime, serverId);
8729
10068
  } catch (error) {
8730
- logger15.error(`Error fetching world settings: ${error}`);
10069
+ logger17.error(`Error fetching world settings: ${error}`);
8731
10070
  throw new Error(`Failed to retrieve settings for server ${serverId}`);
8732
10071
  }
8733
10072
  } else {
8734
10073
  try {
8735
10074
  world = await runtime.getWorld(room.worldId);
8736
10075
  if (!world) {
8737
- logger15.error(`No world found for room ${room.worldId}`);
10076
+ logger17.error(`No world found for room ${room.worldId}`);
8738
10077
  throw new Error(`No world found for room ${room.worldId}`);
8739
10078
  }
8740
10079
  serverId = world.serverId;
8741
10080
  if (serverId) {
8742
10081
  worldSettings = await getWorldSettings2(runtime, serverId);
8743
10082
  } else {
8744
- logger15.error(`No server ID found for world ${room.worldId}`);
10083
+ logger17.error(`No server ID found for world ${room.worldId}`);
8745
10084
  }
8746
10085
  } catch (error) {
8747
- logger15.error(`Error processing world data: ${error}`);
10086
+ logger17.error(`Error processing world data: ${error}`);
8748
10087
  throw new Error("Failed to process world information");
8749
10088
  }
8750
10089
  }
8751
10090
  if (!serverId) {
8752
- logger15.info(
10091
+ logger17.info(
8753
10092
  `No server ownership found for user ${message.entityId} after recovery attempt`
8754
10093
  );
8755
10094
  return isOnboarding ? {
@@ -8771,7 +10110,7 @@ var settingsProvider = {
8771
10110
  };
8772
10111
  }
8773
10112
  if (!worldSettings) {
8774
- logger15.info(`No settings state found for server ${serverId}`);
10113
+ logger17.info(`No settings state found for server ${serverId}`);
8775
10114
  return isOnboarding ? {
8776
10115
  data: {
8777
10116
  settings: []
@@ -8801,7 +10140,7 @@ var settingsProvider = {
8801
10140
  text: output
8802
10141
  };
8803
10142
  } catch (error) {
8804
- logger15.error(`Critical error in settings provider: ${error}`);
10143
+ logger17.error(`Critical error in settings provider: ${error}`);
8805
10144
  return {
8806
10145
  data: {
8807
10146
  settings: []
@@ -8840,8 +10179,8 @@ var timeProvider = {
8840
10179
 
8841
10180
  // src/providers/world.ts
8842
10181
  import {
8843
- logger as logger16,
8844
- addHeader as addHeader9,
10182
+ logger as logger18,
10183
+ addHeader as addHeader10,
8845
10184
  ChannelType as ChannelType8
8846
10185
  } from "@elizaos/core";
8847
10186
  var worldProvider = {
@@ -8850,10 +10189,10 @@ var worldProvider = {
8850
10189
  dynamic: true,
8851
10190
  get: async (runtime, message) => {
8852
10191
  try {
8853
- logger16.debug("[\u{1F310}] World provider activated for roomId:", message.roomId);
10192
+ logger18.debug("[\u{1F310}] World provider activated for roomId:", message.roomId);
8854
10193
  const currentRoom = await runtime.getRoom(message.roomId);
8855
10194
  if (!currentRoom) {
8856
- logger16.warn(`World provider: Room not found for roomId ${message.roomId}`);
10195
+ logger18.warn(`World provider: Room not found for roomId ${message.roomId}`);
8857
10196
  return {
8858
10197
  data: {
8859
10198
  world: {
@@ -8863,10 +10202,10 @@ var worldProvider = {
8863
10202
  text: "Unable to retrieve world information - room not found"
8864
10203
  };
8865
10204
  }
8866
- logger16.debug(`[\u{1F310}] World provider: Found room "${currentRoom.name}" (${currentRoom.type})`);
10205
+ logger18.debug(`[\u{1F310}] World provider: Found room "${currentRoom.name}" (${currentRoom.type})`);
8867
10206
  const worldId = currentRoom.worldId;
8868
10207
  if (!worldId) {
8869
- logger16.warn(`World provider: World ID not found for roomId ${message.roomId}`);
10208
+ logger18.warn(`World provider: World ID not found for roomId ${message.roomId}`);
8870
10209
  return {
8871
10210
  data: {
8872
10211
  world: {
@@ -8878,7 +10217,7 @@ var worldProvider = {
8878
10217
  }
8879
10218
  const world = await runtime.getWorld(worldId);
8880
10219
  if (!world) {
8881
- logger16.warn(`World provider: World not found for worldId ${worldId}`);
10220
+ logger18.warn(`World provider: World not found for worldId ${worldId}`);
8882
10221
  return {
8883
10222
  data: {
8884
10223
  world: {
@@ -8888,13 +10227,13 @@ var worldProvider = {
8888
10227
  text: "Unable to retrieve world information - world not found"
8889
10228
  };
8890
10229
  }
8891
- logger16.debug(`[\u{1F310}] World provider: Found world "${world.name}" (ID: ${world.id})`);
10230
+ logger18.debug(`[\u{1F310}] World provider: Found world "${world.name}" (ID: ${world.id})`);
8892
10231
  const worldRooms = await runtime.getRooms(worldId);
8893
- logger16.debug(
10232
+ logger18.debug(
8894
10233
  `[\u{1F310}] World provider: Found ${worldRooms.length} rooms in world "${world.name}"`
8895
10234
  );
8896
10235
  const participants = await runtime.getParticipantsForRoom(message.roomId);
8897
- logger16.debug(
10236
+ logger18.debug(
8898
10237
  `[\u{1F310}] World provider: Found ${participants.length} participants in room "${currentRoom.name}"`
8899
10238
  );
8900
10239
  const channelsByType = {
@@ -8907,7 +10246,7 @@ var worldProvider = {
8907
10246
  };
8908
10247
  for (const room of worldRooms) {
8909
10248
  if (!room?.id || !room.name) {
8910
- logger16.warn(`World provider: Room ID or name is missing for room ${room.id}`);
10249
+ logger18.warn(`World provider: Room ID or name is missing for room ${room.id}`);
8911
10250
  continue;
8912
10251
  }
8913
10252
  const roomInfo = {
@@ -8975,15 +10314,15 @@ var worldProvider = {
8975
10314
  currentChannelName: currentRoom.name,
8976
10315
  worldInfo: worldInfoText
8977
10316
  };
8978
- const formattedText = addHeader9("# World Information", worldInfoText);
8979
- logger16.debug("[\u{1F310}] World provider completed successfully");
10317
+ const formattedText = addHeader10("# World Information", worldInfoText);
10318
+ logger18.debug("[\u{1F310}] World provider completed successfully");
8980
10319
  return {
8981
10320
  data,
8982
10321
  values,
8983
10322
  text: formattedText
8984
10323
  };
8985
10324
  } catch (error) {
8986
- logger16.error(
10325
+ logger18.error(
8987
10326
  `Error in world provider: ${error instanceof Error ? error.message : String(error)}`
8988
10327
  );
8989
10328
  return {
@@ -9001,7 +10340,7 @@ var worldProvider = {
9001
10340
 
9002
10341
  // src/services/task.ts
9003
10342
  import {
9004
- logger as logger17,
10343
+ logger as logger19,
9005
10344
  Service,
9006
10345
  ServiceType
9007
10346
  } from "@elizaos/core";
@@ -9029,21 +10368,21 @@ var TaskService = class _TaskService extends Service {
9029
10368
  this.runtime.registerTaskWorker({
9030
10369
  name: "REPEATING_TEST_TASK",
9031
10370
  validate: async (_runtime, _message, _state) => {
9032
- logger17.debug("[Bootstrap] Validating repeating test task");
10371
+ logger19.debug("[Bootstrap] Validating repeating test task");
9033
10372
  return true;
9034
10373
  },
9035
10374
  execute: async (_runtime, _options) => {
9036
- logger17.debug("[Bootstrap] Executing repeating test task");
10375
+ logger19.debug("[Bootstrap] Executing repeating test task");
9037
10376
  }
9038
10377
  });
9039
10378
  this.runtime.registerTaskWorker({
9040
10379
  name: "ONETIME_TEST_TASK",
9041
10380
  validate: async (_runtime, _message, _state) => {
9042
- logger17.debug("[Bootstrap] Validating one-time test task");
10381
+ logger19.debug("[Bootstrap] Validating one-time test task");
9043
10382
  return true;
9044
10383
  },
9045
10384
  execute: async (_runtime, _options) => {
9046
- logger17.debug("[Bootstrap] Executing one-time test task");
10385
+ logger19.debug("[Bootstrap] Executing one-time test task");
9047
10386
  }
9048
10387
  });
9049
10388
  const tasks = await this.runtime.getTasksByName("REPEATING_TEST_TASK");
@@ -9080,7 +10419,7 @@ var TaskService = class _TaskService extends Service {
9080
10419
  try {
9081
10420
  await this.checkTasks();
9082
10421
  } catch (error) {
9083
- logger17.error("[Bootstrap] Error checking tasks:", error);
10422
+ logger19.error("[Bootstrap] Error checking tasks:", error);
9084
10423
  }
9085
10424
  }, this.TICK_INTERVAL);
9086
10425
  }
@@ -9109,7 +10448,7 @@ var TaskService = class _TaskService extends Service {
9109
10448
  continue;
9110
10449
  }
9111
10450
  } catch (error) {
9112
- logger17.error(`[Bootstrap] Error validating task ${task.name}:`, error);
10451
+ logger19.error(`[Bootstrap] Error validating task ${task.name}:`, error);
9113
10452
  continue;
9114
10453
  }
9115
10454
  }
@@ -9151,20 +10490,20 @@ var TaskService = class _TaskService extends Service {
9151
10490
  }
9152
10491
  if (task.metadata?.updatedAt === task.metadata?.createdAt) {
9153
10492
  if (task.tags?.includes("immediate")) {
9154
- logger17.debug("[Bootstrap] Immediately running task", task.name);
10493
+ logger19.debug("[Bootstrap] Immediately running task", task.name);
9155
10494
  await this.executeTask(task);
9156
10495
  continue;
9157
10496
  }
9158
10497
  }
9159
10498
  if (now - taskStartTime >= updateIntervalMs) {
9160
- logger17.debug(
10499
+ logger19.debug(
9161
10500
  `[Bootstrap] Executing task ${task.name} - interval of ${updateIntervalMs}ms has elapsed`
9162
10501
  );
9163
10502
  await this.executeTask(task);
9164
10503
  }
9165
10504
  }
9166
10505
  } catch (error) {
9167
- logger17.error("[Bootstrap] Error checking tasks:", error);
10506
+ logger19.error("[Bootstrap] Error checking tasks:", error);
9168
10507
  }
9169
10508
  }
9170
10509
  /**
@@ -9175,12 +10514,12 @@ var TaskService = class _TaskService extends Service {
9175
10514
  async executeTask(task) {
9176
10515
  try {
9177
10516
  if (!task || !task.id) {
9178
- logger17.debug(`[Bootstrap] Task not found`);
10517
+ logger19.debug(`[Bootstrap] Task not found`);
9179
10518
  return;
9180
10519
  }
9181
10520
  const worker = this.runtime.getTaskWorker(task.name);
9182
10521
  if (!worker) {
9183
- logger17.debug(`[Bootstrap] No worker found for task type: ${task.name}`);
10522
+ logger19.debug(`[Bootstrap] No worker found for task type: ${task.name}`);
9184
10523
  return;
9185
10524
  }
9186
10525
  if (task.tags?.includes("repeat")) {
@@ -9190,20 +10529,20 @@ var TaskService = class _TaskService extends Service {
9190
10529
  updatedAt: Date.now()
9191
10530
  }
9192
10531
  });
9193
- logger17.debug(
10532
+ logger19.debug(
9194
10533
  `[Bootstrap] Updated repeating task ${task.name} (${task.id}) with new timestamp`
9195
10534
  );
9196
10535
  }
9197
- logger17.debug(`[Bootstrap] Executing task ${task.name} (${task.id})`);
10536
+ logger19.debug(`[Bootstrap] Executing task ${task.name} (${task.id})`);
9198
10537
  await worker.execute(this.runtime, task.metadata || {}, task);
9199
10538
  if (!task.tags?.includes("repeat")) {
9200
10539
  await this.runtime.deleteTask(task.id);
9201
- logger17.debug(
10540
+ logger19.debug(
9202
10541
  `[Bootstrap] Deleted non-repeating task ${task.name} (${task.id}) after execution`
9203
10542
  );
9204
10543
  }
9205
10544
  } catch (error) {
9206
- logger17.error(`[Bootstrap] Error executing task ${task.id}:`, error);
10545
+ logger19.error(`[Bootstrap] Error executing task ${task.id}:`, error);
9207
10546
  }
9208
10547
  }
9209
10548
  /**
@@ -10416,7 +11755,7 @@ async function processAttachments(attachments, runtime) {
10416
11755
  if (!attachments || attachments.length === 0) {
10417
11756
  return [];
10418
11757
  }
10419
- logger18.debug(`[Bootstrap] Processing ${attachments.length} attachment(s)`);
11758
+ logger20.debug(`[Bootstrap] Processing ${attachments.length} attachment(s)`);
10420
11759
  const processedAttachments = [];
10421
11760
  for (const attachment of attachments) {
10422
11761
  try {
@@ -10424,7 +11763,7 @@ async function processAttachments(attachments, runtime) {
10424
11763
  const isRemote = /^(http|https):\/\//.test(attachment.url);
10425
11764
  const url = isRemote ? attachment.url : getLocalServerUrl(attachment.url);
10426
11765
  if (attachment.contentType === ContentType2.IMAGE && !attachment.description) {
10427
- logger18.debug(`[Bootstrap] Generating description for image: ${attachment.url}`);
11766
+ logger20.debug(`[Bootstrap] Generating description for image: ${attachment.url}`);
10428
11767
  let imageUrl = url;
10429
11768
  if (!isRemote) {
10430
11769
  const res = await lib_default(url);
@@ -10444,24 +11783,24 @@ async function processAttachments(attachments, runtime) {
10444
11783
  processedAttachment.description = parsedXml.description;
10445
11784
  processedAttachment.title = parsedXml.title || "Image";
10446
11785
  processedAttachment.text = parsedXml.text;
10447
- logger18.debug(
11786
+ logger20.debug(
10448
11787
  `[Bootstrap] Generated description: ${processedAttachment.description?.substring(0, 100)}...`
10449
11788
  );
10450
11789
  } else {
10451
- logger18.warn(`[Bootstrap] Failed to parse XML response for image description`);
11790
+ logger20.warn(`[Bootstrap] Failed to parse XML response for image description`);
10452
11791
  }
10453
11792
  } else if (response && typeof response === "object" && "description" in response) {
10454
11793
  processedAttachment.description = response.description;
10455
11794
  processedAttachment.title = response.title || "Image";
10456
11795
  processedAttachment.text = response.description;
10457
- logger18.debug(
11796
+ logger20.debug(
10458
11797
  `[Bootstrap] Generated description: ${processedAttachment.description?.substring(0, 100)}...`
10459
11798
  );
10460
11799
  } else {
10461
- logger18.warn(`[Bootstrap] Unexpected response format for image description`);
11800
+ logger20.warn(`[Bootstrap] Unexpected response format for image description`);
10462
11801
  }
10463
11802
  } catch (error) {
10464
- logger18.error(`[Bootstrap] Error generating image description:`, error);
11803
+ logger20.error(`[Bootstrap] Error generating image description:`, error);
10465
11804
  }
10466
11805
  } else if (attachment.contentType === ContentType2.DOCUMENT && !attachment.text) {
10467
11806
  const res = await lib_default(url);
@@ -10469,20 +11808,20 @@ async function processAttachments(attachments, runtime) {
10469
11808
  const contentType = res.headers.get("content-type") || "";
10470
11809
  const isPlainText = contentType.startsWith("text/plain");
10471
11810
  if (isPlainText) {
10472
- logger18.debug(`[Bootstrap] Processing plain text document: ${attachment.url}`);
11811
+ logger20.debug(`[Bootstrap] Processing plain text document: ${attachment.url}`);
10473
11812
  const textContent = await res.text();
10474
11813
  processedAttachment.text = textContent;
10475
11814
  processedAttachment.title = processedAttachment.title || "Text File";
10476
- logger18.debug(
11815
+ logger20.debug(
10477
11816
  `[Bootstrap] Extracted text content (first 100 chars): ${processedAttachment.text?.substring(0, 100)}...`
10478
11817
  );
10479
11818
  } else {
10480
- logger18.warn(`[Bootstrap] Skipping non-plain-text document: ${contentType}`);
11819
+ logger20.warn(`[Bootstrap] Skipping non-plain-text document: ${contentType}`);
10481
11820
  }
10482
11821
  }
10483
11822
  processedAttachments.push(processedAttachment);
10484
11823
  } catch (error) {
10485
- logger18.error(`[Bootstrap] Failed to process attachment ${attachment.url}:`, error);
11824
+ logger20.error(`[Bootstrap] Failed to process attachment ${attachment.url}:`, error);
10486
11825
  processedAttachments.push(attachment);
10487
11826
  }
10488
11827
  }
@@ -10527,7 +11866,7 @@ var messageReceivedHandler = async ({
10527
11866
  const timeoutDuration = 60 * 60 * 1e3;
10528
11867
  let timeoutId = void 0;
10529
11868
  try {
10530
- logger18.info(`[Bootstrap] Message received from ${message.entityId} in room ${message.roomId}`);
11869
+ logger20.info(`[Bootstrap] Message received from ${message.entityId} in room ${message.roomId}`);
10531
11870
  const responseId = v4_default();
10532
11871
  if (!latestResponseIds.has(runtime.agentId)) {
10533
11872
  latestResponseIds.set(runtime.agentId, /* @__PURE__ */ new Map());
@@ -10570,13 +11909,13 @@ var messageReceivedHandler = async ({
10570
11909
  const processingPromise = (async () => {
10571
11910
  try {
10572
11911
  if (message.entityId === runtime.agentId) {
10573
- logger18.debug(`[Bootstrap] Skipping message from self (${runtime.agentId})`);
11912
+ logger20.debug(`[Bootstrap] Skipping message from self (${runtime.agentId})`);
10574
11913
  throw new Error("Message is from the agent itself");
10575
11914
  }
10576
- logger18.debug(
11915
+ logger20.debug(
10577
11916
  `[Bootstrap] Processing message: ${truncateToCompleteSentence(message.content.text || "", 50)}...`
10578
11917
  );
10579
- logger18.debug("[Bootstrap] Saving message to memory and embeddings");
11918
+ logger20.debug("[Bootstrap] Saving message to memory and embeddings");
10580
11919
  await Promise.all([
10581
11920
  runtime.addEmbeddingToMemory(message),
10582
11921
  runtime.createMemory(message, "messages")
@@ -10586,7 +11925,7 @@ var messageReceivedHandler = async ({
10586
11925
  runtime.agentId
10587
11926
  );
10588
11927
  if (agentUserState === "MUTED" && !message.content.text?.toLowerCase().includes(runtime.character.name.toLowerCase())) {
10589
- logger18.debug(`[Bootstrap] Ignoring muted room ${message.roomId}`);
11928
+ logger20.debug(`[Bootstrap] Ignoring muted room ${message.roomId}`);
10590
11929
  return;
10591
11930
  }
10592
11931
  let state = await runtime.composeState(
@@ -10618,24 +11957,24 @@ var messageReceivedHandler = async ({
10618
11957
  state,
10619
11958
  template: runtime.character.templates?.shouldRespondTemplate || shouldRespondTemplate
10620
11959
  });
10621
- logger18.debug(
11960
+ logger20.debug(
10622
11961
  `[Bootstrap] Evaluating response for ${runtime.character.name}
10623
11962
  Prompt: ${shouldRespondPrompt}`
10624
11963
  );
10625
11964
  const response = await runtime.useModel(ModelType14.TEXT_SMALL, {
10626
11965
  prompt: shouldRespondPrompt
10627
11966
  });
10628
- logger18.debug(
11967
+ logger20.debug(
10629
11968
  `[Bootstrap] Response evaluation for ${runtime.character.name}:
10630
11969
  ${response}`
10631
11970
  );
10632
- logger18.debug(`[Bootstrap] Response type: ${typeof response}`);
11971
+ logger20.debug(`[Bootstrap] Response type: ${typeof response}`);
10633
11972
  const responseObject = parseKeyValueXml(response);
10634
- logger18.debug("[Bootstrap] Parsed response:", responseObject);
11973
+ logger20.debug("[Bootstrap] Parsed response:", responseObject);
10635
11974
  const nonResponseActions = ["IGNORE", "NONE"];
10636
11975
  shouldRespond = responseObject?.action && !nonResponseActions.includes(responseObject.action.toUpperCase());
10637
11976
  } else {
10638
- logger18.debug(
11977
+ logger20.debug(
10639
11978
  `[Bootstrap] Skipping shouldRespond check for ${runtime.character.name} because ${room?.type} ${room?.source}`
10640
11979
  );
10641
11980
  shouldRespond = true;
@@ -10646,7 +11985,7 @@ ${response}`
10646
11985
  if (shouldRespond) {
10647
11986
  state = await runtime.composeState(message, ["ACTIONS"]);
10648
11987
  if (!state.values.actionNames) {
10649
- logger18.warn("actionNames data missing from state, even though it was requested");
11988
+ logger20.warn("actionNames data missing from state, even though it was requested");
10650
11989
  }
10651
11990
  const prompt = composePromptFromState10({
10652
11991
  state,
@@ -10659,9 +11998,9 @@ ${response}`
10659
11998
  let response = await runtime.useModel(ModelType14.TEXT_LARGE, {
10660
11999
  prompt
10661
12000
  });
10662
- logger18.debug("[Bootstrap] *** Raw LLM Response ***\n", response);
12001
+ logger20.debug("[Bootstrap] *** Raw LLM Response ***\n", response);
10663
12002
  const parsedXml = parseKeyValueXml(response);
10664
- logger18.debug("[Bootstrap] *** Parsed XML Content ***\n", parsedXml);
12003
+ logger20.debug("[Bootstrap] *** Parsed XML Content ***\n", parsedXml);
10665
12004
  if (parsedXml) {
10666
12005
  responseContent = {
10667
12006
  ...parsedXml,
@@ -10676,7 +12015,7 @@ ${response}`
10676
12015
  }
10677
12016
  retries++;
10678
12017
  if (!responseContent?.thought || !responseContent?.actions) {
10679
- logger18.warn(
12018
+ logger20.warn(
10680
12019
  "[Bootstrap] *** Missing required fields (thought or actions), retrying... ***\n",
10681
12020
  response,
10682
12021
  parsedXml,
@@ -10686,14 +12025,34 @@ ${response}`
10686
12025
  }
10687
12026
  const currentResponseId = agentResponses.get(message.roomId);
10688
12027
  if (currentResponseId !== responseId) {
10689
- logger18.info(
12028
+ logger20.info(
10690
12029
  `Response discarded - newer message being processed for agent: ${runtime.agentId}, room: ${message.roomId}`
10691
12030
  );
10692
12031
  return;
10693
12032
  }
10694
12033
  if (responseContent && message.id) {
10695
12034
  responseContent.inReplyTo = createUniqueUuid3(runtime, message.id);
10696
- const isSimple = responseContent.actions?.length === 1 && responseContent.actions[0].toUpperCase() === "REPLY" && (!responseContent.providers || responseContent.providers.length === 0);
12035
+ if (responseContent.actions && responseContent.actions.length > 1) {
12036
+ const isIgnoreAction = (action) => {
12037
+ return typeof action === "string" && action.toUpperCase() === "IGNORE";
12038
+ };
12039
+ const hasIgnoreAction = responseContent.actions.some(isIgnoreAction);
12040
+ if (hasIgnoreAction) {
12041
+ if (!responseContent.text || responseContent.text.trim() === "") {
12042
+ responseContent.actions = ["IGNORE"];
12043
+ } else {
12044
+ const filteredActions = responseContent.actions.filter(
12045
+ (action) => !isIgnoreAction(action)
12046
+ );
12047
+ if (filteredActions.length === 0) {
12048
+ responseContent.actions = ["REPLY"];
12049
+ } else {
12050
+ responseContent.actions = filteredActions;
12051
+ }
12052
+ }
12053
+ }
12054
+ }
12055
+ const isSimple = responseContent.actions?.length === 1 && typeof responseContent.actions[0] === "string" && responseContent.actions[0].toUpperCase() === "REPLY" && (!responseContent.providers || responseContent.providers.length === 0);
10697
12056
  responseContent.simple = isSimple;
10698
12057
  const responseMessage = {
10699
12058
  id: asUUID(v4_default()),
@@ -10714,7 +12073,7 @@ ${response}`
10714
12073
  }
10715
12074
  if (responseContent && responseContent.simple && responseContent.text) {
10716
12075
  if (responseContent.providers && responseContent.providers.length > 0) {
10717
- logger18.debug("[Bootstrap] Simple response used providers", responseContent.providers);
12076
+ logger20.debug("[Bootstrap] Simple response used providers", responseContent.providers);
10718
12077
  }
10719
12078
  await callback(responseContent);
10720
12079
  } else {
@@ -10722,16 +12081,16 @@ ${response}`
10722
12081
  }
10723
12082
  await runtime.evaluate(message, state, shouldRespond, callback, responseMessages);
10724
12083
  } else {
10725
- logger18.debug("[Bootstrap] Agent decided not to respond (shouldRespond is false).");
12084
+ logger20.debug("[Bootstrap] Agent decided not to respond (shouldRespond is false).");
10726
12085
  const currentResponseId = agentResponses.get(message.roomId);
10727
12086
  if (currentResponseId !== responseId) {
10728
- logger18.info(
12087
+ logger20.info(
10729
12088
  `Ignore response discarded - newer message being processed for agent: ${runtime.agentId}, room: ${message.roomId}`
10730
12089
  );
10731
12090
  return;
10732
12091
  }
10733
12092
  if (!message.id) {
10734
- logger18.error("[Bootstrap] Message ID is missing, cannot create ignore response.");
12093
+ logger20.error("[Bootstrap] Message ID is missing, cannot create ignore response.");
10735
12094
  return;
10736
12095
  }
10737
12096
  const ignoreContent = {
@@ -10752,7 +12111,7 @@ ${response}`
10752
12111
  createdAt: Date.now()
10753
12112
  };
10754
12113
  await runtime.createMemory(ignoreMemory, "messages");
10755
- logger18.debug("[Bootstrap] Saved ignore response to memory", {
12114
+ logger20.debug("[Bootstrap] Saved ignore response to memory", {
10756
12115
  memoryId: ignoreMemory.id
10757
12116
  });
10758
12117
  agentResponses.delete(message.roomId);
@@ -10803,10 +12162,10 @@ var reactionReceivedHandler = async ({
10803
12162
  await runtime.createMemory(message, "messages");
10804
12163
  } catch (error) {
10805
12164
  if (error.code === "23505") {
10806
- logger18.warn("[Bootstrap] Duplicate reaction memory, skipping");
12165
+ logger20.warn("[Bootstrap] Duplicate reaction memory, skipping");
10807
12166
  return;
10808
12167
  }
10809
- logger18.error("[Bootstrap] Error in reaction handler:", error);
12168
+ logger20.error("[Bootstrap] Error in reaction handler:", error);
10810
12169
  }
10811
12170
  };
10812
12171
  var messageDeletedHandler = async ({
@@ -10815,14 +12174,14 @@ var messageDeletedHandler = async ({
10815
12174
  }) => {
10816
12175
  try {
10817
12176
  if (!message.id) {
10818
- logger18.error("[Bootstrap] Cannot delete memory: message ID is missing");
12177
+ logger20.error("[Bootstrap] Cannot delete memory: message ID is missing");
10819
12178
  return;
10820
12179
  }
10821
- logger18.info("[Bootstrap] Deleting memory for message", message.id, "from room", message.roomId);
12180
+ logger20.info("[Bootstrap] Deleting memory for message", message.id, "from room", message.roomId);
10822
12181
  await runtime.deleteMemory(message.id);
10823
- logger18.debug("[Bootstrap] Successfully deleted memory for message", message.id);
12182
+ logger20.debug("[Bootstrap] Successfully deleted memory for message", message.id);
10824
12183
  } catch (error) {
10825
- logger18.error("[Bootstrap] Error in message deleted handler:", error);
12184
+ logger20.error("[Bootstrap] Error in message deleted handler:", error);
10826
12185
  }
10827
12186
  };
10828
12187
  var channelClearedHandler = async ({
@@ -10832,7 +12191,7 @@ var channelClearedHandler = async ({
10832
12191
  memoryCount
10833
12192
  }) => {
10834
12193
  try {
10835
- logger18.info(
12194
+ logger20.info(
10836
12195
  `[Bootstrap] Clearing ${memoryCount} message memories from channel ${channelId} -> room ${roomId}`
10837
12196
  );
10838
12197
  const memories = await runtime.getMemoriesByRoomIds({
@@ -10846,15 +12205,15 @@ var channelClearedHandler = async ({
10846
12205
  await runtime.deleteMemory(memory.id);
10847
12206
  deletedCount++;
10848
12207
  } catch (error) {
10849
- logger18.warn(`[Bootstrap] Failed to delete message memory ${memory.id}:`, error);
12208
+ logger20.warn(`[Bootstrap] Failed to delete message memory ${memory.id}:`, error);
10850
12209
  }
10851
12210
  }
10852
12211
  }
10853
- logger18.info(
12212
+ logger20.info(
10854
12213
  `[Bootstrap] Successfully cleared ${deletedCount}/${memories.length} message memories from channel ${channelId}`
10855
12214
  );
10856
12215
  } catch (error) {
10857
- logger18.error("[Bootstrap] Error in channel cleared handler:", error);
12216
+ logger20.error("[Bootstrap] Error in channel cleared handler:", error);
10858
12217
  }
10859
12218
  };
10860
12219
  var postGeneratedHandler = async ({
@@ -10865,7 +12224,7 @@ var postGeneratedHandler = async ({
10865
12224
  roomId,
10866
12225
  source
10867
12226
  }) => {
10868
- logger18.info("[Bootstrap] Generating new post...");
12227
+ logger20.info("[Bootstrap] Generating new post...");
10869
12228
  await runtime.ensureWorldExists({
10870
12229
  id: worldId,
10871
12230
  name: `${runtime.character.name}'s Feed`,
@@ -10929,7 +12288,7 @@ var postGeneratedHandler = async ({
10929
12288
  }
10930
12289
  retries++;
10931
12290
  if (!responseContent?.thought || !responseContent?.actions) {
10932
- logger18.warn(
12291
+ logger20.warn(
10933
12292
  "[Bootstrap] *** Missing required fields, retrying... ***\n",
10934
12293
  response,
10935
12294
  parsedXml,
@@ -10947,7 +12306,7 @@ var postGeneratedHandler = async ({
10947
12306
  });
10948
12307
  const parsedXmlResponse = parseKeyValueXml(xmlResponseText);
10949
12308
  if (!parsedXmlResponse) {
10950
- logger18.error(
12309
+ logger20.error(
10951
12310
  "[Bootstrap] Failed to parse XML response for post creation. Raw response:",
10952
12311
  xmlResponseText
10953
12312
  );
@@ -10964,7 +12323,7 @@ var postGeneratedHandler = async ({
10964
12323
  if (RM) {
10965
12324
  for (const m of RM.data.recentMessages) {
10966
12325
  if (cleanedText === m.content.text) {
10967
- logger18.log("[Bootstrap] Already recently posted that, retrying", cleanedText);
12326
+ logger20.log("[Bootstrap] Already recently posted that, retrying", cleanedText);
10968
12327
  postGeneratedHandler({
10969
12328
  runtime,
10970
12329
  callback,
@@ -10982,7 +12341,7 @@ var postGeneratedHandler = async ({
10982
12341
  const googleRefusalRegex = /(i\s+can'?t\s+help\s+with\s+that|that\s+goes\s+against\s+(our\s+)?(policy|policies)|i'?m\s+still\s+learning|response\s+must\s+follow\s+(usage|safety)\s+policies|i'?ve\s+been\s+designed\s+to\s+avoid\s+that)/i;
10983
12342
  const generalRefusalRegex = /(response\s+was\s+withheld|content\s+was\s+filtered|this\s+request\s+cannot\s+be\s+completed|violates\s+our\s+safety\s+policy|content\s+is\s+not\s+available)/i;
10984
12343
  if (oaiRefusalRegex.test(cleanedText) || anthropicRefusalRegex.test(cleanedText) || googleRefusalRegex.test(cleanedText) || generalRefusalRegex.test(cleanedText)) {
10985
- logger18.log("[Bootstrap] Got prompt moderation refusal, retrying", cleanedText);
12344
+ logger20.log("[Bootstrap] Got prompt moderation refusal, retrying", cleanedText);
10986
12345
  postGeneratedHandler({
10987
12346
  runtime,
10988
12347
  callback,
@@ -11016,9 +12375,9 @@ var postGeneratedHandler = async ({
11016
12375
  var syncSingleUser = async (entityId, runtime, serverId, channelId, type, source) => {
11017
12376
  try {
11018
12377
  const entity = await runtime.getEntityById(entityId);
11019
- logger18.info(`[Bootstrap] Syncing user: ${entity?.metadata?.username || entityId}`);
12378
+ logger20.info(`[Bootstrap] Syncing user: ${entity?.metadata?.username || entityId}`);
11020
12379
  if (!channelId) {
11021
- logger18.warn(`[Bootstrap] Cannot sync user ${entity?.id} without a valid channelId`);
12380
+ logger20.warn(`[Bootstrap] Cannot sync user ${entity?.id} without a valid channelId`);
11022
12381
  return;
11023
12382
  }
11024
12383
  const roomId = createUniqueUuid3(runtime, channelId);
@@ -11033,7 +12392,7 @@ var syncSingleUser = async (entityId, runtime, serverId, channelId, type, source
11033
12392
  settings: {}
11034
12393
  // Initialize empty settings for onboarding
11035
12394
  } : void 0;
11036
- logger18.info(
12395
+ logger20.info(
11037
12396
  `[Bootstrap] syncSingleUser - type: ${type}, isDM: ${type === ChannelType9.DM}, worldMetadata: ${JSON.stringify(worldMetadata)}`
11038
12397
  );
11039
12398
  await runtime.ensureConnection({
@@ -11049,15 +12408,15 @@ var syncSingleUser = async (entityId, runtime, serverId, channelId, type, source
11049
12408
  });
11050
12409
  try {
11051
12410
  const createdWorld = await runtime.getWorld(worldId);
11052
- logger18.info(
12411
+ logger20.info(
11053
12412
  `[Bootstrap] Created world check - ID: ${worldId}, metadata: ${JSON.stringify(createdWorld?.metadata)}`
11054
12413
  );
11055
12414
  } catch (error) {
11056
- logger18.error(`[Bootstrap] Failed to verify created world: ${error}`);
12415
+ logger20.error(`[Bootstrap] Failed to verify created world: ${error}`);
11057
12416
  }
11058
- logger18.success(`[Bootstrap] Successfully synced user: ${entity?.id}`);
12417
+ logger20.success(`[Bootstrap] Successfully synced user: ${entity?.id}`);
11059
12418
  } catch (error) {
11060
- logger18.error(
12419
+ logger20.error(
11061
12420
  `[Bootstrap] Error syncing user: ${error instanceof Error ? error.message : String(error)}`
11062
12421
  );
11063
12422
  }
@@ -11070,13 +12429,13 @@ var handleServerSync = async ({
11070
12429
  source,
11071
12430
  onComplete
11072
12431
  }) => {
11073
- logger18.debug(`[Bootstrap] Handling server sync event for server: ${world.name}`);
12432
+ logger20.debug(`[Bootstrap] Handling server sync event for server: ${world.name}`);
11074
12433
  try {
11075
12434
  await runtime.ensureConnections(entities, rooms, source, world);
11076
- logger18.debug(`Successfully synced standardized world structure for ${world.name}`);
12435
+ logger20.debug(`Successfully synced standardized world structure for ${world.name}`);
11077
12436
  onComplete?.();
11078
12437
  } catch (error) {
11079
- logger18.error(
12438
+ logger20.error(
11080
12439
  `Error processing standardized server data: ${error instanceof Error ? error.message : String(error)}`
11081
12440
  );
11082
12441
  }
@@ -11086,7 +12445,7 @@ var controlMessageHandler = async ({
11086
12445
  message
11087
12446
  }) => {
11088
12447
  try {
11089
- logger18.debug(
12448
+ logger20.debug(
11090
12449
  `[controlMessageHandler] Processing control message: ${message.payload.action} for room ${message.roomId}`
11091
12450
  );
11092
12451
  const serviceNames = Array.from(runtime.getAllServices().keys());
@@ -11104,24 +12463,24 @@ var controlMessageHandler = async ({
11104
12463
  roomId: message.roomId
11105
12464
  }
11106
12465
  });
11107
- logger18.debug(
12466
+ logger20.debug(
11108
12467
  `[controlMessageHandler] Control message ${message.payload.action} sent successfully`
11109
12468
  );
11110
12469
  } else {
11111
- logger18.error("[controlMessageHandler] WebSocket service does not have sendMessage method");
12470
+ logger20.error("[controlMessageHandler] WebSocket service does not have sendMessage method");
11112
12471
  }
11113
12472
  } else {
11114
- logger18.error("[controlMessageHandler] No WebSocket service found to send control message");
12473
+ logger20.error("[controlMessageHandler] No WebSocket service found to send control message");
11115
12474
  }
11116
12475
  } catch (error) {
11117
- logger18.error(`[controlMessageHandler] Error processing control message: ${error}`);
12476
+ logger20.error(`[controlMessageHandler] Error processing control message: ${error}`);
11118
12477
  }
11119
12478
  };
11120
12479
  var events = {
11121
12480
  [EventType.MESSAGE_RECEIVED]: [
11122
12481
  async (payload) => {
11123
12482
  if (!payload.callback) {
11124
- logger18.error("No callback provided for message");
12483
+ logger20.error("No callback provided for message");
11125
12484
  return;
11126
12485
  }
11127
12486
  await messageReceivedHandler({
@@ -11135,7 +12494,7 @@ var events = {
11135
12494
  [EventType.VOICE_MESSAGE_RECEIVED]: [
11136
12495
  async (payload) => {
11137
12496
  if (!payload.callback) {
11138
- logger18.error("No callback provided for voice message");
12497
+ logger20.error("No callback provided for voice message");
11139
12498
  return;
11140
12499
  }
11141
12500
  await messageReceivedHandler({
@@ -11161,7 +12520,7 @@ var events = {
11161
12520
  ],
11162
12521
  [EventType.MESSAGE_SENT]: [
11163
12522
  async (payload) => {
11164
- logger18.debug(`[Bootstrap] Message sent: ${payload.message.content.text}`);
12523
+ logger20.debug(`[Bootstrap] Message sent: ${payload.message.content.text}`);
11165
12524
  }
11166
12525
  ],
11167
12526
  [EventType.MESSAGE_DELETED]: [
@@ -11194,17 +12553,17 @@ var events = {
11194
12553
  ],
11195
12554
  [EventType.ENTITY_JOINED]: [
11196
12555
  async (payload) => {
11197
- logger18.debug(`[Bootstrap] ENTITY_JOINED event received for entity ${payload.entityId}`);
12556
+ logger20.debug(`[Bootstrap] ENTITY_JOINED event received for entity ${payload.entityId}`);
11198
12557
  if (!payload.worldId) {
11199
- logger18.error("[Bootstrap] No worldId provided for entity joined");
12558
+ logger20.error("[Bootstrap] No worldId provided for entity joined");
11200
12559
  return;
11201
12560
  }
11202
12561
  if (!payload.roomId) {
11203
- logger18.error("[Bootstrap] No roomId provided for entity joined");
12562
+ logger20.error("[Bootstrap] No roomId provided for entity joined");
11204
12563
  return;
11205
12564
  }
11206
12565
  if (!payload.metadata?.type) {
11207
- logger18.error("[Bootstrap] No type provided for entity joined");
12566
+ logger20.error("[Bootstrap] No type provided for entity joined");
11208
12567
  return;
11209
12568
  }
11210
12569
  await syncSingleUser(
@@ -11229,26 +12588,26 @@ var events = {
11229
12588
  };
11230
12589
  await payload.runtime.updateEntity(entity);
11231
12590
  }
11232
- logger18.info(`[Bootstrap] User ${payload.entityId} left world ${payload.worldId}`);
12591
+ logger20.info(`[Bootstrap] User ${payload.entityId} left world ${payload.worldId}`);
11233
12592
  } catch (error) {
11234
- logger18.error(`[Bootstrap] Error handling user left: ${error.message}`);
12593
+ logger20.error(`[Bootstrap] Error handling user left: ${error.message}`);
11235
12594
  }
11236
12595
  }
11237
12596
  ],
11238
12597
  [EventType.ACTION_STARTED]: [
11239
12598
  async (payload) => {
11240
- logger18.debug(`[Bootstrap] Action started: ${payload.actionName} (${payload.actionId})`);
12599
+ logger20.debug(`[Bootstrap] Action started: ${payload.actionName} (${payload.actionId})`);
11241
12600
  }
11242
12601
  ],
11243
12602
  [EventType.ACTION_COMPLETED]: [
11244
12603
  async (payload) => {
11245
12604
  const status = payload.error ? `failed: ${payload.error.message}` : "completed";
11246
- logger18.debug(`[Bootstrap] Action ${status}: ${payload.actionName} (${payload.actionId})`);
12605
+ logger20.debug(`[Bootstrap] Action ${status}: ${payload.actionName} (${payload.actionId})`);
11247
12606
  }
11248
12607
  ],
11249
12608
  [EventType.EVALUATOR_STARTED]: [
11250
12609
  async (payload) => {
11251
- logger18.debug(
12610
+ logger20.debug(
11252
12611
  `[Bootstrap] Evaluator started: ${payload.evaluatorName} (${payload.evaluatorId})`
11253
12612
  );
11254
12613
  }
@@ -11256,7 +12615,7 @@ var events = {
11256
12615
  [EventType.EVALUATOR_COMPLETED]: [
11257
12616
  async (payload) => {
11258
12617
  const status = payload.error ? `failed: ${payload.error.message}` : "completed";
11259
- logger18.debug(
12618
+ logger20.debug(
11260
12619
  `[Bootstrap] Evaluator ${status}: ${payload.evaluatorName} (${payload.evaluatorId})`
11261
12620
  );
11262
12621
  }
@@ -11298,6 +12657,7 @@ var bootstrapPlugin = {
11298
12657
  attachmentsProvider,
11299
12658
  providersProvider,
11300
12659
  actionsProvider,
12660
+ actionStateProvider,
11301
12661
  characterProvider,
11302
12662
  recentMessagesProvider,
11303
12663
  worldProvider
@@ -11306,6 +12666,7 @@ var bootstrapPlugin = {
11306
12666
  };
11307
12667
  var index_default = bootstrapPlugin;
11308
12668
  export {
12669
+ actionStateProvider,
11309
12670
  actionsProvider,
11310
12671
  anxietyProvider,
11311
12672
  attachmentsProvider,